@storm-software/workspace-tools 1.19.2 → 1.20.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/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/index.js +300 -212
- package/meta.json +1 -1
- package/package.json +1 -1
- package/src/base/index.js +83 -19
- package/src/executors/tsup/executor.js +6827 -103
- package/src/executors/tsup/schema.d.ts +3 -3
- package/src/executors/tsup-neutral/executor.js +1511 -1591
- package/src/executors/tsup-neutral/schema.d.ts +2 -1
- package/src/executors/tsup-node/executor.js +112 -59
- package/src/executors/tsup-node/schema.d.ts +4 -1
- package/src/generators/config-schema/generator.js +60 -15
- package/src/generators/node-library/generator.js +60 -3
- package/src/generators/preset/generator.js +60 -3
- package/src/utils/index.js +46 -6
package/index.js
CHANGED
|
@@ -104957,6 +104957,9 @@ var require_dist6 = __commonJS({
|
|
|
104957
104957
|
var workspace_tools_exports = {};
|
|
104958
104958
|
__export(workspace_tools_exports, {
|
|
104959
104959
|
WorkspaceStorage: () => WorkspaceStorage,
|
|
104960
|
+
applyDefault: () => applyDefault,
|
|
104961
|
+
applyWorkspaceExecutorTokens: () => applyWorkspaceExecutorTokens,
|
|
104962
|
+
applyWorkspaceGeneratorTokens: () => applyWorkspaceGeneratorTokens,
|
|
104960
104963
|
applyWorkspaceTokens: () => applyWorkspaceTokens,
|
|
104961
104964
|
configSchemaGeneratorFn: () => configSchemaGeneratorFn,
|
|
104962
104965
|
eslintVersion: () => eslintVersion,
|
|
@@ -104984,7 +104987,7 @@ __export(workspace_tools_exports, {
|
|
|
104984
104987
|
tsLibVersion: () => tsLibVersion,
|
|
104985
104988
|
tsNeutralBuildExecutorFn: () => tsNeutralBuildExecutorFn,
|
|
104986
104989
|
tsNodeBuildExecutorFn: () => tsNodeBuildExecutorFn,
|
|
104987
|
-
|
|
104990
|
+
tsupExecutorFn: () => tsupExecutorFn,
|
|
104988
104991
|
tsupVersion: () => tsupVersion,
|
|
104989
104992
|
typesNodeVersion: () => typesNodeVersion,
|
|
104990
104993
|
typescriptVersion: () => typescriptVersion,
|
|
@@ -105239,20 +105242,19 @@ var getWorkspaceRoot2 = () => {
|
|
|
105239
105242
|
};
|
|
105240
105243
|
|
|
105241
105244
|
// packages/workspace-tools/src/utils/apply-workspace-tokens.ts
|
|
105242
|
-
var
|
|
105245
|
+
var applyWorkspaceExecutorTokens = (option, config) => {
|
|
105243
105246
|
let result = option;
|
|
105244
105247
|
if (!result) {
|
|
105245
105248
|
return result;
|
|
105246
105249
|
}
|
|
105247
|
-
const workspaceRoot = getWorkspaceRoot2();
|
|
105248
105250
|
let projectName;
|
|
105249
105251
|
let projectRoot;
|
|
105250
105252
|
let sourceRoot;
|
|
105251
|
-
if (config?.
|
|
105253
|
+
if (config?.projectName) {
|
|
105252
105254
|
const context = config;
|
|
105253
105255
|
projectName = context.projectName;
|
|
105254
|
-
projectRoot = context.
|
|
105255
|
-
sourceRoot = context.
|
|
105256
|
+
projectRoot = context.root;
|
|
105257
|
+
sourceRoot = context.sourceRoot;
|
|
105256
105258
|
} else {
|
|
105257
105259
|
const projectConfig = config;
|
|
105258
105260
|
projectName = projectConfig.name;
|
|
@@ -105269,27 +105271,80 @@ var applyWorkspaceTokens = (option, config) => {
|
|
|
105269
105271
|
result = result.replaceAll("{sourceRoot}", sourceRoot);
|
|
105270
105272
|
}
|
|
105271
105273
|
if (result.includes("{workspaceRoot}")) {
|
|
105272
|
-
result = result.replaceAll(
|
|
105274
|
+
result = result.replaceAll(
|
|
105275
|
+
"{workspaceRoot}",
|
|
105276
|
+
config.workspaceRoot ?? getWorkspaceRoot2()
|
|
105277
|
+
);
|
|
105278
|
+
}
|
|
105279
|
+
return result;
|
|
105280
|
+
};
|
|
105281
|
+
var applyWorkspaceGeneratorTokens = (option, config) => {
|
|
105282
|
+
let result = option;
|
|
105283
|
+
if (!result) {
|
|
105284
|
+
return result;
|
|
105285
|
+
}
|
|
105286
|
+
if (result.includes("{workspaceRoot}")) {
|
|
105287
|
+
result = result.replaceAll(
|
|
105288
|
+
"{workspaceRoot}",
|
|
105289
|
+
config.workspaceRoot ?? getWorkspaceRoot2()
|
|
105290
|
+
);
|
|
105273
105291
|
}
|
|
105274
105292
|
return result;
|
|
105275
105293
|
};
|
|
105294
|
+
var applyWorkspaceTokens = (options, config, tokenizerFn) => {
|
|
105295
|
+
let result = options;
|
|
105296
|
+
if (!result) {
|
|
105297
|
+
return {};
|
|
105298
|
+
}
|
|
105299
|
+
return Object.keys(options).reduce(
|
|
105300
|
+
(ret, option) => {
|
|
105301
|
+
if (options[option] === void 0 || options[option] === null || typeof options[option] === "number" || typeof options[option] === "boolean" || typeof options[option] === "string") {
|
|
105302
|
+
ret[option] = tokenizerFn(option, config);
|
|
105303
|
+
} else if (Array.isArray(options[option])) {
|
|
105304
|
+
ret[option] = options[option].map(
|
|
105305
|
+
(item) => tokenizerFn(item, config)
|
|
105306
|
+
);
|
|
105307
|
+
} else if (typeof options[option] === "object") {
|
|
105308
|
+
ret[option] = tokenizerFn(options[option], config);
|
|
105309
|
+
}
|
|
105310
|
+
return ret;
|
|
105311
|
+
},
|
|
105312
|
+
{}
|
|
105313
|
+
);
|
|
105314
|
+
};
|
|
105276
105315
|
|
|
105277
105316
|
// packages/workspace-tools/src/base/base-executor.ts
|
|
105278
|
-
var withRunExecutor = (name, executorFn, executorOptions = {
|
|
105317
|
+
var withRunExecutor = (name, executorFn, executorOptions = {
|
|
105318
|
+
skipReadingConfig: false
|
|
105319
|
+
}) => async (options, context) => {
|
|
105279
105320
|
const startTime = Date.now();
|
|
105280
105321
|
try {
|
|
105281
105322
|
console.info(`\u26A1 Running the ${name} executor...`);
|
|
105282
|
-
|
|
105323
|
+
if (executorOptions?.applyDefaultFn) {
|
|
105324
|
+
options = executorOptions.applyDefaultFn(options);
|
|
105325
|
+
}
|
|
105326
|
+
console.debug(`\u2699\uFE0F Executor schema options:
|
|
105283
105327
|
`, options);
|
|
105284
|
-
|
|
105285
|
-
|
|
105286
|
-
|
|
105287
|
-
|
|
105288
|
-
|
|
105289
|
-
|
|
105290
|
-
|
|
105328
|
+
if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName]) {
|
|
105329
|
+
throw new Error(
|
|
105330
|
+
"The Build process failed because the context is not valid. Please run this command from a workspace."
|
|
105331
|
+
);
|
|
105332
|
+
}
|
|
105333
|
+
const workspaceRoot = getWorkspaceRoot2();
|
|
105334
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
105335
|
+
const sourceRoot = context.projectsConfigurations.projects[context.projectName].sourceRoot;
|
|
105336
|
+
const projectName = context.projectsConfigurations.projects[context.projectName].name;
|
|
105337
|
+
const tokenized = applyWorkspaceTokens(
|
|
105338
|
+
options,
|
|
105339
|
+
{
|
|
105340
|
+
workspaceRoot,
|
|
105341
|
+
projectRoot,
|
|
105342
|
+
sourceRoot,
|
|
105343
|
+
projectName,
|
|
105344
|
+
...context.projectsConfigurations.projects[context.projectName],
|
|
105345
|
+
...executorOptions
|
|
105291
105346
|
},
|
|
105292
|
-
|
|
105347
|
+
applyWorkspaceExecutorTokens
|
|
105293
105348
|
);
|
|
105294
105349
|
let config;
|
|
105295
105350
|
if (!executorOptions.skipReadingConfig) {
|
|
@@ -105327,11 +105382,21 @@ ${Object.keys(process.env).map((key) => ` - ${key}=${process.env[key]}`).join("\
|
|
|
105327
105382
|
};
|
|
105328
105383
|
|
|
105329
105384
|
// packages/workspace-tools/src/base/base-generator.ts
|
|
105330
|
-
var withRunGenerator = (name, generatorFn, generatorOptions = {
|
|
105385
|
+
var withRunGenerator = (name, generatorFn, generatorOptions = {
|
|
105386
|
+
skipReadingConfig: false
|
|
105387
|
+
}) => async (tree, options) => {
|
|
105331
105388
|
const startTime = Date.now();
|
|
105332
105389
|
try {
|
|
105333
105390
|
console.info(`\u26A1 Running the ${name} generator...`);
|
|
105334
|
-
|
|
105391
|
+
if (generatorOptions?.applyDefaultFn) {
|
|
105392
|
+
options = generatorOptions.applyDefaultFn(options);
|
|
105393
|
+
}
|
|
105394
|
+
console.debug("\u2699\uFE0F Generator schema options: \n", options);
|
|
105395
|
+
const tokenized = applyWorkspaceTokens(
|
|
105396
|
+
options,
|
|
105397
|
+
{ workspaceRoot: tree.root },
|
|
105398
|
+
applyWorkspaceGeneratorTokens
|
|
105399
|
+
);
|
|
105335
105400
|
let config;
|
|
105336
105401
|
if (!generatorOptions.skipReadingConfig) {
|
|
105337
105402
|
const configFile = await getConfigFile();
|
|
@@ -105344,7 +105409,9 @@ var withRunGenerator = (name, generatorFn, generatorOptions = { skipReadingConfi
|
|
|
105344
105409
|
console.debug(`Loaded Storm config into env:
|
|
105345
105410
|
${Object.keys(process.env).map((key) => ` - ${key}=${process.env[key]}`).join("\n")}`);
|
|
105346
105411
|
}
|
|
105347
|
-
const result = await Promise.resolve(
|
|
105412
|
+
const result = await Promise.resolve(
|
|
105413
|
+
generatorFn(tree, tokenized, config)
|
|
105414
|
+
);
|
|
105348
105415
|
if (result && (!result.success || result.error && result?.error?.message && typeof result?.error?.message === "string" && result?.error?.name && typeof result?.error?.name === "string")) {
|
|
105349
105416
|
throw new Error(`The ${name} generator failed to run`, {
|
|
105350
105417
|
cause: result.error
|
|
@@ -105367,136 +105434,6 @@ ${Object.keys(process.env).map((key) => ` - ${key}=${process.env[key]}`).join("\
|
|
|
105367
105434
|
}
|
|
105368
105435
|
};
|
|
105369
105436
|
|
|
105370
|
-
// node_modules/.pnpm/esbuild-plugin-pino@2.1.0_esbuild@0.19.5/node_modules/esbuild-plugin-pino/dist/index.mjs
|
|
105371
|
-
var import_module = require("module");
|
|
105372
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
105373
|
-
var import_promises2 = require("node:fs/promises");
|
|
105374
|
-
var import_meta2 = {};
|
|
105375
|
-
var require$1 = true ? /* @__PURE__ */ (0, import_module.createRequire)(import_meta2.url) : require;
|
|
105376
|
-
function isStringArray(entryPoints) {
|
|
105377
|
-
if (Array.isArray(entryPoints) && entryPoints.some((entrypoint) => typeof entrypoint === "string"))
|
|
105378
|
-
return true;
|
|
105379
|
-
return false;
|
|
105380
|
-
}
|
|
105381
|
-
function transformToObject(entryPoints, outbase) {
|
|
105382
|
-
const separator = entryPoints[0].includes("\\") ? import_node_path.default.win32.sep : import_node_path.default.posix.sep;
|
|
105383
|
-
if (!outbase) {
|
|
105384
|
-
const hierarchy = entryPoints[0].split(separator);
|
|
105385
|
-
let i = 0;
|
|
105386
|
-
outbase = "";
|
|
105387
|
-
let nextOutbase = "";
|
|
105388
|
-
do {
|
|
105389
|
-
outbase = nextOutbase;
|
|
105390
|
-
i++;
|
|
105391
|
-
nextOutbase = hierarchy.slice(0, i).join(separator);
|
|
105392
|
-
} while (entryPoints.every(
|
|
105393
|
-
(entrypoint) => entrypoint.startsWith(`${nextOutbase}${separator}`)
|
|
105394
|
-
));
|
|
105395
|
-
}
|
|
105396
|
-
const newEntrypoints = {};
|
|
105397
|
-
for (const entrypoint of entryPoints) {
|
|
105398
|
-
const destination = (outbase ? entrypoint.replace(`${outbase}${separator}`, "") : entrypoint).replace(/.(js|ts)$/, "");
|
|
105399
|
-
newEntrypoints[destination] = entrypoint;
|
|
105400
|
-
}
|
|
105401
|
-
return newEntrypoints;
|
|
105402
|
-
}
|
|
105403
|
-
function transformToNewEntryPointsType(entryPoints) {
|
|
105404
|
-
const newEntrypointsType = [];
|
|
105405
|
-
for (const [key, value] of Object.entries(entryPoints)) {
|
|
105406
|
-
newEntrypointsType.push({ in: value, out: key });
|
|
105407
|
-
}
|
|
105408
|
-
return newEntrypointsType;
|
|
105409
|
-
}
|
|
105410
|
-
function esbuildPluginPino({
|
|
105411
|
-
transports = []
|
|
105412
|
-
}) {
|
|
105413
|
-
return {
|
|
105414
|
-
name: "pino",
|
|
105415
|
-
setup(currentBuild) {
|
|
105416
|
-
const pino = import_node_path.default.dirname(require$1.resolve("pino"));
|
|
105417
|
-
const threadStream = import_node_path.default.dirname(require$1.resolve("thread-stream"));
|
|
105418
|
-
const { entryPoints, outbase, outExtension: outExtension2 } = currentBuild.initialOptions;
|
|
105419
|
-
const customEntrypoints = {
|
|
105420
|
-
"thread-stream-worker": import_node_path.default.join(threadStream, "lib/worker.js"),
|
|
105421
|
-
"pino-worker": import_node_path.default.join(pino, "lib/worker.js"),
|
|
105422
|
-
"pino-pipeline-worker": import_node_path.default.join(pino, "lib/worker-pipeline.js"),
|
|
105423
|
-
"pino-file": import_node_path.default.join(pino, "file.js")
|
|
105424
|
-
};
|
|
105425
|
-
const transportsEntrypoints = Object.fromEntries(
|
|
105426
|
-
transports.map((transport) => [transport, require$1.resolve(transport)])
|
|
105427
|
-
);
|
|
105428
|
-
let newEntrypoints = [];
|
|
105429
|
-
if (isStringArray(entryPoints)) {
|
|
105430
|
-
newEntrypoints = transformToNewEntryPointsType({
|
|
105431
|
-
...transformToObject(entryPoints, outbase),
|
|
105432
|
-
...customEntrypoints,
|
|
105433
|
-
...transportsEntrypoints
|
|
105434
|
-
});
|
|
105435
|
-
} else if (Array.isArray(entryPoints)) {
|
|
105436
|
-
newEntrypoints = [
|
|
105437
|
-
...entryPoints,
|
|
105438
|
-
...transformToNewEntryPointsType({
|
|
105439
|
-
...customEntrypoints,
|
|
105440
|
-
...transportsEntrypoints
|
|
105441
|
-
})
|
|
105442
|
-
];
|
|
105443
|
-
} else {
|
|
105444
|
-
newEntrypoints = transformToNewEntryPointsType({
|
|
105445
|
-
...entryPoints,
|
|
105446
|
-
...customEntrypoints,
|
|
105447
|
-
...transportsEntrypoints
|
|
105448
|
-
});
|
|
105449
|
-
}
|
|
105450
|
-
currentBuild.initialOptions.entryPoints = newEntrypoints;
|
|
105451
|
-
let pinoBundlerRan = false;
|
|
105452
|
-
currentBuild.onEnd(() => {
|
|
105453
|
-
pinoBundlerRan = false;
|
|
105454
|
-
});
|
|
105455
|
-
currentBuild.onLoad({ filter: /pino\.js$/ }, async (args) => {
|
|
105456
|
-
if (pinoBundlerRan)
|
|
105457
|
-
return;
|
|
105458
|
-
pinoBundlerRan = true;
|
|
105459
|
-
const contents = await (0, import_promises2.readFile)(args.path, "utf8");
|
|
105460
|
-
let absoluteOutputPath = "";
|
|
105461
|
-
const { outdir = "dist" } = currentBuild.initialOptions;
|
|
105462
|
-
if (import_node_path.default.isAbsolute(outdir)) {
|
|
105463
|
-
absoluteOutputPath = outdir.replace(/\\/g, "\\\\");
|
|
105464
|
-
} else {
|
|
105465
|
-
const workingDir = currentBuild.initialOptions.absWorkingDir ? `"${currentBuild.initialOptions.absWorkingDir.replace(/\\/g, "\\\\")}"` : "process.cwd()";
|
|
105466
|
-
absoluteOutputPath = `\${${workingDir}}\${require('path').sep}${currentBuild.initialOptions.outdir || "dist"}`;
|
|
105467
|
-
}
|
|
105468
|
-
const functionDeclaration = `
|
|
105469
|
-
function pinoBundlerAbsolutePath(p) {
|
|
105470
|
-
try {
|
|
105471
|
-
return require('path').join(\`${absoluteOutputPath}\`.replace(/\\\\/g, '/'), p)
|
|
105472
|
-
} catch(e) {
|
|
105473
|
-
const f = new Function('p', 'return new URL(p, import.meta.url).pathname');
|
|
105474
|
-
return f(p)
|
|
105475
|
-
}
|
|
105476
|
-
}
|
|
105477
|
-
`;
|
|
105478
|
-
let extension = ".js";
|
|
105479
|
-
if (outExtension2 && outExtension2[".js"]) {
|
|
105480
|
-
extension = outExtension2[".js"];
|
|
105481
|
-
}
|
|
105482
|
-
const pinoOverrides = Object.keys({
|
|
105483
|
-
...customEntrypoints,
|
|
105484
|
-
...transportsEntrypoints
|
|
105485
|
-
}).map(
|
|
105486
|
-
(id) => `'${id === "pino-file" ? "pino/file" : id}': pinoBundlerAbsolutePath('./${id}${extension}')`
|
|
105487
|
-
).join(",");
|
|
105488
|
-
const globalThisDeclaration = `
|
|
105489
|
-
globalThis.__bundlerPathsOverrides = { ...(globalThis.__bundlerPathsOverrides || {}), ${pinoOverrides}}
|
|
105490
|
-
`;
|
|
105491
|
-
const code = functionDeclaration + globalThisDeclaration;
|
|
105492
|
-
return {
|
|
105493
|
-
contents: code + contents
|
|
105494
|
-
};
|
|
105495
|
-
});
|
|
105496
|
-
}
|
|
105497
|
-
};
|
|
105498
|
-
}
|
|
105499
|
-
|
|
105500
105437
|
// packages/workspace-tools/src/utils/get-file-banner.ts
|
|
105501
105438
|
var getFileBanner = (name, commentStart = "//") => {
|
|
105502
105439
|
let padding = "";
|
|
@@ -105580,7 +105517,7 @@ var environmentPlugin = (data) => ({
|
|
|
105580
105517
|
// packages/workspace-tools/src/executors/tsup/executor.ts
|
|
105581
105518
|
var import_fs3 = require("fs");
|
|
105582
105519
|
var import_fs_extra = __toESM(require_lib4());
|
|
105583
|
-
var
|
|
105520
|
+
var import_promises3 = require("fs/promises");
|
|
105584
105521
|
|
|
105585
105522
|
// node_modules/.pnpm/minimatch@9.0.3/node_modules/minimatch/dist/mjs/index.js
|
|
105586
105523
|
var import_brace_expansion = __toESM(require_brace_expansion2(), 1);
|
|
@@ -106251,11 +106188,11 @@ var qmarksTestNoExtDot = ([$0]) => {
|
|
|
106251
106188
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
106252
106189
|
};
|
|
106253
106190
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
106254
|
-
var
|
|
106191
|
+
var path = {
|
|
106255
106192
|
win32: { sep: "\\" },
|
|
106256
106193
|
posix: { sep: "/" }
|
|
106257
106194
|
};
|
|
106258
|
-
var sep = defaultPlatform === "win32" ?
|
|
106195
|
+
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
106259
106196
|
minimatch.sep = sep;
|
|
106260
106197
|
var GLOBSTAR = Symbol("globstar **");
|
|
106261
106198
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -108146,7 +108083,7 @@ var import_path2 = require("path");
|
|
|
108146
108083
|
var import_url = require("url");
|
|
108147
108084
|
var actualFS = __toESM(require("fs"), 1);
|
|
108148
108085
|
var import_fs2 = require("fs");
|
|
108149
|
-
var
|
|
108086
|
+
var import_promises2 = require("fs/promises");
|
|
108150
108087
|
|
|
108151
108088
|
// node_modules/.pnpm/minipass@7.0.4/node_modules/minipass/dist/esm/index.js
|
|
108152
108089
|
var import_events = require("events");
|
|
@@ -109035,10 +108972,10 @@ var defaultFS = {
|
|
|
109035
108972
|
readlinkSync: import_fs2.readlinkSync,
|
|
109036
108973
|
realpathSync,
|
|
109037
108974
|
promises: {
|
|
109038
|
-
lstat:
|
|
109039
|
-
readdir:
|
|
109040
|
-
readlink:
|
|
109041
|
-
realpath:
|
|
108975
|
+
lstat: import_promises2.lstat,
|
|
108976
|
+
readdir: import_promises2.readdir,
|
|
108977
|
+
readlink: import_promises2.readlink,
|
|
108978
|
+
realpath: import_promises2.realpath
|
|
109042
108979
|
}
|
|
109043
108980
|
};
|
|
109044
108981
|
var fsFromOption = (fsOption) => !fsOption || fsOption === defaultFS || fsOption === actualFS ? defaultFS : {
|
|
@@ -111765,13 +111702,13 @@ var import_tsup2 = __toESM(require_dist6());
|
|
|
111765
111702
|
var ts = __toESM(require("typescript"));
|
|
111766
111703
|
|
|
111767
111704
|
// packages/workspace-tools/src/utils/file-path-utils.ts
|
|
111768
|
-
var
|
|
111705
|
+
var import_node_path = require("node:path");
|
|
111769
111706
|
var removeExtension = (filePath) => {
|
|
111770
111707
|
return filePath.lastIndexOf(".") ? filePath.substring(0, filePath.lastIndexOf(".")) : filePath;
|
|
111771
111708
|
};
|
|
111772
111709
|
function findFileName(filePath) {
|
|
111773
111710
|
return filePath?.split(
|
|
111774
|
-
filePath?.includes(
|
|
111711
|
+
filePath?.includes(import_node_path.sep) ? import_node_path.sep : filePath?.includes("/") ? "/" : "\\"
|
|
111775
111712
|
)?.pop() ?? "";
|
|
111776
111713
|
}
|
|
111777
111714
|
|
|
@@ -112044,28 +111981,9 @@ var outExtension = ({ format: format2 }) => {
|
|
|
112044
111981
|
};
|
|
112045
111982
|
|
|
112046
111983
|
// packages/workspace-tools/src/executors/tsup/executor.ts
|
|
112047
|
-
async function
|
|
111984
|
+
async function tsupExecutorFn(options, context) {
|
|
112048
111985
|
try {
|
|
112049
111986
|
console.log("\u{1F4E6} Running Storm build executor on the workspace");
|
|
112050
|
-
options.entry ??= "{sourceRoot}/index.ts";
|
|
112051
|
-
options.outputPath ??= "dist/{projectRoot}";
|
|
112052
|
-
options.tsConfig ??= "tsconfig.json";
|
|
112053
|
-
options.platform ??= "neutral";
|
|
112054
|
-
options.verbose ??= false;
|
|
112055
|
-
options.external ??= [];
|
|
112056
|
-
options.additionalEntryPoints ??= [];
|
|
112057
|
-
options.assets ??= [];
|
|
112058
|
-
options.plugins ??= [];
|
|
112059
|
-
options.includeSrc ??= true;
|
|
112060
|
-
options.clean ??= true;
|
|
112061
|
-
options.bundle ??= true;
|
|
112062
|
-
options.debug ??= false;
|
|
112063
|
-
options.watch ??= false;
|
|
112064
|
-
options.apiReport ??= true;
|
|
112065
|
-
options.docModel ??= true;
|
|
112066
|
-
options.tsdocMetadata ??= true;
|
|
112067
|
-
options.define ??= {};
|
|
112068
|
-
options.env ??= {};
|
|
112069
111987
|
options.verbose && console.log(
|
|
112070
111988
|
`\u2699\uFE0F Executor options:
|
|
112071
111989
|
${Object.keys(options).map(
|
|
@@ -112081,17 +111999,9 @@ ${Object.keys(options).map(
|
|
|
112081
111999
|
const workspaceRoot = getWorkspaceRoot2();
|
|
112082
112000
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
112083
112001
|
const sourceRoot = context.projectsConfigurations.projects[context.projectName].sourceRoot;
|
|
112084
|
-
const outputPath = applyWorkspaceTokens(
|
|
112085
|
-
options.outputPath ? options.outputPath : "dist/{projectRoot}",
|
|
112086
|
-
context
|
|
112087
|
-
);
|
|
112088
|
-
options.entry = applyWorkspaceTokens(
|
|
112089
|
-
options.entry ? options.entry : "{sourceRoot}/index.ts",
|
|
112090
|
-
context
|
|
112091
|
-
);
|
|
112092
112002
|
if (options.clean !== false) {
|
|
112093
|
-
console.log(`\u{1F9F9} Cleaning output path: ${outputPath}`);
|
|
112094
|
-
(0, import_fs_extra.removeSync)(outputPath);
|
|
112003
|
+
console.log(`\u{1F9F9} Cleaning output path: ${options.outputPath}`);
|
|
112004
|
+
(0, import_fs_extra.removeSync)(options.outputPath);
|
|
112095
112005
|
}
|
|
112096
112006
|
const assets = Array.from(options.assets);
|
|
112097
112007
|
assets.push({
|
|
@@ -112112,7 +112022,7 @@ ${Object.keys(options).map(
|
|
|
112112
112022
|
});
|
|
112113
112023
|
}
|
|
112114
112024
|
const result = await (0, import_js.copyAssets)(
|
|
112115
|
-
{ assets, watch: options.watch, outputPath },
|
|
112025
|
+
{ assets, watch: options.watch, outputPath: options.outputPath },
|
|
112116
112026
|
context
|
|
112117
112027
|
);
|
|
112118
112028
|
if (!result.success) {
|
|
@@ -112241,7 +112151,11 @@ ${externalDependencies.map((dep) => {
|
|
|
112241
112151
|
packageJson.keywords ??= workspacePackageJson.keywords;
|
|
112242
112152
|
packageJson.repository ??= workspacePackageJson.repository;
|
|
112243
112153
|
packageJson.repository.directory ??= projectRoot ? projectRoot : (0, import_path4.join)("packages", context.projectName);
|
|
112244
|
-
const packageJsonPath = (0, import_path4.join)(
|
|
112154
|
+
const packageJsonPath = (0, import_path4.join)(
|
|
112155
|
+
context.root,
|
|
112156
|
+
options.outputPath,
|
|
112157
|
+
"package.json"
|
|
112158
|
+
);
|
|
112245
112159
|
console.log(`\u26A1 Writing package.json file to: ${packageJsonPath}`);
|
|
112246
112160
|
(0, import_fs3.writeFileSync)(
|
|
112247
112161
|
packageJsonPath,
|
|
@@ -112263,14 +112177,14 @@ ${externalDependencies.map((dep) => {
|
|
|
112263
112177
|
);
|
|
112264
112178
|
if (options.includeSrc !== false) {
|
|
112265
112179
|
const files = globSync([
|
|
112266
|
-
(0, import_devkit.joinPathFragments)(context.root, outputPath, "src/**/*.ts"),
|
|
112267
|
-
(0, import_devkit.joinPathFragments)(context.root, outputPath, "src/**/*.tsx"),
|
|
112268
|
-
(0, import_devkit.joinPathFragments)(context.root, outputPath, "src/**/*.js"),
|
|
112269
|
-
(0, import_devkit.joinPathFragments)(context.root, outputPath, "src/**/*.jsx")
|
|
112180
|
+
(0, import_devkit.joinPathFragments)(context.root, options.outputPath, "src/**/*.ts"),
|
|
112181
|
+
(0, import_devkit.joinPathFragments)(context.root, options.outputPath, "src/**/*.tsx"),
|
|
112182
|
+
(0, import_devkit.joinPathFragments)(context.root, options.outputPath, "src/**/*.js"),
|
|
112183
|
+
(0, import_devkit.joinPathFragments)(context.root, options.outputPath, "src/**/*.jsx")
|
|
112270
112184
|
]);
|
|
112271
112185
|
await Promise.allSettled(
|
|
112272
112186
|
files.map(
|
|
112273
|
-
(file) => (0,
|
|
112187
|
+
(file) => (0, import_promises3.writeFile)(
|
|
112274
112188
|
file,
|
|
112275
112189
|
`${options.banner ? options.banner.startsWith("//") ? options.banner : `// ${options.banner}` : ""}
|
|
112276
112190
|
|
|
@@ -112292,7 +112206,7 @@ ${(0, import_fs3.readFileSync)(file, "utf-8")}`,
|
|
|
112292
112206
|
...options,
|
|
112293
112207
|
dtsTsConfig: getNormalizedTsConfig(
|
|
112294
112208
|
context.root,
|
|
112295
|
-
outputPath,
|
|
112209
|
+
options.outputPath,
|
|
112296
112210
|
(0, import_tsc.createTypeScriptCompilationOptions)(
|
|
112297
112211
|
(0, import_normalize_options.normalizeOptions)(
|
|
112298
112212
|
{
|
|
@@ -112318,7 +112232,7 @@ ${options.banner}
|
|
|
112318
112232
|
|
|
112319
112233
|
`
|
|
112320
112234
|
} : void 0,
|
|
112321
|
-
outputPath
|
|
112235
|
+
outputPath: options.outputPath
|
|
112322
112236
|
});
|
|
112323
112237
|
if (typeof config === "function") {
|
|
112324
112238
|
await build(await Promise.resolve(config({})));
|
|
@@ -112381,16 +112295,41 @@ var isPrimitive = (value) => {
|
|
|
112381
112295
|
return false;
|
|
112382
112296
|
}
|
|
112383
112297
|
};
|
|
112384
|
-
var
|
|
112298
|
+
var applyDefault = (options) => {
|
|
112299
|
+
options.entry ??= "{sourceRoot}/index.ts";
|
|
112300
|
+
options.outputPath ??= "dist/{projectRoot}";
|
|
112301
|
+
options.tsConfig ??= "tsconfig.json";
|
|
112302
|
+
options.platform ??= "neutral";
|
|
112303
|
+
options.verbose ??= false;
|
|
112304
|
+
options.external ??= [];
|
|
112305
|
+
options.additionalEntryPoints ??= [];
|
|
112306
|
+
options.assets ??= [];
|
|
112307
|
+
options.plugins ??= [];
|
|
112308
|
+
options.includeSrc ??= true;
|
|
112309
|
+
options.clean ??= true;
|
|
112310
|
+
options.bundle ??= true;
|
|
112311
|
+
options.debug ??= false;
|
|
112312
|
+
options.watch ??= false;
|
|
112313
|
+
options.apiReport ??= true;
|
|
112314
|
+
options.docModel ??= true;
|
|
112315
|
+
options.tsdocMetadata ??= true;
|
|
112316
|
+
options.define ??= {};
|
|
112317
|
+
options.env ??= {};
|
|
112318
|
+
return options;
|
|
112319
|
+
};
|
|
112320
|
+
var executor_default = withRunExecutor(
|
|
112321
|
+
"TypeScript Build using tsup",
|
|
112322
|
+
tsupExecutorFn,
|
|
112323
|
+
{
|
|
112324
|
+
skipReadingConfig: false,
|
|
112325
|
+
applyDefaultFn: applyDefault
|
|
112326
|
+
}
|
|
112327
|
+
);
|
|
112385
112328
|
|
|
112386
112329
|
// packages/workspace-tools/src/executors/tsup-neutral/executor.ts
|
|
112387
112330
|
var tsNeutralBuildExecutorFn = (options, context, config) => {
|
|
112388
112331
|
options.plugins ??= [];
|
|
112389
|
-
|
|
112390
|
-
if (options.transports && Array.isArray(options.transports) && options.transports.length > 0) {
|
|
112391
|
-
options.plugins.push(esbuildPluginPino({ transports: options.transports }));
|
|
112392
|
-
}
|
|
112393
|
-
return executor_default(
|
|
112332
|
+
return tsupExecutorFn(
|
|
112394
112333
|
{
|
|
112395
112334
|
...options,
|
|
112396
112335
|
platform: "neutral",
|
|
@@ -112411,19 +112350,156 @@ var tsNeutralBuildExecutorFn = (options, context, config) => {
|
|
|
112411
112350
|
context
|
|
112412
112351
|
);
|
|
112413
112352
|
};
|
|
112353
|
+
var applyDefault2 = (options) => {
|
|
112354
|
+
options = applyDefault({ ...options, platform: "neutral" });
|
|
112355
|
+
options.plugins ??= [];
|
|
112356
|
+
return options;
|
|
112357
|
+
};
|
|
112414
112358
|
var executor_default2 = withRunExecutor(
|
|
112415
112359
|
"TypeScript Build (Neutral Platform)",
|
|
112416
|
-
tsNeutralBuildExecutorFn
|
|
112360
|
+
tsNeutralBuildExecutorFn,
|
|
112361
|
+
{
|
|
112362
|
+
skipReadingConfig: false,
|
|
112363
|
+
applyDefaultFn: applyDefault2
|
|
112364
|
+
}
|
|
112417
112365
|
);
|
|
112418
112366
|
|
|
112367
|
+
// node_modules/.pnpm/esbuild-plugin-pino@2.1.0_esbuild@0.19.5/node_modules/esbuild-plugin-pino/dist/index.mjs
|
|
112368
|
+
var import_module = require("module");
|
|
112369
|
+
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
112370
|
+
var import_promises4 = require("node:fs/promises");
|
|
112371
|
+
var import_meta2 = {};
|
|
112372
|
+
var require$1 = true ? /* @__PURE__ */ (0, import_module.createRequire)(import_meta2.url) : require;
|
|
112373
|
+
function isStringArray(entryPoints) {
|
|
112374
|
+
if (Array.isArray(entryPoints) && entryPoints.some((entrypoint) => typeof entrypoint === "string"))
|
|
112375
|
+
return true;
|
|
112376
|
+
return false;
|
|
112377
|
+
}
|
|
112378
|
+
function transformToObject(entryPoints, outbase) {
|
|
112379
|
+
const separator = entryPoints[0].includes("\\") ? import_node_path2.default.win32.sep : import_node_path2.default.posix.sep;
|
|
112380
|
+
if (!outbase) {
|
|
112381
|
+
const hierarchy = entryPoints[0].split(separator);
|
|
112382
|
+
let i = 0;
|
|
112383
|
+
outbase = "";
|
|
112384
|
+
let nextOutbase = "";
|
|
112385
|
+
do {
|
|
112386
|
+
outbase = nextOutbase;
|
|
112387
|
+
i++;
|
|
112388
|
+
nextOutbase = hierarchy.slice(0, i).join(separator);
|
|
112389
|
+
} while (entryPoints.every(
|
|
112390
|
+
(entrypoint) => entrypoint.startsWith(`${nextOutbase}${separator}`)
|
|
112391
|
+
));
|
|
112392
|
+
}
|
|
112393
|
+
const newEntrypoints = {};
|
|
112394
|
+
for (const entrypoint of entryPoints) {
|
|
112395
|
+
const destination = (outbase ? entrypoint.replace(`${outbase}${separator}`, "") : entrypoint).replace(/.(js|ts)$/, "");
|
|
112396
|
+
newEntrypoints[destination] = entrypoint;
|
|
112397
|
+
}
|
|
112398
|
+
return newEntrypoints;
|
|
112399
|
+
}
|
|
112400
|
+
function transformToNewEntryPointsType(entryPoints) {
|
|
112401
|
+
const newEntrypointsType = [];
|
|
112402
|
+
for (const [key, value] of Object.entries(entryPoints)) {
|
|
112403
|
+
newEntrypointsType.push({ in: value, out: key });
|
|
112404
|
+
}
|
|
112405
|
+
return newEntrypointsType;
|
|
112406
|
+
}
|
|
112407
|
+
function esbuildPluginPino({
|
|
112408
|
+
transports = []
|
|
112409
|
+
}) {
|
|
112410
|
+
return {
|
|
112411
|
+
name: "pino",
|
|
112412
|
+
setup(currentBuild) {
|
|
112413
|
+
const pino = import_node_path2.default.dirname(require$1.resolve("pino"));
|
|
112414
|
+
const threadStream = import_node_path2.default.dirname(require$1.resolve("thread-stream"));
|
|
112415
|
+
const { entryPoints, outbase, outExtension: outExtension2 } = currentBuild.initialOptions;
|
|
112416
|
+
const customEntrypoints = {
|
|
112417
|
+
"thread-stream-worker": import_node_path2.default.join(threadStream, "lib/worker.js"),
|
|
112418
|
+
"pino-worker": import_node_path2.default.join(pino, "lib/worker.js"),
|
|
112419
|
+
"pino-pipeline-worker": import_node_path2.default.join(pino, "lib/worker-pipeline.js"),
|
|
112420
|
+
"pino-file": import_node_path2.default.join(pino, "file.js")
|
|
112421
|
+
};
|
|
112422
|
+
const transportsEntrypoints = Object.fromEntries(
|
|
112423
|
+
transports.map((transport) => [transport, require$1.resolve(transport)])
|
|
112424
|
+
);
|
|
112425
|
+
let newEntrypoints = [];
|
|
112426
|
+
if (isStringArray(entryPoints)) {
|
|
112427
|
+
newEntrypoints = transformToNewEntryPointsType({
|
|
112428
|
+
...transformToObject(entryPoints, outbase),
|
|
112429
|
+
...customEntrypoints,
|
|
112430
|
+
...transportsEntrypoints
|
|
112431
|
+
});
|
|
112432
|
+
} else if (Array.isArray(entryPoints)) {
|
|
112433
|
+
newEntrypoints = [
|
|
112434
|
+
...entryPoints,
|
|
112435
|
+
...transformToNewEntryPointsType({
|
|
112436
|
+
...customEntrypoints,
|
|
112437
|
+
...transportsEntrypoints
|
|
112438
|
+
})
|
|
112439
|
+
];
|
|
112440
|
+
} else {
|
|
112441
|
+
newEntrypoints = transformToNewEntryPointsType({
|
|
112442
|
+
...entryPoints,
|
|
112443
|
+
...customEntrypoints,
|
|
112444
|
+
...transportsEntrypoints
|
|
112445
|
+
});
|
|
112446
|
+
}
|
|
112447
|
+
currentBuild.initialOptions.entryPoints = newEntrypoints;
|
|
112448
|
+
let pinoBundlerRan = false;
|
|
112449
|
+
currentBuild.onEnd(() => {
|
|
112450
|
+
pinoBundlerRan = false;
|
|
112451
|
+
});
|
|
112452
|
+
currentBuild.onLoad({ filter: /pino\.js$/ }, async (args) => {
|
|
112453
|
+
if (pinoBundlerRan)
|
|
112454
|
+
return;
|
|
112455
|
+
pinoBundlerRan = true;
|
|
112456
|
+
const contents = await (0, import_promises4.readFile)(args.path, "utf8");
|
|
112457
|
+
let absoluteOutputPath = "";
|
|
112458
|
+
const { outdir = "dist" } = currentBuild.initialOptions;
|
|
112459
|
+
if (import_node_path2.default.isAbsolute(outdir)) {
|
|
112460
|
+
absoluteOutputPath = outdir.replace(/\\/g, "\\\\");
|
|
112461
|
+
} else {
|
|
112462
|
+
const workingDir = currentBuild.initialOptions.absWorkingDir ? `"${currentBuild.initialOptions.absWorkingDir.replace(/\\/g, "\\\\")}"` : "process.cwd()";
|
|
112463
|
+
absoluteOutputPath = `\${${workingDir}}\${require('path').sep}${currentBuild.initialOptions.outdir || "dist"}`;
|
|
112464
|
+
}
|
|
112465
|
+
const functionDeclaration = `
|
|
112466
|
+
function pinoBundlerAbsolutePath(p) {
|
|
112467
|
+
try {
|
|
112468
|
+
return require('path').join(\`${absoluteOutputPath}\`.replace(/\\\\/g, '/'), p)
|
|
112469
|
+
} catch(e) {
|
|
112470
|
+
const f = new Function('p', 'return new URL(p, import.meta.url).pathname');
|
|
112471
|
+
return f(p)
|
|
112472
|
+
}
|
|
112473
|
+
}
|
|
112474
|
+
`;
|
|
112475
|
+
let extension = ".js";
|
|
112476
|
+
if (outExtension2 && outExtension2[".js"]) {
|
|
112477
|
+
extension = outExtension2[".js"];
|
|
112478
|
+
}
|
|
112479
|
+
const pinoOverrides = Object.keys({
|
|
112480
|
+
...customEntrypoints,
|
|
112481
|
+
...transportsEntrypoints
|
|
112482
|
+
}).map(
|
|
112483
|
+
(id) => `'${id === "pino-file" ? "pino/file" : id}': pinoBundlerAbsolutePath('./${id}${extension}')`
|
|
112484
|
+
).join(",");
|
|
112485
|
+
const globalThisDeclaration = `
|
|
112486
|
+
globalThis.__bundlerPathsOverrides = { ...(globalThis.__bundlerPathsOverrides || {}), ${pinoOverrides}}
|
|
112487
|
+
`;
|
|
112488
|
+
const code = functionDeclaration + globalThisDeclaration;
|
|
112489
|
+
return {
|
|
112490
|
+
contents: code + contents
|
|
112491
|
+
};
|
|
112492
|
+
});
|
|
112493
|
+
}
|
|
112494
|
+
};
|
|
112495
|
+
}
|
|
112496
|
+
|
|
112419
112497
|
// packages/workspace-tools/src/executors/tsup-node/executor.ts
|
|
112420
112498
|
var tsNodeBuildExecutorFn = (options, context, config) => {
|
|
112421
|
-
options.plugins ??= [];
|
|
112422
|
-
options.transports ??= ["pino-pretty", "pino-loki"];
|
|
112423
112499
|
if (options.transports && Array.isArray(options.transports) && options.transports.length > 0) {
|
|
112424
112500
|
options.plugins.push(esbuildPluginPino({ transports: options.transports }));
|
|
112425
112501
|
}
|
|
112426
|
-
return
|
|
112502
|
+
return tsupExecutorFn(
|
|
112427
112503
|
{
|
|
112428
112504
|
...options,
|
|
112429
112505
|
platform: "node",
|
|
@@ -112444,9 +112520,19 @@ var tsNodeBuildExecutorFn = (options, context, config) => {
|
|
|
112444
112520
|
context
|
|
112445
112521
|
);
|
|
112446
112522
|
};
|
|
112523
|
+
var applyDefault3 = (options) => {
|
|
112524
|
+
options = applyDefault({ ...options, platform: "node" });
|
|
112525
|
+
options.plugins ??= [];
|
|
112526
|
+
options.transports ??= ["pino-pretty", "pino-loki"];
|
|
112527
|
+
return options;
|
|
112528
|
+
};
|
|
112447
112529
|
var executor_default3 = withRunExecutor(
|
|
112448
112530
|
"TypeScript Build (NodeJs Platform)",
|
|
112449
|
-
tsNodeBuildExecutorFn
|
|
112531
|
+
tsNodeBuildExecutorFn,
|
|
112532
|
+
{
|
|
112533
|
+
skipReadingConfig: false,
|
|
112534
|
+
applyDefaultFn: applyDefault3
|
|
112535
|
+
}
|
|
112450
112536
|
);
|
|
112451
112537
|
|
|
112452
112538
|
// packages/workspace-tools/src/generators/config-schema/generator.ts
|
|
@@ -117104,7 +117190,6 @@ var getProjectConfigurations = () => (0, import_retrieve_workspace_files.retriev
|
|
|
117104
117190
|
|
|
117105
117191
|
// packages/workspace-tools/src/generators/config-schema/generator.ts
|
|
117106
117192
|
async function configSchemaGeneratorFn(tree, options) {
|
|
117107
|
-
const schema = {};
|
|
117108
117193
|
const projectConfigurations = getProjectConfigurations();
|
|
117109
117194
|
const workspaceRoot = getWorkspaceRoot2();
|
|
117110
117195
|
const modules = await Promise.all(
|
|
@@ -117900,6 +117985,9 @@ var WorkspaceStorage = class {
|
|
|
117900
117985
|
// Annotate the CommonJS export names for ESM import in node:
|
|
117901
117986
|
0 && (module.exports = {
|
|
117902
117987
|
WorkspaceStorage,
|
|
117988
|
+
applyDefault,
|
|
117989
|
+
applyWorkspaceExecutorTokens,
|
|
117990
|
+
applyWorkspaceGeneratorTokens,
|
|
117903
117991
|
applyWorkspaceTokens,
|
|
117904
117992
|
configSchemaGeneratorFn,
|
|
117905
117993
|
eslintVersion,
|
|
@@ -117927,7 +118015,7 @@ var WorkspaceStorage = class {
|
|
|
117927
118015
|
tsLibVersion,
|
|
117928
118016
|
tsNeutralBuildExecutorFn,
|
|
117929
118017
|
tsNodeBuildExecutorFn,
|
|
117930
|
-
|
|
118018
|
+
tsupExecutorFn,
|
|
117931
118019
|
tsupVersion,
|
|
117932
118020
|
typesNodeVersion,
|
|
117933
118021
|
typescriptVersion,
|