@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
@@ -19,6 +19,7 @@ import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
19
19
  import { replacePath, replaceExtension } from '@stryke/path/replace';
20
20
  import { isFunction } from '@stryke/type-checks/is-function';
21
21
  import { isNumber } from '@stryke/type-checks/is-number';
22
+ import { isObject } from '@stryke/type-checks/is-object';
22
23
  import { isPromiseLike } from '@stryke/type-checks/is-promise';
23
24
  import { isSet } from '@stryke/type-checks/is-set';
24
25
  import { isSetObject } from '@stryke/type-checks/is-set-object';
@@ -37,38 +38,40 @@ import { StormJSON } from '@stryke/json/storm-json';
37
38
  import { hasFileExtension, findFilePath, findFileName, relativePath, findFileDotExtensionSafe } from '@stryke/path/file-path-fns';
38
39
  import { titleCase } from '@stryke/string-format/title-case';
39
40
  import { existsSync, exists } from '@stryke/fs/exists';
40
- import { writeFileSync, writeFile as writeFile$1 } from '@stryke/fs/write-file';
41
- import { resolveConfig, format } from 'prettier';
42
41
  import { getEnvPaths } from '@stryke/env/get-env-paths';
43
42
  import { relativeToWorkspaceRoot } from '@stryke/fs/get-workspace-root';
44
43
  import { hashDirectory } from '@stryke/hash/hash-files';
45
44
  import { murmurhash } from '@stryke/hash/murmurhash';
46
45
  import { getUnique, getUniqueBy } from '@stryke/helpers/get-unique';
47
46
  import { omit } from '@stryke/helpers/omit';
47
+ import { fetchRequest } from '@stryke/http/fetch';
48
48
  import { isAbsolutePath, isAbsolute } from '@stryke/path/is-type';
49
49
  import { isNull } from '@stryke/type-checks/is-null';
50
50
  import { isString } from '@stryke/type-checks/is-string';
51
51
  import { uuid } from '@stryke/unique-id/uuid';
52
52
  import { tsconfigPathsToRegExp, match } from 'bundle-require';
53
+ import { create } from 'flat-cache';
54
+ import { parse } from 'oxc-parser';
55
+ import { Response } from 'undici';
53
56
  import { createJiti } from 'jiti';
54
57
  import { isUndefined } from '@stryke/type-checks/is-undefined';
55
58
  import { parseTypeDefinition } from '@stryke/convert/parse-type-definition';
56
59
  import { isFile } from '@stryke/fs/is-file';
57
60
  import * as $ from '@stryke/capnp';
58
61
  import { readFileBuffer, readFileBufferSync, writeFileBuffer } from '@stryke/fs/buffer';
59
- import { correctPath, toAbsolutePath } from '@stryke/path/correct-path';
60
62
  import { isParentPath } from '@stryke/path/is-parent-path';
61
63
  import { prettyBytes } from '@stryke/string-format/pretty-bytes';
62
- import { create } from 'flat-cache';
63
64
  import { Blob } from 'node:buffer';
65
+ import { resolveConfig, format } from 'prettier';
64
66
  import { getColor } from '@storm-software/config-tools/utilities/colors';
65
67
  import { noop } from '@stryke/helpers/noop';
68
+ import { correctPath } from '@stryke/path/correct-path';
66
69
  import { slash } from '@stryke/path/slash';
67
70
  import { readFileSync, readFile } from '@stryke/fs/read-file';
71
+ import { writeFileSync, writeFile } from '@stryke/fs/write-file';
68
72
  import { unlinkSync } from 'node:fs';
69
73
  import { unlink } from 'node:fs/promises';
70
74
  import { resolve } from 'node:path';
71
- import { isObject } from '@stryke/type-checks/is-object';
72
75
 
73
76
  function resolveModulePath(nodePath, state) {
74
77
  if (!t.isStringLiteral(nodePath.node)) {
@@ -330,7 +333,9 @@ async function callHook(context, hook, options, ...args) {
330
333
  if (!isFunction(handler)) {
331
334
  throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
332
335
  }
333
- return Promise.resolve(handler.apply(null, ...args));
336
+ return Promise.resolve(handler.apply(null, [
337
+ ...args
338
+ ]));
334
339
  }));
