From eca9420eb7099ecc2695e07fcda12f4b15fb2c1c Mon Sep 17 00:00:00 2001 From: narol Date: Sat, 1 Jun 2024 22:20:20 +0800 Subject: [PATCH] chore: ci debug --- .github/workflows/main.yml | 1 + package-lock.json | 18 ++++++++++++++---- package.json | 6 ++++-- src/platforms/npm-package/index.spec.ts | 2 +- src/platforms/workspaces/yarn/index.spec.ts | 8 ++++---- src/platforms/workspaces/yarn/index.ts | 20 +++++++++++--------- tsconfig.build.json | 4 ++++ tsconfig.json | 4 ++-- 8 files changed, 41 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d18e887..2d7f2fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 16 + - run: npm install - run: npm run test:coverage - run: npm run test:ci diff --git a/package-lock.json b/package-lock.json index 95c9a29..2dcbe92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,12 +8,12 @@ "name": "sdp-analyzer", "version": "1.0.0", "dependencies": { - "@types/node-fetch": "^2.6.11", "cheerio": "^1.0.0-rc.12", "commander": "^12.1.0", "fast-glob": "^3.3.2", "jsonfile": "^6.1.0", - "node-fetch": "^2.x" + "node-fetch": "^2.x", + "tslib": "^2.3.1" }, "bin": { "sdp-analyzer": "dist/cli/index.js" @@ -26,6 +26,7 @@ "@types/jest": "^27.4.1", "@types/jsonfile": "^6.1.4", "@types/node": "^18.0.0", + "@types/node-fetch": "^2.6.11", "@types/supertest": "^2.0.12", "@typescript-eslint/eslint-plugin": "^5.17.0", "@typescript-eslint/parser": "^5.17.0", @@ -1998,6 +1999,7 @@ "version": "18.19.33", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.33.tgz", "integrity": "sha512-NR9+KrpSajr2qBVp/Yt5TU/rp+b5Mayi3+OlMlcg2cVCfRmcG5PWZ7S4+MG9PZ5gWBoc9Pd0BKSRViuBCRPu0A==", + "dev": true, "dependencies": { "undici-types": "~5.26.4" } @@ -2006,6 +2008,7 @@ "version": "2.6.11", "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.11.tgz", "integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==", + "dev": true, "dependencies": { "@types/node": "*", "form-data": "^4.0.0" @@ -2015,6 +2018,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -2587,7 +2591,8 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true }, "node_modules/available-typed-arrays": { "version": "1.0.7", @@ -3168,6 +3173,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -3581,6 +3587,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, "engines": { "node": ">=0.4.0" } @@ -8710,6 +8717,7 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, "engines": { "node": ">= 0.6" } @@ -8718,6 +8726,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, "dependencies": { "mime-db": "1.52.0" }, @@ -10931,7 +10940,8 @@ "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true }, "node_modules/universalify": { "version": "2.0.1", diff --git a/package.json b/package.json index 58c8fe6..5191dcd 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "sdp-analyzer", + "type": "module", "main": "dist/index.js", "bin": "dist/cli/index.js", "types": "dist/main.d.ts", @@ -16,14 +17,15 @@ "format:check": "prettier \"./**\" --ignore-unknown --check" }, "dependencies": { - "@types/node-fetch": "^2.6.11", "cheerio": "^1.0.0-rc.12", "commander": "^12.1.0", "fast-glob": "^3.3.2", "jsonfile": "^6.1.0", - "node-fetch": "^2.x" + "node-fetch": "^2.x", + "tslib": "^2.3.1" }, "devDependencies": { + "@types/node-fetch": "^2.6.11", "@commitlint/cli": "^17.0.0", "@commitlint/config-conventional": "^17.0.0", "@jest/globals": "^28.0.0", diff --git a/src/platforms/npm-package/index.spec.ts b/src/platforms/npm-package/index.spec.ts index 9edb3fe..a4d3146 100644 --- a/src/platforms/npm-package/index.spec.ts +++ b/src/platforms/npm-package/index.spec.ts @@ -4,7 +4,7 @@ */ import { readNpmPackageDependencies, analyze } from './index'; -describe('Workspaces Test', () => { +describe('Npm pacakge Test', () => { it('should not read a non-existent package', async () => { await expect(readNpmPackageDependencies('is-a-non-existent-package')).rejects.toEqual( new Error('Cannot read is-a-non-existent-package.'), diff --git a/src/platforms/workspaces/yarn/index.spec.ts b/src/platforms/workspaces/yarn/index.spec.ts index 9d687f6..6710054 100644 --- a/src/platforms/workspaces/yarn/index.spec.ts +++ b/src/platforms/workspaces/yarn/index.spec.ts @@ -2,7 +2,7 @@ * This is a sample test suite. * Replace this with your implementation. */ -import { readWorkspacesDependencies, analyzeYarnWorkspaces } from './index'; +import { readWorkspacesDependencies, analyze } from './index'; describe('Workspaces Test', () => { it('should be that the package.json cannot be found', () => { @@ -11,9 +11,9 @@ describe('Workspaces Test', () => { }).toThrow(new Error(`Cannot find package.json on ./error-path.`)); }); it('should be that the package.json can be found', () => { - expect(readWorkspacesDependencies('./src/platforms/yarn/fixture')).toMatchSnapshot(); + expect(readWorkspacesDependencies('./src/platforms/workspaces/yarn/fixture')).toMatchSnapshot(); }); - it('should return a dep tree', () => { - expect(analyzeYarnWorkspaces('./src/platforms/yarn/fixture')).toMatchSnapshot(); + it('should return a dep tree', async () => { + await expect(analyze('./src/platforms/workspaces/yarn/fixture')).resolves.toMatchSnapshot(); }); }); diff --git a/src/platforms/workspaces/yarn/index.ts b/src/platforms/workspaces/yarn/index.ts index 41256d2..690589b 100644 --- a/src/platforms/workspaces/yarn/index.ts +++ b/src/platforms/workspaces/yarn/index.ts @@ -46,15 +46,17 @@ export async function analyze(packagePath: string) { fanOut: v.dependencies ? Object.keys(v.dependencies).length : 0, }; }); - return deps.map(dep => { - const stablility = evaluate(dep.fanOut, dep.fanIn); - return { - ...dep, - instable: stablility, - label: getStablityLabel(stablility), - }; - }); + return Promise.resolve( + deps.map(dep => { + const stablility = evaluate(dep.fanOut, dep.fanIn); + return { + ...dep, + instable: stablility, + label: getStablityLabel(stablility), + }; + }), + ); } catch (error) { - throw error; + return Promise.reject(new Error(`Cannot analyze ${packagePath}`)); } } diff --git a/tsconfig.build.json b/tsconfig.build.json index 83cdf40..bce8f8e 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,8 @@ { + "compilerOptions": { + "target": "es5", + "module": "commonjs", + }, "extends": "./tsconfig.json", "exclude": [ "dist", diff --git a/tsconfig.json b/tsconfig.json index 6e88b2f..fa016c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "target": "es5", - "module": "commonjs", + "target": "ESNext", + "module": "ESNext", "moduleResolution": "Node", "allowSyntheticDefaultImports": true, "esModuleInterop": true,