skuba 13.0.0-subpath-imports-20251003044159 → 13.0.0-subpath-imports-20251014043316

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 (48) hide show
  1. package/lib/cli/build/esbuild.js +3 -1
  2. package/lib/cli/build/esbuild.js.map +2 -2
  3. package/lib/cli/configure/ensureTemplateCompletion.js +1 -1
  4. package/lib/cli/configure/ensureTemplateCompletion.js.map +2 -2
  5. package/lib/cli/configure/modules/index.js +1 -1
  6. package/lib/cli/configure/modules/index.js.map +2 -2
  7. package/lib/cli/init/getConfig.d.ts +1 -1
  8. package/lib/cli/init/getConfig.js +5 -7
  9. package/lib/cli/init/getConfig.js.map +3 -3
  10. package/lib/cli/init/prompts.d.ts +5 -5
  11. package/lib/cli/init/prompts.js +4 -5
  12. package/lib/cli/init/prompts.js.map +3 -3
  13. package/lib/cli/lint/internalLints/upgrade/index.js +7 -3
  14. package/lib/cli/lint/internalLints/upgrade/index.js.map +2 -2
  15. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.d.ts +23 -0
  16. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js +355 -0
  17. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.js.map +7 -0
  18. package/lib/cli/lint/internalLints/upgrade/patches/{13.0.0 → 12.4.1}/index.js +15 -0
  19. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/index.js.map +7 -0
  20. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.d.ts +2 -0
  21. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js +152 -0
  22. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.js.map +7 -0
  23. package/lib/cli/lint/internalLints/upgrade/patches/{13.0.0 → 12.4.1}/rewriteSrcImports.js +7 -3
  24. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/rewriteSrcImports.js.map +7 -0
  25. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.d.ts +3 -0
  26. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js +399 -0
  27. package/lib/cli/lint/internalLints/upgrade/patches/12.4.1/updateLambdaConfigs.js.map +7 -0
  28. package/lib/cli/start/index.js +2 -4
  29. package/lib/cli/start/index.js.map +2 -2
  30. package/package.json +6 -6
  31. package/template/base/tsconfig.build.json +3 -0
  32. package/template/base/tsconfig.json +0 -1
  33. package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
  34. package/template/express-rest-api/Dockerfile +1 -0
  35. package/template/express-rest-api/package.json +1 -1
  36. package/template/greeter/.buildkite/pipeline.yml +1 -1
  37. package/template/greeter/package.json +1 -1
  38. package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
  39. package/template/koa-rest-api/Dockerfile +1 -0
  40. package/template/koa-rest-api/package.json +1 -1
  41. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
  42. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +3 -0
  43. package/template/lambda-sqs-worker-cdk/package.json +1 -1
  44. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/index.js.map +0 -7
  45. package/lib/cli/lint/internalLints/upgrade/patches/13.0.0/rewriteSrcImports.js.map +0 -7
  46. package/template/lambda-sqs-worker-cdk/tsconfig.json +0 -14
  47. /package/lib/cli/lint/internalLints/upgrade/patches/{13.0.0 → 12.4.1}/index.d.ts +0 -0
  48. /package/lib/cli/lint/internalLints/upgrade/patches/{13.0.0 → 12.4.1}/rewriteSrcImports.d.ts +0 -0
