skuba 13.0.3 → 13.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/adapter/eslint.js +3 -3
- package/lib/cli/adapter/eslint.js.map +3 -3
- package/lib/cli/build/assets.d.ts +3 -2
- package/lib/cli/build/assets.js +2 -2
- package/lib/cli/build/assets.js.map +3 -3
- package/lib/cli/build/esbuild.js +3 -12
- package/lib/cli/build/esbuild.js.map +3 -3
- package/lib/cli/build/index.js +3 -13
- package/lib/cli/build/index.js.map +3 -3
- package/lib/cli/build/tsc.js +1 -2
- package/lib/cli/build/tsc.js.map +2 -2
- package/lib/cli/configure/analysis/diff.js +3 -13
- package/lib/cli/configure/analysis/diff.js.map +3 -3
- package/lib/cli/configure/ensureTemplateCompletion.js +5 -2
- package/lib/cli/configure/ensureTemplateCompletion.js.map +3 -3
- package/lib/cli/configure/getEntryPoint.d.ts +1 -1
- package/lib/cli/configure/getEntryPoint.js +8 -10
- package/lib/cli/configure/getEntryPoint.js.map +3 -3
- package/lib/cli/configure/getProjectType.js +4 -6
- package/lib/cli/configure/getProjectType.js.map +2 -2
- package/lib/cli/configure/index.js +12 -11
- package/lib/cli/configure/index.js.map +2 -2
- package/lib/cli/format/index.js +4 -14
- package/lib/cli/format/index.js.map +3 -3
- package/lib/cli/init/getConfig.d.ts +1 -1
- package/lib/cli/init/getConfig.js +35 -42
- package/lib/cli/init/getConfig.js.map +3 -3
- package/lib/cli/init/git.js +2 -2
- package/lib/cli/init/git.js.map +3 -3
- package/lib/cli/init/prompts.d.ts +13 -10
- package/lib/cli/init/prompts.js +26 -36
- package/lib/cli/init/prompts.js.map +3 -3
- package/lib/cli/init/types.d.ts +1 -1
- package/lib/cli/lint/autofix.js +2 -2
- package/lib/cli/lint/autofix.js.map +3 -3
- package/lib/cli/lint/eslint.js +2 -2
- package/lib/cli/lint/eslint.js.map +3 -3
- package/lib/cli/lint/index.js +1 -3
- package/lib/cli/lint/index.js.map +2 -2
- package/lib/cli/lint/internal.js +6 -14
- package/lib/cli/lint/internal.js.map +3 -3
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js +3 -5
- package/lib/cli/lint/internalLints/noSkubaTemplateJs.js.map +3 -3
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +1 -3
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.js +1 -3
- package/lib/cli/lint/internalLints/upgrade/index.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +17 -21
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js +0 -5
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/index.js.map +2 -2
- package/lib/cli/lint/prettier.js +2 -2
- package/lib/cli/lint/prettier.js.map +3 -3
- package/lib/utils/dir.js +3 -2
- package/lib/utils/dir.js.map +2 -2
- package/lib/utils/exec.d.ts +3 -2
- package/lib/utils/exec.js +1 -1
- package/lib/utils/exec.js.map +2 -2
- package/lib/utils/fs.d.ts +1 -0
- package/lib/utils/fs.js +51 -0
- package/lib/utils/fs.js.map +7 -0
- package/lib/utils/logging.d.ts +9 -10
- package/lib/utils/logging.js +9 -19
- package/lib/utils/logging.js.map +3 -3
- package/lib/utils/logo.js +11 -18
- package/lib/utils/logo.js.map +3 -3
- package/lib/utils/sleep.d.ts +5 -0
- package/lib/utils/sleep.js +35 -0
- package/lib/utils/sleep.js.map +7 -0
- package/lib/utils/wait.d.ts +0 -4
- package/lib/utils/wait.js +2 -10
- package/lib/utils/wait.js.map +2 -2
- package/lib/utils/worker.d.ts +3 -3
- package/lib/wrapper/http.d.ts +0 -6
- package/lib/wrapper/http.js +4 -12
- package/lib/wrapper/http.js.map +2 -2
- package/lib/wrapper/requestListener.js +3 -2
- package/lib/wrapper/requestListener.js.map +2 -2
- package/lib/wrapper/server.d.ts +7 -0
- package/lib/wrapper/server.js +35 -0
- package/lib/wrapper/server.js.map +7 -0
- package/package.json +16 -18
- package/template/base/_pnpm-workspace.yaml +1 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/.gantry/dev.yml +2 -2
- package/template/express-rest-api/.gantry/prod.yml +2 -2
- package/template/express-rest-api/package.json +5 -5
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/package.json +2 -2
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/.gantry/dev.yml +2 -2
- package/template/koa-rest-api/.gantry/prod.yml +2 -2
- package/template/koa-rest-api/package.json +5 -5
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +2 -4
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +1 -1
- package/template/lambda-sqs-worker-cdk/infra/config.ts +2 -4
- package/template/lambda-sqs-worker-cdk/package.json +3 -2
- package/template/lambda-sqs-worker-cdk/skuba.template.js +12 -0
- package/template/oss-npm-package/.github/workflows/release.yml +2 -2
- package/template/oss-npm-package/.github/workflows/validate.yml +2 -2
- package/template/private-npm-package/skuba.template.js +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.d.ts +0 -2
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +0 -144
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +0 -7
- package/lib/enquirer.d.js +0 -2
- package/lib/enquirer.d.js.map +0 -7
- package/lib/eslint.d.js +0 -2
- package/lib/eslint.d.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/configure/index.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport { select } from '@inquirer/prompts';\n\nimport { createInclusionFilter } from '../../utils/dir.js';\nimport { createExec, ensureCommands } from '../../utils/exec.js';\nimport { log } from '../../utils/logging.js';\nimport { showLogoAndVersionInfo } from '../../utils/logo.js';\nimport { detectPackageManager } from '../../utils/packageManager.js';\nimport { BASE_TEMPLATE_DIR } from '../../utils/template.js';\nimport { hasProp } from '../../utils/validation.js';\n\nimport { analyseConfiguration } from './analyseConfiguration.js';\nimport { analyseDependencies } from './analyseDependencies.js';\nimport { auditWorkingTree } from './analysis/git.js';\nimport { getDestinationManifest } from './analysis/package.js';\nimport { ensureTemplateCompletion } from './ensureTemplateCompletion.js';\nimport { getEntryPoint } from './getEntryPoint.js';\nimport { getProjectType } from './getProjectType.js';\n\nconst shouldApply = async () => {\n if (!process.stdin.isTTY) {\n return 'yes';\n }\n\n const result = await select({\n message: 'Apply changes?',\n choices: [\n { name: 'Yes', value: 'yes' },\n { name: 'No', value: 'no' },\n ],\n });\n\n return result === 'yes';\n};\n\nexport const configure = async () => {\n await showLogoAndVersionInfo();\n\n const [manifest, packageManager] = await Promise.all([\n getDestinationManifest(),\n detectPackageManager(),\n ]);\n\n await ensureCommands(packageManager.command);\n\n const destinationRoot = path.dirname(manifest.path);\n\n log.plain('Detected project root:', log.bold(destinationRoot));\n\n const [include] = await Promise.all([\n createInclusionFilter([\n path.join(destinationRoot, '.gitignore'),\n path.join(BASE_TEMPLATE_DIR, '_.gitignore'),\n ]),\n\n auditWorkingTree(destinationRoot),\n ]);\n\n const templateConfig = await ensureTemplateCompletion({\n destinationRoot,\n include,\n manifest,\n });\n\n const type = await getProjectType({\n manifest,\n templateConfig,\n });\n\n const entryPoint = await getEntryPoint({\n destinationRoot,\n manifest,\n templateConfig,\n type,\n });\n\n const fixDependencies = await analyseDependencies({\n destinationRoot,\n include,\n manifest,\n type,\n });\n\n if (fixDependencies) {\n log.newline();\n\n if (await shouldApply()) {\n await fixDependencies();\n }\n }\n\n const firstRun = hasProp(manifest.packageJson, 'skuba');\n\n const fixConfiguration = await analyseConfiguration({\n destinationRoot,\n entryPoint,\n firstRun,\n packageManager,\n type,\n });\n\n if (fixConfiguration) {\n log.newline();\n\n if (await shouldApply()) {\n await fixConfiguration();\n }\n }\n\n if (fixDependencies) {\n const exec = createExec({\n stdio: 'pipe',\n streamStdio: packageManager.command,\n });\n\n log.newline();\n try {\n await exec(packageManager.command, 'install');\n } catch {\n log.newline();\n log.warn(log.bold('\u2717 Failed to install dependencies. Resume with:'));\n\n log.newline();\n log.plain(log.bold(`${packageManager.command} install`));\n log.plain(log.bold(`${packageManager.command} format`));\n\n log.newline();\n process.exitCode = 1;\n return;\n }\n }\n\n if (fixConfiguration ?? fixDependencies) {\n log.newline();\n log.ok(log.bold('\u2714 All done! Try running:'));\n\n log.newline();\n log.plain(log.bold(`${packageManager.command} format`));\n }\n\n log.newline();\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,qBAAuB;AAEvB,iBAAsC;AACtC,kBAA2C;AAC3C,qBAAoB;AACpB,kBAAuC;AACvC,4BAAqC;AACrC,sBAAkC;AAClC,wBAAwB;AAExB,kCAAqC;AACrC,iCAAoC;AACpC,iBAAiC;AACjC,qBAAuC;AACvC,sCAAyC;AACzC,2BAA8B;AAC9B,4BAA+B;AAE/B,MAAM,cAAc,YAAY;AAC9B,MAAI,CAAC,QAAQ,MAAM,OAAO;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,UAAM,uBAAO;AAAA,IAC1B,SAAS;AAAA,IACT,SAAS;AAAA,MACP,EAAE,MAAM,OAAO,OAAO,MAAM;AAAA,MAC5B,EAAE,MAAM,MAA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AQ;AAEZ,QAAI,MAAM,YAAY,GAAG;AACvB,YAAM,iBAAiB;AAAA,IACzB;AAAA,EACF;AAEA,MAAI,iBAAiB;AACnB,UAAM,WAAO,wBAAW;AAAA,MACtB,OAAO;AAAA,MACP,aAAa,eAAe;AAAA,IAC9B,CAAC;AAED,uBAAI,QAAQ;AACZ,QAAI;AACF,YAAM,KAAK,eAAe,SAAS,SAAS;AAAA,IAC9C,QAAQ;AACN,yBAAI,QAAQ;AACZ,yBAAI,KAAK,mBAAI,KAAK,qDAAgD,CAAC;AAEnE,yBAAI,QAAQ;AACZ,yBAAI,MAAM,mBAAI,KAAK,GAAG,eAAe,OAAO,UAAU,CAAC;AACvD,yBAAI,MAAM,mBAAI,KAAK,GAAG,eAAe,OAAO,SAAS,CAAC;AAEtD,yBAAI,QAAQ;AACZ,cAAQ,WAAW;AACnB;AAAA,IACF;AAAA,EACF;AAEA,MAAI,oBAAoB,iBAAiB;AACvC,uBAAI,QAAQ;AACZ,uBAAI,GAAG,mBAAI,KAAK,+BAA0B,CAAC;AAE3C,uBAAI,QAAQ;AACZ,uBAAI,MAAM,mBAAI,KAAK,GAAG,eAAe,OAAO,SAAS,CAAC;AAAA,EACxD;AAEA,qBAAI,QAAQ;AACd;",
|
|
6
6
|
"names": ["path"]
|
|
7
7
|
}
|
package/lib/cli/format/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,21 +15,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var format_exports = {};
|
|
30
20
|
__export(format_exports, {
|
|
31
21
|
format: () => format
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(format_exports);
|
|
34
|
-
var
|
|
24
|
+
var import_node_util = require("node:util");
|
|
35
25
|
var import_args = require("../../utils/args.js");
|
|
36
26
|
var import_logging = require("../../utils/logging.js");
|
|
37
27
|
var import_eslint = require("../adapter/eslint.js");
|
|
@@ -39,7 +29,7 @@ var import_prettier = require("../adapter/prettier.js");
|
|
|
39
29
|
var import_internal = require("../lint/internal.js");
|
|
40
30
|
const format = async (args = process.argv.slice(2), overrideConfigFile) => {
|
|
41
31
|
const debug = (0, import_args.hasDebugFlag)(args);
|
|
42
|
-
import_logging.log.plain(
|
|
32
|
+
import_logging.log.plain((0, import_node_util.styleText)("blueBright", "skuba lints"));
|
|
43
33
|
const internal = await (0, import_internal.internalLint)("format", {
|
|
44
34
|
debug,
|
|
45
35
|
additionalFlags: args.includes("--force-apply-all-patches") ? ["--force-apply-all-patches"] : [],
|
|
@@ -47,10 +37,10 @@ const format = async (args = process.argv.slice(2), overrideConfigFile) => {
|
|
|
47
37
|
});
|
|
48
38
|
const logger = (0, import_logging.createLogger)({ debug });
|
|
49
39
|
import_logging.log.newline();
|
|
50
|
-
import_logging.log.plain(
|
|
40
|
+
import_logging.log.plain((0, import_node_util.styleText)("magenta", "ESLint"));
|
|
51
41
|
const eslint = await (0, import_eslint.runESLint)("format", logger, overrideConfigFile);
|
|
52
42
|
import_logging.log.newline();
|
|
53
|
-
import_logging.log.plain(
|
|
43
|
+
import_logging.log.plain((0, import_node_util.styleText)("cyan", "Prettier"));
|
|
54
44
|
const prettier = await (0, import_prettier.runPrettier)("format", logger);
|
|
55
45
|
if (eslint.ok && prettier.ok && internal.ok) {
|
|
56
46
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/format/index.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { styleText } from 'node:util';\n\nimport { hasDebugFlag } from '../../utils/args.js';\nimport { createLogger, log } from '../../utils/logging.js';\nimport { runESLint } from '../adapter/eslint.js';\nimport { runPrettier } from '../adapter/prettier.js';\nimport { internalLint } from '../lint/internal.js';\n\nexport const format = async (\n args = process.argv.slice(2),\n overrideConfigFile?: string,\n): Promise<void> => {\n const debug = hasDebugFlag(args);\n\n log.plain(styleText('blueBright', 'skuba lints'));\n\n const internal = await internalLint('format', {\n debug,\n additionalFlags: args.includes('--force-apply-all-patches')\n ? ['--force-apply-all-patches']\n : [],\n serial: true,\n });\n\n const logger = createLogger({ debug });\n\n log.newline();\n log.plain(styleText('magenta', 'ESLint'));\n\n const eslint = await runESLint('format', logger, overrideConfigFile);\n\n log.newline();\n log.plain(styleText('cyan', 'Prettier'));\n\n const prettier = await runPrettier('format', logger);\n\n if (eslint.ok && prettier.ok && internal.ok) {\n return;\n }\n\n const tools = [\n ...(eslint.ok ? [] : ['ESLint']),\n ...(prettier.ok ? [] : ['Prettier']),\n ...(internal.ok ? [] : ['skuba']),\n ];\n\n log.newline();\n log.err(tools.join(', '), 'found issues that require triage.');\n\n process.exitCode = 1;\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romPrompt: () => Promise<InitConfig>;
|
|
11
11
|
export declare const readJSONFromStdIn: () => Promise<unknown>;
|
|
12
12
|
export declare const getConfig: () => Promise<{
|
|
13
|
-
templateName: string;
|
|
14
13
|
destinationDir: string;
|
|
15
14
|
templateComplete: boolean;
|
|
15
|
+
templateName: string;
|
|
16
16
|
templateData: {
|
|
17
17
|
[x: string]: string;
|
|
18
18
|
ownerName: string;
|
|
@@ -35,9 +35,9 @@ __export(getConfig_exports, {
|
|
|
35
35
|
runForm: () => runForm
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(getConfig_exports);
|
|
38
|
+
var import_node_util = require("node:util");
|
|
38
39
|
var import_path = __toESM(require("path"));
|
|
39
|
-
var
|
|
40
|
-
var import_enquirer = require("enquirer");
|
|
40
|
+
var import_prompts = require("@inquirer/prompts");
|
|
41
41
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
42
42
|
var import_copy = require("../../utils/copy.js");
|
|
43
43
|
var import_error = require("../../utils/error.js");
|
|
@@ -46,31 +46,26 @@ var import_packageManager = require("../../utils/packageManager.js");
|
|
|
46
46
|
var import_port = require("../../utils/port.js");
|
|
47
47
|
var import_template = require("../../utils/template.js");
|
|
48
48
|
var import_git = require("./git.js");
|
|
49
|
-
var
|
|
49
|
+
var import_prompts2 = require("./prompts.js");
|
|
50
50
|
var import_types = require("./types.js");
|
|
51
|
-
const runForm = (props) => {
|
|
52
|
-
const { message
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const runForm = async (props) => {
|
|
52
|
+
const { message } = props;
|
|
53
|
+
import_logging.log.plain(message);
|
|
54
|
+
const result = {};
|
|
55
|
+
for (const choice of props.choices) {
|
|
56
|
+
const inputValue = await (0, import_prompts.input)({
|
|
57
|
+
message: choice.message,
|
|
58
|
+
default: choice.initial,
|
|
59
|
+
validate: async (inputText) => {
|
|
60
|
+
if (!inputText || inputText === "" || inputText === choice.initial && !choice.allowInitial) {
|
|
61
|
+
return "Form is not complete";
|
|
62
|
+
}
|
|
63
|
+
return choice.validate?.(inputText) ?? true;
|
|
58
64
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
choices,
|
|
64
|
-
message,
|
|
65
|
-
name,
|
|
66
|
-
validate: async (values) => {
|
|
67
|
-
const results = await Promise.all(
|
|
68
|
-
choices.map(async (choice) => choice.validate(values[choice.name]))
|
|
69
|
-
);
|
|
70
|
-
return results.find((result) => typeof result === "string") ?? results.every((result) => result === true);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return form.run();
|
|
65
|
+
});
|
|
66
|
+
result[choice.name] = inputValue;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
74
69
|
};
|
|
75
70
|
const confirmShouldContinue = async (choices) => {
|
|
76
71
|
const fieldsList = choices.map((choice) => choice.message);
|
|
@@ -79,7 +74,7 @@ const confirmShouldContinue = async (choices) => {
|
|
|
79
74
|
import_logging.log.newline();
|
|
80
75
|
fieldsList.forEach((message) => import_logging.log.subtle(`- ${message}`));
|
|
81
76
|
import_logging.log.newline();
|
|
82
|
-
const result = await
|
|
77
|
+
const result = await (0, import_prompts2.shouldContinue)();
|
|
83
78
|
return result === "yes";
|
|
84
79
|
};
|
|
85
80
|
const createDirectory = async (dir) => {
|
|
@@ -118,19 +113,17 @@ const cloneTemplate = async (templateName, destinationDir) => {
|
|
|
118
113
|
import_logging.log.warn(
|
|
119
114
|
"You may need to run",
|
|
120
115
|
import_logging.log.bold(
|
|
121
|
-
(0, import_packageManager.configForPackageManager)(templateConfig.packageManager).print.exec
|
|
122
|
-
"skuba",
|
|
123
|
-
"configure"
|
|
116
|
+
`${(0, import_packageManager.configForPackageManager)(templateConfig.packageManager).print.exec} skuba configure`
|
|
124
117
|
),
|
|
125
118
|
"once this is done."
|
|
126
119
|
);
|
|
127
120
|
}
|
|
128
121
|
return templateConfig;
|
|
129
122
|
};
|
|
130
|
-
const
|
|
131
|
-
const templateSelection = await
|
|
123
|
+
const selectTemplateName = async () => {
|
|
124
|
+
const templateSelection = await (0, import_prompts2.getTemplateName)();
|
|
132
125
|
if (templateSelection === "github \u2192") {
|
|
133
|
-
const gitHubPath = await
|
|
126
|
+
const gitHubPath = await (0, import_prompts2.getGitPath)();
|
|
134
127
|
return `github:${gitHubPath}`;
|
|
135
128
|
}
|
|
136
129
|
return templateSelection;
|
|
@@ -180,8 +173,8 @@ const baseToTemplateData = async ({
|
|
|
180
173
|
};
|
|
181
174
|
};
|
|
182
175
|
const configureFromPrompt = async () => {
|
|
183
|
-
const { ownerName, platformName, repoName, defaultBranch } = await runForm(
|
|
184
|
-
import_logging.log.plain(
|
|
176
|
+
const { ownerName, platformName, repoName, defaultBranch } = await runForm(import_prompts2.BASE_PROMPT_PROPS);
|
|
177
|
+
import_logging.log.plain((0, import_node_util.styleText)("cyan", repoName), "by", (0, import_node_util.styleText)("cyan", ownerName));
|
|
185
178
|
const templateData = await baseToTemplateData({
|
|
186
179
|
ownerName,
|
|
187
180
|
platformName,
|
|
@@ -191,7 +184,7 @@ const configureFromPrompt = async () => {
|
|
|
191
184
|
const destinationDir = repoName;
|
|
192
185
|
await createDirectory(destinationDir);
|
|
193
186
|
import_logging.log.newline();
|
|
194
|
-
const templateName = await
|
|
187
|
+
const templateName = await selectTemplateName();
|
|
195
188
|
const { entryPoint, fields, noSkip, packageManager, type } = await cloneTemplate(templateName, destinationDir);
|
|
196
189
|
if (fields.length === 0) {
|
|
197
190
|
return {
|
|
@@ -204,12 +197,15 @@ const configureFromPrompt = async () => {
|
|
|
204
197
|
type
|
|
205
198
|
};
|
|
206
199
|
}
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
200
|
+
const shouldContinueWithTemplate = noSkip ? true : await confirmShouldContinue(fields);
|
|
201
|
+
if (shouldContinueWithTemplate) {
|
|
209
202
|
import_logging.log.newline();
|
|
210
203
|
const customAnswers2 = await runForm({
|
|
211
204
|
choices: fields,
|
|
212
|
-
message:
|
|
205
|
+
message: (0, import_node_util.styleText)(
|
|
206
|
+
"bold",
|
|
207
|
+
`Complete ${(0, import_node_util.styleText)("cyan", templateName)}:`
|
|
208
|
+
),
|
|
213
209
|
name: "customAnswers"
|
|
214
210
|
});
|
|
215
211
|
return {
|
|
@@ -224,10 +220,7 @@ const configureFromPrompt = async () => {
|
|
|
224
220
|
}
|
|
225
221
|
import_logging.log.newline();
|
|
226
222
|
import_logging.log.warn(
|
|
227
|
-
`Resume this later with ${
|
|
228
|
-
(0, import_packageManager.configForPackageManager)(packageManager).print.exec,
|
|
229
|
-
"skuba configure"
|
|
230
|
-
)}.`
|
|
223
|
+
`Resume this later with ${(0, import_node_util.styleText)("bold", `${(0, import_packageManager.configForPackageManager)(packageManager).print.exec} skuba configure`)}.`
|
|
231
224
|
);
|
|
232
225
|
const customAnswers = generatePlaceholders(fields);
|
|
233
226
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/getConfig.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { styleText } from 'node:util';\nimport path from 'path';\n\nimport { input } from '@inquirer/prompts';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy.js';\nimport { isErrorWithCode } from '../../utils/error.js';\nimport { log } from '../../utils/logging.js';\nimport {\n DEFAULT_PACKAGE_MANAGER,\n configForPackageManager,\n} from '../../utils/packageManager.js';\nimport { getRandomPort } from '../../utils/port.js';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n type TemplateConfig,\n templateConfigSchema,\n} from '../../utils/template.js';\n\nimport { downloadGitHubTemplate } from './git.js';\nimport {\n BASE_PROMPT_PROPS,\n type BaseFields,\n type Choice,\n getGitPath,\n getTemplateName,\n shouldContinue,\n} from './prompts.js';\nimport { type InitConfig, initConfigInputSchema } from './types.js';\n\nexport const runForm = async <T = Record<string, string>>(props: {\n choices: readonly Choice[];\n message: string;\n name: string;\n}): Promise<T> => {\n const { message } = props;\n log.plain(message);\n\n const result: Record<string, string> = {};\n\n for (const choice of props.choices) {\n const inputValue = await input({\n message: choice.message,\n default: choice.initial,\n validate: async (inputText: string) => {\n if (\n !inputText ||\n inputText === '' ||\n (inputText === choice.initial && !choice.allowInitial)\n ) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(inputText) ?? true;\n },\n });\n\n result[choice.name] = inputValue;\n }\n\n return result as T;\n};\n\nconst confirmShouldContinue = async (choices: readonly Choice[]) => {\n const fieldsList = choices.map((choice) => choice.message);\n\n log.newline();\n log.plain('This template uses the following information:');\n log.newline();\n fieldsList.forEach((message) => log.subtle(`- ${message}`));\n\n log.newline();\n const result = await shouldContinue();\n\n return result === 'yes';\n};\n\nconst createDirectory = async (dir: string) => {\n try {\n await fs.promises.mkdir(dir);\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n log.err(`The directory '${dir}' already exists.`);\n process.exit(1);\n }\n\n throw err;\n }\n};\n\nconst cloneTemplate = async (\n templateName: string,\n destinationDir: string,\n): Promise<TemplateConfig> => {\n const isCustomTemplate = templateName.startsWith('github:');\n\n if (isCustomTemplate) {\n const gitHubPath = templateName.slice('github:'.length);\n\n await downloadGitHubTemplate(gitHubPath, destinationDir);\n } else {\n const templateDir = path.join(TEMPLATE_DIR, templateName);\n\n await copyFiles({\n // assume built-in templates have no extraneous files\n include: () => true,\n sourceRoot: templateDir,\n destinationRoot: destinationDir,\n processors: [],\n // built-in templates have files like _package.json\n stripUnderscorePrefix: true,\n });\n }\n\n const templateConfig = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (isCustomTemplate) {\n log.newline();\n log.warn(\n 'You may need to run',\n log.bold(\n `${configForPackageManager(templateConfig.packageManager).print.exec} skuba configure`,\n ),\n 'once this is done.',\n );\n }\n\n return templateConfig;\n};\n\nconst selectTemplateName = async () => {\n const templateSelection = await getTemplateName();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await getGitPath();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: Choice[]) =>\n Object.fromEntries(\n choices.map(({ name }) => [name, `<%- ${name} %>`] as const),\n );\n\nexport const getTemplateConfig = (dir: string): TemplateConfig => {\n const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const templateConfig = require(templateConfigPath) as unknown;\n\n return templateConfigSchema.parse(templateConfig);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n packageManager: DEFAULT_PACKAGE_MANAGER,\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n}: BaseFields) => {\n const [orgName, teamName] = ownerName.split('/');\n\n const port = String(await getRandomPort());\n\n if (!orgName) {\n throw new Error(`Invalid format for owner name: ${ownerName}`);\n }\n\n return {\n orgName,\n ownerName,\n repoName,\n defaultBranch,\n // Use standalone username in `teamName` contexts\n teamName: teamName ?? orgName,\n\n port,\n\n platformName,\n lambdaCdkArchitecture: platformName === 'amd64' ? 'X86_64' : 'ARM_64',\n lambdaServerlessArchitecture:\n platformName === 'amd64' ? 'x86_64' : platformName,\n };\n};\n\nexport const configureFromPrompt = async (): Promise<InitConfig> => {\n const { ownerName, platformName, repoName, defaultBranch } =\n await runForm<BaseFields>(BASE_PROMPT_PROPS);\n log.plain(styleText('cyan', repoName), 'by', styleText('cyan', ownerName));\n\n const templateData = await baseToTemplateData({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n });\n\n const destinationDir = repoName;\n\n await createDirectory(destinationDir);\n\n log.newline();\n const templateName = await selectTemplateName();\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (fields.length === 0) {\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData,\n templateName,\n type,\n };\n }\n\n const shouldContinueWithTemplate = noSkip\n ? true\n : await confirmShouldContinue(fields);\n\n if (shouldContinueWithTemplate) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: styleText(\n 'bold',\n `Complete ${styleText('cyan', templateName)}:`,\n ),\n name: 'customAnswers',\n });\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n }\n\n log.newline();\n log.warn(\n `Resume this later with ${styleText('bold', `${configForPackageManager(packageManager).print.exec} skuba configure`)}.`,\n );\n\n const customAnswers = generatePlaceholders(fields);\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: false,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n};\n\nexport const readJSONFromStdIn = async () => {\n let text = '';\n\n await new Promise((resolve) =>\n process.stdin\n .on('data', (chunk) => (text += chunk.toString()))\n .once('end', resolve),\n );\n\n text = text.trim();\n\n if (text === '') {\n log.err('No data from stdin.');\n process.exit(1);\n }\n\n let value: unknown;\n\n try {\n value = JSON.parse(text) as unknown;\n } catch {\n log.err('Invalid JSON from stdin.');\n process.exit(1);\n }\n\n return value;\n};\n\nconst configureFromPipe = async (): Promise<InitConfig> => {\n const value = await readJSONFromStdIn();\n\n const result = initConfigInputSchema.safeParse(value);\n\n if (!result.success) {\n log.err('Invalid data from stdin:');\n log.err(result.error);\n process.exit(1);\n }\n\n const { destinationDir, templateComplete, templateName } = result.data;\n\n const templateData = {\n ...(await baseToTemplateData(result.data.templateData)),\n ...result.data.templateData,\n };\n\n await createDirectory(destinationDir);\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (!templateComplete) {\n if (noSkip) {\n log.err('Templating for', log.bold(templateName), 'cannot be skipped.');\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData: {\n ...templateData,\n ...generatePlaceholders(fields),\n },\n type,\n };\n }\n\n const required = fields.map(({ name }) => name);\n\n const provided = new Set(Object.keys(templateData));\n\n const missing = required.filter((name) => !provided.has(name));\n\n if (missing.length > 0) {\n log.err('This template uses the following information:');\n log.newline();\n missing.forEach((name) => log.err(`- ${name}`));\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData,\n type,\n };\n};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0B;AAC1B,kBAAiB;AAEjB,qBAAsB;AACtB,sBAAe;AAEf,kBAA0B;AAC1B,mBAAgC;AAChC,qBAAoB;AACpB,4BAGO;AACP,kBAA8B;AAC9B,sBAKO;AAEP,iBAAuC;AACvC,IAAAA,kBAOO;AACP,mBAAuD;AAEhD,MAAM,UAAU,OAAmC,UAIxC;AAChB,QAAM,EAAE,QAAQ,IAAI;AACpB,qBAAI,MAAM,OAAO;AAEjB,QAAM,SAAiC,CAAC;AAExC,aAAW,UAAU,MAAM,SAAS;AAClC,UAAM,aAAa,UAAM,sBAAM;AAAA,MAC7B,SAAS,OAAO;AAAA,MAChB,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO,cAAsB;AACrC,YACE,CAAC,aACD,cAAc,MACb,cAAc,OAAO,WAAW,CAAC,OAAO,cACzC;AACA,iBAAO;AAAA,QACT;AAEA,eAAO,OAAO,WAAW,SAAS,KAAK;AAAA,MACzC;AAAA,IACF,CAAC;AAED,WAAO,OAAO,IAAI,IAAI;AAA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GAAG,OAAO;AAAA,MACV;AAAA,MACA;AAAA,MACA,cAAc;AAAA,QACZ,GAAG;AAAA,QACH,GAAG,qBAAqB,MAAM;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,OAAO,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AAE9C,QAAM,WAAW,IAAI,IAAI,OAAO,KAAK,YAAY,CAAC;AAElD,QAAM,UAAU,SAAS,OAAO,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC;AAE7D,MAAI,QAAQ,SAAS,GAAG;AACtB,uBAAI,IAAI,+CAA+C;AACvD,uBAAI,QAAQ;AACZ,YAAQ,QAAQ,CAAC,SAAS,mBAAI,IAAI,KAAK,IAAI,EAAE,CAAC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,GAAG,OAAO;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,MACvB,QAAQ,MAAM,QAAQ,oBAAoB,IAAI,kBAAkB;",
|
|
6
|
+
"names": ["import_prompts", "fs", "path", "customAnswers"]
|
|
7
7
|
}
|
package/lib/cli/init/git.js
CHANGED
|
@@ -35,7 +35,7 @@ module.exports = __toCommonJS(git_exports);
|
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
36
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
37
|
var import_isomorphic_git = __toESM(require("isomorphic-git"));
|
|
38
|
-
var import_simple_git =
|
|
38
|
+
var import_simple_git = require("simple-git");
|
|
39
39
|
var import_logging = require("../../utils/logging.js");
|
|
40
40
|
var Git = __toESM(require("@skuba-lib/api/git"));
|
|
41
41
|
const initialiseRepo = async (dir, { orgName, repoName, defaultBranch }) => {
|
|
@@ -58,7 +58,7 @@ const initialiseRepo = async (dir, { orgName, repoName, defaultBranch }) => {
|
|
|
58
58
|
const downloadGitHubTemplate = async (gitHubPath, destinationDir) => {
|
|
59
59
|
import_logging.log.newline();
|
|
60
60
|
import_logging.log.plain("Downloading", import_logging.log.bold(gitHubPath), "from GitHub...");
|
|
61
|
-
await (0, import_simple_git.
|
|
61
|
+
await (0, import_simple_git.simpleGit)().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [
|
|
62
62
|
"--depth=1",
|
|
63
63
|
"--quiet"
|
|
64
64
|
]);
|
package/lib/cli/init/git.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/git.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport simpleGit from 'simple-git';\n\nimport { log } from '../../utils/logging.js';\n\nimport * as Git from '@skuba-lib/api/git';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n defaultBranch: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName, defaultBranch }: GitHubProject,\n) => {\n await git.init({\n defaultBranch,\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAChB,
|
|
6
|
-
"names": ["git", "fs", "
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport { simpleGit } from 'simple-git';\n\nimport { log } from '../../utils/logging.js';\n\nimport * as Git from '@skuba-lib/api/git';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n defaultBranch: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName, defaultBranch }: GitHubProject,\n) => {\n await git.init({\n defaultBranch,\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAChB,wBAA0B;AAE1B,qBAAoB;AAEpB,UAAqB;AAQd,MAAM,iBAAiB,OAC5B,KACA,EAAE,SAAS,UAAU,cAAc,MAChC;AACH,QAAM,sBAAAA,QAAI,KAAK;AAAA,IACb;AAAA,IACA;AAAA,IACA,oBAAAC;AAAA,EACF,CAAC;AAED,QAAM,IAAI,OAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,sBAAAD,QAAI,UAAU;AAAA,IAClB;AAAA,IACA,oBAAAC;AAAA,IACA,QAAQ;AAAA,IACR,KAAK,kBAAkB,OAAO,IAAI,QAAQ;AAAA,EAC5C,CAAC;AACH;AAEO,MAAM,yBAAyB,OACpC,YACA,mBACG;AACH,qBAAI,QAAQ;AACZ,qBAAI,MAAM,eAAe,mBAAI,KAAK,UAAU,GAAG,gBAAgB;AAE/D,YAAM,6BAAU,EAAE,MAAM,kBAAkB,UAAU,QAAQ,gBAAgB;AAAA,IAC1E;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,gBAAAA,QAAG,SAAS,GAAG,YAAAC,QAAK,KAAK,gBAAgB,MAAM,GAAG;AAAA,IACtD,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AACH;",
|
|
6
|
+
"names": ["git", "fs", "path"]
|
|
7
7
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { type FormChoice, Input, Select } from 'enquirer';
|
|
2
1
|
import { type Platform } from './validation.js';
|
|
3
|
-
export
|
|
2
|
+
export interface Choice {
|
|
3
|
+
name: string;
|
|
4
|
+
message: string;
|
|
5
|
+
initial?: string;
|
|
6
|
+
validate?: (value: string) => boolean | string | Promise<boolean | string>;
|
|
4
7
|
/**
|
|
5
8
|
* Whether the user is allowed to skip field entry and use the initial value.
|
|
6
9
|
*
|
|
7
10
|
* Defaults to `false`.
|
|
8
11
|
*/
|
|
9
12
|
allowInitial?: boolean;
|
|
10
|
-
}
|
|
13
|
+
}
|
|
11
14
|
export type BaseFields = Record<(typeof BASE_CHOICES)[number]['name'], string> & {
|
|
12
15
|
platformName: Platform;
|
|
13
16
|
};
|
|
@@ -15,7 +18,7 @@ declare const BASE_CHOICES: readonly [{
|
|
|
15
18
|
readonly name: "ownerName";
|
|
16
19
|
readonly message: "Owner";
|
|
17
20
|
readonly initial: "SEEK-Jobs/my-team";
|
|
18
|
-
readonly validate: (value: unknown) => true | "
|
|
21
|
+
readonly validate: (value: unknown) => true | "Required" | "Must contain a valid GitHub org name" | "Must contain a valid GitHub team name";
|
|
19
22
|
}, {
|
|
20
23
|
readonly name: "repoName";
|
|
21
24
|
readonly message: "Repo";
|
|
@@ -32,14 +35,14 @@ declare const BASE_CHOICES: readonly [{
|
|
|
32
35
|
readonly message: "Default Branch";
|
|
33
36
|
readonly initial: "main";
|
|
34
37
|
readonly allowInitial: true;
|
|
35
|
-
readonly validate: (value: unknown) => true | "
|
|
38
|
+
readonly validate: (value: unknown) => true | "Required";
|
|
36
39
|
}];
|
|
37
40
|
export declare const BASE_PROMPT_PROPS: {
|
|
38
41
|
choices: readonly [{
|
|
39
42
|
readonly name: "ownerName";
|
|
40
43
|
readonly message: "Owner";
|
|
41
44
|
readonly initial: "SEEK-Jobs/my-team";
|
|
42
|
-
readonly validate: (value: unknown) => true | "
|
|
45
|
+
readonly validate: (value: unknown) => true | "Required" | "Must contain a valid GitHub org name" | "Must contain a valid GitHub team name";
|
|
43
46
|
}, {
|
|
44
47
|
readonly name: "repoName";
|
|
45
48
|
readonly message: "Repo";
|
|
@@ -56,12 +59,12 @@ export declare const BASE_PROMPT_PROPS: {
|
|
|
56
59
|
readonly message: "Default Branch";
|
|
57
60
|
readonly initial: "main";
|
|
58
61
|
readonly allowInitial: true;
|
|
59
|
-
readonly validate: (value: unknown) => true | "
|
|
62
|
+
readonly validate: (value: unknown) => true | "Required";
|
|
60
63
|
}];
|
|
61
64
|
message: string;
|
|
62
65
|
name: string;
|
|
63
66
|
};
|
|
64
|
-
export declare const
|
|
65
|
-
export declare const
|
|
66
|
-
export declare const
|
|
67
|
+
export declare const shouldContinue: () => Promise<string>;
|
|
68
|
+
export declare const getGitPath: () => Promise<string>;
|
|
69
|
+
export declare const getTemplateName: () => Promise<"express-rest-api" | "greeter" | "koa-rest-api" | "lambda-sqs-worker-cdk" | "oss-npm-package" | "private-npm-package" | "github →">;
|
|
67
70
|
export {};
|
package/lib/cli/init/prompts.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,25 +15,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var prompts_exports = {};
|
|
30
20
|
__export(prompts_exports, {
|
|
31
21
|
BASE_PROMPT_PROPS: () => BASE_PROMPT_PROPS,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
getGitPath: () => getGitPath,
|
|
23
|
+
getTemplateName: () => getTemplateName,
|
|
24
|
+
shouldContinue: () => shouldContinue
|
|
35
25
|
});
|
|
36
26
|
module.exports = __toCommonJS(prompts_exports);
|
|
37
|
-
var
|
|
38
|
-
var
|
|
27
|
+
var import_prompts = require("@inquirer/prompts");
|
|
28
|
+
var import_fs = require("../../utils/fs.js");
|
|
39
29
|
var import_template = require("../../utils/template.js");
|
|
40
30
|
var import_validation = require("./validation.js");
|
|
41
31
|
const BASE_CHOICES = [
|
|
@@ -45,13 +35,13 @@ const BASE_CHOICES = [
|
|
|
45
35
|
initial: "SEEK-Jobs/my-team",
|
|
46
36
|
validate: (value) => {
|
|
47
37
|
if (typeof value !== "string") {
|
|
48
|
-
return "
|
|
38
|
+
return "Required";
|
|
49
39
|
}
|
|
50
40
|
const [org, team] = value.split("/");
|
|
51
41
|
if (!org || !(0, import_validation.isGitHubOrg)(org)) {
|
|
52
|
-
return "
|
|
42
|
+
return "Must contain a valid GitHub org name";
|
|
53
43
|
}
|
|
54
|
-
return team === void 0 || (0, import_validation.isGitHubTeam)(team) || "
|
|
44
|
+
return team === void 0 || (0, import_validation.isGitHubTeam)(team) || "Must contain a valid GitHub team name";
|
|
55
45
|
}
|
|
56
46
|
},
|
|
57
47
|
{
|
|
@@ -60,12 +50,12 @@ const BASE_CHOICES = [
|
|
|
60
50
|
initial: "my-repo",
|
|
61
51
|
validate: async (value) => {
|
|
62
52
|
if (typeof value !== "string") {
|
|
63
|
-
return "
|
|
53
|
+
return "Required";
|
|
64
54
|
}
|
|
65
55
|
if (!(0, import_validation.isGitHubRepo)(value)) {
|
|
66
|
-
return "
|
|
56
|
+
return "Must be a valid GitHub repo name";
|
|
67
57
|
}
|
|
68
|
-
const exists = await
|
|
58
|
+
const exists = await (0, import_fs.pathExists)(value);
|
|
69
59
|
return !exists || `'${value}' is an existing directory`;
|
|
70
60
|
}
|
|
71
61
|
},
|
|
@@ -74,14 +64,14 @@ const BASE_CHOICES = [
|
|
|
74
64
|
message: "Platform",
|
|
75
65
|
initial: "arm64",
|
|
76
66
|
allowInitial: true,
|
|
77
|
-
validate: (value) => (0, import_validation.isPlatform)(value) || `
|
|
67
|
+
validate: (value) => (0, import_validation.isPlatform)(value) || `Must be ${import_validation.PLATFORM_OPTIONS}`
|
|
78
68
|
},
|
|
79
69
|
{
|
|
80
70
|
name: "defaultBranch",
|
|
81
71
|
message: "Default Branch",
|
|
82
72
|
initial: "main",
|
|
83
73
|
allowInitial: true,
|
|
84
|
-
validate: (value) => typeof value === "string" && value.length > 0 ? true : "
|
|
74
|
+
validate: (value) => typeof value === "string" && value.length > 0 ? true : "Required"
|
|
85
75
|
}
|
|
86
76
|
];
|
|
87
77
|
const BASE_PROMPT_PROPS = {
|
|
@@ -89,27 +79,27 @@ const BASE_PROMPT_PROPS = {
|
|
|
89
79
|
message: "For starters, some project details:",
|
|
90
80
|
name: "baseAnswers"
|
|
91
81
|
};
|
|
92
|
-
const
|
|
93
|
-
choices: ["yes", "no"],
|
|
82
|
+
const shouldContinue = async () => (0, import_prompts.select)({
|
|
94
83
|
message: "Fill this in now?",
|
|
95
|
-
|
|
84
|
+
choices: [
|
|
85
|
+
{ name: "Yes", value: "yes" },
|
|
86
|
+
{ name: "No", value: "no" }
|
|
87
|
+
]
|
|
96
88
|
});
|
|
97
|
-
const
|
|
89
|
+
const getGitPath = async () => (0, import_prompts.input)({
|
|
98
90
|
message: "Git path",
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
validate: (value) => /[^/]+\/[^/]+/.test(value) || "Path is not valid"
|
|
91
|
+
default: "seek-oss/skuba",
|
|
92
|
+
validate: (value) => /[^/]+\/[^/]+/.test(value) || "Must be a valid path"
|
|
102
93
|
});
|
|
103
|
-
const
|
|
104
|
-
choices: import_template.TEMPLATE_NAMES_WITH_BYO,
|
|
94
|
+
const getTemplateName = async () => (0, import_prompts.select)({
|
|
105
95
|
message: "Select a template:",
|
|
106
|
-
name:
|
|
96
|
+
choices: import_template.TEMPLATE_NAMES_WITH_BYO.map((name) => ({ name, value: name }))
|
|
107
97
|
});
|
|
108
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
99
|
0 && (module.exports = {
|
|
110
100
|
BASE_PROMPT_PROPS,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
getGitPath,
|
|
102
|
+
getTemplateName,
|
|
103
|
+
shouldContinue
|
|
114
104
|
});
|
|
115
105
|
//# sourceMappingURL=prompts.js.map
|