skuba 10.1.0 → 10.2.0-config-20250421024010
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/index.d.ts +1 -0
- package/config/index.js +1 -0
- package/lib/cli/build/assets.js +13 -7
- package/lib/cli/build/assets.js.map +2 -2
- package/lib/cli/build/esbuild.js +1 -1
- package/lib/cli/build/esbuild.js.map +2 -2
- package/lib/cli/format.js +6 -2
- package/lib/cli/format.js.map +2 -2
- package/lib/cli/init/index.js +5 -1
- package/lib/cli/init/index.js.map +2 -2
- package/lib/cli/lint/autofix.js +1 -1
- package/lib/cli/lint/autofix.js.map +2 -2
- package/lib/cli/lint/eslint.js +9 -2
- package/lib/cli/lint/eslint.js.map +2 -2
- package/lib/cli/lint/internal.js +31 -13
- package/lib/cli/lint/internal.js.map +2 -2
- package/lib/cli/lint/internalLints/detectBadCodeowners.d.ts +1 -1
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +5 -2
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +1 -1
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.d.ts +1 -1
- package/lib/cli/lint/internalLints/upgrade/index.js +3 -3
- package/lib/cli/lint/internalLints/upgrade/index.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +35 -0
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.d.ts +3 -0
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +96 -0
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +7 -0
- package/lib/cli/lint/prettier.js +5 -2
- package/lib/cli/lint/prettier.js.map +2 -2
- package/lib/cli/lint/types.d.ts +4 -0
- package/lib/cli/lint/types.js.map +1 -1
- package/lib/config/index.d.ts +1 -0
- package/lib/config/index.js +29 -0
- package/lib/config/index.js.map +7 -0
- package/lib/config/load.d.ts +2 -0
- package/lib/config/load.js +75 -0
- package/lib/config/load.js.map +7 -0
- package/lib/config/types.d.ts +51 -0
- package/lib/config/types.js +74 -0
- package/lib/config/types.js.map +7 -0
- package/lib/utils/logging.d.ts +33 -1
- package/lib/utils/logging.js +17 -4
- package/lib/utils/logging.js.map +2 -2
- package/lib/utils/worker.d.ts +5 -0
- package/package.json +14 -11
- package/template/base/_.gitignore +0 -1
- package/template/express-rest-api/.buildkite/pipeline.yml +2 -2
- package/template/express-rest-api/package.json +1 -1
- package/template/greeter/.buildkite/pipeline.yml +2 -2
- package/template/greeter/package.json +2 -2
- package/template/koa-rest-api/.buildkite/pipeline.yml +2 -2
- package/template/koa-rest-api/package.json +8 -8
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +3 -3
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +4 -0
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +1 -1
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +2 -0
- package/template/lambda-sqs-worker-cdk/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/cli/lint/internalLints/upgrade/index.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport { readdir, writeFile } from 'fs-extra';\nimport type readPkgUp from 'read-pkg-up';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../../utils/logging';\nimport { getConsumerManifest } from '../../../../utils/manifest';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../../utils/packageManager';\nimport { getSkubaVersion } from '../../../../utils/version';\nimport { formatPackage } from '../../../configure/processing/package';\nimport type { SkubaPackageJson } from '../../../init/writePackageJson';\nimport type { InternalLintResult } from '../../internal';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\n\nexport type PatchConfig = {\n mode: 'format' | 'lint';\n manifest: readPkgUp.NormalizedReadResult;\n packageManager: PackageManagerConfig;\n dir?: string;\n};\n\nexport type PatchFunction = (config: PatchConfig) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await readdir(path.join(__dirname, 'patches'), {\n withFileTypes: true,\n });\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.flatMap((patch) =>\n // Is a directory rather than a JavaScript source file\n patch.isDirectory() &&\n // Has been added since the last patch run on the project\n gte(patch.name, manifestVersion)\n ? patch.name\n : [],\n ),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest, packageManager] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n detectPackageManager(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = (manifest.packageJson.skuba as SkubaPackageJson)
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAmC;AAEnC,oBAA0B;AAG1B,sBAAoC;AACpC,4BAGO;AACP,qBAAgC;AAChC,qBAA8B;AAsB9B,MAAM,aAAa,OAAO,oBAA8C;AACtE,QAAM,UAAU,UAAM,yBAAQ,YAAAA,QAAK,KAAK,WAAW,SAAS,GAAG;AAAA,IAC7D,eAAe;AAAA,EACjB,CAAC;AAID,QAAM,wBAAoB;AAAA,IACxB,QAAQ;AAAA,MAAQ,CAAC;AAAA;AAAA,QAEf,MAAM,YAAY;AAAA,YAElB,mBAAI,MAAM,MAAM,eAAe,IAC3B,MAAM,OACN,CAAC;AAAA;AAAA,IACP;AAAA,EACF;AAEA,UAAQ,MAAM,QAAQ,IAAI,kBAAkB,IAAI,cAAc,CAAC,GAAG,KAAK;AACzE;AAEA,MAAM,iBAAiB,CAAC,MAAM,IAAI;AAIlC,MAAM,iBAAiB,OAAO,YAAsC;AAClE,aAAW,aAAa,gBAAgB;AACtC,QAAI;AAEF,cAAQ,MAAM,OAAO,aAAa,OAAO,UAAU,SAAS,KAAK;AAAA,IACnE,QAAQ;AAAA,IAER;AAAA,EACF;AACA,QAAM,IAAI,MAAM,iCAAiC,OAAO,EAAE;AAC5D;AAEO,MAAM,eAAe,OAC1B,MACA,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport { readdir, writeFile } from 'fs-extra';\nimport type readPkgUp from 'read-pkg-up';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../../utils/logging';\nimport { getConsumerManifest } from '../../../../utils/manifest';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../../utils/packageManager';\nimport { getSkubaVersion } from '../../../../utils/version';\nimport { formatPackage } from '../../../configure/processing/package';\nimport type { SkubaPackageJson } from '../../../init/writePackageJson';\nimport type { InternalLintResult } from '../../internal';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\n\nexport type PatchConfig = {\n mode: 'format' | 'lint';\n manifest: readPkgUp.NormalizedReadResult;\n packageManager: PackageManagerConfig;\n dir?: string;\n};\n\nexport type PatchFunction = (config: PatchConfig) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await readdir(path.join(__dirname, 'patches'), {\n withFileTypes: true,\n });\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.flatMap((patch) =>\n // Is a directory rather than a JavaScript source file\n patch.isDirectory() &&\n // Has been added since the last patch run on the project\n gte(patch.name, manifestVersion)\n ? patch.name\n : [],\n ),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n additionalFlags: string[] = [],\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest, packageManager] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n detectPackageManager(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = additionalFlags.includes('--force-apply-all-patches')\n ? '1.0.0'\n : (manifest.packageJson.skuba as SkubaPackageJson).version;\n\n // We are up to date, skip patches\n if (gte(manifestVersion, currentVersion)) {\n return { ok: true, fixable: false };\n }\n\n const patches = await getPatches(manifestVersion);\n // No patches to apply even if version out of date. Early exit to avoid unnecessary commits.\n if (patches.length === 0) {\n return { ok: true, fixable: false };\n }\n\n if (mode === 'lint') {\n const results = await Promise.all(\n patches.map(\n async ({ apply }) =>\n await apply({\n mode,\n manifest,\n packageManager,\n }),\n ),\n );\n\n // No patches are applicable. Early exit to avoid unnecessary commits.\n if (results.every(({ result }) => result === 'skip')) {\n return { ok: true, fixable: false };\n }\n\n logger.warn(\n `skuba has patches to apply. Run ${logger.bold(\n packageManager.print.exec,\n 'skuba',\n 'format',\n )} to run them.`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: [\n {\n // package.json as likely skuba version has changed\n // TODO: locate the \"skuba\": {} config in the package.json and annotate on the version property\n path: manifest.path,\n message: `skuba has patches to apply. Run ${packageManager.print.exec} skuba format to run them.`,\n },\n ],\n };\n }\n\n logger.plain('Updating skuba...');\n\n // Run these in series in case a subsequent patch relies on a previous patch\n for (const { apply, description } of patches) {\n const result = await apply({\n mode,\n manifest,\n packageManager,\n });\n logger.newline();\n if (result.result === 'skip') {\n logger.plain(\n `Patch skipped: ${description}${\n result.reason ? ` - ${result.reason}` : ''\n }`,\n );\n } else {\n logger.plain(`Patch applied: ${description}`);\n }\n }\n\n (manifest.packageJson.skuba as SkubaPackageJson).version = currentVersion;\n\n const updatedPackageJson = await formatPackage(manifest.packageJson);\n\n await writeFile(manifest.path, updatedPackageJson);\n logger.newline();\n logger.plain('skuba update complete.');\n logger.newline();\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAmC;AAEnC,oBAA0B;AAG1B,sBAAoC;AACpC,4BAGO;AACP,qBAAgC;AAChC,qBAA8B;AAsB9B,MAAM,aAAa,OAAO,oBAA8C;AACtE,QAAM,UAAU,UAAM,yBAAQ,YAAAA,QAAK,KAAK,WAAW,SAAS,GAAG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@@
|
|
|
1
|
+
"use strict";
|
|
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 __exports = {};
|
|
20
|
+
__export(__exports, {
|
|
21
|
+
patches: () => patches
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(__exports);
|
|
24
|
+
var import_stopBundlingInCDKTests = require("./stopBundlingInCDKTests");
|
|
25
|
+
const patches = [
|
|
26
|
+
{
|
|
27
|
+
apply: import_stopBundlingInCDKTests.tryStopBundlingInCDKTests,
|
|
28
|
+
description: "Stop bundling inside CDK unit tests"
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
patches
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.1.0/index.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Patches } from '../..';\n\nimport { tryStopBundlingInCDKTests } from './stopBundlingInCDKTests';\n\nexport const patches: Patches = [\n {\n apply: tryStopBundlingInCDKTests,\n description: 'Stop bundling inside CDK unit tests',\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oCAA0C;AAEnC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
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 stopBundlingInCDKTests_exports = {};
|
|
20
|
+
__export(stopBundlingInCDKTests_exports, {
|
|
21
|
+
hasAppImportRegex: () => hasAppImportRegex,
|
|
22
|
+
tryStopBundlingInCDKTests: () => tryStopBundlingInCDKTests
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(stopBundlingInCDKTests_exports);
|
|
25
|
+
var import_util = require("util");
|
|
26
|
+
var import_fast_glob = require("fast-glob");
|
|
27
|
+
var import_fs_extra = require("fs-extra");
|
|
28
|
+
var import_logging = require("../../../../../../utils/logging");
|
|
29
|
+
const fetchFiles = async (files) => Promise.all(
|
|
30
|
+
files.map(async (file) => {
|
|
31
|
+
const contents = await import_fs_extra.promises.readFile(file, "utf8");
|
|
32
|
+
return {
|
|
33
|
+
file,
|
|
34
|
+
contents
|
|
35
|
+
};
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
const hasAppImportRegex = /import\s*\{\s*(?:[^}]*,\s*)?App\s*(?:,\s*[^}]*)?\s*\}\s*from\s*['"]aws-cdk-lib['"]/gm;
|
|
39
|
+
const addBundlingContext = (contents) => {
|
|
40
|
+
if (contents.includes("new App()") && hasAppImportRegex.test(contents)) {
|
|
41
|
+
return contents.replaceAll(
|
|
42
|
+
"new App()",
|
|
43
|
+
"new App({ context: { 'aws:cdk:bundling-stacks': [] } })"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return contents;
|
|
47
|
+
};
|
|
48
|
+
const stopBundlingInCDKTests = async ({
|
|
49
|
+
mode
|
|
50
|
+
}) => {
|
|
51
|
+
const infraTestFileNames = await (0, import_fast_glob.glob)(["**/infra/**/*.test.ts"]);
|
|
52
|
+
if (!infraTestFileNames.length) {
|
|
53
|
+
return {
|
|
54
|
+
result: "skip",
|
|
55
|
+
reason: "no CDK test files found"
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const infraTestFiles = await fetchFiles(infraTestFileNames);
|
|
59
|
+
const mapped = infraTestFiles.map(({ file, contents }) => ({
|
|
60
|
+
file,
|
|
61
|
+
before: contents,
|
|
62
|
+
after: addBundlingContext(contents)
|
|
63
|
+
}));
|
|
64
|
+
if (!mapped.some(({ before, after }) => before !== after)) {
|
|
65
|
+
return {
|
|
66
|
+
result: "skip",
|
|
67
|
+
reason: "no CDK test files need patching"
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (mode === "lint") {
|
|
71
|
+
return {
|
|
72
|
+
result: "apply"
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
await Promise.all(
|
|
76
|
+
mapped.map(async ({ file, after }) => {
|
|
77
|
+
await import_fs_extra.promises.writeFile(file, after);
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
return { result: "apply" };
|
|
81
|
+
};
|
|
82
|
+
const tryStopBundlingInCDKTests = async (config) => {
|
|
83
|
+
try {
|
|
84
|
+
return await stopBundlingInCDKTests(config);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
import_logging.log.warn("Failed to remove bundling in CDK tests");
|
|
87
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
88
|
+
return { result: "skip", reason: "due to an error" };
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
hasAppImportRegex,
|
|
94
|
+
tryStopBundlingInCDKTests
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=stopBundlingInCDKTests.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport { promises as fs } from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\nexport const hasAppImportRegex =\n /import\\s*\\{\\s*(?:[^}]*,\\s*)?App\\s*(?:,\\s*[^}]*)?\\s*\\}\\s*from\\s*['\"]aws-cdk-lib['\"]/gm;\n\nconst addBundlingContext = (contents: string) => {\n if (contents.includes('new App()') && hasAppImportRegex.test(contents)) {\n return contents.replaceAll(\n 'new App()',\n \"new App({ context: { 'aws:cdk:bundling-stacks': [] } })\",\n );\n }\n\n return contents;\n};\n\nconst stopBundlingInCDKTests: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const infraTestFileNames = await glob(['**/infra/**/*.test.ts']);\n\n if (!infraTestFileNames.length) {\n return {\n result: 'skip',\n reason: 'no CDK test files found',\n };\n }\n\n const infraTestFiles = await fetchFiles(infraTestFileNames);\n\n const mapped = infraTestFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: addBundlingContext(contents),\n }));\n\n if (!mapped.some(({ before, after }) => before !== after)) {\n return {\n result: 'skip',\n reason: 'no CDK test files need patching',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n mapped.map(async ({ file, after }) => {\n await fs.writeFile(file, after);\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const tryStopBundlingInCDKTests: PatchFunction = async (config) => {\n try {\n return await stopBundlingInCDKTests(config);\n } catch (err) {\n log.warn('Failed to remove bundling in CDK tests');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAA+B;AAG/B,qBAAoB;AAEpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,gBAAAA,SAAG,SAAS,MAAM,MAAM;AAE/C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEK,MAAM,oBACX;AAEF,MAAM,qBAAqB,CAAC,aAAqB;AAC/C,MAAI,SAAS,SAAS,WAAW,KAAK,kBAAkB,KAAK,QAAQ,GAAG;AACtE,WAAO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
|
var import_worker = require("../../utils/worker");
|
|
40
40
|
var import_prettier = require("../adapter/prettier");
|
|
41
41
|
const LOG_PREFIX = import_chalk.default.cyan("Prettier \u2502");
|
|
42
|
-
const runPrettierInCurrentThread = ({ debug }) => (0, import_prettier.runPrettier)("lint", (0, import_logging.createLogger)(debug, LOG_PREFIX));
|
|
42
|
+
const runPrettierInCurrentThread = ({ debug }) => (0, import_prettier.runPrettier)("lint", (0, import_logging.createLogger)({ debug, prefixes: [LOG_PREFIX] }));
|
|
43
43
|
const runPrettierInWorkerThread = (input) => (0, import_worker.execWorkerThread)(
|
|
44
44
|
import_path.default.posix.join(__dirname, "prettier.js"),
|
|
45
45
|
input
|
|
46
46
|
);
|
|
47
47
|
if (!import_worker_threads.isMainThread) {
|
|
48
|
-
(0, import_worker.postWorkerOutput)(
|
|
48
|
+
(0, import_worker.postWorkerOutput)(
|
|
49
|
+
runPrettierInCurrentThread,
|
|
50
|
+
(0, import_logging.createLogger)({ debug: false, prefixes: [LOG_PREFIX] })
|
|
51
|
+
);
|
|
49
52
|
}
|
|
50
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
51
54
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/prettier.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\nimport { isMainThread } from 'worker_threads';\n\nimport chalk from 'chalk';\n\nimport { createLogger } from '../../utils/logging';\nimport { execWorkerThread, postWorkerOutput } from '../../utils/worker';\nimport { type PrettierOutput, runPrettier } from '../adapter/prettier';\n\nimport type { Input } from './types';\n\nconst LOG_PREFIX = chalk.cyan('Prettier \u2502');\n\nexport const runPrettierInCurrentThread = ({ debug }: Input) =>\n runPrettier('lint', createLogger(debug, LOG_PREFIX));\n\nexport const runPrettierInWorkerThread = (input: Input) =>\n execWorkerThread<Input, PrettierOutput>(\n path.posix.join(__dirname, 'prettier.js'),\n input,\n );\n\nif (!isMainThread) {\n postWorkerOutput(runPrettierInCurrentThread
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,4BAA6B;AAE7B,mBAAkB;AAElB,qBAA6B;AAC7B,oBAAmD;AACnD,sBAAiD;AAIjD,MAAM,aAAa,aAAAA,QAAM,KAAK,iBAAY;AAEnC,MAAM,6BAA6B,CAAC,EAAE,MAAM,UACjD,6BAAY,YAAQ,6BAAa,OAAO,UAAU,CAAC;
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { isMainThread } from 'worker_threads';\n\nimport chalk from 'chalk';\n\nimport { createLogger } from '../../utils/logging';\nimport { execWorkerThread, postWorkerOutput } from '../../utils/worker';\nimport { type PrettierOutput, runPrettier } from '../adapter/prettier';\n\nimport type { Input } from './types';\n\nconst LOG_PREFIX = chalk.cyan('Prettier \u2502');\n\nexport const runPrettierInCurrentThread = ({ debug }: Input) =>\n runPrettier('lint', createLogger({ debug, prefixes: [LOG_PREFIX] }));\n\nexport const runPrettierInWorkerThread = (input: Input) =>\n execWorkerThread<Input, PrettierOutput>(\n path.posix.join(__dirname, 'prettier.js'),\n input,\n );\n\nif (!isMainThread) {\n postWorkerOutput(\n runPrettierInCurrentThread,\n createLogger({ debug: false, prefixes: [LOG_PREFIX] }),\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,4BAA6B;AAE7B,mBAAkB;AAElB,qBAA6B;AAC7B,oBAAmD;AACnD,sBAAiD;AAIjD,MAAM,aAAa,aAAAA,QAAM,KAAK,iBAAY;AAEnC,MAAM,6BAA6B,CAAC,EAAE,MAAM,UACjD,6BAAY,YAAQ,6BAAa,EAAE,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC;AAE9D,MAAM,4BAA4B,CAAC,cACxC;AAAA,EACE,YAAAC,QAAK,MAAM,KAAK,WAAW,aAAa;AAAA,EACxC;AACF;AAEF,IAAI,CAAC,oCAAc;AACjB;AAAA,IACE;AAAA,QACA,6BAAa,EAAE,OAAO,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC;AAAA,EACvD;AACF;",
|
|
6
6
|
"names": ["chalk", "path"]
|
|
7
7
|
}
|
package/lib/cli/lint/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/types.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Writable } from 'stream';\n\nexport interface Input {\n /**\n * Whether to enable verbose debug logging.\n *\n * Defaults to `false`.\n */\n debug: boolean;\n\n /**\n * Whether to disable parallelism to run linting operations serially.\n *\n * This can be useful for executing in resource-constrained environments and\n * snapshotting deterministic output in tests.\n *\n * Defaults to `false`.\n */\n serial: boolean;\n\n /**\n * An override output stream that can be supplied to test `tsc` logging.\n *\n * Defaults to `process.stdout`.\n */\n tscOutputStream?: Writable;\n\n /**\n * Whether to allow usage of Node.js worker threads.\n *\n * This may be set to `false` when there is a worker thread incompatibility,\n * such as calling in from a TypeScript context in our Jest tests.\n *\n * Defaults to `true`.\n */\n workerThreads?: boolean;\n\n /**\n * An override to point to a specific ESLint config file.\n */\n eslintConfigFile?: string;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type { Writable } from 'stream';\n\nexport interface Input {\n /**\n * Whether to enable verbose debug logging.\n *\n * Defaults to `false`.\n */\n debug: boolean;\n\n /**\n * Whether to disable parallelism to run linting operations serially.\n *\n * This can be useful for executing in resource-constrained environments and\n * snapshotting deterministic output in tests.\n *\n * Defaults to `false`.\n */\n serial: boolean;\n\n /**\n * An override output stream that can be supplied to test `tsc` logging.\n *\n * Defaults to `process.stdout`.\n */\n tscOutputStream?: Writable;\n\n /**\n * Whether to allow usage of Node.js worker threads.\n *\n * This may be set to `false` when there is a worker thread incompatibility,\n * such as calling in from a TypeScript context in our Jest tests.\n *\n * Defaults to `true`.\n */\n workerThreads?: boolean;\n\n /**\n * An override to point to a specific ESLint config file.\n */\n eslintConfigFile?: string;\n\n /**\n * Additional CLI flags that are used for skuba's internal lints.\n */\n additionalFlags?: string[];\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SkubaConfig } from './types';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
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 config_exports = {};
|
|
20
|
+
__export(config_exports, {
|
|
21
|
+
SkubaConfig: () => import_types.SkubaConfig
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(config_exports);
|
|
24
|
+
var import_types = require("./types");
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
SkubaConfig
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -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 load_exports = {};
|
|
30
|
+
__export(load_exports, {
|
|
31
|
+
loadSkubaConfig: () => loadSkubaConfig
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(load_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
36
|
+
var import_jiti = require("jiti");
|
|
37
|
+
var import_logging = require("../utils/logging");
|
|
38
|
+
var import_types = require("./types");
|
|
39
|
+
const CONFIG_FILENAME = "skuba.config.ts";
|
|
40
|
+
const jiti = (0, import_jiti.createJiti)(__filename);
|
|
41
|
+
const skubaConfigCacheForPath = {};
|
|
42
|
+
const findSkubaConfig = async (cwd) => {
|
|
43
|
+
let currentDir = cwd;
|
|
44
|
+
while (currentDir !== import_path.default.dirname(currentDir)) {
|
|
45
|
+
const filePath = import_path.default.join(currentDir, CONFIG_FILENAME);
|
|
46
|
+
const pathExists = await import_fs_extra.default.pathExists(filePath);
|
|
47
|
+
if (pathExists) {
|
|
48
|
+
return filePath;
|
|
49
|
+
}
|
|
50
|
+
currentDir = import_path.default.dirname(currentDir);
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
54
|
+
const loadSkubaConfig = (cwd = process.cwd()) => {
|
|
55
|
+
const load = async () => {
|
|
56
|
+
const configPath = await findSkubaConfig(cwd);
|
|
57
|
+
if (!configPath) {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const rawConfig = await jiti.import(configPath);
|
|
62
|
+
return import_types.skubaConfigSchema.parse(rawConfig);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
import_logging.log.warn(`Failed to load ${import_logging.log.bold(configPath)}.`);
|
|
65
|
+
import_logging.log.subtle(err);
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return skubaConfigCacheForPath[cwd] ??= load();
|
|
70
|
+
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
loadSkubaConfig
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/config/load.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport { createJiti } from 'jiti';\n\nimport { log } from '../utils/logging';\n\nimport { type SkubaConfig, skubaConfigSchema } from './types';\n\nconst CONFIG_FILENAME = 'skuba.config.ts';\n\nconst jiti = createJiti(__filename);\n\nconst skubaConfigCacheForPath: Record<string, Promise<SkubaConfig>> = {};\n\nconst findSkubaConfig = async (cwd: string): Promise<string | null> => {\n let currentDir = cwd;\n\n while (currentDir !== path.dirname(currentDir)) {\n const filePath = path.join(currentDir, CONFIG_FILENAME);\n const pathExists = await fs.pathExists(filePath);\n\n if (pathExists) {\n return filePath;\n }\n\n currentDir = path.dirname(currentDir);\n }\n\n return null;\n};\n\nexport const loadSkubaConfig = (\n cwd: string = process.cwd(),\n): Promise<SkubaConfig> => {\n const load = async (): Promise<SkubaConfig> => {\n const configPath = await findSkubaConfig(cwd);\n if (!configPath) {\n return {};\n }\n\n try {\n const rawConfig = await jiti.import(configPath);\n return skubaConfigSchema.parse(rawConfig);\n } catch (err) {\n log.warn(`Failed to load ${log.bold(configPath)}.`);\n log.subtle(err);\n\n return {};\n }\n };\n\n return (skubaConfigCacheForPath[cwd] ??= load());\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,kBAA2B;AAE3B,qBAAoB;AAEpB,mBAAoD;AAEpD,MAAM,kBAAkB;AAExB,MAAM,WAAO,wBAAW,UAAU;AAElC,MAAM,0BAAgE,CAAC;AAEvE,MAAM,kBAAkB,OAAO,QAAwC;AACrE,MAAI,aAAa;AAEjB,SAAO,eAAe,YAAAA,QAAK,QAAQ,UAAU,GAAG;AAC9C,UAAM,WAAW,YAAAA,QAAK,KAAK,YAAY,eAAe;AACtD,UAAM,aAAa,MAAM,gBAAAC,QAAG,WAAW,QAAQ;AAE/C,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAEA,iBAAa,YAAAD,QAAK,QAAQ,UAAU;AAAA,EACtC;AAEA,SAAO;AACT;AAEO,MAAM,kBAAkB,CAC7B,MAAc,QAAQ,IAAI,MACD;AACzB,QAAM,OAAO,YAAkC;AAC7C,UAAM,aAAa,MAAM,gBAAgB,GAAG;AAC5C,QAAI,CAAC,YAAY;AACf,aAAO,CAAC;AAAA,IACV;AAEA,QAAI;AACF,YAAM,YAAY,MAAM,KAAK,OAAO,UAAU;AAC9C,aAAO,+BAAkB,MAAM,SAAS;AAAA,IAC1C,SAAS,KAAK;AACZ,yBAAI,KAAK,kBAAkB,mBAAI,KAAK,UAAU,CAAC,GAAG;AAClD,yBAAI,OAAO,GAAG;AAEd,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AAEA,SAAQ,wBAAwB,GAAG,MAAM,KAAK;AAChD;",
|
|
6
|
+
"names": ["path", "fs"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const skubaConfigSchema: z.ZodObject<{
|
|
3
|
+
/**
|
|
4
|
+
* Files to copy from the working directory to the output directory after
|
|
5
|
+
* compilation. This feature is useful to bundle non-JavaScript assets in an
|
|
6
|
+
* npm package, back-end deployment package or container image.
|
|
7
|
+
*
|
|
8
|
+
* Supports `picomatch` glob patterns with dotfile matching.
|
|
9
|
+
*
|
|
10
|
+
* - https://github.com/micromatch/picomatch#globbing-features
|
|
11
|
+
* - https://github.com/micromatch/picomatch#picomatch-options
|
|
12
|
+
*
|
|
13
|
+
* Commands:
|
|
14
|
+
*
|
|
15
|
+
* - `skuba build`
|
|
16
|
+
* - `skuba build-package`
|
|
17
|
+
*/
|
|
18
|
+
assets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
+
/**
|
|
20
|
+
* The entry point to the package or application. For packages, this is the
|
|
21
|
+
* main file that will be imported when the package is required. For applications,
|
|
22
|
+
* this is the main file that will be executed when the application is run.
|
|
23
|
+
*
|
|
24
|
+
* Commands:
|
|
25
|
+
*
|
|
26
|
+
* - `skuba build`
|
|
27
|
+
* - `skuba build-package`
|
|
28
|
+
* - `skuba start`
|
|
29
|
+
*/
|
|
30
|
+
entryPoint: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
entryPoint?: string | undefined;
|
|
33
|
+
assets?: string[] | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
entryPoint?: string | undefined;
|
|
36
|
+
assets?: string[] | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const SkubaConfig: {
|
|
39
|
+
assets: {
|
|
40
|
+
/**
|
|
41
|
+
* The default list of `assets` that are applied if your project does not
|
|
42
|
+
* specify the configuration property.
|
|
43
|
+
*
|
|
44
|
+
* Currently includes:
|
|
45
|
+
*
|
|
46
|
+
* - JSON translation files for https://github.com/seek-oss/vocab
|
|
47
|
+
*/
|
|
48
|
+
default: string[];
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export type SkubaConfig = z.infer<typeof skubaConfigSchema>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
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 types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
SkubaConfig: () => SkubaConfig,
|
|
22
|
+
skubaConfigSchema: () => skubaConfigSchema
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
|
25
|
+
var import_zod = require("zod");
|
|
26
|
+
const skubaConfigSchema = import_zod.z.object({
|
|
27
|
+
/**
|
|
28
|
+
* Files to copy from the working directory to the output directory after
|
|
29
|
+
* compilation. This feature is useful to bundle non-JavaScript assets in an
|
|
30
|
+
* npm package, back-end deployment package or container image.
|
|
31
|
+
*
|
|
32
|
+
* Supports `picomatch` glob patterns with dotfile matching.
|
|
33
|
+
*
|
|
34
|
+
* - https://github.com/micromatch/picomatch#globbing-features
|
|
35
|
+
* - https://github.com/micromatch/picomatch#picomatch-options
|
|
36
|
+
*
|
|
37
|
+
* Commands:
|
|
38
|
+
*
|
|
39
|
+
* - `skuba build`
|
|
40
|
+
* - `skuba build-package`
|
|
41
|
+
*/
|
|
42
|
+
assets: import_zod.z.array(import_zod.z.string()).optional(),
|
|
43
|
+
/**
|
|
44
|
+
* The entry point to the package or application. For packages, this is the
|
|
45
|
+
* main file that will be imported when the package is required. For applications,
|
|
46
|
+
* this is the main file that will be executed when the application is run.
|
|
47
|
+
*
|
|
48
|
+
* Commands:
|
|
49
|
+
*
|
|
50
|
+
* - `skuba build`
|
|
51
|
+
* - `skuba build-package`
|
|
52
|
+
* - `skuba start`
|
|
53
|
+
*/
|
|
54
|
+
entryPoint: import_zod.z.string().optional()
|
|
55
|
+
});
|
|
56
|
+
const SkubaConfig = {
|
|
57
|
+
assets: {
|
|
58
|
+
/**
|
|
59
|
+
* The default list of `assets` that are applied if your project does not
|
|
60
|
+
* specify the configuration property.
|
|
61
|
+
*
|
|
62
|
+
* Currently includes:
|
|
63
|
+
*
|
|
64
|
+
* - JSON translation files for https://github.com/seek-oss/vocab
|
|
65
|
+
*/
|
|
66
|
+
default: ["**/*.vocab/*translations.json"]
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
SkubaConfig,
|
|
72
|
+
skubaConfigSchema
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/config/types.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod';\n\nexport const skubaConfigSchema = z.object({\n /**\n * Files to copy from the working directory to the output directory after\n * compilation. This feature is useful to bundle non-JavaScript assets in an\n * npm package, back-end deployment package or container image.\n *\n * Supports `picomatch` glob patterns with dotfile matching.\n *\n * - https://github.com/micromatch/picomatch#globbing-features\n * - https://github.com/micromatch/picomatch#picomatch-options\n *\n * Commands:\n *\n * - `skuba build`\n * - `skuba build-package`\n */\n assets: z.array(z.string()).optional(),\n\n /**\n * The entry point to the package or application. For packages, this is the\n * main file that will be imported when the package is required. For applications,\n * this is the main file that will be executed when the application is run.\n *\n * Commands:\n *\n * - `skuba build`\n * - `skuba build-package`\n * - `skuba start`\n */\n entryPoint: z.string().optional(),\n});\n\nexport const SkubaConfig = {\n assets: {\n /**\n * The default list of `assets` that are applied if your project does not\n * specify the configuration property.\n *\n * Currently includes:\n *\n * - JSON translation files for https://github.com/seek-oss/vocab\n */\n default: ['**/*.vocab/*translations.json'],\n },\n};\n\nexport type SkubaConfig = z.infer<typeof skubaConfigSchema>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAEX,MAAM,oBAAoB,aAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBxC,QAAQ,aAAE,MAAM,aAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAarC,YAAY,aAAE,OAAO,EAAE,SAAS;AAClC,CAAC;AAEM,MAAM,cAAc;AAAA,EACzB,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASN,SAAS,CAAC,+BAA+B;AAAA,EAC3C;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/utils/logging.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
export type Logger = typeof log;
|
|
3
|
-
export declare const createLogger: (debug
|
|
3
|
+
export declare const createLogger: ({ debug, prefixes, suffixes, }: {
|
|
4
|
+
debug: boolean;
|
|
5
|
+
prefixes?: unknown[];
|
|
6
|
+
suffixes?: unknown[];
|
|
7
|
+
}) => {
|
|
8
|
+
settings: {
|
|
9
|
+
debug: boolean;
|
|
10
|
+
prefixes: unknown[];
|
|
11
|
+
suffixes: unknown[];
|
|
12
|
+
};
|
|
4
13
|
bold: chalk.Chalk;
|
|
5
14
|
dim: chalk.Chalk;
|
|
6
15
|
formatSubtle: chalk.Chalk;
|
|
@@ -14,6 +23,29 @@ export declare const createLogger: (debug: boolean, ...prefixes: unknown[]) => {
|
|
|
14
23
|
warn: (...message: unknown[]) => void;
|
|
15
24
|
};
|
|
16
25
|
export declare const log: {
|
|
26
|
+
settings: {
|
|
27
|
+
debug: boolean;
|
|
28
|
+
prefixes: unknown[];
|
|
29
|
+
suffixes: unknown[];
|
|
30
|
+
};
|
|
31
|
+
bold: chalk.Chalk;
|
|
32
|
+
dim: chalk.Chalk;
|
|
33
|
+
formatSubtle: chalk.Chalk;
|
|
34
|
+
timing: (start: bigint, end: bigint) => string;
|
|
35
|
+
debug: (...message: unknown[]) => void;
|
|
36
|
+
subtle: (...message: unknown[]) => void;
|
|
37
|
+
err: (...message: unknown[]) => void;
|
|
38
|
+
newline: () => void;
|
|
39
|
+
ok: (...message: unknown[]) => void;
|
|
40
|
+
plain: (...message: unknown[]) => void;
|
|
41
|
+
warn: (...message: unknown[]) => void;
|
|
42
|
+
};
|
|
43
|
+
export declare const childLogger: (logger: Logger, settings: Partial<Logger["settings"]>) => {
|
|
44
|
+
settings: {
|
|
45
|
+
debug: boolean;
|
|
46
|
+
prefixes: unknown[];
|
|
47
|
+
suffixes: unknown[];
|
|
48
|
+
};
|
|
17
49
|
bold: chalk.Chalk;
|
|
18
50
|
dim: chalk.Chalk;
|
|
19
51
|
formatSubtle: chalk.Chalk;
|
package/lib/utils/logging.js
CHANGED
|
@@ -28,15 +28,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var logging_exports = {};
|
|
30
30
|
__export(logging_exports, {
|
|
31
|
+
childLogger: () => childLogger,
|
|
31
32
|
createLogger: () => createLogger,
|
|
32
33
|
log: () => log,
|
|
33
34
|
pluralise: () => pluralise
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(logging_exports);
|
|
36
37
|
var import_chalk = __toESM(require("chalk"));
|
|
37
|
-
const createLogger = (
|
|
38
|
-
|
|
38
|
+
const createLogger = ({
|
|
39
|
+
debug,
|
|
40
|
+
prefixes = [],
|
|
41
|
+
suffixes = []
|
|
42
|
+
}) => {
|
|
43
|
+
const logWithoutSuffixes = (...message) => console.log(...prefixes, ...message);
|
|
44
|
+
const log2 = (...message) => logWithoutSuffixes(...message, ...suffixes);
|
|
39
45
|
return {
|
|
46
|
+
settings: { debug, prefixes, suffixes },
|
|
40
47
|
bold: import_chalk.default.bold,
|
|
41
48
|
dim: import_chalk.default.dim,
|
|
42
49
|
formatSubtle: import_chalk.default.grey,
|
|
@@ -44,16 +51,22 @@ const createLogger = (debug, ...prefixes) => {
|
|
|
44
51
|
debug: (...message) => debug ? log2(import_chalk.default.grey(...message)) : void 0,
|
|
45
52
|
subtle: (...message) => log2(import_chalk.default.grey(...message)),
|
|
46
53
|
err: (...message) => log2(import_chalk.default.red(...message)),
|
|
47
|
-
newline: () =>
|
|
54
|
+
newline: () => logWithoutSuffixes(),
|
|
48
55
|
ok: (...message) => log2(import_chalk.default.green(...message)),
|
|
49
56
|
plain: (...message) => log2(...message),
|
|
50
57
|
warn: (...message) => log2(import_chalk.default.yellow(...message))
|
|
51
58
|
};
|
|
52
59
|
};
|
|
53
|
-
const log = createLogger(false);
|
|
60
|
+
const log = createLogger({ debug: false });
|
|
61
|
+
const childLogger = (logger, settings) => createLogger({
|
|
62
|
+
debug: settings.debug ?? logger.settings.debug,
|
|
63
|
+
prefixes: [...settings.prefixes ?? [], ...logger.settings.prefixes],
|
|
64
|
+
suffixes: [...logger.settings.suffixes, ...settings.suffixes ?? []]
|
|
65
|
+
});
|
|
54
66
|
const pluralise = (count, subject) => `${count} ${subject}${count === 1 ? "" : "s"}`;
|
|
55
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56
68
|
0 && (module.exports = {
|
|
69
|
+
childLogger,
|
|
57
70
|
createLogger,
|
|
58
71
|
log,
|
|
59
72
|
pluralise
|