skuba 10.0.4 → 10.2.0-config-20250421023131

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.
Files changed (64) hide show
  1. package/lib/cli/build/assets.js +13 -7
  2. package/lib/cli/build/assets.js.map +2 -2
  3. package/lib/cli/build/esbuild.js +1 -1
  4. package/lib/cli/build/esbuild.js.map +2 -2
  5. package/lib/cli/format.js +6 -2
  6. package/lib/cli/format.js.map +2 -2
  7. package/lib/cli/init/index.js +5 -1
  8. package/lib/cli/init/index.js.map +2 -2
  9. package/lib/cli/lint/autofix.js +1 -1
  10. package/lib/cli/lint/autofix.js.map +2 -2
  11. package/lib/cli/lint/eslint.js +9 -2
  12. package/lib/cli/lint/eslint.js.map +2 -2
  13. package/lib/cli/lint/internal.js +31 -13
  14. package/lib/cli/lint/internal.js.map +2 -2
  15. package/lib/cli/lint/internalLints/detectBadCodeowners.d.ts +1 -1
  16. package/lib/cli/lint/internalLints/detectBadCodeowners.js +5 -2
  17. package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +2 -2
  18. package/lib/cli/lint/internalLints/refreshConfigFiles.js +1 -1
  19. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
  20. package/lib/cli/lint/internalLints/upgrade/index.d.ts +1 -1
  21. package/lib/cli/lint/internalLints/upgrade/index.js +3 -3
  22. package/lib/cli/lint/internalLints/upgrade/index.js.map +2 -2
  23. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.d.ts +2 -0
  24. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js +35 -0
  25. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/index.js.map +7 -0
  26. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.d.ts +2 -0
  27. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js +109 -0
  28. package/lib/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.js.map +7 -0
  29. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.d.ts +2 -0
  30. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +35 -0
  31. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +7 -0
  32. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.d.ts +3 -0
  33. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js +96 -0
  34. package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/stopBundlingInCDKTests.js.map +7 -0
  35. package/lib/cli/lint/prettier.js +5 -2
  36. package/lib/cli/lint/prettier.js.map +2 -2
  37. package/lib/cli/lint/types.d.ts +4 -0
  38. package/lib/cli/lint/types.js.map +1 -1
  39. package/lib/config/load.d.ts +2 -0
  40. package/lib/config/load.js +75 -0
  41. package/lib/config/load.js.map +7 -0
  42. package/lib/config/types.d.ts +51 -0
  43. package/lib/config/types.js +74 -0
  44. package/lib/config/types.js.map +7 -0
  45. package/lib/index.d.ts +1 -0
  46. package/lib/index.js +5 -2
  47. package/lib/index.js.map +2 -2
  48. package/lib/utils/logging.d.ts +33 -1
  49. package/lib/utils/logging.js +17 -4
  50. package/lib/utils/logging.js.map +2 -2
  51. package/lib/utils/worker.d.ts +5 -0
  52. package/package.json +15 -12
  53. package/template/base/_.gitignore +0 -1
  54. package/template/express-rest-api/.buildkite/pipeline.yml +2 -2
  55. package/template/express-rest-api/package.json +1 -1
  56. package/template/greeter/.buildkite/pipeline.yml +2 -2
  57. package/template/greeter/package.json +2 -2
  58. package/template/koa-rest-api/.buildkite/pipeline.yml +2 -2
  59. package/template/koa-rest-api/package.json +8 -8
  60. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +3 -3
  61. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +4 -0
  62. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +1 -1
  63. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +2 -0
  64. 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)\n .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. ${logger.dim('skuba-patches')}`,\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;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,WACgC;AAChC,QAAM,CAAC,gBAAgB,UAAU,cAAc,IAAI,MAAM,QAAQ,IAAI;AAAA,QACnE,gCAAgB;AAAA,QAChB,qCAAoB;AAAA,QACpB,4CAAqB;AAA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,QAAQ;AAC5B,aAAO;AAAA,QACL,kBAAkB,WAAW,GAC3B,OAAO,SAAS,MAAM,OAAO,MAAM,KAAK,EAC1C;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO,MAAM,kBAAkB,WAAW,EAAE;AAAA,IAC9C;AAAA,EACF;AAEA,EAAC,SAAS,YAAY,MAA2B,UAAU;AAE3D,QAAM,qBAAqB,UAAM,8BAAc,SAAS,WAAW;AAEnE,YAAM,2BAAU,SAAS,MAAM,kBAAkB;AACjD,SAAO,QAAQ;AACf,SAAO,MAAM,wBAAwB;AACrC,SAAO,QAAQ;AAEf,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
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;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;AAE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AAAA,QACX;AAAA;AAAA;AAAA,UAGE,MAAM,SAAS;AAAA,UACf,SAAS,mCAAmC,eAAe,MAAM,IAAI;AAAA,QACvE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,MAAM,mBAAmB;AAGhC,aAAW,EAAE,OAAO,YAAY,KAAK,SAAS;AAC5C,UAAM,SAAS,MAAM,MAAM;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,WAAO,QAAQ;AACf,QAAI,OAAO,WAAW,QAAQ;AAC5B,aAAO;AAAA,QACL,kBAAkB,WAAW,GAC3B,OAAO,SAAS,MAAM,OAAO,MAAM,KAAK,EAC1C;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO,MAAM,kBAAkB,WAAW,EAAE;AAAA,IAC9C;AAAA,EACF;AAEA,EAAC,SAAS,YAAY,MAA2B,UAAU;AAE3D,QAAM,qBAAqB,UAAM,8BAAc,SAAS,WAAW;AAEnE,YAAM,2BAAU,SAAS,MAAM,kBAAkB;AACjD,SAAO,QAAQ;AACf,SAAO,MAAM,wBAAwB;AACrC,SAAO,QAAQ;AAEf,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
6
6
  "names": ["path"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ import type { Patches } from '../..';
2
+ export declare const patches: Patches;
@@ -0,0 +1,35 @@
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_removeYarnIgnoreOptionalFlags = require("./removeYarnIgnoreOptionalFlags");
25
+ const patches = [
26
+ {
27
+ apply: import_removeYarnIgnoreOptionalFlags.tryRemoveYarnIgnoreOptionalFlags,
28
+ description: "Remove yarn --ignore-optional flags in Dockerfiles"
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.0.4/index.ts"],
4
+ "sourcesContent": ["import type { Patches } from '../..';\n\nimport { tryRemoveYarnIgnoreOptionalFlags } from './removeYarnIgnoreOptionalFlags';\n\nexport const patches: Patches = [\n {\n apply: tryRemoveYarnIgnoreOptionalFlags,\n description: 'Remove yarn --ignore-optional flags in Dockerfiles',\n },\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2CAAiD;AAE1C,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { PatchFunction } from '../..';
2
+ export declare const tryRemoveYarnIgnoreOptionalFlags: PatchFunction;
@@ -0,0 +1,109 @@
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 removeYarnIgnoreOptionalFlags_exports = {};
20
+ __export(removeYarnIgnoreOptionalFlags_exports, {
21
+ tryRemoveYarnIgnoreOptionalFlags: () => tryRemoveYarnIgnoreOptionalFlags
22
+ });
23
+ module.exports = __toCommonJS(removeYarnIgnoreOptionalFlags_exports);
24
+ var import_util = require("util");
25
+ var import_fast_glob = require("fast-glob");
26
+ var import_fs_extra = require("fs-extra");
27
+ var import_logging = require("../../../../../../utils/logging");
28
+ const fetchFiles = async (files) => Promise.all(
29
+ files.map(async (file) => {
30
+ const contents = await import_fs_extra.promises.readFile(file, "utf8");
31
+ return {
32
+ file,
33
+ contents
34
+ };
35
+ })
36
+ );
37
+ const regex = /\s*--ignore-optional/;
38
+ const removeYarnIgnoreFlag = (contents) => {
39
+ let isInYarn = false;
40
+ const lines = contents.split("\n");
41
+ for (let i = 0; i < lines.length; i++) {
42
+ const line = lines[i];
43
+ if (line.includes("yarn")) isInYarn = true;
44
+ if (isInYarn && regex.test(line)) {
45
+ lines[i] = line.replace(regex, "");
46
+ if (!lines[i].trim()) {
47
+ lines.splice(i, 1);
48
+ if (i > 0) {
49
+ lines[i - 1] = lines[i - 1].replace(/\s*\\$/, "");
50
+ }
51
+ i--;
52
+ } else if (lines[i] === "\\") {
53
+ lines.splice(i, 1);
54
+ i--;
55
+ }
56
+ isInYarn = false;
57
+ }
58
+ if (!line.endsWith("\\")) isInYarn = false;
59
+ }
60
+ return lines.join("\n");
61
+ };
62
+ const removeYarnIgnoreOptionalFlags = async ({
63
+ mode
64
+ }) => {
65
+ const maybeDockerFilesPaths = await (0, import_fast_glob.glob)(["Dockerfile*"]);
66
+ if (!maybeDockerFilesPaths.length) {
67
+ return {
68
+ result: "skip",
69
+ reason: "no Dockerfiles found"
70
+ };
71
+ }
72
+ const dockerFiles = await fetchFiles(maybeDockerFilesPaths);
73
+ const mapped = dockerFiles.map(({ file, contents }) => ({
74
+ file,
75
+ before: contents,
76
+ after: removeYarnIgnoreFlag(contents)
77
+ }));
78
+ if (!mapped.some(({ before, after }) => before !== after)) {
79
+ return {
80
+ result: "skip",
81
+ reason: "no Dockerfiles to patch"
82
+ };
83
+ }
84
+ if (mode === "lint") {
85
+ return {
86
+ result: "apply"
87
+ };
88
+ }
89
+ await Promise.all(
90
+ mapped.map(async ({ file, after }) => {
91
+ await import_fs_extra.promises.writeFile(file, after);
92
+ })
93
+ );
94
+ return { result: "apply" };
95
+ };
96
+ const tryRemoveYarnIgnoreOptionalFlags = async (config) => {
97
+ try {
98
+ return await removeYarnIgnoreOptionalFlags(config);
99
+ } catch (err) {
100
+ import_logging.log.warn("Failed to remove yarn --ignore-optional flags");
101
+ import_logging.log.subtle((0, import_util.inspect)(err));
102
+ return { result: "skip", reason: "due to an error" };
103
+ }
104
+ };
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ tryRemoveYarnIgnoreOptionalFlags
108
+ });
109
+ //# sourceMappingURL=removeYarnIgnoreOptionalFlags.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/10.0.4/removeYarnIgnoreOptionalFlags.ts"],
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { 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\nconst regex = /\\s*--ignore-optional/;\n\nconst removeYarnIgnoreFlag = (contents: string) => {\n let isInYarn = false;\n\n const lines = contents.split('\\n');\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n\n if (line.includes('yarn')) isInYarn = true;\n\n if (isInYarn && regex.test(line)) {\n lines[i] = line.replace(regex, '');\n\n // If we're now an empty line, remove it and get rid of the \\ at the end of the previous line\n if (!lines[i]!.trim()) {\n lines.splice(i, 1);\n if (i > 0) {\n lines[i - 1] = lines[i - 1]!.replace(/\\s*\\\\$/, '');\n }\n i--;\n } else if (lines[i] === '\\\\') {\n lines.splice(i, 1);\n i--;\n }\n\n isInYarn = false;\n }\n\n if (!line.endsWith('\\\\')) isInYarn = false;\n }\n\n return lines.join('\\n');\n};\n\nconst removeYarnIgnoreOptionalFlags: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const maybeDockerFilesPaths = await glob(['Dockerfile*']);\n\n if (!maybeDockerFilesPaths.length) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles found',\n };\n }\n\n const dockerFiles = await fetchFiles(maybeDockerFilesPaths);\n\n const mapped = dockerFiles.map(({ file, contents }) => ({\n file,\n before: contents,\n after: removeYarnIgnoreFlag(contents),\n }));\n\n if (!mapped.some(({ before, after }) => before !== after)) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles to patch',\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 tryRemoveYarnIgnoreOptionalFlags: PatchFunction = async (\n config,\n) => {\n try {\n return await removeYarnIgnoreOptionalFlags(config);\n } catch (err) {\n log.warn('Failed to remove yarn --ignore-optional fl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AsB,QAAQ;AACjC,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,cAAc,MAAM,WAAW,qBAAqB;AAE1D,QAAM,SAAS,YAAY,IAAI,CAAC,EAAE,MAAM,SAAS,OAAO;AAAA,IACtD;AAAA,IACA,QAAQ;AAAA,IACR,OAAO,qBAAqB,QAAQ;AAAA,EACtC,EAAE;AAEF,MAAI,CAAC,OAAO,KAAK,CAAC,EAAE,QAAQ,MAAM,MAAM,WAAW,KAAK,GAAG;AACzD,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,OAAO,IAAI,OAAO,EAAE,MAAM,MAAM,MAAM;AACpC,YAAM,gBAAAA,SAAG,UAAU,MAAM,KAAK;AAAA,IAChC,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,mCAAkD,OAC7D,WACG;AACH,MAAI;AACF,WAAO,MAAM,8BAA8B,MAAM;AAAA,EACnD,SAAS,KAAK;AACZ,uBAAI,KAAK,+CAA+C;AACxD,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { Patches } from '../..';
2
+ export declare const patches: Patches;
@@ -0,0 +1,35 @@
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,3 @@
1
+ import type { PatchFunction } from '../..';
2
+ export declare const hasAppImportRegex: RegExp;
3
+ export declare const tryStopBundlingInCDKTests: PatchFunction;
@@ -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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/logging");
39
39
  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)(runPrettierInCurrentThread, (0, import_logging.createLogger)(false, LOG_PREFIX));
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, createLogger(false, LOG_PREFIX));\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,OAAO,UAAU,CAAC;AAE9C,MAAM,4BAA4B,CAAC,cACxC;AAAA,EACE,YAAAC,QAAK,MAAM,KAAK,WAAW,aAAa;AAAA,EACxC;AACF;AAEF,IAAI,CAAC,oCAAc;AACjB,sCAAiB,gCAA4B,6BAAa,OAAO,UAAU,CAAC;AAC9E;",
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
  }
@@ -34,4 +34,8 @@ export interface Input {
34
34
  * An override to point to a specific ESLint config file.
35
35
  */
36
36
  eslintConfigFile?: string;
37
+ /**
38
+ * Additional CLI flags that are used for skuba's internal lints.
39
+ */
40
+ additionalFlags?: string[];
37
41
  }
@@ -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,2 @@
1
+ import { type SkubaConfig } from './types';
2
+ export declare const loadSkubaConfig: (cwd?: string) => Promise<SkubaConfig>;
@@ -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
+ assets?: string[] | undefined;
33
+ entryPoint?: string | undefined;
34
+ }, {
35
+ assets?: string[] | undefined;
36
+ entryPoint?: 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>;