@@ -0,0 +1,355 @@
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 configureTsConfigForESM_exports = {};
30
+ __export(configureTsConfigForESM_exports, {
31
+ addJestModuleNameMapper: () => addJestModuleNameMapper,
32
+ configureTsConfigForESM: () => configureTsConfigForESM,
33
+ parsePackageJson: () => parsePackageJson,
34
+ tryConfigureTsConfigForESM: () => tryConfigureTsConfigForESM,
35
+ updatePackageJson: () => updatePackageJson
36
+ });
37
+ module.exports = __toCommonJS(configureTsConfigForESM_exports);
38
+ var import_path = __toESM(require("path"));
39
+ var import_util = require("util");
40
+ var import_fast_glob = require("fast-glob");
41
+ var import_fs_extra = __toESM(require("fs-extra"));
42
+ var import_typescript = __toESM(require("typescript"));
43
+ var z = __toESM(require("zod"));
44
+ var import__ = require("../../../../../../index.js");
45
+ var import_logging = require("../../../../../../utils/logging.js");
46
+ const packageJsonSchema = z.looseObject({
47
+ imports: z.record(z.string(), z.record(z.string(), z.string())).optional()
48
+ });
49
+ const tsConfigSchema = z.looseObject({
50
+ compilerOptions: z.looseObject({
51
+ customConditions: z.array(z.string()).optional(),
52
+ rootDir: z.string().optional(),
53
+ paths: z.record(z.string(), z.union([z.array(z.string()), z.null()])).optional()
54
+ }).optional()
55
+ });
56
+ const fetchFiles = async (patterns) => {
57
+ const files = await (0, import_fast_glob.glob)(patterns, {
58
+ ignore: ["**/.git", "**/node_modules"]
59
+ });
60
+ return Promise.all(
61
+ files.map(async (file) => {
62
+ const contents = await import_fs_extra.default.promises.readFile(file, "utf8");
63
+ return {
64
+ file,
65
+ contents
66
+ };
67
+ })
68
+ );
69
+ };
70
+ const addJestModuleNameMapper = (contents, srcPaths) => {
71
+ if (!srcPaths.length) {
72
+ return contents;
73
+ }
74
+ const moduleNameRegex = /moduleNameMapper:\s*\{([\s\S]*?)\}/;
75
+ const match = moduleNameRegex.exec(contents);
76
+ const srcPathArray = srcPaths.map(
77
+ (subfolderPath) => subfolderPath === "." || subfolderPath === "./" ? "<rootDir>/src/$1" : `<rootDir>/${subfolderPath}/src/$1`
78
+ );
79
+ const srcModuleMappers = JSON.stringify({
80
+ "^#src/(.*)\\.js$": srcPathArray,
81
+ "^#src/(.*)$": srcPathArray
82
+ });
83
+ const newModuleNameMapper = srcModuleMappers.replace(/^{/, "").replace(/}$/, "");
84
+ if (match?.[1] !== void 0) {
85
+ const existingModuleMappers = match[1];
86
+ const optionalComma = !/[,\s]*$/.test(existingModuleMappers) ? "" : ",";
87
+ const newContents = `${contents.slice(
88
+ 0,
89
+ match.index
90
+ )}moduleNameMapper: {${existingModuleMappers}${optionalComma}${newModuleNameMapper}}${contents.slice(
91
+ match.index + match[0].length
92
+ )}`;
93
+ return newContents;
94
+ }
95
+ const moduleNameMapperFunctionRegex = /moduleNameMapper:\s*([a-zA-Z_$][\w$]*(?:\([^)]*\))?)/;
96
+ const functionMatch = moduleNameMapperFunctionRegex.exec(contents);
97
+ if (functionMatch?.[1] !== void 0) {
98
+ const functionBody = functionMatch[1];
99
+ const optionalComma = !/[,\s]*$/.test(functionBody) ? "" : ",";
100
+ const newContents = `${contents.slice(
101
+ 0,
102
+ functionMatch.index
103
+ )}moduleNameMapper: {...${functionBody}${optionalComma}${newModuleNameMapper}}${contents.slice(
104
+ functionMatch.index + functionMatch[0].length
105
+ )}}`;
106
+ return newContents;
107
+ }
108
+ const insertionPointRegex = /(\b(jest|export\s+default)\b[\s\S]*?{)/;
109
+ const insertionMatch = insertionPointRegex.exec(contents);
110
+ if (insertionMatch?.[1] !== void 0) {
111
+ const insertionIndex = insertionMatch.index + insertionMatch[0].length;
112
+ const moduleNameMapperString = `
113
+ moduleNameMapper: {${newModuleNameMapper}},`;
114
+ const newContents = contents.slice(0, insertionIndex) + moduleNameMapperString + contents.slice(insertionIndex);
115
+ return newContents;
116
+ }
117
+ import_logging.log.warn(
118
+ "Could not find a suitable place to insert moduleNameMapper in jest config"
119
+ );
120
+ return contents;
121
+ };
122
+ const parsePackageJson = (contents) => {
123
+ try {
124
+ const parsedJson = JSON.parse(contents);
125
+ return {
126
+ original: parsedJson,
127
+ parsed: packageJsonSchema.parse(parsedJson)
128
+ };
129
+ } catch (error) {
130
+ import_logging.log.warn(`Failed to parse package.json as JSON: ${String(error)}`);
131
+ return null;
132
+ }
133
+ };
134
+ const updatePackageJson = ({
135
+ parsed,
136
+ customCondition
137
+ }) => {
138
+ parsed.imports ??= {};
139
+ parsed.imports["#src/*"] ??= {
140
+ [customCondition]: "./src/*",
141
+ default: "./lib/*"
142
+ };
143
+ return {
144
+ parsed
145
+ };
146
+ };
147
+ const parseTsconfig = (file, contents) => {
148
+ try {
149
+ const parsedJson = import_typescript.default.parseConfigFileTextToJson(file, contents);
150
+ const tsconfig = tsConfigSchema.parse(parsedJson.config);
151
+ return {
152
+ original: parsedJson.config,
153
+ parsed: tsconfig,
154
+ srcPaths: tsconfig.compilerOptions?.paths?.["./src/*"] ?? []
155
+ };
156
+ } catch (error) {
157
+ import_logging.log.warn(`Failed to parse root tsconfig.json as JSON: ${String(error)}`);
158
+ return null;
159
+ }
160
+ };
161
+ const updateTsConfig = ({
162
+ parsed,
163
+ customCondition,
164
+ file
165
+ }) => {
166
+ if (file === "tsconfig.json") {
167
+ parsed.compilerOptions ??= {};
168
+ parsed.compilerOptions.customConditions ??= [];
169
+ if (parsed.compilerOptions.customConditions.includes(customCondition) && customCondition !== "@seek/skuba/source") {
170
+ throw new Error(
171
+ `Custom condition ${customCondition} already exists in tsconfig.json`
172
+ );
173
+ }
174
+ if (!parsed.compilerOptions.customConditions.includes(customCondition)) {
175
+ parsed.compilerOptions.customConditions.push(customCondition);
176
+ }
177
+ }
178
+ let srcPaths = [];
179
+ ["./src/*", "src/*", "src"].forEach((key) => {
180
+ if (parsed.compilerOptions?.paths?.[key]) {
181
+ srcPaths = parsed.compilerOptions.paths[key];
182
+ delete parsed.compilerOptions.paths[key];
183
+ }
184
+ });
185
+ if (parsed.compilerOptions?.paths && Object.keys(parsed.compilerOptions.paths).length === 0) {
186
+ delete parsed.compilerOptions.paths;
187
+ }
188
+ return {
189
+ parsed,
190
+ srcPaths
191
+ };
192
+ };
193
+ const tryConfigureTsConfigForESM = async ({
194
+ mode
195
+ }) => {
196
+ let customCondition;
197
+ try {
198
+ const { repo } = await import__.Git.getOwnerAndRepo({ dir: process.cwd() });
199
+ customCondition = `@seek/${repo}/source`;
200
+ } catch {
201
+ return { result: "skip", reason: "no repository name found" };
202
+ }
203
+ const tsconfigJsonPatterns = ["**/tsconfig.json"];
204
+ const tsconfigBuildJsonPatterns = ["**/tsconfig.build.json"];
205
+ const jestConfigPatterns = ["**/jest.config.ts", "**/jest.config.*.ts"];
206
+ const [tsconfigJsonFiles, tsconfigBuildJsonFiles, jestConfigFiles] = await Promise.all([
207
+ fetchFiles(tsconfigJsonPatterns),
208
+ fetchFiles(tsconfigBuildJsonPatterns),
209
+ fetchFiles(jestConfigPatterns)
210
+ ]);
211
+ const parsedTsconfigFiles = tsconfigJsonFiles.flatMap(
212
+ ({ file, contents }) => {
213
+ const parsed = parseTsconfig(file, contents);
214
+ return parsed ? [{ file, ...parsed }] : [];
215
+ }
216
+ );
217
+ const parsedTsconfigBuildFiles = tsconfigBuildJsonFiles.flatMap(
218
+ ({ file, contents }) => {
219
+ const parsed = parseTsconfig(file, contents);
220
+ return parsed ? [{ file, ...parsed }] : [];
221
+ }
222
+ );
223
+ if (parsedTsconfigFiles.length === 0) {
224
+ return { result: "skip", reason: "no valid tsconfig.json files found" };
225
+ }
226
+ const updatedTsconfigFiles = parsedTsconfigFiles.map(
227
+ ({ file, parsed, original }) => ({
228
+ file,
229
+ original,
230
+ ...updateTsConfig({ parsed, customCondition, file })
231
+ })
232
+ );
233
+ const allSrcPaths = [
234
+ ...new Set(
235
+ updatedTsconfigFiles.flatMap(
236
+ ({ srcPaths, file }) => srcPaths.flatMap((p) => {
237
+ const regex = /(.*)src\/?\*?$/;
238
+ const match = regex.exec(p);
239
+ if (match?.[1] !== void 0) {
240
+ return [
241
+ import_path.default.join(import_path.default.dirname(file), match[1].replace(/\/?$/, ""))
242
+ ];
243
+ }
244
+ import_logging.log.warn(
245
+ `Unexpected src path format in ${file}: ${p}. Expected format like "apps/api/src/*"`
246
+ );
247
+ return [];
248
+ })
249
+ )
250
+ )
251
+ ];
252
+ const packageJsonPatterns = allSrcPaths.map(
253
+ (srcPath) => import_path.default.join(srcPath, "package.json")
254
+ );
255
+ const packageJsonFiles = await fetchFiles(packageJsonPatterns);
256
+ const parsedPackageJsonFiles = packageJsonFiles.flatMap(
257
+ ({ file, contents }) => {
258
+ const parsed = parsePackageJson(contents);
259
+ return parsed ? [{ file, ...parsed }] : [];
260
+ }
261
+ );
262
+ parsedPackageJsonFiles.forEach(({ parsed, file }) => {
263
+ updatePackageJson({ parsed, customCondition });
264
+ const relativeTsconfigPath = import_path.default.join(import_path.default.dirname(file), "tsconfig.json");
265
+ const relativeTsconfig = updatedTsconfigFiles.find(
266
+ (tsconfig) => tsconfig.file === relativeTsconfigPath
267
+ );
268
+ if (relativeTsconfig) {
269
+ relativeTsconfig.parsed.compilerOptions ??= {};
270
+ relativeTsconfig.parsed.compilerOptions.rootDir ??= ".";
271
+ } else {
272
+ import_logging.log.warn(
273
+ `No corresponding tsconfig.json found for package.json at ${file}. Expected at ${relativeTsconfigPath}`
274
+ );
275
+ }
276
+ const relativeTsconfigBuildPath = import_path.default.join(
277
+ import_path.default.dirname(file),
278
+ "tsconfig.build.json"
279
+ );
280
+ const relativeTsconfigBuild = parsedTsconfigBuildFiles.find(
281
+ (tsconfig) => tsconfig.file === relativeTsconfigBuildPath
282
+ );
283
+ if (relativeTsconfigBuild) {
284
+ relativeTsconfigBuild.parsed.compilerOptions ??= {};
285
+ relativeTsconfigBuild.parsed.compilerOptions.rootDir ??= "src";
286
+ } else {
287
+ import_logging.log.warn(
288
+ `No corresponding tsconfig.build.json found for package.json at ${file}. Expected at ${relativeTsconfigBuildPath}`
289
+ );
290
+ }
291
+ });
292
+ const updatedJestConfigFiles = jestConfigFiles.map(({ file, contents }) => {
293
+ const parsed = addJestModuleNameMapper(contents, allSrcPaths);
294
+ return { file, original: contents, parsed };
295
+ });
296
+ const hasJestConfigsChanged = updatedJestConfigFiles.some(
297
+ ({ parsed, original }) => original !== parsed
298
+ );
299
+ const hasRelativeTsconfigBuildsChanged = parsedTsconfigBuildFiles.some(
300
+ ({ original, parsed }) => JSON.stringify(original) !== JSON.stringify(parsed)
301
+ );
302
+ const hasPackageJsonsChanged = parsedPackageJsonFiles.some(
303
+ ({ original, parsed }) => JSON.stringify(original) !== JSON.stringify(parsed)
304
+ );
305
+ const hasRootTsconfigChanged = updatedTsconfigFiles.some(
306
+ ({ original, parsed }) => JSON.stringify(original) !== JSON.stringify(parsed)
307
+ );
308
+ if (mode === "lint" && (hasRootTsconfigChanged || hasPackageJsonsChanged || hasRelativeTsconfigBuildsChanged || hasJestConfigsChanged)) {
309
+ return { result: "apply" };
310
+ }
311
+ if (!hasRootTsconfigChanged && !hasPackageJsonsChanged && !hasRelativeTsconfigBuildsChanged && !hasJestConfigsChanged) {
312
+ return { result: "skip", reason: "no changes required" };
313
+ }
314
+ const jsonFilePromises = Promise.all(
315
+ [
316
+ ...updatedTsconfigFiles,
317
+ ...parsedTsconfigBuildFiles,
318
+ ...parsedPackageJsonFiles
319
+ ].map(async ({ file, parsed, original }) => {
320
+ if (JSON.stringify(original) === JSON.stringify(parsed)) {
321
+ return;
322
+ }
323
+ const updatedContents = JSON.stringify(parsed, null, 2);
324
+ await import_fs_extra.default.promises.writeFile(file, updatedContents);
325
+ })
326
+ );
327
+ const otherFilePromises = Promise.all(
328
+ updatedJestConfigFiles.map(async ({ file, parsed, original }) => {
329
+ if (original === parsed) {
330
+ return;
331
+ }
332
+ await import_fs_extra.default.promises.writeFile(file, parsed);
333
+ })
334
+ );
335
+ await Promise.all([jsonFilePromises, otherFilePromises]);
336
+ return { result: "apply" };
337
+ };
338
+ const configureTsConfigForESM = async (config) => {
339
+ try {
340
+ return await tryConfigureTsConfigForESM(config);
341
+ } catch (err) {
342
+ import_logging.log.warn("Failed to write configure `tsconfig.json` and `package.json`");
343
+ import_logging.log.subtle((0, import_util.inspect)(err));
344
+ return { result: "skip", reason: "due to an error" };
345
+ }
346
+ };
347
+ // Annotate the CommonJS export names for ESM import in node:
348
+ 0 && (module.exports = {
349
+ addJestModuleNameMapper,
350
+ configureTsConfigForESM,
351
+ parsePackageJson,
352
+ tryConfigureTsConfigForESM,
353
+ updatePackageJson
354
+ });
355
+ //# sourceMappingURL=configureTsConfigForESM.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/configureTsConfigForESM.ts"],
4
+ "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\nimport ts from 'typescript';\nimport * as z from 'zod';\n\nimport { Git } from '../../../../../../index.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst packageJsonSchema = z.looseObject({\n imports: z.record(z.string(), z.record(z.string(), z.string())).optional(),\n});\n\ntype PackageJson = z.infer<typeof packageJsonSchema>;\n\nconst tsConfigSchema = z.looseObject({\n compilerOptions: z\n .looseObject({\n customConditions: z.array(z.string()).optional(),\n rootDir: z.string().optional(),\n paths: z\n .record(z.string(), z.union([z.array(z.string()), z.null()]))\n .optional(),\n })\n .optional(),\n});\n\ntype TsConfig = z.infer<typeof tsConfigSchema>;\n\nconst fetchFiles = async (patterns: string[]) => {\n const files = await glob(patterns, {\n ignore: ['**/.git', '**/node_modules'],\n });\n\n return Promise.all(\n files.map(async (file) => {\n const contents = await fs.promises.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n};\n\nexport const addJestModuleNameMapper = (\n contents: string,\n srcPaths: string[],\n) => {\n if (!srcPaths.length) {\n return contents;\n }\n const moduleNameRegex = /moduleNameMapper:\\s*\\{([\\s\\S]*?)\\}/;\n const match = moduleNameRegex.exec(contents);\n\n const srcPathArray = srcPaths.map((subfolderPath) =>\n subfolderPath === '.' || subfolderPath === './'\n ? '<rootDir>/src/$1'\n : `<rootDir>/${subfolderPath}/src/$1`,\n );\n\n const srcModuleMappers = JSON.stringify({\n '^#src/(.*)\\\\.js$': srcPathArray,\n '^#src/(.*)$': srcPathArray,\n });\n\n // strip the surrounding { } from the JSON stringify result\n const newModuleNameMapper = srcModuleMappers\n .replace(/^{/, '')\n .replace(/}$/, '');\n\n if (match?.[1] !== undefined) {\n // insert srcModuleMappers into existing moduleNameMapper\n const existingModuleMappers = match[1];\n\n const optionalComma = !/[,\\s]*$/.test(existingModuleMappers) ? '' : ',';\n const newContents = `${contents.slice(\n 0,\n match.index,\n )}moduleNameMapper: {${existingModuleMappers}${optionalComma}${newModuleNameMapper}}${contents.slice(\n match.index + match[0].length,\n )}`;\n\n return newContents;\n }\n\n // match against function calls\n\n // Match function calls like moduleNameMapper: getMapper()\n const moduleNameMapperFunctionRegex =\n /moduleNameMapper:\\s*([a-zA-Z_$][\\w$]*(?:\\([^)]*\\))?)/;\n const functionMatch = moduleNameMapperFunctionRegex.exec(contents);\n\n if (functionMatch?.[1] !== undefined) {\n const functionBody = functionMatch[1];\n const optionalComma = !/[,\\s]*$/.test(functionBody) ? '' : ',';\n const newContents = `${contents.slice(\n 0,\n functionMatch.index,\n )}moduleNameMapper: {...${functionBody}${optionalComma}${newModuleNameMapper}}${contents.slice(\n functionMatch.index + functionMatch[0].length,\n )}}`;\n\n return newContents;\n }\n\n // Add moduleNameMapper if not present\n\n const insertionPointRegex = /(\\b(jest|export\\s+default)\\b[\\s\\S]*?{)/;\n const insertionMatch = insertionPointRegex.exec(contents);\n\n if (insertionMatch?.[1] !== undefined) {\n const insertionIndex = insertionMatch.index + insertionMatch[0].length;\n const moduleNameMapperString = `\\n moduleNameMapper: {${newModuleNameMapper}},`;\n\n const newContents =\n contents.slice(0, insertionIndex) +\n moduleNameMapperString +\n contents.slice(insertionIndex);\n\n return newContents;\n }\n\n log.warn(\n 'Could not find a suitable place to insert moduleNameMapper in jest config',\n );\n return contents;\n};\n\nexport const parsePackageJson = (\n contents: string,\n): {\n original: PackageJson;\n parsed: PackageJson;\n} | null => {\n try {\n const parsedJson: unknown = JSON.parse(contents);\n return {\n original: parsedJson as PackageJson,\n parsed: packageJsonSchema.parse(parsedJson),\n };\n } catch (error) {\n log.warn(`Failed to parse package.json as JSON: ${String(error)}`);\n return null;\n }\n};\n\nexport const updatePackageJson = ({\n parsed,\n customCondition,\n}: {\n parsed: PackageJson;\n customCondition: string;\n}) => {\n parsed.imports ??= {};\n parsed.imports['#src/*'] ??= {\n [customCondition]: './src/*',\n default: './lib/*',\n };\n\n return {\n parsed,\n };\n};\n\nconst parseTsconfig = (\n file: string,\n contents: string,\n): {\n original: TsConfig;\n parsed: TsConfig;\n srcPaths: string[];\n} | null => {\n try {\n const parsedJson = ts.parseConfigFileTextToJson(file, contents);\n const tsconfig = tsConfigSchema.parse(parsedJson.config);\n\n return {\n original: parsedJson.config as TsConfig,\n parsed: tsconfig,\n srcPaths: tsconfig.compilerOptions?.paths?.['./src/*'] ?? [],\n };\n } catch (error) {\n log.warn(`Failed to parse root tsconfig.json as JSON: ${String(error)}`);\n return null;\n }\n};\n\nconst updateTsConfig = ({\n parsed,\n customCondition,\n file,\n}: {\n parsed: TsConfig;\n customCondition: string;\n file: string;\n}) => {\n if (file === 'tsconfig.json') {\n parsed.compilerOptions ??= {};\n parsed.compilerOptions.customConditions ??= [];\n\n if (\n parsed.compilerOptions.customConditions.includes(customCondition) &&\n customCondition !== '@seek/skuba/source'\n ) {\n throw new Error(\n `Custom condition ${customCondition} already exists in tsconfig.json`,\n );\n }\n\n if (!parsed.compilerOptions.customConditions.includes(customCondition)) {\n parsed.compilerOptions.customConditions.push(customCondition);\n }\n }\n\n let srcPaths: string[] = [];\n ['./src/*', 'src/*', 'src'].forEach((key) => {\n if (parsed.compilerOptions?.paths?.[key]) {\n srcPaths = parsed.compilerOptions.paths[key];\n delete parsed.compilerOptions.paths[key];\n }\n });\n\n if (\n parsed.compilerOptions?.paths &&\n Object.keys(parsed.compilerOptions.paths).length === 0\n ) {\n delete parsed.compilerOptions.paths;\n }\n\n return {\n parsed,\n srcPaths,\n };\n};\n\nexport const tryConfigureTsConfigForESM: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n let customCondition: string;\n try {\n const { repo } = await Git.getOwnerAndRepo({ dir: process.cwd() });\n customCondition = `@seek/${repo}/source`;\n } catch {\n return { result: 'skip', reason: 'no repository name found' };\n }\n\n const tsconfigJsonPatterns = ['**/tsconfig.json'];\n const tsconfigBuildJsonPatterns = ['**/tsconfig.build.json'];\n const jestConfigPatterns = ['**/jest.config.ts', '**/jest.config.*.ts'];\n\n const [tsconfigJsonFiles, tsconfigBuildJsonFiles, jestConfigFiles] =\n await Promise.all([\n fetchFiles(tsconfigJsonPatterns),\n fetchFiles(tsconfigBuildJsonPatterns),\n fetchFiles(jestConfigPatterns),\n ]);\n\n const parsedTsconfigFiles = tsconfigJsonFiles.flatMap(\n ({ file, contents }) => {\n const parsed = parseTsconfig(file, contents);\n return parsed ? [{ file, ...parsed }] : [];\n },\n );\n\n const parsedTsconfigBuildFiles = tsconfigBuildJsonFiles.flatMap(\n ({ file, contents }) => {\n const parsed = parseTsconfig(file, contents);\n return parsed ? [{ file, ...parsed }] : [];\n },\n );\n\n if (parsedTsconfigFiles.length === 0) {\n return { result: 'skip', reason: 'no valid tsconfig.json files found' };\n }\n\n const updatedTsconfigFiles = parsedTsconfigFiles.map(\n ({ file, parsed, original }) => ({\n file,\n original,\n ...updateTsConfig({ parsed, customCondition, file }),\n }),\n );\n\n const allSrcPaths = [\n ...new Set(\n updatedTsconfigFiles.flatMap(({ srcPaths, file }) =>\n srcPaths.flatMap((p) => {\n const regex = /(.*)src\\/?\\*?$/;\n const match = regex.exec(p);\n if (match?.[1] !== undefined) {\n return [\n path.join(path.dirname(file), match[1].replace(/\\/?$/, '')),\n ];\n }\n\n log.warn(\n `Unexpected src path format in ${file}: ${p}. Expected format like \"apps/api/src/*\"`,\n );\n return [];\n }),\n ),\n ),\n ];\n\n // Fetch all package.json paths which may be in allSrcPaths\n const packageJsonPatterns = allSrcPaths.map((srcPath) =>\n path.join(srcPath, 'package.json'),\n );\n\n const packageJsonFiles = await fetchFiles(packageJsonPatterns);\n\n const parsedPackageJsonFiles = packageJsonFiles.flatMap(\n ({ file, contents }) => {\n const parsed = parsePackageJson(contents);\n return parsed ? [{ file, ...parsed }] : [];\n },\n );\n\n parsedPackageJsonFiles.forEach(({ parsed, file }) => {\n updatePackageJson({ parsed, customCondition });\n\n const relativeTsconfigPath = path.join(path.dirname(file), 'tsconfig.json');\n\n const relativeTsconfig = updatedTsconfigFiles.find(\n (tsconfig) => tsconfig.file === relativeTsconfigPath,\n );\n\n if (relativeTsconfig) {\n relativeTsconfig.parsed.compilerOptions ??= {};\n relativeTsconfig.parsed.compilerOptions.rootDir ??= '.';\n } else {\n log.warn(\n `No corresponding tsconfig.json found for package.json at ${file}. Expected at ${relativeTsconfigPath}`,\n );\n }\n\n const relativeTsconfigBuildPath = path.join(\n path.dirname(file),\n 'tsconfig.build.json',\n );\n\n const relativeTsconfigBuild = parsedTsconfigBuildFiles.find(\n (tsconfig) => tsconfig.file === relativeTsconfigBuildPath,\n );\n\n if (relativeTsconfigBuild) {\n relativeTsconfigBuild.parsed.compilerOptions ??= {};\n relativeTsconfigBuild.parsed.compilerOptions.rootDir ??= 'src';\n } else {\n log.warn(\n `No corresponding tsconfig.build.json found for package.json at ${file}. Expected at ${relativeTsconfigBuildPath}`,\n );\n }\n });\n\n const updatedJestConfigFiles = jestConfigFiles.map(({ file, contents }) => {\n const parsed = addJestModuleNameMapper(contents, allSrcPaths);\n return { file, original: contents, parsed };\n });\n\n const hasJestConfigsChanged = updatedJestConfigFiles.some(\n ({ parsed, original }) => original !== parsed,\n );\n\n const hasRelativeTsconfigBuildsChanged = parsedTsconfigBuildFiles.some(\n ({ original, parsed }) =>\n JSON.stringify(original) !== JSON.stringify(parsed),\n );\n\n const hasPackageJsonsChanged = parsedPackageJsonFiles.some(\n ({ original, parsed }) =>\n JSON.stringify(original) !== JSON.stringify(parsed),\n );\n\n const hasRootTsconfigChanged = updatedTsconfigFiles.some(\n ({ original, parsed }) =>\n JSON.stringify(original) !== JSON.stringify(parsed),\n );\n\n if (\n mode === 'lint' &&\n (hasRootTsconfigChanged ||\n hasPackageJsonsChanged ||\n hasRelativeTsconfigBuildsChanged ||\n hasJestConfigsChanged)\n ) {\n return { result: 'apply' };\n }\n\n if (\n !hasRootTsconfigChanged &&\n !hasPackageJsonsChanged &&\n !hasRelativeTsconfigBuildsChanged &&\n !hasJestConfigsChanged\n ) {\n return { result: 'skip', reason: 'no changes required' };\n }\n\n const jsonFilePromises = Promise.all(\n [\n ...updatedTsconfigFiles,\n ...parsedTsconfigBuildFiles,\n ...parsedPackageJsonFiles,\n ].map(async ({ file, parsed, original }) => {\n if (JSON.stringify(original) === JSON.stringify(parsed)) {\n return;\n }\n const updatedContents = JSON.stringify(parsed, null, 2);\n await fs.promises.writeFile(file, updatedContents);\n }),\n );\n\n const otherFilePromises = Promise.all(\n updatedJestConfigFiles.map(async ({ file, parsed, original }) => {\n if (original === parsed) {\n return;\n }\n await fs.promises.writeFile(file, parsed);\n }),\n );\n\n await Promise.all([jsonFilePromises, otherFilePromises]);\n\n return { result: 'apply' };\n};\n\nexport const configureTsConfigForESM: PatchFunction = async (config) => {\n try {\n return await tryConfigureTsConfigForESM(config);\n } catch (err) {\n log.warn('Failed to write configure `tsconfig.json` and `package.json`');\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;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AACf,wBAAe;AACf,QAAmB;AAEnB,eAAoB;AACpB,qBAAoB;AAGpB,MAAM,oBAAoB,EAAE,YAAY;AAAA,EACtC,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS;AAC3E,CAAC;AAID,MAAM,iBAAiB,EAAE,YAAY;AAAA,EACnC,iBAAiB,EACd,YAAY;AAAA,IACX,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,IAC/C,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,OAAO,EACJ,OAAO,EAAE,OAAO,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAC3D,SAAS;AAAA,EACd,CAAC,EACA,SAAS;AACd,CAAC;AAID,MAAM,aAAa,OAAO,aAAuB;AAC/C,QAAM,QAAQ,UAAM,uBAAK,UAAU;AAA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A,YAAM,kBAAkB,KAAK,UAAU,QAAQ,MAAM,CAAC;AACtD,YAAM,gBAAAF,QAAG,SAAS,UAAU,MAAM,eAAe;AAAA,IACnD,CAAC;AAAA,EACH;AAEA,QAAM,oBAAoB,QAAQ;AAAA,IAChC,uBAAuB,IAAI,OAAO,EAAE,MAAM,QAAQ,SAAS,MAAM;AAC/D,UAAI,aAAa,QAAQ;AACvB;AAAA,MACF;AACA,YAAM,gBAAAA,QAAG,SAAS,UAAU,MAAM,MAAM;AAAA,IAC1C,CAAC;AAAA,EACH;AAEA,QAAM,QAAQ,IAAI,CAAC,kBAAkB,iBAAiB,CAAC;AAEvD,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,0BAAyC,OAAO,WAAW;AACtE,MAAI;AACF,WAAO,MAAM,2BAA2B,MAAM;AAAA,EAChD,SAAS,KAAK;AACZ,uBAAI,KAAK,8DAA8D;AACvE,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs", "ts", "path"]
7
+ }
@@ -21,11 +21,26 @@ __export(__exports, {
21
21
  patches: () => patches
22
22
  });
