From ba4bebb8e6cc65632c666653f5c6db8fcadf57b8 Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Thu, 12 Sep 2024 17:46:38 +0500 Subject: [PATCH 01/11] test: husky integration check --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c4e0c08..ec8ee9f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint src", - "tsc": "bash -c tsc -p tsconfig.json", + "tsc": "bash -c tsc --noEmit -p tsconfig.json", "docs:build": "typedoc src/index.ts --out out", "docs:serve": "npm run docs:build && serve out" }, @@ -23,10 +23,12 @@ "license": "ISC", "lint-staged": { "src/**/*.{ts,tsx}": [ + "npm run format", "npm run lint", "npm run tsc" ], "src/**/*.js": [ + "npm run format", "npm run lint" ] }, From c6ec8b9c0ab571fdd3dd09148e79e56626dac6f1 Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Tue, 17 Sep 2024 05:54:54 +0500 Subject: [PATCH 02/11] test: husky integration check --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ec8ee9f..04adaf1 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,9 @@ "prepare": "husky", "build": "tsc -p tsconfig.build.json", "test": "vitest run", - "format": "prettier --write .", - "format:check": "prettier --check .", + "format": "prettier --write 'src/**/*.{ts,json}'", "lint": "eslint src", - "tsc": "bash -c tsc --noEmit -p tsconfig.json", + "tsc": "bash -c tsc -p tsconfig.json", "docs:build": "typedoc src/index.ts --out out", "docs:serve": "npm run docs:build && serve out" }, From b3d638d2db8049c4fc379bcd8a146f9eaeb508fa Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Tue, 17 Sep 2024 05:55:39 +0500 Subject: [PATCH 03/11] build: add ci-checks in github workflow --- .github/workflows/main.yml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f91a64..490e3c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,25 +9,47 @@ on: - main jobs: - ci: + lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - + - uses: actions/checkout@v2 - name: Install Dependencies - run: npm ci - + run: npm install - name: Run ESLint run: npm run lint + prettier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: npm install - name: Run Prettier Formatter - run: npm run format:check + run: npm run format + typescript: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: npm install - name: Check TypeScript Types run: npm run tsc + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: npm install - name: Run Tests run: npm run test + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Dependencies + run: npm install - name: Build Application run: npm run build From caff143216e4efb806d8aa7ba5d4a3621b55a5f5 Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Tue, 17 Sep 2024 05:56:46 +0500 Subject: [PATCH 04/11] testing check failure --- src/client.test.ts | 3 ++- src/client.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client.test.ts b/src/client.test.ts index b100357..98cb358 100644 --- a/src/client.test.ts +++ b/src/client.test.ts @@ -66,7 +66,8 @@ describe("Check installation", () => { extension.postExtension(); const response = await client.isExtensionInstalled(); - expect(response).toEqual(extension.extensionId); + // extension.extensionId + expect(response).toEqual(1); }); test("Should return false if not installed", async () => { diff --git a/src/client.ts b/src/client.ts index 047a63c..074af35 100644 --- a/src/client.ts +++ b/src/client.ts @@ -335,8 +335,9 @@ export class ExtensionClient { * * @see Template for [Vendor Loaded JSON](https://api.npoint.io/52639f849bb31823a8c0) */ - configureVendor = async (payload?: ConfigureVendorArgs): Promise => { - return this.sendMessage("/signify/configure-vendor", { payload }); + configureVendor = async (payload?: ConfigureVendorArgs): Promise => { + this.sendMessage("/signify/configure-vendor", { payload }); + return "str"; }; /** From 3237177ab53d25746a888ad0606cc461037fed9b Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Thu, 12 Sep 2024 18:23:54 +0500 Subject: [PATCH 05/11] testing check failure --- src/client.test.ts | 3 +-- src/client.ts | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/client.test.ts b/src/client.test.ts index 98cb358..b100357 100644 --- a/src/client.test.ts +++ b/src/client.test.ts @@ -66,8 +66,7 @@ describe("Check installation", () => { extension.postExtension(); const response = await client.isExtensionInstalled(); - // extension.extensionId - expect(response).toEqual(1); + expect(response).toEqual(extension.extensionId); }); test("Should return false if not installed", async () => { diff --git a/src/client.ts b/src/client.ts index 074af35..047a63c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -335,9 +335,8 @@ export class ExtensionClient { * * @see Template for [Vendor Loaded JSON](https://api.npoint.io/52639f849bb31823a8c0) */ - configureVendor = async (payload?: ConfigureVendorArgs): Promise => { - this.sendMessage("/signify/configure-vendor", { payload }); - return "str"; + configureVendor = async (payload?: ConfigureVendorArgs): Promise => { + return this.sendMessage("/signify/configure-vendor", { payload }); }; /** From 801604babad81fde6d66279343dc86f3adac6b2d Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Thu, 12 Sep 2024 23:15:46 +0500 Subject: [PATCH 06/11] Apply suggestions from Daniel in code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel Lenksjö <5889538+lenkan@users.noreply.github.com> --- .github/workflows/main.yml | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 490e3c5..1d3a519 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,9 +21,9 @@ jobs: prettier: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Dependencies - run: npm install + run: npm ci - name: Run Prettier Formatter run: npm run format diff --git a/package.json b/package.json index 04adaf1..bf69339 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "prepare": "husky", "build": "tsc -p tsconfig.build.json", "test": "vitest run", - "format": "prettier --write 'src/**/*.{ts,json}'", + "format": "prettier --write .", "lint": "eslint src", "tsc": "bash -c tsc -p tsconfig.json", "docs:build": "typedoc src/index.ts --out out", From 8a1c371ec6e31f7059a74907fc53c9fb0ae1d211 Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Thu, 12 Sep 2024 23:30:25 +0500 Subject: [PATCH 07/11] fix: add single job for main.yml --- .github/workflows/main.yml | 32 +++++--------------------------- package.json | 2 +- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1d3a519..904f4e5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,47 +9,25 @@ on: - main jobs: - lint: + ci: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Install Dependencies - run: npm install + run: npm ci + - name: Run ESLint run: npm run lint - prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install Dependencies - run: npm ci - name: Run Prettier Formatter run: npm run format - typescript: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Dependencies - run: npm install - name: Check TypeScript Types run: npm run tsc - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Dependencies - run: npm install - name: Run Tests run: npm run test - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Dependencies - run: npm install - name: Build Application run: npm run build diff --git a/package.json b/package.json index bf69339..04adaf1 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "prepare": "husky", "build": "tsc -p tsconfig.build.json", "test": "vitest run", - "format": "prettier --write .", + "format": "prettier --write 'src/**/*.{ts,json}'", "lint": "eslint src", "tsc": "bash -c tsc -p tsconfig.json", "docs:build": "typedoc src/index.ts --out out", From c9c37f7c1acdf7ef61b06a34a3581ee944f4e4c0 Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Thu, 12 Sep 2024 23:42:47 +0500 Subject: [PATCH 08/11] feat: add prettierignore file --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 04adaf1..bf69339 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "prepare": "husky", "build": "tsc -p tsconfig.build.json", "test": "vitest run", - "format": "prettier --write 'src/**/*.{ts,json}'", + "format": "prettier --write .", "lint": "eslint src", "tsc": "bash -c tsc -p tsconfig.json", "docs:build": "typedoc src/index.ts --out out", From c2ce487d090e1b89134643f23409c8f853608e45 Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Fri, 13 Sep 2024 17:39:28 +0500 Subject: [PATCH 09/11] fix: format check instead of overwrite --- .github/workflows/main.yml | 2 +- package.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 904f4e5..6f91a64 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: run: npm run lint - name: Run Prettier Formatter - run: npm run format + run: npm run format:check - name: Check TypeScript Types run: npm run tsc diff --git a/package.json b/package.json index bf69339..c4e0c08 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "build": "tsc -p tsconfig.build.json", "test": "vitest run", "format": "prettier --write .", + "format:check": "prettier --check .", "lint": "eslint src", "tsc": "bash -c tsc -p tsconfig.json", "docs:build": "typedoc src/index.ts --out out", @@ -22,12 +23,10 @@ "license": "ISC", "lint-staged": { "src/**/*.{ts,tsx}": [ - "npm run format", "npm run lint", "npm run tsc" ], "src/**/*.js": [ - "npm run format", "npm run lint" ] }, From 38df34aaa236c1dd587113287705165f9746f1ba Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Fri, 13 Sep 2024 18:10:10 +0500 Subject: [PATCH 10/11] feat: add npm publish github action workflow --- .github/workflows/publish-npm.yml | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/publish-npm.yml diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..7a41ec5 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,61 @@ +name: Publish NPM + +on: + workflow_dispatch: + inputs: + dry-run: + type: boolean + default: true + description: Dry run publish + dist-tag: + type: choice + options: + - dev + - latest + default: dev + description: Npm dist tag +jobs: + publish: + name: Publish NPM + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci --ignore-scripts + + - name: Set package name from vars + if: ${{ vars.NPM_PACKAGE_NAME }} + run: | + cat package.json | jq -r '.name = "${{ vars.NPM_PACKAGE_NAME }}"' > package.json.tmp + mv package.json.tmp package.json + + - name: Set version from commit + if: ${{ inputs.dist-tag == 'dev' }} + run: | + npm version --no-git-tag-version $(cat package.json | jq .version -r)-dev.$(git rev-parse --short HEAD) + + - name: Create git tag + run: git tag $(cat package.json | jq .version -r) + + - name: Publish dev package (Dry run) + if: ${{ inputs.dry-run == true }} + run: npm publish --tag "${{ inputs.dist-tag }}" --dry-run + + - name: Publish dev package + if: ${{ inputs.dry-run == false }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + npm publish --tag "${{ inputs.dist-tag }}" + git tag v$(cat package.json | jq .version -r) + git push origin v$(cat package.json | jq .version -r) From 03fe76f30962014a1df96cf37f2cba92354509ee Mon Sep 17 00:00:00 2001 From: Hunain Bin Sajid Date: Fri, 13 Sep 2024 18:13:25 +0500 Subject: [PATCH 11/11] format: publish-npm file --- .github/workflows/publish-npm.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 7a41ec5..73a88f6 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -18,7 +18,7 @@ jobs: publish: name: Publish NPM permissions: - contents: write + contents: write runs-on: ubuntu-latest steps: - name: Checkout repo @@ -26,9 +26,9 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: '20' - cache: 'npm' - registry-url: 'https://registry.npmjs.org' + node-version: "20" + cache: "npm" + registry-url: "https://registry.npmjs.org" - name: Install dependencies run: npm ci --ignore-scripts @@ -56,6 +56,6 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | - npm publish --tag "${{ inputs.dist-tag }}" - git tag v$(cat package.json | jq .version -r) - git push origin v$(cat package.json | jq .version -r) + npm publish --tag "${{ inputs.dist-tag }}" + git tag v$(cat package.json | jq .version -r) + git push origin v$(cat package.json | jq .version -r)