@storm-software/workspace-tools 1.19.3 → 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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.19.3](https://github.com/storm-software/storm-ops/compare/workspace-tools-v1.19.2...workspace-tools-v1.19.3) (2023-12-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **workspace-tools:** Resolved issue with `esbuildPluginPino` plugin for neutral build ([dba1022](https://github.com/storm-software/storm-ops/commit/dba102278281102a359c1c7cff087b9969b58c7c))
7
+
1
8
  ## [1.19.2](https://github.com/storm-software/storm-ops/compare/workspace-tools-v1.19.1...workspace-tools-v1.19.2) (2023-12-02)
2
9
 
3
10
 
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
- tsupExecutor: () => tsupExecutor,
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 applyWorkspaceTokens = (option, config) => {
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?.projectsConfigurations?.projects && config?.projectName) {
105253
+ if (config?.projectName) {
105252
105254
  const context = config;
105253
105255
  projectName = context.projectName;
105254
- projectRoot = context.projectsConfigurations.projects[projectName].root;
105255
- sourceRoot = context.projectsConfigurations.projects[projectName].sourceRoot;
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("{workspaceRoot}", workspaceRoot);
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 = { skipReadingConfig: false }) => async (options, context) => {
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
- console.debug(`\u2699\uFE0F Executor schema options:
105323
+ if (executorOptions?.applyDefaultFn) {
105324
+ options = executorOptions.applyDefaultFn(options);
105325
+ }
105326
+ console.debug(`\u2699\uFE0F Executor schema options:
105283
105327
  `, options);
105284
- const tokenized = Object.keys(options).reduce(
105285
- (ret, key) => {
105286
- ret[key] = applyWorkspaceTokens(
105287
- options[key],
105288
- context
105289
- );
105290
- return ret;
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
- options
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 = { skipReadingConfig: false }) => async (tree, options) => {
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
- console.debug("\u2699\uFE0F Generator schema options: \n", options);
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(generatorFn(tree, options, config));
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
@@ -111914,28 +111981,9 @@ var outExtension = ({ format: format2 }) => {
111914
111981
  };
111915
111982
 
111916
111983
  // packages/workspace-tools/src/executors/tsup/executor.ts
111917
- async function tsupExecutor(options, context) {
111984
+ async function tsupExecutorFn(options, context) {
111918
111985
  try {
111919
111986
  console.log("\u{1F4E6} Running Storm build executor on the workspace");
111920
- options.entry ??= "{sourceRoot}/index.ts";
111921
- options.outputPath ??= "dist/{projectRoot}";
111922
- options.tsConfig ??= "tsconfig.json";
111923
- options.platform ??= "neutral";
111924
- options.verbose ??= false;
111925
- options.external ??= [];
111926
- options.additionalEntryPoints ??= [];
111927
- options.assets ??= [];
111928
- options.plugins ??= [];
111929
- options.includeSrc ??= true;
111930
- options.clean ??= true;
111931
- options.bundle ??= true;
111932
- options.debug ??= false;
111933
- options.watch ??= false;
111934
- options.apiReport ??= true;
111935
- options.docModel ??= true;
111936
- options.tsdocMetadata ??= true;
111937
- options.define ??= {};
111938
- options.env ??= {};
111939
111987
  options.verbose && console.log(
111940
111988
  `\u2699\uFE0F Executor options:
111941
111989
  ${Object.keys(options).map(
@@ -111951,17 +111999,9 @@ ${Object.keys(options).map(
111951
111999
  const workspaceRoot = getWorkspaceRoot2();
111952
112000
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
111953
112001
  const sourceRoot = context.projectsConfigurations.projects[context.projectName].sourceRoot;
111954
- const outputPath = applyWorkspaceTokens(
111955
- options.outputPath ? options.outputPath : "dist/{projectRoot}",
111956
- context
111957
- );
111958
- options.entry = applyWorkspaceTokens(
111959
- options.entry ? options.entry : "{sourceRoot}/index.ts",
111960
- context
111961
- );
111962
112002
  if (options.clean !== false) {
111963
- console.log(`\u{1F9F9} Cleaning output path: ${outputPath}`);
111964
- (0, import_fs_extra.removeSync)(outputPath);
112003
+ console.log(`\u{1F9F9} Cleaning output path: ${options.outputPath}`);
112004
+ (0, import_fs_extra.removeSync)(options.outputPath);
111965
112005
  }
111966
112006
  const assets = Array.from(options.assets);
111967
112007
  assets.push({
@@ -111982,7 +112022,7 @@ ${Object.keys(options).map(
111982
112022
  });
111983
112023
  }
111984
112024
  const result = await (0, import_js.copyAssets)(
111985
- { assets, watch: options.watch, outputPath },
112025
+ { assets, watch: options.watch, outputPath: options.outputPath },
111986
112026
  context
111987
112027
  );
111988
112028
  if (!result.success) {
@@ -112111,7 +112151,11 @@ ${externalDependencies.map((dep) => {
112111
112151
  packageJson.keywords ??= workspacePackageJson.keywords;
112112
112152
  packageJson.repository ??= workspacePackageJson.repository;
112113
112153
  packageJson.repository.directory ??= projectRoot ? projectRoot : (0, import_path4.join)("packages", context.projectName);
112114
- const packageJsonPath = (0, import_path4.join)(context.root, outputPath, "package.json");
112154
+ const packageJsonPath = (0, import_path4.join)(
112155
+ context.root,
112156
+ options.outputPath,
112157
+ "package.json"
112158
+ );
112115
112159
  console.log(`\u26A1 Writing package.json file to: ${packageJsonPath}`);
112116
112160
  (0, import_fs3.writeFileSync)(
112117
112161
  packageJsonPath,
@@ -112133,10 +112177,10 @@ ${externalDependencies.map((dep) => {
112133
112177
  );
112134
112178
  if (options.includeSrc !== false) {
112135
112179
  const files = globSync([
112136
- (0, import_devkit.joinPathFragments)(context.root, outputPath, "src/**/*.ts"),
112137
- (0, import_devkit.joinPathFragments)(context.root, outputPath, "src/**/*.tsx"),
112138
- (0, import_devkit.joinPathFragments)(context.root, outputPath, "src/**/*.js"),
112139
- (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")
112140
112184
  ]);
112141
112185
  await Promise.allSettled(
112142
112186
  files.map(
@@ -112162,7 +112206,7 @@ ${(0, import_fs3.readFileSync)(file, "utf-8")}`,
112162
112206
  ...options,
112163
112207
  dtsTsConfig: getNormalizedTsConfig(
112164
112208
  context.root,
112165
- outputPath,
112209
+ options.outputPath,
112166
112210
  (0, import_tsc.createTypeScriptCompilationOptions)(
112167
112211
  (0, import_normalize_options.normalizeOptions)(
112168
112212
  {
@@ -112188,7 +112232,7 @@ ${options.banner}
112188
112232
 
112189
112233
  `
112190
112234
  } : void 0,
112191
- outputPath
112235
+ outputPath: options.outputPath
112192
112236
  });
112193
112237
  if (typeof config === "function") {
112194
112238
  await build(await Promise.resolve(config({})));
@@ -112251,12 +112295,41 @@ var isPrimitive = (value) => {
112251
112295
  return false;
112252
112296
  }
112253
112297
  };
112254
- var executor_default = tsupExecutor;
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
+ );
112255
112328
 
112256
112329
  // packages/workspace-tools/src/executors/tsup-neutral/executor.ts
112257
112330
  var tsNeutralBuildExecutorFn = (options, context, config) => {
112258
112331
  options.plugins ??= [];
112259
- return executor_default(
112332
+ return tsupExecutorFn(
112260
112333
  {
112261
112334
  ...options,
112262
112335
  platform: "neutral",
@@ -112277,9 +112350,18 @@ var tsNeutralBuildExecutorFn = (options, context, config) => {
112277
112350
  context
112278
112351
  );
112279
112352
  };
112353
+ var applyDefault2 = (options) => {
112354
+ options = applyDefault({ ...options, platform: "neutral" });
112355
+ options.plugins ??= [];
112356
+ return options;
112357
+ };
112280
112358
  var executor_default2 = withRunExecutor(
112281
112359
  "TypeScript Build (Neutral Platform)",
112282
- tsNeutralBuildExecutorFn
112360
+ tsNeutralBuildExecutorFn,
112361
+ {
112362
+ skipReadingConfig: false,
112363
+ applyDefaultFn: applyDefault2
112364
+ }
112283
112365
  );
112284
112366
 
112285
112367
  // node_modules/.pnpm/esbuild-plugin-pino@2.1.0_esbuild@0.19.5/node_modules/esbuild-plugin-pino/dist/index.mjs
@@ -112414,12 +112496,10 @@ function esbuildPluginPino({
112414
112496
 
112415
112497
  // packages/workspace-tools/src/executors/tsup-node/executor.ts
112416
112498
  var tsNodeBuildExecutorFn = (options, context, config) => {
112417
- options.plugins ??= [];
112418
- options.transports ??= ["pino-pretty", "pino-loki"];
112419
112499
  if (options.transports && Array.isArray(options.transports) && options.transports.length > 0) {
112420
112500
  options.plugins.push(esbuildPluginPino({ transports: options.transports }));
112421
112501
  }
112422
- return executor_default(
112502
+ return tsupExecutorFn(
112423
112503
  {
112424
112504
  ...options,
112425
112505
  platform: "node",
@@ -112440,9 +112520,19 @@ var tsNodeBuildExecutorFn = (options, context, config) => {
112440
112520
  context
112441
112521
  );
112442
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
+ };
112443
112529
  var executor_default3 = withRunExecutor(
112444
112530
  "TypeScript Build (NodeJs Platform)",
112445
- tsNodeBuildExecutorFn
112531
+ tsNodeBuildExecutorFn,
112532
+ {
112533
+ skipReadingConfig: false,
112534
+ applyDefaultFn: applyDefault3
112535
+ }
112446
112536
  );
112447
112537
 
112448
112538
  // packages/workspace-tools/src/generators/config-schema/generator.ts
@@ -117100,7 +117190,6 @@ var getProjectConfigurations = () => (0, import_retrieve_workspace_files.retriev
117100
117190
 
117101
117191
  // packages/workspace-tools/src/generators/config-schema/generator.ts
117102
117192
  async function configSchemaGeneratorFn(tree, options) {
117103
- const schema = {};
117104
117193
  const projectConfigurations = getProjectConfigurations();
117105
117194
  const workspaceRoot = getWorkspaceRoot2();
117106
117195
  const modules = await Promise.all(
@@ -117896,6 +117985,9 @@ var WorkspaceStorage = class {
117896
117985
  // Annotate the CommonJS export names for ESM import in node:
117897
117986
  0 && (module.exports = {
117898
117987
  WorkspaceStorage,
117988
+ applyDefault,
117989
+ applyWorkspaceExecutorTokens,
117990
+ applyWorkspaceGeneratorTokens,
117899
117991
  applyWorkspaceTokens,
117900
117992
  configSchemaGeneratorFn,
117901
117993
  eslintVersion,
@@ -117923,7 +118015,7 @@ var WorkspaceStorage = class {
117923
118015
  tsLibVersion,
117924
118016
  tsNeutralBuildExecutorFn,
117925
118017
  tsNodeBuildExecutorFn,
117926
- tsupExecutor,
118018
+ tsupExecutorFn,
117927
118019
  tsupVersion,
117928
118020
  typesNodeVersion,
117929
118021
  typescriptVersion,