skuba 4.4.0 → 5.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/tsconfig.json +1 -0
- package/jest/moduleNameMapper.js +50 -78
- package/jest/moduleNameMapper.test.ts +4 -14
- package/jest/transform.js +10 -1
- package/jest/tsConfig.js +26 -0
- package/lib/api/buildkite/annotate.js +46 -33
- package/lib/api/buildkite/annotate.js.map +7 -1
- package/lib/api/buildkite/index.js +31 -7
- package/lib/api/buildkite/index.js.map +7 -1
- package/lib/api/buildkite/md.js +31 -8
- package/lib/api/buildkite/md.js.map +7 -1
- package/lib/api/git/commit.js +45 -17
- package/lib/api/git/commit.js.map +7 -1
- package/lib/api/git/commitAllChanges.js +57 -27
- package/lib/api/git/commitAllChanges.js.map +7 -1
- package/lib/api/git/currentBranch.js +50 -28
- package/lib/api/git/currentBranch.js.map +7 -1
- package/lib/api/git/getChangedFiles.js +49 -27
- package/lib/api/git/getChangedFiles.js.map +7 -1
- package/lib/api/git/index.js +54 -22
- package/lib/api/git/index.js.map +7 -1
- package/lib/api/git/log.js +63 -42
- package/lib/api/git/log.js.map +7 -1
- package/lib/api/git/pull.js +62 -31
- package/lib/api/git/pull.js.map +7 -1
- package/lib/api/git/push.js +63 -31
- package/lib/api/git/push.js.map +7 -1
- package/lib/api/git/remote.js +59 -56
- package/lib/api/git/remote.js.map +7 -1
- package/lib/api/git/reset.js +55 -27
- package/lib/api/git/reset.js.map +7 -1
- package/lib/api/git/statusMatrix.js +46 -13
- package/lib/api/git/statusMatrix.js.map +7 -1
- package/lib/api/github/checkRun.js +70 -79
- package/lib/api/github/checkRun.js.map +7 -1
- package/lib/api/github/environment.js +40 -33
- package/lib/api/github/environment.js.map +7 -1
- package/lib/api/github/index.js +47 -17
- package/lib/api/github/index.js.map +7 -1
- package/lib/api/github/issueComment.js +73 -81
- package/lib/api/github/issueComment.js.map +7 -1
- package/lib/api/github/pullRequest.js +60 -61
- package/lib/api/github/pullRequest.js.map +7 -1
- package/lib/api/github/push.js +138 -133
- package/lib/api/github/push.js.map +7 -1
- package/lib/api/jest/index.d.ts +2 -1
- package/lib/api/jest/index.js +35 -14
- package/lib/api/jest/index.js.map +7 -1
- package/lib/api/net/compose.js +45 -17
- package/lib/api/net/compose.js.map +7 -1
- package/lib/api/net/index.js +28 -5
- package/lib/api/net/index.js.map +7 -1
- package/lib/api/net/socket.js +58 -36
- package/lib/api/net/socket.js.map +7 -1
- package/lib/api/net/waitFor.js +38 -18
- package/lib/api/net/waitFor.js.map +7 -1
- package/lib/cli/adapter/eslint.js +95 -72
- package/lib/cli/adapter/eslint.js.map +7 -1
- package/lib/cli/adapter/prettier.js +126 -124
- package/lib/cli/adapter/prettier.js.map +7 -1
- package/lib/cli/build/args.d.ts +7 -0
- package/lib/cli/build/args.js +69 -0
- package/lib/cli/build/args.js.map +7 -0
- package/lib/cli/build/esbuild.d.ts +5 -0
- package/lib/cli/build/esbuild.js +128 -0
- package/lib/cli/build/esbuild.js.map +7 -0
- package/lib/cli/build/index.d.ts +1 -1
- package/lib/cli/build/index.js +68 -5
- package/lib/cli/build/index.js.map +7 -1
- package/lib/cli/build/tsc.d.ts +1 -1
- package/lib/cli/build/tsc.js +34 -23
- package/lib/cli/build/tsc.js.map +7 -1
- package/lib/cli/buildPackage.js +53 -23
- package/lib/cli/buildPackage.js.map +7 -1
- package/lib/cli/configure/addEmptyExports.d.ts +5 -0
- package/lib/cli/configure/addEmptyExports.js +67 -0
- package/lib/cli/configure/addEmptyExports.js.map +7 -0
- package/lib/cli/configure/analyseConfiguration.js +61 -31
- package/lib/cli/configure/analyseConfiguration.js.map +7 -1
- package/lib/cli/configure/analyseDependencies.js +122 -113
- package/lib/cli/configure/analyseDependencies.js.map +7 -1
- package/lib/cli/configure/analysis/diff.js +37 -11
- package/lib/cli/configure/analysis/diff.js.map +7 -1
- package/lib/cli/configure/analysis/files.js +49 -22
- package/lib/cli/configure/analysis/files.js.map +7 -1
- package/lib/cli/configure/analysis/git.js +46 -16
- package/lib/cli/configure/analysis/git.js.map +7 -1
- package/lib/cli/configure/analysis/package.js +99 -52
- package/lib/cli/configure/analysis/package.js.map +7 -1
- package/lib/cli/configure/analysis/project.js +90 -54
- package/lib/cli/configure/analysis/project.js.map +7 -1
- package/lib/cli/configure/dependencies/index.js +40 -13
- package/lib/cli/configure/dependencies/index.js.map +7 -1
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js +57 -32
- package/lib/cli/configure/dependencies/seekDatadogCustomMetrics.js.map +7 -1
- package/lib/cli/configure/dependencies/seekKoala.js +53 -31
- package/lib/cli/configure/dependencies/seekKoala.js.map +7 -1
- package/lib/cli/configure/dependencies/skuba.js +49 -27
- package/lib/cli/configure/dependencies/skuba.js.map +7 -1
- package/lib/cli/configure/dependencies/skubaDeps.js +49 -28
- package/lib/cli/configure/dependencies/skubaDeps.js.map +7 -1
- package/lib/cli/configure/dependencies/skubaDive.js +65 -38
- package/lib/cli/configure/dependencies/skubaDive.js.map +7 -1
- package/lib/cli/configure/ensureTemplateCompletion.js +69 -41
- package/lib/cli/configure/ensureTemplateCompletion.js.map +7 -1
- package/lib/cli/configure/getEntryPoint.js +62 -32
- package/lib/cli/configure/getEntryPoint.js.map +7 -1
- package/lib/cli/configure/getProjectType.js +50 -28
- package/lib/cli/configure/getProjectType.js.map +7 -1
- package/lib/cli/configure/index.js +134 -109
- package/lib/cli/configure/index.js.map +7 -1
- package/lib/cli/configure/modules/eslint.js +57 -26
- package/lib/cli/configure/modules/eslint.js.map +7 -1
- package/lib/cli/configure/modules/ignore.js +37 -14
- package/lib/cli/configure/modules/ignore.js.map +7 -1
- package/lib/cli/configure/modules/index.js +53 -28
- package/lib/cli/configure/modules/index.js.map +7 -1
- package/lib/cli/configure/modules/jest.js +84 -47
- package/lib/cli/configure/modules/jest.js.map +7 -1
- package/lib/cli/configure/modules/nodemon.js +29 -6
- package/lib/cli/configure/modules/nodemon.js.map +7 -1
- package/lib/cli/configure/modules/package.js +113 -92
- package/lib/cli/configure/modules/package.js.map +7 -1
- package/lib/cli/configure/modules/prettier.js +48 -19
- package/lib/cli/configure/modules/prettier.js.map +7 -1
- package/lib/cli/configure/modules/renovate.js +52 -39
- package/lib/cli/configure/modules/renovate.js.map +7 -1
- package/lib/cli/configure/modules/serverless.js +33 -15
- package/lib/cli/configure/modules/serverless.js.map +7 -1
- package/lib/cli/configure/modules/skubaDive.js +63 -37
- package/lib/cli/configure/modules/skubaDive.js.map +7 -1
- package/lib/cli/configure/modules/tsconfig.js +79 -63
- package/lib/cli/configure/modules/tsconfig.js.map +7 -1
- package/lib/cli/configure/modules/tslint.js +29 -6
- package/lib/cli/configure/modules/tslint.js.map +7 -1
- package/lib/cli/configure/processing/deleteFiles.js +30 -8
- package/lib/cli/configure/processing/deleteFiles.js.map +7 -1
- package/lib/cli/configure/processing/ignoreFile.js +65 -59
- package/lib/cli/configure/processing/ignoreFile.js.map +7 -1
- package/lib/cli/configure/processing/javascript.js +35 -15
- package/lib/cli/configure/processing/javascript.js.map +7 -1
- package/lib/cli/configure/processing/json.js +51 -20
- package/lib/cli/configure/processing/json.js.map +7 -1
- package/lib/cli/configure/processing/loadFiles.js +30 -8
- package/lib/cli/configure/processing/loadFiles.js.map +7 -1
- package/lib/cli/configure/processing/module.js +37 -14
- package/lib/cli/configure/processing/module.js.map +7 -1
- package/lib/cli/configure/processing/package.js +73 -43
- package/lib/cli/configure/processing/package.js.map +7 -1
- package/lib/cli/configure/processing/prettier.js +37 -11
- package/lib/cli/configure/processing/prettier.js.map +7 -1
- package/lib/cli/configure/processing/record.js +54 -31
- package/lib/cli/configure/processing/record.js.map +7 -1
- package/lib/cli/configure/processing/typescript.js +176 -158
- package/lib/cli/configure/processing/typescript.js.map +7 -1
- package/lib/cli/configure/refreshIgnoreFiles.js +64 -40
- package/lib/cli/configure/refreshIgnoreFiles.js.map +7 -1
- package/lib/cli/configure/types.js +16 -2
- package/lib/cli/configure/types.js.map +7 -1
- package/lib/cli/format.js +58 -31
- package/lib/cli/format.js.map +7 -1
- package/lib/cli/help.js +31 -8
- package/lib/cli/help.js.map +7 -1
- package/lib/cli/init/getConfig.js +238 -207
- package/lib/cli/init/getConfig.js.map +7 -1
- package/lib/cli/init/git.js +70 -63
- package/lib/cli/init/git.js.map +7 -1
- package/lib/cli/init/index.js +133 -100
- package/lib/cli/init/index.js.map +7 -1
- package/lib/cli/init/prompts.js +84 -54
- package/lib/cli/init/prompts.js.map +7 -1
- package/lib/cli/init/types.js +52 -52
- package/lib/cli/init/types.js.map +7 -1
- package/lib/cli/init/validation.js +34 -12
- package/lib/cli/init/validation.js.map +7 -1
- package/lib/cli/init/writePackageJson.js +51 -22
- package/lib/cli/init/writePackageJson.js.map +7 -1
- package/lib/cli/lint/annotate/buildkite/eslint.js +34 -28
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +7 -1
- package/lib/cli/lint/annotate/buildkite/index.js +50 -44
- package/lib/cli/lint/annotate/buildkite/index.js.map +7 -1
- package/lib/cli/lint/annotate/buildkite/prettier.js +41 -35
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +7 -1
- package/lib/cli/lint/annotate/buildkite/tsc.js +39 -39
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +7 -1
- package/lib/cli/lint/annotate/github/eslint.js +40 -16
- package/lib/cli/lint/annotate/github/eslint.js.map +7 -1
- package/lib/cli/lint/annotate/github/index.js +55 -51
- package/lib/cli/lint/annotate/github/index.js.map +7 -1
- package/lib/cli/lint/annotate/github/prettier.js +36 -13
- package/lib/cli/lint/annotate/github/prettier.js.map +7 -1
- package/lib/cli/lint/annotate/github/tsc.js +52 -52
- package/lib/cli/lint/annotate/github/tsc.js.map +7 -1
- package/lib/cli/lint/annotate/index.js +33 -10
- package/lib/cli/lint/annotate/index.js.map +7 -1
- package/lib/cli/lint/autofix.js +122 -117
- package/lib/cli/lint/autofix.js.map +7 -1
- package/lib/cli/lint/eslint.js +48 -18
- package/lib/cli/lint/eslint.js.map +7 -1
- package/lib/cli/lint/external.js +102 -81
- package/lib/cli/lint/external.js.map +7 -1
- package/lib/cli/lint/index.js +42 -18
- package/lib/cli/lint/index.js.map +7 -1
- package/lib/cli/lint/internal.js +54 -21
- package/lib/cli/lint/internal.js.map +7 -1
- package/lib/cli/lint/prettier.js +48 -18
- package/lib/cli/lint/prettier.js.map +7 -1
- package/lib/cli/lint/tsc.js +56 -32
- package/lib/cli/lint/tsc.js.map +7 -1
- package/lib/cli/lint/types.js +16 -2
- package/lib/cli/lint/types.js.map +7 -1
- package/lib/cli/node.js +65 -58
- package/lib/cli/node.js.map +7 -1
- package/lib/cli/release.js +29 -6
- package/lib/cli/release.js.map +7 -1
- package/lib/cli/start.js +61 -24
- package/lib/cli/start.js.map +7 -1
- package/lib/cli/test/index.js +35 -11
- package/lib/cli/test/index.js.map +7 -1
- package/lib/cli/test/reporters/github/annotations.js +89 -92
- package/lib/cli/test/reporters/github/annotations.js.map +7 -1
- package/lib/cli/test/reporters/github/index.js +68 -68
- package/lib/cli/test/reporters/github/index.js.map +7 -1
- package/lib/cli/version.js +31 -8
- package/lib/cli/version.js.map +7 -1
- package/lib/enquirer.d.js +2 -0
- package/lib/enquirer.d.js.map +7 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +45 -41
- package/lib/index.js.map +7 -1
- package/lib/skuba.js +45 -38
- package/lib/skuba.js.map +7 -1
- package/lib/utils/args.js +97 -96
- package/lib/utils/args.js.map +7 -1
- package/lib/utils/command.js +64 -33
- package/lib/utils/command.js.map +7 -1
- package/lib/utils/copy.js +88 -51
- package/lib/utils/copy.js.map +7 -1
- package/lib/utils/dir.js +79 -67
- package/lib/utils/dir.js.map +7 -1
- package/lib/utils/env.js +27 -7
- package/lib/utils/env.js.map +7 -1
- package/lib/utils/error.js +58 -56
- package/lib/utils/error.js.map +7 -1
- package/lib/utils/exec.js +139 -110
- package/lib/utils/exec.js.map +7 -1
- package/lib/utils/help.js +31 -8
- package/lib/utils/help.js.map +7 -1
- package/lib/utils/logging.js +52 -24
- package/lib/utils/logging.js.map +7 -1
- package/lib/utils/logo.js +65 -27
- package/lib/utils/logo.js.map +7 -1
- package/lib/utils/manifest.d.ts +1 -0
- package/lib/utils/manifest.js +65 -51
- package/lib/utils/manifest.js.map +7 -1
- package/lib/utils/port.js +38 -17
- package/lib/utils/port.js.map +7 -1
- package/lib/utils/template.js +106 -87
- package/lib/utils/template.js.map +7 -1
- package/lib/utils/validation.js +43 -18
- package/lib/utils/validation.js.map +7 -1
- package/lib/utils/version.js +73 -40
- package/lib/utils/version.js.map +7 -1
- package/lib/utils/wait.js +52 -25
- package/lib/utils/wait.js.map +7 -1
- package/lib/utils/worker.js +59 -44
- package/lib/utils/worker.js.map +7 -1
- package/lib/wrapper/function-arguments.d.js +2 -0
- package/lib/wrapper/function-arguments.d.js.map +7 -0
- package/lib/wrapper/functionHandler.js +56 -29
- package/lib/wrapper/functionHandler.js.map +7 -1
- package/lib/wrapper/http.js +66 -56
- package/lib/wrapper/http.js.map +7 -1
- package/lib/wrapper/index.js +9 -21
- package/lib/wrapper/index.js.map +7 -1
- package/lib/wrapper/main.js +39 -20
- package/lib/wrapper/main.js.map +7 -1
- package/lib/wrapper/requestListener.js +50 -35
- package/lib/wrapper/requestListener.js.map +7 -1
- package/package.json +21 -14
- package/template/base/jest.config.ts +0 -6
- package/template/base/jest.setup.ts +2 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/package.json +1 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/package.json +1 -1
- package/template/greeter/src/app.test.ts +3 -1
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/package.json +6 -9
- package/template/koa-rest-api/src/api/jobs/postJob.test.ts +3 -7
- package/template/koa-rest-api/src/api/jobs/postJob.ts +2 -2
- package/template/koa-rest-api/src/framework/validation.test.ts +17 -15
- package/template/koa-rest-api/src/framework/validation.ts +50 -9
- package/template/koa-rest-api/src/storage/jobs.ts +2 -2
- package/template/koa-rest-api/src/testing/types.ts +5 -10
- package/template/koa-rest-api/src/types/jobs.ts +5 -10
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +3 -3
- package/template/lambda-sqs-worker/README.md +1 -1
- package/template/lambda-sqs-worker/package.json +4 -4
- package/template/lambda-sqs-worker/serverless.yml +17 -2
- package/template/lambda-sqs-worker/src/app.test.ts +19 -17
- package/template/lambda-sqs-worker/src/app.ts +8 -8
- package/template/lambda-sqs-worker/src/config.ts +3 -0
- package/template/lambda-sqs-worker/src/framework/handler.test.ts +7 -7
- package/template/lambda-sqs-worker/src/framework/handler.ts +31 -8
- package/template/lambda-sqs-worker/src/framework/metrics.ts +10 -6
- package/template/lambda-sqs-worker/src/framework/validation.test.ts +37 -17
- package/template/lambda-sqs-worker/src/framework/validation.ts +4 -2
- package/template/lambda-sqs-worker/src/services/jobScorer.ts +2 -2
- package/template/lambda-sqs-worker/src/testing/types.ts +5 -10
- package/template/lambda-sqs-worker/src/types/jobScorer.ts +9 -16
- package/template/lambda-sqs-worker/src/types/pipelineEvents.ts +13 -20
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +3 -3
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +6 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -3
- package/template/lambda-sqs-worker-cdk/infra/index.ts +2 -2
- package/template/lambda-sqs-worker-cdk/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/shared/context-types.ts +16 -25
- package/template/oss-npm-package/_package.json +1 -1
- package/template/private-npm-package/_package.json +1 -1
- package/jest/resolver.js +0 -24
package/config/tsconfig.json
CHANGED
package/jest/moduleNameMapper.js
CHANGED
|
@@ -1,86 +1,58 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
3
|
const { pathsToModuleNameMapper } = require('ts-jest');
|
|
4
|
-
const {
|
|
5
|
-
sys,
|
|
6
|
-
findConfigFile,
|
|
7
|
-
readConfigFile,
|
|
8
|
-
parseJsonConfigFileContent,
|
|
9
|
-
} = require('typescript');
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
* Set a default `src` module alias for backward compatibility.
|
|
13
|
-
*
|
|
14
|
-
* TODO: drop this default in skuba v5.
|
|
15
|
-
*/
|
|
16
|
-
const DEFAULT_PATHS = { src: ['src'], 'src/*': ['src/*'] };
|
|
5
|
+
const { tryParseTsConfig } = require('./tsConfig');
|
|
17
6
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
const getConfigFromDisk = () => {
|
|
22
|
-
const filename =
|
|
23
|
-
findConfigFile('.', sys.fileExists.bind(this)) ?? 'tsconfig.json';
|
|
7
|
+
module.exports.createModuleNameMapper = (getConfig) => {
|
|
8
|
+
const maybeTsConfig = tryParseTsConfig(getConfig);
|
|
24
9
|
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const paths = Object.fromEntries(
|
|
35
|
-
Object.entries(parsedConfig.options.paths ?? DEFAULT_PATHS).flatMap(
|
|
36
|
-
([key, values]) => [
|
|
37
|
-
// Pass through the input path entry almost verbatim.
|
|
38
|
-
// We trim a trailing slash because TypeScript allows `import 'src'`
|
|
39
|
-
// to be resolved by the alias `src/`, but Jest's mapper does not.
|
|
40
|
-
[
|
|
41
|
-
key.replace(/\/$/, ''),
|
|
42
|
-
values.map((value) => value.replace(/\/$/, '')),
|
|
43
|
-
],
|
|
44
|
-
// Append a variant of the input path entry.
|
|
45
|
-
// As TypeScript allows both `import 'src'` and `import 'src/nested'`
|
|
46
|
-
// to be resolved by the alias `src/*` (and likewise for plain `src`),
|
|
47
|
-
// we need to seed two Jest mappings per path.
|
|
48
|
-
...(key.endsWith('/*')
|
|
49
|
-
? [
|
|
50
|
-
[
|
|
51
|
-
// Given a path `src/*`, seed an extra `src`.
|
|
52
|
-
key.replace(/\/\*$/, ''),
|
|
53
|
-
values.map((value) => value.replace(/\/\*$/, '')),
|
|
54
|
-
],
|
|
55
|
-
]
|
|
56
|
-
: [
|
|
57
|
-
[
|
|
58
|
-
// Given a path `src`, seed an extra `src/*`.
|
|
59
|
-
path.join(key, '*'),
|
|
60
|
-
values.map((value) => path.join(value, '*')),
|
|
61
|
-
],
|
|
62
|
-
]),
|
|
10
|
+
const paths = Object.fromEntries(
|
|
11
|
+
Object.entries(maybeTsConfig?.options.paths ?? {}).flatMap(
|
|
12
|
+
([key, values]) => [
|
|
13
|
+
// Pass through the input path entry almost verbatim.
|
|
14
|
+
// We trim a trailing slash because TypeScript allows `import 'src'`
|
|
15
|
+
// to be resolved by the alias `src/`, but Jest's mapper does not.
|
|
16
|
+
[
|
|
17
|
+
key.replace(/\/$/, ''),
|
|
18
|
+
values.map((value) => value.replace(/\/$/, '')),
|
|
63
19
|
],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
20
|
+
// Append a variant of the input path entry.
|
|
21
|
+
// As TypeScript allows both `import 'src'` and `import 'src/nested'`
|
|
22
|
+
// to be resolved by the alias `src/*` (and likewise for plain `src`),
|
|
23
|
+
// we need to seed two Jest mappings per path.
|
|
24
|
+
...(key.endsWith('/*')
|
|
25
|
+
? [
|
|
26
|
+
[
|
|
27
|
+
// Given a path `src/*`, seed an extra `src`.
|
|
28
|
+
key.replace(/\/\*$/, ''),
|
|
29
|
+
values.map((value) => value.replace(/\/\*$/, '')),
|
|
30
|
+
],
|
|
31
|
+
]
|
|
32
|
+
: [
|
|
33
|
+
[
|
|
34
|
+
// Given a path `src`, seed an extra `src/*`.
|
|
35
|
+
path.join(key, '*'),
|
|
36
|
+
values.map((value) => path.join(value, '*')),
|
|
37
|
+
],
|
|
38
|
+
]),
|
|
39
|
+
],
|
|
40
|
+
),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const prefix = path.join('<rootDir>', maybeTsConfig?.options.baseUrl ?? '.');
|
|
44
|
+
|
|
45
|
+
const moduleNameMapper = pathsToModuleNameMapper(paths, { prefix });
|
|
46
|
+
|
|
47
|
+
// Normalise away any `..`s that may crop up from `baseUrl` usage.
|
|
48
|
+
// For example, a `baseUrl` of `src` and a path of `../cli` will result in
|
|
49
|
+
// `<rootDir>/src/../cli`, which can be normalised to `<rootDir>/cli`.
|
|
50
|
+
return Object.fromEntries(
|
|
51
|
+
Object.entries(moduleNameMapper).map(([key, values]) => [
|
|
52
|
+
key,
|
|
53
|
+
Array.isArray(values)
|
|
54
|
+
? values.map((value) => path.normalize(value))
|
|
55
|
+
: path.normalize(values),
|
|
56
|
+
]),
|
|
57
|
+
);
|
|
86
58
|
};
|
|
@@ -56,19 +56,9 @@ describe('moduleNameMapper', () => {
|
|
|
56
56
|
|
|
57
57
|
it('respects no paths', () => expect(act({})).toMatchInlineSnapshot(`{}`));
|
|
58
58
|
|
|
59
|
-
it('
|
|
60
|
-
expect(act(undefined)).toMatchInlineSnapshot(`
|
|
61
|
-
{
|
|
62
|
-
"^src$": "<rootDir>/src",
|
|
63
|
-
"^src/(.*)$": "<rootDir>/src/$1",
|
|
64
|
-
}
|
|
65
|
-
`));
|
|
59
|
+
it('defaults to no paths on undefined', () =>
|
|
60
|
+
expect(act(undefined)).toMatchInlineSnapshot(`{}`));
|
|
66
61
|
|
|
67
|
-
it('
|
|
68
|
-
expect(act('INVALID')).toMatchInlineSnapshot(`
|
|
69
|
-
{
|
|
70
|
-
"^src$": "<rootDir>/src",
|
|
71
|
-
"^src/(.*)$": "<rootDir>/src/$1",
|
|
72
|
-
}
|
|
73
|
-
`));
|
|
62
|
+
it('defaults to no paths on invalid config', () =>
|
|
63
|
+
expect(act('INVALID')).toMatchInlineSnapshot(`{}`));
|
|
74
64
|
});
|
package/jest/transform.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { defaults } = require('ts-jest/presets');
|
|
2
2
|
|
|
3
|
+
const { tryParseTsConfig } = require('./tsConfig');
|
|
4
|
+
|
|
3
5
|
const TS_JEST_NAME = 'ts-jest';
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -10,10 +12,17 @@ const TS_JEST_NAME = 'ts-jest';
|
|
|
10
12
|
*/
|
|
11
13
|
const TS_JEST_PATH = require.resolve(TS_JEST_NAME);
|
|
12
14
|
|
|
15
|
+
const maybeTsConfig = tryParseTsConfig();
|
|
16
|
+
|
|
13
17
|
// Rewrite `ts-jest` transformations using our resolved `TS_JEST_PATH`.
|
|
14
18
|
module.exports.transform = Object.fromEntries(
|
|
15
19
|
Object.entries(defaults.transform).map(([key, value]) => [
|
|
16
20
|
key,
|
|
17
|
-
value === TS_JEST_NAME
|
|
21
|
+
value === TS_JEST_NAME
|
|
22
|
+
? [
|
|
23
|
+
TS_JEST_PATH,
|
|
24
|
+
{ isolatedModules: maybeTsConfig?.options.isolatedModules ?? true },
|
|
25
|
+
]
|
|
26
|
+
: value,
|
|
18
27
|
]),
|
|
19
28
|
);
|
package/jest/tsConfig.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const {
|
|
2
|
+
sys,
|
|
3
|
+
findConfigFile,
|
|
4
|
+
readConfigFile,
|
|
5
|
+
parseJsonConfigFileContent,
|
|
6
|
+
} = require('typescript');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @returns {unknown}
|
|
10
|
+
*/
|
|
11
|
+
const getTsConfigFromDisk = () => {
|
|
12
|
+
const filename =
|
|
13
|
+
findConfigFile('.', sys.fileExists.bind(this)) ?? 'tsconfig.json';
|
|
14
|
+
|
|
15
|
+
return readConfigFile(filename, sys.readFile.bind(this)).config;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
module.exports.tryParseTsConfig = (getConfig = getTsConfigFromDisk) => {
|
|
19
|
+
try {
|
|
20
|
+
const json = getConfig();
|
|
21
|
+
|
|
22
|
+
return parseJsonConfigFileContent(json, sys, '.');
|
|
23
|
+
} catch {
|
|
24
|
+
// Bail out here to support zero-config mode.
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var annotate_exports = {};
|
|
20
|
+
__export(annotate_exports, {
|
|
21
|
+
annotate: () => annotate
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(annotate_exports);
|
|
24
|
+
var import_exec = require("../../utils/exec");
|
|
25
|
+
const isAnnotationEnabled = async () => Boolean(
|
|
26
|
+
process.env.BUILDKITE && process.env.BUILDKITE_AGENT_ACCESS_TOKEN && process.env.BUILDKITE_JOB_ID && await (0, import_exec.hasCommand)("buildkite-agent")
|
|
27
|
+
);
|
|
21
28
|
const annotate = async (markdown, opts = {}) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
if (!await isAnnotationEnabled()) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const context = [
|
|
33
|
+
opts.scopeContextToStep && process.env.BUILDKITE_STEP_ID,
|
|
34
|
+
opts.context
|
|
35
|
+
].filter(Boolean).join("|");
|
|
36
|
+
const { style } = opts;
|
|
37
|
+
await (0, import_exec.exec)(
|
|
38
|
+
"buildkite-agent",
|
|
39
|
+
"annotate",
|
|
40
|
+
...context ? ["--context", context] : [],
|
|
41
|
+
...style ? ["--style", style] : [],
|
|
42
|
+
markdown
|
|
43
|
+
);
|
|
34
44
|
};
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
annotate
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=annotate.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/api/buildkite/annotate.ts"],
|
|
4
|
+
"sourcesContent": ["import { exec, hasCommand } from '../../utils/exec';\n\nexport type AnnotationStyle = 'success' | 'info' | 'warning' | 'error';\n\nconst isAnnotationEnabled = async () =>\n Boolean(\n process.env.BUILDKITE &&\n process.env.BUILDKITE_AGENT_ACCESS_TOKEN &&\n process.env.BUILDKITE_JOB_ID &&\n (await hasCommand('buildkite-agent')),\n );\n\ninterface AnnotationOptions {\n context?: string;\n\n /**\n * Scopes an annotation's context to the Buildkite step ID.\n *\n * This lets you emit distinct annotations per step, and only takes effect if\n * the `BUILDKITE_STEP_ID` environment variable is present.\n */\n scopeContextToStep?: boolean;\n\n style?: AnnotationStyle;\n}\n\n/**\n * Asynchronously uploads a Buildkite annotation.\n *\n * If the following environment variables are not present,\n * the function will silently return without attempting to annotate:\n *\n * - `BUILDKITE`\n * - `BUILDKITE_AGENT_ACCESS_TOKEN`\n * - `BUILDKITE_JOB_ID`\n *\n * The `buildkite-agent` binary must also be on your `PATH`.\n */\nexport const annotate = async (\n markdown: string,\n opts: AnnotationOptions = {},\n): Promise<void> => {\n if (!(await isAnnotationEnabled())) {\n return;\n }\n\n // Always scope to the current Buildkite step.\n const context = [\n opts.scopeContextToStep && process.env.BUILDKITE_STEP_ID,\n opts.context,\n ]\n .filter(Boolean)\n .join('|');\n\n const { style } = opts;\n\n await exec(\n 'buildkite-agent',\n 'annotate',\n ...(context ? ['--context', context] : []),\n ...(style ? ['--style', style] : []),\n markdown,\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AAIjC,MAAM,sBAAsB,YAC1B;AAAA,EACE,QAAQ,IAAI,aACV,QAAQ,IAAI,gCACZ,QAAQ,IAAI,oBACX,UAAM,wBAAW,iBAAiB;AACvC;AA4BK,MAAM,WAAW,OACtB,UACA,OAA0B,CAAC,MACT;AAClB,MAAI,CAAE,MAAM,oBAAoB,GAAI;AAClC;AAAA,EACF;AAGA,QAAM,UAAU;AAAA,IACd,KAAK,sBAAsB,QAAQ,IAAI;AAAA,IACvC,KAAK;AAAA,EACP,EACG,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,QAAM,EAAE,MAAM,IAAI;AAElB,YAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,GAAI,UAAU,CAAC,aAAa,OAAO,IAAI,CAAC;AAAA,IACxC,GAAI,QAAQ,CAAC,WAAW,KAAK,IAAI,CAAC;AAAA,IAClC;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var buildkite_exports = {};
|
|
20
|
+
__export(buildkite_exports, {
|
|
21
|
+
annotate: () => import_annotate.annotate,
|
|
22
|
+
md: () => import_md.md
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(buildkite_exports);
|
|
25
|
+
var import_annotate = require("./annotate");
|
|
26
|
+
var import_md = require("./md");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
annotate,
|
|
30
|
+
md
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/api/buildkite/index.ts"],
|
|
4
|
+
"sourcesContent": ["export type { AnnotationStyle } from './annotate';\nexport { annotate } from './annotate';\nexport { md } from './md';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAyB;AACzB,gBAAmB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/api/buildkite/md.js
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var md_exports = {};
|
|
20
|
+
__export(md_exports, {
|
|
21
|
+
md: () => md
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(md_exports);
|
|
24
|
+
const md = {
|
|
25
|
+
terminal: (code) => `\`\`\`term
|
|
26
|
+
${code.replace(/```/g, "\\`\\`\\`")}
|
|
27
|
+
\`\`\``
|
|
28
|
+
};
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
md
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=md.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/api/buildkite/md.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @internal\n */\nexport const md = {\n terminal: (code: string) =>\n `\\`\\`\\`term\\n${code.replace(/```/g, '\\\\`\\\\`\\\\`')}\\n\\`\\`\\``,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,KAAK;AAAA,EAChB,UAAU,CAAC,SACT;AAAA,EAAe,KAAK,QAAQ,QAAQ,WAAW;AAAA;AACnD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/api/git/commit.js
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var commit_exports = {};
|
|
26
|
+
__export(commit_exports, {
|
|
27
|
+
commit: () => commit
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(commit_exports);
|
|
30
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
31
|
+
var import_isomorphic_git = __toESM(require("isomorphic-git"));
|
|
32
|
+
const commit = async ({
|
|
33
|
+
author = { name: "skuba" },
|
|
34
|
+
committer = { name: "skuba" },
|
|
35
|
+
dir,
|
|
36
|
+
message
|
|
37
|
+
}) => import_isomorphic_git.default.commit({
|
|
38
|
+
author,
|
|
39
|
+
committer,
|
|
40
|
+
dir,
|
|
41
|
+
fs: import_fs_extra.default,
|
|
42
|
+
message
|
|
43
|
+
});
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
commit
|
|
18
47
|
});
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=commit.js.map
|
|
48
|
+
//# sourceMappingURL=commit.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/api/git/commit.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from 'fs-extra';\nimport git from 'isomorphic-git';\n\nexport interface Identity {\n email?: string;\n name?: string;\n}\n\ninterface CommitParameters {\n author?: Identity;\n committer?: Identity;\n dir: string;\n message: string;\n}\n\n/**\n * Writes a commit to the local Git repository.\n */\nexport const commit = async ({\n author = { name: 'skuba' },\n committer = { name: 'skuba' },\n dir,\n message,\n}: CommitParameters): Promise<string> =>\n git.commit({\n author,\n committer,\n dir,\n fs,\n message,\n });\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AACf,4BAAgB;AAiBT,MAAM,SAAS,OAAO;AAAA,EAC3B,SAAS,EAAE,MAAM,QAAQ;AAAA,EACzB,YAAY,EAAE,MAAM,QAAQ;AAAA,EAC5B;AAAA,EACA;AACF,MACE,sBAAAA,QAAI,OAAO;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAAC;AAAA,EACA;AACF,CAAC;",
|
|
6
|
+
"names": ["git", "fs"]
|
|
7
|
+
}
|
|
@@ -1,30 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* Stages all changes and writes a commit to the local Git repository.
|
|
13
|
-
*/
|
|
14
|
-
const commitAllChanges = async ({ dir, message, author, committer, }) => {
|
|
15
|
-
const changedFiles = await (0, getChangedFiles_1.getChangedFiles)({ dir });
|
|
16
|
-
if (!changedFiles.length) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
await Promise.all(changedFiles.map((file) => file.state === 'deleted'
|
|
20
|
-
? isomorphic_git_1.default.remove({ fs: fs_extra_1.default, dir, filepath: file.path })
|
|
21
|
-
: isomorphic_git_1.default.add({ fs: fs_extra_1.default, dir, filepath: file.path })));
|
|
22
|
-
return (0, commit_1.commit)({
|
|
23
|
-
dir,
|
|
24
|
-
message,
|
|
25
|
-
author,
|
|
26
|
-
committer,
|
|
27
|
-
});
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
28
19
|
};
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var commitAllChanges_exports = {};
|
|
26
|
+
__export(commitAllChanges_exports, {
|
|
27
|
+
commitAllChanges: () => commitAllChanges
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(commitAllChanges_exports);
|
|
30
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
31
|
+
var import_isomorphic_git = __toESM(require("isomorphic-git"));
|
|
32
|
+
var import_commit = require("./commit");
|
|
33
|
+
var import_getChangedFiles = require("./getChangedFiles");
|
|
34
|
+
const commitAllChanges = async ({
|
|
35
|
+
dir,
|
|
36
|
+
message,
|
|
37
|
+
author,
|
|
38
|
+
committer
|
|
39
|
+
}) => {
|
|
40
|
+
const changedFiles = await (0, import_getChangedFiles.getChangedFiles)({ dir });
|
|
41
|
+
if (!changedFiles.length) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
await Promise.all(
|
|
45
|
+
changedFiles.map(
|
|
46
|
+
(file) => file.state === "deleted" ? import_isomorphic_git.default.remove({ fs: import_fs_extra.default, dir, filepath: file.path }) : import_isomorphic_git.default.add({ fs: import_fs_extra.default, dir, filepath: file.path })
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
return (0, import_commit.commit)({
|
|
50
|
+
dir,
|
|
51
|
+
message,
|
|
52
|
+
author,
|
|
53
|
+
committer
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
commitAllChanges
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=commitAllChanges.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/api/git/commitAllChanges.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from 'fs-extra';\nimport git from 'isomorphic-git';\n\nimport { commit } from './commit';\nimport type { Identity } from './commit';\nimport { getChangedFiles } from './getChangedFiles';\n\ninterface CommitAllParameters {\n dir: string;\n message: string;\n author?: Identity;\n committer?: Identity;\n}\n\n/**\n * Stages all changes and writes a commit to the local Git repository.\n */\nexport const commitAllChanges = async ({\n dir,\n message,\n author,\n committer,\n}: CommitAllParameters): Promise<string | undefined> => {\n const changedFiles = await getChangedFiles({ dir });\n\n if (!changedFiles.length) {\n return;\n }\n\n await Promise.all(\n changedFiles.map((file) =>\n file.state === 'deleted'\n ? git.remove({ fs, dir, filepath: file.path })\n : git.add({ fs, dir, filepath: file.path }),\n ),\n );\n\n return commit({\n dir,\n message,\n author,\n committer,\n });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAe;AACf,4BAAgB;AAEhB,oBAAuB;AAEvB,6BAAgC;AAYzB,MAAM,mBAAmB,OAAO;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwD;AACtD,QAAM,eAAe,UAAM,wCAAgB,EAAE,IAAI,CAAC;AAElD,MAAI,CAAC,aAAa,QAAQ;AACxB;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,aAAa;AAAA,MAAI,CAAC,SAChB,KAAK,UAAU,YACX,sBAAAA,QAAI,OAAO,EAAE,oBAAAC,SAAI,KAAK,UAAU,KAAK,KAAK,CAAC,IAC3C,sBAAAD,QAAI,IAAI,EAAE,oBAAAC,SAAI,KAAK,UAAU,KAAK,KAAK,CAAC;AAAA,IAC9C;AAAA,EACF;AAEA,aAAO,sBAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": ["git", "fs"]
|
|
7
|
+
}
|