@powerlines/nx 0.10.46 → 0.10.47

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/{chunk-EUCVGGMW.js → chunk-23GFPMA6.js} +2 -2
  3. package/dist/{chunk-BA3VSEVV.js → chunk-2ZHIKYNK.js} +2 -2
  4. package/dist/{chunk-3BM4F7DF.js → chunk-3IX4CIEZ.js} +2 -2
  5. package/dist/{chunk-BTBIUGND.mjs → chunk-BRGJUSQE.mjs} +1 -1
  6. package/dist/{chunk-R6ECHVU4.mjs → chunk-JLOTTRGF.mjs} +269 -114
  7. package/dist/{chunk-PE72KJBW.mjs → chunk-KAGXZMPG.mjs} +1 -1
  8. package/dist/{chunk-WDCMFWCL.mjs → chunk-RVCS4GUB.mjs} +1 -1
  9. package/dist/{chunk-B73RQF3Y.js → chunk-SMUQRWNQ.js} +270 -115
  10. package/dist/{chunk-QFQYFQT4.mjs → chunk-SW7WPPQ5.mjs} +1 -1
  11. package/dist/{chunk-6MIGHWXS.js → chunk-UC4XWZN3.js} +2 -2
  12. package/dist/{chunk-N4LRSAGW.mjs → chunk-WOB6ZDJH.mjs} +1 -1
  13. package/dist/{chunk-FKZWCQXX.js → chunk-ZUHOITET.js} +2 -2
  14. package/dist/executors.js +14 -14
  15. package/dist/executors.mjs +6 -6
  16. package/dist/index.js +14 -14
  17. package/dist/index.mjs +6 -6
  18. package/dist/src/base/base-executor.js +2 -2
  19. package/dist/src/base/base-executor.mjs +1 -1
  20. package/dist/src/executors/build/executor.js +4 -4
  21. package/dist/src/executors/build/executor.mjs +2 -2
  22. package/dist/src/executors/clean/executor.js +4 -4
  23. package/dist/src/executors/clean/executor.mjs +2 -2
  24. package/dist/src/executors/docs/executor.js +4 -4
  25. package/dist/src/executors/docs/executor.mjs +2 -2
  26. package/dist/src/executors/lint/executor.js +4 -4
  27. package/dist/src/executors/lint/executor.mjs +2 -2
  28. package/dist/src/executors/prepare/executor.js +4 -4
  29. package/dist/src/executors/prepare/executor.mjs +2 -2
  30. package/package.json +8 -8
@@ -21,6 +21,7 @@ var joinPaths = require('@stryke/path/join-paths');
21
21
  var replace = require('@stryke/path/replace');
22
22
  var isFunction = require('@stryke/type-checks/is-function');
23
23
  var isNumber = require('@stryke/type-checks/is-number');
24
+ var isObject = require('@stryke/type-checks/is-object');
24
25
  var isPromise = require('@stryke/type-checks/is-promise');
25
26
  var isSet = require('@stryke/type-checks/is-set');
26
27
  var isSetObject = require('@stryke/type-checks/is-set-object');
@@ -39,38 +40,40 @@ var stormJson = require('@stryke/json/storm-json');
39
40
  var filePathFns = require('@stryke/path/file-path-fns');
40
41
  var titleCase = require('@stryke/string-format/title-case');
41
42
  var exists = require('@stryke/fs/exists');
42
- var writeFile$1 = require('@stryke/fs/write-file');
43
- var prettier = require('prettier');
44
43
  var getEnvPaths = require('@stryke/env/get-env-paths');
45
44
  var getWorkspaceRoot = require('@stryke/fs/get-workspace-root');
46
45
  var hashFiles = require('@stryke/hash/hash-files');
47
46
  var murmurhash = require('@stryke/hash/murmurhash');
48
47
  var getUnique = require('@stryke/helpers/get-unique');
49
48
  var omit = require('@stryke/helpers/omit');
49
+ var fetch = require('@stryke/http/fetch');
50
50
  var isType = require('@stryke/path/is-type');
51
51
  var isNull = require('@stryke/type-checks/is-null');
52
52
  var isString = require('@stryke/type-checks/is-string');
53
53
  var uuid = require('@stryke/unique-id/uuid');
54
54
  var bundleRequire = require('bundle-require');
