skuba 8.2.1 → 9.0.0-main-20240924121500

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 (99) hide show
  1. package/config/eslint.js +1 -3
  2. package/lib/api/buildkite/annotate.d.ts +2 -0
  3. package/lib/api/buildkite/annotate.js +14 -1
  4. package/lib/api/buildkite/annotate.js.map +2 -2
  5. package/lib/api/github/issueComment.js.map +2 -2
  6. package/lib/cli/adapter/eslint.d.ts +1 -1
  7. package/lib/cli/adapter/eslint.js +34 -8
  8. package/lib/cli/adapter/eslint.js.map +2 -2
  9. package/lib/cli/build/index.js +1 -0
  10. package/lib/cli/build/index.js.map +1 -1
  11. package/lib/cli/configure/analyseDependencies.js +0 -2
  12. package/lib/cli/configure/analyseDependencies.js.map +2 -2
  13. package/lib/cli/configure/analysis/package.d.ts +1 -2
  14. package/lib/cli/configure/analysis/package.js +0 -27
  15. package/lib/cli/configure/analysis/package.js.map +2 -2
  16. package/lib/cli/configure/dependencies/skubaDeps.js +4 -3
  17. package/lib/cli/configure/dependencies/skubaDeps.js.map +2 -2
  18. package/lib/cli/configure/modules/eslint.js +4 -8
  19. package/lib/cli/configure/modules/eslint.js.map +2 -2
  20. package/lib/cli/configure/processing/configFile.js +1 -1
  21. package/lib/cli/configure/processing/configFile.js.map +2 -2
  22. package/lib/cli/format.d.ts +1 -1
  23. package/lib/cli/format.js +2 -2
  24. package/lib/cli/format.js.map +2 -2
  25. package/lib/cli/init/getConfig.js.map +1 -1
  26. package/lib/cli/init/index.js +1 -1
  27. package/lib/cli/init/index.js.map +1 -1
  28. package/lib/cli/init/types.js.map +2 -2
  29. package/lib/cli/lint/autofix.d.ts +1 -0
  30. package/lib/cli/lint/autofix.js +2 -2
  31. package/lib/cli/lint/autofix.js.map +2 -2
  32. package/lib/cli/lint/eslint.d.ts +1 -1
  33. package/lib/cli/lint/eslint.js +1 -1
  34. package/lib/cli/lint/eslint.js.map +2 -2
  35. package/lib/cli/lint/internalLints/patchRenovateConfig.js +0 -4
  36. package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +2 -2
  37. package/lib/cli/lint/internalLints/refreshConfigFiles.js +0 -1
  38. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
  39. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.d.ts +2 -0
  40. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js +90 -0
  41. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/collapseDuplicateMergeKeys.js.map +7 -0
  42. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.d.ts +2 -0
  43. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +45 -0
  44. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +7 -0
  45. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.d.ts +2 -0
  46. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js +99 -0
  47. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.js.map +7 -0
  48. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.d.ts +2 -0
  49. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +144 -0
  50. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +7 -0
  51. package/lib/cli/lint/types.d.ts +4 -0
  52. package/lib/cli/lint/types.js.map +1 -1
  53. package/lib/cli/node.d.ts +2 -1
  54. package/lib/cli/node.js +23 -18
  55. package/lib/cli/node.js.map +3 -3
  56. package/lib/cli/start.js +3 -3
  57. package/lib/cli/start.js.map +2 -2
  58. package/lib/eslint.d.js +2 -0
  59. package/lib/index.js.map +1 -1
  60. package/lib/skuba.js.map +1 -1
  61. package/lib/utils/copy.js +1 -1
  62. package/lib/utils/copy.js.map +2 -2
  63. package/lib/utils/template.d.ts +4 -4
  64. package/lib/wrapper/main.js.map +1 -1
  65. package/lib/wrapper/requestListener.js.map +2 -2
  66. package/package.json +18 -16
  67. package/template/base/_eslint.config.js +1 -0
  68. package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
  69. package/template/express-rest-api/Dockerfile.dev-deps +1 -1
  70. package/template/express-rest-api/package.json +2 -2
  71. package/template/greeter/.buildkite/pipeline.yml +1 -1
  72. package/template/greeter/Dockerfile +1 -1
  73. package/template/greeter/package.json +2 -2
  74. package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
  75. package/template/koa-rest-api/Dockerfile.dev-deps +1 -1
  76. package/template/koa-rest-api/package.json +6 -6
  77. package/template/koa-rest-api/src/framework/server.test.ts +2 -1
  78. package/template/koa-rest-api/src/framework/server.ts +3 -5
  79. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +3 -3
  80. package/template/lambda-sqs-worker/Dockerfile +1 -1
  81. package/template/lambda-sqs-worker/package.json +2 -2
  82. package/template/lambda-sqs-worker/src/types/jobScorer.ts +1 -1
  83. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
  84. package/template/lambda-sqs-worker-cdk/Dockerfile +1 -1
  85. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +447 -891
  86. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +4 -1
  87. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +5 -84
  88. package/template/lambda-sqs-worker-cdk/infra/config.ts +1 -1
  89. package/template/lambda-sqs-worker-cdk/infra/index.ts +20 -3
  90. package/template/lambda-sqs-worker-cdk/package.json +4 -3
  91. package/template/oss-npm-package/.github/workflows/release.yml +1 -1
  92. package/template/oss-npm-package/_package.json +1 -1
  93. package/template/private-npm-package/_package.json +1 -1
  94. package/lib/why-is-node-running.d.js +0 -2
  95. package/template/base/_.eslintignore +0 -15
  96. package/template/base/_.eslintrc.js +0 -3
  97. package/template/lambda-sqs-worker-cdk/src/postHook.ts +0 -154
  98. package/template/lambda-sqs-worker-cdk/src/preHook.ts +0 -95
  99. /package/lib/{why-is-node-running.d.js.map → eslint.d.js.map} +0 -0