23
23
  module.exports = __toCommonJS(__exports);
24
+ var import_configureTsConfigForESM = require("./configureTsConfigForESM.js");
25
+ var import_patchApiDockerfiles = require("./patchApiDockerfiles.js");
24
26
  var import_rewriteSrcImports = require("./rewriteSrcImports.js");
27
+ var import_updateLambdaConfigs = require("./updateLambdaConfigs.js");
25
28
  const patches = [
26
29
  {
27
30
  apply: import_rewriteSrcImports.rewriteSrcImports,
28
31
  description: "Rewrite all 'src' imports to be '#src'"
32
+ },
33
+ {
34
+ apply: import_configureTsConfigForESM.configureTsConfigForESM,
35
+ description: "Configure `tsconfig.json`, `package.json` and `jest.config.ts` to support custom conditions"
36
+ },
37
+ {
38
+ apply: import_updateLambdaConfigs.updateLambdaConfigs,
39
+ description: "Update lambda function configurations to support custom conditions"
40
+ },
41
+ {
42
+ apply: import_patchApiDockerfiles.patchApiDockerfiles,
43
+ description: "Patch Dockerfiles to copy `package.json`"
29
44
  }
30
45
  ];
31
46
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/index.ts"],
4
+ "sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { configureTsConfigForESM } from './configureTsConfigForESM.js';\nimport { patchApiDockerfiles } from './patchApiDockerfiles.js';\nimport { rewriteSrcImports } from './rewriteSrcImports.js';\nimport { updateLambdaConfigs } from './updateLambdaConfigs.js';\n\nexport const patches: Patches = [\n {\n apply: rewriteSrcImports,\n description: \"Rewrite all 'src' imports to be '#src'\",\n },\n {\n apply: configureTsConfigForESM,\n description:\n 'Configure `tsconfig.json`, `package.json` and `jest.config.ts` to support custom conditions',\n },\n {\n apply: updateLambdaConfigs,\n description:\n 'Update lambda function configurations to support custom conditions',\n },\n {\n apply: patchApiDockerfiles,\n description: 'Patch Dockerfiles to copy `package.json`',\n },\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qCAAwC;AACxC,iCAAoC;AACpC,+BAAkC;AAClC,iCAAoC;AAE7B,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { PatchFunction } from '../../index.js';
2
+ export declare const patchApiDockerfiles: PatchFunction;
@@ -0,0 +1,152 @@
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 patchApiDockerfiles_exports = {};
30
+ __export(patchApiDockerfiles_exports, {
31
+ patchApiDockerfiles: () => patchApiDockerfiles
32
+ });
33
+ module.exports = __toCommonJS(patchApiDockerfiles_exports);
34
+ var import_util = require("util");
35
+ var import_fast_glob = require("fast-glob");
36
+ var import_fs_extra = __toESM(require("fs-extra"));
37
+ var import_logging = require("../../../../../../utils/logging.js");
38
+ const fetchFiles = async (files) => Promise.all(
39
+ files.map(async (file) => {
40
+ const contents = await import_fs_extra.default.promises.readFile(file, "utf8");
41
+ return {
42
+ file,
43
+ contents
44
+ };
45
+ })
46
+ );
47
+ const applyDockerfilePatch = (contents) => {
48
+ const cmdLineRegex = /CMD\s+\[.*?\]/ms;
49
+ const cmdLineMatch = cmdLineRegex.exec(contents);
50
+ const cmdLine = cmdLineMatch?.[0];
51
+ if (!cmdLine) {
52
+ return void 0;
53
+ }
54
+ const libPathRegex = /"([^"]*\/)?lib\/[^"]*"/;
55
+ const libPathMatch = libPathRegex.exec(cmdLine);
56
+ if (!libPathMatch) {
57
+ return void 0;
58
+ }
59
+ const fullPath = libPathMatch[1] || "./";
60
+ const libParentPath = fullPath.endsWith("/") ? fullPath.slice(0, -1) : fullPath;
61
+ const normalizedPath = libParentPath === "." || libParentPath === "" ? "." : libParentPath;
62
+ const copyNodeModulesWithFromRegex = /^\s*COPY\s+--from=(\S+)\s+.*node_modules.*$/m;
63
+ const copyNodeModulesWithFromMatch = copyNodeModulesWithFromRegex.exec(contents);
64
+ const copyNodeModulesWithoutFromRegex = /^\s*COPY\s+(?!--from).*node_modules.*$/m;
65
+ const copyNodeModulesWithoutFromMatch = copyNodeModulesWithoutFromRegex.exec(contents);
66
+ const copyNodeModulesMatch = copyNodeModulesWithFromMatch ?? copyNodeModulesWithoutFromMatch;
67
+ const copyNodeModulesLine = copyNodeModulesMatch?.[0];
68
+ const fromSource = copyNodeModulesWithFromMatch?.[1];
69
+ if (!copyNodeModulesLine) {
70
+ return void 0;
71
+ }
72
+ const packageJsonPattern = normalizedPath === "." ? "" : `${normalizedPath}/`;
73
+ const packageJsonCopyPattern = fromSource ? new RegExp(
74
+ `^\\s*COPY\\s+--from=${fromSource}\\s+.*${packageJsonPattern}package\\.json`,
75
+ "m"
76
+ ) : new RegExp(
77
+ `^\\s*COPY\\s+(?!--from).*${packageJsonPattern}package\\.json`,
78
+ "m"
79
+ );
80
+ if (packageJsonCopyPattern.test(contents)) {
81
+ return void 0;
82
+ }
83
+ let packageJsonCopyLine;
84
+ if (fromSource) {
85
+ packageJsonCopyLine = normalizedPath === "." ? `COPY --from=${fromSource} /workdir/package.json package.json` : `COPY --from=${fromSource} /workdir/${normalizedPath}/package.json ${normalizedPath}/package.json`;
86
+ } else {
87
+ packageJsonCopyLine = normalizedPath === "." ? "COPY package.json package.json" : `COPY ${normalizedPath}/package.json ${normalizedPath}/package.json`;
88
+ }
89
+ const newContents = contents.replace(
90
+ copyNodeModulesLine,
91
+ `${copyNodeModulesLine}
92
+ ${packageJsonCopyLine}`
93
+ );
94
+ return newContents;
95
+ };
96
+ const tryPatchApiDockerfiles = async (config) => {
97
+ const dockerfilePaths = await (0, import_fast_glob.glob)(["**/Dockerfile*"], {
98
+ ignore: ["**/.git", "**/node_modules"]
99
+ });
100
+ if (dockerfilePaths.length === 0) {
101
+ return {
102
+ result: "skip",
103
+ reason: "no Dockerfiles found"
104
+ };
105
+ }
106
+ const dockerfiles = await fetchFiles(dockerfilePaths);
107
+ const dockerFilesToPatch = dockerfiles.flatMap(({ file, contents }) => {
108
+ const newContents = applyDockerfilePatch(contents);
109
+ if (!newContents || newContents === contents) {
110
+ return [];
111
+ }
112
+ return [
113
+ {
114
+ file,
115
+ contents: newContents
116
+ }
117
+ ];
118
+ });
119
+ if (dockerFilesToPatch.length === 0) {
120
+ return {
121
+ result: "skip",
122
+ reason: "no Dockerfiles to patch"
123
+ };
124
+ }
125
+ if (config.mode === "lint") {
126
+ return {
127
+ result: "apply"
128
+ };
129
+ }
130
+ await Promise.all(
131
+ dockerFilesToPatch.map(
132
+ ({ file, contents }) => import_fs_extra.default.promises.writeFile(file, contents, "utf8")
133
+ )
134
+ );
135
+ return {
136
+ result: "apply"
137
+ };
138
+ };
139
+ const patchApiDockerfiles = async (config) => {
140
+ try {
141
+ return await tryPatchApiDockerfiles(config);
142
+ } catch (err) {
143
+ import_logging.log.warn("Failed to patch API dockerfiles");
144
+ import_logging.log.subtle((0, import_util.inspect)(err));
145
+ return { result: "skip", reason: "due to an error" };
146
+ }
147
+ };
148
+ // Annotate the CommonJS export names for ESM import in node:
149
+ 0 && (module.exports = {
150
+ patchApiDockerfiles
151
+ });
152
+ //# sourceMappingURL=patchApiDockerfiles.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/12.4.1/patchApiDockerfiles.ts"],
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../../../../utils/logging.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await fs.promises.readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\nconst applyDockerfilePatch = (contents: string) => {\n const cmdLineRegex = /CMD\\s+\\[.*?\\]/ms;\n const cmdLineMatch = cmdLineRegex.exec(contents);\n const cmdLine = cmdLineMatch?.[0];\n\n if (!cmdLine) {\n return undefined;\n }\n\n // Extract the lib path from CMD line\n // Match patterns like \"./lib/\", \"apps/api/lib/\", \"lib/\"\n const libPathRegex = /\"([^\"]*\\/)?lib\\/[^\"]*\"/;\n const libPathMatch = libPathRegex.exec(cmdLine);\n\n if (!libPathMatch) {\n return undefined;\n }\n\n const fullPath = libPathMatch[1] || './';\n const libParentPath = fullPath.endsWith('/')\n ? fullPath.slice(0, -1)\n : fullPath;\n\n // If the path is empty or just './', the lib is in current directory\n const normalizedPath =\n libParentPath === '.' || libParentPath === '' ? '.' : libParentPath;\n\n // Try to find COPY with --from first\n const copyNodeModulesWithFromRegex =\n /^\\s*COPY\\s+--from=(\\S+)\\s+.*node_modules.*$/m;\n const copyNodeModulesWithFromMatch =\n copyNodeModulesWithFromRegex.exec(contents);\n\n // If no --from, try to find COPY without --from\n const copyNodeModulesWithoutFromRegex =\n /^\\s*COPY\\s+(?!--from).*node_modules.*$/m;\n const copyNodeModulesWithoutFromMatch =\n copyNodeModulesWithoutFromRegex.exec(contents);\n\n const copyNodeModulesMatch =\n copyNodeModulesWithFromMatch ?? copyNodeModulesWithoutFromMatch;\n const copyNodeModulesLine = copyNodeModulesMatch?.[0];\n const fromSource = copyNodeModulesWithFromMatch?.[1];\n\n if (!copyNodeModulesLine) {\n return undefined;\n }\n\n // Check if package.json is already being copied for this path\n const packageJsonPattern = normalizedPath === '.' ? '' : `${normalizedPath}/`;\n const packageJsonCopyPattern = fromSource\n ? new RegExp(\n `^\\\\s*COPY\\\\s+--from=${fromSource}\\\\s+.*${packageJsonPattern}package\\\\.json`,\n 'm',\n )\n : new RegExp(\n `^\\\\s*COPY\\\\s+(?!--from).*${packageJsonPattern}package\\\\.json`,\n 'm',\n );\n\n if (packageJsonCopyPattern.test(contents)) {\n return undefined;\n }\n\n let packageJsonCopyLine: string;\n if (fromSource) {\n packageJsonCopyLine =\n normalizedPath === '.'\n ? `COPY --from=${fromSource} /workdir/package.json package.json`\n : `COPY --from=${fromSource} /workdir/${normalizedPath}/package.json ${normalizedPath}/package.json`;\n } else {\n packageJsonCopyLine =\n normalizedPath === '.'\n ? 'COPY package.json package.json'\n : `COPY ${normalizedPath}/package.json ${normalizedPath}/package.json`;\n }\n\n const newContents = contents.replace(\n copyNodeModulesLine,\n `${copyNodeModulesLine}\\n${packageJsonCopyLine}`,\n );\n\n return newContents;\n};\n\nconst tryPatchApiDockerfiles = async (config: {\n mode: 'lint' | 'format';\n}): Promise<PatchReturnType> => {\n const dockerfilePaths = await glob(['**/Dockerfile*'], {\n ignore: ['**/.git', '**/node_modules'],\n });\n\n if (dockerfilePaths.length === 0) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles found',\n };\n }\n\n const dockerfiles = await fetchFiles(dockerfilePaths);\n\n const dockerFilesToPatch = dockerfiles.flatMap(({ file, contents }) => {\n const newContents = applyDockerfilePatch(contents);\n if (!newContents || newContents === contents) {\n return [];\n }\n\n return [\n {\n file,\n contents: newContents,\n },\n ];\n });\n\n if (dockerFilesToPatch.length === 0) {\n return {\n result: 'skip',\n reason: 'no Dockerfiles to patch',\n };\n }\n\n if (config.mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n dockerFilesToPatch.map(({ file, contents }) =>\n fs.promises.writeFile(file, contents, 'utf8'),\n ),\n );\n\n return {\n result: 'apply',\n };\n};\n\nexport const patchApiDockerfiles: PatchFunction = async (config) => {\n try {\n return await tryPatchApiDockerfiles(config);\n } catch (err) {\n log.warn('Failed to patch API dockerfiles');\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,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AAGpB,MAAM,aAAa,OAAO,UACxB,QAAQ;AAAA,EACN,MAAM,IAAI,OAAO,SAAS;AACxB,UAAM,WAAW,MAAM,gBAAAA,QAAG,SAAS,SAAS,MAAM,MAAM;AAExD,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEF,MAAM,uBAAuB,CAAC,aAAqB;AACjD,QAAM,eAAe;AACrB,QAAM,eAAe,aAAa,KAAK,QAAQ;AAC/C,QAAM,UAAU,eAAe,CAAC;AAEhC,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAIA,QAAM,eAAe;AACrB,QAAM,eAAe,aAAa,KAAK,OAAO;AAE9C,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,aAAa,CAAC,KAAK;AACpC,QAAM,gBAAgB,SAAS,SAAS,GAAG,IACvC,SAAS,MAAM,GAAG,EAAE,IACpB;AAGJ,QAAM,iBACJ,kBAAkB,OAAO,kBAAkB,KAAK,MAAM;AAGxD,QAAM,+BACJ;AACF,QAAM,+BACJ,6BAA6B,KAAK,QAAQ;AAG5C,QAAM,kCACJ;AACF,QAAM,kCACJ,gCAAgC,KAAK,QAAQ;AAE/C,QAAM,uBACJ,gCAAgC;AAClC,QAAM,sBAAsB,uBAAuB,CAAC;AACpD,QAAM,aAAa,+BAA+B,CAAC;AAEnD,MAAI,CA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A,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,MAAI,OAAO,SAAS,QAAQ;AAC1B,WAAO;AAAA,MACL,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,mBAAmB;AAAA,MAAI,CAAC,EAAE,MAAM,SAAS,MACvC,gBAAAA,QAAG,SAAS,UAAU,MAAM,UAAU,MAAM;AAAA,IAC9C;AAAA,EACF;AAEA,SAAO;AAAA,IACL,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,sBAAqC,OAAO,WAAW;AAClE,MAAI;AACF,WAAO,MAAM,uBAAuB,MAAM;AAAA,EAC5C,SAAS,KAAK;AACZ,uBAAI,KAAK,iCAAiC;AAC1C,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs"]
7
+ }
@@ -59,9 +59,9 @@ const fetchFiles = async (files) => Promise.all(
59
59
  const hasSkubaDiveRegisterImportRegex = /import\s+['"](?:skuba-dive\/register)(?:\.js)?['"];?\s*/gm;
60
60
  const hasRelativeRegisterImportRegex = /import\s+['"](\.\.?\/.*?register)(?:\.js)?['"];?\s*/gm;
61
61
  const hasRelativeImportRegex = /import\s+['"](\.\.?\/[^'"]*?)(?:\.js)?['"];?\s*/gm;
62
- const hasSrcImportRegex = /import\s+(?:type\s+\{[^}]*\}|\{[^}]*\}|\*\s+as\s+\w+|\w+(?:\s*,\s*\{[^}]*\})?)\s+from\s+['"]src\/[^'"]*['"]/gm;
62
+ const hasSrcImportRegex = /import\s+(?:type\s+(?:\{[^}]*\}|\*\s+as\s+\w+)|\{[^}]*\}|\*\s+as\s+\w+|\w+(?:\s*,\s*\{[^}]*\})?)\s+from\s+['"]src\/[^'"]*['"]/gm;
63
63
  const hasImportRegex = /import\(\s*["']src\/[^'"]*["']\s*\)/gm;
64
- const hasJestMockRegex = /jest\.mock\(\s*["']src\/[^'"]*["']\s*\)/gm;
64
+ const hasJestMockRegex = /jest\.(mock|doMock)\(\s*["']src\/[^'"]*["']/gm;
65
65
  const multiLineCommentRegex = /\/\*[\s\S]*?\*\//g;
66
66
  const singleLineCommentRegex = /\/\/.*$/gm;
67
67
  const whitespaceRegex = /\s/g;
@@ -138,7 +138,11 @@ const tryRewriteSrcImports = async ({
138
138
  mode
139
139
  }) => {
140
140
  const tsFileNames = await (0, import_fast_glob.glob)(["**/*.ts", "**/*.test.ts"], {
141
- ignore: ["**/.git", "**/node_modules"]
141
+ ignore: [
142
+ "**/.git",
143
+ "**/node_modules",
144
+ "src/cli/lint/internalLints/upgrade/patches/**/*"
145
+ ]
142
146
  });
143
147
  if (!tsFileNames.length) {
144
148
  return {