55
+ var flatCache = require('flat-cache');
56
+ var oxcParser = require('oxc-parser');
57
+ var undici = require('undici');
55
58
  var jiti = require('jiti');
56
59
  var isUndefined = require('@stryke/type-checks/is-undefined');
57
60
  var parseTypeDefinition = require('@stryke/convert/parse-type-definition');
58
61
  var isFile = require('@stryke/fs/is-file');
59
62
  var $ = require('@stryke/capnp');
60
63
  var buffer = require('@stryke/fs/buffer');
61
- var correctPath = require('@stryke/path/correct-path');
62
64
  var isParentPath = require('@stryke/path/is-parent-path');
63
65
  var prettyBytes = require('@stryke/string-format/pretty-bytes');
64
- var flatCache = require('flat-cache');
65
66
  var buffer$1 = require('buffer');
67
+ var prettier = require('prettier');
66
68
  var colors = require('@storm-software/config-tools/utilities/colors');
67
69
  var noop = require('@stryke/helpers/noop');
70
+ var correctPath = require('@stryke/path/correct-path');
68
71
  var slash = require('@stryke/path/slash');
69
72
  var readFile = require('@stryke/fs/read-file');
73
+ var writeFile = require('@stryke/fs/write-file');
70
74
  var fs = require('fs');
71
75
  var promises = require('fs/promises');
72
76
  var path = require('path');
73
- var isObject = require('@stryke/type-checks/is-object');
74
77
 
75
78
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
76
79
 
@@ -359,7 +362,9 @@ async function callHook(context, hook, options, ...args) {
359
362
  if (!isFunction.isFunction(handler)) {
360
363
  throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
361
364
  }
362
- return Promise.resolve(handler.apply(null, ...args));
365
+ return Promise.resolve(handler.apply(null, [
366
+ ...args
367
+ ]));
363
368
  }));
364
369
  } else {
365
370
  for (const handler of handlers) {
@@ -367,7 +372,9 @@ async function callHook(context, hook, options, ...args) {
367
372
  throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
368
373
  }
369
374
  if (options?.result === "first" || options?.asNextParam === false) {
370
- results.push(await Promise.resolve(handler.apply(null, ...args)));
375
+ results.push(await Promise.resolve(handler.apply(null, [
376
+ ...args
377
+ ])));
371
378
  if (options?.result === "first" && isSet.isSet(results[results.length - 1])) {
372
379
  break;
373
380
  }
@@ -379,12 +386,22 @@ async function callHook(context, hook, options, ...args) {
379
386
  sequenceArgs[0] = isFunction.isFunction(options.asNextParam) ? await Promise.resolve(options.asNextParam(results[0])) : results[0];
380
387
  }
381
388
  const result = await Promise.resolve(
382
- // eslint-disable-next-line ts/no-unsafe-call
383
- handler.apply(null, ...sequenceArgs)
389
+ // eslint-disable-next-line ts/no-unsafe-call, no-useless-call
390
+ handler.apply(null, [
391
+ ...sequenceArgs
392
+ ])
384
393
  );
385
- results = [
386
- result
387
- ];
394
+ if (result) {
395
+ if (options?.result === "last") {
396
+ results = [
397
+ result
398
+ ];
399
+ } else {
400
+ results = [
401
+ defu6.defu(result, results[0] ?? {})
402
+ ];
403
+ }
404
+ }
388
405
  }
389
406
  }
390
407
  }
@@ -550,33 +567,20 @@ ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && err
550
567
  };
551
568
  }
552
569
  chunkSHUYVCID_js.__name(getParsedTypeScriptConfig, "getParsedTypeScriptConfig");
553
- async function writeFile(log, filepath, content, skipFormat = false) {
554
- try {
555
- if (skipFormat) {
556
- await writeFile$1.writeFile(filepath, content);
557
- } else {
558
- const config = await prettier.resolveConfig(filepath);
559
- const formatted = await prettier.format(content, {
560
- ...config ?? {},
561
- filepath
562
- });
563
- await writeFile$1.writeFile(filepath, formatted || "");
564
- }
565
- } catch (error) {
566
- log(types.LogLevelLabel.ERROR, `Failed to write file ${filepath} to disk
567
- ${error?.message ? error.message : ""}`);
568
- }
569
- }
570
- chunkSHUYVCID_js.__name(writeFile, "writeFile");
571
570
 
