Skip to content

Commit

Permalink
refactor sdk and cli as separate projects
Browse files Browse the repository at this point in the history
  • Loading branch information
0xshiba1 committed Oct 30, 2024
1 parent 0470f8d commit a473671
Show file tree
Hide file tree
Showing 15 changed files with 830 additions and 599 deletions.
38 changes: 36 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
build
suilend-cli/node_modules
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
**node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
Binary file added bun.lockb
Binary file not shown.
38 changes: 38 additions & 0 deletions cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"ignorePatterns": ["_generated"],
"extends": [
"prettier",
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended"
],
"plugins": ["prettier"],
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"prettier/prettier": ["error"],
"import/order": [
"error",
{
"pathGroups": [],
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object",
"type"
],
"newlines-between": "always",
"alphabetize": { "order": "asc", "caseInsensitive": true }
}
],
"sort-imports": [
"error",
{
"ignoreDeclarationSort": true
}
]
}
}
38 changes: 38 additions & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

dist/
38 changes: 38 additions & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@suilend/springsui-cli",
"version": "1.0.0",
"private": true,
"description": "A CLI for interacting with the SpringSui program",
"author": "Suilend",
"license": "MIT",
"main": "./src/index.ts",
"exports": {
".": "./src/index.js"
},
"types": "./src/index.ts",
"scripts": {
"build": "rm -rf ./dist && bun tsc",
"eslint": "eslint --fix \"./src/**/*.ts\"",
"prettier": "prettier --write \"./src/**/*\"",
"lint": "bun eslint && bun prettier && bun tsc",
"release": "bun run build && bun ts-node ./prepublish.ts && cd ./dist && npm publish --access public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/solendprotocol/liquid-staking.git"
},
"bugs": {
"url": "https://github.com/solendprotocol/liquid-staking/issues"
},
"dependencies": {
"@mysten/bcs": "1.1.0",
"@mysten/sui": "1.12.0",
"commander": "^12.1.0",
"uuid": "^9.0.1"
},
"devDependencies": {
"@types/node": "^20.12.7",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
29 changes: 29 additions & 0 deletions cli/prepublish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import fs from "fs";

// 1. Update package.json
import packageJson from "./package.json";
const newPackageJson = Object.assign({}, packageJson);

newPackageJson["private"] = false;
newPackageJson["main"] = "./index.js";

const exportsMap: Record<string, string> = {
".": "./index.js",
};
const files = (
fs.readdirSync("./dist/", { recursive: true }) as string[]
).filter((file) => file !== "index.js" && file.endsWith(".js"));
for (const file of files) {
const fileName = file.substring(
0,
file.endsWith("index.js")
? file.lastIndexOf("/index.js")
: file.lastIndexOf(".js"),
);
exportsMap[`./${fileName}`] = `./${file}`;
}
newPackageJson["exports"] = exportsMap as any;

newPackageJson["types"] = "./index.js";

fs.writeFileSync("./dist/package.json", JSON.stringify(newPackageJson), "utf8");
Loading

0 comments on commit a473671

Please sign in to comment.