skuba 0.0.0-master-20231002013336 → 0.0.0-master-20240206001217
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/README.md +3 -3
- package/jest/transform.test.ts +3 -1
- package/lib/api/jest/index.d.ts +3 -3
- package/lib/api/jest/index.js +19 -1
- package/lib/api/jest/index.js.map +2 -2
- package/lib/api/net/compose.js +2 -1
- package/lib/api/net/compose.js.map +2 -2
- package/lib/cli/adapter/prettier.d.ts +1 -1
- package/lib/cli/adapter/prettier.js +11 -10
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/index.js +0 -2
- package/lib/cli/build/index.js.map +2 -2
- package/lib/cli/buildPackage.js +0 -2
- package/lib/cli/buildPackage.js.map +2 -2
- package/lib/cli/configure/analyseConfiguration.d.ts +2 -0
- package/lib/cli/configure/analyseConfiguration.js.map +2 -2
- package/lib/cli/configure/getEntryPoint.js +1 -1
- package/lib/cli/configure/getEntryPoint.js.map +2 -2
- package/lib/cli/configure/getProjectType.d.ts +1 -1
- package/lib/cli/configure/getProjectType.js +6 -3
- package/lib/cli/configure/getProjectType.js.map +2 -2
- package/lib/cli/configure/index.js +11 -12
- package/lib/cli/configure/index.js.map +2 -2
- package/lib/cli/configure/modules/index.js +0 -2
- package/lib/cli/configure/modules/index.js.map +2 -2
- package/lib/cli/configure/modules/package.d.ts +1 -1
- package/lib/cli/configure/modules/package.js +2 -1
- package/lib/cli/configure/modules/package.js.map +2 -2
- package/lib/cli/configure/patchRenovateConfig.d.ts +2 -1
- package/lib/cli/configure/patchRenovateConfig.js +36 -21
- package/lib/cli/configure/patchRenovateConfig.js.map +2 -2
- package/lib/cli/configure/types.d.ts +2 -0
- package/lib/cli/configure/types.js.map +1 -1
- package/lib/cli/configure/upgrade/index.d.ts +15 -0
- package/lib/cli/configure/upgrade/index.js +130 -0
- package/lib/cli/configure/upgrade/index.js.map +7 -0
- package/lib/cli/configure/{addEmptyExports.d.ts → upgrade/patches/7.3.1/addEmptyExports.d.ts} +2 -2
- package/lib/cli/configure/{addEmptyExports.js → upgrade/patches/7.3.1/addEmptyExports.js} +15 -11
- package/lib/cli/configure/upgrade/patches/7.3.1/addEmptyExports.js.map +7 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/index.d.ts +2 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/index.js +55 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/index.js.map +7 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.d.ts +2 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js +94 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js.map +7 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.d.ts +2 -0
- package/lib/cli/configure/{patchDockerfile.js → upgrade/patches/7.3.1/patchDockerfile.js} +18 -12
- package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.js.map +7 -0
- package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.d.ts +2 -0
- package/lib/cli/configure/{patchServerListener.js → upgrade/patches/7.3.1/patchServerListener.js} +18 -14
- package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.js.map +7 -0
- package/lib/cli/format.js +7 -14
- package/lib/cli/format.js.map +2 -2
- package/lib/cli/init/getConfig.d.ts +7 -5
- package/lib/cli/init/getConfig.js +61 -34
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/init/git.d.ts +2 -1
- package/lib/cli/init/git.js +2 -9
- package/lib/cli/init/git.js.map +2 -2
- package/lib/cli/init/index.d.ts +1 -1
- package/lib/cli/init/index.js +19 -10
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/init/prompts.d.ts +26 -3
- package/lib/cli/init/prompts.js +10 -2
- package/lib/cli/init/prompts.js.map +2 -2
- package/lib/cli/init/types.d.ts +120 -27
- package/lib/cli/init/types.js +30 -35
- package/lib/cli/init/types.js.map +2 -2
- package/lib/cli/init/writePackageJson.d.ts +6 -0
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/index.d.ts +2 -1
- package/lib/cli/lint/annotate/buildkite/index.js +5 -3
- package/lib/cli/lint/annotate/buildkite/index.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/internal.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/internal.js +45 -0
- package/lib/cli/lint/annotate/buildkite/internal.js.map +7 -0
- package/lib/cli/lint/annotate/github/index.d.ts +2 -1
- package/lib/cli/lint/annotate/github/index.js +4 -2
- package/lib/cli/lint/annotate/github/index.js.map +2 -2
- package/lib/cli/lint/annotate/github/internal.d.ts +3 -0
- package/lib/cli/lint/annotate/github/internal.js +36 -0
- package/lib/cli/lint/annotate/github/internal.js.map +7 -0
- package/lib/cli/lint/annotate/index.d.ts +4 -3
- package/lib/cli/lint/annotate/index.js +9 -3
- package/lib/cli/lint/annotate/index.js.map +2 -2
- package/lib/cli/lint/autofix.d.ts +3 -1
- package/lib/cli/lint/autofix.js +36 -59
- package/lib/cli/lint/autofix.js.map +3 -3
- package/lib/cli/lint/external.d.ts +6 -1
- package/lib/cli/lint/external.js +6 -29
- package/lib/cli/lint/external.js.map +2 -2
- package/lib/cli/lint/index.d.ts +2 -1
- package/lib/cli/lint/index.js +46 -14
- package/lib/cli/lint/index.js.map +2 -2
- package/lib/cli/lint/internal.d.ts +12 -1
- package/lib/cli/lint/internal.js +55 -19
- package/lib/cli/lint/internal.js.map +3 -3
- package/lib/cli/lint/internalLints/deleteFiles.d.ts +3 -0
- package/lib/cli/lint/internalLints/deleteFiles.js +102 -0
- package/lib/cli/lint/internalLints/deleteFiles.js.map +7 -0
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.d.ts +3 -0
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +75 -0
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +7 -0
- package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +11 -0
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +147 -0
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +7 -0
- package/lib/cli/test/index.js +0 -2
- package/lib/cli/test/index.js.map +2 -2
- package/lib/skuba.d.ts +1 -1
- package/lib/skuba.js.map +1 -1
- package/lib/utils/error.d.ts +30 -10
- package/lib/utils/error.js +10 -20
- package/lib/utils/error.js.map +2 -2
- package/lib/utils/exec.d.ts +2 -1
- package/lib/utils/exec.js +3 -2
- package/lib/utils/exec.js.map +2 -2
- package/lib/utils/logging.d.ts +2 -0
- package/lib/utils/logging.js +1 -0
- package/lib/utils/logging.js.map +2 -2
- package/lib/utils/logo.js +6 -10
- package/lib/utils/logo.js.map +3 -3
- package/lib/utils/manifest.d.ts +4 -4
- package/lib/utils/manifest.js +10 -10
- package/lib/utils/manifest.js.map +2 -2
- package/lib/utils/npmrc.d.ts +1 -0
- package/lib/utils/npmrc.js +29 -0
- package/lib/utils/npmrc.js.map +7 -0
- package/lib/utils/packageManager.d.ts +24 -0
- package/lib/utils/packageManager.js +97 -0
- package/lib/utils/packageManager.js.map +7 -0
- package/lib/utils/template.d.ts +46 -13
- package/lib/utils/template.js +17 -15
- package/lib/utils/template.js.map +2 -2
- package/lib/utils/worker.d.ts +1 -0
- package/lib/wrapper/http.d.ts +1 -0
- package/package.json +50 -47
- package/template/base/_.dockerignore +0 -1
- package/template/base/_.eslintignore +1 -0
- package/template/base/_.gitignore +1 -1
- package/template/base/_.npmrc +8 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +16 -12
- package/template/express-rest-api/.gantry/dev.yml +3 -0
- package/template/express-rest-api/.nvmrc +1 -1
- package/template/express-rest-api/Dockerfile +6 -12
- package/template/express-rest-api/Dockerfile.dev-deps +8 -7
- package/template/express-rest-api/README.md +12 -12
- package/template/express-rest-api/docker-compose.yml +0 -10
- package/template/express-rest-api/gantry.apply.yml +5 -0
- package/template/express-rest-api/gantry.build.yml +1 -2
- package/template/express-rest-api/package.json +4 -4
- package/template/express-rest-api/skuba.template.js +1 -0
- package/template/greeter/.buildkite/pipeline.yml +15 -11
- package/template/greeter/.nvmrc +1 -1
- package/template/greeter/Dockerfile +8 -7
- package/template/greeter/README.md +9 -9
- package/template/greeter/docker-compose.yml +0 -10
- package/template/greeter/package.json +3 -3
- package/template/greeter/skuba.template.js +1 -0
- package/template/koa-rest-api/.buildkite/pipeline.yml +16 -12
- package/template/koa-rest-api/.gantry/dev.yml +3 -0
- package/template/koa-rest-api/.nvmrc +1 -1
- package/template/koa-rest-api/Dockerfile +6 -12
- package/template/koa-rest-api/Dockerfile.dev-deps +8 -7
- package/template/koa-rest-api/README.md +12 -12
- package/template/koa-rest-api/docker-compose.yml +0 -10
- package/template/koa-rest-api/gantry.apply.yml +5 -0
- package/template/koa-rest-api/gantry.build.yml +1 -2
- package/template/koa-rest-api/package.json +10 -8
- package/template/koa-rest-api/skuba.template.js +1 -0
- package/template/koa-rest-api/src/app.test.ts +8 -4
- package/template/koa-rest-api/src/framework/validation.test.ts +48 -15
- package/template/koa-rest-api/src/framework/validation.ts +31 -8
- package/template/koa-rest-api/src/testing/types.ts +16 -4
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +25 -18
- package/template/lambda-sqs-worker/.nvmrc +1 -1
- package/template/lambda-sqs-worker/Dockerfile +8 -8
- package/template/lambda-sqs-worker/README.md +14 -14
- package/template/lambda-sqs-worker/_.npmrc +12 -0
- package/template/lambda-sqs-worker/docker-compose.yml +0 -15
- package/template/lambda-sqs-worker/package.json +6 -7
- package/template/lambda-sqs-worker/serverless.yml +5 -2
- package/template/lambda-sqs-worker/skuba.template.js +1 -0
- package/template/lambda-sqs-worker/src/framework/validation.test.ts +1 -1
- package/template/lambda-sqs-worker/src/hooks.ts +1 -2
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +46 -21
- package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
- package/template/lambda-sqs-worker-cdk/Dockerfile +11 -9
- package/template/lambda-sqs-worker-cdk/cdk.json +12 -6
- package/template/lambda-sqs-worker-cdk/docker-compose.yml +0 -15
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +1590 -228
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +23 -3
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +128 -15
- package/template/lambda-sqs-worker-cdk/package.json +9 -7
- package/template/lambda-sqs-worker-cdk/shared/context-types.ts +1 -0
- package/template/lambda-sqs-worker-cdk/skuba.template.js +1 -0
- package/template/lambda-sqs-worker-cdk/src/app.ts +14 -1
- package/template/lambda-sqs-worker-cdk/src/postHook.ts +154 -0
- package/template/lambda-sqs-worker-cdk/src/preHook.ts +95 -0
- package/template/oss-npm-package/.github/workflows/release.yml +10 -7
- package/template/oss-npm-package/.github/workflows/validate.yml +10 -7
- package/template/oss-npm-package/.nvmrc +1 -1
- package/template/oss-npm-package/.releaserc +16 -0
- package/template/oss-npm-package/README.md +18 -18
- package/template/oss-npm-package/_package.json +3 -2
- package/template/oss-npm-package/skuba.template.js +1 -0
- package/template/private-npm-package/.nvmrc +1 -1
- package/template/private-npm-package/.releaserc +16 -0
- package/template/private-npm-package/README.md +18 -18
- package/template/private-npm-package/_package.json +3 -3
- package/template/private-npm-package/skuba.template.js +1 -0
- package/lib/cli/configure/addEmptyExports.js.map +0 -7
- package/lib/cli/configure/modules/tsconfig.d.ts +0 -2
- package/lib/cli/configure/modules/tsconfig.js +0 -87
- package/lib/cli/configure/modules/tsconfig.js.map +0 -7
- package/lib/cli/configure/patchDockerfile.d.ts +0 -1
- package/lib/cli/configure/patchDockerfile.js.map +0 -7
- package/lib/cli/configure/patchServerListener.d.ts +0 -3
- package/lib/cli/configure/patchServerListener.js.map +0 -7
- package/lib/cli/configure/refreshIgnoreFiles.d.ts +0 -3
- package/lib/cli/configure/refreshIgnoreFiles.js +0 -78
- package/lib/cli/configure/refreshIgnoreFiles.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/external.ts"],
|
|
4
|
-
"sourcesContent": ["import stream from 'stream';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;
|
|
4
|
+
"sourcesContent": ["import stream from 'stream';\n\nimport { runESLintInCurrentThread, runESLintInWorkerThread } from './eslint';\nimport {\n runPrettierInCurrentThread,\n runPrettierInWorkerThread,\n} from './prettier';\nimport { runTscInNewProcess } from './tsc';\nimport type { Input } from './types';\n\nconst tscPrefixRegex = /^(.*?tsc\\s+\u2502.*?\\s)/gm;\n\nexport class StreamInterceptor extends stream.Transform {\n private chunks: Uint8Array[] = [];\n\n public output() {\n return Buffer.concat(this.chunks).toString().replace(tscPrefixRegex, '');\n }\n\n _transform(\n chunk: Uint8Array,\n _encoding: BufferEncoding,\n callback: stream.TransformCallback,\n ) {\n this.chunks.push(chunk);\n\n callback(null, chunk);\n }\n}\n\nconst lintConcurrently = async ({ tscOutputStream, ...input }: Input) => {\n const [eslint, prettier, tscOk] = await Promise.all([\n runESLintInWorkerThread(input),\n runPrettierInWorkerThread(input),\n runTscInNewProcess({ ...input, tscOutputStream }),\n ]);\n\n return { eslint, prettier, tscOk };\n};\n\n/**\n * Run linting tools `--serial`ly for resource-constrained environments.\n *\n * Note that we still run ESLint and Prettier in worker threads as a\n * counterintuitive optimisation. Memory can be more readily freed on worker\n * thread exit, which isn't as easy with a monolithic main thread.\n */\nconst lintSerially = async ({ tscOutputStream, ...input }: Input) => {\n const eslint = await runESLintInWorkerThread(input);\n const prettier = await runPrettierInWorkerThread(input);\n const tscOk = await runTscInNewProcess({ ...input, tscOutputStream });\n\n return { eslint, prettier, tscOk };\n};\n\nconst lintSeriallyWithoutWorkerThreads = async (input: Input) => {\n const eslint = await runESLintInCurrentThread(input);\n const prettier = await runPrettierInCurrentThread(input);\n const tscOk = await runTscInNewProcess(input);\n\n return { eslint, prettier, tscOk };\n};\n\nconst selectLintFunction = (input: Input) => {\n if (!input.workerThreads) {\n return lintSeriallyWithoutWorkerThreads;\n }\n\n // `--debug` implies `--serial`.\n const isSerial = input.debug || input.serial;\n\n return isSerial ? lintSerially : lintConcurrently;\n};\n\nexport const externalLint = async (input: Input) => {\n const lint = selectLintFunction(input);\n\n const tscOutputStream = new StreamInterceptor();\n tscOutputStream.pipe(input.tscOutputStream ?? process.stdout);\n\n const { eslint, prettier, tscOk } = await lint({ ...input, tscOutputStream });\n\n return {\n eslint,\n prettier,\n tscOk,\n tscOutputStream,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AAEnB,oBAAkE;AAClE,sBAGO;AACP,iBAAmC;AAGnC,MAAM,iBAAiB;AAEhB,MAAM,0BAA0B,cAAAA,QAAO,UAAU;AAAA,EAC9C,SAAuB,CAAC;AAAA,EAEzB,SAAS;AACd,WAAO,OAAO,OAAO,KAAK,MAAM,EAAE,SAAS,EAAE,QAAQ,gBAAgB,EAAE;AAAA,EACzE;AAAA,EAEA,WACE,OACA,WACA,UACA;AACA,SAAK,OAAO,KAAK,KAAK;AAEtB,aAAS,MAAM,KAAK;AAAA,EACtB;AACF;AAEA,MAAM,mBAAmB,OAAO,EAAE,iBAAiB,GAAG,MAAM,MAAa;AACvE,QAAM,CAAC,QAAQ,UAAU,KAAK,IAAI,MAAM,QAAQ,IAAI;AAAA,QAClD,uCAAwB,KAAK;AAAA,QAC7B,2CAA0B,KAAK;AAAA,QAC/B,+BAAmB,EAAE,GAAG,OAAO,gBAAgB,CAAC;AAAA,EAClD,CAAC;AAED,SAAO,EAAE,QAAQ,UAAU,MAAM;AACnC;AASA,MAAM,eAAe,OAAO,EAAE,iBAAiB,GAAG,MAAM,MAAa;AACnE,QAAM,SAAS,UAAM,uCAAwB,KAAK;AAClD,QAAM,WAAW,UAAM,2CAA0B,KAAK;AACtD,QAAM,QAAQ,UAAM,+BAAmB,EAAE,GAAG,OAAO,gBAAgB,CAAC;AAEpE,SAAO,EAAE,QAAQ,UAAU,MAAM;AACnC;AAEA,MAAM,mCAAmC,OAAO,UAAiB;AAC/D,QAAM,SAAS,UAAM,wCAAyB,KAAK;AACnD,QAAM,WAAW,UAAM,4CAA2B,KAAK;AACvD,QAAM,QAAQ,UAAM,+BAAmB,KAAK;AAE5C,SAAO,EAAE,QAAQ,UAAU,MAAM;AACnC;AAEA,MAAM,qBAAqB,CAAC,UAAiB;AAC3C,MAAI,CAAC,MAAM,eAAe;AACxB,WAAO;AAAA,EACT;AAGA,QAAM,WAAW,MAAM,SAAS,MAAM;AAEtC,SAAO,WAAW,eAAe;AACnC;AAEO,MAAM,eAAe,OAAO,UAAiB;AAClD,QAAM,OAAO,mBAAmB,KAAK;AAErC,QAAM,kBAAkB,IAAI,kBAAkB;AAC9C,kBAAgB,KAAK,MAAM,mBAAmB,QAAQ,MAAM;AAE5D,QAAM,EAAE,QAAQ,UAAU,MAAM,IAAI,MAAM,KAAK,EAAE,GAAG,OAAO,gBAAgB,CAAC;AAE5E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["stream"]
|
|
7
7
|
}
|
package/lib/cli/lint/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { Writable } from 'stream';
|
|
2
|
-
export declare const lint: (args?: string[],
|
|
3
|
+
export declare const lint: (args?: string[], tscWriteable?: Writable | undefined, workerThreads?: boolean) => Promise<void>;
|
package/lib/cli/lint/index.js
CHANGED
|
@@ -21,28 +21,60 @@ __export(lint_exports, {
|
|
|
21
21
|
lint: () => lint
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(lint_exports);
|
|
24
|
+
var import_util = require("util");
|
|
24
25
|
var import_args = require("../../utils/args");
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
26
|
+
var import_logging = require("../../utils/logging");
|
|
27
|
+
var import_packageManager = require("../../utils/packageManager");
|
|
28
|
+
var import_wait = require("../../utils/wait");
|
|
29
|
+
var import_annotate = require("./annotate");
|
|
30
|
+
var import_autofix = require("./autofix");
|
|
29
31
|
var import_external = require("./external");
|
|
30
32
|
var import_internal = require("./internal");
|
|
31
|
-
const lint = async (args = process.argv.slice(2),
|
|
32
|
-
await Promise.all([
|
|
33
|
-
(0, import_addEmptyExports.tryAddEmptyExports)(),
|
|
34
|
-
(0, import_patchRenovateConfig.tryPatchRenovateConfig)(),
|
|
35
|
-
(0, import_patchServerListener.tryPatchServerListener)(),
|
|
36
|
-
(0, import_refreshIgnoreFiles.tryRefreshIgnoreFiles)()
|
|
37
|
-
]);
|
|
33
|
+
const lint = async (args = process.argv.slice(2), tscWriteable = void 0, workerThreads = true) => {
|
|
38
34
|
const opts = {
|
|
39
35
|
debug: (0, import_args.hasDebugFlag)(args),
|
|
40
36
|
serial: (0, import_args.hasSerialFlag)(args),
|
|
41
|
-
tscOutputStream,
|
|
37
|
+
tscOutputStream: tscWriteable,
|
|
42
38
|
workerThreads
|
|
43
39
|
};
|
|
44
|
-
await (0, import_external.externalLint)(opts);
|
|
45
|
-
await (0, import_internal.internalLint)();
|
|
40
|
+
const { eslint, prettier, tscOk, tscOutputStream } = await (0, import_external.externalLint)(opts);
|
|
41
|
+
const internal = await (0, import_internal.internalLint)("lint", opts);
|
|
42
|
+
try {
|
|
43
|
+
await (0, import_wait.throwOnTimeout)(
|
|
44
|
+
(0, import_annotate.createAnnotations)(internal, eslint, prettier, tscOk, tscOutputStream),
|
|
45
|
+
{ s: 30 }
|
|
46
|
+
);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
import_logging.log.warn("Failed to annotate lint results.");
|
|
49
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
50
|
+
}
|
|
51
|
+
if (!internal.ok || !eslint.ok || !prettier.ok || !tscOk) {
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
const tools = [
|
|
54
|
+
...internal.ok ? [] : ["skuba"],
|
|
55
|
+
...eslint.ok ? [] : ["ESLint"],
|
|
56
|
+
...prettier.ok ? [] : ["Prettier"],
|
|
57
|
+
...tscOk ? [] : ["tsc"]
|
|
58
|
+
];
|
|
59
|
+
import_logging.log.err(`${tools.join(", ")} found issues that require triage.`);
|
|
60
|
+
if (internal.fixable || eslint.fixable || !prettier.ok) {
|
|
61
|
+
const packageManager = await (0, import_packageManager.detectPackageManager)();
|
|
62
|
+
import_logging.log.newline();
|
|
63
|
+
import_logging.log.warn(
|
|
64
|
+
`Try running ${import_logging.log.bold(
|
|
65
|
+
packageManager.exec,
|
|
66
|
+
"skuba",
|
|
67
|
+
"format"
|
|
68
|
+
)} to fix them.`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
await (0, import_autofix.autofix)({
|
|
73
|
+
debug: opts.debug,
|
|
74
|
+
eslint: eslint.fixable,
|
|
75
|
+
prettier: !prettier.ok,
|
|
76
|
+
internal: internal.fixable
|
|
77
|
+
});
|
|
46
78
|
};
|
|
47
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
80
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Writable } from 'stream';\n\nimport { hasDebugFlag, hasSerialFlag } from '../../utils/args';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import type { Writable } from 'stream';\nimport { inspect } from 'util';\n\nimport { hasDebugFlag, hasSerialFlag } from '../../utils/args';\nimport { log } from '../../utils/logging';\nimport { detectPackageManager } from '../../utils/packageManager';\nimport { throwOnTimeout } from '../../utils/wait';\n\nimport { createAnnotations } from './annotate';\nimport { autofix } from './autofix';\nimport { externalLint } from './external';\nimport { internalLint } from './internal';\nimport type { Input } from './types';\n\nexport const lint = async (\n args = process.argv.slice(2),\n tscWriteable: Writable | undefined = undefined,\n workerThreads = true,\n) => {\n const opts: Input = {\n debug: hasDebugFlag(args),\n serial: hasSerialFlag(args),\n tscOutputStream: tscWriteable,\n workerThreads,\n };\n\n const { eslint, prettier, tscOk, tscOutputStream } = await externalLint(opts);\n const internal = await internalLint('lint', opts);\n\n try {\n await throwOnTimeout(\n createAnnotations(internal, eslint, prettier, tscOk, tscOutputStream),\n { s: 30 },\n );\n } catch (err) {\n log.warn('Failed to annotate lint results.');\n log.subtle(inspect(err));\n }\n\n if (!internal.ok || !eslint.ok || !prettier.ok || !tscOk) {\n process.exitCode = 1;\n\n const tools = [\n ...(internal.ok ? [] : ['skuba']),\n ...(eslint.ok ? [] : ['ESLint']),\n ...(prettier.ok ? [] : ['Prettier']),\n ...(tscOk ? [] : ['tsc']),\n ];\n\n log.err(`${tools.join(', ')} found issues that require triage.`);\n\n if (internal.fixable || eslint.fixable || !prettier.ok) {\n const packageManager = await detectPackageManager();\n log.newline();\n log.warn(\n `Try running ${log.bold(\n packageManager.exec,\n 'skuba',\n 'format',\n )} to fix them.`,\n );\n }\n }\n\n await autofix({\n debug: opts.debug,\n eslint: eslint.fixable,\n prettier: !prettier.ok,\n internal: internal.fixable,\n });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAwB;AAExB,kBAA4C;AAC5C,qBAAoB;AACpB,4BAAqC;AACrC,kBAA+B;AAE/B,sBAAkC;AAClC,qBAAwB;AACxB,sBAA6B;AAC7B,sBAA6B;AAGtB,MAAM,OAAO,OAClB,OAAO,QAAQ,KAAK,MAAM,CAAC,GAC3B,eAAqC,QACrC,gBAAgB,SACb;AACH,QAAM,OAAc;AAAA,IAClB,WAAO,0BAAa,IAAI;AAAA,IACxB,YAAQ,2BAAc,IAAI;AAAA,IAC1B,iBAAiB;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,EAAE,QAAQ,UAAU,OAAO,gBAAgB,IAAI,UAAM,8BAAa,IAAI;AAC5E,QAAM,WAAW,UAAM,8BAAa,QAAQ,IAAI;AAEhD,MAAI;AACF,cAAM;AAAA,UACJ,mCAAkB,UAAU,QAAQ,UAAU,OAAO,eAAe;AAAA,MACpE,EAAE,GAAG,GAAG;AAAA,IACV;AAAA,EACF,SAAS,KAAK;AACZ,uBAAI,KAAK,kCAAkC;AAC3C,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AAAA,EACzB;AAEA,MAAI,CAAC,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,SAAS,MAAM,CAAC,OAAO;AACxD,YAAQ,WAAW;AAEnB,UAAM,QAAQ;AAAA,MACZ,GAAI,SAAS,KAAK,CAAC,IAAI,CAAC,OAAO;AAAA,MAC/B,GAAI,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ;AAAA,MAC9B,GAAI,SAAS,KAAK,CAAC,IAAI,CAAC,UAAU;AAAA,MAClC,GAAI,QAAQ,CAAC,IAAI,CAAC,KAAK;AAAA,IACzB;AAEA,uBAAI,IAAI,GAAG,MAAM,KAAK,IAAI,CAAC,oCAAoC;AAE/D,QAAI,SAAS,WAAW,OAAO,WAAW,CAAC,SAAS,IAAI;AACtD,YAAM,iBAAiB,UAAM,4CAAqB;AAClD,yBAAI,QAAQ;AACZ,yBAAI;AAAA,QACF,eAAe,mBAAI;AAAA,UACjB,eAAe;AAAA,UACf;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,YAAM,wBAAQ;AAAA,IACZ,OAAO,KAAK;AAAA,IACZ,QAAQ,OAAO;AAAA,IACf,UAAU,CAAC,SAAS;AAAA,IACpB,UAAU,SAAS;AAAA,EACrB,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Input } from './types';
|
|
2
|
+
export type InternalLintResult = {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
fixable: boolean;
|
|
5
|
+
annotations?: Array<{
|
|
6
|
+
start_line?: number;
|
|
7
|
+
end_line?: number;
|
|
8
|
+
path: string;
|
|
9
|
+
message: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
export declare const internalLint: (mode: 'format' | 'lint', input?: Input) => Promise<InternalLintResult>;
|
package/lib/cli/lint/internal.js
CHANGED
|
@@ -31,32 +31,68 @@ __export(internal_exports, {
|
|
|
31
31
|
internalLint: () => internalLint
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(internal_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_util = require("util");
|
|
35
35
|
var import_chalk = __toESM(require("chalk"));
|
|
36
|
-
var import_fs_extra = require("fs-extra");
|
|
37
36
|
var import_logging = require("../../utils/logging");
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
var import_upgrade = require("../configure/upgrade");
|
|
38
|
+
var import_deleteFiles = require("./internalLints/deleteFiles");
|
|
39
|
+
var import_noSkubaTemplateJs = require("./internalLints/noSkubaTemplateJs");
|
|
40
|
+
var import_refreshConfigFiles = require("./internalLints/refreshConfigFiles");
|
|
41
|
+
const lints = [
|
|
42
|
+
// Run upgradeSkuba before refreshConfigFiles for npmrc handling
|
|
43
|
+
[import_upgrade.upgradeSkuba],
|
|
44
|
+
[import_deleteFiles.deleteFilesLint, import_noSkubaTemplateJs.noSkubaTemplateJs, import_refreshConfigFiles.tryRefreshConfigFiles]
|
|
45
|
+
];
|
|
46
|
+
const lintSerially = async (mode, logger) => {
|
|
47
|
+
const results = [];
|
|
48
|
+
for (const lintGroup of lints) {
|
|
49
|
+
for (const lint of lintGroup) {
|
|
50
|
+
results.push(await lint(mode, logger));
|
|
51
|
+
}
|
|
43
52
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"yarn skuba configure"
|
|
52
|
-
)}. ${import_chalk.default.dim("no-skuba-template-js")}`
|
|
53
|
+
return results;
|
|
54
|
+
};
|
|
55
|
+
const lintConcurrently = async (mode, logger) => {
|
|
56
|
+
const results = [];
|
|
57
|
+
for (const lintGroup of lints) {
|
|
58
|
+
results.push(
|
|
59
|
+
...await Promise.all(lintGroup.map((lint) => lint(mode, logger)))
|
|
53
60
|
);
|
|
54
|
-
process.exitCode = 1;
|
|
55
61
|
}
|
|
62
|
+
return results;
|
|
63
|
+
};
|
|
64
|
+
const selectLintFunction = (input) => {
|
|
65
|
+
const isSerial = input?.debug || input?.serial;
|
|
66
|
+
return isSerial ? lintSerially : lintConcurrently;
|
|
56
67
|
};
|
|
57
|
-
const internalLint = async () => {
|
|
58
|
-
|
|
68
|
+
const internalLint = async (mode, input) => {
|
|
69
|
+
const start = process.hrtime.bigint();
|
|
70
|
+
const logger = (0, import_logging.createLogger)(
|
|
71
|
+
input?.debug ?? false,
|
|
72
|
+
...mode === "lint" ? [import_chalk.default.blueBright("skuba \u2502")] : []
|
|
73
|
+
);
|
|
74
|
+
try {
|
|
75
|
+
const lint = selectLintFunction(input);
|
|
76
|
+
const results = await lint(mode, logger);
|
|
77
|
+
const result = combineResults(results);
|
|
78
|
+
const end = process.hrtime.bigint();
|
|
79
|
+
logger.plain(`Processed skuba lints in ${logger.timing(start, end)}.`);
|
|
80
|
+
return result;
|
|
81
|
+
} catch (err) {
|
|
82
|
+
logger.err(logger.bold("Failed to run skuba lints."));
|
|
83
|
+
logger.subtle((0, import_util.inspect)(err));
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
return { ok: false, fixable: false, annotations: [] };
|
|
86
|
+
}
|
|
59
87
|
};
|
|
88
|
+
const combineResults = (results) => results.reduce(
|
|
89
|
+
(cur, next) => ({
|
|
90
|
+
ok: cur.ok && next.ok,
|
|
91
|
+
fixable: cur.fixable || next.fixable,
|
|
92
|
+
annotations: [...cur.annotations ?? [], ...next.annotations ?? []]
|
|
93
|
+
}),
|
|
94
|
+
{ ok: true, fixable: false }
|
|
95
|
+
);
|
|
60
96
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
97
|
0 && (module.exports = {
|
|
62
98
|
internalLint
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/internal.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport chalk from 'chalk';\n\nimport { type Logger, createLogger } from '../../utils/logging';\nimport { upgradeSkuba } from '../configure/upgrade';\n\nimport { deleteFilesLint } from './internalLints/deleteFiles';\nimport { noSkubaTemplateJs } from './internalLints/noSkubaTemplateJs';\nimport { tryRefreshConfigFiles } from './internalLints/refreshConfigFiles';\nimport type { Input } from './types';\n\nexport type InternalLintResult = {\n ok: boolean;\n fixable: boolean;\n annotations?: Array<{\n start_line?: number;\n end_line?: number;\n path: string;\n message: string;\n }>;\n};\n\nconst lints: Array<\n Array<\n (mode: 'format' | 'lint', logger: Logger) => Promise<InternalLintResult>\n >\n> = [\n // Run upgradeSkuba before refreshConfigFiles for npmrc handling\n [upgradeSkuba],\n [deleteFilesLint, noSkubaTemplateJs, tryRefreshConfigFiles],\n];\n\nconst lintSerially = async (mode: 'format' | 'lint', logger: Logger) => {\n const results: InternalLintResult[] = [];\n for (const lintGroup of lints) {\n for (const lint of lintGroup) {\n results.push(await lint(mode, logger));\n }\n }\n return results;\n};\n\nconst lintConcurrently = async (mode: 'format' | 'lint', logger: Logger) => {\n const results: InternalLintResult[] = [];\n\n for (const lintGroup of lints) {\n results.push(\n ...(await Promise.all(lintGroup.map((lint) => lint(mode, logger)))),\n );\n }\n\n return results;\n};\n\nconst selectLintFunction = (input?: Input) => {\n const isSerial = input?.debug || input?.serial;\n return isSerial ? lintSerially : lintConcurrently;\n};\n\nexport const internalLint = async (\n mode: 'format' | 'lint',\n input?: Input,\n): Promise<InternalLintResult> => {\n const start = process.hrtime.bigint();\n const logger = createLogger(\n input?.debug ?? false,\n ...(mode === 'lint' ? [chalk.blueBright('skuba \u2502')] : []),\n );\n\n try {\n const lint = selectLintFunction(input);\n const results = await lint(mode, logger);\n const result = combineResults(results);\n const end = process.hrtime.bigint();\n logger.plain(`Processed skuba lints in ${logger.timing(start, end)}.`);\n return result;\n } catch (err) {\n logger.err(logger.bold('Failed to run skuba lints.'));\n logger.subtle(inspect(err));\n\n process.exitCode = 1;\n\n return { ok: false, fixable: false, annotations: [] };\n }\n};\n\nconst combineResults = (results: InternalLintResult[]): InternalLintResult =>\n results.reduce(\n (cur, next) => ({\n ok: cur.ok && next.ok,\n fixable: cur.fixable || next.fixable,\n annotations: [...(cur.annotations ?? []), ...(next.annotations ?? [])],\n }),\n { ok: true, fixable: false },\n );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,mBAAkB;AAElB,qBAA0C;AAC1C,qBAA6B;AAE7B,yBAAgC;AAChC,+BAAkC;AAClC,gCAAsC;AActC,MAAM,QAIF;AAAA;AAAA,EAEF,CAAC,2BAAY;AAAA,EACb,CAAC,oCAAiB,4CAAmB,+CAAqB;AAC5D;AAEA,MAAM,eAAe,OAAO,MAAyB,WAAmB;AACtE,QAAM,UAAgC,CAAC;AACvC,aAAW,aAAa,OAAO;AAC7B,eAAW,QAAQ,WAAW;AAC5B,cAAQ,KAAK,MAAM,KAAK,MAAM,MAAM,CAAC;AAAA,IACvC;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,mBAAmB,OAAO,MAAyB,WAAmB;AAC1E,QAAM,UAAgC,CAAC;AAEvC,aAAW,aAAa,OAAO;AAC7B,YAAQ;AAAA,MACN,GAAI,MAAM,QAAQ,IAAI,UAAU,IAAI,CAAC,SAAS,KAAK,MAAM,MAAM,CAAC,CAAC;AAAA,IACnE;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,qBAAqB,CAAC,UAAkB;AAC5C,QAAM,WAAW,OAAO,SAAS,OAAO;AACxC,SAAO,WAAW,eAAe;AACnC;AAEO,MAAM,eAAe,OAC1B,MACA,UACgC;AAChC,QAAM,QAAQ,QAAQ,OAAO,OAAO;AACpC,QAAM,aAAS;AAAA,IACb,OAAO,SAAS;AAAA,IAChB,GAAI,SAAS,SAAS,CAAC,aAAAA,QAAM,WAAW,iBAAY,CAAC,IAAI,CAAC;AAAA,EAC5D;AAEA,MAAI;AACF,UAAM,OAAO,mBAAmB,KAAK;AACrC,UAAM,UAAU,MAAM,KAAK,MAAM,MAAM;AACvC,UAAM,SAAS,eAAe,OAAO;AACrC,UAAM,MAAM,QAAQ,OAAO,OAAO;AAClC,WAAO,MAAM,4BAA4B,OAAO,OAAO,OAAO,GAAG,CAAC,GAAG;AACrE,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,WAAO,IAAI,OAAO,KAAK,4BAA4B,CAAC;AACpD,WAAO,WAAO,qBAAQ,GAAG,CAAC;AAE1B,YAAQ,WAAW;AAEnB,WAAO,EAAE,IAAI,OAAO,SAAS,OAAO,aAAa,CAAC,EAAE;AAAA,EACtD;AACF;AAEA,MAAM,iBAAiB,CAAC,YACtB,QAAQ;AAAA,EACN,CAAC,KAAK,UAAU;AAAA,IACd,IAAI,IAAI,MAAM,KAAK;AAAA,IACnB,SAAS,IAAI,WAAW,KAAK;AAAA,IAC7B,aAAa,CAAC,GAAI,IAAI,eAAe,CAAC,GAAI,GAAI,KAAK,eAAe,CAAC,CAAE;AAAA,EACvE;AAAA,EACA,EAAE,IAAI,MAAM,SAAS,MAAM;AAC7B;",
|
|
6
|
+
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
11
|
+
};
|
|
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
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var deleteFiles_exports = {};
|
|
30
|
+
__export(deleteFiles_exports, {
|
|
31
|
+
deleteFilesLint: () => deleteFilesLint
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(deleteFiles_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_util = require("util");
|
|
36
|
+
var import_fs_extra = require("fs-extra");
|
|
37
|
+
var import_packageManager = require("../../../utils/packageManager");
|
|
38
|
+
const AUTOFIX_DELETE_FILES = [
|
|
39
|
+
// Try to delete this SEEK-Jobs/gutenberg automation file that may have been
|
|
40
|
+
// accidentally committed in old versions of skuba.
|
|
41
|
+
"Dockerfile-incunabulum"
|
|
42
|
+
];
|
|
43
|
+
const deleteFilesLint = async (mode, logger) => {
|
|
44
|
+
const dir = process.cwd();
|
|
45
|
+
const toDelete = (await Promise.all(
|
|
46
|
+
AUTOFIX_DELETE_FILES.map(
|
|
47
|
+
async (filename) => [filename, await (0, import_fs_extra.pathExists)(import_path.default.join(dir, filename))]
|
|
48
|
+
)
|
|
49
|
+
)).filter(([, exists]) => exists).map(([filename]) => filename);
|
|
50
|
+
if (mode === "format") {
|
|
51
|
+
if (toDelete.length === 0) {
|
|
52
|
+
return { ok: true, fixable: false };
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
await Promise.all(
|
|
56
|
+
toDelete.map((filename) => {
|
|
57
|
+
logger.warn(`Deleting ${logger.bold(filename)}.`);
|
|
58
|
+
return (0, import_fs_extra.rm)(import_path.default.join(dir, filename), { force: true });
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
return {
|
|
62
|
+
ok: true,
|
|
63
|
+
fixable: false
|
|
64
|
+
};
|
|
65
|
+
} catch (err) {
|
|
66
|
+
logger.warn(logger.bold("Failed to delete files."));
|
|
67
|
+
logger.subtle((0, import_util.inspect)(err));
|
|
68
|
+
return {
|
|
69
|
+
ok: true,
|
|
70
|
+
// It's not really a huge deal if we can't delete these files
|
|
71
|
+
fixable: false
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (toDelete.length) {
|
|
76
|
+
const packageManager = await (0, import_packageManager.detectPackageManager)();
|
|
77
|
+
logger.warn(
|
|
78
|
+
`Some files should be deleted. Run ${logger.bold(
|
|
79
|
+
packageManager.exec,
|
|
80
|
+
"skuba",
|
|
81
|
+
"format"
|
|
82
|
+
)} to delete them. ${logger.dim("delete-files")}`
|
|
83
|
+
);
|
|
84
|
+
return {
|
|
85
|
+
ok: false,
|
|
86
|
+
fixable: true,
|
|
87
|
+
annotations: toDelete.map((filename) => ({
|
|
88
|
+
path: filename,
|
|
89
|
+
message: "This file should be deleted."
|
|
90
|
+
}))
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
ok: true,
|
|
95
|
+
fixable: false
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
deleteFilesLint
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=deleteFiles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/lint/internalLints/deleteFiles.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { pathExists, rm } from 'fs-extra';\n\nimport type { Logger } from '../../../utils/logging';\nimport { detectPackageManager } from '../../../utils/packageManager';\nimport type { InternalLintResult } from '../internal';\n\nconst AUTOFIX_DELETE_FILES = [\n // Try to delete this SEEK-Jobs/gutenberg automation file that may have been\n // accidentally committed in old versions of skuba.\n 'Dockerfile-incunabulum',\n];\n\nexport const deleteFilesLint = async (\n mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n const dir = process.cwd();\n\n const toDelete = (\n await Promise.all(\n AUTOFIX_DELETE_FILES.map(\n async (filename) =>\n [filename, await pathExists(path.join(dir, filename))] as const,\n ),\n )\n )\n .filter(([, exists]) => exists)\n .map(([filename]) => filename);\n\n if (mode === 'format') {\n if (toDelete.length === 0) {\n return { ok: true, fixable: false };\n }\n\n try {\n await Promise.all(\n toDelete.map((filename) => {\n logger.warn(`Deleting ${logger.bold(filename)}.`);\n return rm(path.join(dir, filename), { force: true });\n }),\n );\n\n return {\n ok: true,\n fixable: false,\n };\n } catch (err) {\n logger.warn(logger.bold('Failed to delete files.'));\n logger.subtle(inspect(err));\n\n return {\n ok: true, // It's not really a huge deal if we can't delete these files\n fixable: false,\n };\n }\n }\n\n if (toDelete.length) {\n const packageManager = await detectPackageManager();\n\n logger.warn(\n `Some files should be deleted. Run ${logger.bold(\n packageManager.exec,\n 'skuba',\n 'format',\n )} to delete them. ${logger.dim('delete-files')}`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: toDelete.map((filename) => ({\n path: filename,\n message: 'This file should be deleted.',\n })),\n };\n }\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAA+B;AAG/B,4BAAqC;AAGrC,MAAM,uBAAuB;AAAA;AAAA;AAAA,EAG3B;AACF;AAEO,MAAM,kBAAkB,OAC7B,MACA,WACgC;AAChC,QAAM,MAAM,QAAQ,IAAI;AAExB,QAAM,YACJ,MAAM,QAAQ;AAAA,IACZ,qBAAqB;AAAA,MACnB,OAAO,aACL,CAAC,UAAU,UAAM,4BAAW,YAAAA,QAAK,KAAK,KAAK,QAAQ,CAAC,CAAC;AAAA,IACzD;AAAA,EACF,GAEC,OAAO,CAAC,CAAC,EAAE,MAAM,MAAM,MAAM,EAC7B,IAAI,CAAC,CAAC,QAAQ,MAAM,QAAQ;AAE/B,MAAI,SAAS,UAAU;AACrB,QAAI,SAAS,WAAW,GAAG;AACzB,aAAO,EAAE,IAAI,MAAM,SAAS,MAAM;AAAA,IACpC;AAEA,QAAI;AACF,YAAM,QAAQ;AAAA,QACZ,SAAS,IAAI,CAAC,aAAa;AACzB,iBAAO,KAAK,YAAY,OAAO,KAAK,QAAQ,CAAC,GAAG;AAChD,qBAAO,oBAAG,YAAAA,QAAK,KAAK,KAAK,QAAQ,GAAG,EAAE,OAAO,KAAK,CAAC;AAAA,QACrD,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,SAAS;AAAA,MACX;AAAA,IACF,SAAS,KAAK;AACZ,aAAO,KAAK,OAAO,KAAK,yBAAyB,CAAC;AAClD,aAAO,WAAO,qBAAQ,GAAG,CAAC;AAE1B,aAAO;AAAA,QACL,IAAI;AAAA;AAAA,QACJ,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAEA,MAAI,SAAS,QAAQ;AACnB,UAAM,iBAAiB,UAAM,4CAAqB;AAElD,WAAO;AAAA,MACL,qCAAqC,OAAO;AAAA,QAC1C,eAAe;AAAA,QACf;AAAA,QACA;AAAA,MACF,CAAC,oBAAoB,OAAO,IAAI,cAAc,CAAC;AAAA,IACjD;AAEA,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa,SAAS,IAAI,CAAC,cAAc;AAAA,QACvC,MAAM;AAAA,QACN,SAAS;AAAA,MACX,EAAE;AAAA,IACJ;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
|
|
6
|
+
"names": ["path"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
11
|
+
};
|
|
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
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var noSkubaTemplateJs_exports = {};
|
|
30
|
+
__export(noSkubaTemplateJs_exports, {
|
|
31
|
+
noSkubaTemplateJs: () => noSkubaTemplateJs
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(noSkubaTemplateJs_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_fs_extra = require("fs-extra");
|
|
36
|
+
var import_manifest = require("../../../utils/manifest");
|
|
37
|
+
var import_packageManager = require("../../../utils/packageManager");
|
|
38
|
+
const noSkubaTemplateJs = async (_mode, logger) => {
|
|
39
|
+
const [manifest, packageManager] = await Promise.all([
|
|
40
|
+
(0, import_manifest.getConsumerManifest)(),
|
|
41
|
+
(0, import_packageManager.detectPackageManager)()
|
|
42
|
+
]);
|
|
43
|
+
if (!manifest) {
|
|
44
|
+
return { ok: true, fixable: false };
|
|
45
|
+
}
|
|
46
|
+
const templateConfigPath = import_path.default.join(
|
|
47
|
+
import_path.default.dirname(manifest.path),
|
|
48
|
+
"skuba.template.js"
|
|
49
|
+
);
|
|
50
|
+
if (await (0, import_fs_extra.pathExists)(templateConfigPath)) {
|
|
51
|
+
logger.err(
|
|
52
|
+
`Template is incomplete; run ${logger.bold(
|
|
53
|
+
packageManager.exec,
|
|
54
|
+
"skuba",
|
|
55
|
+
"configure"
|
|
56
|
+
)}. ${logger.dim("no-skuba-template-js")}`
|
|
57
|
+
);
|
|
58
|
+
return {
|
|
59
|
+
ok: false,
|
|
60
|
+
fixable: false,
|
|
61
|
+
annotations: [
|
|
62
|
+
{
|
|
63
|
+
path: "skuba.template.js",
|
|
64
|
+
message: `Template is incomplete; run ${packageManager.exec} skuba configure.`
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return { ok: true, fixable: false };
|
|
70
|
+
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
noSkubaTemplateJs
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=noSkubaTemplateJs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/lint/internalLints/noSkubaTemplateJs.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport { pathExists } from 'fs-extra';\n\nimport type { Logger } from '../../../utils/logging';\nimport { getConsumerManifest } from '../../../utils/manifest';\nimport { detectPackageManager } from '../../../utils/packageManager';\nimport type { InternalLintResult } from '../internal';\n\nexport const noSkubaTemplateJs = async (\n _mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n const [manifest, packageManager] = await Promise.all([\n getConsumerManifest(),\n detectPackageManager(),\n ]);\n\n if (!manifest) {\n // This will throw elsewhere\n return { ok: true, fixable: false };\n }\n\n const templateConfigPath = path.join(\n path.dirname(manifest.path),\n 'skuba.template.js',\n );\n\n if (await pathExists(templateConfigPath)) {\n logger.err(\n `Template is incomplete; run ${logger.bold(\n packageManager.exec,\n 'skuba',\n 'configure',\n )}. ${logger.dim('no-skuba-template-js')}`,\n );\n\n return {\n ok: false,\n fixable: false,\n annotations: [\n {\n path: 'skuba.template.js',\n message: `Template is incomplete; run ${packageManager.exec} skuba configure.`,\n },\n ],\n };\n }\n\n return { ok: true, fixable: false };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAA2B;AAG3B,sBAAoC;AACpC,4BAAqC;AAG9B,MAAM,oBAAoB,OAC/B,OACA,WACgC;AAChC,QAAM,CAAC,UAAU,cAAc,IAAI,MAAM,QAAQ,IAAI;AAAA,QACnD,qCAAoB;AAAA,QACpB,4CAAqB;AAAA,EACvB,CAAC;AAED,MAAI,CAAC,UAAU;AAEb,WAAO,EAAE,IAAI,MAAM,SAAS,MAAM;AAAA,EACpC;AAEA,QAAM,qBAAqB,YAAAA,QAAK;AAAA,IAC9B,YAAAA,QAAK,QAAQ,SAAS,IAAI;AAAA,IAC1B;AAAA,EACF;AAEA,MAAI,UAAM,4BAAW,kBAAkB,GAAG;AACxC,WAAO;AAAA,MACL,+BAA+B,OAAO;AAAA,QACpC,eAAe;AAAA,QACf;AAAA,QACA;AAAA,MACF,CAAC,KAAK,OAAO,IAAI,sBAAsB,CAAC;AAAA,IAC1C;AAEA,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,QACX;AAAA,UACE,MAAM;AAAA,UACN,SAAS,+BAA+B,eAAe,IAAI;AAAA,QAC7D;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,IAAI,MAAM,SAAS,MAAM;AACpC;",
|
|
6
|
+
"names": ["path"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Logger } from '../../../utils/logging';
|
|
2
|
+
import type { InternalLintResult } from '../internal';
|
|
3
|
+
export declare const refreshConfigFiles: (mode: 'format' | 'lint', logger: Logger) => Promise<{
|
|
4
|
+
ok: boolean;
|
|
5
|
+
fixable: boolean;
|
|
6
|
+
annotations: {
|
|
7
|
+
path: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}[];
|
|
10
|
+
}>;
|
|
11
|
+
export declare const tryRefreshConfigFiles: (mode: 'format' | 'lint', logger: Logger) => Promise<InternalLintResult>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
11
|
+
};
|
|
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
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var refreshConfigFiles_exports = {};
|
|
30
|
+
__export(refreshConfigFiles_exports, {
|
|
31
|
+
refreshConfigFiles: () => refreshConfigFiles,
|
|
32
|
+
tryRefreshConfigFiles: () => tryRefreshConfigFiles
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(refreshConfigFiles_exports);
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_util = require("util");
|
|
37
|
+
var import_fs_extra = require("fs-extra");
|
|
38
|
+
var import_strip_ansi = __toESM(require("strip-ansi"));
|
|
39
|
+
var import_npmrc = require("../../../utils/npmrc");
|
|
40
|
+
var import_packageManager = require("../../../utils/packageManager");
|
|
41
|
+
var import_template = require("../../../utils/template");
|
|
42
|
+
var import_package = require("../../configure/analysis/package");
|
|
43
|
+
var import_project = require("../../configure/analysis/project");
|
|
44
|
+
var import_ignoreFile = require("../../configure/processing/ignoreFile");
|
|
45
|
+
const ensureNoAuthToken = (fileContents) => fileContents.split("\n").filter((line) => !(0, import_npmrc.hasNpmrcSecret)(line)).join("\n");
|
|
46
|
+
const REFRESHABLE_CONFIG_FILES = [
|
|
47
|
+
{ name: ".eslintignore" },
|
|
48
|
+
{ name: ".gitignore" },
|
|
49
|
+
{ name: ".prettierignore" },
|
|
50
|
+
{
|
|
51
|
+
name: ".npmrc",
|
|
52
|
+
additionalMapping: ensureNoAuthToken,
|
|
53
|
+
if: (packageManager) => packageManager.command === "pnpm"
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
const refreshConfigFiles = async (mode, logger) => {
|
|
57
|
+
const manifest = await (0, import_package.getDestinationManifest)();
|
|
58
|
+
const destinationRoot = import_path.default.dirname(manifest.path);
|
|
59
|
+
const readDestinationFile = (0, import_project.createDestinationFileReader)(destinationRoot);
|
|
60
|
+
const refreshConfigFile = async (filename, packageManager2, additionalMapping = (s) => s, condition = () => true) => {
|
|
61
|
+
if (!condition(packageManager2)) {
|
|
62
|
+
return { needsChange: false };
|
|
63
|
+
}
|
|
64
|
+
const [inputFile, templateFile] = await Promise.all([
|
|
65
|
+
readDestinationFile(filename),
|
|
66
|
+
(0, import_template.readBaseTemplateFile)(`_${filename}`)
|
|
67
|
+
]);
|
|
68
|
+
const data = additionalMapping(
|
|
69
|
+
inputFile ? (0, import_ignoreFile.mergeWithIgnoreFile)(templateFile)(inputFile) : templateFile,
|
|
70
|
+
packageManager2
|
|
71
|
+
);
|
|
72
|
+
const filepath = import_path.default.join(destinationRoot, filename);
|
|
73
|
+
if (mode === "format") {
|
|
74
|
+
if (data === inputFile) {
|
|
75
|
+
return { needsChange: false };
|
|
76
|
+
}
|
|
77
|
+
await (0, import_fs_extra.writeFile)(filepath, data);
|
|
78
|
+
return {
|
|
79
|
+
needsChange: false,
|
|
80
|
+
msg: `Refreshed ${logger.bold(filename)}.`,
|
|
81
|
+
filename
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (data !== inputFile) {
|
|
85
|
+
return {
|
|
86
|
+
needsChange: true,
|
|
87
|
+
msg: `The ${logger.bold(
|
|
88
|
+
filename
|
|
89
|
+
)} file is out of date. Run \`${logger.bold(
|
|
90
|
+
packageManager2.exec,
|
|
91
|
+
"skuba",
|
|
92
|
+
"format"
|
|
93
|
+
)}\` to update it.`,
|
|
94
|
+
filename
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return { needsChange: false };
|
|
98
|
+
};
|
|
99
|
+
const packageManager = await (0, import_packageManager.detectPackageManager)(destinationRoot);
|
|
100
|
+
const results = await Promise.all(
|
|
101
|
+
REFRESHABLE_CONFIG_FILES.map(
|
|
102
|
+
(conf) => refreshConfigFile(
|
|
103
|
+
conf.name,
|
|
104
|
+
packageManager,
|
|
105
|
+
conf.additionalMapping,
|
|
106
|
+
conf.if
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
results.forEach((result) => {
|
|
111
|
+
if (result.msg) {
|
|
112
|
+
logger.warn(result.msg, logger.dim("refresh-config-files"));
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
const anyNeedChanging = results.some(({ needsChange }) => needsChange);
|
|
116
|
+
return {
|
|
117
|
+
ok: !anyNeedChanging,
|
|
118
|
+
fixable: anyNeedChanging,
|
|
119
|
+
annotations: results.flatMap(
|
|
120
|
+
({ needsChange, filename, msg }) => needsChange && msg ? [
|
|
121
|
+
{
|
|
122
|
+
path: filename,
|
|
123
|
+
message: (0, import_strip_ansi.default)(msg)
|
|
124
|
+
}
|
|
125
|
+
] : []
|
|
126
|
+
)
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
const tryRefreshConfigFiles = async (mode, logger) => {
|
|
130
|
+
try {
|
|
131
|
+
return await refreshConfigFiles(mode, logger);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
logger.warn("Failed to refresh config files.");
|
|
134
|
+
logger.subtle((0, import_util.inspect)(err));
|
|
135
|
+
return {
|
|
136
|
+
ok: false,
|
|
137
|
+
fixable: false,
|
|
138
|
+
annotations: []
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
refreshConfigFiles,
|
|
145
|
+
tryRefreshConfigFiles
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=refreshConfigFiles.js.map
|