skuba 0.0.0-master-20230319220011 → 0.0.0-master-20230718070720
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/README.md +1 -1
- package/config/tsconfig.json +3 -1
- package/lib/api/buildkite/md.js.map +1 -1
- package/lib/api/git/currentBranch.js +2 -1
- package/lib/api/git/currentBranch.js.map +2 -2
- package/lib/api/git/findRoot.d.ts +9 -0
- package/lib/api/git/findRoot.js +52 -0
- package/lib/api/git/findRoot.js.map +7 -0
- package/lib/api/git/index.d.ts +1 -0
- package/lib/api/git/index.js +3 -0
- package/lib/api/git/index.js.map +2 -2
- package/lib/api/git/pull.js.map +1 -1
- package/lib/api/git/push.js.map +1 -1
- package/lib/api/git/remote.js +2 -1
- package/lib/api/git/remote.js.map +2 -2
- package/lib/api/git/reset.js.map +1 -1
- package/lib/api/github/checkRun.d.ts +1 -1
- package/lib/api/github/checkRun.js.map +2 -2
- package/lib/api/github/environment.js.map +1 -1
- package/lib/api/github/issueComment.js.map +1 -1
- package/lib/api/github/pullRequest.js +3 -2
- package/lib/api/github/pullRequest.js.map +2 -2
- package/lib/api/github/push.js.map +1 -1
- package/lib/api/jest/index.d.ts +24 -21
- package/lib/api/net/compose.js.map +1 -1
- package/lib/api/net/socket.js.map +1 -1
- package/lib/cli/adapter/eslint.js +0 -24
- package/lib/cli/adapter/eslint.js.map +2 -2
- package/lib/cli/adapter/prettier.d.ts +1 -1
- package/lib/cli/adapter/prettier.js +14 -11
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/build/assets.d.ts +10 -0
- package/lib/cli/build/assets.js +107 -0
- package/lib/cli/build/assets.js.map +7 -0
- package/lib/cli/build/esbuild.js +7 -42
- package/lib/cli/build/esbuild.js.map +3 -3
- package/lib/cli/build/index.js +12 -2
- package/lib/cli/build/index.js.map +2 -2
- package/lib/cli/build/tsc.d.ts +3 -0
- package/lib/cli/build/tsc.js +66 -0
- package/lib/cli/build/tsc.js.map +3 -3
- package/lib/cli/buildPackage.js +13 -0
- package/lib/cli/buildPackage.js.map +2 -2
- package/lib/cli/configure/addEmptyExports.js +1 -1
- package/lib/cli/configure/addEmptyExports.js.map +2 -2
- package/lib/cli/configure/analyseDependencies.js +1 -1
- package/lib/cli/configure/analyseDependencies.js.map +2 -2
- package/lib/cli/configure/analysis/files.js.map +1 -1
- package/lib/cli/configure/analysis/package.js.map +1 -1
- package/lib/cli/configure/analysis/project.js +7 -3
- package/lib/cli/configure/analysis/project.js.map +2 -2
- package/lib/cli/configure/ensureTemplateCompletion.js +1 -1
- package/lib/cli/configure/ensureTemplateCompletion.js.map +2 -2
- package/lib/cli/configure/getEntryPoint.js +3 -0
- package/lib/cli/configure/getEntryPoint.js.map +3 -3
- package/lib/cli/configure/index.js.map +1 -1
- package/lib/cli/configure/modules/jest.js +2 -2
- package/lib/cli/configure/modules/jest.js.map +2 -2
- package/lib/cli/configure/modules/skubaDive.js.map +1 -1
- package/lib/cli/configure/modules/tsconfig.js.map +1 -1
- package/lib/cli/configure/patchRenovateConfig.js +9 -4
- package/lib/cli/configure/patchRenovateConfig.js.map +2 -2
- package/lib/cli/configure/patchServerListener.js +1 -1
- package/lib/cli/configure/patchServerListener.js.map +2 -2
- package/lib/cli/configure/processing/ignoreFile.js.map +1 -1
- package/lib/cli/configure/processing/javascript.js.map +1 -1
- package/lib/cli/configure/processing/json.d.ts +1 -1
- package/lib/cli/configure/processing/json.js.map +1 -1
- package/lib/cli/configure/processing/module.js.map +1 -1
- package/lib/cli/configure/processing/package.d.ts +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/processing/typescript.js +14 -6
- package/lib/cli/configure/processing/typescript.js.map +2 -2
- package/lib/cli/configure/refreshIgnoreFiles.js.map +1 -1
- package/lib/cli/configure/types.d.ts +1 -1
- package/lib/cli/configure/types.js.map +1 -1
- package/lib/cli/init/getConfig.js +4 -1
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/init/git.js.map +1 -1
- package/lib/cli/init/index.js.map +1 -1
- package/lib/cli/init/prompts.js +1 -1
- package/lib/cli/init/prompts.js.map +2 -2
- package/lib/cli/init/writePackageJson.js +1 -1
- package/lib/cli/init/writePackageJson.js.map +2 -2
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +2 -2
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -1
- package/lib/cli/lint/annotate/github/index.js.map +1 -1
- package/lib/cli/lint/annotate/github/tsc.js +1 -1
- package/lib/cli/lint/annotate/github/tsc.js.map +2 -2
- package/lib/cli/lint/autofix.js +6 -0
- package/lib/cli/lint/autofix.js.map +2 -2
- package/lib/cli/lint/external.js.map +1 -1
- package/lib/cli/lint/internal.js.map +1 -1
- package/lib/cli/lint/tsc.js.map +1 -1
- package/lib/cli/test/reporters/github/annotations.js +1 -1
- package/lib/cli/test/reporters/github/annotations.js.map +2 -2
- package/lib/cli/test/reporters/github/index.js +0 -2
- package/lib/cli/test/reporters/github/index.js.map +1 -1
- package/lib/skuba.js +1 -0
- package/lib/skuba.js.map +2 -2
- package/lib/utils/args.d.ts +1 -1
- package/lib/utils/args.js.map +2 -2
- package/lib/utils/command.js +1 -1
- package/lib/utils/command.js.map +2 -2
- package/lib/utils/copy.d.ts +1 -0
- package/lib/utils/copy.js +6 -1
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/dir.d.ts +3 -2
- package/lib/utils/dir.js +6 -6
- package/lib/utils/dir.js.map +2 -2
- package/lib/utils/exec.js.map +1 -1
- package/lib/utils/logging.js.map +1 -1
- package/lib/utils/logo.js.map +1 -1
- package/lib/utils/manifest.d.ts +1 -0
- package/lib/utils/manifest.js +8 -2
- package/lib/utils/manifest.js.map +2 -2
- package/lib/utils/validation.d.ts +2 -2
- package/lib/utils/validation.js.map +2 -2
- package/lib/utils/version.js.map +1 -1
- package/lib/utils/wait.js.map +1 -1
- package/lib/utils/worker.js.map +1 -1
- package/lib/wrapper/functionHandler.js.map +1 -1
- package/lib/wrapper/http.js.map +1 -1
- package/lib/wrapper/index.js.map +1 -1
- package/lib/wrapper/main.js.map +2 -2
- package/lib/wrapper/requestListener.js +3 -0
- package/lib/wrapper/requestListener.js.map +2 -2
- package/package.json +28 -25
- package/template/base/.github/CODEOWNERS +0 -4
- package/template/base/_.prettierignore +0 -13
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/gantry.apply.yml +0 -2
- package/template/express-rest-api/package.json +2 -2
- package/template/express-rest-api/src/api/healthCheck.ts +1 -1
- package/template/express-rest-api/src/api/smokeTest.ts +1 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/package.json +1 -1
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/gantry.apply.yml +0 -2
- package/template/koa-rest-api/package.json +7 -7
- package/template/koa-rest-api/src/api/healthCheck.ts +1 -1
- package/template/koa-rest-api/src/api/jobs/getJobs.ts +1 -1
- package/template/koa-rest-api/src/api/jobs/postJob.ts +1 -1
- package/template/koa-rest-api/src/api/smokeTest.ts +1 -1
- package/template/koa-rest-api/src/framework/server.test.ts +1 -1
- package/template/koa-rest-api/src/framework/validation.ts +2 -2
- package/template/koa-rest-api/src/storage/jobs.ts +1 -1
- package/template/koa-rest-api/src/testing/server.ts +2 -2
- package/template/koa-rest-api/src/testing/types.ts +1 -1
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker/package.json +9 -9
- package/template/lambda-sqs-worker/src/app.test.ts +1 -1
- package/template/lambda-sqs-worker/src/app.ts +10 -5
- package/template/lambda-sqs-worker/src/framework/handler.test.ts +4 -4
- package/template/lambda-sqs-worker/src/framework/handler.ts +1 -1
- package/template/lambda-sqs-worker/src/framework/validation.ts +1 -1
- package/template/lambda-sqs-worker/src/mapping/jobScorer.ts +5 -2
- package/template/lambda-sqs-worker/src/services/jobScorer.ts +6 -6
- package/template/lambda-sqs-worker/src/testing/handler.ts +3 -3
- package/template/lambda-sqs-worker/src/testing/logging.ts +3 -0
- package/template/lambda-sqs-worker/src/testing/types.ts +1 -1
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/src/app.ts +1 -1
- package/template/oss-npm-package/.github/workflows/release.yml +1 -0
- package/template/oss-npm-package/_package.json +4 -1
- package/template/private-npm-package/_package.json +1 -1
|
@@ -40,15 +40,15 @@ var import_logging = require("../../utils/logging");
|
|
|
40
40
|
var import_manifest = require("../../utils/manifest");
|
|
41
41
|
var import_package = require("../configure/processing/package");
|
|
42
42
|
let languages;
|
|
43
|
-
const inferParser = (filepath) => {
|
|
43
|
+
const inferParser = async (filepath) => {
|
|
44
44
|
const filename = import_path.default.basename(filepath).toLowerCase();
|
|
45
|
-
languages ??= (0, import_prettier.getSupportInfo)().languages
|
|
45
|
+
languages ??= (await (0, import_prettier.getSupportInfo)()).languages;
|
|
46
46
|
const firstLanguage = languages.find(
|
|
47
47
|
(language) => language.extensions?.some((extension) => filename.endsWith(extension)) || language.filenames?.some((name) => name.toLowerCase() === filename)
|
|
48
48
|
);
|
|
49
49
|
return firstLanguage?.parsers[0];
|
|
50
50
|
};
|
|
51
|
-
const isPackageJsonOk = ({
|
|
51
|
+
const isPackageJsonOk = async ({
|
|
52
52
|
data,
|
|
53
53
|
filepath
|
|
54
54
|
}) => {
|
|
@@ -57,16 +57,16 @@ const isPackageJsonOk = ({
|
|
|
57
57
|
}
|
|
58
58
|
try {
|
|
59
59
|
const packageJson = (0, import_package.parsePackage)(data);
|
|
60
|
-
return !packageJson || (0, import_package.formatPackage)(packageJson) === data;
|
|
60
|
+
return !packageJson || await (0, import_package.formatPackage)(packageJson) === data;
|
|
61
61
|
} catch {
|
|
62
62
|
}
|
|
63
63
|
return true;
|
|
64
64
|
};
|
|
65
|
-
const formatOrLintFile = ({ data, filepath, options }, mode, result) => {
|
|
65
|
+
const formatOrLintFile = async ({ data, filepath, options }, mode, result) => {
|
|
66
66
|
if (mode === "lint") {
|
|
67
67
|
let ok;
|
|
68
68
|
try {
|
|
69
|
-
ok = (0, import_prettier.check)(data, options) && isPackageJsonOk({ data, filepath });
|
|
69
|
+
ok = await (0, import_prettier.check)(data, options) && await isPackageJsonOk({ data, filepath });
|
|
70
70
|
} catch (err) {
|
|
71
71
|
result.errored.push({ err, filepath });
|
|
72
72
|
return;
|
|
@@ -78,7 +78,7 @@ const formatOrLintFile = ({ data, filepath, options }, mode, result) => {
|
|
|
78
78
|
}
|
|
79
79
|
let formatted;
|
|
80
80
|
try {
|
|
81
|
-
formatted = (0, import_prettier.format)(data, options);
|
|
81
|
+
formatted = await (0, import_prettier.format)(data, options);
|
|
82
82
|
} catch (err) {
|
|
83
83
|
result.errored.push({ err, filepath });
|
|
84
84
|
return;
|
|
@@ -87,7 +87,7 @@ const formatOrLintFile = ({ data, filepath, options }, mode, result) => {
|
|
|
87
87
|
if (import_path.default.basename(filepath) === "package.json") {
|
|
88
88
|
const packageJson = (0, import_package.parsePackage)(formatted);
|
|
89
89
|
if (packageJson) {
|
|
90
|
-
formatted = (0, import_package.formatPackage)(packageJson);
|
|
90
|
+
formatted = await (0, import_package.formatPackage)(packageJson);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
} catch {
|
|
@@ -111,7 +111,10 @@ const runPrettier = async (mode, logger) => {
|
|
|
111
111
|
directory
|
|
112
112
|
);
|
|
113
113
|
logger.debug("Discovering files...");
|
|
114
|
-
const filepaths = await (0, import_dir.crawlDirectory)(directory,
|
|
114
|
+
const filepaths = await (0, import_dir.crawlDirectory)(directory, [
|
|
115
|
+
".gitignore",
|
|
116
|
+
".prettierignore"
|
|
117
|
+
]);
|
|
115
118
|
logger.debug(`Discovered ${(0, import_logging.pluralise)(filepaths.length, "file")}.`);
|
|
116
119
|
const result = {
|
|
117
120
|
count: filepaths.length,
|
|
@@ -121,7 +124,7 @@ const runPrettier = async (mode, logger) => {
|
|
|
121
124
|
};
|
|
122
125
|
logger.debug(mode === "format" ? "Formatting" : "Linting", "files...");
|
|
123
126
|
for (const filepath of filepaths) {
|
|
124
|
-
const parser = inferParser(filepath);
|
|
127
|
+
const parser = await inferParser(filepath);
|
|
125
128
|
logger.debug(filepath);
|
|
126
129
|
logger.debug(" parser:", parser ?? "-");
|
|
127
130
|
if (!parser) {
|
|
@@ -137,7 +140,7 @@ const runPrettier = async (mode, logger) => {
|
|
|
137
140
|
filepath,
|
|
138
141
|
options: { ...config, filepath }
|
|
139
142
|
};
|
|
140
|
-
const formatted = formatOrLintFile(file, mode, result);
|
|
143
|
+
const formatted = await formatOrLintFile(file, mode, result);
|
|
141
144
|
if (typeof formatted === "string") {
|
|
142
145
|
await import_fs_extra.default.promises.writeFile(filepath, formatted);
|
|
143
146
|
}
|
|
@@ -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
|
|
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,
|
|
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 = async (\n filepath: string,\n): Promise<string | undefined> => {\n const filename = path.basename(filepath).toLowerCase();\n\n languages ??= (await getSupportInfo()).languages;\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 = async ({\n data,\n filepath,\n}: {\n data: string;\n filepath: string;\n}): Promise<boolean> => {\n if (path.basename(filepath) !== 'package.json') {\n return true;\n }\n\n try {\n const packageJson = parsePackage(data);\n\n return !packageJson || (await 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 = async (\n { data, filepath, options }: File,\n mode: 'format' | 'lint',\n result: Result,\n): Promise<string | undefined> => {\n if (mode === 'lint') {\n let ok: boolean;\n try {\n ok =\n (await check(data, options)) &&\n (await 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 = await 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 = await 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 respecting `.gitignore`.\n // This avoids exhibiting different behaviour than a Prettier IDE integration,\n // though it may present headaches if `.gitignore` and `.prettierignore` rules\n // conflict.\n const filepaths = await crawlDirectory(directory, [\n '.gitignore',\n '.prettierignore',\n ]);\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 = await 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 = await 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": ";;;;;;;;;;;;;;;;;;;;;;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M,CAAC,QAAQ,IAAI,IAAI,MAAM,QAAQ,IAAI;AAAA,UACvC,+BAAc,QAAQ;AAAA,MACtB,gBAAAC,QAAG,SAAS,SAAS,UAAU,OAAO;AAAA,IACxC,CAAC;AAED,UAAM,OAAa;AAAA,MACjB;AAAA,MACA;AAAA,MACA,SAAS,EAAE,GAAG,QAAQ,SAAS;AAAA,IACjC;AAEA,UAAM,YAAY,MAAM,iBAAiB,MAAM,MAAM,MAAM;AAE3D,QAAI,OAAO,cAAc,UAAU;AACjC,YAAM,gBAAAA,QAAG,SAAS,UAAU,UAAU,SAAS;AAAA,IACjD;AAAA,EACF;AAEA,QAAM,MAAM,QAAQ,OAAO,OAAO;AAElC,SAAO;AAAA,IACL,iBAAa;AAAA,MACX,OAAO,QAAQ,OAAO,SAAS;AAAA,MAC/B;AAAA,IACF,CAAC,OAAO,OAAO,OAAO,OAAO,GAAG,CAAC;AAAA,EACnC;AAEA,MAAI,OAAO,QAAQ,QAAQ;AACzB,WAAO,MAAM,iBAAa,0BAAU,OAAO,QAAQ,QAAQ,MAAM,CAAC,GAAG;AACrE,eAAW,YAAY,OAAO,SAAS;AACrC,aAAO,KAAK,QAAQ;AAAA,IACtB;AAAA,EACF;AAEA,MAAI,OAAO,QAAQ,QAAQ;AACzB,WAAO,MAAM,eAAW,0BAAU,OAAO,QAAQ,QAAQ,MAAM,CAAC,GAAG;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
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Color } from 'chalk';
|
|
2
|
+
import { type Logger } from '../../utils/logging';
|
|
3
|
+
export declare const copyAssets: (destinationDir: string, logger?: Logger) => Promise<void>;
|
|
4
|
+
interface CopyAssetsConfig {
|
|
5
|
+
outDir: string;
|
|
6
|
+
name: string;
|
|
7
|
+
prefixColor: typeof Color;
|
|
8
|
+
}
|
|
9
|
+
export declare const copyAssetsConcurrently: (configs: CopyAssetsConfig[]) => Promise<void>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var assets_exports = {};
|
|
30
|
+
__export(assets_exports, {
|
|
31
|
+
copyAssets: () => copyAssets,
|
|
32
|
+
copyAssetsConcurrently: () => copyAssetsConcurrently
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(assets_exports);
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_chalk = __toESM(require("chalk"));
|
|
37
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
38
|
+
var import_copy = require("../../utils/copy");
|
|
39
|
+
var import_dir = require("../../utils/dir");
|
|
40
|
+
var import_logging = require("../../utils/logging");
|
|
41
|
+
var import_manifest = require("../../utils/manifest");
|
|
42
|
+
const copyAssets = async (destinationDir, logger = import_logging.log) => {
|
|
43
|
+
const manifest = await (0, import_manifest.getConsumerManifest)();
|
|
44
|
+
if (!manifest) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const assets = await (0, import_manifest.getPropFromConsumerManifest)("assets");
|
|
48
|
+
if (!assets) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const entryPoint = await (0, import_manifest.getEntryPointFromManifest)();
|
|
52
|
+
if (!entryPoint) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const pathSegments = entryPoint.split(import_path.default.sep);
|
|
56
|
+
const srcDir = pathSegments.length > 1 && pathSegments[0] || "";
|
|
57
|
+
const resolvedSrcDir = import_path.default.resolve(import_path.default.dirname(manifest.path), srcDir);
|
|
58
|
+
const resolvedDestinationDir = import_path.default.resolve(
|
|
59
|
+
import_path.default.dirname(manifest.path),
|
|
60
|
+
destinationDir
|
|
61
|
+
);
|
|
62
|
+
const allFiles = await (0, import_dir.crawlDirectory)(resolvedSrcDir);
|
|
63
|
+
const filesByPattern = (0, import_dir.buildPatternToFilepathMap)(assets, allFiles, {
|
|
64
|
+
cwd: resolvedSrcDir,
|
|
65
|
+
dot: true
|
|
66
|
+
});
|
|
67
|
+
const matchedFiles = Array.from(
|
|
68
|
+
new Set(Object.values(filesByPattern).flat())
|
|
69
|
+
);
|
|
70
|
+
await Promise.all(
|
|
71
|
+
matchedFiles.map(async (filename) => {
|
|
72
|
+
logger.subtle(`Copying ${filename}`);
|
|
73
|
+
await import_fs_extra.default.promises.mkdir(
|
|
74
|
+
import_path.default.dirname(import_path.default.join(resolvedDestinationDir, filename)),
|
|
75
|
+
{ recursive: true }
|
|
76
|
+
);
|
|
77
|
+
await (0, import_copy.copyFile)(
|
|
78
|
+
import_path.default.join(resolvedSrcDir, filename),
|
|
79
|
+
import_path.default.join(resolvedDestinationDir, filename),
|
|
80
|
+
{ processors: [] }
|
|
81
|
+
);
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
const copyAssetsConcurrently = async (configs) => {
|
|
86
|
+
const maxNameLength = configs.reduce(
|
|
87
|
+
(length, command) => Math.max(length, command.name.length),
|
|
88
|
+
0
|
|
89
|
+
);
|
|
90
|
+
await Promise.all(
|
|
91
|
+
configs.map(
|
|
92
|
+
({ outDir, name, prefixColor }) => copyAssets(
|
|
93
|
+
outDir,
|
|
94
|
+
(0, import_logging.createLogger)(
|
|
95
|
+
false,
|
|
96
|
+
import_chalk.default[prefixColor](`${name.padEnd(maxNameLength)} \u2502`)
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
copyAssets,
|
|
105
|
+
copyAssetsConcurrently
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/cli/build/assets.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport type { Color } from 'chalk';\nimport chalk from 'chalk';\nimport fs from 'fs-extra';\n\nimport { copyFile } from '../../utils/copy';\nimport { buildPatternToFilepathMap, crawlDirectory } from '../../utils/dir';\nimport { type Logger, createLogger, log } from '../../utils/logging';\nimport {\n getConsumerManifest,\n getEntryPointFromManifest,\n getPropFromConsumerManifest,\n} from '../../utils/manifest';\n\nexport const copyAssets = async (\n destinationDir: string,\n logger: Logger = log,\n) => {\n const manifest = await getConsumerManifest();\n if (!manifest) {\n return;\n }\n\n const assets = await getPropFromConsumerManifest<string, string[]>('assets');\n if (!assets) {\n return;\n }\n\n const entryPoint = await getEntryPointFromManifest();\n if (!entryPoint) {\n return;\n }\n\n const pathSegments = entryPoint.split(path.sep);\n const srcDir = (pathSegments.length > 1 && pathSegments[0]) || '';\n const resolvedSrcDir = path.resolve(path.dirname(manifest.path), srcDir);\n const resolvedDestinationDir = path.resolve(\n path.dirname(manifest.path),\n destinationDir,\n );\n\n const allFiles = await crawlDirectory(resolvedSrcDir);\n const filesByPattern = buildPatternToFilepathMap(assets, allFiles, {\n cwd: resolvedSrcDir,\n dot: true,\n });\n const matchedFiles = Array.from(\n new Set(Object.values(filesByPattern).flat()),\n );\n\n await Promise.all(\n matchedFiles.map(async (filename) => {\n logger.subtle(`Copying ${filename}`);\n\n await fs.promises.mkdir(\n path.dirname(path.join(resolvedDestinationDir, filename)),\n { recursive: true },\n );\n await copyFile(\n path.join(resolvedSrcDir, filename),\n path.join(resolvedDestinationDir, filename),\n { processors: [] },\n );\n }),\n );\n};\n\ninterface CopyAssetsConfig {\n outDir: string;\n name: string;\n prefixColor: typeof Color;\n}\n\nexport const copyAssetsConcurrently = async (configs: CopyAssetsConfig[]) => {\n const maxNameLength = configs.reduce(\n (length, command) => Math.max(length, command.name.length),\n 0,\n );\n\n await Promise.all(\n configs.map(({ outDir, name, prefixColor }) =>\n copyAssets(\n outDir,\n createLogger(\n false,\n chalk[prefixColor](`${name.padEnd(maxNameLength)} \u2502`),\n ),\n ),\n ),\n );\n};\n"],
|
|
5
|
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QACJ,YAAAA,QAAK,KAAK,gBAAgB,QAAQ;AAAA,QAClC,YAAAA,QAAK,KAAK,wBAAwB,QAAQ;AAAA,QAC1C,EAAE,YAAY,CAAC,EAAE;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAQO,MAAM,yBAAyB,OAAO,YAAgC;AAC3E,QAAM,gBAAgB,QAAQ;AAAA,IAC5B,CAAC,QAAQ,YAAY,KAAK,IAAI,QAAQ,QAAQ,KAAK,MAAM;AAAA,IACzD;AAAA,EACF;AAEA,QAAM,QAAQ;AAAA,IACZ,QAAQ;AAAA,MAAI,CAAC,EAAE,QAAQ,MAAM,YAAY,MACvC;AAAA,QACE;AAAA,YACA;AAAA,UACE;AAAA,UACA,aAAAE,QAAM,WAAW,EAAE,GAAG,KAAK,OAAO,aAAa,CAAC,SAAI;AAAA,QACtD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["path", "fs", "chalk"]
|
|
7
|
+
}
|
package/lib/cli/build/esbuild.js
CHANGED
|
@@ -34,15 +34,10 @@ module.exports = __toCommonJS(esbuild_exports);
|
|
|
34
34
|
var import_util = require("util");
|
|
35
35
|
var import_tsconfig_paths = __toESM(require("@esbuild-plugins/tsconfig-paths"));
|
|
36
36
|
var import_esbuild = require("esbuild");
|
|
37
|
-
var import_typescript =
|
|
37
|
+
var import_typescript = require("typescript");
|
|
38
38
|
var import_logging = require("../../utils/logging");
|
|
39
39
|
var import_args = require("./args");
|
|
40
40
|
var import_tsc = require("./tsc");
|
|
41
|
-
const formatHost = {
|
|
42
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
43
|
-
getCurrentDirectory: import_typescript.default.sys.getCurrentDirectory.bind(void 0),
|
|
44
|
-
getNewLine: () => import_typescript.default.sys.newLine
|
|
45
|
-
};
|
|
46
41
|
const esbuild = async ({ debug }, args = process.argv.slice(2)) => {
|
|
47
42
|
const log = (0, import_logging.createLogger)(debug);
|
|
48
43
|
const tscArgs = (0, import_args.parseTscArgs)(args);
|
|
@@ -53,42 +48,8 @@ const esbuild = async ({ debug }, args = process.argv.slice(2)) => {
|
|
|
53
48
|
process.exitCode = 1;
|
|
54
49
|
return;
|
|
55
50
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"tsconfig",
|
|
59
|
-
...tscArgs.project ? ["--project", tscArgs.project] : []
|
|
60
|
-
)
|
|
61
|
-
);
|
|
62
|
-
log.debug(tscArgs.pathname);
|
|
63
|
-
const tsconfigFile = import_typescript.default.findConfigFile(
|
|
64
|
-
tscArgs.dirname,
|
|
65
|
-
import_typescript.default.sys.fileExists.bind(void 0),
|
|
66
|
-
tscArgs.basename
|
|
67
|
-
);
|
|
68
|
-
if (!tsconfigFile) {
|
|
69
|
-
log.err(`Could not find ${tscArgs.pathname}.`);
|
|
70
|
-
process.exitCode = 1;
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const readConfigFile = import_typescript.default.readConfigFile(
|
|
74
|
-
tsconfigFile,
|
|
75
|
-
import_typescript.default.sys.readFile.bind(void 0)
|
|
76
|
-
);
|
|
77
|
-
if (readConfigFile.error) {
|
|
78
|
-
log.err(`Could not read ${tscArgs.pathname}.`);
|
|
79
|
-
log.subtle(import_typescript.default.formatDiagnostic(readConfigFile.error, formatHost));
|
|
80
|
-
process.exitCode = 1;
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const parsedCommandLine = import_typescript.default.parseJsonConfigFileContent(
|
|
84
|
-
readConfigFile.config,
|
|
85
|
-
import_typescript.default.sys,
|
|
86
|
-
tscArgs.dirname
|
|
87
|
-
);
|
|
88
|
-
if (parsedCommandLine.errors.length) {
|
|
89
|
-
log.err(`Could not parse ${tscArgs.pathname}.`);
|
|
90
|
-
log.subtle(import_typescript.default.formatDiagnostics(parsedCommandLine.errors, formatHost));
|
|
91
|
-
process.exitCode = 1;
|
|
51
|
+
const parsedCommandLine = (0, import_tsc.readTsconfig)(args, log);
|
|
52
|
+
if (!parsedCommandLine || process.exitCode) {
|
|
92
53
|
return;
|
|
93
54
|
}
|
|
94
55
|
const { fileNames: entryPoints, options: compilerOptions } = parsedCommandLine;
|
|
@@ -113,6 +74,10 @@ const esbuild = async ({ debug }, args = process.argv.slice(2)) => {
|
|
|
113
74
|
})
|
|
114
75
|
],
|
|
115
76
|
sourcemap: compilerOptions.sourceMap,
|
|
77
|
+
// TODO: as of 0.18, the esbuild CLI no longer infers the target property to
|
|
78
|
+
// avoid ambiguity where multiple `tsconfig.json`s are involved in a build.
|
|
79
|
+
// This would be unusual for a typical SEEK project but we can still explore
|
|
80
|
+
// an explicit setting once we implement `skuba.config.ts` (#1167).
|
|
116
81
|
target: compilerOptions.target ? import_typescript.ScriptTarget[compilerOptions.target].toLocaleLowerCase() : void 0,
|
|
117
82
|
tsconfig: tscArgs.pathname
|
|
118
83
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/build/esbuild.ts"],
|
|
4
|
-
"sourcesContent": ["import { inspect } from 'util';\n\nimport tsconfigPaths from '@esbuild-plugins/tsconfig-paths';\nimport { build } from 'esbuild';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,4BAA0B;AAC1B,qBAAsB;AACtB,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport tsconfigPaths from '@esbuild-plugins/tsconfig-paths';\nimport { build } from 'esbuild';\nimport { ModuleKind, ModuleResolutionKind, ScriptTarget } from 'typescript';\n\nimport { createLogger } from '../../utils/logging';\n\nimport { parseTscArgs } from './args';\nimport { readTsconfig, tsc } from './tsc';\n\ninterface EsbuildParameters {\n debug: boolean;\n}\n\nexport const esbuild = async (\n { debug }: EsbuildParameters,\n args = process.argv.slice(2),\n) => {\n const log = createLogger(debug);\n\n const tscArgs = parseTscArgs(args);\n\n if (tscArgs.build) {\n log.err(\n 'skuba does not currently support the tsc --build flag with esbuild',\n );\n process.exitCode = 1;\n return;\n }\n\n const parsedCommandLine = readTsconfig(args, log);\n\n if (!parsedCommandLine || process.exitCode) {\n return;\n }\n\n const { fileNames: entryPoints, options: compilerOptions } =\n parsedCommandLine;\n\n log.debug(log.bold('Files'));\n entryPoints.forEach((filepath) => log.debug(filepath));\n\n log.debug(log.bold('Compiler options'));\n log.debug(inspect(compilerOptions));\n\n const start = process.hrtime.bigint();\n\n // TODO: support `bundle`, `minify`, `splitting`, `treeShaking`\n const bundle = false;\n\n await build({\n bundle,\n entryPoints,\n format: compilerOptions.module === ModuleKind.CommonJS ? 'cjs' : undefined,\n outdir: compilerOptions.outDir,\n logLevel: debug ? 'debug' : 'info',\n logLimit: 0,\n platform:\n compilerOptions.moduleResolution === ModuleResolutionKind.NodeJs\n ? 'node'\n : undefined,\n plugins: bundle\n ? []\n : [\n // evanw/esbuild#394\n tsconfigPaths({\n tsconfig: { baseUrl: compilerOptions.baseUrl, compilerOptions },\n }),\n ],\n sourcemap: compilerOptions.sourceMap,\n // TODO: as of 0.18, the esbuild CLI no longer infers the target property to\n // avoid ambiguity where multiple `tsconfig.json`s are involved in a build.\n // This would be unusual for a typical SEEK project but we can still explore\n // an explicit setting once we implement `skuba.config.ts` (#1167).\n target: compilerOptions.target\n ? ScriptTarget[compilerOptions.target].toLocaleLowerCase()\n : undefined,\n tsconfig: tscArgs.pathname,\n });\n\n const end = process.hrtime.bigint();\n\n log.plain(`Built in ${log.timing(start, end)}.`);\n\n if (compilerOptions.declaration) {\n await tsc([\n '--declaration',\n '--emitDeclarationOnly',\n ...(tscArgs.project ? ['--project', tscArgs.project] : []),\n ]);\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,4BAA0B;AAC1B,qBAAsB;AACtB,wBA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AAM,QAAQ,OAAO,OAAO;AAElC,MAAI,MAAM,YAAY,IAAI,OAAO,OAAO,GAAG,CAAC,GAAG;AAE/C,MAAI,gBAAgB,aAAa;AAC/B,cAAM,gBAAI;AAAA,MACR;AAAA,MACA;AAAA,MACA,GAAI,QAAQ,UAAU,CAAC,aAAa,QAAQ,OAAO,IAAI,CAAC;AAAA,IAC1D,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": ["tsconfigPaths"]
|
|
7
7
|
}
|
package/lib/cli/build/index.js
CHANGED
|
@@ -36,6 +36,7 @@ var import_args = require("../../utils/args");
|
|
|
36
36
|
var import_logging = require("../../utils/logging");
|
|
37
37
|
var import_manifest = require("../../utils/manifest");
|
|
38
38
|
var import_addEmptyExports = require("../configure/addEmptyExports");
|
|
39
|
+
var import_assets = require("./assets");
|
|
39
40
|
var import_esbuild = require("./esbuild");
|
|
40
41
|
var import_tsc = require("./tsc");
|
|
41
42
|
const build = async (args = process.argv.slice(2)) => {
|
|
@@ -46,13 +47,13 @@ const build = async (args = process.argv.slice(2)) => {
|
|
|
46
47
|
const debug = (0, import_args.hasDebugFlag)(args);
|
|
47
48
|
import_logging.log.plain(import_chalk.default.yellow("esbuild"));
|
|
48
49
|
await (0, import_esbuild.esbuild)({ debug }, args);
|
|
49
|
-
|
|
50
|
+
break;
|
|
50
51
|
}
|
|
51
52
|
case void 0:
|
|
52
53
|
case "tsc": {
|
|
53
54
|
import_logging.log.plain(import_chalk.default.blue("tsc"));
|
|
54
55
|
await (0, import_tsc.tsc)(args);
|
|
55
|
-
|
|
56
|
+
break;
|
|
56
57
|
}
|
|
57
58
|
default: {
|
|
58
59
|
import_logging.log.err(
|
|
@@ -65,6 +66,15 @@ const build = async (args = process.argv.slice(2)) => {
|
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
const parsedCommandLine = (0, import_tsc.readTsconfig)(args, import_logging.log);
|
|
70
|
+
if (!parsedCommandLine || process.exitCode) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const { options: compilerOptions } = parsedCommandLine;
|
|
74
|
+
if (!compilerOptions.outDir) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
await (0, import_assets.copyAssets)(compilerOptions.outDir);
|
|
68
78
|
};
|
|
69
79
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
80
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/build/index.ts"],
|
|
4
|
-
"sourcesContent": ["import chalk from 'chalk';\n\nimport { hasDebugFlag } from '../../utils/args';\nimport { log } from '../../utils/logging';\nimport { getStringPropFromConsumerManifest } from '../../utils/manifest';\nimport { tryAddEmptyExports } from '../configure/addEmptyExports';\n\nimport { esbuild } from './esbuild';\nimport { tsc } from './tsc';\n\nexport const build = async (args = process.argv.slice(2)) => {\n await tryAddEmptyExports();\n\n // TODO: define a unified `package.json#/skuba` schema and parser so we don't\n // need all these messy lookups.\n const tool = await getStringPropFromConsumerManifest('build');\n\n switch (tool) {\n case 'esbuild': {\n const debug = hasDebugFlag(args);\n\n log.plain(chalk.yellow('esbuild'));\n await esbuild({ debug }, args);\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,kBAA6B;AAC7B,qBAAoB;AACpB,sBAAkD;AAClD,6BAAmC;AAEnC,qBAAwB;AACxB,
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk';\n\nimport { hasDebugFlag } from '../../utils/args';\nimport { log } from '../../utils/logging';\nimport { getStringPropFromConsumerManifest } from '../../utils/manifest';\nimport { tryAddEmptyExports } from '../configure/addEmptyExports';\n\nimport { copyAssets } from './assets';\nimport { esbuild } from './esbuild';\nimport { readTsconfig, tsc } from './tsc';\n\nexport const build = async (args = process.argv.slice(2)) => {\n await tryAddEmptyExports();\n\n // TODO: define a unified `package.json#/skuba` schema and parser so we don't\n // need all these messy lookups.\n const tool = await getStringPropFromConsumerManifest('build');\n\n switch (tool) {\n case 'esbuild': {\n const debug = hasDebugFlag(args);\n\n log.plain(chalk.yellow('esbuild'));\n await esbuild({ debug }, args);\n break;\n }\n\n // TODO: flip the default case over to `esbuild` in skuba vNext.\n case undefined:\n case 'tsc': {\n log.plain(chalk.blue('tsc'));\n await tsc(args);\n break;\n }\n\n default: {\n log.err(\n 'We don\u2019t support the build tool specified in your',\n log.bold('package.json'),\n 'yet:',\n );\n log.err(log.subtle(JSON.stringify({ skuba: { build: tool } }, null, 2)));\n process.exitCode = 1;\n return;\n }\n }\n\n const parsedCommandLine = readTsconfig(args, log);\n\n if (!parsedCommandLine || process.exitCode) {\n return;\n }\n\n const { options: compilerOptions } = parsedCommandLine;\n\n if (!compilerOptions.outDir) {\n return;\n }\n\n await copyAssets(compilerOptions.outDir);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,kBAA6B;AAC7B,qBAAoB;AACpB,sBAAkD;AAClD,6BAAmC;AAEnC,oBAA2B;AAC3B,qBAAwB;AACxB,iBAAkC;AAE3B,MAAM,QAAQ,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAC3D,YAAM,2CAAmB;AAIzB,QAAM,OAAO,UAAM,mDAAkC,OAAO;AAE5D,UAAQ,MAAM;AAAA,IACZ,KAAK,WAAW;AACd,YAAM,YAAQ,0BAAa,IAAI;AAE/B,yBAAI,MAAM,aAAAA,QAAM,OAAO,SAAS,CAAC;AACjC,gBAAM,wBAAQ,EAAE,MAAM,GAAG,IAAI;AAC7B;AAAA,IACF;AAAA,IAGA,KAAK;AAAA,IACL,KAAK,OAAO;AACV,yBAAI,MAAM,aAAAA,QAAM,KAAK,KAAK,CAAC;AAC3B,gBAAM,gBAAI,IAAI;AACd;AAAA,IACF;AAAA,IAEA,SAAS;AACP,yBAAI;AAAA,QACF;AAAA,QACA,mBAAI,KAAK,cAAc;AAAA,QACvB;AAAA,MACF;AACA,yBAAI,IAAI,mBAAI,OAAO,KAAK,UAAU,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;AACvE,cAAQ,WAAW;AACnB;AAAA,IACF;AAAA,EACF;AAEA,QAAM,wBAAoB,yBAAa,MAAM,kBAAG;AAEhD,MAAI,CAAC,qBAAqB,QAAQ,UAAU;AAC1C;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,gBAAgB,IAAI;AAErC,MAAI,CAAC,gBAAgB,QAAQ;AAC3B;AAAA,EACF;AAEA,YAAM,0BAAW,gBAAgB,MAAM;AACzC;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/lib/cli/build/tsc.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { Logger } from '../../utils/logging';
|
|
1
3
|
export declare const tsc: (args?: string[]) => Promise<import("execa").ExecaReturnValue<string>>;
|
|
4
|
+
export declare const readTsconfig: (args: string[] | undefined, log: Logger) => ts.ParsedCommandLine | undefined;
|
package/lib/cli/build/tsc.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,22 +17,86 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var tsc_exports = {};
|
|
20
30
|
__export(tsc_exports, {
|
|
31
|
+
readTsconfig: () => readTsconfig,
|
|
21
32
|
tsc: () => tsc
|
|
22
33
|
});
|
|
23
34
|
module.exports = __toCommonJS(tsc_exports);
|
|
35
|
+
var import_typescript = __toESM(require("typescript"));
|
|
24
36
|
var import_exec = require("../../utils/exec");
|
|
25
37
|
var import_args = require("./args");
|
|
26
38
|
const DEFAULT_ARGS = ["--project", "tsconfig.build.json"];
|
|
39
|
+
const formatHost = {
|
|
40
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
41
|
+
getCurrentDirectory: import_typescript.default.sys.getCurrentDirectory.bind(void 0),
|
|
42
|
+
getNewLine: () => import_typescript.default.sys.newLine
|
|
43
|
+
};
|
|
44
|
+
const tsconfigCache = /* @__PURE__ */ new Map();
|
|
45
|
+
const computeCacheKey = (args) => Array.from(args).sort().toString();
|
|
27
46
|
const tsc = async (args = process.argv.slice(2)) => {
|
|
28
47
|
const tscArgs = (0, import_args.parseTscArgs)(args);
|
|
29
48
|
const defaultArgs = tscArgs.build || tscArgs.project ? [] : DEFAULT_ARGS;
|
|
30
49
|
return (0, import_exec.exec)("tsc", ...defaultArgs, ...args);
|
|
31
50
|
};
|
|
51
|
+
const readTsconfig = (args = process.argv.slice(2), log) => {
|
|
52
|
+
const tscArgs = (0, import_args.parseTscArgs)(args);
|
|
53
|
+
let parsedCommandLine = tsconfigCache.get(computeCacheKey(args));
|
|
54
|
+
if (!parsedCommandLine) {
|
|
55
|
+
log.debug(
|
|
56
|
+
log.bold(
|
|
57
|
+
"tsconfig",
|
|
58
|
+
...tscArgs.project ? ["--project", tscArgs.project] : []
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
log.debug(tscArgs.pathname);
|
|
62
|
+
const tsconfigFile = import_typescript.default.findConfigFile(
|
|
63
|
+
tscArgs.dirname,
|
|
64
|
+
import_typescript.default.sys.fileExists.bind(void 0),
|
|
65
|
+
tscArgs.basename
|
|
66
|
+
);
|
|
67
|
+
if (!tsconfigFile) {
|
|
68
|
+
log.err(`Could not find ${tscArgs.pathname}.`);
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const readConfigFile = import_typescript.default.readConfigFile(
|
|
73
|
+
tsconfigFile,
|
|
74
|
+
import_typescript.default.sys.readFile.bind(void 0)
|
|
75
|
+
);
|
|
76
|
+
if (readConfigFile.error) {
|
|
77
|
+
log.err(`Could not read ${tscArgs.pathname}.`);
|
|
78
|
+
log.subtle(import_typescript.default.formatDiagnostic(readConfigFile.error, formatHost));
|
|
79
|
+
process.exitCode = 1;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
parsedCommandLine = import_typescript.default.parseJsonConfigFileContent(
|
|
83
|
+
readConfigFile.config,
|
|
84
|
+
import_typescript.default.sys,
|
|
85
|
+
tscArgs.dirname
|
|
86
|
+
);
|
|
87
|
+
tsconfigCache.set(computeCacheKey(args), parsedCommandLine);
|
|
88
|
+
}
|
|
89
|
+
if (parsedCommandLine.errors.length) {
|
|
90
|
+
log.err(`Could not parse ${tscArgs.pathname}.`);
|
|
91
|
+
log.subtle(import_typescript.default.formatDiagnostics(parsedCommandLine.errors, formatHost));
|
|
92
|
+
process.exitCode = 1;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
return parsedCommandLine;
|
|
96
|
+
};
|
|
32
97
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
98
|
0 && (module.exports = {
|
|
99
|
+
readTsconfig,
|
|
34
100
|
tsc
|
|
35
101
|
});
|
|
36
102
|
//# sourceMappingURL=tsc.js.map
|
package/lib/cli/build/tsc.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/build/tsc.ts"],
|
|
4
|
-
"sourcesContent": ["import { exec } from '../../utils/exec';\n\nimport { parseTscArgs } from './args';\n\nconst DEFAULT_ARGS = ['--project', 'tsconfig.build.json'] as const;\n\nexport const tsc = async (args = process.argv.slice(2)) => {\n const tscArgs = parseTscArgs(args);\n\n // Build flag is incompatible with project flag.\n const defaultArgs = tscArgs.build || tscArgs.project ? [] : DEFAULT_ARGS;\n\n return exec('tsc', ...defaultArgs, ...args);\n};\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import ts from 'typescript';\n\nimport { exec } from '../../utils/exec';\nimport type { Logger } from '../../utils/logging';\n\nimport { parseTscArgs } from './args';\n\nconst DEFAULT_ARGS = ['--project', 'tsconfig.build.json'] as const;\n\nconst formatHost: ts.FormatDiagnosticsHost = {\n getCanonicalFileName: (fileName) => fileName,\n getCurrentDirectory: ts.sys.getCurrentDirectory.bind(undefined),\n getNewLine: () => ts.sys.newLine,\n};\n\nconst tsconfigCache = new Map<string, ts.ParsedCommandLine>();\nconst computeCacheKey = (args: string[]) => Array.from(args).sort().toString();\n\nexport const tsc = async (args = process.argv.slice(2)) => {\n const tscArgs = parseTscArgs(args);\n\n // Build flag is incompatible with project flag.\n const defaultArgs = tscArgs.build || tscArgs.project ? [] : DEFAULT_ARGS;\n\n return exec('tsc', ...defaultArgs, ...args);\n};\n\nexport const readTsconfig = (args = process.argv.slice(2), log: Logger) => {\n const tscArgs = parseTscArgs(args);\n\n let parsedCommandLine = tsconfigCache.get(computeCacheKey(args));\n\n if (!parsedCommandLine) {\n log.debug(\n log.bold(\n 'tsconfig',\n ...(tscArgs.project ? ['--project', tscArgs.project] : []),\n ),\n );\n log.debug(tscArgs.pathname);\n\n const tsconfigFile = ts.findConfigFile(\n tscArgs.dirname,\n ts.sys.fileExists.bind(undefined),\n tscArgs.basename,\n );\n if (!tsconfigFile) {\n log.err(`Could not find ${tscArgs.pathname}.`);\n process.exitCode = 1;\n return;\n }\n\n const readConfigFile = ts.readConfigFile(\n tsconfigFile,\n ts.sys.readFile.bind(undefined),\n );\n if (readConfigFile.error) {\n log.err(`Could not read ${tscArgs.pathname}.`);\n log.subtle(ts.formatDiagnostic(readConfigFile.error, formatHost));\n process.exitCode = 1;\n return;\n }\n\n parsedCommandLine = ts.parseJsonConfigFileContent(\n readConfigFile.config,\n ts.sys,\n tscArgs.dirname,\n );\n tsconfigCache.set(computeCacheKey(args), parsedCommandLine);\n }\n\n if (parsedCommandLine.errors.length) {\n log.err(`Could not parse ${tscArgs.pathname}.`);\n log.subtle(ts.formatDiagnostics(parsedCommandLine.errors, formatHost));\n process.exitCode = 1;\n return;\n }\n\n return parsedCommandLine;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe;AAEf,kBAAqB;AAGrB,kBAA6B;AAE7B,MAAM,eAAe,CAAC,aAAa,qBAAqB;AAExD,MAAM,aAAuC;AAAA,EAC3C,sBAAsB,CAAC,aAAa;AAAA,EACpC,qBAAqB,kBAAAA,QAAG,IAAI,oBAAoB,KAAK,MAAS;AAAA,EAC9D,YAAY,MAAM,kBAAAA,QAAG,IAAI;AAC3B;AAEA,MAAM,gBAAgB,oBAAI,IAAkC;AAC5D,MAAM,kBAAkB,CAAC,SAAmB,MAAM,KAAK,IAAI,EAAE,KAAK,EAAE,SAAS;AAEtE,MAAM,MAAM,OAAO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AAO,QAAQ;AACnC,QAAI,IAAI,mBAAmB,QAAQ,QAAQ,GAAG;AAC9C,QAAI,OAAO,kBAAAA,QAAG,kBAAkB,kBAAkB,QAAQ,UAAU,CAAC;AACrE,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": ["ts"]
|
|
7
7
|
}
|
package/lib/cli/buildPackage.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(buildPackage_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(buildPackage_exports);
|
|
24
24
|
var import_args = require("../utils/args");
|
|
25
25
|
var import_exec = require("../utils/exec");
|
|
26
|
+
var import_assets = require("./build/assets");
|
|
26
27
|
var import_addEmptyExports = require("./configure/addEmptyExports");
|
|
27
28
|
const buildPackage = async (args = process.argv.slice(2)) => {
|
|
28
29
|
await (0, import_addEmptyExports.tryAddEmptyExports)();
|
|
@@ -48,6 +49,18 @@ const buildPackage = async (args = process.argv.slice(2)) => {
|
|
|
48
49
|
maxProcesses: (0, import_args.hasSerialFlag)(args) ? 1 : void 0
|
|
49
50
|
}
|
|
50
51
|
);
|
|
52
|
+
await (0, import_assets.copyAssetsConcurrently)([
|
|
53
|
+
{
|
|
54
|
+
outDir: "lib-commonjs",
|
|
55
|
+
name: "commonjs",
|
|
56
|
+
prefixColor: "green"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
outDir: "lib-es2015",
|
|
60
|
+
name: "es2015",
|
|
61
|
+
prefixColor: "yellow"
|
|
62
|
+
}
|
|
63
|
+
]);
|
|
51
64
|
};
|
|
52
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
66
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cli/buildPackage.ts"],
|
|
4
|
-
"sourcesContent": ["import { hasSerialFlag } from '../utils/args';\nimport { execConcurrently } from '../utils/exec';\n\nimport { tryAddEmptyExports } from './configure/addEmptyExports';\n\nexport const buildPackage = async (args = process.argv.slice(2)) => {\n await tryAddEmptyExports();\n\n await execConcurrently(\n [\n {\n command:\n 'tsc --module CommonJS --outDir lib-commonjs --project tsconfig.build.json',\n name: 'commonjs',\n prefixColor: 'green',\n },\n {\n command:\n 'tsc --module ES2015 --outDir lib-es2015 --project tsconfig.build.json',\n name: 'es2015',\n prefixColor: 'yellow',\n },\n {\n command:\n 'tsc --allowJS false --declaration --emitDeclarationOnly --outDir lib-types --project tsconfig.build.json',\n name: 'types',\n prefixColor: 'blue',\n },\n ],\n {\n maxProcesses: hasSerialFlag(args) ? 1 : undefined,\n },\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA8B;AAC9B,kBAAiC;AAEjC,6BAAmC;AAE5B,MAAM,eAAe,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAClE,YAAM,2CAAmB;AAEzB,YAAM;AAAA,IACJ;AAAA,MACE;AAAA,QACE,SACE;AAAA,QACF,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,SACE;AAAA,QACF,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,SACE;AAAA,QACF,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA;AAAA,MACE,kBAAc,2BAAc,IAAI,IAAI,IAAI;AAAA,IAC1C;AAAA,EACF;
|
|
4
|
+
"sourcesContent": ["import { hasSerialFlag } from '../utils/args';\nimport { execConcurrently } from '../utils/exec';\n\nimport { copyAssetsConcurrently } from './build/assets';\nimport { tryAddEmptyExports } from './configure/addEmptyExports';\n\nexport const buildPackage = async (args = process.argv.slice(2)) => {\n await tryAddEmptyExports();\n\n await execConcurrently(\n [\n {\n command:\n 'tsc --module CommonJS --outDir lib-commonjs --project tsconfig.build.json',\n name: 'commonjs',\n prefixColor: 'green',\n },\n {\n command:\n 'tsc --module ES2015 --outDir lib-es2015 --project tsconfig.build.json',\n name: 'es2015',\n prefixColor: 'yellow',\n },\n {\n command:\n 'tsc --allowJS false --declaration --emitDeclarationOnly --outDir lib-types --project tsconfig.build.json',\n name: 'types',\n prefixColor: 'blue',\n },\n ],\n {\n maxProcesses: hasSerialFlag(args) ? 1 : undefined,\n },\n );\n\n await copyAssetsConcurrently([\n {\n outDir: 'lib-commonjs',\n name: 'commonjs',\n prefixColor: 'green',\n },\n {\n outDir: 'lib-es2015',\n name: 'es2015',\n prefixColor: 'yellow',\n },\n ]);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA8B;AAC9B,kBAAiC;AAEjC,oBAAuC;AACvC,6BAAmC;AAE5B,MAAM,eAAe,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAClE,YAAM,2CAAmB;AAEzB,YAAM;AAAA,IACJ;AAAA,MACE;AAAA,QACE,SACE;AAAA,QACF,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,SACE;AAAA,QACF,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,MACA;AAAA,QACE,SACE;AAAA,QACF,MAAM;AAAA,QACN,aAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA;AAAA,MACE,kBAAc,2BAAc,IAAI,IAAI,IAAI;AAAA,IAC1C;AAAA,EACF;AAEA,YAAM,sCAAuB;AAAA,IAC3B;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -52,7 +52,7 @@ const addEmptyExports = async () => {
|
|
|
52
52
|
inputFile.includes("import ") || inputFile.includes("export ")) {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
const data = (0, import_prettier.formatPrettier)([inputFile, "export {}"].join("\n\n"), {
|
|
55
|
+
const data = await (0, import_prettier.formatPrettier)([inputFile, "export {}"].join("\n\n"), {
|
|
56
56
|
parser: "typescript"
|
|
57
57
|
});
|
|
58
58
|
const filepath = import_path.default.join(destinationRoot, filename);
|