@@ -0,0 +1,99 @@
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 patchDockerCompose_exports = {};
30
+ __export(patchDockerCompose_exports, {
31
+ tryPatchDockerComposeFiles: () => tryPatchDockerComposeFiles
32
+ });
33
+ module.exports = __toCommonJS(patchDockerCompose_exports);
34
+ var import_util = require("util");
35
+ var import_fast_glob = __toESM(require("fast-glob"));
36
+ var import_fs_extra = require("fs-extra");
37
+ var import_logging = require("../../../../../../utils/logging");
38
+ const DOCKER_COMPOSE_VERSION_REGEX = /^version: ['"]?\d+(\.\d+)*['"]?\n*/m;
39
+ const fetchFiles = async (files) => Promise.all(
40
+ files.map(async (file) => {
41
+ const contents = await (0, import_fs_extra.readFile)(file, "utf8");
42
+ return {
43
+ file,
44
+ contents
45
+ };
46
+ })
47
+ );
48
+ const patchDockerComposeFiles = async ({
49
+ mode
50
+ }) => {
51
+ const maybeDockerComposeFiles = await Promise.resolve(
52
+ (0, import_fast_glob.default)(["docker-compose*.yml"])
53
+ );
54
+ if (!maybeDockerComposeFiles.length) {
55
+ return {
56
+ result: "skip",
57
+ reason: "no docker-compose files found"
58
+ };
59
+ }
60
+ const dockerComposeFiles = await fetchFiles(maybeDockerComposeFiles);
61
+ const dockerComposeFilesToPatch = dockerComposeFiles.filter(
62
+ ({ contents }) => DOCKER_COMPOSE_VERSION_REGEX.exec(contents)
63
+ );
64
+ if (!dockerComposeFilesToPatch.length) {
65
+ return {
66
+ result: "skip",
67
+ reason: "no docker-compose files to patch"
68
+ };
69
+ }
70
+ if (mode === "lint") {
71
+ return {
72
+ result: "apply"
73
+ };
74
+ }
75
+ await Promise.all(
76
+ dockerComposeFilesToPatch.map(async ({ file, contents }) => {
77
+ const patchedContents = contents.replace(
78
+ DOCKER_COMPOSE_VERSION_REGEX,
79
+ ""
80
+ );
81
+ await (0, import_fs_extra.writeFile)(file, patchedContents);
82
+ })
83
+ );
84
+ return { result: "apply" };
85
+ };
86
+ const tryPatchDockerComposeFiles = async (config) => {
87
+ try {
88
+ return await patchDockerComposeFiles(config);
89
+ } catch (err) {
90
+ import_logging.log.warn("Failed to patch pnpm packageManager CI configuration.");
91
+ import_logging.log.subtle((0, import_util.inspect)(err));
92
+ return { result: "skip", reason: "due to an error" };
93
+ }
94
+ };
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ tryPatchDockerComposeFiles
98
+ });
99
+ //# sourceMappingURL=patchDockerCompose.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/8.2.1/patchDockerCompose.ts"],
4
+ "sourcesContent": ["import { inspect } from 'util';\n\nimport fg from 'fast-glob';\nimport { readFile, writeFile } from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\n\nconst DOCKER_COMPOSE_VERSION_REGEX = /^version: ['\"]?\\d+(\\.\\d+)*['\"]?\\n*/m;\n\nconst fetchFiles = async (files: string[]) =>\n Promise.all(\n files.map(async (file) => {\n const contents = await readFile(file, 'utf8');\n\n return {\n file,\n contents,\n };\n }),\n );\n\nconst patchDockerComposeFiles: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n const maybeDockerComposeFiles = await Promise.resolve(\n fg(['docker-compose*.yml']),\n );\n\n if (!maybeDockerComposeFiles.length) {\n return {\n result: 'skip',\n reason: 'no docker-compose files found',\n };\n }\n\n const dockerComposeFiles = await fetchFiles(maybeDockerComposeFiles);\n\n const dockerComposeFilesToPatch = dockerComposeFiles.filter(({ contents }) =>\n DOCKER_COMPOSE_VERSION_REGEX.exec(contents),\n );\n\n if (!dockerComposeFilesToPatch.length) {\n return {\n result: 'skip',\n reason: 'no docker-compose files to patch',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n await Promise.all(\n dockerComposeFilesToPatch.map(async ({ file, contents }) => {\n const patchedContents = contents.replace(\n DOCKER_COMPOSE_VERSION_REGEX,\n '',\n );\n await writeFile(file, patchedContents);\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const tryPatchDockerComposeFiles: PatchFunction = async (config) => {\n try {\n return await patchDockerComposeFiles(config);\n } catch (err) {\n log.warn('Failed to patch pnpm packageManager CI configuration.');\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,uBAAe;AACf,sB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AAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fg"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { PatchFunction } from '../..';
2
+ export declare const tryUpgradeESLint: PatchFunction;
@@ -0,0 +1,144 @@
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 upgradeESLint_exports = {};
30
+ __export(upgradeESLint_exports, {
31
+ tryUpgradeESLint: () => tryUpgradeESLint
32
+ });
33
+ module.exports = __toCommonJS(upgradeESLint_exports);
34
+ var fsp = __toESM(require("fs/promises"));
35
+ var import_path = __toESM(require("path"));
36
+ var import_util = require("util");
37
+ var import_fs_extra = require("fs-extra");
38
+ var import_exec = require("../../../../../../utils/exec");
39
+ var import_logging = require("../../../../../../utils/logging");
40
+ var import_project = require("../../../../../configure/analysis/project");
41
+ var import_configFile = require("../../../../../configure/processing/configFile");
42
+ var import_prettier = require("../../../../../configure/processing/prettier");
43
+ const IGNORE_FILE = ".eslintignore";
44
+ const OLD_CONFIG_FILE = ".eslintrc.js";
45
+ const NEW_CONFIG_FILE_CJS = "eslint.config.cjs";
46
+ const NEW_CONFIG_FILE_JS = "eslint.config.js";
47
+ const upgradeESLint = async ({
48
+ mode,
49
+ dir: cwd = process.cwd()
50
+ }) => {
51
+ const readFile = (0, import_project.createDestinationFileReader)(cwd);
52
+ const [ignoreFileContents, oldConfig] = await Promise.all([
53
+ readFile(IGNORE_FILE),
54
+ readFile(OLD_CONFIG_FILE)
55
+ ]);
56
+ if (oldConfig === void 0) {
57
+ return {
58
+ result: "skip",
59
+ reason: `no ${OLD_CONFIG_FILE} - have you already migrated?`
60
+ };
61
+ }
62
+ if (mode === "lint") {
63
+ return { result: "apply" };
64
+ }
65
+ const ignoreContentsWithoutSkubaManaged = (0, import_configFile.mergeWithConfigFile)(
66
+ "",
67
+ "ignore"
68
+ )(ignoreFileContents);
69
+ const exec = (0, import_exec.createExec)({
70
+ cwd: process.cwd(),
71
+ stdio: "ignore"
72
+ });
73
+ const dir = await writeTemporaryFiles({
74
+ [OLD_CONFIG_FILE]: oldConfig,
75
+ ...ignoreContentsWithoutSkubaManaged.trim().length > 0 ? { [IGNORE_FILE]: ignoreContentsWithoutSkubaManaged } : {}
76
+ });
77
+ try {
78
+ await exec(
79
+ "eslint-migrate-config",
80
+ import_path.default.join(dir, OLD_CONFIG_FILE),
81
+ "--commonjs"
82
+ );
83
+ const output = fiddleWithOutput(
84
+ await fsp.readFile(import_path.default.join(dir, NEW_CONFIG_FILE_CJS), "utf-8")
85
+ );
86
+ await import_fs_extra.promises.writeFile(
87
+ NEW_CONFIG_FILE_JS,
88
+ await (0, import_prettier.formatPrettier)(output, { filepath: NEW_CONFIG_FILE_JS })
89
+ );
90
+ await Promise.all([
91
+ ignoreFileContents === void 0 ? Promise.resolve() : import_fs_extra.promises.rm(IGNORE_FILE),
92
+ import_fs_extra.promises.rm(OLD_CONFIG_FILE)
93
+ ]);
94
+ return { result: "apply" };
95
+ } finally {
96
+ await fsp.rm(dir, { recursive: true });
97
+ }
98
+ };
99
+ const writeTemporaryFiles = async (contents) => {
100
+ const dir = await fsp.mkdtemp("eslint-migrate-config");
101
+ await Promise.all(
102
+ Object.entries(contents).map(
103
+ ([file, content]) => fsp.writeFile(import_path.default.join(dir, file), content)
104
+ )
105
+ );
106
+ return dir;
107
+ };
108
+ const fiddleWithOutput = (input) => {
109
+ let output = input.replace(/compat.extends\(["']skuba["']\)/, "skuba");
110
+ if (!output.includes("eslint-config-skuba")) {
111
+ output = `const skuba = require('eslint-config-skuba');
112
+
113
+ ${output}`;
114
+ }
115
+ if (!output.includes("compat.")) {
116
+ output = output.replace(/const compat = new FlatCompat\(\{[^}]+\}\);/m, "");
117
+ output = output.replace(
118
+ /const \{\s*FlatCompat,?\s*\}\s*=\s*require\(["']@eslint\/eslintrc["']\);/m,
119
+ ""
120
+ );
121
+ }
122
+ if (!output.includes("js.")) {
123
+ output = output.replace(/const js = require\(['"]@eslint\/js['"]\);/, "");
124
+ }
125
+ output = output.replace(
126
+ /^const skuba = require\('eslint-config-skuba'\);\s*module.exports = \[...skuba\];$/m,
127
+ "module.exports = require('eslint-config-skuba');"
128
+ );
129
+ return output;
130
+ };
131
+ const tryUpgradeESLint = async (config) => {
132
+ try {
133
+ return await upgradeESLint(config);
134
+ } catch (err) {
135
+ import_logging.log.warn("Failed to upgrade ESLint to flat config.");
136
+ import_logging.log.subtle((0, import_util.inspect)(err));
137
+ return { result: "skip", reason: "due to an error" };
138
+ }
139
+ };
140
+ // Annotate the CommonJS export names for ESM import in node:
141
+ 0 && (module.exports = {
142
+ tryUpgradeESLint
143
+ });
144
+ //# sourceMappingURL=upgradeESLint.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.ts"],
4
+ "sourcesContent": ["// eslint-disable-next-line no-restricted-imports -- fs-extra is mocked\nimport * as fsp from 'fs/promises';\nimport path from 'path';\nimport { inspect } from 'util';\n\nimport { promises as fsExtra } from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { createExec } from '../../../../../../utils/exec';\nimport { log } from '../../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project';\nimport { mergeWithConfigFile } from '../../../../../configure/processing/configFile';\nimport { formatPrettier } from '../../../../../configure/processing/prettier';\n\nconst IGNORE_FILE = '.eslintignore';\nconst OLD_CONFIG_FILE = '.eslintrc.js';\nconst NEW_CONFIG_FILE_CJS = 'eslint.config.cjs';\nconst NEW_CONFIG_FILE_JS = 'eslint.config.js';\n\nconst upgradeESLint: PatchFunction = async ({\n mode,\n dir: cwd = process.cwd(),\n}): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(cwd);\n const [ignoreFileContents, oldConfig] = await Promise.all([\n readFile(IGNORE_FILE),\n readFile(OLD_CONFIG_FILE),\n ]);\n\n if (oldConfig === undefined) {\n return {\n result: 'skip',\n reason: `no ${OLD_CONFIG_FILE} - have you already migrated?`,\n };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const ignoreContentsWithoutSkubaManaged = mergeWithConfigFile(\n '',\n 'ignore',\n )(ignoreFileContents);\n\n const exec = createExec({\n cwd: process.cwd(),\n stdio: 'ignore',\n });\n\n // eslint-migrate-config require()s the file, so for testability, put it in a temporary location\n const dir = await writeTemporaryFiles({\n [OLD_CONFIG_FILE]: oldConfig,\n ...(ignoreContentsWithoutSkubaManaged.trim().length > 0\n ? { [IGNORE_FILE]: ignoreContentsWithoutSkubaManaged }\n : {}),\n });\n try {\n await exec(\n 'eslint-migrate-config',\n path.join(dir, OLD_CONFIG_FILE),\n '--commonjs',\n );\n\n const output = fiddleWithOutput(\n await fsp.readFile(path.join(dir, NEW_CONFIG_FILE_CJS), 'utf-8'),\n );\n await fsExtra.writeFile(\n NEW_CONFIG_FILE_JS,\n await formatPrettier(output, { filepath: NEW_CONFIG_FILE_JS }),\n );\n\n await Promise.all([\n ignoreFileContents === undefined\n ? Promise.resolve()\n : fsExtra.rm(IGNORE_FILE),\n fsExtra.rm(OLD_CONFIG_FILE),\n ]);\n\n return { result: 'apply' };\n } finally {\n await fsp.rm(dir, { recursive: true });\n }\n};\n\nconst writeTemporaryFiles = async (contents: Record<string, string>) => {\n const dir = await fsp.mkdtemp('eslint-migrate-config');\n\n await Promise.all(\n Object.entries(contents).map(([file, content]) =>\n fsp.writeFile(path.join(dir, file), content),\n ),\n );\n\n return dir;\n};\n\nconst fiddleWithOutput = (input: string) => {\n let output = input.replace(/compat.extends\\([\"']skuba[\"']\\)/, 'skuba');\n\n if (!output.includes('eslint-config-skuba')) {\n output = `const skuba = require('eslint-config-skuba');\\n\\n${output}`;\n }\n\n if (!output.includes('compat.')) {\n output = output.replace(/const compat = new FlatCompat\\(\\{[^}]+\\}\\);/m, '');\n output = output.replace(\n /const \\{\\s*FlatCompat,?\\s*\\}\\s*=\\s*require\\([\"']@eslint\\/eslintrc[\"']\\);/m,\n '',\n );\n }\n\n if (!output.includes('js.')) {\n output = output.replace(/const js = require\\(['\"]@eslint\\/js['\"]\\);/, '');\n }\n\n output = output.replace(\n /^const skuba = require\\('eslint-config-skuba'\\);\\s*module.exports = \\[...skuba\\];$/m,\n \"module.exports = require('eslint-config-skuba');\",\n );\n\n return output;\n};\n\nexport const tryUpgradeESLint: PatchFunction = async (config) => {\n try {\n return await upgradeESLint(config);\n } catch (err) {\n log.warn('Failed to upgrade ESLint to flat config.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,U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I,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["path", "fsExtra"]
7
+ }
@@ -30,4 +30,8 @@ export interface Input {
30
30
  * Defaults to `true`.
31
31
  */
32
32
  workerThreads?: boolean;
33
+ /**
34
+ * An override to point to a specific ESLint config file.
35
+ */
36
+ eslintConfigFile?: string;
33
37
  }
@@ -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"],
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"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
package/lib/cli/node.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ import execa from 'execa';
1
2
  export declare const longRunning = true;
2
- export declare const node: () => Promise<void | import("execa").ExecaReturnValue<string>>;
3
+ export declare const node: () => Promise<execa.ExecaReturnValue<string>>;
package/lib/cli/node.js CHANGED
@@ -33,8 +33,8 @@ __export(node_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(node_exports);
35
35
  var import_path = __toESM(require("path"));
36
+ var import_execa = __toESM(require("execa"));
36
37
  var import_get_port = __toESM(require("get-port"));
37
- var tsNode = __toESM(require("ts-node"));
38
38
  var import_args = require("../utils/args");
39
39
  var import_exec = require("../utils/exec");
40
40
  var import_validation = require("../utils/validation");
@@ -42,6 +42,13 @@ const longRunning = true;
42
42
  const node = async () => {
43
43
  const args = (0, import_args.parseRunArgs)(process.argv.slice(2));
44
44
  const availablePort = await (0, import_get_port.default)();
45
+ const commonArgs = [
46
+ ...args.node,
47
+ "--require",
48
+ require.resolve("dotenv/config"),
49
+ "--require",
50
+ require.resolve("tsconfig-paths/register")
51
+ ];
45
52
  if (args.entryPoint) {
46
53
  const exec = (0, import_exec.createExec)({
47
54
  env: {
@@ -50,27 +57,25 @@ const node = async () => {
50
57
  }
51
58
  });
52
59
  return exec(
53
- "node",
54
- ...args.node,
55
- "--require",
56
- "dotenv/config",
57
- "--require",
58
- "tsconfig-paths/register",
59
- "--require",
60
- "ts-node/register/transpile-only",
61
- // Override dangerously warn-only default on Node.js <15 so that we
62
- // predictably return a non-zero exit code on an unhandled rejection.
63
- "--unhandled-rejections=throw",
60
+ "tsx",
61
+ ...commonArgs,
64
62
  import_path.default.join(__dirname, "..", "wrapper"),
65
63
  ...args.script
66
64
  );
67
65
  }
68
- return tsNode.createRepl({
69
- service: tsNode.register({
70
- require: ["dotenv/config", "tsconfig-paths/register"],
71
- transpileOnly: true
72
- })
73
- }).start();
66
+ return (0, import_execa.default)(
67
+ require.resolve("tsx/cli"),
68
+ [
69
+ ...commonArgs,
70
+ "--require",
71
+ // Unsure if bug or feature that this is needed, but tsx appears to not do anything typescript in the REPL without this!
72
+ // Doesn't occur when just running the tsx binary directly 🧐
73
+ require.resolve("tsx/patch-repl")
74
+ ],
75
+ {
76
+ stdio: "inherit"
77
+ }
78
+ );
74
79
  };
75
80
  // Annotate the CommonJS export names for ESM import in node:
76
81
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/cli/node.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport getPort from 'get-port';\nimport * as tsNode from 'ts-node';\n\nimport { parseRunArgs } from '../utils/args';\nimport { createExec } from '../utils/exec';\nimport { isIpPort } from '../utils/validation';\n\nexport const longRunning = true;\n\nexport const node = async () => {\n const args = parseRunArgs(process.argv.slice(2));\n\n const availablePort = await getPort();\n\n if (args.entryPoint) {\n const exec = createExec({\n env: {\n __SKUBA_ENTRY_POINT: args.entryPoint,\n __SKUBA_PORT: String(isIpPort(args.port) ? args.port : availablePort),\n },\n });\n\n // Run a script with plain `node` to support inspector options.\n // https://github.com/TypeStrong/ts-node#programmatic\n return exec(\n 'node',\n ...args.node,\n '--require',\n 'dotenv/config',\n '--require',\n 'tsconfig-paths/register',\n '--require',\n 'ts-node/register/transpile-only',\n // Override dangerously warn-only default on Node.js <15 so that we\n // predictably return a non-zero exit code on an unhandled rejection.\n '--unhandled-rejections=throw',\n path.join(__dirname, '..', 'wrapper'),\n ...args.script,\n );\n }\n\n // REPL with `ts-node` to support import statements.\n return tsNode\n .createRepl({\n service: tsNode.register({\n require: ['dotenv/config', 'tsconfig-paths/register'],\n transpileOnly: true,\n }),\n })\n .start();\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAoB;AACpB,aAAwB;AAExB,kBAA6B;AAC7B,kBAA2B;AAC3B,wBAAyB;AAElB,MAAM,cAAc;AAEpB,MAAM,OAAO,YAAY;AAC9B,QAAM,WAAO,0BAAa,QAAQ,KAAK,MAAM,CAAC,CAAC;AAE/C,QAAM,gBAAgB,UAAM,gBAAAA,SAAQ;AAEpC,MAAI,KAAK,YAAY;AACnB,UAAM,WAAO,wBAAW;AAAA,MACtB,KAAK;AAAA,QACH,qBAAqB,KAAK;AAAA,QAC1B,cAAc,WAAO,4BAAS,KAAK,IAAI,IAAI,KAAK,OAAO,aAAa;AAAA,MACtE;AAAA,IACF,CAAC;AAID,WAAO;AAAA,MACL;AAAA,MACA,GAAG,KAAK;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,MAGA;AAAA,MACA,YAAAC,QAAK,KAAK,WAAW,MAAM,SAAS;AAAA,MACpC,GAAG,KAAK;AAAA,IACV;AAAA,EACF;AAGA,SAAO,OACJ,WAAW;AAAA,IACV,SAAS,OAAO,SAAS;AAAA,MACvB,SAAS,CAAC,iBAAiB,yBAAyB;AAAA,MACpD,eAAe;AAAA,IACjB,CAAC;AAAA,EACH,CAAC,EACA,MAAM;AACX;",
6
- "names": ["getPort", "path"]
4
+ "sourcesContent": ["import path from 'path';\n\nimport execa from 'execa';\nimport getPort from 'get-port';\n\nimport { parseRunArgs } from '../utils/args';\nimport { createExec } from '../utils/exec';\nimport { isIpPort } from '../utils/validation';\n\nexport const longRunning = true;\n\nexport const node = async () => {\n const args = parseRunArgs(process.argv.slice(2));\n\n const availablePort = await getPort();\n\n const commonArgs = [\n ...args.node,\n '--require',\n require.resolve('dotenv/config'),\n '--require',\n require.resolve('tsconfig-paths/register'),\n ];\n\n if (args.entryPoint) {\n const exec = createExec({\n env: {\n __SKUBA_ENTRY_POINT: args.entryPoint,\n __SKUBA_PORT: String(isIpPort(args.port) ? args.port : availablePort),\n },\n });\n\n return exec(\n 'tsx',\n ...commonArgs,\n path.join(__dirname, '..', 'wrapper'),\n ...args.script,\n );\n }\n\n return execa(\n require.resolve('tsx/cli'),\n [\n ...commonArgs,\n '--require',\n // Unsure if bug or feature that this is needed, but tsx appears to not do anything typescript in the REPL without this!\n // Doesn't occur when just running the tsx binary directly \uD83E\uDDD0\n require.resolve('tsx/patch-repl'),\n ],\n {\n stdio: 'inherit',\n },\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,mBAAkB;AAClB,sBAAoB;AAEpB,kBAA6B;AAC7B,kBAA2B;AAC3B,wBAAyB;AAElB,MAAM,cAAc;AAEpB,MAAM,OAAO,YAAY;AAC9B,QAAM,WAAO,0BAAa,QAAQ,KAAK,MAAM,CAAC,CAAC;AAE/C,QAAM,gBAAgB,UAAM,gBAAAA,SAAQ;AAEpC,QAAM,aAAa;AAAA,IACjB,GAAG,KAAK;AAAA,IACR;AAAA,IACA,gBAAgB,eAAe;AAAA,IAC/B;AAAA,IACA,gBAAgB,yBAAyB;AAAA,EAC3C;AAEA,MAAI,KAAK,YAAY;AACnB,UAAM,WAAO,wBAAW;AAAA,MACtB,KAAK;AAAA,QACH,qBAAqB,KAAK;AAAA,QAC1B,cAAc,WAAO,4BAAS,KAAK,IAAI,IAAI,KAAK,OAAO,aAAa;AAAA,MACtE;AAAA,IACF,CAAC;AAED,WAAO;AAAA,MACL;AAAA,MACA,GAAG;AAAA,MACH,YAAAC,QAAK,KAAK,WAAW,MAAM,SAAS;AAAA,MACpC,GAAG,KAAK;AAAA,IACV;AAAA,EACF;AAEA,aAAO,aAAAC;AAAA,IACL,gBAAgB,SAAS;AAAA,IACzB;AAAA,MACE,GAAG;AAAA,MACH;AAAA;AAAA;AAAA,MAGA,gBAAgB,gBAAgB;AAAA,IAClC;AAAA,IACA;AAAA,MACE,OAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": ["getPort", "path", "execa"]
7
7
  }
package/lib/cli/start.js CHANGED
@@ -50,14 +50,14 @@ const start = async () => {
50
50
  }
51
51
  });
52
52
  return execProcess(
53
- "ts-node-dev",
53
+ "tsx",
54
+ "watch",
55
+ "--clear-screen=false",
54
56
  ...args.node,
55
57
  "--require",
56
58
  "dotenv/config",
57
59
  "--require",
58
60
  "tsconfig-paths/register",
59
- "--respawn",
60
- "--transpile-only",
61
61
  import_path.default.join(__dirname, "..", "wrapper"),
62
62
  ...args.script
63
63
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/cli/start.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport getPort from 'get-port';\n\nimport { parseRunArgs } from '../utils/args';\nimport { createExec } from '../utils/exec';\nimport { getEntryPointFromManifest } from '../utils/manifest';\nimport { isIpPort } from '../utils/validation';\n\nexport const start = async () => {\n const [args, availablePort] = await Promise.all([\n parseRunArgs(process.argv.slice(2)),\n getPort(),\n ]);\n\n args.entryPoint ??= await getEntryPointFromManifest();\n\n const execProcess = createExec({\n env: {\n __SKUBA_ENTRY_POINT: args.entryPoint,\n __SKUBA_PORT: String(isIpPort(args.port) ? args.port : availablePort),\n },\n });\n\n return execProcess(\n 'ts-node-dev',\n ...args.node,\n '--require',\n 'dotenv/config',\n '--require',\n 'tsconfig-paths/register',\n '--respawn',\n '--transpile-only',\n path.join(__dirname, '..', 'wrapper'),\n ...args.script,\n );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAoB;AAEpB,kBAA6B;AAC7B,kBAA2B;AAC3B,sBAA0C;AAC1C,wBAAyB;AAElB,MAAM,QAAQ,YAAY;AAC/B,QAAM,CAAC,MAAM,aAAa,IAAI,MAAM,QAAQ,IAAI;AAAA,QAC9C,0BAAa,QAAQ,KAAK,MAAM,CAAC,CAAC;AAAA,QAClC,gBAAAA,SAAQ;AAAA,EACV,CAAC;AAED,OAAK,eAAe,UAAM,2CAA0B;AAEpD,QAAM,kBAAc,wBAAW;AAAA,IAC7B,KAAK;AAAA,MACH,qBAAqB,KAAK;AAAA,MAC1B,cAAc,WAAO,4BAAS,KAAK,IAAI,IAAI,KAAK,OAAO,aAAa;AAAA,IACtE;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA,GAAG,KAAK;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAAC,QAAK,KAAK,WAAW,MAAM,SAAS;AAAA,IACpC,GAAG,KAAK;AAAA,EACV;AACF;",
4
+ "sourcesContent": ["import path from 'path';\n\nimport getPort from 'get-port';\n\nimport { parseRunArgs } from '../utils/args';\nimport { createExec } from '../utils/exec';\nimport { getEntryPointFromManifest } from '../utils/manifest';\nimport { isIpPort } from '../utils/validation';\n\nexport const start = async () => {\n const [args, availablePort] = await Promise.all([\n parseRunArgs(process.argv.slice(2)),\n getPort(),\n ]);\n\n args.entryPoint ??= await getEntryPointFromManifest();\n\n const execProcess = createExec({\n env: {\n __SKUBA_ENTRY_POINT: args.entryPoint,\n __SKUBA_PORT: String(isIpPort(args.port) ? args.port : availablePort),\n },\n });\n\n return execProcess(\n 'tsx',\n 'watch',\n '--clear-screen=false',\n ...args.node,\n '--require',\n 'dotenv/config',\n '--require',\n 'tsconfig-paths/register',\n path.join(__dirname, '..', 'wrapper'),\n ...args.script,\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAoB;AAEpB,kBAA6B;AAC7B,kBAA2B;AAC3B,sBAA0C;AAC1C,wBAAyB;AAElB,MAAM,QAAQ,YAAY;AAC/B,QAAM,CAAC,MAAM,aAAa,IAAI,MAAM,QAAQ,IAAI;AAAA,QAC9C,0BAAa,QAAQ,KAAK,MAAM,CAAC,CAAC;AAAA,QAClC,gBAAAA,SAAQ;AAAA,EACV,CAAC;AAED,OAAK,eAAe,UAAM,2CAA0B;AAEpD,QAAM,kBAAc,wBAAW;AAAA,IAC7B,KAAK;AAAA,MACH,qBAAqB,KAAK;AAAA,MAC1B,cAAc,WAAO,4BAAS,KAAK,IAAI,IAAI,KAAK,OAAO,aAAa;AAAA,IACtE;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG,KAAK;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAAC,QAAK,KAAK,WAAW,MAAM,SAAS;AAAA,IACpC,GAAG,KAAK;AAAA,EACV;AACF;",
6
6
  "names": ["getPort", "path"]
7
7
  }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=eslint.d.js.map
package/lib/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["/**\n * Entry point for the Node.js development API.\n *\n * This is where skuba imports point to:\n *\n * ```typescript\n * import { Net } from 'skuba';\n *\n * const { Net } = require('skuba');\n * ```\n */\n\nexport * as Buildkite from './api/buildkite';\nexport * as Git from './api/git';\nexport * as GitHub from './api/github';\nexport * as Jest from './api/jest';\nexport * as Net from './api/net';\n\n// evanw/esbuild#2388\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace WebAssembly {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n interface Module {}\n }\n}\n"],
4
+ "sourcesContent": ["/**\n * Entry point for the Node.js development API.\n *\n * This is where skuba imports point to:\n *\n * ```typescript\n * import { Net } from 'skuba';\n *\n * const { Net } = require('skuba');\n * ```\n */\n\nexport * as Buildkite from './api/buildkite';\nexport * as Git from './api/git';\nexport * as GitHub from './api/github';\nexport * as Jest from './api/jest';\nexport * as Net from './api/net';\n\n// evanw/esbuild#2388\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace WebAssembly {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface Module {}\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,gBAA2B;AAC3B,UAAqB;AACrB,aAAwB;AACxB,WAAsB;AACtB,UAAqB;",
6
6
  "names": []
7
7
  }
package/lib/skuba.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/skuba.ts"],
4
- "sourcesContent": ["#!/usr/bin/env node\n\n/**\n * Entry point for the CLI.\n *\n * This is where you end up when you run:\n *\n * ```bash\n * [pnpm|yarn] skuba help\n * ```\n */\n\nimport path from 'path';\n\nimport { parseProcessArgs } from './utils/args';\nimport {\n COMMAND_DIR,\n COMMAND_SET,\n type Command,\n commandToModule,\n} from './utils/command';\nimport { isCiEnv } from './utils/env';\nimport { handleCliError } from './utils/error';\nimport { showHelp } from './utils/help';\nimport { log } from './utils/logging';\nimport { showLogoAndVersionInfo } from './utils/logo';\nimport { hasProp } from './utils/validation';\n\nconst THIRTY_MINUTES = 30 * 60 * 1000;\n\nconst skuba = async () => {\n const { commandName } = parseProcessArgs(process.argv);\n\n if (COMMAND_SET.has(commandName)) {\n const moduleName = commandToModule(commandName as Command);\n\n /* eslint-disable @typescript-eslint/no-var-requires */\n const commandModule = require(\n path.join(COMMAND_DIR, moduleName),\n ) as unknown;\n\n if (!hasProp(commandModule, moduleName)) {\n log.err(log.bold(commandName), \"couldn't run! Please submit an issue.\");\n process.exitCode = 1;\n return;\n }\n\n const run = commandModule[moduleName] as () => Promise<unknown>;\n\n if (commandModule.longRunning) {\n // This is a long-running command, so we don't want to impose a timeout.\n return run();\n }\n\n // If we're not in a CI environment, we don't need to worry about timeouts, which are primarily to prevent\n // builds running \"forever\" in CI without our knowledge.\n // Local commands may run for a long time, e.g. `skuba start` or `skuba test --watch`, which are unlikely to be used in CI.\n if (!isCiEnv() || process.env.SKUBA_NO_TIMEOUT === 'true') {\n return run();\n }\n\n const timeoutId = setTimeout(\n () => {\n log.err(\n log.bold(commandName),\n 'timed out. This may indicate a process hanging - please file an issue.',\n );\n\n // Need to force exit because promises may be hanging so node won't exit on its own.\n process.exit(1);\n },\n process.env.SKUBA_TIMEOUT_MS\n ? parseInt(process.env.SKUBA_TIMEOUT_MS, 10)\n : THIRTY_MINUTES,\n );\n\n return run().finally(() => clearTimeout(timeoutId));\n }\n\n log.err(log.bold(commandName), 'is not recognised as a command.');\n await showLogoAndVersionInfo();\n showHelp();\n\n process.exitCode = 1;\n return;\n};\n\nskuba().catch(handleCliError);\n"],
4
+ "sourcesContent": ["#!/usr/bin/env node\n\n/**\n * Entry point for the CLI.\n *\n * This is where you end up when you run:\n *\n * ```bash\n * [pnpm|yarn] skuba help\n * ```\n */\n\nimport path from 'path';\n\nimport { parseProcessArgs } from './utils/args';\nimport {\n COMMAND_DIR,\n COMMAND_SET,\n type Command,\n commandToModule,\n} from './utils/command';\nimport { isCiEnv } from './utils/env';\nimport { handleCliError } from './utils/error';\nimport { showHelp } from './utils/help';\nimport { log } from './utils/logging';\nimport { showLogoAndVersionInfo } from './utils/logo';\nimport { hasProp } from './utils/validation';\n\nconst THIRTY_MINUTES = 30 * 60 * 1000;\n\nconst skuba = async () => {\n const { commandName } = parseProcessArgs(process.argv);\n\n if (COMMAND_SET.has(commandName)) {\n const moduleName = commandToModule(commandName as Command);\n\n /* eslint-disable @typescript-eslint/no-require-imports */\n const commandModule = require(\n path.join(COMMAND_DIR, moduleName),\n ) as unknown;\n\n if (!hasProp(commandModule, moduleName)) {\n log.err(log.bold(commandName), \"couldn't run! Please submit an issue.\");\n process.exitCode = 1;\n return;\n }\n\n const run = commandModule[moduleName] as () => Promise<unknown>;\n\n if (commandModule.longRunning) {\n // This is a long-running command, so we don't want to impose a timeout.\n return run();\n }\n\n // If we're not in a CI environment, we don't need to worry about timeouts, which are primarily to prevent\n // builds running \"forever\" in CI without our knowledge.\n // Local commands may run for a long time, e.g. `skuba start` or `skuba test --watch`, which are unlikely to be used in CI.\n if (!isCiEnv() || process.env.SKUBA_NO_TIMEOUT === 'true') {\n return run();\n }\n\n const timeoutId = setTimeout(\n () => {\n log.err(\n log.bold(commandName),\n 'timed out. This may indicate a process hanging - please file an issue.',\n );\n\n // Need to force exit because promises may be hanging so node won't exit on its own.\n process.exit(1);\n },\n process.env.SKUBA_TIMEOUT_MS\n ? parseInt(process.env.SKUBA_TIMEOUT_MS, 10)\n : THIRTY_MINUTES,\n );\n\n return run().finally(() => clearTimeout(timeoutId));\n }\n\n log.err(log.bold(commandName), 'is not recognised as a command.');\n await showLogoAndVersionInfo();\n showHelp();\n\n process.exitCode = 1;\n return;\n};\n\nskuba().catch(handleCliError);\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAYA,kBAAiB;AAEjB,kBAAiC;AACjC,qBAKO;AACP,iBAAwB;AACxB,mBAA+B;AAC/B,kBAAyB;AACzB,qBAAoB;AACpB,kBAAuC;AACvC,wBAAwB;AAExB,MAAM,iBAAiB,KAAK,KAAK;AAEjC,MAAM,QAAQ,YAAY;AACxB,QAAM,EAAE,YAAY,QAAI,8BAAiB,QAAQ,IAAI;AAErD,MAAI,2BAAY,IAAI,WAAW,GAAG;AAChC,UAAM,iBAAa,gCAAgB,WAAsB;AAGzD,UAAM,gBAAgB,QACpB,YAAAA,QAAK,KAAK,4BAAa,UAAU,CACnC;AAEA,QAAI,KAAC,2BAAQ,eAAe,UAAU,GAAG;AACvC,yBAAI,IAAI,mBAAI,KAAK,WAAW,GAAG,uCAAuC;AACtE,cAAQ,WAAW;AACnB;AAAA,IACF;AAEA,UAAM,MAAM,cAAc,UAAU;AAEpC,QAAI,cAAc,aAAa;AAE7B,aAAO,IAAI;AAAA,IACb;AAKA,QAAI,KAAC,oBAAQ,KAAK,QAAQ,IAAI,qBAAqB,QAAQ;AACzD,aAAO,IAAI;AAAA,IACb;AAEA,UAAM,YAAY;AAAA,MAChB,MAAM;AACJ,2BAAI;AAAA,UACF,mBAAI,KAAK,WAAW;AAAA,UACpB;AAAA,QACF;AAGA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,MACA,QAAQ,IAAI,mBACR,SAAS,QAAQ,IAAI,kBAAkB,EAAE,IACzC;AAAA,IACN;AAEA,WAAO,IAAI,EAAE,QAAQ,MAAM,aAAa,SAAS,CAAC;AAAA,EACpD;AAEA,qBAAI,IAAI,mBAAI,KAAK,WAAW,GAAG,iCAAiC;AAChE,YAAM,oCAAuB;AAC7B,4BAAS;AAET,UAAQ,WAAW;AACnB;AACF;AAEA,MAAM,EAAE,MAAM,2BAAc;",
6
6
  "names": ["path"]
7
7
  }
package/lib/utils/copy.js CHANGED
@@ -71,7 +71,7 @@ const copyFiles = async (opts, currentSourceDir = opts.sourceRoot, currentDestin
71
71
  const filenames = await import_fs_extra.default.promises.readdir(currentSourceDir);
72
72
  const toDestinationPath = (filename) => import_path.default.join(
73
73
  currentDestinationDir,
74
- opts.stripUnderscorePrefix ? filename.replace(/^_\./, ".").replace(/^_package\.json/, "package.json") : filename
74
+ opts.stripUnderscorePrefix ? filename.replace(/^_\./, ".").replace(/^_package\.json/, "package.json").replace(/^_eslint\.config\.js/, "eslint.config.js") : filename
75
75
  );
76
76
  const filteredFilenames = filenames.filter(
77
77
  (filename) => opts.include(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/copy.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport ejs from 'ejs';\nimport fs from 'fs-extra';\n\nimport { isErrorWithCode } from './error';\nimport { log } from './logging';\n\nexport type TextProcessor = (contents: string) => string;\n\nexport const copyFile = async (\n sourcePath: string,\n destinationPath: string,\n {\n overwrite = true,\n processors,\n }: Pick<CopyFilesOptions, 'overwrite' | 'processors'>,\n) => {\n const oldContents = await fs.promises.readFile(sourcePath, 'utf8');\n\n const newContents = processors.reduce(\n (contents, process) => process(contents),\n oldContents,\n );\n\n if (oldContents === newContents && sourcePath === destinationPath) {\n return;\n }\n\n try {\n await fs.promises.writeFile(destinationPath, newContents, {\n flag: overwrite ? 'w' : 'wx',\n });\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n return;\n }\n\n throw err;\n }\n};\n\ninterface CopyFilesOptions {\n sourceRoot: string;\n destinationRoot: string;\n\n include: (pathname: string) => boolean;\n overwrite?: boolean;\n processors: TextProcessor[];\n stripUnderscorePrefix?: boolean;\n}\n\nexport const createEjsRenderer =\n (templateData: Record<string, unknown>): TextProcessor =>\n (contents) =>\n ejs.render(contents, templateData);\n\nexport const createStringReplacer =\n (\n replacements: Array<{\n input: RegExp;\n output: string;\n }>,\n ): TextProcessor =>\n (contents) =>\n replacements.reduce(\n (newContents, { input, output }) => newContents.replace(input, output),\n contents,\n );\n\nexport const copyFiles = async (\n opts: CopyFilesOptions,\n currentSourceDir: string = opts.sourceRoot,\n currentDestinationDir: string = opts.destinationRoot,\n) => {\n const filenames = await fs.promises.readdir(currentSourceDir);\n\n const toDestinationPath = (filename: string) =>\n path.join(\n currentDestinationDir,\n opts.stripUnderscorePrefix\n ? filename\n .replace(/^_\\./, '.')\n .replace(/^_package\\.json/, 'package.json')\n : filename,\n );\n\n const filteredFilenames = filenames.filter((filename) =>\n opts.include(\n path.relative(opts.destinationRoot, toDestinationPath(filename)),\n ),\n );\n\n await Promise.all(\n filteredFilenames.map(async (filename) => {\n const sourcePath = path.join(currentSourceDir, filename);\n const destinationPath = toDestinationPath(filename);\n\n try {\n await copyFile(sourcePath, destinationPath, opts);\n } catch (err) {\n if (isErrorWithCode(err, 'EISDIR')) {\n await fs.promises.mkdir(destinationPath, { recursive: true });\n return copyFiles(opts, sourcePath, destinationPath);\n }\n\n log.err('Failed to render', log.bold(sourcePath));\n\n throw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AC1C,KAAK;AAAA,MACH,YAAAA,QAAK,SAAS,KAAK,iBAAiB,kBAAkB,QAAQ,CAAC;AAAA,IACjE;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,kBAAkB,IAAI,OAAO,aAAa;AACxC,YAAM,aAAa,YAAAA,QAAK,KAAK,kBAAkB,QAAQ;AACvD,YAAM,kBAAkB,kBAAkB,QAAQ;AAElD,UAAI;AACF,cAAM,SAAS,YAAY,iBAAiB,IAAI;AAAA,MAClD,SAAS,KAAK;AACZ,gBAAI,8BAAgB,KAAK,QAAQ,GAAG;AAClC,gBAAM,gBAAAF,QAAG,SAAS,MAAM,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAC5D,iBAAO,UAAU,MAAM,YAAY,eAAe;AAAA,QACpD;AAEA,2BAAI,IAAI,oBAAoB,mBAAI,KAAK,UAAU,CAAC;AAEhD,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import path from 'path';\n\nimport ejs from 'ejs';\nimport fs from 'fs-extra';\n\nimport { isErrorWithCode } from './error';\nimport { log } from './logging';\n\nexport type TextProcessor = (contents: string) => string;\n\nexport const copyFile = async (\n sourcePath: string,\n destinationPath: string,\n {\n overwrite = true,\n processors,\n }: Pick<CopyFilesOptions, 'overwrite' | 'processors'>,\n) => {\n const oldContents = await fs.promises.readFile(sourcePath, 'utf8');\n\n const newContents = processors.reduce(\n (contents, process) => process(contents),\n oldContents,\n );\n\n if (oldContents === newContents && sourcePath === destinationPath) {\n return;\n }\n\n try {\n await fs.promises.writeFile(destinationPath, newContents, {\n flag: overwrite ? 'w' : 'wx',\n });\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n return;\n }\n\n throw err;\n }\n};\n\ninterface CopyFilesOptions {\n sourceRoot: string;\n destinationRoot: string;\n\n include: (pathname: string) => boolean;\n overwrite?: boolean;\n processors: TextProcessor[];\n stripUnderscorePrefix?: boolean;\n}\n\nexport const createEjsRenderer =\n (templateData: Record<string, unknown>): TextProcessor =>\n (contents) =>\n ejs.render(contents, templateData);\n\nexport const createStringReplacer =\n (\n replacements: Array<{\n input: RegExp;\n output: string;\n }>,\n ): TextProcessor =>\n (contents) =>\n replacements.reduce(\n (newContents, { input, output }) => newContents.replace(input, output),\n contents,\n );\n\nexport const copyFiles = async (\n opts: CopyFilesOptions,\n currentSourceDir: string = opts.sourceRoot,\n currentDestinationDir: string = opts.destinationRoot,\n) => {\n const filenames = await fs.promises.readdir(currentSourceDir);\n\n const toDestinationPath = (filename: string) =>\n path.join(\n currentDestinationDir,\n opts.stripUnderscorePrefix\n ? filename\n .replace(/^_\\./, '.')\n .replace(/^_package\\.json/, 'package.json')\n .replace(/^_eslint\\.config\\.js/, 'eslint.config.js')\n : filename,\n );\n\n const filteredFilenames = filenames.filter((filename) =>\n opts.include(\n path.relative(opts.destinationRoot, toDestinationPath(filename)),\n ),\n );\n\n await Promise.all(\n filteredFilenames.map(async (filename) => {\n const sourcePath = path.join(currentSourceDir, filename);\n const destinationPath = toDestinationPath(filename);\n\n try {\n await copyFile(sourcePath, destinationPath, opts);\n } catch (err) {\n if (isErrorWithCode(err, 'EISDIR')) {\n await fs.promises.mkdir(destinationPath, { recursive: true });\n return copyFiles(opts, sourcePath, destinationPath);\n }\n\n log.err('Failed to render', log.bold(sourcePath));\n\n throw err;\n }\n }),\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,iBAAgB;AAChB,sBAAe;AAEf,mBAAgC;AAChC,qBAAoB;AAIb,MAAM,WAAW,OACtB,YACA,iBACA;AAAA,EACE,YAAY;AAAA,EACZ;AACF,MACG;AACH,QAAM,cAAc,MAAM,gBAAAA,QAAG,SAAS,SAAS,YAAY,MAAM;AAEjE,QAAM,cAAc,WAAW;AAAA,IAC7B,CAAC,UAAU,YAAY,QAAQ,QAA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AAClC,gBAAM,gBAAAF,QAAG,SAAS,MAAM,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAC5D,iBAAO,UAAU,MAAM,YAAY,eAAe;AAAA,QACpD;AAEA,2BAAI,IAAI,oBAAoB,mBAAI,KAAK,UAAU,CAAC;AAEhD,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
6
6
  "names": ["fs", "ejs", "path"]
7
7
  }
@@ -28,12 +28,12 @@ export declare const templateConfigSchema: z.ZodObject<{
28
28
  message: string;
29
29
  name: string;
30
30
  initial: string;
31
- validate?: ((args_0: string, ...args_1: unknown[]) => string | boolean) | undefined;
31
+ validate?: ((args_0: string, ...args: unknown[]) => string | boolean) | undefined;
32
32
  }, {
33
33
  message: string;
34
34
  name: string;
35
35
  initial: string;
36
- validate?: ((args_0: string, ...args_1: unknown[]) => string | boolean) | undefined;
36
+ validate?: ((args_0: string, ...args: unknown[]) => string | boolean) | undefined;
37
37
  }>, "many">;
38
38
  entryPoint: z.ZodOptional<z.ZodString>;
39
39
  noSkip: z.ZodOptional<z.ZodBoolean>;
@@ -44,7 +44,7 @@ export declare const templateConfigSchema: z.ZodObject<{
44
44
  message: string;
45
45
  name: string;
46
46
  initial: string;
47
- validate?: ((args_0: string, ...args_1: unknown[]) => string | boolean) | undefined;
47
+ validate?: ((args_0: string, ...args: unknown[]) => string | boolean) | undefined;
48
48
  }[];
49
49
  packageManager: "yarn" | "pnpm";
50
50
  type?: "package" | "application" | undefined;
@@ -55,7 +55,7 @@ export declare const templateConfigSchema: z.ZodObject<{
55
55
  message: string;
56
56
  name: string;
57
57
  initial: string;
58
- validate?: ((args_0: string, ...args_1: unknown[]) => string | boolean) | undefined;
58
+ validate?: ((args_0: string, ...args: unknown[]) => string | boolean) | undefined;
59
59
  }[];
60
60
  type?: "package" | "application" | undefined;
61
61
  entryPoint?: string | undefined;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/wrapper/main.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport { runFunctionHandler } from './functionHandler';\nimport { runRequestListener } from './requestListener';\n\nexport const main = async (rawEntryPoint: string, rawPort: string) => {\n const availablePort = Number(rawPort) || undefined;\n\n // Support exported function targeting, e.g. `src/module.ts#callMeMaybe`\n const [modulePath, functionName] = path\n .join(process.cwd(), rawEntryPoint)\n .split('#', 2);\n\n // Load entry point as module\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const entryPoint = require(modulePath as string) as unknown;\n\n return functionName\n ? runFunctionHandler({ availablePort, entryPoint, functionName })\n : runRequestListener({ availablePort, entryPoint });\n};\n"],
4
+ "sourcesContent": ["import path from 'path';\n\nimport { runFunctionHandler } from './functionHandler';\nimport { runRequestListener } from './requestListener';\n\nexport const main = async (rawEntryPoint: string, rawPort: string) => {\n const availablePort = Number(rawPort) || undefined;\n\n // Support exported function targeting, e.g. `src/module.ts#callMeMaybe`\n const [modulePath, functionName] = path\n .join(process.cwd(), rawEntryPoint)\n .split('#', 2);\n\n // Load entry point as module\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const entryPoint = require(modulePath as string) as unknown;\n\n return functionName\n ? runFunctionHandler({ availablePort, entryPoint, functionName })\n : runRequestListener({ availablePort, entryPoint });\n};\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,6BAAmC;AACnC,6BAAmC;AAE5B,MAAM,OAAO,OAAO,eAAuB,YAAoB;AACpE,QAAM,gBAAgB,OAAO,OAAO,KAAK;AAGzC,QAAM,CAAC,YAAY,YAAY,IAAI,YAAAA,QAChC,KAAK,QAAQ,IAAI,GAAG,aAAa,EACjC,MAAM,KAAK,CAAC;AAIf,QAAM,aAAa,QAAQ,UAAoB;AAE/C,SAAO,mBACH,2CAAmB,EAAE,eAAe,YAAY,aAAa,CAAC,QAC9D,2CAAmB,EAAE,eAAe,WAAW,CAAC;AACtD;",
6
6
  "names": ["path"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/wrapper/requestListener.ts"],
4
- "sourcesContent": ["import http from 'http';\n\nimport { isFunction, isIpPort, isObject } from '../utils/validation';\n\nimport { serveRequestListener, startServer } from './http';\n\n// Express compatibility\ninterface FunctionConfig extends http.RequestListener {\n port?: number;\n}\n\ninterface ObjectConfig {\n // Koa compatibility\n callback?: () => http.RequestListener;\n\n requestListener?: http.RequestListener;\n\n // Fastify compatibility\n server?: http.Server;\n\n default?: Promise<unknown>;\n port?: unknown;\n}\n\nconst isConfig = (\n data: unknown,\n): data is Promise<FunctionConfig> | Promise<ObjectConfig> =>\n isFunction(data) || isObject(data);\n\ninterface Args {\n availablePort?: number;\n entryPoint: unknown;\n}\n\n/**\n * Create an HTTP server that calls into an exported `http.RequestListener`.\n *\n * This supports Express and Koa applications out of the box.\n */\nexport const runRequestListener = async ({\n availablePort,\n entryPoint,\n}: Args): Promise<void> => {\n if (!isConfig(entryPoint)) {\n // Assume an executable script with weird exports\n return;\n }\n\n let config: FunctionConfig | ObjectConfig = await entryPoint;\n\n if (typeof config === 'object' && isConfig(config.default)) {\n // Prefer `export default` over `export =`\n config = await config.default;\n }\n\n if (Object.keys(config).length === 0) {\n // Assume an executable script with no exports\n return;\n }\n\n const port = isIpPort(config.port) ? config.port : availablePort;\n\n // http.Server support\n if (typeof config !== 'function' && config instanceof http.Server) {\n return startServer(config, port);\n }\n\n // Fastify workaround\n if (\n typeof config !== 'function' &&\n config.server &&\n config.server instanceof http.Server\n ) {\n return startServer(config.server, port);\n }\n\n const requestListener =\n typeof config === 'function'\n ? config\n : (config.requestListener ?? config.callback?.());\n\n if (typeof requestListener !== 'function') {\n // Assume an executable script with non-request listener exports\n return;\n }\n\n return serveRequestListener(requestListener, port);\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,wBAA+C;AAE/C,IAAAA,eAAkD;AAoBlD,MAAM,WAAW,CACf,aAEA,8BAAW,IAAI,SAAK,4BAAS,IAAI;AAY5B,MAAM,qBAAqB,OAAO;AAAA,EACvC;AAAA,EACA;AACF,MAA2B;AACzB,MAAI,CAAC,SAAS,UAAU,GAAG;AAEzB;AAAA,EACF;AAEA,MAAI,SAAwC,MAAM;AAElD,MAAI,OAAO,WAAW,YAAY,SAAS,OAAO,OAAO,GAAG;AAE1D,aAAS,MAAM,OAAO;AAAA,EACxB;AAEA,MAAI,OAAO,KAAK,MAAM,EAAE,WAAW,GAAG;AAEpC;AAAA,EACF;AAEA,QAAM,WAAO,4BAAS,OAAO,IAAI,IAAI,OAAO,OAAO;AAGnD,MAAI,OAAO,WAAW,cAAc,kBAAkB,YAAAC,QAAK,QAAQ;AACjE,eAAO,0BAAY,QAAQ,IAAI;AAAA,EACjC;AAGA,MACE,OAAO,WAAW,cAClB,OAAO,UACP,OAAO,kBAAkB,YAAAA,QAAK,QAC9B;AACA,eAAO,0BAAY,OAAO,QAAQ,IAAI;AAAA,EACxC;AAEA,QAAM,kBACJ,OAAO,WAAW,aACd,SACC,OAAO,mBAAmB,OAAO,WAAW;AAEnD,MAAI,OAAO,oBAAoB,YAAY;AAEzC;AAAA,EACF;AAEA,aAAO,mCAAqB,iBAAiB,IAAI;AACnD;",
4
+ "sourcesContent": ["import http from 'http';\n\nimport { isFunction, isIpPort, isObject } from '../utils/validation';\n\nimport { serveRequestListener, startServer } from './http';\n\n// Express compatibility\ninterface FunctionConfig extends http.RequestListener {\n port?: number;\n}\n\ninterface ObjectConfig {\n // Koa compatibility\n callback?: () => http.RequestListener;\n\n requestListener?: http.RequestListener;\n\n // Fastify compatibility\n server?: http.Server;\n\n default?: Promise<unknown>;\n port?: unknown;\n}\n\nconst isConfig = (\n data: unknown,\n): data is Promise<FunctionConfig> | Promise<ObjectConfig> =>\n isFunction(data) || isObject(data);\n\ninterface Args {\n availablePort?: number;\n entryPoint: unknown;\n}\n\n/**\n * Create an HTTP server that calls into an exported `http.RequestListener`.\n *\n * This supports Express and Koa applications out of the box.\n */\nexport const runRequestListener = async ({\n availablePort,\n entryPoint,\n}: Args): Promise<void> => {\n if (!isConfig(entryPoint)) {\n // Assume an executable script with weird exports\n return;\n }\n\n let config: FunctionConfig | ObjectConfig = await entryPoint;\n\n if (typeof config === 'object' && isConfig(config.default)) {\n // Prefer `export default` over `export =`\n config = await config.default;\n }\n\n if (Object.keys(config).length === 0) {\n // Assume an executable script with no exports\n return;\n }\n\n const port = isIpPort(config.port) ? config.port : availablePort;\n\n // http.Server support\n if (typeof config !== 'function' && config instanceof http.Server) {\n return startServer(config, port);\n }\n\n // Fastify workaround\n if (\n typeof config !== 'function' &&\n config.server &&\n config.server instanceof http.Server\n ) {\n return startServer(config.server, port);\n }\n\n const requestListener =\n typeof config === 'function'\n ? config\n : config.requestListener ?? config.callback?.();\n\n if (typeof requestListener !== 'function') {\n // Assume an executable script with non-request listener exports\n return;\n }\n\n return serveRequestListener(requestListener, port);\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,wBAA+C;AAE/C,IAAAA,eAAkD;AAoBlD,MAAM,WAAW,CACf,aAEA,8BAAW,IAAI,SAAK,4BAAS,IAAI;AAY5B,MAAM,qBAAqB,OAAO;AAAA,EACvC;AAAA,EACA;AACF,MAA2B;AACzB,MAAI,CAAC,SAAS,UAAU,GAAG;AAEzB;AAAA,EACF;AAEA,MAAI,SAAwC,MAAM;AAElD,MAAI,OAAO,WAAW,YAAY,SAAS,OAAO,OAAO,GAAG;AAE1D,aAAS,MAAM,OAAO;AAAA,EACxB;AAEA,MAAI,OAAO,KAAK,MAAM,EAAE,WAAW,GAAG;AAEpC;AAAA,EACF;AAEA,QAAM,WAAO,4BAAS,OAAO,IAAI,IAAI,OAAO,OAAO;AAGnD,MAAI,OAAO,WAAW,cAAc,kBAAkB,YAAAC,QAAK,QAAQ;AACjE,eAAO,0BAAY,QAAQ,IAAI;AAAA,EACjC;AAGA,MACE,OAAO,WAAW,cAClB,OAAO,UACP,OAAO,kBAAkB,YAAAA,QAAK,QAC9B;AACA,eAAO,0BAAY,OAAO,QAAQ,IAAI;AAAA,EACxC;AAEA,QAAM,kBACJ,OAAO,WAAW,aACd,SACA,OAAO,mBAAmB,OAAO,WAAW;AAElD,MAAI,OAAO,oBAAoB,YAAY;AAEzC;AAAA,EACF;AAEA,aAAO,mCAAqB,iBAAiB,IAAI;AACnD;",
6
6
  "names": ["import_http", "http"]
7
7
  }