335
340
  } else {
336
341
  for (const handler of handlers) {
@@ -338,7 +343,9 @@ async function callHook(context, hook, options, ...args) {
338
343
  throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
339
344
  }
340
345
  if (options?.result === "first" || options?.asNextParam === false) {
341
- results.push(await Promise.resolve(handler.apply(null, ...args)));
346
+ results.push(await Promise.resolve(handler.apply(null, [
347
+ ...args
348
+ ])));
342
349
  if (options?.result === "first" && isSet(results[results.length - 1])) {
343
350
  break;
344
351
  }
@@ -350,12 +357,22 @@ async function callHook(context, hook, options, ...args) {
350
357
  sequenceArgs[0] = isFunction(options.asNextParam) ? await Promise.resolve(options.asNextParam(results[0])) : results[0];
351
358
  }
352
359
  const result = await Promise.resolve(
353
- // eslint-disable-next-line ts/no-unsafe-call
354
- handler.apply(null, ...sequenceArgs)
360
+ // eslint-disable-next-line ts/no-unsafe-call, no-useless-call
361
+ handler.apply(null, [
362
+ ...sequenceArgs
363
+ ])
355
364
  );
356
- results = [
357
- result
358
- ];
365
+ if (result) {
366
+ if (options?.result === "last") {
367
+ results = [
368
+ result
369
+ ];
370
+ } else {
371
+ results = [
372
+ defu(result, results[0] ?? {})
373
+ ];
374
+ }
375
+ }
359
376
  }
360
377
  }
361
378
  }
@@ -521,33 +538,20 @@ ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && err
521
538
  };
522
539
  }
523
540
  __name(getParsedTypeScriptConfig, "getParsedTypeScriptConfig");
524
- async function writeFile(log, filepath, content, skipFormat = false) {
525
- try {
526
- if (skipFormat) {
527
- await writeFile$1(filepath, content);
528
- } else {
529
- const config = await resolveConfig(filepath);
530
- const formatted = await format(content, {
531
- ...config ?? {},
532
- filepath
533
- });
534
- await writeFile$1(filepath, formatted || "");
535
- }
536
- } catch (error) {
537
- log(LogLevelLabel.ERROR, `Failed to write file ${filepath} to disk
538
- ${error?.message ? error.message : ""}`);
539
- }
540
- }
541
- __name(writeFile, "writeFile");
542
541
 
543
542
  // ../powerlines/src/internal/helpers/resolve-tsconfig.ts
543
+ function getTsconfigDtsPath(context) {
544
+ const dtsRelativePath = joinPaths$1(relativePath(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(context.dtsPath)), findFileName(context.dtsPath));
545
+ return dtsRelativePath;
546
+ }
547
+ __name(getTsconfigDtsPath, "getTsconfigDtsPath");
544
548
  async function resolveTsconfigChanges(context) {
545
549
  const tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
546
550
  const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
547
551
  const tsconfigJson = await readJsonFile(tsconfigFilePath);
548
552
  tsconfigJson.compilerOptions ??= {};
549
553
  if (context.config.output.dts !== false) {
550
- const dtsRelativePath = joinPaths$1(relativePath(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(context.dtsPath)), findFileName(context.dtsPath));
554
+ const dtsRelativePath = getTsconfigDtsPath(context);
551
555
  if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [
552
556
  context.dtsPath,
553
557
  dtsRelativePath
@@ -589,7 +593,7 @@ async function initializeTsconfig(context) {
589
593
  context.tsconfig.originalTsconfigJson = await readJsonFile(tsconfigFilePath);
590
594
  context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
591
595
  context.log(LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
592
- await writeFile(context.log, tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson));
596
+ await context.fs.write(tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson));
593
597
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
594
598
  }
595
599
  __name(initializeTsconfig, "initializeTsconfig");
@@ -638,13 +642,11 @@ async function resolveTsconfig(context) {
638
642
  `).join("\n")}
639
643
  `);
640
644
  }
641
- await writeFile(context.log, context.tsconfig.tsconfigFilePath, StormJSON.stringify(updateTsconfigJson));
645
+ await context.fs.write(context.tsconfig.tsconfigFilePath, StormJSON.stringify(updateTsconfigJson));
642
646
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
643
647
  if (!context.tsconfig) {
644
648
  throw new Error("Failed to parse the TypeScript configuration file.");
645
649
  }
646
- context.tsconfig.tsconfigJson.compilerOptions ??= {};
647
- context.tsconfig.tsconfigJson.compilerOptions.strict = false;
648
650
  }
