From ecabcf525a637add8295d5e355e455ca2f91fb7d Mon Sep 17 00:00:00 2001 From: SeiyaKobayashi Date: Wed, 21 Aug 2024 16:15:31 +0900 Subject: [PATCH 1/4] Fix typos: npm --> yarn --- .github/workflows/check-core.yml | 16 ++++++++-------- .github/workflows/check-v1.yml | 10 +++++----- .npmrc | 1 - README.md | 6 +++--- package.json | 8 ++++---- packages/core/README.md | 2 +- packages/core/package.json | 3 +++ packages/v1/README.md | 4 ++-- packages/v1/examples/README.md | 8 ++++---- packages/v1/package.json | 3 +++ yarnrc.yml | 3 +++ 11 files changed, 36 insertions(+), 28 deletions(-) delete mode 100644 .npmrc create mode 100644 yarnrc.yml diff --git a/.github/workflows/check-core.yml b/.github/workflows/check-core.yml index f307fc4..303e5d4 100644 --- a/.github/workflows/check-core.yml +++ b/.github/workflows/check-core.yml @@ -26,14 +26,14 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 - - name: Install Dependencies - run: yarn + - name: Install dependencies + run: yarn --frozen-lockfile - name: Compile - run: npm run compile + run: yarn run compile - name: Lint - run: npm run lint:dry-run + run: yarn run lint:dry-run - name: Format - run: npm run format:dry-run + run: yarn run format:dry-run test: runs-on: ubuntu-latest @@ -43,7 +43,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 - - name: Install Dependencies - run: yarn + - name: Install dependencies + run: yarn --frozen-lockfile - name: Run tests - run: npm run test + run: yarn run test diff --git a/.github/workflows/check-v1.yml b/.github/workflows/check-v1.yml index b4eb799..4e3dae8 100644 --- a/.github/workflows/check-v1.yml +++ b/.github/workflows/check-v1.yml @@ -26,11 +26,11 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 - - name: Install Dependencies - run: yarn + - name: Install dependencies + run: yarn --frozen-lockfile - name: Compile - run: npm run compile:sdk + run: yarn run compile:sdk - name: Lint - run: npm run lint:dry-run + run: yarn run lint:dry-run - name: Format - run: npm run format:dry-run + run: yarn run format:dry-run diff --git a/.npmrc b/.npmrc deleted file mode 100644 index c42da84..0000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict = true diff --git a/README.md b/README.md index 3b9646a..04aa476 100644 --- a/README.md +++ b/README.md @@ -36,12 +36,12 @@ $ cd sdks $ yarn ``` -### NPM Scripts +### Yarn Scripts -To run npm scripts defined in workspaces, run the following. +To run yarn scripts defined in workspaces, run the following. ```sh -$ npm run -w +$ yarn workspace run ``` ### Dependencies diff --git a/package.json b/package.json index 36aef3e..ebbad94 100644 --- a/package.json +++ b/package.json @@ -25,16 +25,16 @@ }, "lint-staged": { "packages/core/**/*.{ts,js}": [ - "npm run -w @jpyc/sdk-core lint" + "yarn workspace @jpyc/sdk-core run lint" ], "packages/core/**/*.{ts,js,md,json}": [ - "npm run -w @jpyc/sdk-core format" + "yarn workspace @jpyc/sdk-core run format" ], "packages/v1/**/*.{ts,js}": [ - "npm run -w @jpyc/sdk-v1 lint" + "yarn workspace @jpyc/sdk-v1 run lint" ], "packages/v1/**/*.{ts,js,md,json}": [ - "npm run -w @jpyc/sdk-v1 format" + "yarn workspace @jpyc/sdk-v1 run format" ] } } diff --git a/packages/core/README.md b/packages/core/README.md index 896ebc0..200f175 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -4,7 +4,7 @@ JPYC core SDK implements a set of constants, types and functions, commonly used ## 🤖 Available Commands -The following commands are available as npm scripts for local development & testing. +The following commands are available as yarn scripts for local development & testing. | Command | Description | | ---------------: | :----------------------------------- | diff --git a/packages/core/package.json b/packages/core/package.json index b9ced9e..98d696a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -4,6 +4,9 @@ "repository": "https://github.com/jcam1/sdks.git", "license": "MIT", "version": "1.0.0", + "publishConfig": { + "access": "public" + }, "engines": { "node": "^20.12.0", "yarn": "^1.22.22" diff --git a/packages/v1/README.md b/packages/v1/README.md index 8e8f954..990ea8f 100644 --- a/packages/v1/README.md +++ b/packages/v1/README.md @@ -8,7 +8,7 @@ Please follow the following steps to configure our SDK. #### 1. Install Packages -Install npm packages. +Install packages. ```sh # yarn @@ -78,7 +78,7 @@ For your reference, we provide code examples in `examples` directory. Please fol ## 🤖 Available Commands -The following commands are available as npm scripts for local development & testing. +The following commands are available as yarn scripts for local development & testing. | Command | Description | | ----------------------------: | :------------------------------------------------------ | diff --git a/packages/v1/examples/README.md b/packages/v1/examples/README.md index fc263db..9c73f1a 100644 --- a/packages/v1/examples/README.md +++ b/packages/v1/examples/README.md @@ -7,7 +7,7 @@ We provide code examples that use JPYC V1 SDK as an interface to locally-deploye Run the following command to start running local Hardhat network and its accompanying node. ```sh -$ npm run node +$ yarn run node ``` ### 2. Deploy Contracts @@ -15,7 +15,7 @@ $ npm run node **Open a different window** and run the following command to deploy JPYCv2 contracts to the local network. Once successfully deployed, a new directory will be created, and you can find deployed contract addresses at `/packages/v1/ignition/deployments/chain-31337/deployed_addresses.json`. ```sh -$ npm run deploy +$ yarn run deploy ``` ### 3. Set Environment Variables @@ -26,7 +26,7 @@ Run the following commands, and edit the generated `.env` file accordingly. Set # cd into this directory $ cd /packages/v1 # copy `.env.example` to `.env` -$ npm run env +$ yarn run env ``` ### 4. Run Code Examples @@ -48,5 +48,5 @@ Run the following commands to execute our code examples. For example, to mint JPYC tokens on local network, run the following. ```sh -$ npm run mint +$ yarn run mint ``` diff --git a/packages/v1/package.json b/packages/v1/package.json index 2896494..90f0e0f 100644 --- a/packages/v1/package.json +++ b/packages/v1/package.json @@ -4,6 +4,9 @@ "repository": "https://github.com/jcam1/sdks.git", "license": "MIT", "version": "1.0.0", + "publishConfig": { + "access": "public" + }, "engines": { "node": "^20.12.0", "yarn": "^1.22.22" diff --git a/yarnrc.yml b/yarnrc.yml new file mode 100644 index 0000000..527fbe1 --- /dev/null +++ b/yarnrc.yml @@ -0,0 +1,3 @@ +npmAlwaysAuth: true +npmAuthToken: "${NODE_AUTH_TOKEN}" +npmPublishRegistry: "https://registry.npmjs.org" From 9d495465a3da5918031f453bdcdcce973041a853 Mon Sep 17 00:00:00 2001 From: SeiyaKobayashi Date: Wed, 21 Aug 2024 16:31:25 +0900 Subject: [PATCH 2/4] Apply formatter to root-level directories --- .github/pull_request_template.md | 2 +- .github/workflows/check-core.yml | 4 ++-- .github/workflows/check-v1.yml | 4 ++-- .prettierrc | 9 +++++++++ README.md | 14 +++++++------- package.json | 23 +++++++++++++++++------ yarn.lock | 5 +++++ yarnrc.yml | 4 ++-- 8 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 .prettierrc diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6c54f05..418641e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,7 +8,7 @@ -- +- ## 📚 References diff --git a/.github/workflows/check-core.yml b/.github/workflows/check-core.yml index 303e5d4..fa19b49 100644 --- a/.github/workflows/check-core.yml +++ b/.github/workflows/check-core.yml @@ -10,8 +10,8 @@ on: - main - develop paths: - - "packages/core/**" - - ".github/workflows/check-core.yml" + - 'packages/core/**' + - '.github/workflows/check-core.yml' defaults: run: diff --git a/.github/workflows/check-v1.yml b/.github/workflows/check-v1.yml index 4e3dae8..c49984d 100644 --- a/.github/workflows/check-v1.yml +++ b/.github/workflows/check-v1.yml @@ -10,8 +10,8 @@ on: - main - develop paths: - - "packages/v1/**" - - ".github/workflows/check-v1.yml" + - 'packages/v1/**' + - '.github/workflows/check-v1.yml' defaults: run: diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..7bf3551 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "printWidth": 100, + "semi": true, + "singleQuote": true, + "quoteProps": "consistent", + "trailingComma": "all", + "bracketSpacing": true, + "arrowParens": "always" +} diff --git a/README.md b/README.md index 04aa476..a692907 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,18 @@ Monorepo for JPYC Node SDKs. Please refer to `README`s of each SDK for version specific details. -| SDK | `README` | -|----:|:---------| +| SDK | `README` | +| -----: | :----------------------------------------- | | `core` | [packages/core](./packages/core/README.md) | -| `v1` | [packages/v1](./packages/v1/README.md) | +| `v1` | [packages/v1](./packages/v1/README.md) | ## 🔨 Development ### Git Submodules -This repo uses [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to be in sync with [JPYCv2](https://github.com/jcam1/JPYCv2/tree/main) repo. +This repo uses [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to be in sync with [JPYCv2](https://github.com/jcam1/JPYCv2/tree/main) repo. -To include submodules when cloning the repo, add `--recursive` option like below. +To include submodules when cloning the repo, add `--recursive` option like below. ```sh $ git clone --recursive https://github.com/jcam1/sdks.git @@ -38,7 +38,7 @@ $ yarn ### Yarn Scripts -To run yarn scripts defined in workspaces, run the following. +To run yarn scripts defined in workspaces, run the following. ```sh $ yarn workspace run @@ -46,7 +46,7 @@ $ yarn workspace run ### Dependencies -To add dependencies, run one of the following. To prevent unexpected behaviors, always pin the exact versions of the dependencies to be installed. +To add dependencies, run one of the following. To prevent unexpected behaviors, always pin the exact versions of the dependencies to be installed. ```sh # Add dependencies to the specified workspace diff --git a/package.json b/package.json index ebbad94..6e4e085 100644 --- a/package.json +++ b/package.json @@ -17,23 +17,34 @@ "packages/*" ], "scripts": { - "prepare": "husky" + "prepare": "husky", + "format": "prettier --write", + "format:dry-run": "prettier --check" }, "devDependencies": { "husky": "9.0.11", - "lint-staged": "15.2.9" + "lint-staged": "15.2.9", + "prettier": "3.3.3" }, "lint-staged": { + "*.{md,json,yml}": [ + "yarn run format" + ], + ".github/**/*.{md,json,yml}": [ + "yarn run format" + ], "packages/core/**/*.{ts,js}": [ - "yarn workspace @jpyc/sdk-core run lint" + "yarn workspace @jpyc/sdk-core run lint", + "yarn workspace @jpyc/sdk-core run format" ], - "packages/core/**/*.{ts,js,md,json}": [ + "packages/core/**/*.{md,json}": [ "yarn workspace @jpyc/sdk-core run format" ], "packages/v1/**/*.{ts,js}": [ - "yarn workspace @jpyc/sdk-v1 run lint" + "yarn workspace @jpyc/sdk-v1 run lint", + "yarn workspace @jpyc/sdk-v1 run format" ], - "packages/v1/**/*.{ts,js,md,json}": [ + "packages/v1/**/*.{md,json}": [ "yarn workspace @jpyc/sdk-v1 run format" ] } diff --git a/yarn.lock b/yarn.lock index 93cd9b3..4b77a6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5252,6 +5252,11 @@ prettier@3.3.2: resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.2.tgz#03ff86dc7c835f2d2559ee76876a3914cec4a90a" integrity sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA== +prettier@3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105" + integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew== + pretty-format@^29.0.0, pretty-format@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812" diff --git a/yarnrc.yml b/yarnrc.yml index 527fbe1..8a2a5eb 100644 --- a/yarnrc.yml +++ b/yarnrc.yml @@ -1,3 +1,3 @@ npmAlwaysAuth: true -npmAuthToken: "${NODE_AUTH_TOKEN}" -npmPublishRegistry: "https://registry.npmjs.org" +npmAuthToken: '${NODE_AUTH_TOKEN}' +npmPublishRegistry: 'https://registry.npmjs.org' From fb3271edcb4273264601a32e739be97c86fb0b22 Mon Sep 17 00:00:00 2001 From: SeiyaKobayashi Date: Wed, 21 Aug 2024 16:45:27 +0900 Subject: [PATCH 3/4] Modify workflows & precommit hooks --- .github/workflows/check-core.yml | 1 - .github/workflows/check-root.yml | 32 ++++++++++++++++++++++++++++++++ .github/workflows/check-v1.yml | 1 - package.json | 7 +++++-- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/check-root.yml diff --git a/.github/workflows/check-core.yml b/.github/workflows/check-core.yml index fa19b49..d27b9bd 100644 --- a/.github/workflows/check-core.yml +++ b/.github/workflows/check-core.yml @@ -11,7 +11,6 @@ on: - develop paths: - 'packages/core/**' - - '.github/workflows/check-core.yml' defaults: run: diff --git a/.github/workflows/check-root.yml b/.github/workflows/check-root.yml new file mode 100644 index 0000000..d6a7a66 --- /dev/null +++ b/.github/workflows/check-root.yml @@ -0,0 +1,32 @@ +name: static checks for core package + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + paths: + - '.github/**' + - 'docs/**' + - 'README.md' + - 'yarnrc.yml' + +defaults: + run: + working-directory: ./ + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Format + run: yarn run format:dry-run .github docs README.md yarnrc.yml diff --git a/.github/workflows/check-v1.yml b/.github/workflows/check-v1.yml index c49984d..5b9b7c0 100644 --- a/.github/workflows/check-v1.yml +++ b/.github/workflows/check-v1.yml @@ -11,7 +11,6 @@ on: - develop paths: - 'packages/v1/**' - - '.github/workflows/check-v1.yml' defaults: run: diff --git a/package.json b/package.json index 6e4e085..014cd62 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,13 @@ }, "lint-staged": { "*.{md,json,yml}": [ - "yarn run format" + "yarn run format README.md yarnrc.yml" ], ".github/**/*.{md,json,yml}": [ - "yarn run format" + "yarn run format .github" + ], + ".docs/**/*.{md,json,yml}": [ + "yarn run format docs" ], "packages/core/**/*.{ts,js}": [ "yarn workspace @jpyc/sdk-core run lint", From f7fcc7f16d009f83b28a353df7094493665c7296 Mon Sep 17 00:00:00 2001 From: SeiyaKobayashi Date: Wed, 21 Aug 2024 16:47:41 +0900 Subject: [PATCH 4/4] Fix workflow --- .github/workflows/check-root.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-root.yml b/.github/workflows/check-root.yml index d6a7a66..02acee2 100644 --- a/.github/workflows/check-root.yml +++ b/.github/workflows/check-root.yml @@ -1,4 +1,4 @@ -name: static checks for core package +name: static checks for root-level directories & files on: push: @@ -28,5 +28,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 + - name: Install dependencies + run: yarn --frozen-lockfile - name: Format run: yarn run format:dry-run .github docs README.md yarnrc.yml