diff --git a/.gitignore b/.gitignore index 619105221e..ea0b2e96a5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .oclif.manifest.json /packages/**/oclif.manifest.json /cli +/.nyc_output /coverage /dist /lib @@ -15,7 +16,7 @@ node_modules .idea .vscode **/.nyc_output - +**/coverage/ .pnp.* .yarn/* !.yarn/patches diff --git a/packages/cli/.mocharc.json b/packages/cli/.mocharc.json new file mode 100644 index 0000000000..ecb7fe5f06 --- /dev/null +++ b/packages/cli/.mocharc.json @@ -0,0 +1,9 @@ +{ + "require": [ + "ts-node/register", + "source-map-support/register" + ], + "recursive": true, + "extension": ["ts"], + "timeout": 360000 +} diff --git a/packages/cli/nyc-config.js b/packages/cli/nyc-config.js new file mode 100644 index 0000000000..7d928a5725 --- /dev/null +++ b/packages/cli/nyc-config.js @@ -0,0 +1,33 @@ +module.exports = { + cache: false, + extension: ['.ts'], + exclude: [ + '**/*.d.ts', + '**/*.test.ts', + '**/*.spec.ts', + 'test/**/*', + 'lib/**/*', + 'coverage/**', + '.nyc_output/**', + ], + include: [ + 'src/**/*.ts', + ], + reporter: [ + 'text-summary', + 'html', + 'lcov', + ], + all: true, + 'check-coverage': true, + statements: 80, + branches: 80, + functions: 80, + lines: 80, + require: [ + 'ts-node/register', + 'source-map-support/register', + ], + sourceMap: true, + instrument: true, +} diff --git a/packages/cli/package.json b/packages/cli/package.json index a1e331699d..ef8cc342d9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -82,6 +82,7 @@ }, "devDependencies": { "@heroku-cli/schema": "^1.0.25", + "@istanbuljs/nyc-config-typescript": "^1.0.2", "@oclif/test": "^2.3.28", "@types/ansi-styles": "^3.2.1", "@types/bytes": "^3.1.4", @@ -127,10 +128,11 @@ "read-pkg": "^4.0.1", "rimraf": "5.0.5", "sinon": "^19.0.2", + "source-map-support": "^0.5.21", "std-mocks": "^2.0.0", "strip-ansi": "6.0.1", "tmp": "^0.2.3", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "typescript": "4.8.4" }, "engines": { @@ -378,6 +380,9 @@ "build": "rm -rf lib && tsc", "build:dev": "rm -rf lib && tsc --sourcemap", "lint": "eslint . --ext .ts --config ../../.eslintrc --ignore-path ../../.eslintignore-lib", + "coverage": "nyc --reporter=lcov --reporter=text-summary npm run test", + "coverage:html": "nyc --reporter=html --reporter=text-summary npm run test", + "coverage:check": "nyc --check-coverage --branches 80 --statements 80 --functions 80 --lines 80 npm run test", "postpublish": "rm -f oclif.manifest.json", "prepack": "yarn run build && oclif manifest", "pretest": "tsc -p test --noEmit && cd ../.. && yarn build", @@ -385,7 +390,7 @@ "test:integration": "yarn pretest && mocha --forbid-only \"test/**/*.integration.test.ts\"", "test:smoke": "yarn pretest && mocha --forbid-only \"test/**/smoke.acceptance.test.ts\"", "test:unit:justTest:local": "nyc mocha \"test/**/*.unit.test.ts\"", - "test:unit:justTest:ci": "nyc mocha --forbid-only \"test/**/*.unit.test.ts\"", + "test:unit:justTest:ci": "nyc --reporter=lcov --reporter=text-summary mocha --forbid-only \"test/**/*.unit.test.ts\"", "test": "yarn pretest && yarn test:unit:justTest:ci", "test:local": "yarn pretest && yarn test:unit:justTest:local", "version": "oclif readme --multi && git add README.md ../../docs" diff --git a/yarn.lock b/yarn.lock index 3eaf62e264..5360608f98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2054,6 +2054,17 @@ __metadata: languageName: node linkType: hard +"@istanbuljs/nyc-config-typescript@npm:^1.0.2": + version: 1.0.2 + resolution: "@istanbuljs/nyc-config-typescript@npm:1.0.2" + dependencies: + "@istanbuljs/schema": ^0.1.2 + peerDependencies: + nyc: ">=15" + checksum: df6f9c9b17df8f1d8813f768c11ca31ec125d60bcd82d8273a467022e414d2d686ee80abb7b0f0e3c512b7ed686771fadb7fb5be8881619b9f6cb1f31b86e9f3 + languageName: node + linkType: hard + "@istanbuljs/schema@npm:^0.1.2": version: 0.1.3 resolution: "@istanbuljs/schema@npm:0.1.3" @@ -10326,6 +10337,7 @@ __metadata: "@heroku/heroku-cli-util": ^8.0.13 "@heroku/http-call": ^5.4.0 "@inquirer/prompts": ^5.0.5 + "@istanbuljs/nyc-config-typescript": ^1.0.2 "@oclif/core": ^2.16.0 "@oclif/plugin-commands": 2.2.28 "@oclif/plugin-help": ^5 @@ -10419,6 +10431,7 @@ __metadata: shell-quote: ^1.8.1 sinon: ^19.0.2 smooth-progress: ^1.1.0 + source-map-support: ^0.5.21 sparkline: ^0.2.0 ssh2: ^1.15.0 std-mocks: ^2.0.0 @@ -10428,7 +10441,7 @@ __metadata: term-img: ^4.1.0 tmp: ^0.2.3 true-myth: 2.2.3 - ts-node: ^10.9.1 + ts-node: ^10.9.2 tsheredoc: ^1.0.1 tslib: 1.14.1 tunnel-ssh: 4.1.6 @@ -15383,6 +15396,16 @@ __metadata: languageName: node linkType: hard +"source-map-support@npm:^0.5.21": + version: 0.5.21 + resolution: "source-map-support@npm:0.5.21" + dependencies: + buffer-from: ^1.0.0 + source-map: ^0.6.0 + checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137 + languageName: node + linkType: hard + "source-map@npm:^0.5.7": version: 0.5.7 resolution: "source-map@npm:0.5.7" @@ -15390,7 +15413,7 @@ __metadata: languageName: node linkType: hard -"source-map@npm:^0.6.1": +"source-map@npm:^0.6.0, source-map@npm:^0.6.1": version: 0.6.1 resolution: "source-map@npm:0.6.1" checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2 @@ -16228,6 +16251,44 @@ __metadata: languageName: node linkType: hard +"ts-node@npm:^10.9.2": + version: 10.9.2 + resolution: "ts-node@npm:10.9.2" + dependencies: + "@cspotcode/source-map-support": ^0.8.0 + "@tsconfig/node10": ^1.0.7 + "@tsconfig/node12": ^1.0.7 + "@tsconfig/node14": ^1.0.0 + "@tsconfig/node16": ^1.0.2 + acorn: ^8.4.1 + acorn-walk: ^8.1.1 + arg: ^4.1.0 + create-require: ^1.1.0 + diff: ^4.0.1 + make-error: ^1.1.1 + v8-compile-cache-lib: ^3.0.1 + yn: 3.1.1 + peerDependencies: + "@swc/core": ">=1.2.50" + "@swc/wasm": ">=1.2.50" + "@types/node": "*" + typescript: ">=2.7" + peerDependenciesMeta: + "@swc/core": + optional: true + "@swc/wasm": + optional: true + bin: + ts-node: dist/bin.js + ts-node-cwd: dist/bin-cwd.js + ts-node-esm: dist/bin-esm.js + ts-node-script: dist/bin-script.js + ts-node-transpile-only: dist/bin-transpile.js + ts-script: dist/bin-script-deprecated.js + checksum: fde256c9073969e234526e2cfead42591b9a2aec5222bac154b0de2fa9e4ceb30efcd717ee8bc785a56f3a119bdd5aa27b333d9dbec94ed254bd26f8944c67ac + languageName: node + linkType: hard + "tsconfig-paths@npm:^3.14.1": version: 3.14.2 resolution: "tsconfig-paths@npm:3.14.2"