572
571
  // ../powerlines/src/internal/helpers/resolve-tsconfig.ts
572
+ function getTsconfigDtsPath(context) {
573
+ const dtsRelativePath = joinPaths.joinPaths(filePathFns.relativePath(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), filePathFns.findFilePath(context.dtsPath)), filePathFns.findFileName(context.dtsPath));
574
+ return dtsRelativePath;
575
+ }
576
+ chunkSHUYVCID_js.__name(getTsconfigDtsPath, "getTsconfigDtsPath");
573
577
  async function resolveTsconfigChanges(context) {
574
578
  const tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
575
579
  const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
576
580
  const tsconfigJson = await json.readJsonFile(tsconfigFilePath);
577
581
  tsconfigJson.compilerOptions ??= {};
578
582
  if (context.config.output.dts !== false) {
579
- const dtsRelativePath = joinPaths.joinPaths(filePathFns.relativePath(joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), filePathFns.findFilePath(context.dtsPath)), filePathFns.findFileName(context.dtsPath));
583
+ const dtsRelativePath = getTsconfigDtsPath(context);
580
584
  if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [
581
585
  context.dtsPath,
582
586
  dtsRelativePath
@@ -618,7 +622,7 @@ async function initializeTsconfig(context) {
618
622
  context.tsconfig.originalTsconfigJson = await json.readJsonFile(tsconfigFilePath);
619
623
  context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
620
624
  context.log(types.LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
621
- await writeFile(context.log, tsconfigFilePath, stormJson.StormJSON.stringify(context.tsconfig.tsconfigJson));
625
+ await context.fs.write(tsconfigFilePath, stormJson.StormJSON.stringify(context.tsconfig.tsconfigJson));
622
626
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
623
627
  }
624
628
  chunkSHUYVCID_js.__name(initializeTsconfig, "initializeTsconfig");
@@ -667,13 +671,11 @@ async function resolveTsconfig(context) {
667
671
  `).join("\n")}
668
672
  `);
669
673
  }
670
- await writeFile(context.log, context.tsconfig.tsconfigFilePath, stormJson.StormJSON.stringify(updateTsconfigJson));
674
+ await context.fs.write(context.tsconfig.tsconfigFilePath, stormJson.StormJSON.stringify(updateTsconfigJson));
671
675
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
672
676
  if (!context.tsconfig) {
673
677
  throw new Error("Failed to parse the TypeScript configuration file.");
674
678
  }
675
- context.tsconfig.tsconfigJson.compilerOptions ??= {};
676
- context.tsconfig.tsconfigJson.compilerOptions.strict = false;
677
679
  }
678
680
  chunkSHUYVCID_js.__name(resolveTsconfig, "resolveTsconfig");
679
681
  var DEFAULT_ENVIRONMENT = "default";
@@ -813,7 +815,7 @@ function replacePathTokens(context, path) {
813
815
  if (!path) {
814
816
  return path;
815
817
  }
816
- return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replace.replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replace.replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replace.replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
818
+ return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replace.replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replace.replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replace.replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
817
819
  }
818
820
  chunkSHUYVCID_js.__name(replacePathTokens, "replacePathTokens");
819
821
  function resolveEntryInputFile(context, typeDefinition) {
@@ -1371,7 +1373,7 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
1371
1373
  */
1372
1374
  setSync(key, value) {
1373
1375
  if (!this.options.isReadOnly) {
1374
- return writeFile$1.writeFileSync(this.resolve(key), value);
1376
+ return writeFile.writeFileSync(this.resolve(key), value);
1375
1377
  }
1376
1378
  }
1377
1379
  /**
@@ -1382,7 +1384,7 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
1382
1384
  */
1383
1385
  async set(key, value) {
1384
1386
  if (!this.options.isReadOnly) {
1385
- return writeFile$1.writeFile(this.resolve(key), value);
1387
+ return writeFile.writeFile(this.resolve(key), value);
1386
1388
  }
1387
1389
  }
1388
1390
  /**
@@ -1565,7 +1567,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
1565
1567
  * @returns The normalized module id.
1566
1568
  */
1567
1569
  #normalizeId(id) {
1568
- return normalizeId(id, this.#context.config.output.builtinPrefix);
1570
+ let normalized = id;
1571
+ if (isParentPath.isParentPath(normalized, this.#context.builtinsPath)) {
1572
+ normalized = replace.replacePath(normalized, this.#context.builtinsPath);
1573
+ }
1574
+ return normalizeId(normalized, this.#context.config.output.builtinPrefix);
1569
1575
  }
1570
1576
  /**
1571
1577
  * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
@@ -1574,7 +1580,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1574
1580
  * @returns The normalized path.
1575
1581
  */
1576
1582
  #normalizePath(path) {
1577
- return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
1583
+ return normalizePath(path.includes("{") || path.includes("}") ? replacePathTokens(this.#context, path) : path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
1578
1584
  }
1579
1585
  /**
1580
1586
  * Builds a regular expression from a string pattern for path matching.
@@ -2079,15 +2085,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
2079
2085
  }
2080
2086
  }
2081
2087
  const { relativeKey, adapter } = this.#getStorage(path);
2082
- this.#log(types.LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
2083
- const id = options?.meta?.id || this.#normalizeId(path);
2088
+ this.#log(types.LogLevelLabel.TRACE, `Writing ${this.#normalizePath(relativeKey)} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
2089
+ const id = options?.meta?.id || this.#normalizeId(relativeKey);
2084
2090
  this.#metadata[id] = {
2085
2091
  variant: "normal",
2086
2092
  timestamp: Date.now(),
2087
2093
  ...options.meta ?? {}
2088
2094
  };
2089
- this.#paths[id] = this.#normalizePath(path);
2090
- this.#ids[this.#normalizePath(path)] = id;
2095
+ this.#paths[id] = this.#normalizePath(relativeKey);
2096
+ this.#ids[this.#normalizePath(relativeKey)] = id;
2091
2097
  return adapter.set(relativeKey, code);
2092
2098
  }
2093
2099
  /**
@@ -2099,15 +2105,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
2099
2105
  */
2100
2106
  writeSync(path, data = "", options = {}) {
2101
2107
  const { relativeKey, adapter } = this.#getStorage(path);
2102
- this.#log(types.LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(data)).size)})`);
2103
- const id = options?.meta?.id || this.#normalizeId(path);
2108
+ this.#log(types.LogLevelLabel.TRACE, `Writing ${this.#normalizePath(relativeKey)} file to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(data)).size)})`);
2109
+ const id = options?.meta?.id || this.#normalizeId(relativeKey);
2104
2110
  this.#metadata[id] = {
2105
2111
  variant: "normal",
2106
2112
  timestamp: Date.now(),
2107
2113
  ...options.meta ?? {}
2108
2114
  };
2109
- this.#paths[id] = this.#normalizePath(path);
2110
- this.#ids[this.#normalizePath(path)] = id;
2115
+ this.#paths[id] = this.#normalizePath(relativeKey);
2116
+ this.#ids[this.#normalizePath(relativeKey)] = id;
2111
2117
  return adapter.setSync(relativeKey, data);
2112
2118
  }
2113
2119
  /**
@@ -2140,11 +2146,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
2140
2146
  * @returns A promise that resolves to the resolved module path.
2141
2147
  */
2142
2148
  async resolve(id, importer, options = {}) {
2143
- if (isType.isAbsolutePath(id)) {
2144
- return id;
2149
+ let path = id;
2150
+ if (path.includes("{") || path.includes("}")) {
2151
+ path = replacePathTokens(this.#context, path);
2152
+ }
2153
+ if (isType.isAbsolutePath(path)) {
2154
+ return path;
2145
2155
  }
2146
2156
  const resolverCacheKey = murmurhash.murmurhash({
2147
- id: this.#normalizeId(id),
2157
+ path: this.#normalizeId(path),
2148
2158
  importer,
2149
2159
  options
2150
2160
  });
@@ -2155,7 +2165,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
2155
2165
  return result;
2156
2166
  }
2157
2167
  }
2158
- result = this.paths[this.#normalizeId(id)];
2168
+ result = this.paths[this.#normalizeId(path)];
2159
2169
  if (!result) {
2160
2170
  const paths = options.paths ?? [];
2161
2171
  if (importer && !paths.includes(importer)) {
@@ -2164,8 +2174,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
2164
2174
  paths.push(this.#context.workspaceConfig.workspaceRoot);
2165
2175
  paths.push(append.appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
2166
2176
  paths.push(append.appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
2167
- paths.push(...Object.keys(this.#context.tsconfig.options.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => append.appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2168
- for (const combination of resolve.getResolutionCombinations(id, {
2177
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => append.appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2178
+ for (const combination of resolve.getResolutionCombinations(path, {
2169
2179
  paths
2170
2180
  })) {
2171
2181
  const { relativeKey, adapter } = this.#getStorage(combination);
@@ -2174,19 +2184,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
2174
2184
  break;
2175
2185
  }
2176
2186
  }
2177
- try {
2178
- result = await resolve.resolve(id, {
2179
- ...options,
2180
- paths
2181
- });
2182
- } catch {
2187
+ if (!result) {
2188
+ try {
2189
+ result = await resolve.resolve(path, {
2190
+ ...options,
2191
+ paths
2192
+ });
2193
+ } catch {
2194
+ }
2183
2195
  }
2184
2196
  }
2185
- if (result) {
2186
- result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
2187
- if (!this.#context.config.skipCache) {
2188
- this.resolverCache.set(resolverCacheKey, result);
2189
- }
2197
+ if (result && !this.#context.config.skipCache) {
2198
+ this.resolverCache.set(resolverCacheKey, result);
2190
2199
  }
2191
2200
  return result;
2192
2201
  }
@@ -2207,17 +2216,21 @@ var VirtualFileSystem = class _VirtualFileSystem {
2207
2216
  * @returns The resolved module path.
2208
2217
  */
2209
2218
  resolveSync(id, importer, options = {}) {
2210
- if (isType.isAbsolutePath(id)) {
2211
- return id;
2219
+ let path = id;
2220
+ if (path.includes("{") || path.includes("}")) {
2221
+ path = replacePathTokens(this.#context, path);
2222
+ }
2223
+ if (isType.isAbsolutePath(path)) {
2224
+ return path;
2212
2225
  }
2213
2226
  let result;
2214
2227
  if (!this.#context.config.skipCache) {
2215
- result = this.resolverCache.get(this.#normalizeId(id));
2228
+ result = this.resolverCache.get(this.#normalizeId(path));
2216
2229
  if (result) {
2217
2230
  return result;
2218
2231
  }
2219
2232
  }
2220
- result = this.paths[this.#normalizeId(id)];
2233
+ result = this.paths[this.#normalizeId(path)];
2221
2234
  if (!result) {
2222
2235
  const paths = options.paths ?? [];
2223
2236
  if (importer && !paths.includes(importer)) {
@@ -2226,8 +2239,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
2226
2239
  paths.push(this.#context.workspaceConfig.workspaceRoot);
2227
2240
  paths.push(append.appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
2228
2241
  paths.push(append.appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
2229
- paths.push(...Object.keys(this.#context.tsconfig.options.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => append.appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2230
- for (const combination of resolve.getResolutionCombinations(id, {
2242
+ paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => path.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => append.appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2243
+ for (const combination of resolve.getResolutionCombinations(path, {
2231
2244
  paths
2232
2245
  })) {
2233
2246
  const { relativeKey, adapter } = this.#getStorage(combination);
@@ -2236,18 +2249,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
2236
2249
  break;
2237
2250
  }
2238
2251
  }
2239
- try {
2240
- result = resolve.resolveSync(id, {
2241
- paths
2242
- });
2243
- } catch {
2252
+ if (!result) {
2253
+ try {
2254
+ result = resolve.resolveSync(path, {
2255
+ ...options,
2256
+ paths
2257
+ });
2258
+ } catch {
2259
+ }
2244
2260
  }
2245
2261
  }
2246
- if (result) {
2247
- result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
2248
- if (!this.#context.config.skipCache) {
2249
- this.resolverCache.set(this.#normalizeId(id), result);
2250
- }
2262
+ if (result && !this.#context.config.skipCache) {
2263
+ this.resolverCache.set(this.#normalizeId(path), result);
2251
2264
  }
2252
2265
  return result;
2253
2266
  }
@@ -2347,7 +2360,8 @@ var PowerlinesContext = class _PowerlinesContext {
2347
2360
  #fs;
2348
2361
  #tsconfig;
2349
2362
  #program;
2350
- #resolvePatterns = [];
2363
+ #parserCache;
2364
+ #requestCache;
2351
2365
  #getConfigProps(config = {}) {
2352
2366
  return {
2353
2367
  variant: config.build?.variant,
@@ -2371,7 +2385,8 @@ var PowerlinesContext = class _PowerlinesContext {
2371
2385
  lint: config.lint,
2372
2386
  transform: config.transform,
2373
2387
  build: config.build,
2374
- framework: config.framework
2388
+ framework: config.framework,
2389
+ ...config
2375
2390
  };
2376
2391
  }
2377
2392
  /**
@@ -2419,6 +2434,10 @@ var PowerlinesContext = class _PowerlinesContext {
2419
2434
  */
2420
2435
  resolver;
2421
2436
  /**
2437
+ * The resolved configuration options
2438
+ */
2439
+ resolvePatterns = [];
2440
+ /**
2422
2441
  * Internal context fields and methods
2423
2442
  *
2424
2443
  * @internal
@@ -2450,7 +2469,7 @@ var PowerlinesContext = class _PowerlinesContext {
2450
2469
  */
2451
2470
  set tsconfig(value) {
2452
2471
  this.#tsconfig = value;
2453
- this.#resolvePatterns = bundleRequire.tsconfigPathsToRegExp(value?.options?.paths ?? {});
2472
+ this.resolvePatterns = bundleRequire.tsconfigPathsToRegExp(value?.options?.paths ?? {});
2454
2473
  }
2455
2474
  /**
2456
2475
  * The virtual file system interface for the project
@@ -2591,6 +2610,123 @@ var PowerlinesContext = class _PowerlinesContext {
2591
2610
  return this.#program;
2592
2611
  }
2593
2612
  /**
2613
+ * Gets the parser cache.
2614
+ */
2615
+ get parserCache() {
2616
+ if (!this.#parserCache) {
2617
+ this.#parserCache = flatCache.create({
2618
+ cacheId: "parser",
2619
+ cacheDir: this.cachePath,
2620
+ ttl: 2 * 60 * 60 * 1e3,
2621
+ lruSize: 5e3,
2622
+ persistInterval: 250
2623
+ });
2624
+ }
2625
+ return this.#parserCache;
2626
+ }
2627
+ /**
2628
+ * Gets the request cache.
2629
+ */
2630
+ get requestCache() {
2631
+ if (!this.#requestCache) {
2632
+ this.#requestCache = flatCache.create({
2633
+ cacheId: "http",
2634
+ cacheDir: this.cachePath,
2635
+ ttl: 5 * 60 * 1e3,
2636
+ lruSize: 5e3,
2637
+ persistInterval: 250
2638
+ });
2639
+ }
2640
+ return this.#requestCache;
2641
+ }
2642
+ /**
2643
+ * A function to perform HTTP fetch requests
2644
+ *
2645
+ * @remarks
2646
+ * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
2647
+ *
2648
+ * @example
2649
+ * ```ts
2650
+ * const response = await context.fetch("https://api.example.com/data");
2651
+ * const data = await response.json();
2652
+ * ```
2653
+ *
2654
+ * @see https://github.com/nodejs/undici
2655
+ *
2656
+ * @param input - The URL to fetch.
2657
+ * @param options - The fetch request options.
2658
+ * @returns A promise that resolves to a response returned by the fetch.
2659
+ */
2660
+ async fetch(input, options = {}) {
2661
+ const cacheKey = murmurhash.murmurhash({
2662
+ input: input.toString(),
2663
+ options: JSON.stringify(options)
2664
+ });
2665
+ if (!this.config.skipCache && !options.skipCache) {
2666
+ const cached = this.requestCache.get(cacheKey);
2667
+ if (cached) {
2668
+ return new undici.Response(cached.body, {
2669
+ status: cached.status,
2670
+ statusText: cached.statusText,
2671
+ headers: cached.headers
2672
+ });
2673
+ }
2674
+ }
2675
+ const result = await fetch.fetchRequest(input, options);
2676
+ if (!this.config.skipCache && !options.skipCache) {
2677
+ try {
2678
+ this.requestCache.set(cacheKey, {
2679
+ body: await result.text(),
2680
+ status: result.status,
2681
+ statusText: result.statusText,
2682
+ headers: Object.fromEntries(result.headers.entries())
2683
+ });
2684
+ } catch {
2685
+ }
2686
+ }
2687
+ return result;
2688
+ }
2689
+ /**
2690
+ * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
2691
+ *
2692
+ * @remarks
2693
+ * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
2694
+ *
2695
+ * @example
2696
+ * ```ts
2697
+ * const ast = context.parse("const x: number = 42;");
2698
+ * ```
2699
+ *
2700
+ * @see https://rollupjs.org/plugin-development/#this-parse
2701
+ * @see https://github.com/oxc/oxc
2702
+ *
2703
+ * @param code - The source code to parse.
2704
+ * @param options - The options to pass to the parser.
2705
+ * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
2706
+ */
2707
+ async parse(code, options = {}) {
2708
+ const cacheKey = murmurhash.murmurhash({
2709
+ code,
2710
+ options
2711
+ });
2712
+ let result;
2713
+ if (!this.config.skipCache) {
2714
+ result = this.parserCache.get(cacheKey);
2715
+ if (result) {
2716
+ return result;
2717
+ }
2718
+ }
2719
+ result = await oxcParser.parse(`source.${options.lang || "ts"}`, code, {
2720
+ ...options,
2721
+ sourceType: "module",
2722
+ showSemanticErrors: this.config.mode === "development"
2723
+ });
2724
+ if (!this.config.skipCache) {
2725
+ this.parserCache.set(cacheKey, result);
2726
+ }
2727
+ return result;
2728
+ }
2729
+ /**
2594
2730
  * A helper function to resolve modules in the Virtual File System
2595
2731
  *
2596
2732
  * @remarks
@@ -2635,7 +2771,7 @@ var PowerlinesContext = class _PowerlinesContext {
2635
2771
  };
2636
2772
  }
2637
2773
  if (this.config.build.skipNodeModulesBundle) {
2638
- if (bundleRequire.match(moduleId, this.#resolvePatterns) || bundleRequire.match(moduleId, this.config.build.noExternal)) {
2774
+ if (bundleRequire.match(moduleId, this.resolvePatterns) || bundleRequire.match(moduleId, this.config.build.noExternal)) {
2639
2775
  return void 0;
2640
2776
  }
2641
2777
  if (bundleRequire.match(moduleId, this.config.build.external) || moduleId.startsWith("node:")) {
@@ -2829,6 +2965,26 @@ var PowerlinesContext = class _PowerlinesContext {
2829
2965
  return extendLog(this.log, name);
2830
2966
  }
2831
2967
  /**
2968
+ * Generates a checksum representing the current context state
2969
+ *
2970
+ * @param root - The root directory of the project to generate the checksum for
2971
+ * @returns A promise that resolves to a string representing the checksum
2972
+ */
2973
+ async generateChecksum(root = this.config.projectRoot) {
2974
+ this.#checksum = await hashFiles.hashDirectory(root, {
2975
+ ignore: [
2976
+ "node_modules",
2977
+ ".git",
2978
+ ".nx",
2979
+ ".cache",
2980
+ ".storm",
2981
+ "tmp",
2982
+ "dist"
2983
+ ]
2984
+ });
2985
+ return this.#checksum;
2986
+ }
2987
+ /**
2832
2988
  * Creates a new StormContext instance.
2833
2989
  *
2834
2990
  * @param workspaceConfig - The workspace configuration.
@@ -2850,26 +3006,6 @@ var PowerlinesContext = class _PowerlinesContext {
2850
3006
  */
2851
3007
  logFn;
2852
3008
  /**
2853
- * Generates a checksum representing the current context state
2854
- *
2855
- * @param root - The root directory of the project to generate the checksum for
2856
- * @returns A promise that resolves to a string representing the checksum
2857
- */
2858
- async generateChecksum(root = this.config.projectRoot) {
2859
- this.#checksum = await hashFiles.hashDirectory(root, {
2860
- ignore: [
2861
- "node_modules",
2862
- ".git",
2863
- ".nx",
2864
- ".cache",
2865
- ".storm",
2866
- "tmp",
2867
- "dist"
2868
- ]
2869
- });
2870
- return this.#checksum;
2871
- }
2872
- /**
2873
3009
  * Initialize the context with the provided configuration options
2874
3010
  *
2875
3011
  * @param config - The partial user configuration to use for initialization.
@@ -3601,9 +3737,13 @@ ${console.formatLogMessage(context.config)}`);
3601
3737
  let generatedTypes = await emitTypes(context, files);
3602
3738
  context.log(types.LogLevelLabel.TRACE, `Generating TypeScript declaration file ${context.dtsPath}.`);
3603
3739
  const directives = [];
3740
+ const asNextParam = /* @__PURE__ */ chunkSHUYVCID_js.__name((previousResult) => isObject.isObject(previousResult) ? previousResult.code : previousResult, "asNextParam");
3604
3741
  let result = await this.callHook("generateTypes", {
3605
3742
  environment: context,
3606
- order: "pre"
3743
+ sequential: true,
3744
+ order: "pre",
3745
+ result: "merge",
3746
+ asNextParam
3607
3747
  }, generatedTypes);
3608
3748
  if (result) {
3609
3749
  if (isSetObject.isSetObject(result)) {
@@ -3617,7 +3757,10 @@ ${console.formatLogMessage(context.config)}`);
3617
3757
  }
3618
3758
  result = await this.callHook("generateTypes", {
3619
3759
  environment: context,
3620
- order: "normal"
3760
+ sequential: true,
3761
+ order: "normal",
3762
+ result: "merge",
3763
+ asNextParam
3621
3764
  }, generatedTypes);
3622
3765
  if (result) {
3623
3766
  if (isSetObject.isSetObject(result)) {
@@ -3631,7 +3774,10 @@ ${console.formatLogMessage(context.config)}`);
3631
3774
  }
3632
3775
  result = await this.callHook("generateTypes", {
3633
3776
  environment: context,
3634
- order: "post"
3777
+ sequential: true,
3778
+ order: "post",
3779
+ result: "merge",
3780
+ asNextParam
3635
3781
  }, generatedTypes);
3636
3782
  if (result) {
3637
3783
  if (isSetObject.isSetObject(result)) {
@@ -3643,15 +3789,24 @@ ${console.formatLogMessage(context.config)}`);
3643
3789
  generatedTypes = result;
3644
3790
  }
3645
3791
  }
3646
- await context.fs.write(context.dtsPath, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3792
+ if (generatedTypes?.trim() || directives.length > 0) {
3793
+ await context.fs.write(context.dtsPath, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3647
3794
 
3648
3795
  ` : ""}${getFileHeader(context, {
3649
- directive: null,
3650
- prettierIgnore: false
3651
- })}
3796
+ directive: null,
3797
+ prettierIgnore: false
3798
+ })}
3652
3799
 
3653
3800
  ${formatTypes(generatedTypes)}
3654
3801
  `);
3802
+ } else {
3803
+ const dtsRelativePath = getTsconfigDtsPath(context);
3804
+ if (context.tsconfig.tsconfigJson.include && isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
3805
+ const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
3806
+ context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
3807
+ await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
3808
+ }
3809
+ }
3655
3810
  }
3656
3811
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
3657
3812
  if (!context.tsconfig) {
@@ -3688,7 +3843,7 @@ ${formatTypes(generatedTypes)}
3688
3843
  for (const file of files) {
3689
3844
  context.log(types.LogLevelLabel.TRACE, `Adding template file: ${file}`);
3690
3845
  const template = Handlebars__default.default.compile(file);
3691
- await writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3846
+ await context.fs.write(joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3692
3847
  }
3693
3848
  await this.callHook("new", {
3694
3849
  environment: context,
@@ -3699,14 +3854,14 @@ ${formatTypes(generatedTypes)}
3699
3854
  for (const file of files2) {
3700
3855
  context.log(types.LogLevelLabel.TRACE, `Adding application template file: ${file}`);
3701
3856
  const template = Handlebars__default.default.compile(file);
3702
- await writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3857
+ await context.fs.write(joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3703
3858
  }
3704
3859
  } else {
3705
3860
  const files2 = await listFiles.listFiles(joinPaths.joinPaths(context.powerlinesPath, "files/library/**/*.hbs"));
3706
3861
  for (const file of files2) {
3707
3862
  context.log(types.LogLevelLabel.TRACE, `Adding library template file: ${file}`);
3708
3863
  const template = Handlebars__default.default.compile(file);
3709
- await writeFile(context.log, joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3864
+ await context.fs.write(joinPaths.joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3710
3865
  }
3711
3866
  }
3712
3867
  await this.callHook("new", {