649
651
  __name(resolveTsconfig, "resolveTsconfig");
650
652
  var DEFAULT_ENVIRONMENT = "default";
@@ -784,7 +786,7 @@ function replacePathTokens(context, path) {
784
786
  if (!path) {
785
787
  return path;
786
788
  }
787
- 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}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
789
+ 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}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
788
790
  }
789
791
  __name(replacePathTokens, "replacePathTokens");
790
792
  function resolveEntryInputFile(context, typeDefinition) {
@@ -1353,7 +1355,7 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
1353
1355
  */
1354
1356
  async set(key, value) {
1355
1357
  if (!this.options.isReadOnly) {
1356
- return writeFile$1(this.resolve(key), value);
1358
+ return writeFile(this.resolve(key), value);
1357
1359
  }
1358
1360
  }
1359
1361
  /**
@@ -1536,7 +1538,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
1536
1538
  * @returns The normalized module id.
1537
1539
  */
1538
1540
  #normalizeId(id) {
1539
- return normalizeId(id, this.#context.config.output.builtinPrefix);
1541
+ let normalized = id;
1542
+ if (isParentPath(normalized, this.#context.builtinsPath)) {
1543
+ normalized = replacePath(normalized, this.#context.builtinsPath);
1544
+ }
1545
+ return normalizeId(normalized, this.#context.config.output.builtinPrefix);
1540
1546
  }
1541
1547
  /**
1542
1548
  * Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
@@ -1545,7 +1551,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1545
1551
  * @returns The normalized path.
1546
1552
  */
1547
1553
  #normalizePath(path) {
1548
- return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
1554
+ return normalizePath(path.includes("{") || path.includes("}") ? replacePathTokens(this.#context, path) : path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
1549
1555
  }
1550
1556
  /**
1551
1557
  * Builds a regular expression from a string pattern for path matching.
@@ -2050,15 +2056,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
2050
2056
  }
2051
2057
  }
2052
2058
  const { relativeKey, adapter } = this.#getStorage(path);
2053
- this.#log(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(new Blob(toArray(code)).size)})`);
2054
- const id = options?.meta?.id || this.#normalizeId(path);
2059
+ this.#log(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(new Blob(toArray(code)).size)})`);
2060
+ const id = options?.meta?.id || this.#normalizeId(relativeKey);
2055
2061
  this.#metadata[id] = {
2056
2062
  variant: "normal",
2057
2063
  timestamp: Date.now(),
2058
2064
  ...options.meta ?? {}
2059
2065
  };
2060
- this.#paths[id] = this.#normalizePath(path);
2061
- this.#ids[this.#normalizePath(path)] = id;
2066
+ this.#paths[id] = this.#normalizePath(relativeKey);
2067
+ this.#ids[this.#normalizePath(relativeKey)] = id;
2062
2068
  return adapter.set(relativeKey, code);
2063
2069
  }
2064
2070
  /**
@@ -2070,15 +2076,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
2070
2076
  */
2071
2077
  writeSync(path, data = "", options = {}) {
2072
2078
  const { relativeKey, adapter } = this.#getStorage(path);
2073
- this.#log(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(new Blob(toArray(data)).size)})`);
2074
- const id = options?.meta?.id || this.#normalizeId(path);
2079
+ this.#log(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(new Blob(toArray(data)).size)})`);
2080
+ const id = options?.meta?.id || this.#normalizeId(relativeKey);
2075
2081
  this.#metadata[id] = {
2076
2082
  variant: "normal",
2077
2083
  timestamp: Date.now(),
2078
2084
  ...options.meta ?? {}
2079
2085
  };
2080
- this.#paths[id] = this.#normalizePath(path);
2081
- this.#ids[this.#normalizePath(path)] = id;
2086
+ this.#paths[id] = this.#normalizePath(relativeKey);
2087
+ this.#ids[this.#normalizePath(relativeKey)] = id;
2082
2088
  return adapter.setSync(relativeKey, data);
2083
2089
  }
2084
2090
  /**
@@ -2111,11 +2117,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
2111
2117
  * @returns A promise that resolves to the resolved module path.
2112
2118
  */
2113
2119
  async resolve(id, importer, options = {}) {
2114
- if (isAbsolutePath(id)) {
2115
- return id;
2120
+ let path = id;
2121
+ if (path.includes("{") || path.includes("}")) {
2122
+ path = replacePathTokens(this.#context, path);
2123
+ }
2124
+ if (isAbsolutePath(path)) {
2125
+ return path;
2116
2126
  }
2117
2127
  const resolverCacheKey = murmurhash({
2118
- id: this.#normalizeId(id),
2128
+ path: this.#normalizeId(path),
2119
2129
  importer,
2120
2130
  options
2121
2131
  });
@@ -2126,7 +2136,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
2126
2136
  return result;
2127
2137
  }
2128
2138
  }
2129
- result = this.paths[this.#normalizeId(id)];
2139
+ result = this.paths[this.#normalizeId(path)];
2130
2140
  if (!result) {
2131
2141
  const paths = options.paths ?? [];
2132
2142
  if (importer && !paths.includes(importer)) {
@@ -2135,8 +2145,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
2135
2145
  paths.push(this.#context.workspaceConfig.workspaceRoot);
2136
2146
  paths.push(appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
2137
2147
  paths.push(appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
2138
- 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) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2139
- for (const combination of getResolutionCombinations(id, {
2148
+ 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) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2149
+ for (const combination of getResolutionCombinations(path, {
2140
2150
  paths
2141
2151
  })) {
2142
2152
  const { relativeKey, adapter } = this.#getStorage(combination);
@@ -2145,19 +2155,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
2145
2155
  break;
2146
2156
  }
2147
2157
  }
2148
- try {
2149
- result = await resolve$1(id, {
2150
- ...options,
2151
- paths
2152
- });
2153
- } catch {
2158
+ if (!result) {
2159
+ try {
2160
+ result = await resolve$1(path, {
2161
+ ...options,
2162
+ paths
2163
+ });
2164
+ } catch {
2165
+ }
2154
2166
  }
2155
2167
  }
2156
- if (result) {
2157
- result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
2158
- if (!this.#context.config.skipCache) {
2159
- this.resolverCache.set(resolverCacheKey, result);
2160
- }
2168
+ if (result && !this.#context.config.skipCache) {
2169
+ this.resolverCache.set(resolverCacheKey, result);
2161
2170
  }
2162
2171
  return result;
2163
2172
  }
@@ -2178,17 +2187,21 @@ var VirtualFileSystem = class _VirtualFileSystem {
2178
2187
  * @returns The resolved module path.
2179
2188
  */
2180
2189
  resolveSync(id, importer, options = {}) {
2181
- if (isAbsolutePath(id)) {
2182
- return id;
2190
+ let path = id;
2191
+ if (path.includes("{") || path.includes("}")) {
2192
+ path = replacePathTokens(this.#context, path);
2193
+ }
2194
+ if (isAbsolutePath(path)) {
2195
+ return path;
2183
2196
  }
2184
2197
  let result;
2185
2198
  if (!this.#context.config.skipCache) {
2186
- result = this.resolverCache.get(this.#normalizeId(id));
2199
+ result = this.resolverCache.get(this.#normalizeId(path));
2187
2200
  if (result) {
2188
2201
  return result;
2189
2202
  }
2190
2203
  }
2191
- result = this.paths[this.#normalizeId(id)];
2204
+ result = this.paths[this.#normalizeId(path)];
2192
2205
  if (!result) {
2193
2206
  const paths = options.paths ?? [];
2194
2207
  if (importer && !paths.includes(importer)) {
@@ -2197,8 +2210,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
2197
2210
  paths.push(this.#context.workspaceConfig.workspaceRoot);
2198
2211
  paths.push(appendPath(this.#context.config.projectRoot, this.#context.workspaceConfig.workspaceRoot));
2199
2212
  paths.push(appendPath(this.#context.config.sourceRoot, this.#context.workspaceConfig.workspaceRoot));
2200
- 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) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2201
- for (const combination of getResolutionCombinations(id, {
2213
+ 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) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
2214
+ for (const combination of getResolutionCombinations(path, {
2202
2215
  paths
2203
2216
  })) {
2204
2217
  const { relativeKey, adapter } = this.#getStorage(combination);
@@ -2207,18 +2220,18 @@ var VirtualFileSystem = class _VirtualFileSystem {
2207
2220
  break;
2208
2221
  }
2209
2222
  }
2210
- try {
2211
- result = resolveSync(id, {
2212
- paths
2213
- });
2214
- } catch {
2223
+ if (!result) {
2224
+ try {
2225
+ result = resolveSync(path, {
2226
+ ...options,
2227
+ paths
2228
+ });
2229
+ } catch {
2230
+ }
2215
2231
  }
2216
2232
  }
2217
- if (result) {
2218
- result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
2219
- if (!this.#context.config.skipCache) {
2220
- this.resolverCache.set(this.#normalizeId(id), result);
2221
- }
2233
+ if (result && !this.#context.config.skipCache) {
2234
+ this.resolverCache.set(this.#normalizeId(path), result);
2222
2235
  }
2223
2236
  return result;
2224
2237
  }
@@ -2318,7 +2331,8 @@ var PowerlinesContext = class _PowerlinesContext {
2318
2331
  #fs;
2319
2332
  #tsconfig;
2320
2333
  #program;
2321
- #resolvePatterns = [];
2334
+ #parserCache;
2335
+ #requestCache;
2322
2336
  #getConfigProps(config = {}) {
2323
2337
  return {
2324
2338
  variant: config.build?.variant,
@@ -2342,7 +2356,8 @@ var PowerlinesContext = class _PowerlinesContext {
2342
2356
  lint: config.lint,
2343
2357
  transform: config.transform,
2344
2358
  build: config.build,
2345
- framework: config.framework
2359
+ framework: config.framework,
2360
+ ...config
2346
2361
  };
2347
2362
  }
2348
2363
  /**
@@ -2390,6 +2405,10 @@ var PowerlinesContext = class _PowerlinesContext {
2390
2405
  */
2391
2406
  resolver;
2392
2407
  /**
2408
+ * The resolved configuration options
2409
+ */
2410
+ resolvePatterns = [];
2411
+ /**
2393
2412
  * Internal context fields and methods
2394
2413
  *
2395
2414
  * @internal
@@ -2421,7 +2440,7 @@ var PowerlinesContext = class _PowerlinesContext {
2421
2440
  */
2422
2441
  set tsconfig(value) {
2423
2442
  this.#tsconfig = value;
2424
- this.#resolvePatterns = tsconfigPathsToRegExp(value?.options?.paths ?? {});
2443
+ this.resolvePatterns = tsconfigPathsToRegExp(value?.options?.paths ?? {});
2425
2444
  }
2426
2445
  /**
2427
2446
  * The virtual file system interface for the project
@@ -2562,6 +2581,123 @@ var PowerlinesContext = class _PowerlinesContext {
2562
2581
  return this.#program;
2563
2582
  }
2564
2583
  /**
2584
+ * Gets the parser cache.
2585
+ */
2586
+ get parserCache() {
2587
+ if (!this.#parserCache) {
2588
+ this.#parserCache = create({
2589
+ cacheId: "parser",
2590
+ cacheDir: this.cachePath,
2591
+ ttl: 2 * 60 * 60 * 1e3,
2592
+ lruSize: 5e3,
2593
+ persistInterval: 250
2594
+ });
2595
+ }
2596
+ return this.#parserCache;
2597
+ }
2598
+ /**
2599
+ * Gets the request cache.
2600
+ */
2601
+ get requestCache() {
2602
+ if (!this.#requestCache) {
2603
+ this.#requestCache = create({
2604
+ cacheId: "http",
2605
+ cacheDir: this.cachePath,
2606
+ ttl: 5 * 60 * 1e3,
2607
+ lruSize: 5e3,
2608
+ persistInterval: 250
2609
+ });
2610
+ }
2611
+ return this.#requestCache;
2612
+ }
2613
+ /**
2614
+ * A function to perform HTTP fetch requests
2615
+ *
2616
+ * @remarks
2617
+ * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
2618
+ *
2619
+ * @example
2620
+ * ```ts
2621
+ * const response = await context.fetch("https://api.example.com/data");
2622
+ * const data = await response.json();
2623
+ * ```
2624
+ *
2625
+ * @see https://github.com/nodejs/undici
2626
+ *
2627
+ * @param input - The URL to fetch.
2628
+ * @param options - The fetch request options.
2629
+ * @returns A promise that resolves to a response returned by the fetch.
2630
+ */
2631
+ async fetch(input, options = {}) {
2632
+ const cacheKey = murmurhash({
2633
+ input: input.toString(),
2634
+ options: JSON.stringify(options)
2635
+ });
2636
+ if (!this.config.skipCache && !options.skipCache) {
2637
+ const cached = this.requestCache.get(cacheKey);
2638
+ if (cached) {
2639
+ return new Response(cached.body, {
2640
+ status: cached.status,
2641
+ statusText: cached.statusText,
2642
+ headers: cached.headers
2643
+ });
2644
+ }
2645
+ }
2646
+ const result = await fetchRequest(input, options);
2647
+ if (!this.config.skipCache && !options.skipCache) {
2648
+ try {
2649
+ this.requestCache.set(cacheKey, {
2650
+ body: await result.text(),
2651
+ status: result.status,
2652
+ statusText: result.statusText,
2653
+ headers: Object.fromEntries(result.headers.entries())
2654
+ });
2655
+ } catch {
2656
+ }
2657
+ }
2658
+ return result;
2659
+ }
2660
+ /**
2661
+ * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
2662
+ *
2663
+ * @remarks
2664
+ * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
2665
+ *
2666
+ * @example
2667
+ * ```ts
2668
+ * const ast = context.parse("const x: number = 42;");
2669
+ * ```
2670
+ *
2671
+ * @see https://rollupjs.org/plugin-development/#this-parse
2672
+ * @see https://github.com/oxc/oxc
2673
+ *
2674
+ * @param code - The source code to parse.
2675
+ * @param options - The options to pass to the parser.
2676
+ * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
2677
+ */
2678
+ async parse(code, options = {}) {
2679
+ const cacheKey = murmurhash({
2680
+ code,
2681
+ options
2682
+ });
2683
+ let result;
2684
+ if (!this.config.skipCache) {
2685
+ result = this.parserCache.get(cacheKey);
2686
+ if (result) {
2687
+ return result;
2688
+ }
2689
+ }
2690
+ result = await parse(`source.${options.lang || "ts"}`, code, {
2691
+ ...options,
2692
+ sourceType: "module",
2693
+ showSemanticErrors: this.config.mode === "development"
2694
+ });
2695
+ if (!this.config.skipCache) {
2696
+ this.parserCache.set(cacheKey, result);
2697
+ }
2698
+ return result;
2699
+ }
2700
+ /**
2565
2701
  * A helper function to resolve modules in the Virtual File System
2566
2702
  *
2567
2703
  * @remarks
@@ -2606,7 +2742,7 @@ var PowerlinesContext = class _PowerlinesContext {
2606
2742
  };
2607
2743
  }
2608
2744
  if (this.config.build.skipNodeModulesBundle) {
2609
- if (match(moduleId, this.#resolvePatterns) || match(moduleId, this.config.build.noExternal)) {
2745
+ if (match(moduleId, this.resolvePatterns) || match(moduleId, this.config.build.noExternal)) {
2610
2746
  return void 0;
2611
2747
  }
2612
2748
  if (match(moduleId, this.config.build.external) || moduleId.startsWith("node:")) {
@@ -2800,6 +2936,26 @@ var PowerlinesContext = class _PowerlinesContext {
2800
2936
  return extendLog(this.log, name);
2801
2937
  }
2802
2938
  /**
2939
+ * Generates a checksum representing the current context state
2940
+ *
2941
+ * @param root - The root directory of the project to generate the checksum for
2942
+ * @returns A promise that resolves to a string representing the checksum
2943
+ */
2944
+ async generateChecksum(root = this.config.projectRoot) {
2945
+ this.#checksum = await hashDirectory(root, {
2946
+ ignore: [
2947
+ "node_modules",
2948
+ ".git",
2949
+ ".nx",
2950
+ ".cache",
2951
+ ".storm",
2952
+ "tmp",
2953
+ "dist"
2954
+ ]
2955
+ });
2956
+ return this.#checksum;
2957
+ }
2958
+ /**
2803
2959
  * Creates a new StormContext instance.
2804
2960
  *
2805
2961
  * @param workspaceConfig - The workspace configuration.
@@ -2821,26 +2977,6 @@ var PowerlinesContext = class _PowerlinesContext {
2821
2977
  */
2822
2978
  logFn;
2823
2979
  /**
2824
- * Generates a checksum representing the current context state
2825
- *
2826
- * @param root - The root directory of the project to generate the checksum for
2827
- * @returns A promise that resolves to a string representing the checksum
2828
- */
2829
- async generateChecksum(root = this.config.projectRoot) {
2830
- this.#checksum = await hashDirectory(root, {
2831
- ignore: [
2832
- "node_modules",
2833
- ".git",
2834
- ".nx",
2835
- ".cache",
2836
- ".storm",
2837
- "tmp",
2838
- "dist"
2839
- ]
2840
- });
2841
- return this.#checksum;
2842
- }
2843
- /**
2844
2980
  * Initialize the context with the provided configuration options
2845
2981
  *
2846
2982
  * @param config - The partial user configuration to use for initialization.
@@ -3572,9 +3708,13 @@ ${formatLogMessage(context.config)}`);
3572
3708
  let generatedTypes = await emitTypes(context, files);
3573
3709
  context.log(LogLevelLabel.TRACE, `Generating TypeScript declaration file ${context.dtsPath}.`);
3574
3710
  const directives = [];
3711
+ const asNextParam = /* @__PURE__ */ __name((previousResult) => isObject(previousResult) ? previousResult.code : previousResult, "asNextParam");
3575
3712
  let result = await this.callHook("generateTypes", {
3576
3713
  environment: context,
3577
- order: "pre"
3714
+ sequential: true,
3715
+ order: "pre",
3716
+ result: "merge",
3717
+ asNextParam
3578
3718
  }, generatedTypes);
3579
3719
  if (result) {
3580
3720
  if (isSetObject(result)) {
@@ -3588,7 +3728,10 @@ ${formatLogMessage(context.config)}`);
3588
3728
  }
3589
3729
  result = await this.callHook("generateTypes", {
3590
3730
  environment: context,
3591
- order: "normal"
3731
+ sequential: true,
3732
+ order: "normal",
3733
+ result: "merge",
3734
+ asNextParam
3592
3735
  }, generatedTypes);
3593
3736
  if (result) {
3594
3737
  if (isSetObject(result)) {
@@ -3602,7 +3745,10 @@ ${formatLogMessage(context.config)}`);
3602
3745
  }
3603
3746
  result = await this.callHook("generateTypes", {
3604
3747
  environment: context,
3605
- order: "post"
3748
+ sequential: true,
3749
+ order: "post",
3750
+ result: "merge",
3751
+ asNextParam
3606
3752
  }, generatedTypes);
3607
3753
  if (result) {
3608
3754
  if (isSetObject(result)) {
@@ -3614,15 +3760,24 @@ ${formatLogMessage(context.config)}`);
3614
3760
  generatedTypes = result;
3615
3761
  }
3616
3762
  }
3617
- await context.fs.write(context.dtsPath, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3763
+ if (generatedTypes?.trim() || directives.length > 0) {
3764
+ await context.fs.write(context.dtsPath, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3618
3765
 
3619
3766
  ` : ""}${getFileHeader(context, {
3620
- directive: null,
3621
- prettierIgnore: false
3622
- })}
3767
+ directive: null,
3768
+ prettierIgnore: false
3769
+ })}
3623
3770
 
3624
3771
  ${formatTypes(generatedTypes)}
3625
3772
  `);
3773
+ } else {
3774
+ const dtsRelativePath = getTsconfigDtsPath(context);
3775
+ if (context.tsconfig.tsconfigJson.include && isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
3776
+ const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
3777
+ context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
3778
+ await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
3779
+ }
3780
+ }
3626
3781
  }
3627
3782
  context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
3628
3783
  if (!context.tsconfig) {
@@ -3659,7 +3814,7 @@ ${formatTypes(generatedTypes)}
3659
3814
  for (const file of files) {
3660
3815
  context.log(LogLevelLabel.TRACE, `Adding template file: ${file}`);
3661
3816
  const template = Handlebars.compile(file);
3662
- await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3817
+ await context.fs.write(joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3663
3818
  }
3664
3819
  await this.callHook("new", {
3665
3820
  environment: context,
@@ -3670,14 +3825,14 @@ ${formatTypes(generatedTypes)}
3670
3825
  for (const file of files2) {
3671
3826
  context.log(LogLevelLabel.TRACE, `Adding application template file: ${file}`);
3672
3827
  const template = Handlebars.compile(file);
3673
- await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3828
+ await context.fs.write(joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3674
3829
  }
3675
3830
  } else {
3676
3831
  const files2 = await listFiles(joinPaths$1(context.powerlinesPath, "files/library/**/*.hbs"));
3677
3832
  for (const file of files2) {
3678
3833
  context.log(LogLevelLabel.TRACE, `Adding library template file: ${file}`);
3679
3834
  const template = Handlebars.compile(file);
3680
- await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3835
+ await context.fs.write(joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3681
3836
  }
3682
3837
  }
3683
3838
  await this.callHook("new", {