@storm-software/workspace-tools 1.43.5 → 1.43.7

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/index.js CHANGED
@@ -47246,8 +47246,8 @@ var require_dist2 = __commonJS({
47246
47246
  loadTsConfig: () => loadTsConfig2
47247
47247
  });
47248
47248
  module2.exports = __toCommonJS2(src_exports);
47249
- var import_path5 = __toESM2(require("path"), 1);
47250
- var import_fs5 = __toESM2(require("fs"), 1);
47249
+ var import_path3 = __toESM2(require("path"), 1);
47250
+ var import_fs3 = __toESM2(require("fs"), 1);
47251
47251
  var singleComment = Symbol("singleComment");
47252
47252
  var multiComment = Symbol("multiComment");
47253
47253
  var stripWithoutWhitespace = () => "";
@@ -47342,29 +47342,29 @@ var require_dist2 = __commonJS({
47342
47342
  }
47343
47343
  }
47344
47344
  var req = false ? createRequire(import_meta.url) : require;
47345
- var findUp = (name, startDir, stopDir = import_path5.default.parse(startDir).root) => {
47345
+ var findUp = (name, startDir, stopDir = import_path3.default.parse(startDir).root) => {
47346
47346
  let dir = startDir;
47347
47347
  while (dir !== stopDir) {
47348
- const file = import_path5.default.join(dir, name);
47349
- if (import_fs5.default.existsSync(file))
47348
+ const file = import_path3.default.join(dir, name);
47349
+ if (import_fs3.default.existsSync(file))
47350
47350
  return file;
47351
47351
  if (!file.endsWith(".json")) {
47352
47352
  const fileWithExt = file + ".json";
47353
- if (import_fs5.default.existsSync(fileWithExt))
47353
+ if (import_fs3.default.existsSync(fileWithExt))
47354
47354
  return fileWithExt;
47355
47355
  }
47356
- dir = import_path5.default.dirname(dir);
47356
+ dir = import_path3.default.dirname(dir);
47357
47357
  }
47358
47358
  return null;
47359
47359
  };
47360
47360
  var resolveTsConfigFromFile = (cwd, filename) => {
47361
- if (import_path5.default.isAbsolute(filename))
47362
- return import_fs5.default.existsSync(filename) ? filename : null;
47361
+ if (import_path3.default.isAbsolute(filename))
47362
+ return import_fs3.default.existsSync(filename) ? filename : null;
47363
47363
  return findUp(filename, cwd);
47364
47364
  };
47365
47365
  var resolveTsConfigFromExtends = (cwd, name) => {
47366
- if (import_path5.default.isAbsolute(name))
47367
- return import_fs5.default.existsSync(name) ? name : null;
47366
+ if (import_path3.default.isAbsolute(name))
47367
+ return import_fs3.default.existsSync(name) ? name : null;
47368
47368
  if (name.startsWith("."))
47369
47369
  return findUp(name, cwd);
47370
47370
  const id = req.resolve(name, { paths: [cwd] });
@@ -47372,14 +47372,14 @@ var require_dist2 = __commonJS({
47372
47372
  };
47373
47373
  var loadTsConfigInternal = (dir = process.cwd(), name = "tsconfig.json", isExtends = false) => {
47374
47374
  var _a, _b;
47375
- dir = import_path5.default.resolve(dir);
47375
+ dir = import_path3.default.resolve(dir);
47376
47376
  const id = isExtends ? resolveTsConfigFromExtends(dir, name) : resolveTsConfigFromFile(dir, name);
47377
47377
  if (!id)
47378
47378
  return null;
47379
- const data = jsoncParse(import_fs5.default.readFileSync(id, "utf-8"));
47380
- const configDir = import_path5.default.dirname(id);
47379
+ const data = jsoncParse(import_fs3.default.readFileSync(id, "utf-8"));
47380
+ const configDir = import_path3.default.dirname(id);
47381
47381
  if ((_a = data.compilerOptions) == null ? void 0 : _a.baseUrl) {
47382
- data.compilerOptions.baseUrl = import_path5.default.join(
47382
+ data.compilerOptions.baseUrl = import_path3.default.join(
47383
47383
  configDir,
47384
47384
  data.compilerOptions.baseUrl
47385
47385
  );
@@ -47461,12 +47461,12 @@ var require_dist3 = __commonJS({
47461
47461
  var import_url3 = require("url");
47462
47462
  var import_esbuild = require("esbuild");
47463
47463
  var import_load_tsconfig = require_dist2();
47464
- var import_fs5 = __toESM2(require("fs"), 1);
47465
- var import_path5 = __toESM2(require("path"), 1);
47464
+ var import_fs3 = __toESM2(require("fs"), 1);
47465
+ var import_path3 = __toESM2(require("path"), 1);
47466
47466
  var getPkgType = () => {
47467
47467
  try {
47468
47468
  const pkg = JSON.parse(
47469
- import_fs5.default.readFileSync(import_path5.default.resolve("package.json"), "utf-8")
47469
+ import_fs3.default.readFileSync(import_path3.default.resolve("package.json"), "utf-8")
47470
47470
  );
47471
47471
  return pkg.type;
47472
47472
  } catch (error) {
@@ -47475,7 +47475,7 @@ var require_dist3 = __commonJS({
47475
47475
  function guessFormat(inputFile) {
47476
47476
  if (!usingDynamicImport)
47477
47477
  return "cjs";
47478
- const ext2 = import_path5.default.extname(inputFile);
47478
+ const ext2 = import_path3.default.extname(inputFile);
47479
47479
  const type = getPkgType();
47480
47480
  if (ext2 === ".js") {
47481
47481
  return type === "module" ? "esm" : "cjs";
@@ -126381,7 +126381,7 @@ module.exports = __toCommonJS(workspace_tools_exports);
126381
126381
  // packages/config-tools/src/config-file/get-config-file.ts
126382
126382
  var import_cosmiconfig = __toESM(require_dist(), 1);
126383
126383
  var _static_cache = void 0;
126384
- var getConfigFileName = (fileName, filePath) => (0, import_cosmiconfig.cosmiconfig)(fileName, { cache: true }).search(filePath);
126384
+ var getConfigFileName = async (fileName, filePath) => (0, import_cosmiconfig.cosmiconfig)(fileName, { cache: true }).search(filePath);
126385
126385
  var getConfigFile = async (filePath) => {
126386
126386
  if (_static_cache) {
126387
126387
  return _static_cache;
@@ -126441,17 +126441,17 @@ var LogLevelLabel = {
126441
126441
  };
126442
126442
 
126443
126443
  // packages/config-tools/src/utilities/find-up.ts
126444
- var import_fs = require("fs");
126445
- var import_path = require("path");
126444
+ var import_node_fs = require("node:fs");
126445
+ var import_node_path = require("node:path");
126446
126446
  var MAX_PATH_SEARCH_DEPTH = 30;
126447
126447
  var depth = 0;
126448
126448
  function findFolderUp(startPath, endFileNames) {
126449
126449
  const _startPath = startPath ?? process.cwd();
126450
- if (endFileNames.some((endFileName) => (0, import_fs.existsSync)((0, import_path.join)(_startPath, endFileName)))) {
126450
+ if (endFileNames.some((endFileName) => (0, import_node_fs.existsSync)((0, import_node_path.join)(_startPath, endFileName)))) {
126451
126451
  return _startPath;
126452
126452
  }
126453
126453
  if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
126454
- const parent = (0, import_path.join)(_startPath, "..");
126454
+ const parent = (0, import_node_path.join)(_startPath, "..");
126455
126455
  return findFolderUp(parent, endFileNames);
126456
126456
  }
126457
126457
  return void 0;
@@ -126510,8 +126510,8 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
126510
126510
  }
126511
126511
 
126512
126512
  // packages/config-tools/src/utilities/get-default-config.ts
126513
- var import_fs2 = require("fs");
126514
- var import_path2 = require("path");
126513
+ var import_node_fs2 = require("node:fs");
126514
+ var import_node_path2 = require("node:path");
126515
126515
 
126516
126516
  // node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
126517
126517
  var util;
@@ -130180,8 +130180,8 @@ var getDefaultConfig = (config = {}, root) => {
130180
130180
  let license = DefaultStormConfig.license;
130181
130181
  let homepage = DefaultStormConfig.homepage;
130182
130182
  const workspaceRoot = findWorkspaceRoot(root);
130183
- if ((0, import_fs2.existsSync)((0, import_path2.join)(workspaceRoot, "package.json"))) {
130184
- const file = (0, import_fs2.readFileSync)((0, import_path2.join)(workspaceRoot, "package.json"), {
130183
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(workspaceRoot, "package.json"))) {
130184
+ const file = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(workspaceRoot, "package.json"), {
130185
130185
  encoding: "utf-8"
130186
130186
  });
130187
130187
  if (file) {
@@ -130204,9 +130204,9 @@ var getDefaultConfig = (config = {}, root) => {
130204
130204
  }
130205
130205
  }
130206
130206
  return StormConfigSchema.parse({
130207
- ...config,
130208
130207
  ...DefaultStormConfig,
130209
- colors: { ...config.colors, ...DefaultColorConfig },
130208
+ ...config,
130209
+ colors: { ...DefaultColorConfig, ...config.colors },
130210
130210
  workspaceRoot,
130211
130211
  name,
130212
130212
  namespace,
@@ -130550,16 +130550,6 @@ var setConfigEnv = (config) => {
130550
130550
  }
130551
130551
  };
130552
130552
 
130553
- // packages/config-tools/src/utilities/prepare-workspace.ts
130554
- var prepareWorkspace = async () => {
130555
- const _STORM_CONFIG = getDefaultConfig({
130556
- ...await getConfigFile(),
130557
- ...getConfigEnv()
130558
- });
130559
- setConfigEnv(_STORM_CONFIG);
130560
- return _STORM_CONFIG;
130561
- };
130562
-
130563
130553
  // packages/config-tools/src/env/get-env.ts
130564
130554
  var getExtensionEnv = (extensionName) => {
130565
130555
  const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
@@ -130627,6 +130617,32 @@ var getConfigEnv = () => {
130627
130617
  }, config);
130628
130618
  };
130629
130619
 
130620
+ // packages/config-tools/src/create-storm-config.ts
130621
+ var loadStormConfig = async (workspaceRoot) => {
130622
+ let config = {};
130623
+ let _workspaceRoot = workspaceRoot;
130624
+ if (!_workspaceRoot) {
130625
+ _workspaceRoot = findWorkspaceRoot();
130626
+ }
130627
+ const configFile = await getDefaultConfig(
130628
+ {
130629
+ ...await getConfigFile(_workspaceRoot),
130630
+ ...getConfigEnv()
130631
+ },
130632
+ _workspaceRoot
130633
+ );
130634
+ if (configFile) {
130635
+ config = StormConfigSchema.parse(configFile);
130636
+ } else {
130637
+ writeWarning(
130638
+ config,
130639
+ "No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.config.js` file to the root of your workspace if it is not."
130640
+ );
130641
+ }
130642
+ setConfigEnv(config);
130643
+ return config;
130644
+ };
130645
+
130630
130646
  // packages/workspace-tools/src/utils/get-workspace-root.ts
130631
130647
  var import_find_workspace_root2 = require("nx/src/utils/find-workspace-root.js");
130632
130648
  var getWorkspaceRoot = () => {
@@ -130765,7 +130781,7 @@ var withRunExecutor = (name, executorFn, executorOptions) => async (_options, co
130765
130781
  - projectName: ${projectName}
130766
130782
  `
130767
130783
  );
130768
- config = await prepareWorkspace();
130784
+ config = await loadStormConfig(workspaceRoot);
130769
130785
  writeTrace(
130770
130786
  config,
130771
130787
  `Loaded Storm config into env:
@@ -130853,7 +130869,7 @@ var withRunGenerator = (name, generatorFn, generatorOptions = {
130853
130869
  `Loading the Storm Config from environment variables and storm.config.js file...
130854
130870
  - workspaceRoot: ${workspaceRoot}`
130855
130871
  );
130856
- config = await prepareWorkspace();
130872
+ config = await loadStormConfig(workspaceRoot);
130857
130873
  writeTrace(
130858
130874
  config,
130859
130875
  `Loaded Storm config into env:
@@ -131413,9 +131429,9 @@ ${commentStart} ----------------------------------------------------------------
131413
131429
  };
131414
131430
 
131415
131431
  // packages/workspace-tools/src/executors/tsup/executor.ts
131416
- var import_node_fs = require("node:fs");
131432
+ var import_node_fs3 = require("node:fs");
131417
131433
  var import_promises2 = require("node:fs/promises");
131418
- var import_node_path2 = require("node:path");
131434
+ var import_node_path4 = require("node:path");
131419
131435
  var import_esbuild_decorators = __toESM(require_src2());
131420
131436
  var import_devkit3 = __toESM(require_devkit());
131421
131437
  var import_js2 = __toESM(require_src());
@@ -134026,10 +134042,10 @@ var LRUCache = class _LRUCache {
134026
134042
  };
134027
134043
 
134028
134044
  // node_modules/.pnpm/path-scurry@1.10.1/node_modules/path-scurry/dist/mjs/index.js
134029
- var import_path3 = require("path");
134045
+ var import_path = require("path");
134030
134046
  var import_url = require("url");
134031
134047
  var actualFS = __toESM(require("fs"), 1);
134032
- var import_fs3 = require("fs");
134048
+ var import_fs = require("fs");
134033
134049
  var import_promises = require("fs/promises");
134034
134050
 
134035
134051
  // node_modules/.pnpm/minipass@7.0.4/node_modules/minipass/dist/esm/index.js
@@ -134911,12 +134927,12 @@ var Minipass = class extends import_events.EventEmitter {
134911
134927
  };
134912
134928
 
134913
134929
  // node_modules/.pnpm/path-scurry@1.10.1/node_modules/path-scurry/dist/mjs/index.js
134914
- var realpathSync = import_fs3.realpathSync.native;
134930
+ var realpathSync = import_fs.realpathSync.native;
134915
134931
  var defaultFS = {
134916
- lstatSync: import_fs3.lstatSync,
134917
- readdir: import_fs3.readdir,
134918
- readdirSync: import_fs3.readdirSync,
134919
- readlinkSync: import_fs3.readlinkSync,
134932
+ lstatSync: import_fs.lstatSync,
134933
+ readdir: import_fs.readdir,
134934
+ readdirSync: import_fs.readdirSync,
134935
+ readlinkSync: import_fs.readlinkSync,
134920
134936
  realpathSync,
134921
134937
  promises: {
134922
134938
  lstat: import_promises.lstat,
@@ -135912,7 +135928,7 @@ var PathWin32 = class _PathWin32 extends PathBase {
135912
135928
  * @internal
135913
135929
  */
135914
135930
  getRootString(path3) {
135915
- return import_path3.win32.parse(path3).root;
135931
+ return import_path.win32.parse(path3).root;
135916
135932
  }
135917
135933
  /**
135918
135934
  * @internal
@@ -136552,7 +136568,7 @@ var PathScurryWin32 = class extends PathScurryBase {
136552
136568
  sep = "\\";
136553
136569
  constructor(cwd = process.cwd(), opts = {}) {
136554
136570
  const { nocase = true } = opts;
136555
- super(cwd, import_path3.win32, "\\", { ...opts, nocase });
136571
+ super(cwd, import_path.win32, "\\", { ...opts, nocase });
136556
136572
  this.nocase = nocase;
136557
136573
  for (let p = this.cwd; p; p = p.parent) {
136558
136574
  p.nocase = this.nocase;
@@ -136562,7 +136578,7 @@ var PathScurryWin32 = class extends PathScurryBase {
136562
136578
  * @internal
136563
136579
  */
136564
136580
  parseRootPath(dir) {
136565
- return import_path3.win32.parse(dir).root.toUpperCase();
136581
+ return import_path.win32.parse(dir).root.toUpperCase();
136566
136582
  }
136567
136583
  /**
136568
136584
  * @internal
@@ -136584,7 +136600,7 @@ var PathScurryPosix = class extends PathScurryBase {
136584
136600
  sep = "/";
136585
136601
  constructor(cwd = process.cwd(), opts = {}) {
136586
136602
  const { nocase = false } = opts;
136587
- super(cwd, import_path3.posix, "/", { ...opts, nocase });
136603
+ super(cwd, import_path.posix, "/", { ...opts, nocase });
136588
136604
  this.nocase = nocase;
136589
136605
  }
136590
136606
  /**
@@ -137647,13 +137663,13 @@ var import_tsup = __toESM(require_dist6());
137647
137663
  var ts = __toESM(require("typescript"));
137648
137664
 
137649
137665
  // packages/workspace-tools/src/utils/file-path-utils.ts
137650
- var import_node_path = require("node:path");
137666
+ var import_node_path3 = require("node:path");
137651
137667
  var removeExtension = (filePath) => {
137652
137668
  return filePath.lastIndexOf(".") ? filePath.substring(0, filePath.lastIndexOf(".")) : filePath;
137653
137669
  };
137654
137670
  function findFileName(filePath) {
137655
137671
  return filePath?.split(
137656
- filePath?.includes(import_node_path.sep) ? import_node_path.sep : filePath?.includes("/") ? "/" : "\\"
137672
+ filePath?.includes(import_node_path3.sep) ? import_node_path3.sep : filePath?.includes("/") ? "/" : "\\"
137657
137673
  )?.pop() ?? "";
137658
137674
  }
137659
137675
 
@@ -137724,416 +137740,403 @@ var getTypiaTransform = (program, diagnostics) => (0, import_transform.default)(
137724
137740
 
137725
137741
  // packages/workspace-tools/src/executors/tsup/executor.ts
137726
137742
  async function tsupExecutorFn(options, context, config) {
137727
- try {
137728
- writeInfo(config, "\u{1F4E6} Running Storm build executor on the workspace");
137729
- getLogLevel(config?.logLevel) >= LogLevel.TRACE && writeDebug(
137730
- config,
137731
- `\u2699\uFE0F Executor options:
137743
+ writeInfo(config, "\u{1F4E6} Running Storm build executor on the workspace");
137744
+ getLogLevel(config?.logLevel) >= LogLevel.TRACE && writeDebug(
137745
+ config,
137746
+ `\u2699\uFE0F Executor options:
137732
137747
  ${Object.keys(options).map(
137733
- (key) => `${key}: ${!options[key] || _isPrimitive(options[key]) ? options[key] : JSON.stringify(options[key])}`
137734
- ).join("\n")}
137748
+ (key) => `${key}: ${!options[key] || _isPrimitive(options[key]) ? options[key] : JSON.stringify(options[key])}`
137749
+ ).join("\n")}
137735
137750
  `
137751
+ );
137752
+ if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName]) {
137753
+ throw new Error(
137754
+ "The Build process failed because the context is not valid. Please run this command from a workspace."
137736
137755
  );
137737
- if (!context.projectsConfigurations?.projects || !context.projectName || !context.projectsConfigurations.projects[context.projectName]) {
137738
- throw new Error(
137739
- "The Build process failed because the context is not valid. Please run this command from a workspace."
137740
- );
137741
- }
137742
- const workspaceRoot = getWorkspaceRoot();
137743
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
137744
- const sourceRoot = context.projectsConfigurations.projects[context.projectName].sourceRoot;
137745
- if (options.clean !== false) {
137746
- if (getLogLevel(config?.logLevel) >= LogLevel.DEBUG) {
137747
- writeInfo(config, `\u{1F9F9} Cleaning output path: ${options.outputPath}`);
137748
- }
137749
- (0, import_fs_extra.removeSync)(options.outputPath);
137750
- }
137751
- const assets = Array.from(options.assets);
137756
+ }
137757
+ const workspaceRoot = getWorkspaceRoot();
137758
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
137759
+ const sourceRoot = context.projectsConfigurations.projects[context.projectName].sourceRoot;
137760
+ if (options.clean !== false) {
137761
+ if (getLogLevel(config?.logLevel) >= LogLevel.DEBUG) {
137762
+ writeInfo(config, `\u{1F9F9} Cleaning output path: ${options.outputPath}`);
137763
+ }
137764
+ (0, import_fs_extra.removeSync)(options.outputPath);
137765
+ }
137766
+ const assets = Array.from(options.assets);
137767
+ assets.push({
137768
+ input: projectRoot,
137769
+ glob: "*.md",
137770
+ output: "/"
137771
+ });
137772
+ assets.push({
137773
+ input: "",
137774
+ glob: "LICENSE",
137775
+ output: "."
137776
+ });
137777
+ if (options.generatePackageJson === false) {
137752
137778
  assets.push({
137753
137779
  input: projectRoot,
137754
- glob: "*.md",
137755
- output: "/"
137780
+ glob: "**/package.json",
137781
+ output: "."
137756
137782
  });
137783
+ }
137784
+ if (options.includeSrc === true) {
137757
137785
  assets.push({
137758
- input: "",
137759
- glob: "LICENSE",
137760
- output: "."
137786
+ input: sourceRoot,
137787
+ glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
137788
+ output: "src/"
137761
137789
  });
137762
- if (options.generatePackageJson === false) {
137763
- assets.push({
137764
- input: projectRoot,
137765
- glob: "**/package.json",
137766
- output: "."
137767
- });
137768
- }
137769
- if (options.includeSrc === true) {
137770
- assets.push({
137771
- input: sourceRoot,
137772
- glob: "**/{*.ts,*.tsx,*.js,*.jsx}",
137773
- output: "src/"
137774
- });
137775
- }
137776
- const result = await (0, import_js2.copyAssets)(
137777
- { assets, watch: options.watch, outputPath: options.outputPath },
137778
- context
137779
- );
137780
- if (!result.success) {
137781
- throw new Error("The Build process failed trying to copy assets");
137782
- }
137783
- const pathToPackageJson = (0, import_node_path2.join)(context.root, projectRoot, "package.json");
137784
- const packageJson = (0, import_fileutils.fileExists)(pathToPackageJson) ? (0, import_devkit3.readJsonFile)(pathToPackageJson) : { name: context.projectName, version: "0.0.1" };
137785
- const workspacePackageJson = (0, import_devkit3.readJsonFile)((0, import_node_path2.join)(workspaceRoot, "package.json"));
137786
- options.external = options.external || [];
137787
- if (workspacePackageJson?.dependencies) {
137788
- options.external = Object.keys(workspacePackageJson?.dependencies).reduce(
137789
- (ret, key) => {
137790
- if (!ret.includes(key)) {
137791
- ret.push(key);
137792
- }
137793
- return ret;
137794
- },
137795
- options.external
137796
- );
137797
- }
137798
- const externalDependencies = options.external.reduce(
137799
- (ret, name) => {
137800
- if (!packageJson?.devDependencies?.[name]) {
137801
- const externalNode = context.projectGraph.externalNodes[`npm:${name}`];
137802
- if (externalNode) {
137803
- ret.push({
137804
- name,
137805
- outputs: [],
137806
- node: externalNode
137807
- });
137808
- }
137790
+ }
137791
+ const result = await (0, import_js2.copyAssets)(
137792
+ { assets, watch: options.watch, outputPath: options.outputPath },
137793
+ context
137794
+ );
137795
+ if (!result.success) {
137796
+ throw new Error("The Build process failed trying to copy assets");
137797
+ }
137798
+ const pathToPackageJson = (0, import_node_path4.join)(context.root, projectRoot, "package.json");
137799
+ const packageJson = (0, import_fileutils.fileExists)(pathToPackageJson) ? (0, import_devkit3.readJsonFile)(pathToPackageJson) : { name: context.projectName, version: "0.0.1" };
137800
+ const workspacePackageJson = (0, import_devkit3.readJsonFile)((0, import_node_path4.join)(workspaceRoot, "package.json"));
137801
+ options.external = options.external || [];
137802
+ if (workspacePackageJson?.dependencies) {
137803
+ options.external = Object.keys(workspacePackageJson?.dependencies).reduce(
137804
+ (ret, key) => {
137805
+ if (!ret.includes(key)) {
137806
+ ret.push(key);
137809
137807
  }
137810
137808
  return ret;
137811
137809
  },
137812
- []
137810
+ options.external
137813
137811
  );
137814
- const implicitDependencies = context.projectsConfigurations.projects[context.projectName].implicitDependencies;
137815
- const internalDependencies = [];
137816
- const projectConfigs = await Promise.resolve(getProjectConfigurations());
137817
- if (getLogLevel(config?.logLevel) >= LogLevel.TRACE) {
137818
- writeDebug(config, "Project Configs:");
137819
- console.log(projectConfigs);
137820
- }
137821
- if (implicitDependencies && implicitDependencies.length > 0) {
137822
- options.external = implicitDependencies.reduce((ret, key) => {
137823
- if (getLogLevel(config?.logLevel) >= LogLevel.DEBUG) {
137824
- writeDebug(config, `\u26A1 Adding implicit dependency: ${key}`);
137825
- }
137826
- const projectConfig = projectConfigs[key];
137827
- if (projectConfig?.targets?.build) {
137828
- const projectPackageJson = (0, import_devkit3.readJsonFile)(projectConfig.targets?.build.options.project);
137829
- if (projectPackageJson?.name && !options.external.includes(projectPackageJson.name)) {
137830
- ret.push(projectPackageJson.name);
137831
- internalDependencies.push(projectPackageJson.name);
137832
- }
137833
- }
137834
- return ret;
137835
- }, options.external);
137836
- }
137837
- if (options.bundle === false) {
137838
- for (const thirdPartyDependency of getExternalDependencies(
137839
- context.projectName,
137840
- context.projectGraph
137841
- )) {
137842
- const packageConfig = thirdPartyDependency.node.data;
137843
- if (packageConfig?.packageName) {
137844
- options.external.push(packageConfig.packageName);
137845
- if (!packageJson?.devDependencies?.[packageConfig.packageName]) {
137846
- externalDependencies.push(thirdPartyDependency);
137847
- }
137812
+ }
137813
+ const externalDependencies = options.external.reduce(
137814
+ (ret, name) => {
137815
+ if (!packageJson?.devDependencies?.[name]) {
137816
+ const externalNode = context.projectGraph.externalNodes[`npm:${name}`];
137817
+ if (externalNode) {
137818
+ ret.push({
137819
+ name,
137820
+ outputs: [],
137821
+ node: externalNode
137822
+ });
137848
137823
  }
137849
137824
  }
137850
- }
137851
- if (getLogLevel(config?.logLevel) >= LogLevel.TRACE) {
137852
- console.log(`Building with the following dependencies marked as external:
137853
- ${externalDependencies.map((dep) => {
137854
- return `name: ${dep.name}, node: ${dep.node}, outputs: ${dep.outputs}`;
137855
- }).join("\n")}`);
137856
- }
137857
- const prettierOptions = {
137858
- plugins: ["prettier-plugin-packagejson"],
137859
- trailingComma: "none",
137860
- tabWidth: 2,
137861
- semi: true,
137862
- singleQuote: false,
137863
- quoteProps: "preserve",
137864
- insertPragma: false,
137865
- bracketSameLine: true,
137866
- printWidth: 80,
137867
- bracketSpacing: true,
137868
- arrowParens: "avoid",
137869
- endOfLine: "lf"
137870
- };
137871
- const entryPoints = [];
137872
- if (options.entry) {
137873
- entryPoints.push(options.entry);
137874
- }
137875
- if (options.emitOnAll === true) {
137876
- entryPoints.push((0, import_devkit3.joinPathFragments)(sourceRoot, "**/*.{ts,tsx}"));
137877
- }
137878
- if (options.additionalEntryPoints) {
137879
- entryPoints.push(...options.additionalEntryPoints);
137880
- }
137881
- const entry = globSync(entryPoints, {
137882
- withFileTypes: true
137883
- }).reduce((ret, filePath) => {
137884
- let formattedPath = workspaceRoot.replaceAll("\\", "/");
137885
- if (formattedPath.toUpperCase().startsWith("C:")) {
137886
- formattedPath = formattedPath.substring(2);
137887
- }
137888
- let propertyKey = (0, import_devkit3.joinPathFragments)(filePath.path, removeExtension(filePath.name)).replaceAll("\\", "/").replaceAll(formattedPath, "").replaceAll(sourceRoot, "").replaceAll(projectRoot, "");
137889
- if (propertyKey) {
137890
- while (propertyKey.startsWith("/")) {
137891
- propertyKey = propertyKey.substring(1);
137892
- }
137893
- if (getLogLevel(config?.logLevel) >= LogLevel.DEBUG) {
137894
- console.debug(
137895
- `Trying to add entry point ${propertyKey} at "${(0, import_devkit3.joinPathFragments)(
137896
- filePath.path,
137897
- filePath.name
137898
- )}"`
137899
- );
137900
- }
137901
- if (!(propertyKey in ret)) {
137902
- ret[propertyKey] = (0, import_devkit3.joinPathFragments)(filePath.path, filePath.name);
137825
+ return ret;
137826
+ },
137827
+ []
137828
+ );
137829
+ const implicitDependencies = context.projectsConfigurations.projects[context.projectName].implicitDependencies;
137830
+ const internalDependencies = [];
137831
+ const projectConfigs = await Promise.resolve(getProjectConfigurations());
137832
+ if (getLogLevel(config?.logLevel) >= LogLevel.TRACE) {
137833
+ writeDebug(config, "Project Configs:");
137834
+ console.log(projectConfigs);
137835
+ }
137836
+ if (implicitDependencies && implicitDependencies.length > 0) {
137837
+ options.external = implicitDependencies.reduce((ret, key) => {
137838
+ writeDebug(config, `\u26A1 Adding implicit dependency: ${key}`);
137839
+ const projectConfig = projectConfigs[key];
137840
+ if (projectConfig?.targets?.build) {
137841
+ const projectPackageJson = (0, import_devkit3.readJsonFile)(projectConfig.targets?.build.options.project);
137842
+ if (projectPackageJson?.name && !options.external.includes(projectPackageJson.name)) {
137843
+ ret.push(projectPackageJson.name);
137844
+ internalDependencies.push(projectPackageJson.name);
137903
137845
  }
137904
137846
  }
137905
137847
  return ret;
137906
- }, {});
137907
- if (options.generatePackageJson !== false) {
137908
- const projectGraph = (0, import_devkit3.readCachedProjectGraph)();
137909
- packageJson.dependencies = void 0;
137910
- for (const externalDependency of externalDependencies) {
137911
- const packageConfig = externalDependency.node.data;
137912
- if (packageConfig?.packageName && !!(projectGraph.externalNodes[externalDependency.node.name]?.type === "npm")) {
137913
- const { packageName, version } = packageConfig;
137914
- if (workspacePackageJson.dependencies?.[packageName] || workspacePackageJson.devDependencies?.[packageName] || packageJson?.devDependencies?.[packageName]) {
137915
- return null;
137916
- }
137917
- packageJson.dependencies ??= {};
137918
- packageJson.dependencies[packageName] = projectGraph.nodes[externalDependency.node.name] ? "latest" : version;
137848
+ }, options.external);
137849
+ }
137850
+ if (options.bundle === false) {
137851
+ for (const thirdPartyDependency of getExternalDependencies(
137852
+ context.projectName,
137853
+ context.projectGraph
137854
+ )) {
137855
+ const packageConfig = thirdPartyDependency.node.data;
137856
+ if (packageConfig?.packageName) {
137857
+ options.external.push(packageConfig.packageName);
137858
+ if (!packageJson?.devDependencies?.[packageConfig.packageName]) {
137859
+ externalDependencies.push(thirdPartyDependency);
137919
137860
  }
137920
137861
  }
137921
- for (const packageName of internalDependencies) {
137922
- if (!packageJson?.devDependencies?.[packageName]) {
137923
- packageJson.dependencies ??= {};
137924
- packageJson.dependencies[packageName] = "latest";
137862
+ }
137863
+ }
137864
+ writeTrace(
137865
+ config,
137866
+ `Building with the following dependencies marked as external:
137867
+ ${externalDependencies.map((dep) => {
137868
+ return `name: ${dep.name}, node: ${dep.node}, outputs: ${dep.outputs}`;
137869
+ }).join("\n")}`
137870
+ );
137871
+ const prettierOptions = {
137872
+ plugins: ["prettier-plugin-packagejson"],
137873
+ trailingComma: "none",
137874
+ tabWidth: 2,
137875
+ semi: true,
137876
+ singleQuote: false,
137877
+ quoteProps: "preserve",
137878
+ insertPragma: false,
137879
+ bracketSameLine: true,
137880
+ printWidth: 80,
137881
+ bracketSpacing: true,
137882
+ arrowParens: "avoid",
137883
+ endOfLine: "lf"
137884
+ };
137885
+ const entryPoints = [];
137886
+ if (options.entry) {
137887
+ entryPoints.push(options.entry);
137888
+ }
137889
+ if (options.emitOnAll === true) {
137890
+ entryPoints.push((0, import_devkit3.joinPathFragments)(sourceRoot, "**/*.{ts,tsx}"));
137891
+ }
137892
+ if (options.additionalEntryPoints) {
137893
+ entryPoints.push(...options.additionalEntryPoints);
137894
+ }
137895
+ const entry = globSync(entryPoints, {
137896
+ withFileTypes: true
137897
+ }).reduce((ret, filePath) => {
137898
+ let formattedPath = workspaceRoot.replaceAll("\\", "/");
137899
+ if (formattedPath.toUpperCase().startsWith("C:")) {
137900
+ formattedPath = formattedPath.substring(2);
137901
+ }
137902
+ let propertyKey = (0, import_devkit3.joinPathFragments)(filePath.path, removeExtension(filePath.name)).replaceAll("\\", "/").replaceAll(formattedPath, "").replaceAll(sourceRoot, "").replaceAll(projectRoot, "");
137903
+ if (propertyKey) {
137904
+ while (propertyKey.startsWith("/")) {
137905
+ propertyKey = propertyKey.substring(1);
137906
+ }
137907
+ writeDebug(
137908
+ config,
137909
+ `Trying to add entry point ${propertyKey} at "${(0, import_devkit3.joinPathFragments)(
137910
+ filePath.path,
137911
+ filePath.name
137912
+ )}"`
137913
+ );
137914
+ if (!(propertyKey in ret)) {
137915
+ ret[propertyKey] = (0, import_devkit3.joinPathFragments)(filePath.path, filePath.name);
137916
+ }
137917
+ }
137918
+ return ret;
137919
+ }, {});
137920
+ if (options.generatePackageJson !== false) {
137921
+ const projectGraph = (0, import_devkit3.readCachedProjectGraph)();
137922
+ packageJson.dependencies = void 0;
137923
+ for (const externalDependency of externalDependencies) {
137924
+ const packageConfig = externalDependency.node.data;
137925
+ if (packageConfig?.packageName && !!(projectGraph.externalNodes[externalDependency.node.name]?.type === "npm")) {
137926
+ const { packageName, version } = packageConfig;
137927
+ if (workspacePackageJson.dependencies?.[packageName] || workspacePackageJson.devDependencies?.[packageName] || packageJson?.devDependencies?.[packageName]) {
137928
+ return null;
137925
137929
  }
137930
+ packageJson.dependencies ??= {};
137931
+ packageJson.dependencies[packageName] = projectGraph.nodes[externalDependency.node.name] ? "latest" : version;
137926
137932
  }
137927
- const distPaths = !options?.getConfig || _isFunction(options.getConfig) ? ["dist/"] : Object.keys(options.getConfig).map((key) => `${key}/`);
137928
- packageJson.type = "module";
137929
- if (distPaths.length > 0) {
137930
- packageJson.exports ??= {
137931
- ".": {
137933
+ }
137934
+ for (const packageName of internalDependencies) {
137935
+ if (!packageJson?.devDependencies?.[packageName]) {
137936
+ packageJson.dependencies ??= {};
137937
+ packageJson.dependencies[packageName] = "latest";
137938
+ }
137939
+ }
137940
+ const distPaths = !options?.getConfig || _isFunction(options.getConfig) ? ["dist/"] : Object.keys(options.getConfig).map((key) => `${key}/`);
137941
+ packageJson.type = "module";
137942
+ if (distPaths.length > 0) {
137943
+ packageJson.exports ??= {
137944
+ ".": {
137945
+ import: {
137946
+ types: `./${distPaths[0]}index.d.ts`,
137947
+ default: `./${distPaths[0]}index.js`
137948
+ },
137949
+ require: {
137950
+ types: `./${distPaths[0]}index.d.cts`,
137951
+ default: `./${distPaths[0]}index.cjs`
137952
+ },
137953
+ default: {
137954
+ types: `./${distPaths[0]}index.d.ts`,
137955
+ default: `./${distPaths[0]}index.js`
137956
+ },
137957
+ ...(options.additionalEntryPoints ?? []).map((entryPoint) => ({
137958
+ [removeExtension(entryPoint).replace(sourceRoot, "")]: {
137959
+ types: (0, import_node_path4.join)(
137960
+ `./${distPaths[0]}`,
137961
+ `${removeExtension(entryPoint.replace(sourceRoot, ""))}.d.ts`
137962
+ ),
137963
+ default: (0, import_node_path4.join)(
137964
+ `./${distPaths[0]}`,
137965
+ `${removeExtension(entryPoint.replace(sourceRoot, ""))}.js`
137966
+ )
137967
+ }
137968
+ }))
137969
+ },
137970
+ "./package.json": "./package.json"
137971
+ };
137972
+ packageJson.exports = Object.keys(entry).reduce((ret, key) => {
137973
+ let packageJsonKey = key.startsWith("./") ? key : `./${key}`;
137974
+ packageJsonKey = packageJsonKey.replaceAll("/index", "");
137975
+ if (!ret[packageJsonKey]) {
137976
+ ret[packageJsonKey] = {
137932
137977
  import: {
137933
137978
  types: `./${distPaths[0]}index.d.ts`,
137934
- default: `./${distPaths[0]}index.js`
137979
+ default: `./${distPaths[0]}${key}.js`
137935
137980
  },
137936
137981
  require: {
137937
137982
  types: `./${distPaths[0]}index.d.cts`,
137938
- default: `./${distPaths[0]}index.cjs`
137983
+ default: `./${distPaths[0]}${key}.cjs`
137939
137984
  },
137940
137985
  default: {
137941
137986
  types: `./${distPaths[0]}index.d.ts`,
137942
- default: `./${distPaths[0]}index.js`
137943
- },
137944
- ...(options.additionalEntryPoints ?? []).map((entryPoint) => ({
137945
- [removeExtension(entryPoint).replace(sourceRoot, "")]: {
137946
- types: (0, import_node_path2.join)(
137947
- `./${distPaths[0]}`,
137948
- `${removeExtension(entryPoint.replace(sourceRoot, ""))}.d.ts`
137949
- ),
137950
- default: (0, import_node_path2.join)(
137951
- `./${distPaths[0]}`,
137952
- `${removeExtension(entryPoint.replace(sourceRoot, ""))}.js`
137953
- )
137954
- }
137955
- }))
137956
- },
137957
- "./package.json": "./package.json"
137958
- };
137959
- packageJson.exports = Object.keys(entry).reduce((ret, key) => {
137960
- let packageJsonKey = key.startsWith("./") ? key : `./${key}`;
137961
- packageJsonKey = packageJsonKey.replaceAll("/index", "");
137962
- if (!ret[packageJsonKey]) {
137963
- ret[packageJsonKey] = {
137964
- import: {
137965
- types: `./${distPaths[0]}index.d.ts`,
137966
- default: `./${distPaths[0]}${key}.js`
137967
- },
137968
- require: {
137969
- types: `./${distPaths[0]}index.d.cts`,
137970
- default: `./${distPaths[0]}${key}.cjs`
137971
- },
137972
- default: {
137973
- types: `./${distPaths[0]}index.d.ts`,
137974
- default: `./${distPaths[0]}${key}.js`
137975
- }
137976
- };
137977
- }
137978
- return ret;
137979
- }, packageJson.exports);
137980
- packageJson.funding ??= workspacePackageJson.funding;
137981
- packageJson.types ??= `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.d.ts`;
137982
- packageJson.typings ??= `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.d.ts`;
137983
- packageJson.typescript ??= {
137984
- definition: `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.d.ts`
137985
- };
137986
- packageJson.main ??= `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.cjs`;
137987
- packageJson.module ??= `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.js`;
137988
- if (options.platform && options.platform !== "node") {
137989
- packageJson.browser ??= `${distPaths[0]}index.global.js`;
137990
- }
137991
- if (options.includeSrc === true) {
137992
- let distSrc = sourceRoot.replace(projectRoot, "");
137993
- if (distSrc.startsWith("/")) {
137994
- distSrc = distSrc.substring(1);
137995
- }
137996
- packageJson.source ??= `${(0, import_node_path2.join)(distSrc, "index.ts").replaceAll("\\", "/")}`;
137997
- }
137998
- packageJson.sideEffects ??= false;
137999
- packageJson.files ??= ["dist/**/*"];
138000
- if (options.includeSrc === true && !packageJson.files.includes("src")) {
138001
- packageJson.files.push("src/**/*");
137987
+ default: `./${distPaths[0]}${key}.js`
137988
+ }
137989
+ };
138002
137990
  }
138003
- }
138004
- packageJson.publishConfig ??= {
138005
- access: "public"
138006
- };
138007
- packageJson.description ??= workspacePackageJson.description;
138008
- packageJson.homepage ??= workspacePackageJson.homepage;
138009
- packageJson.bugs ??= workspacePackageJson.bugs;
138010
- packageJson.author ??= workspacePackageJson.author;
138011
- packageJson.license ??= workspacePackageJson.license;
138012
- packageJson.keywords ??= workspacePackageJson.keywords;
138013
- packageJson.repository ??= workspacePackageJson.repository;
138014
- packageJson.repository.directory ??= projectRoot ? projectRoot : (0, import_node_path2.join)("packages", context.projectName);
138015
- const packageJsonPath = (0, import_node_path2.join)(context.root, options.outputPath, "package.json");
138016
- if (getLogLevel(config?.logLevel) >= LogLevel.DEBUG) {
138017
- writeDebug(config, `\u26A1 Writing package.json file to: ${packageJsonPath}`);
138018
- }
138019
- (0, import_node_fs.writeFileSync)(
138020
- packageJsonPath,
138021
- await (0, import_prettier.format)(JSON.stringify(packageJson), {
138022
- ...prettierOptions,
138023
- parser: "json"
138024
- })
138025
- );
138026
- }
138027
- if (options.includeSrc === true) {
138028
- const files = globSync([
138029
- (0, import_devkit3.joinPathFragments)(context.root, options.outputPath, "src/**/*.ts"),
138030
- (0, import_devkit3.joinPathFragments)(context.root, options.outputPath, "src/**/*.tsx"),
138031
- (0, import_devkit3.joinPathFragments)(context.root, options.outputPath, "src/**/*.js"),
138032
- (0, import_devkit3.joinPathFragments)(context.root, options.outputPath, "src/**/*.jsx")
138033
- ]);
138034
- await Promise.allSettled(
138035
- files.map(
138036
- async (file) => (0, import_promises2.writeFile)(
138037
- file,
138038
- await (0, import_prettier.format)(
138039
- `${options.banner ? options.banner.startsWith("//") ? options.banner : `// ${options.banner}` : ""}
138040
-
138041
- ${(0, import_node_fs.readFileSync)(file, "utf-8")}`,
138042
- {
138043
- ...prettierOptions,
138044
- parser: "typescript"
138045
- }
138046
- ),
138047
- "utf-8"
138048
- )
138049
- )
138050
- );
138051
- }
138052
- const stormEnv = Object.keys(options.env).filter((key) => key.startsWith("STORM_")).reduce((ret, key) => {
138053
- ret[key] = options.env[key];
138054
- return ret;
138055
- }, {});
138056
- options.plugins.push(
138057
- (0, import_esbuild_decorators.esbuildDecorators)({
138058
- tsconfig: options.tsConfig,
138059
- cwd: workspaceRoot
137991
+ return ret;
137992
+ }, packageJson.exports);
137993
+ packageJson.funding ??= workspacePackageJson.funding;
137994
+ packageJson.types ??= `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.d.ts`;
137995
+ packageJson.typings ??= `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.d.ts`;
137996
+ packageJson.typescript ??= {
137997
+ definition: `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.d.ts`
137998
+ };
137999
+ packageJson.main ??= `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.cjs`;
138000
+ packageJson.module ??= `${distPaths.length > 1 ? distPaths[1] : distPaths[0]}index.js`;
138001
+ if (options.platform && options.platform !== "node") {
138002
+ packageJson.browser ??= `${distPaths[0]}index.global.js`;
138003
+ }
138004
+ if (options.includeSrc === true) {
138005
+ let distSrc = sourceRoot.replace(projectRoot, "");
138006
+ if (distSrc.startsWith("/")) {
138007
+ distSrc = distSrc.substring(1);
138008
+ }
138009
+ packageJson.source ??= `${(0, import_node_path4.join)(distSrc, "index.ts").replaceAll("\\", "/")}`;
138010
+ }
138011
+ packageJson.sideEffects ??= false;
138012
+ packageJson.files ??= ["dist/**/*"];
138013
+ if (options.includeSrc === true && !packageJson.files.includes("src")) {
138014
+ packageJson.files.push("src/**/*");
138015
+ }
138016
+ }
138017
+ packageJson.publishConfig ??= {
138018
+ access: "public"
138019
+ };
138020
+ packageJson.description ??= workspacePackageJson.description;
138021
+ packageJson.homepage ??= workspacePackageJson.homepage;
138022
+ packageJson.bugs ??= workspacePackageJson.bugs;
138023
+ packageJson.author ??= workspacePackageJson.author;
138024
+ packageJson.license ??= workspacePackageJson.license;
138025
+ packageJson.keywords ??= workspacePackageJson.keywords;
138026
+ packageJson.repository ??= workspacePackageJson.repository;
138027
+ packageJson.repository.directory ??= projectRoot ? projectRoot : (0, import_node_path4.join)("packages", context.projectName);
138028
+ const packageJsonPath = (0, import_node_path4.join)(context.root, options.outputPath, "package.json");
138029
+ writeDebug(config, `\u26A1 Writing package.json file to: ${packageJsonPath}`);
138030
+ (0, import_node_fs3.writeFileSync)(
138031
+ packageJsonPath,
138032
+ await (0, import_prettier.format)(JSON.stringify(packageJson), {
138033
+ ...prettierOptions,
138034
+ parser: "json"
138060
138035
  })
138061
138036
  );
138062
- options.plugins.push(environmentPlugin(stormEnv));
138063
- const getConfigOptions = {
138064
- ...options,
138065
- define: {
138066
- __STORM_CONFIG: JSON.stringify(stormEnv)
138067
- },
138068
- env: {
138069
- __STORM_CONFIG: JSON.stringify(stormEnv),
138070
- ...stormEnv
138071
- },
138072
- dtsTsConfig: getNormalizedTsConfig(
138073
- context.root,
138074
- options.outputPath,
138075
- (0, import_tsc.createTypeScriptCompilationOptions)(
138076
- (0, import_normalize_options.normalizeOptions)(
138037
+ } else {
138038
+ writeWarning(config, "Skipping writing to package.json file");
138039
+ }
138040
+ if (options.includeSrc === true) {
138041
+ const files = globSync([
138042
+ (0, import_devkit3.joinPathFragments)(context.root, options.outputPath, "src/**/*.ts"),
138043
+ (0, import_devkit3.joinPathFragments)(context.root, options.outputPath, "src/**/*.tsx"),
138044
+ (0, import_devkit3.joinPathFragments)(context.root, options.outputPath, "src/**/*.js"),
138045
+ (0, import_devkit3.joinPathFragments)(context.root, options.outputPath, "src/**/*.jsx")
138046
+ ]);
138047
+ await Promise.allSettled(
138048
+ files.map(
138049
+ async (file) => (0, import_promises2.writeFile)(
138050
+ file,
138051
+ await (0, import_prettier.format)(
138052
+ `${options.banner ? options.banner.startsWith("//") ? options.banner : `// ${options.banner}` : ""}
138053
+
138054
+ ${(0, import_node_fs3.readFileSync)(file, "utf-8")}`,
138077
138055
  {
138078
- ...options,
138079
- watch: false,
138080
- main: options.entry,
138081
- transformers: options.skipTypia ? [] : ["typia/lib/transform"]
138082
- },
138083
- context.root,
138084
- sourceRoot,
138085
- workspaceRoot
138056
+ ...prettierOptions,
138057
+ parser: "typescript"
138058
+ }
138086
138059
  ),
138087
- context
138060
+ "utf-8"
138088
138061
  )
138089
- ),
138090
- banner: options.banner ? {
138091
- js: `${options.banner}
138062
+ )
138063
+ );
138064
+ }
138065
+ const stormEnv = Object.keys(options.env).filter((key) => key.startsWith("STORM_")).reduce((ret, key) => {
138066
+ ret[key] = options.env[key];
138067
+ return ret;
138068
+ }, {});
138069
+ options.plugins.push(
138070
+ (0, import_esbuild_decorators.esbuildDecorators)({
138071
+ tsconfig: options.tsConfig,
138072
+ cwd: workspaceRoot
138073
+ })
138074
+ );
138075
+ options.plugins.push(environmentPlugin(stormEnv));
138076
+ const getConfigOptions = {
138077
+ ...options,
138078
+ define: {
138079
+ __STORM_CONFIG: JSON.stringify(stormEnv)
138080
+ },
138081
+ env: {
138082
+ __STORM_CONFIG: JSON.stringify(stormEnv),
138083
+ ...stormEnv
138084
+ },
138085
+ dtsTsConfig: getNormalizedTsConfig(
138086
+ context.root,
138087
+ options.outputPath,
138088
+ (0, import_tsc.createTypeScriptCompilationOptions)(
138089
+ (0, import_normalize_options.normalizeOptions)(
138090
+ {
138091
+ ...options,
138092
+ watch: false,
138093
+ main: options.entry,
138094
+ transformers: options.skipTypia ? [] : ["typia/lib/transform"]
138095
+ },
138096
+ context.root,
138097
+ sourceRoot,
138098
+ workspaceRoot
138099
+ ),
138100
+ context
138101
+ )
138102
+ ),
138103
+ banner: options.banner ? {
138104
+ js: `${options.banner}
138092
138105
 
138093
138106
  `,
138094
- css: `/*
138107
+ css: `/*
138095
138108
  ${options.banner}
138096
138109
  */
138097
138110
 
138098
138111
  `
138099
- } : void 0,
138100
- outputPath: options.outputPath,
138101
- entry,
138102
- getTransform: options.skipTypia ? void 0 : getTypiaTransform
138103
- };
138104
- if (options.getConfig) {
138105
- if (getLogLevel(config?.logLevel) >= LogLevel.INFO) {
138106
- writeInfo(config, "\u26A1 Running the Build process");
138107
- }
138108
- const getConfigFns = _isFunction(options.getConfig) ? [options.getConfig] : Object.keys(options.getConfig).map((key) => options.getConfig[key]);
138109
- const tsupConfig = (0, import_tsup.defineConfig)(
138110
- getConfigFns.map(
138111
- (getConfigFn) => getConfig(context.root, projectRoot, getConfigFn, getConfigOptions)
138112
- )
138113
- );
138114
- if (_isFunction(tsupConfig)) {
138115
- await build(await Promise.resolve(tsupConfig({})), config);
138116
- } else {
138117
- await build(tsupConfig, config);
138118
- }
138119
- } else if (getLogLevel(config?.logLevel) >= LogLevel.WARN) {
138120
- writeWarning(
138121
- config,
138122
- "The Build process did not run because no `getConfig` parameter was provided"
138123
- );
138124
- }
138125
- if (getLogLevel(config?.logLevel) >= LogLevel.INFO) {
138126
- writeSuccess(config, "\u26A1 The Build process has completed successfully");
138112
+ } : void 0,
138113
+ outputPath: options.outputPath,
138114
+ entry,
138115
+ getTransform: options.skipTypia ? void 0 : getTypiaTransform
138116
+ };
138117
+ if (options.getConfig) {
138118
+ writeInfo(config, "\u26A1 Running the Build process");
138119
+ const getConfigFns = _isFunction(options.getConfig) ? [options.getConfig] : Object.keys(options.getConfig).map((key) => options.getConfig[key]);
138120
+ const tsupConfig = (0, import_tsup.defineConfig)(
138121
+ getConfigFns.map(
138122
+ (getConfigFn) => getConfig(context.root, projectRoot, getConfigFn, getConfigOptions)
138123
+ )
138124
+ );
138125
+ if (_isFunction(tsupConfig)) {
138126
+ await build(await Promise.resolve(tsupConfig({})), config);
138127
+ } else {
138128
+ await build(tsupConfig, config);
138127
138129
  }
138128
- return {
138129
- success: true
138130
- };
138131
- } catch (e) {
138132
- console.error(e);
138133
- return {
138134
- success: false
138135
- };
138130
+ } else if (getLogLevel(config?.logLevel) >= LogLevel.WARN) {
138131
+ writeWarning(
138132
+ config,
138133
+ "The Build process did not run because no `getConfig` parameter was provided"
138134
+ );
138136
138135
  }
138136
+ writeSuccess(config, "\u26A1 The Build process has completed successfully");
138137
+ return {
138138
+ success: true
138139
+ };
138137
138140
  }
138138
138141
  function getNormalizedTsConfig(workspaceRoot, outputPath, options) {
138139
138142
  const config = ts.readConfigFile(options.tsConfig, ts.sys.readFile).config;
@@ -138153,11 +138156,11 @@ function getNormalizedTsConfig(workspaceRoot, outputPath, options) {
138153
138156
  emitDeclarationOnly: true,
138154
138157
  declaration: true,
138155
138158
  declarationMap: true,
138156
- declarationDir: (0, import_node_path2.join)(workspaceRoot, "tmp", ".tsup", "declaration")
138159
+ declarationDir: (0, import_node_path4.join)(workspaceRoot, "tmp", ".tsup", "declaration")
138157
138160
  }
138158
138161
  },
138159
138162
  ts.sys,
138160
- (0, import_node_path2.dirname)(options.tsConfig)
138163
+ (0, import_node_path4.dirname)(options.tsConfig)
138161
138164
  );
138162
138165
  tsConfig.options.pathsBasePath = workspaceRoot;
138163
138166
  if (tsConfig.options.incremental && !tsConfig.options.tsBuildInfoFile) {
@@ -138483,8 +138486,8 @@ var executor_default3 = withRunExecutor(
138483
138486
 
138484
138487
  // packages/workspace-tools/src/generators/config-schema/generator.ts
138485
138488
  var import_devkit6 = __toESM(require_devkit());
138486
- var import_fs4 = require("fs");
138487
- var import_path4 = require("path");
138489
+ var import_fs2 = require("fs");
138490
+ var import_path2 = require("path");
138488
138491
 
138489
138492
  // node_modules/.pnpm/zod-to-json-schema@3.22.1_zod@3.22.4/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
138490
138493
  function addErrorMessage(res, key, errorMessage, refs) {
@@ -139504,11 +139507,11 @@ async function configSchemaGeneratorFn(tree, options) {
139504
139507
  const modules = await Promise.all(
139505
139508
  Object.keys(projectConfigurations).map(async (key) => {
139506
139509
  if (projectConfigurations[key]?.config) {
139507
- const configPath = (0, import_path4.join)(
139510
+ const configPath = (0, import_path2.join)(
139508
139511
  workspaceRoot,
139509
139512
  projectConfigurations[key].config
139510
139513
  );
139511
- if ((0, import_fs4.existsSync)(configPath)) {
139514
+ if ((0, import_fs2.existsSync)(configPath)) {
139512
139515
  const mod = await import(configPath);
139513
139516
  if (mod.default) {
139514
139517
  return { name: key, schema: mod.default };
@@ -139536,7 +139539,7 @@ async function configSchemaGeneratorFn(tree, options) {
139536
139539
  );
139537
139540
  (0, import_devkit6.writeJson)(
139538
139541
  tree,
139539
- options.outputFile ? (0, import_path4.join)(workspaceRoot, options.outputFile) : (0, import_path4.join)(workspaceRoot, "storm.schema.json"),
139542
+ options.outputFile ? (0, import_path2.join)(workspaceRoot, options.outputFile) : (0, import_path2.join)(workspaceRoot, "storm.schema.json"),
139540
139543
  zodToJsonSchema(ModulesSchema, "StormConfig")
139541
139544
  );
139542
139545
  await (0, import_devkit6.formatFiles)(tree);
@@ -139835,12 +139838,12 @@ var generator_default3 = withRunGenerator(
139835
139838
  );
139836
139839
 
139837
139840
  // packages/workspace-tools/src/utils/find-cache-dir.ts
139838
- var import_node_fs2 = require("node:fs");
139839
- var import_node_path3 = require("node:path");
139841
+ var import_node_fs4 = require("node:fs");
139842
+ var import_node_path5 = require("node:path");
139840
139843
  var import_node_process = require("node:process");
139841
139844
  var isWritable2 = (path3) => {
139842
139845
  try {
139843
- (0, import_node_fs2.accessSync)(path3, import_node_fs2.constants.W_OK);
139846
+ (0, import_node_fs4.accessSync)(path3, import_node_fs4.constants.W_OK);
139844
139847
  return true;
139845
139848
  } catch {
139846
139849
  return false;
@@ -139848,13 +139851,13 @@ var isWritable2 = (path3) => {
139848
139851
  };
139849
139852
  function useDirectory(directory, { create = true }) {
139850
139853
  if (create) {
139851
- (0, import_node_fs2.mkdirSync)(directory, { recursive: true });
139854
+ (0, import_node_fs4.mkdirSync)(directory, { recursive: true });
139852
139855
  }
139853
139856
  return directory;
139854
139857
  }
139855
139858
  function getNodeModuleDirectory(workspaceRoot) {
139856
- const nodeModules = (0, import_node_path3.join)(workspaceRoot, "node_modules");
139857
- if ((0, import_node_fs2.existsSync)(nodeModules) && !isWritable2(nodeModules)) {
139859
+ const nodeModules = (0, import_node_path5.join)(workspaceRoot, "node_modules");
139860
+ if ((0, import_node_fs4.existsSync)(nodeModules) && !isWritable2(nodeModules)) {
139858
139861
  throw new Error("Cannot write to node_modules directory");
139859
139862
  }
139860
139863
  return nodeModules;
@@ -139870,10 +139873,10 @@ function findCacheDirectory({
139870
139873
  create: true
139871
139874
  }) {
139872
139875
  if (import_node_process.env.CACHE_DIR && !["true", "false", "1", "0"].includes(import_node_process.env.CACHE_DIR)) {
139873
- return useDirectory((0, import_node_path3.join)(import_node_process.env.CACHE_DIR, name, cacheName), { create });
139876
+ return useDirectory((0, import_node_path5.join)(import_node_process.env.CACHE_DIR, name, cacheName), { create });
139874
139877
  }
139875
139878
  if (import_node_process.env.STORM_CACHE_DIR && !["true", "false", "1", "0"].includes(import_node_process.env.STORM_CACHE_DIR)) {
139876
- return useDirectory((0, import_node_path3.join)(import_node_process.env.STORM_CACHE_DIR, name, cacheName), {
139879
+ return useDirectory((0, import_node_path5.join)(import_node_process.env.STORM_CACHE_DIR, name, cacheName), {
139877
139880
  create
139878
139881
  });
139879
139882
  }
@@ -139882,14 +139885,14 @@ function findCacheDirectory({
139882
139885
  throw new Error("Cannot find node_modules directory");
139883
139886
  }
139884
139887
  return useDirectory(
139885
- (0, import_node_path3.join)(workspaceRoot, "node_modules", ".cache", name, cacheName),
139888
+ (0, import_node_path5.join)(workspaceRoot, "node_modules", ".cache", name, cacheName),
139886
139889
  { create }
139887
139890
  );
139888
139891
  }
139889
139892
 
139890
139893
  // packages/workspace-tools/src/utils/workspace-storage.ts
139891
- var import_node_fs3 = require("node:fs");
139892
- var import_node_path4 = require("node:path");
139894
+ var import_node_fs5 = require("node:fs");
139895
+ var import_node_path6 = require("node:path");
139893
139896
  var WorkspaceStorage = class {
139894
139897
  constructor({
139895
139898
  cacheName,
@@ -139909,9 +139912,9 @@ var WorkspaceStorage = class {
139909
139912
  * @returns The value of the key
139910
139913
  */
139911
139914
  getItem(key) {
139912
- const cacheFile = (0, import_node_path4.join)(this.cacheDir, key);
139913
- if ((0, import_node_fs3.existsSync)(cacheFile)) {
139914
- return (0, import_node_fs3.readFileSync)(cacheFile, "utf-8");
139915
+ const cacheFile = (0, import_node_path6.join)(this.cacheDir, key);
139916
+ if ((0, import_node_fs5.existsSync)(cacheFile)) {
139917
+ return (0, import_node_fs5.readFileSync)(cacheFile, "utf-8");
139915
139918
  }
139916
139919
  return void 0;
139917
139920
  }
@@ -139922,7 +139925,7 @@ var WorkspaceStorage = class {
139922
139925
  * @param value - The value to set
139923
139926
  */
139924
139927
  setItem(key, value) {
139925
- (0, import_node_fs3.writeFileSync)((0, import_node_path4.join)(this.cacheDir, key), value, { encoding: "utf-8" });
139928
+ (0, import_node_fs5.writeFileSync)((0, import_node_path6.join)(this.cacheDir, key), value, { encoding: "utf-8" });
139926
139929
  }
139927
139930
  /**
139928
139931
  * Remove item from cache
@@ -139930,14 +139933,14 @@ var WorkspaceStorage = class {
139930
139933
  * @param key - The key to remove
139931
139934
  */
139932
139935
  removeItem(key) {
139933
- (0, import_node_fs3.rmSync)((0, import_node_path4.join)(this.cacheDir, key), { force: true, recursive: true });
139936
+ (0, import_node_fs5.rmSync)((0, import_node_path6.join)(this.cacheDir, key), { force: true, recursive: true });
139934
139937
  }
139935
139938
  /**
139936
139939
  * Clear the cache
139937
139940
  */
139938
139941
  clear() {
139939
- (0, import_node_fs3.readdirSync)(this.cacheDir).forEach((cacheFile) => {
139940
- (0, import_node_fs3.rmSync)(cacheFile, { force: true, recursive: true });
139942
+ (0, import_node_fs5.readdirSync)(this.cacheDir).forEach((cacheFile) => {
139943
+ (0, import_node_fs5.rmSync)(cacheFile, { force: true, recursive: true });
139941
139944
  });
139942
139945
  }
139943
139946
  /**
@@ -139947,7 +139950,7 @@ var WorkspaceStorage = class {
139947
139950
  * @returns The key at the index
139948
139951
  */
139949
139952
  key(index) {
139950
- const files = (0, import_node_fs3.readdirSync)(this.cacheDir);
139953
+ const files = (0, import_node_fs5.readdirSync)(this.cacheDir);
139951
139954
  if (index < files.length && index >= 0) {
139952
139955
  return files[index];
139953
139956
  }