skuba 5.0.1 → 5.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/api/buildkite/annotate.d.ts +1 -1
- package/lib/api/git/getChangedFiles.d.ts +1 -1
- package/lib/api/github/checkRun.d.ts +2 -2
- package/lib/api/jest/index.d.ts +2 -2
- package/lib/cli/adapter/prettier.js +15 -1
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/configure/processing/prettier.d.ts +1 -1
- package/lib/cli/configure/processing/typescript.d.ts +2 -2
- package/lib/cli/configure/types.d.ts +6 -6
- package/lib/cli/init/getConfig.js +18 -5
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/init/prompts.d.ts +14 -1
- package/lib/cli/init/prompts.js +7 -1
- package/lib/cli/init/prompts.js.map +2 -2
- package/lib/cli/init/types.d.ts +3 -2
- package/lib/cli/init/types.js +2 -1
- package/lib/cli/init/types.js.map +2 -2
- package/lib/cli/init/validation.d.ts +5 -0
- package/lib/cli/init/validation.js +10 -2
- package/lib/cli/init/validation.js.map +2 -2
- package/lib/skuba.js.map +1 -1
- package/lib/utils/command.d.ts +1 -1
- package/lib/utils/copy.d.ts +1 -1
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/exec.d.ts +2 -2
- package/lib/utils/logging.d.ts +1 -1
- package/lib/utils/manifest.d.ts +1 -1
- package/lib/utils/template.d.ts +2 -2
- package/lib/utils/version.d.ts +1 -1
- package/lib/utils/wait.d.ts +1 -1
- package/lib/wrapper/main.js.map +1 -1
- package/package.json +14 -14
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/.gantry/common.yml +1 -1
- package/template/express-rest-api/.gantry/dev.yml +1 -0
- package/template/express-rest-api/.gantry/prod.yml +1 -0
- package/template/express-rest-api/Dockerfile +1 -1
- package/template/express-rest-api/Dockerfile.dev-deps +1 -1
- package/template/express-rest-api/README.md +7 -10
- package/template/express-rest-api/gantry.apply.yml +2 -2
- package/template/express-rest-api/gantry.build.yml +1 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/Dockerfile +1 -1
- package/template/greeter/README.md +6 -9
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/.gantry/common.yml +1 -1
- package/template/koa-rest-api/.gantry/dev.yml +1 -0
- package/template/koa-rest-api/.gantry/prod.yml +1 -0
- package/template/koa-rest-api/Dockerfile +1 -1
- package/template/koa-rest-api/Dockerfile.dev-deps +1 -1
- package/template/koa-rest-api/README.md +7 -10
- package/template/koa-rest-api/gantry.apply.yml +2 -2
- package/template/koa-rest-api/gantry.build.yml +1 -1
- package/template/koa-rest-api/package.json +2 -2
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +4 -4
- package/template/lambda-sqs-worker/.nvmrc +1 -1
- package/template/lambda-sqs-worker/Dockerfile +1 -1
- package/template/lambda-sqs-worker/README.md +7 -10
- package/template/lambda-sqs-worker/package.json +10 -5
- package/template/lambda-sqs-worker/serverless.yml +2 -4
- package/template/lambda-sqs-worker/src/app.test.ts +5 -6
- package/template/lambda-sqs-worker/src/framework/handler.test.ts +2 -2
- package/template/lambda-sqs-worker/src/hooks.ts +22 -30
- package/template/lambda-sqs-worker/src/services/aws.ts +2 -2
- package/template/lambda-sqs-worker/src/services/pipelineEventSender.test.ts +9 -7
- package/template/lambda-sqs-worker/src/services/pipelineEventSender.ts +6 -4
- package/template/lambda-sqs-worker/src/testing/services.ts +11 -7
- package/template/lambda-sqs-worker/tsconfig.json +2 -2
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +4 -4
- package/template/lambda-sqs-worker-cdk/.nvmrc +1 -1
- package/template/lambda-sqs-worker-cdk/Dockerfile +1 -1
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +2 -4
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +4 -4
- package/template/lambda-sqs-worker-cdk/package.json +4 -4
- package/template/lambda-sqs-worker-cdk/tsconfig.json +2 -2
- package/template/oss-npm-package/_package.json +1 -1
- package/template/private-npm-package/_package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Endpoints } from '@octokit/types';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
type Output = NonNullable<Endpoints['POST /repos/{owner}/{repo}/check-runs']['parameters']['output']>;
|
|
3
|
+
export type Annotation = NonNullable<Output['annotations']>[number];
|
|
4
4
|
/**
|
|
5
5
|
* {@link https://docs.github.com/en/rest/reference/checks#create-a-check-run}
|
|
6
6
|
*/
|
package/lib/api/jest/index.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ import type { Config } from '@jest/types';
|
|
|
5
5
|
* While we technically accept anything compatible with `Config.InitialOptions`,
|
|
6
6
|
* these are tacitly endorsed for our use cases and receive IntelliSense.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
type DefaultOptions = 'collectCoverage' | 'collectCoverageFrom' | 'coveragePathIgnorePatterns' | 'coverageThreshold' | 'displayName' | 'globals' | 'globalSetup' | 'globalTeardown' | 'projects' | 'setupFiles' | 'setupFilesAfterEnv' | 'snapshotSerializers' | 'testEnvironment' | 'testPathIgnorePatterns' | 'testTimeout' | 'watchPathIgnorePatterns';
|
|
9
9
|
/**
|
|
10
10
|
* Merge additional Jest options into the **skuba** preset.
|
|
11
11
|
*
|
|
12
12
|
* This concatenates array options like `testPathIgnorePatterns`.
|
|
13
13
|
*/
|
|
14
|
-
export declare const mergePreset: <AdditionalOptions extends "filter" | "json" | "silent" | "cache" | "runtime" | "runner" | "projects" | "id" | "automock" | "cacheDirectory" | "clearMocks" | "coveragePathIgnorePatterns" | "dependencyExtractor" | "detectLeaks" | "detectOpenHandles" | "displayName" | "errorOnDeprecated" | "extensionsToTreatAsEsm" | "fakeTimers" | "forceCoverageMatch" | "globalSetup" | "globalTeardown" | "globals" | "haste" | "injectGlobals" | "moduleDirectories" | "moduleFileExtensions" | "moduleNameMapper" | "modulePathIgnorePatterns" | "modulePaths" | "prettierPath" | "resetMocks" | "resetModules" | "resolver" | "restoreMocks" | "rootDir" | "roots" | "sandboxInjectedGlobals" | "setupFiles" | "setupFilesAfterEnv" | "skipFilter" | "skipNodeResolution" | "slowTestThreshold" | "snapshotResolver" | "snapshotSerializers" | "snapshotFormat" | "testEnvironment" | "testEnvironmentOptions" | "testMatch" | "testLocationInResults" | "testPathIgnorePatterns" | "testRegex" | "testRunner" | "transform" | "transformIgnorePatterns" | "watchPathIgnorePatterns" | "unmockedModulePathPatterns" | "workerIdleMemoryLimit" | "bail" | "ci" | "changedFilesWithAncestor" | "changedSince" | "collectCoverage" | "collectCoverageFrom" | "coverageDirectory" | "coverageProvider" | "coverageReporters" | "coverageThreshold" | "expand" | "findRelatedTests" | "forceExit" | "reporters" | "logHeapUsage" | "lastCommit" | "listTests" | "maxConcurrency" | "maxWorkers" | "noStackTrace" | "notify" | "notifyMode" | "onlyChanged" | "onlyFailures" | "outputFile" | "passWithNoTests" | "
|
|
14
|
+
export declare const mergePreset: <AdditionalOptions extends "filter" | "json" | "silent" | "cache" | "runtime" | "runner" | "projects" | "id" | "automock" | "cacheDirectory" | "clearMocks" | "coveragePathIgnorePatterns" | "dependencyExtractor" | "detectLeaks" | "detectOpenHandles" | "displayName" | "errorOnDeprecated" | "extensionsToTreatAsEsm" | "fakeTimers" | "forceCoverageMatch" | "globalSetup" | "globalTeardown" | "globals" | "haste" | "injectGlobals" | "moduleDirectories" | "moduleFileExtensions" | "moduleNameMapper" | "modulePathIgnorePatterns" | "modulePaths" | "preset" | "prettierPath" | "resetMocks" | "resetModules" | "resolver" | "restoreMocks" | "rootDir" | "roots" | "sandboxInjectedGlobals" | "setupFiles" | "setupFilesAfterEnv" | "skipFilter" | "skipNodeResolution" | "slowTestThreshold" | "snapshotResolver" | "snapshotSerializers" | "snapshotFormat" | "testEnvironment" | "testEnvironmentOptions" | "testMatch" | "testLocationInResults" | "testPathIgnorePatterns" | "testRegex" | "testRunner" | "transform" | "transformIgnorePatterns" | "watchPathIgnorePatterns" | "unmockedModulePathPatterns" | "workerIdleMemoryLimit" | "bail" | "ci" | "changedFilesWithAncestor" | "changedSince" | "collectCoverage" | "collectCoverageFrom" | "coverageDirectory" | "coverageProvider" | "coverageReporters" | "coverageThreshold" | "expand" | "findRelatedTests" | "forceExit" | "reporters" | "logHeapUsage" | "lastCommit" | "listTests" | "maxConcurrency" | "maxWorkers" | "noStackTrace" | "notify" | "notifyMode" | "onlyChanged" | "onlyFailures" | "outputFile" | "passWithNoTests" | "replname" | "runTestsByPath" | "showSeed" | "testFailureExitCode" | "testNamePattern" | "testResultsProcessor" | "testSequencer" | "testTimeout" | "updateSnapshot" | "useStderr" | "verbose" | "watch" | "watchAll" | "watchman" | "watchPlugins">(options: Pick<Partial<{
|
|
15
15
|
automock: boolean;
|
|
16
16
|
bail: number | boolean;
|
|
17
17
|
cache: boolean;
|
|
@@ -44,11 +44,25 @@ const inferParser = (filepath) => {
|
|
|
44
44
|
);
|
|
45
45
|
return firstLanguage?.parsers[0];
|
|
46
46
|
};
|
|
47
|
+
const isPackageJsonOk = ({
|
|
48
|
+
data,
|
|
49
|
+
filepath
|
|
50
|
+
}) => {
|
|
51
|
+
if (import_path.default.basename(filepath) !== "package.json") {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const packageJson = (0, import_package.parsePackage)(data);
|
|
56
|
+
return !packageJson || (0, import_package.formatPackage)(packageJson) === data;
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
};
|
|
47
61
|
const formatOrLintFile = ({ data, filepath, options }, mode, result) => {
|
|
48
62
|
if (mode === "lint") {
|
|
49
63
|
let ok;
|
|
50
64
|
try {
|
|
51
|
-
ok = (0, import_prettier.check)(data, options);
|
|
65
|
+
ok = (0, import_prettier.check)(data, options) && isPackageJsonOk({ data, filepath });
|
|
52
66
|
} catch (err) {
|
|
53
67
|
result.errored.push({ err, filepath });
|
|
54
68
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/adapter/prettier.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport type { Options, SupportLanguage } from 'prettier';\nimport { check, format, getSupportInfo, resolveConfig } from 'prettier';\n\nimport { crawlDirectory } from '../../utils/dir';\nimport type { Logger } from '../../utils/logging';\nimport { pluralise } from '../../utils/logging';\nimport { getConsumerManifest } from '../../utils/manifest';\nimport { formatPackage, parsePackage } from '../configure/processing/package';\n\nlet languages: SupportLanguage[] | undefined;\n\n/**\n * Infers a parser for the specified filepath.\n *\n * This is a cut-down version of Prettier's built-in function of the same name;\n * ours operates purely on the `filepath` string and does not perform file I/O.\n * Prettier's internal `getInterpreter` function can open a file to read the\n * shebang, and its file descriptor usage can throw warnings on worker threads:\n *\n * ```console\n * Warning: File descriptor 123 closed but not opened in unmanaged mode\n * at Object.closeSync (node:fs:530:11)\n * at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:74:20)\n * ...\n * ```\n *\n * References:\n *\n * - https://github.com/prettier/prettier/blob/2.4.1/src/main/options.js#L167\n * - seek-oss/skuba#659\n */\nexport const inferParser = (filepath: string): string | undefined => {\n const filename = path.basename(filepath).toLowerCase();\n\n languages ??= getSupportInfo().languages.filter((language) => language.since);\n\n const firstLanguage = languages.find(\n (language) =>\n language.extensions?.some((extension) => filename.endsWith(extension)) ||\n language.filenames?.some((name) => name.toLowerCase() === filename),\n );\n\n return firstLanguage?.parsers[0];\n};\n\ninterface File {\n data: string;\n options: Options;\n filepath: string;\n}\n\ninterface Result {\n count: number;\n errored: Array<{ err?: unknown; filepath: string }>;\n touched: string[];\n unparsed: string[];\n}\n\nconst formatOrLintFile = (\n { data, filepath, options }: File,\n mode: 'format' | 'lint',\n result: Result,\n): string | undefined => {\n if (mode === 'lint') {\n let ok: boolean;\n try {\n ok = check(data, options);\n } catch (err) {\n result.errored.push({ err, filepath });\n return;\n }\n\n if (!ok) {\n result.errored.push({ filepath });\n }\n\n return;\n }\n\n let formatted: string;\n try {\n formatted = format(data, options);\n } catch (err) {\n result.errored.push({ err, filepath });\n return;\n }\n\n // Perform additional formatting (i.e. sorting) on a `package.json` manifest.\n try {\n if (path.basename(filepath) === 'package.json') {\n const packageJson = parsePackage(formatted);\n if (packageJson) {\n formatted = formatPackage(packageJson);\n }\n }\n } catch {\n //
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AAEf,sBAA6D;AAE7D,iBAA+B;AAE/B,qBAA0B;AAC1B,sBAAoC;AACpC,qBAA4C;AAE5C,IAAI;AAsBG,MAAM,cAAc,CAAC,aAAyC;AACnE,QAAM,WAAW,YAAAA,QAAK,SAAS,QAAQ,EAAE,YAAY;AAErD,gCAAc,gCAAe,EAAE,UAAU,OAAO,CAAC,aAAa,SAAS,KAAK;AAE5E,QAAM,gBAAgB,UAAU;AAAA,IAC9B,CAAC,aACC,SAAS,YAAY,KAAK,CAAC,cAAc,SAAS,SAAS,SAAS,CAAC,KACrE,SAAS,WAAW,KAAK,CAAC,SAAS,KAAK,YAAY,MAAM,QAAQ;AAAA,EACtE;AAEA,SAAO,eAAe,QAAQ;AAChC;AAeA,MAAM,mBAAmB,CACvB,EAAE,MAAM,UAAU,QAAQ,GAC1B,MACA,WACuB;AACvB,MAAI,SAAS,QAAQ;AACnB,QAAI;AACJ,QAAI;AACF,eAAK,uBAAM,MAAM,OAAO;AAAA,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport type { Options, SupportLanguage } from 'prettier';\nimport { check, format, getSupportInfo, resolveConfig } from 'prettier';\n\nimport { crawlDirectory } from '../../utils/dir';\nimport type { Logger } from '../../utils/logging';\nimport { pluralise } from '../../utils/logging';\nimport { getConsumerManifest } from '../../utils/manifest';\nimport { formatPackage, parsePackage } from '../configure/processing/package';\n\nlet languages: SupportLanguage[] | undefined;\n\n/**\n * Infers a parser for the specified filepath.\n *\n * This is a cut-down version of Prettier's built-in function of the same name;\n * ours operates purely on the `filepath` string and does not perform file I/O.\n * Prettier's internal `getInterpreter` function can open a file to read the\n * shebang, and its file descriptor usage can throw warnings on worker threads:\n *\n * ```console\n * Warning: File descriptor 123 closed but not opened in unmanaged mode\n * at Object.closeSync (node:fs:530:11)\n * at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:74:20)\n * ...\n * ```\n *\n * References:\n *\n * - https://github.com/prettier/prettier/blob/2.4.1/src/main/options.js#L167\n * - seek-oss/skuba#659\n */\nexport const inferParser = (filepath: string): string | undefined => {\n const filename = path.basename(filepath).toLowerCase();\n\n languages ??= getSupportInfo().languages.filter((language) => language.since);\n\n const firstLanguage = languages.find(\n (language) =>\n language.extensions?.some((extension) => filename.endsWith(extension)) ||\n language.filenames?.some((name) => name.toLowerCase() === filename),\n );\n\n return firstLanguage?.parsers[0];\n};\n\nconst isPackageJsonOk = ({\n data,\n filepath,\n}: {\n data: string;\n filepath: string;\n}): boolean => {\n if (path.basename(filepath) !== 'package.json') {\n return true;\n }\n\n try {\n const packageJson = parsePackage(data);\n\n return !packageJson || formatPackage(packageJson) === data;\n } catch {\n // Be more lenient about our custom formatting and don't throw if it errors.\n }\n\n return true;\n};\n\ninterface File {\n data: string;\n options: Options;\n filepath: string;\n}\n\ninterface Result {\n count: number;\n errored: Array<{ err?: unknown; filepath: string }>;\n touched: string[];\n unparsed: string[];\n}\n\nconst formatOrLintFile = (\n { data, filepath, options }: File,\n mode: 'format' | 'lint',\n result: Result,\n): string | undefined => {\n if (mode === 'lint') {\n let ok: boolean;\n try {\n ok = check(data, options) && isPackageJsonOk({ data, filepath });\n } catch (err) {\n result.errored.push({ err, filepath });\n return;\n }\n\n if (!ok) {\n result.errored.push({ filepath });\n }\n\n return;\n }\n\n let formatted: string;\n try {\n formatted = format(data, options);\n } catch (err) {\n result.errored.push({ err, filepath });\n return;\n }\n\n // Perform additional formatting (i.e. sorting) on a `package.json` manifest.\n try {\n if (path.basename(filepath) === 'package.json') {\n const packageJson = parsePackage(formatted);\n if (packageJson) {\n formatted = formatPackage(packageJson);\n }\n }\n } catch {\n // Be more lenient about our custom formatting and don't throw if it errors.\n }\n\n if (formatted === data) {\n return;\n }\n\n result.touched.push(filepath);\n return formatted;\n};\n\nexport interface PrettierOutput {\n ok: boolean;\n result: Result;\n}\n\n/**\n * Formats/lints files with Prettier.\n *\n * Prettier doesn't provide a higher-level Node.js API that replicates the\n * behaviour of its CLI, so we have to plumb together its lower-level functions.\n * On the other hand, this affords more flexibility in how we track and report\n * on progress and results.\n */\nexport const runPrettier = async (\n mode: 'format' | 'lint',\n logger: Logger,\n): Promise<PrettierOutput> => {\n logger.debug('Initialising Prettier...');\n\n const start = process.hrtime.bigint();\n\n let directory = process.cwd();\n\n const manifest = await getConsumerManifest();\n if (manifest) {\n directory = path.dirname(manifest.path);\n }\n\n logger.debug(\n manifest ? 'Detected project root:' : 'Detected working directory:',\n directory,\n );\n\n logger.debug('Discovering files...');\n\n // Match Prettier's opinion of not respecting `.gitignore`.\n // This avoids exhibiting different behaviour than a Prettier IDE integration,\n // and the headache of conflicting `.gitignore` and `.prettierignore` rules.\n const filepaths = await crawlDirectory(directory, '.prettierignore');\n\n logger.debug(`Discovered ${pluralise(filepaths.length, 'file')}.`);\n\n const result: Result = {\n count: filepaths.length,\n errored: [],\n touched: [],\n unparsed: [],\n };\n\n logger.debug(mode === 'format' ? 'Formatting' : 'Linting', 'files...');\n\n for (const filepath of filepaths) {\n // Infer parser upfront so we can skip unsupported files.\n const parser = inferParser(filepath);\n\n logger.debug(filepath);\n logger.debug(' parser:', parser ?? '-');\n\n if (!parser) {\n result.unparsed.push(filepath);\n continue;\n }\n\n const [config, data] = await Promise.all([\n resolveConfig(filepath),\n fs.promises.readFile(filepath, 'utf-8'),\n ]);\n\n const file: File = {\n data,\n filepath,\n options: { ...config, filepath },\n };\n\n const formatted = formatOrLintFile(file, mode, result);\n\n if (typeof formatted === 'string') {\n await fs.promises.writeFile(filepath, formatted);\n }\n }\n\n const end = process.hrtime.bigint();\n\n logger.plain(\n `Processed ${pluralise(\n result.count - result.unparsed.length,\n 'file',\n )} in ${logger.timing(start, end)}.`,\n );\n\n if (result.touched.length) {\n logger.plain(`Formatted ${pluralise(result.touched.length, 'file')}:`);\n for (const filepath of result.touched) {\n logger.warn(filepath);\n }\n }\n\n if (result.errored.length) {\n logger.plain(`Flagged ${pluralise(result.errored.length, 'file')}:`);\n for (const { err, filepath } of result.errored) {\n logger.warn(filepath, ...(err ? [String(err)] : []));\n }\n }\n\n return { ok: result.errored.length === 0, result };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AAEf,sBAA6D;AAE7D,iBAA+B;AAE/B,qBAA0B;AAC1B,sBAAoC;AACpC,qBAA4C;AAE5C,IAAI;AAsBG,MAAM,cAAc,CAAC,aAAyC;AACnE,QAAM,WAAW,YAAAA,QAAK,SAAS,QAAQ,EAAE,YAAY;AAErD,gCAAc,gCAAe,EAAE,UAAU,OAAO,CAAC,aAAa,SAAS,KAAK;AAE5E,QAAM,gBAAgB,UAAU;AAAA,IAC9B,CAAC,aACC,SAAS,YAAY,KAAK,CAAC,cAAc,SAAS,SAAS,SAAS,CAAC,KACrE,SAAS,WAAW,KAAK,CAAC,SAAS,KAAK,YAAY,MAAM,QAAQ;AAAA,EACtE;AAEA,SAAO,eAAe,QAAQ;AAChC;AAEA,MAAM,kBAAkB,CAAC;AAAA,EACvB;AAAA,EACA;AACF,MAGe;AACb,MAAI,YAAAA,QAAK,SAAS,QAAQ,MAAM,gBAAgB;AAC9C,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,kBAAc,6BAAa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QAAQ,QAAQ;AACzB,WAAO,MAAM,eAAW,0BAAU,OAAO,QAAQ,QAAQ,MAAM,IAAI;AACnE,eAAW,EAAE,KAAK,SAAS,KAAK,OAAO,SAAS;AAC9C,aAAO,KAAK,UAAU,GAAI,MAAM,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAE;AAAA,IACrD;AAAA,EACF;AAEA,SAAO,EAAE,IAAI,OAAO,QAAQ,WAAW,GAAG,OAAO;AACnD;",
|
|
6
6
|
"names": ["path", "fs"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Props = ts.NodeArray<ts.ObjectLiteralElementLike>;
|
|
3
|
+
type Transformer<T> = (context: ts.TransformationContext | null, props: T) => T;
|
|
4
4
|
/**
|
|
5
5
|
* Create a transformer to filter out unspecified props from an object literal.
|
|
6
6
|
*/
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { PackageJson as TypeFestPackageJson } from 'type-fest';
|
|
2
2
|
import type { ProjectType } from '../../utils/manifest';
|
|
3
3
|
export type { TsConfigJson } from 'type-fest';
|
|
4
|
-
export
|
|
4
|
+
export type PackageJson = TypeFestPackageJson & Record<string, unknown>;
|
|
5
5
|
export interface DependencySet {
|
|
6
6
|
dependencies: Record<string, string>;
|
|
7
7
|
devDependencies: Record<string, string>;
|
|
8
8
|
type: ProjectType;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type DependencyDiff = Record<string, {
|
|
11
11
|
operation: string;
|
|
12
12
|
version: string;
|
|
13
13
|
}>;
|
|
14
|
-
|
|
15
|
-
export
|
|
14
|
+
type FileProcessor = (file: string | undefined, files: Files, initialFiles: Readonly<Files>) => string | undefined;
|
|
15
|
+
export type FileDiff = Record<string, {
|
|
16
16
|
data: string | undefined;
|
|
17
17
|
operation: string;
|
|
18
18
|
}>;
|
|
19
|
-
export
|
|
20
|
-
export
|
|
19
|
+
export type Files = Record<string, string | undefined>;
|
|
20
|
+
export type Module = Record<string, FileProcessor>;
|
|
21
21
|
export interface Options {
|
|
22
22
|
destinationRoot: string;
|
|
23
23
|
entryPoint: string;
|
|
@@ -128,21 +128,34 @@ const getTemplateConfig = (dir) => {
|
|
|
128
128
|
throw err;
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
|
-
const baseToTemplateData = async ({
|
|
131
|
+
const baseToTemplateData = async ({
|
|
132
|
+
ownerName,
|
|
133
|
+
platformName,
|
|
134
|
+
repoName
|
|
135
|
+
}) => {
|
|
132
136
|
const [orgName, teamName] = ownerName.split("/");
|
|
133
137
|
const port = String(await (0, import_port.getRandomPort)());
|
|
134
138
|
return {
|
|
135
139
|
orgName,
|
|
136
140
|
ownerName,
|
|
137
|
-
port,
|
|
138
141
|
repoName,
|
|
139
|
-
teamName: teamName ?? orgName
|
|
142
|
+
teamName: teamName ?? orgName,
|
|
143
|
+
port,
|
|
144
|
+
platformName,
|
|
145
|
+
lambdaCdkArchitecture: platformName === "amd64" ? "X86_64" : "ARM_64",
|
|
146
|
+
lambdaServerlessArchitecture: platformName === "amd64" ? "x86_64" : platformName
|
|
140
147
|
};
|
|
141
148
|
};
|
|
142
149
|
const configureFromPrompt = async () => {
|
|
143
|
-
const { ownerName, repoName } = await runForm(
|
|
150
|
+
const { ownerName, platformName, repoName } = await runForm(
|
|
151
|
+
import_prompts.BASE_PROMPT_PROPS
|
|
152
|
+
);
|
|
144
153
|
import_logging.log.plain(import_chalk.default.cyan(repoName), "by", import_chalk.default.cyan(ownerName));
|
|
145
|
-
const templateData = await baseToTemplateData({
|
|
154
|
+
const templateData = await baseToTemplateData({
|
|
155
|
+
ownerName,
|
|
156
|
+
platformName,
|
|
157
|
+
repoName
|
|
158
|
+
});
|
|
146
159
|
const destinationDir = repoName;
|
|
147
160
|
await createDirectory(destinationDir);
|
|
148
161
|
import_logging.log.newline();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/getConfig.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy';\nimport { isErrorWithCode } from '../../utils/error';\nimport { log } from '../../utils/logging';\nimport { getRandomPort } from '../../utils/port';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n TemplateConfig,\n} from '../../utils/template';\n\nimport { downloadGitHubTemplate } from './git';\nimport type { BaseFields } from './prompts';\nimport {\n BASE_PROMPT_PROPS,\n GIT_PATH_PROMPT,\n SHOULD_CONTINUE_PROMPT,\n TEMPLATE_PROMPT,\n} from './prompts';\nimport type { InitConfig } from './types';\nimport { InitConfigInput } from './types';\n\nimport { Form } from 'enquirer';\nimport type { FormChoice } from 'enquirer';\n\nexport const runForm = <T = Record<string, string>>(props: {\n choices: Readonly<FormChoice[]>;\n message: string;\n name: string;\n}) => {\n const { message, name } = props;\n\n const choices = props.choices.map((choice) => ({\n ...choice,\n validate: (value: string) => {\n if (value === '' || value === choice.initial) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(value) ?? true;\n },\n }));\n\n const form = new Form<T>({\n choices,\n message,\n name,\n validate: async (values) => {\n const results = await Promise.all(\n choices.map((choice) => choice.validate(values[choice.name])),\n );\n\n return (\n results.find((result) => typeof result === 'string') ??\n results.every((result) => result === true)\n );\n },\n });\n\n return form.run();\n};\n\nconst confirmShouldContinue = async (choices: Readonly<FormChoice[]>) => {\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 SHOULD_CONTINUE_PROMPT.run();\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 (templateName: string, destinationDir: string) => {\n if (templateName.startsWith('github:')) {\n const gitHubPath = templateName.slice('github:'.length);\n return downloadGitHubTemplate(gitHubPath, destinationDir);\n }\n\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\nconst getTemplateName = async () => {\n const templateSelection = await TEMPLATE_PROMPT.run();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await GIT_PATH_PROMPT.run();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: FormChoice[]) =>\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-var-requires */\n const templateConfig = require(templateConfigPath) as unknown;\n\n return TemplateConfig.check(templateConfig);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,mBAAkB;AAClB,sBAAe;AAEf,kBAA0B;AAC1B,mBAAgC;AAChC,qBAAoB;AACpB,kBAA8B;AAC9B,sBAIO;AAEP,iBAAuC;AAEvC,qBAKO;AAEP,mBAAgC;AAEhC,sBAAqB;AAGd,MAAM,UAAU,CAA6B,UAI9C;AACJ,QAAM,EAAE,SAAS,KAAK,IAAI;AAE1B,Q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GAAG;AACtC,UAAM,aAAa,aAAa,MAAM,UAAU,MAAM;AACtD,eAAO,mCAAuB,YAAY,cAAc;AAAA,EAC1D;AAEA,QAAM,cAAc,YAAAC,QAAK,KAAK,8BAAc,YAAY;AAExD,YAAM,uBAAU;AAAA,IAEd,SAAS,MAAM;AAAA,IACf,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,YAAY,CAAC;AAAA,IAEb,uBAAuB;AAAA,EACzB,CAAC;AACH;AAEA,MAAM,kBAAkB,YAAY;AAClC,QAAM,oBAAoB,MAAM,+BAAgB,IAAI;AAEpD,MAAI,sBAAsB,iBAAY;AACpC,UAAM,aAAa,MAAM,+BAAgB,IAAI;AAC7C,WAAO,UAAU;AAAA,EACnB;AAEA,SAAO;AACT;AAEA,MAAM,uBAAuB,CAAC,YAC5B,OAAO;AAAA,EACL,QAAQ,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,MAAM,OAAO,SAAS,CAAU;AAC7D;AAEK,MAAM,oBAAoB,CAAC,QAAgC;AAChE,QAAM,qBAAqB,YAAAA,QAAK,KAAK,KAAK,wCAAwB;AAElE,MAAI;AAEF,UAAM,iBAAiB,QAAQ
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy';\nimport { isErrorWithCode } from '../../utils/error';\nimport { log } from '../../utils/logging';\nimport { getRandomPort } from '../../utils/port';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n TemplateConfig,\n} from '../../utils/template';\n\nimport { downloadGitHubTemplate } from './git';\nimport type { BaseFields } from './prompts';\nimport {\n BASE_PROMPT_PROPS,\n GIT_PATH_PROMPT,\n SHOULD_CONTINUE_PROMPT,\n TEMPLATE_PROMPT,\n} from './prompts';\nimport type { InitConfig } from './types';\nimport { InitConfigInput } from './types';\n\nimport { Form } from 'enquirer';\nimport type { FormChoice } from 'enquirer';\n\nexport const runForm = <T = Record<string, string>>(props: {\n choices: Readonly<FormChoice[]>;\n message: string;\n name: string;\n}) => {\n const { message, name } = props;\n\n const choices = props.choices.map((choice) => ({\n ...choice,\n validate: (value: string) => {\n if (value === '' || value === choice.initial) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(value) ?? true;\n },\n }));\n\n const form = new Form<T>({\n choices,\n message,\n name,\n validate: async (values) => {\n const results = await Promise.all(\n choices.map((choice) => choice.validate(values[choice.name])),\n );\n\n return (\n results.find((result) => typeof result === 'string') ??\n results.every((result) => result === true)\n );\n },\n });\n\n return form.run();\n};\n\nconst confirmShouldContinue = async (choices: Readonly<FormChoice[]>) => {\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 SHOULD_CONTINUE_PROMPT.run();\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 (templateName: string, destinationDir: string) => {\n if (templateName.startsWith('github:')) {\n const gitHubPath = templateName.slice('github:'.length);\n return downloadGitHubTemplate(gitHubPath, destinationDir);\n }\n\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\nconst getTemplateName = async () => {\n const templateSelection = await TEMPLATE_PROMPT.run();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await GIT_PATH_PROMPT.run();\n return `github:${gitHubPath}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: FormChoice[]) =>\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-var-requires */\n const templateConfig = require(templateConfigPath) as unknown;\n\n return TemplateConfig.check(templateConfig);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({\n ownerName,\n platformName,\n repoName,\n}: BaseFields) => {\n const [orgName, teamName] = ownerName.split('/');\n\n const port = String(await getRandomPort());\n\n return {\n orgName,\n ownerName,\n repoName,\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 } = await runForm<BaseFields>(\n BASE_PROMPT_PROPS,\n );\n log.plain(chalk.cyan(repoName), 'by', chalk.cyan(ownerName));\n\n const templateData = await baseToTemplateData({\n ownerName,\n platformName,\n repoName,\n });\n\n const destinationDir = repoName;\n\n await createDirectory(destinationDir);\n\n log.newline();\n const templateName = await getTemplateName();\n\n await cloneTemplate(templateName, destinationDir);\n\n const { entryPoint, fields, noSkip, type } = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (fields.length === 0) {\n return {\n destinationDir,\n entryPoint,\n templateComplete: true,\n templateData,\n templateName,\n type,\n };\n }\n\n const shouldContinue = noSkip ? true : await confirmShouldContinue(fields);\n\n if (shouldContinue) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: chalk.bold(`Complete ${chalk.cyan(templateName)}:`),\n name: 'customAnswers',\n });\n\n return {\n destinationDir,\n entryPoint,\n templateComplete: true,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n }\n\n log.newline();\n log.warn(`Resume this later with ${chalk.bold('yarn skuba configure')}.`);\n\n const customAnswers = generatePlaceholders(fields);\n\n return {\n destinationDir,\n entryPoint,\n templateComplete: false,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n};\n\nconst configureFromPipe = async (): Promise<InitConfig> => {\n let text = '';\n\n await new Promise((resolve) =>\n process.stdin.on('data', (chunk) => (text += chunk)).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 const result = InitConfigInput.validate(value);\n\n if (!result.success) {\n log.err('Invalid data from stdin:');\n log.err(result.message);\n process.exit(1);\n }\n\n const { destinationDir, templateComplete, templateName } = result.value;\n\n const templateData = {\n ...(await baseToTemplateData(result.value.templateData)),\n ...result.value.templateData,\n };\n\n await createDirectory(destinationDir);\n\n await cloneTemplate(templateName, destinationDir);\n\n const { entryPoint, fields, noSkip, type } = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\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.value,\n entryPoint,\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.value,\n entryPoint,\n templateData,\n type,\n };\n};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;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AAM,gBAAgB,cAAc;AAEpC,QAAM,cAAc,cAAc,cAAc;AAEhD,QAAM,EAAE,YAAY,QAAQ,QAAQ,KAAK,IAAI;AAAA,IAC3C,YAAAD,QAAK,KAAK,QAAQ,IAAI,GAAG,cAAc;AAAA,EACzC;AAEA,MAAI,CAAC,kBAAkB;AACrB,QAAI,QAAQ;AACV,yBAAI,IAAI,kBAAkB,mBAAI,KAAK,YAAY,GAAG,oBAAoB;AACtE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,WAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV;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,MAAM,CAAC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,GAAG,OAAO;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,MACvB,QAAQ,MAAM,QAAQ,oBAAoB,IAAI,kBAAkB;",
|
|
6
6
|
"names": ["fs", "path", "chalk", "customAnswers"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { Platform } from './validation';
|
|
1
2
|
import { Input, Select } from 'enquirer';
|
|
2
|
-
export
|
|
3
|
+
export type BaseFields = Record<typeof BASE_CHOICES[number]['name'], string> & {
|
|
4
|
+
platformName: Platform;
|
|
5
|
+
};
|
|
3
6
|
declare const BASE_CHOICES: readonly [{
|
|
4
7
|
readonly name: "ownerName";
|
|
5
8
|
readonly message: "Owner";
|
|
@@ -10,6 +13,11 @@ declare const BASE_CHOICES: readonly [{
|
|
|
10
13
|
readonly message: "Repo";
|
|
11
14
|
readonly initial: "my-repo";
|
|
12
15
|
readonly validate: (value: unknown) => Promise<string | true>;
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "platformName";
|
|
18
|
+
readonly message: "Platform";
|
|
19
|
+
readonly initial: string;
|
|
20
|
+
readonly validate: (value: unknown) => string | true;
|
|
13
21
|
}];
|
|
14
22
|
export declare const BASE_PROMPT_PROPS: {
|
|
15
23
|
choices: readonly [{
|
|
@@ -22,6 +30,11 @@ export declare const BASE_PROMPT_PROPS: {
|
|
|
22
30
|
readonly message: "Repo";
|
|
23
31
|
readonly initial: "my-repo";
|
|
24
32
|
readonly validate: (value: unknown) => Promise<string | true>;
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "platformName";
|
|
35
|
+
readonly message: "Platform";
|
|
36
|
+
readonly initial: string;
|
|
37
|
+
readonly validate: (value: unknown) => string | true;
|
|
25
38
|
}];
|
|
26
39
|
message: string;
|
|
27
40
|
name: string;
|
package/lib/cli/init/prompts.js
CHANGED
|
@@ -58,11 +58,17 @@ const BASE_CHOICES = [
|
|
|
58
58
|
const exists = await (0, import_fs_extra.pathExists)(value);
|
|
59
59
|
return !exists || `'${value}' is an existing directory`;
|
|
60
60
|
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "platformName",
|
|
64
|
+
message: "Platform",
|
|
65
|
+
initial: import_validation.PLATFORM_OPTIONS,
|
|
66
|
+
validate: (value) => (0, import_validation.isPlatform)(value) || `must be ${import_validation.PLATFORM_OPTIONS}`
|
|
61
67
|
}
|
|
62
68
|
];
|
|
63
69
|
const BASE_PROMPT_PROPS = {
|
|
64
70
|
choices: BASE_CHOICES,
|
|
65
|
-
message: "For starters, some
|
|
71
|
+
message: "For starters, some project details:",
|
|
66
72
|
name: "baseAnswers"
|
|
67
73
|
};
|
|
68
74
|
const SHOULD_CONTINUE_PROMPT = new import_enquirer.Select({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/prompts.ts"],
|
|
4
|
-
"sourcesContent": ["import { pathExists } from 'fs-extra';\n\nimport { TEMPLATE_NAMES_WITH_BYO } from '../../utils/template';\n\nimport { isGitHubOrg
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2B;AAE3B,sBAAwC;
|
|
4
|
+
"sourcesContent": ["import { pathExists } from 'fs-extra';\n\nimport { TEMPLATE_NAMES_WITH_BYO } from '../../utils/template';\n\nimport type { Platform } from './validation';\nimport {\n PLATFORM_OPTIONS,\n isGitHubOrg,\n isGitHubRepo,\n isGitHubTeam,\n isPlatform,\n} from './validation';\n\nimport { Input, Select } from 'enquirer';\n\nexport type BaseFields = Record<typeof BASE_CHOICES[number]['name'], string> & {\n platformName: Platform;\n};\n\nconst BASE_CHOICES = [\n {\n name: 'ownerName',\n message: 'Owner',\n initial: 'SEEK-Jobs/my-team',\n validate: (value: unknown) => {\n if (typeof value !== 'string') {\n return 'required';\n }\n\n const [org, team] = value.split('/');\n\n if (!isGitHubOrg(org)) {\n return 'fails GitHub validation';\n }\n\n return (\n team === undefined || isGitHubTeam(team) || 'fails GitHub validation'\n );\n },\n },\n {\n name: 'repoName',\n message: 'Repo',\n initial: 'my-repo',\n validate: async (value: unknown) => {\n if (typeof value !== 'string') {\n return 'required';\n }\n\n if (!isGitHubRepo(value)) {\n return 'fails GitHub validation';\n }\n\n const exists = await pathExists(value);\n\n return !exists || `'${value}' is an existing directory`;\n },\n },\n {\n name: 'platformName',\n message: 'Platform',\n initial: PLATFORM_OPTIONS,\n validate: (value: unknown) =>\n isPlatform(value) || `must be ${PLATFORM_OPTIONS}`,\n },\n] as const;\n\nexport const BASE_PROMPT_PROPS = {\n choices: BASE_CHOICES,\n message: 'For starters, some project details:',\n name: 'baseAnswers',\n};\n\nexport const SHOULD_CONTINUE_PROMPT = new Select({\n choices: ['yes', 'no'] as const,\n message: 'Fill this in now?',\n name: 'shouldContinue',\n});\n\nexport const GIT_PATH_PROMPT = new Input({\n message: 'Git path',\n name: 'gitPath',\n initial: 'seek-oss/skuba',\n validate: (value) => /[^/]+\\/[^/]+/.test(value) || 'Path is not valid',\n});\n\nexport const TEMPLATE_PROMPT = new Select({\n choices: TEMPLATE_NAMES_WITH_BYO,\n message: 'Select a template:',\n name: 'templateName',\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2B;AAE3B,sBAAwC;AAGxC,wBAMO;AAEP,sBAA8B;AAM9B,MAAM,eAAe;AAAA,EACnB;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,CAAC,UAAmB;AAC5B,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAEA,YAAM,CAAC,KAAK,IAAI,IAAI,MAAM,MAAM,GAAG;AAEnC,UAAI,KAAC,+BAAY,GAAG,GAAG;AACrB,eAAO;AAAA,MACT;AAEA,aACE,SAAS,cAAa,gCAAa,IAAI,KAAK;AAAA,IAEhD;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,OAAO,UAAmB;AAClC,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAEA,UAAI,KAAC,gCAAa,KAAK,GAAG;AACxB,eAAO;AAAA,MACT;AAEA,YAAM,SAAS,UAAM,4BAAW,KAAK;AAErC,aAAO,CAAC,UAAU,IAAI;AAAA,IACxB;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,CAAC,cACT,8BAAW,KAAK,KAAK,WAAW;AAAA,EACpC;AACF;AAEO,MAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR;AAEO,MAAM,yBAAyB,IAAI,uBAAO;AAAA,EAC/C,SAAS,CAAC,OAAO,IAAI;AAAA,EACrB,SAAS;AAAA,EACT,MAAM;AACR,CAAC;AAEM,MAAM,kBAAkB,IAAI,sBAAM;AAAA,EACvC,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,UAAU,eAAe,KAAK,KAAK,KAAK;AACrD,CAAC;AAEM,MAAM,kBAAkB,IAAI,uBAAO;AAAA,EACxC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/init/types.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as t from 'runtypes';
|
|
2
|
-
export
|
|
2
|
+
export type InitConfigInput = t.Static<typeof InitConfigInput>;
|
|
3
3
|
export declare const InitConfigInput: t.Record<{
|
|
4
4
|
destinationDir: t.String;
|
|
5
5
|
templateComplete: t.Boolean;
|
|
6
6
|
templateData: t.Intersect<[t.Record<{
|
|
7
7
|
ownerName: t.String;
|
|
8
8
|
repoName: t.String;
|
|
9
|
+
platformName: t.Union<[t.Literal<"amd64">, t.Literal<"arm64">]>;
|
|
9
10
|
}, false>, t.Dictionary<t.String, string>]>;
|
|
10
11
|
templateName: t.String;
|
|
11
12
|
}, false>;
|
|
12
|
-
export
|
|
13
|
+
export type InitConfig = t.Static<typeof InitConfig>;
|
|
13
14
|
declare const InitConfig: t.Record<{
|
|
14
15
|
templateData: t.Intersect<[t.Record<{
|
|
15
16
|
ownerName: t.String;
|
package/lib/cli/init/types.js
CHANGED
|
@@ -34,7 +34,8 @@ const INIT_CONFIG_INPUT_FIELDS = {
|
|
|
34
34
|
templateComplete: t.Boolean,
|
|
35
35
|
templateData: t.Record({
|
|
36
36
|
ownerName: t.String,
|
|
37
|
-
repoName: t.String
|
|
37
|
+
repoName: t.String,
|
|
38
|
+
platformName: t.Union(t.Literal("amd64"), t.Literal("arm64"))
|
|
38
39
|
}).And(t.Dictionary(t.String, t.String)),
|
|
39
40
|
templateName: t.String
|
|
40
41
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/types.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable new-cap */\n\nimport * as t from 'runtypes';\n\nimport { ProjectType } from '../../utils/manifest';\n\nconst INIT_CONFIG_INPUT_FIELDS = {\n destinationDir: t.String,\n templateComplete: t.Boolean,\n templateData: t\n .Record({\n ownerName: t.String,\n repoName: t.String,\n })\n .And(t.Dictionary(t.String, t.String)),\n templateName: t.String,\n};\n\nexport type InitConfigInput = t.Static<typeof InitConfigInput>;\n\nexport const InitConfigInput = t.Record(INIT_CONFIG_INPUT_FIELDS);\n\nexport type InitConfig = t.Static<typeof InitConfig>;\n\nconst InitConfig = t.Record({\n ...INIT_CONFIG_INPUT_FIELDS,\n\n templateData: t\n .Record({\n ownerName: t.String,\n repoName: t.String,\n\n // Derived from ownerName\n orgName: t.String,\n teamName: t.String,\n\n // Generated by init command\n port: t.String,\n })\n .And(t.Dictionary(t.String, t.String)),\n\n entryPoint: t.String.optional(),\n type: ProjectType.optional(),\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,QAAmB;AAEnB,sBAA4B;AAE5B,MAAM,2BAA2B;AAAA,EAC/B,gBAAgB,EAAE;AAAA,EAClB,kBAAkB,EAAE;AAAA,EACpB,cAAc,EACX,OAAO;AAAA,IACN,WAAW,EAAE;AAAA,IACb,UAAU,EAAE;AAAA,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable new-cap */\n\nimport * as t from 'runtypes';\n\nimport { ProjectType } from '../../utils/manifest';\n\nconst INIT_CONFIG_INPUT_FIELDS = {\n destinationDir: t.String,\n templateComplete: t.Boolean,\n templateData: t\n .Record({\n ownerName: t.String,\n repoName: t.String,\n platformName: t.Union(t.Literal('amd64'), t.Literal('arm64')),\n })\n .And(t.Dictionary(t.String, t.String)),\n templateName: t.String,\n};\n\nexport type InitConfigInput = t.Static<typeof InitConfigInput>;\n\nexport const InitConfigInput = t.Record(INIT_CONFIG_INPUT_FIELDS);\n\nexport type InitConfig = t.Static<typeof InitConfig>;\n\nconst InitConfig = t.Record({\n ...INIT_CONFIG_INPUT_FIELDS,\n\n templateData: t\n .Record({\n ownerName: t.String,\n repoName: t.String,\n\n // Derived from ownerName\n orgName: t.String,\n teamName: t.String,\n\n // Generated by init command\n port: t.String,\n })\n .And(t.Dictionary(t.String, t.String)),\n\n entryPoint: t.String.optional(),\n type: ProjectType.optional(),\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,QAAmB;AAEnB,sBAA4B;AAE5B,MAAM,2BAA2B;AAAA,EAC/B,gBAAgB,EAAE;AAAA,EAClB,kBAAkB,EAAE;AAAA,EACpB,cAAc,EACX,OAAO;AAAA,IACN,WAAW,EAAE;AAAA,IACb,UAAU,EAAE;AAAA,IACZ,cAAc,EAAE,MAAM,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,CAAC;AAAA,EAC9D,CAAC,EACA,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC;AAAA,EACvC,cAAc,EAAE;AAClB;AAIO,MAAM,kBAAkB,EAAE,OAAO,wBAAwB;AAIhE,MAAM,aAAa,EAAE,OAAO;AAAA,EAC1B,GAAG;AAAA,EAEH,cAAc,EACX,OAAO;AAAA,IACN,WAAW,EAAE;AAAA,IACb,UAAU,EAAE;AAAA,IAGZ,SAAS,EAAE;AAAA,IACX,UAAU,EAAE;AAAA,IAGZ,MAAM,EAAE;AAAA,EACV,CAAC,EACA,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC;AAAA,EAEvC,YAAY,EAAE,OAAO,SAAS;AAAA,EAC9B,MAAM,4BAAY,SAAS;AAC7B,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export declare const isGitHubOrg: (value: string) => boolean;
|
|
2
2
|
export declare const isGitHubRepo: (value: string) => boolean;
|
|
3
3
|
export declare const isGitHubTeam: (value: string) => boolean;
|
|
4
|
+
declare const PLATFORMS: readonly ["amd64", "arm64"];
|
|
5
|
+
export type Platform = typeof PLATFORMS[number];
|
|
6
|
+
export declare const PLATFORM_OPTIONS: string;
|
|
7
|
+
export declare const isPlatform: (value: unknown) => boolean;
|
|
8
|
+
export {};
|
|
@@ -18,18 +18,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var validation_exports = {};
|
|
20
20
|
__export(validation_exports, {
|
|
21
|
+
PLATFORM_OPTIONS: () => PLATFORM_OPTIONS,
|
|
21
22
|
isGitHubOrg: () => isGitHubOrg,
|
|
22
23
|
isGitHubRepo: () => isGitHubRepo,
|
|
23
|
-
isGitHubTeam: () => isGitHubTeam
|
|
24
|
+
isGitHubTeam: () => isGitHubTeam,
|
|
25
|
+
isPlatform: () => isPlatform
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(validation_exports);
|
|
26
28
|
const isGitHubOrg = (value) => /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(value) && !value.includes("--");
|
|
27
29
|
const isGitHubRepo = (value) => /^[A-Za-z0-9_.-]+$/.test(value) && value !== "." && value !== "..";
|
|
28
30
|
const isGitHubTeam = (value) => /^[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/.test(value) && !value.endsWith("-") && !value.includes("--");
|
|
31
|
+
const PLATFORMS = ["amd64", "arm64"];
|
|
32
|
+
const PLATFORM_OPTIONS = PLATFORMS.join(" | ");
|
|
33
|
+
const platformSet = new Set(PLATFORMS);
|
|
34
|
+
const isPlatform = (value) => platformSet.has(value);
|
|
29
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
36
|
0 && (module.exports = {
|
|
37
|
+
PLATFORM_OPTIONS,
|
|
31
38
|
isGitHubOrg,
|
|
32
39
|
isGitHubRepo,
|
|
33
|
-
isGitHubTeam
|
|
40
|
+
isGitHubTeam,
|
|
41
|
+
isPlatform
|
|
34
42
|
});
|
|
35
43
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/validation.ts"],
|
|
4
|
-
"sourcesContent": ["export const isGitHubOrg = (value: string) =>\n /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(value) &&\n !value.includes('--');\n\nexport const isGitHubRepo = (value: string) =>\n /^[A-Za-z0-9_.-]+$/.test(value) && value !== '.' && value !== '..';\n\nexport const isGitHubTeam = (value: string) =>\n /^[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/.test(value) &&\n !value.endsWith('-') &&\n !value.includes('--');\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc,CAAC,UAC1B,6CAA6C,KAAK,KAAK,KACvD,CAAC,MAAM,SAAS,IAAI;AAEf,MAAM,eAAe,CAAC,UAC3B,oBAAoB,KAAK,KAAK,KAAK,UAAU,OAAO,UAAU;AAEzD,MAAM,eAAe,CAAC,UAC3B,gDAAgD,KAAK,KAAK,KAC1D,CAAC,MAAM,SAAS,GAAG,KACnB,CAAC,MAAM,SAAS,IAAI;",
|
|
4
|
+
"sourcesContent": ["export const isGitHubOrg = (value: string) =>\n /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(value) &&\n !value.includes('--');\n\nexport const isGitHubRepo = (value: string) =>\n /^[A-Za-z0-9_.-]+$/.test(value) && value !== '.' && value !== '..';\n\nexport const isGitHubTeam = (value: string) =>\n /^[A-Za-z0-9_](?:[A-Za-z0-9_-]*[A-Za-z0-9_])?$/.test(value) &&\n !value.endsWith('-') &&\n !value.includes('--');\n\nconst PLATFORMS = ['amd64', 'arm64'] as const;\n\nexport type Platform = typeof PLATFORMS[number];\n\nexport const PLATFORM_OPTIONS = PLATFORMS.join(' | ');\n\nconst platformSet = new Set<unknown>(PLATFORMS);\n\nexport const isPlatform = (value: unknown) => platformSet.has(value);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc,CAAC,UAC1B,6CAA6C,KAAK,KAAK,KACvD,CAAC,MAAM,SAAS,IAAI;AAEf,MAAM,eAAe,CAAC,UAC3B,oBAAoB,KAAK,KAAK,KAAK,UAAU,OAAO,UAAU;AAEzD,MAAM,eAAe,CAAC,UAC3B,gDAAgD,KAAK,KAAK,KAC1D,CAAC,MAAM,SAAS,GAAG,KACnB,CAAC,MAAM,SAAS,IAAI;AAEtB,MAAM,YAAY,CAAC,SAAS,OAAO;AAI5B,MAAM,mBAAmB,UAAU,KAAK,KAAK;AAEpD,MAAM,cAAc,IAAI,IAAa,SAAS;AAEvC,MAAM,aAAa,CAAC,UAAmB,YAAY,IAAI,KAAK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/skuba.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/skuba.ts"],
|
|
4
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 * [yarn] skuba help\n * ```\n */\n\nimport path from 'path';\n\nimport { parseProcessArgs } from './utils/args';\nimport { COMMAND_DIR, COMMAND_SET, commandToModule } from './utils/command';\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 skuba = async () => {\n const { commandName } = parseProcessArgs(process.argv);\n\n if (COMMAND_SET.has(commandName)) {\n const moduleName = commandToModule(commandName);\n\n /* eslint-disable @typescript-eslint/no-var-requires */\n const commandModule = require(path.join(\n COMMAND_DIR,\n 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 return run();\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};\n\nskuba().catch(handleCliError);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAYA,kBAAiB;AAEjB,kBAAiC;AACjC,qBAA0D;AAC1D,mBAA+B;AAC/B,kBAAyB;AACzB,qBAAoB;AACpB,kBAAuC;AACvC,wBAAwB;AAExB,MAAM,QAAQ,YAAY;AACxB,QAAM,EAAE,YAAY,QAAI,8BAAiB,QAAQ,IAAI;AAErD,MAAI,2BAAY,IAAI,WAAW,GAAG;AAChC,UAAM,iBAAa,gCAAgB,WAAW;AAG9C,UAAM,gBAAgB,QAAQ,YAAAA,QAAK;AAAA,MACjC;AAAA,MACA;AAAA,IACF
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAYA,kBAAiB;AAEjB,kBAAiC;AACjC,qBAA0D;AAC1D,mBAA+B;AAC/B,kBAAyB;AACzB,qBAAoB;AACpB,kBAAuC;AACvC,wBAAwB;AAExB,MAAM,QAAQ,YAAY;AACxB,QAAM,EAAE,YAAY,QAAI,8BAAiB,QAAQ,IAAI;AAErD,MAAI,2BAAY,IAAI,WAAW,GAAG;AAChC,UAAM,iBAAa,gCAAgB,WAAW;AAG9C,UAAM,gBAAgB,QAAQ,YAAAA,QAAK;AAAA,MACjC;AAAA,MACA;AAAA,IACF;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;AAE1B,WAAO,IAAI;AAAA,EACb;AAEA,qBAAI,IAAI,mBAAI,KAAK,WAAW,GAAG,iCAAiC;AAChE,YAAM,oCAAuB;AAC7B,4BAAS;AAET,UAAQ,WAAW;AACrB;AAEA,MAAM,EAAE,MAAM,2BAAc;",
|
|
6
6
|
"names": ["path"]
|
|
7
7
|
}
|
package/lib/utils/command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Command = typeof COMMAND_LIST[number];
|
|
2
2
|
export declare const COMMAND_ALIASES: Record<string, Command>;
|
|
3
3
|
export declare const COMMAND_DIR: string;
|
|
4
4
|
export declare const COMMAND_LIST: readonly ["build", "build-package", "configure", "format", "help", "init", "lint", "node", "release", "start", "test", "version"];
|
package/lib/utils/copy.d.ts
CHANGED
package/lib/utils/error.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { inspect } from 'util';
|
|
3
3
|
import * as t from 'runtypes';
|
|
4
|
-
export
|
|
4
|
+
export type ConcurrentlyErrors = t.Static<typeof ConcurrentlyErrors>;
|
|
5
5
|
export declare const ConcurrentlyErrors: t.Array<t.Record<{
|
|
6
6
|
command: t.Record<{
|
|
7
7
|
command: t.String;
|
package/lib/utils/exec.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import stream from 'stream';
|
|
|
3
3
|
import type { Color } from 'chalk';
|
|
4
4
|
import type { ExecaChildProcess } from 'execa';
|
|
5
5
|
import execa from 'execa';
|
|
6
|
-
export
|
|
6
|
+
export type Exec = (command: string, ...args: string[]) => ExecaChildProcess<string>;
|
|
7
7
|
interface ExecConcurrentlyCommand {
|
|
8
8
|
command: string;
|
|
9
9
|
name: string;
|
|
@@ -29,7 +29,7 @@ interface ExecConcurrentlyOptions {
|
|
|
29
29
|
*/
|
|
30
30
|
outputStream?: stream.Writable;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
type ExecOptions = execa.Options & {
|
|
33
33
|
streamStdio?: true | 'yarn';
|
|
34
34
|
};
|
|
35
35
|
export declare const createExec: (opts: ExecOptions) => Exec;
|
package/lib/utils/logging.d.ts
CHANGED
package/lib/utils/manifest.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NormalizedPackageJson } from 'read-pkg-up';
|
|
2
2
|
import readPkgUp from 'read-pkg-up';
|
|
3
3
|
import * as t from 'runtypes';
|
|
4
|
-
export
|
|
4
|
+
export type ProjectType = t.Static<typeof ProjectType>;
|
|
5
5
|
export declare const ProjectType: t.Union<[t.Literal<"application">, t.Literal<"package">]>;
|
|
6
6
|
export declare const PROJECT_TYPES: readonly ["application", "package"];
|
|
7
7
|
export declare const getSkubaManifest: () => Promise<NormalizedPackageJson>;
|
package/lib/utils/template.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from 'runtypes';
|
|
2
2
|
export declare const TEMPLATE_NAMES: readonly ["express-rest-api", "greeter", "koa-rest-api", "lambda-sqs-worker", "lambda-sqs-worker-cdk", "oss-npm-package", "private-npm-package"];
|
|
3
|
-
export
|
|
3
|
+
export type TemplateName = typeof TEMPLATE_NAMES[number];
|
|
4
4
|
export declare const TEMPLATE_NAMES_WITH_BYO: readonly ["express-rest-api", "greeter", "koa-rest-api", "lambda-sqs-worker", "lambda-sqs-worker-cdk", "oss-npm-package", "private-npm-package", "github →"];
|
|
5
5
|
interface TemplateDocumentationConfig {
|
|
6
6
|
/**
|
|
@@ -17,7 +17,7 @@ interface TemplateDocumentationConfig {
|
|
|
17
17
|
filename: string;
|
|
18
18
|
}
|
|
19
19
|
export declare const TEMPLATE_DOCUMENTATION_CONFIG: Record<TemplateName, TemplateDocumentationConfig>;
|
|
20
|
-
export
|
|
20
|
+
export type TemplateConfig = t.Static<typeof TemplateConfig>;
|
|
21
21
|
export declare const TemplateConfig: t.Record<{
|
|
22
22
|
fields: t.Array<t.Record<{
|
|
23
23
|
name: t.String;
|
package/lib/utils/version.d.ts
CHANGED
package/lib/utils/wait.d.ts
CHANGED
package/lib/wrapper/main.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/wrapper/main.ts"],
|
|
4
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 unknown;\n\n return functionName\n ? runFunctionHandler({ availablePort, entryPoint, functionName })\n : runRequestListener({ availablePort, entryPoint });\n};\n"],
|
|
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
|
|
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;AAE3B,SAAO,mBACH,2CAAmB,EAAE,eAAe,YAAY,aAAa,CAAC,QAC9D,2CAAmB,EAAE,eAAe,WAAW,CAAC;AACtD;",
|
|
6
6
|
"names": ["path"]
|
|
7
7
|
}
|