@powerlines/nx 0.10.47 → 0.10.49

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 (31) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +8 -2
  3. package/dist/{chunk-SW7WPPQ5.mjs → chunk-AQLBII62.mjs} +1 -1
  4. package/dist/{chunk-KAGXZMPG.mjs → chunk-DOWZ5F6D.mjs} +1 -1
  5. package/dist/{chunk-RVCS4GUB.mjs → chunk-FAE7BWIE.mjs} +1 -1
  6. package/dist/{chunk-JLOTTRGF.mjs → chunk-GWF62XV6.mjs} +419 -138
  7. package/dist/{chunk-23GFPMA6.js → chunk-HDBRGT3B.js} +2 -2
  8. package/dist/{chunk-UC4XWZN3.js → chunk-HXYHZZNY.js} +2 -2
  9. package/dist/{chunk-SMUQRWNQ.js → chunk-ICVHGDOB.js} +415 -134
  10. package/dist/{chunk-2ZHIKYNK.js → chunk-JAMOE4UV.js} +2 -2
  11. package/dist/{chunk-WOB6ZDJH.mjs → chunk-KRUK7M7J.mjs} +1 -1
  12. package/dist/{chunk-3IX4CIEZ.js → chunk-NIRQ5XRT.js} +2 -2
  13. package/dist/{chunk-BRGJUSQE.mjs → chunk-TXB7X42C.mjs} +1 -1
  14. package/dist/{chunk-ZUHOITET.js → chunk-Y5PCYOA7.js} +2 -2
  15. package/dist/executors.js +11 -11
  16. package/dist/executors.mjs +6 -6
  17. package/dist/index.js +11 -11
  18. package/dist/index.mjs +6 -6
  19. package/dist/src/base/base-executor.js +2 -2
  20. package/dist/src/base/base-executor.mjs +1 -1
  21. package/dist/src/executors/build/executor.js +4 -4
  22. package/dist/src/executors/build/executor.mjs +2 -2
  23. package/dist/src/executors/clean/executor.js +4 -4
  24. package/dist/src/executors/clean/executor.mjs +2 -2
  25. package/dist/src/executors/docs/executor.js +4 -4
  26. package/dist/src/executors/docs/executor.mjs +2 -2
  27. package/dist/src/executors/lint/executor.js +4 -4
  28. package/dist/src/executors/lint/executor.mjs +2 -2
  29. package/dist/src/executors/prepare/executor.js +4 -4
  30. package/dist/src/executors/prepare/executor.mjs +2 -2
  31. package/package.json +15 -15
@@ -10,7 +10,6 @@ var core = require('@babel/core');
10
10
  var console = require('@storm-software/config-tools/logger/console');
11
11
  var types = require('@storm-software/config-tools/types');
12
12
  var toArray = require('@stryke/convert/to-array');
13
- var copyFile = require('@stryke/fs/copy-file');
14
13
  var helpers = require('@stryke/fs/helpers');
15
14
  var install = require('@stryke/fs/install');
16
15
  var listFiles = require('@stryke/fs/list-files');
@@ -31,8 +30,8 @@ var Handlebars = require('handlebars');
31
30
  var helperPluginUtils = require('@babel/helper-plugin-utils');
32
31
  var t = require('@babel/types');
33
32
  var ts = require('typescript');
34
- var join = require('@stryke/path/join');
35
33
  var tsMorph = require('ts-morph');
34
+ var isString = require('@stryke/type-checks/is-string');
36
35
  var _package = require('@stryke/string-format/package');
37
36
  var superdiff = require('@donedeal0/superdiff');
38
37
  var json = require('@stryke/fs/json');
@@ -48,8 +47,8 @@ var getUnique = require('@stryke/helpers/get-unique');
48
47
  var omit = require('@stryke/helpers/omit');
49
48
  var fetch = require('@stryke/http/fetch');
50
49
  var isType = require('@stryke/path/is-type');
50
+ var join = require('@stryke/path/join');
51
51
  var isNull = require('@stryke/type-checks/is-null');
52
- var isString = require('@stryke/type-checks/is-string');
53
52
  var uuid = require('@stryke/unique-id/uuid');
54
53
  var bundleRequire = require('bundle-require');
55
54
  var flatCache = require('flat-cache');
@@ -64,6 +63,7 @@ var buffer = require('@stryke/fs/buffer');
64
63
  var isParentPath = require('@stryke/path/is-parent-path');
65
64
  var prettyBytes = require('@stryke/string-format/pretty-bytes');
66
65
  var buffer$1 = require('buffer');
66
+ var url = require('url');
67
67
  var prettier = require('prettier');
68
68
  var colors = require('@storm-software/config-tools/utilities/colors');
69
69
  var noop = require('@stryke/helpers/noop');
@@ -216,13 +216,16 @@ var VirtualFileSystemHost = class extends tsMorph.InMemoryFileSystemHost {
216
216
  this.#context.fs.removeSync(path);
217
217
  }
218
218
  readDirSync(dirPath) {
219
+ if (!this.#context.fs.isDirectorySync(dirPath)) {
220
+ return [];
221
+ }
219
222
  return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {
220
- const fullPath = this.#context.fs.resolveSync(join.joinPaths(dirPath, entry));
223
+ const fullPath = this.#context.fs.resolveSync(entry);
221
224
  if (fullPath) {
222
225
  ret.push({
223
226
  name: entry,
224
- isDirectory: this.#context.fs.existsSync(fullPath),
225
- isFile: this.#context.fs.existsSync(fullPath),
227
+ isDirectory: this.#context.fs.isDirectorySync(fullPath),
228
+ isFile: this.#context.fs.isFileSync(fullPath),
226
229
  isSymlink: false
227
230
  });
228
231
  }
@@ -230,14 +233,14 @@ var VirtualFileSystemHost = class extends tsMorph.InMemoryFileSystemHost {
230
233
  }, []);
231
234
  }
232
235
  async readFile(filePath) {
233
- if (!this.#context.fs.existsSync(filePath)) {
234
- throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
236
+ if (!this.#context.fs.isFileSync(filePath)) {
237
+ return "";
235
238
  }
236
239
  return await this.#context.fs.read(filePath);
237
240
  }
238
241
  readFileSync(filePath) {
239
- if (!this.#context.fs.existsSync(filePath)) {
240
- throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
242
+ if (!this.#context.fs.isFileSync(filePath)) {
243
+ return "";
241
244
  }
242
245
  return this.#context.fs.readSync(filePath);
243
246
  }
@@ -247,9 +250,11 @@ var VirtualFileSystemHost = class extends tsMorph.InMemoryFileSystemHost {
247
250
  writeFileSync(filePath, fileText) {
248
251
  this.#context.fs.writeSync(filePath, fileText);
249
252
  }
250
- async mkdir(_dirPath) {
253
+ async mkdir(dirPath) {
254
+ await this.#context.fs.mkdir(dirPath);
251
255
  }
252
- mkdirSync(_dirPath) {
256
+ mkdirSync(dirPath) {
257
+ this.#context.fs.mkdirSync(dirPath);
253
258
  }
254
259
  async move(srcPath, destPath) {
255
260
  await this.#context.fs.move(srcPath, destPath);
@@ -264,16 +269,16 @@ var VirtualFileSystemHost = class extends tsMorph.InMemoryFileSystemHost {
264
269
  this.#context.fs.copySync(srcPath, destPath);
265
270
  }
266
271
  async fileExists(filePath) {
267
- return this.#context.fs.exists(filePath);
272
+ return this.#context.fs.isFile(filePath);
268
273
  }
269
274
  fileExistsSync(filePath) {
270
- return this.#context.fs.existsSync(filePath);
275
+ return this.#context.fs.isFileSync(filePath);
271
276
  }
272
277
  async directoryExists(dirPath) {
273
- return this.#context.fs.exists(dirPath);
278
+ return this.#context.fs.isDirectory(dirPath);
274
279
  }
275
280
  directoryExistsSync(dirPath) {
276
- return this.#context.fs.existsSync(dirPath);
281
+ return this.#context.fs.isDirectorySync(dirPath);
277
282
  }
278
283
  realpathSync(path) {
279
284
  return this.#context.fs.resolveSync(path) || path;
@@ -352,6 +357,14 @@ ${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : dia
352
357
  return formatTypes(builtinModules);
353
358
  }
354
359
  chunkSHUYVCID_js.__name(emitTypes, "emitTypes");
360
+ var mergeResults = defu6.createDefu((obj, key, value) => {
361
+ if (isString.isString(obj[key]) && isString.isString(value)) {
362
+ obj[key] = `${obj[key] || ""}
363
+ ${value || ""}`.trim();
364
+ return true;
365
+ }
366
+ return false;
367
+ });
355
368
  async function callHook(context, hook, options, ...args) {
356
369
  const handlers = context.selectHooks(hook, options);
357
370
  if (handlers.length > 0) {
@@ -359,22 +372,28 @@ async function callHook(context, hook, options, ...args) {
359
372
  let results = [];
360
373
  if (options?.sequential === false) {
361
374
  results = await Promise.all(handlers.map(async (handler) => {
362
- if (!isFunction.isFunction(handler)) {
375
+ if (!isFunction.isFunction(handler.handle)) {
363
376
  throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
364
377
  }
365
- return Promise.resolve(handler.apply(null, [
366
- ...args
367
- ]));
378
+ return Promise.resolve(
379
+ // eslint-disable-next-line ts/no-unsafe-call
380
+ handler.handle.apply(handler.context, [
381
+ ...args
382
+ ])
383
+ );
368
384
  }));
369
385
  } else {
370
386
  for (const handler of handlers) {
371
- if (!isFunction.isFunction(handler)) {
387
+ if (!isFunction.isFunction(handler.handle)) {
372
388
  throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
373
389
  }
374
390
  if (options?.result === "first" || options?.asNextParam === false) {
375
- results.push(await Promise.resolve(handler.apply(null, [
376
- ...args
377
- ])));
391
+ results.push(await Promise.resolve(
392
+ // eslint-disable-next-line ts/no-unsafe-call
393
+ handler.handle.apply(handler.context, [
394
+ ...args
395
+ ])
396
+ ));
378
397
  if (options?.result === "first" && isSet.isSet(results[results.length - 1])) {
379
398
  break;
380
399
  }
@@ -386,8 +405,8 @@ async function callHook(context, hook, options, ...args) {
386
405
  sequenceArgs[0] = isFunction.isFunction(options.asNextParam) ? await Promise.resolve(options.asNextParam(results[0])) : results[0];
387
406
  }
388
407
  const result = await Promise.resolve(
389
- // eslint-disable-next-line ts/no-unsafe-call, no-useless-call
390
- handler.apply(null, [
408
+ // eslint-disable-next-line ts/no-unsafe-call
409
+ handler.handle.apply(handler.context, [
391
410
  ...sequenceArgs
392
411
  ])
393
412
  );
@@ -396,9 +415,14 @@ async function callHook(context, hook, options, ...args) {
396
415
  results = [
397
416
  result
398
417
  ];
399
- } else {
418
+ } else if (isString.isString(result)) {
419
+ results = [
420
+ `${isString.isString(results[0]) ? results[0] || "" : ""}
421
+ ${result || ""}`.trim()
422
+ ];
423
+ } else if (isObject.isObject(result)) {
400
424
  results = [
401
- defu6.defu(result, results[0] ?? {})
425
+ mergeResults(result, results[0] ?? {})
402
426
  ];
403
427
  }
404
428
  }
@@ -1156,20 +1180,17 @@ function normalizePath(path, builtinsPath, prefix = "powerlines") {
1156
1180
  return isType.isAbsolutePath(path) ? path : isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
1157
1181
  }
1158
1182
  chunkSHUYVCID_js.__name(normalizePath, "normalizePath");
1159
- function normalizeKey(key, sep = ":") {
1160
- if (!key) {
1161
- return "";
1162
- }
1163
- return key.replace(/[:/\\]/g, sep).replace(/^[:/\\]|[:/\\]$/g, "");
1164
- }
1165
- chunkSHUYVCID_js.__name(normalizeKey, "normalizeKey");
1166
- function filterKeyByBase(key, base) {
1167
- if (base) {
1168
- return key.startsWith(base) && key[key.length - 1] !== "$";
1169
- }
1170
- return key[key.length - 1] !== "$";
1183
+ function normalizeGlobPatterns(workspaceRoot, patterns) {
1184
+ return getUnique.getUnique(toArray.toArray(patterns).map((pattern) => {
1185
+ if (isSetObject.isSetObject(pattern) && (isSetString.isSetString(pattern.input) || isSetString.isSetString(pattern.glob))) {
1186
+ return join.joinPaths(pattern.input || workspaceRoot, pattern.glob || "**/*");
1187
+ } else if (!isSetString.isSetString(pattern)) {
1188
+ return void 0;
1189
+ }
1190
+ return pattern;
1191
+ }).filter(isSetString.isSetString));
1171
1192
  }
1172
- chunkSHUYVCID_js.__name(filterKeyByBase, "filterKeyByBase");
1193
+ chunkSHUYVCID_js.__name(normalizeGlobPatterns, "normalizeGlobPatterns");
1173
1194
  var BaseStorageAdapter = class {
1174
1195
  static {
1175
1196
  chunkSHUYVCID_js.__name(this, "BaseStorageAdapter");
@@ -1224,6 +1245,21 @@ var BaseStorageAdapter = class {
1224
1245
  }
1225
1246
  }
1226
1247
  /**
1248
+ * Synchronously creates a directory at the specified path.
1249
+ *
1250
+ * @param _ - The path of the directory to create.
1251
+ */
1252
+ mkdirSync(_) {
1253
+ }
1254
+ /**
1255
+ * Creates a directory at the specified path.
1256
+ *
1257
+ * @param dirPath - The path of the directory to create.
1258
+ */
1259
+ async mkdir(dirPath) {
1260
+ return Promise.resolve(this.mkdirSync(dirPath));
1261
+ }
1262
+ /**
1227
1263
  * Asynchronously removes a key from the storage.
1228
1264
  *
1229
1265
  * @param key - The key to remove.
@@ -1272,6 +1308,42 @@ var BaseStorageAdapter = class {
1272
1308
  return this.listSync(base);
1273
1309
  }
1274
1310
  /**
1311
+ * Synchronously checks if the given key is a directory.
1312
+ *
1313
+ * @param _ - The key to check.
1314
+ * @returns `true` if the key is a directory, otherwise `false`.
1315
+ */
1316
+ isDirectorySync(_) {
1317
+ return false;
1318
+ }
1319
+ /**
1320
+ * Checks if the given key is a directory.
1321
+ *
1322
+ * @param key - The key to check.
1323
+ * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
1324
+ */
1325
+ async isDirectory(key) {
1326
+ return Promise.resolve(this.isDirectorySync(key));
1327
+ }
1328
+ /**
1329
+ * Synchronously checks if the given key is a file.
1330
+ *
1331
+ * @param key - The key to check.
1332
+ * @returns `true` if the key is a file, otherwise `false`.
1333
+ */
1334
+ isFileSync(key) {
1335
+ return this.existsSync(key) && !this.isDirectorySync(key);
1336
+ }
1337
+ /**
1338
+ * Checks if the given key is a file.
1339
+ *
1340
+ * @param key - The key to check.
1341
+ * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
1342
+ */
1343
+ async isFile(key) {
1344
+ return Promise.resolve(this.isFileSync(key));
1345
+ }
1346
+ /**
1275
1347
  * Disposes of the storage adapter, releasing any held resources.
1276
1348
  *
1277
1349
  * @returns A promise that resolves when the disposal is complete.
@@ -1412,6 +1484,22 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
1412
1484
  }
1413
1485
  }
1414
1486
  /**
1487
+ * Synchronously creates a directory at the specified path.
1488
+ *
1489
+ * @param dirPath - The path of the directory to create.
1490
+ */
1491
+ mkdirSync(dirPath) {
1492
+ helpers.createDirectorySync(this.resolve(dirPath));
1493
+ }
1494
+ /**
1495
+ * Creates a directory at the specified path.
1496
+ *
1497
+ * @param dirPath - The path of the directory to create.
1498
+ */
1499
+ async mkdir(dirPath) {
1500
+ await helpers.createDirectory(this.resolve(dirPath));
1501
+ }
1502
+ /**
1415
1503
  * Lists all keys under a given base path synchronously.
1416
1504
  *
1417
1505
  * @param base - The base path to list keys from.
@@ -1437,6 +1525,24 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
1437
1525
  ignore: this.options.ignore
1438
1526
  }).catch(ignoreNotfound).then((r) => r || []);
1439
1527
  }
1528
+ /**
1529
+ * Synchronously checks if the given key is a directory.
1530
+ *
1531
+ * @param key - The key to check.
1532
+ * @returns `true` if the key is a directory, otherwise `false`.
1533
+ */
1534
+ isDirectorySync(key) {
1535
+ return isFile.isDirectory(this.resolve(key));
1536
+ }
1537
+ /**
1538
+ * Synchronously checks if the given key is a file.
1539
+ *
1540
+ * @param key - The key to check.
1541
+ * @returns `true` if the key is a file, otherwise `false`.
1542
+ */
1543
+ isFileSync(key) {
1544
+ return !isFile.isFile(this.resolve(key));
1545
+ }
1440
1546
  };
1441
1547
  var VirtualStorageAdapter = class extends BaseStorageAdapter {
1442
1548
  static {
@@ -1807,26 +1913,65 @@ var VirtualFileSystem = class _VirtualFileSystem {
1807
1913
  return this.#getStorage(resolved)?.adapter?.name === "virtual";
1808
1914
  }
1809
1915
  /**
1916
+ * Checks if a path is a directory in the virtual file system (VFS).
1917
+ *
1918
+ * @param path - The path to check.
1919
+ * @returns `true` if the path is a directory, otherwise `false`.
1920
+ */
1921
+ isDirectorySync(path) {
1922
+ const resolved = this.resolveSync(path);
1923
+ if (!resolved) {
1924
+ return false;
1925
+ }
1926
+ return !!(this.existsSync(resolved) && this.#getStorage(resolved)?.adapter?.isDirectorySync(resolved));
1927
+ }
1928
+ /**
1929
+ * Checks if a path is a directory in the virtual file system (VFS).
1930
+ *
1931
+ * @param path - The path to check.
1932
+ * @returns `true` if the path is a directory, otherwise `false`.
1933
+ */
1934
+ async isDirectory(path) {
1935
+ const resolved = await this.resolve(path);
1936
+ if (!resolved) {
1937
+ return false;
1938
+ }
1939
+ return !!(await this.exists(resolved) && await this.#getStorage(resolved)?.adapter?.isDirectory(resolved));
1940
+ }
1941
+ /**
1942
+ * Checks if a path is a file in the virtual file system (VFS).
1943
+ *
1944
+ * @param path - The path to check.
1945
+ * @returns `true` if the path is a file, otherwise `false`.
1946
+ */
1947
+ isFileSync(path) {
1948
+ const resolved = this.resolveSync(path);
1949
+ if (!resolved) {
1950
+ return false;
1951
+ }
1952
+ return this.#getStorage(resolved)?.adapter?.isFileSync(resolved) ?? false;
1953
+ }
1954
+ /**
1955
+ * Checks if a path is a file in the virtual file system (VFS).
1956
+ *
1957
+ * @param path - The path to check.
1958
+ * @returns `true` if the path is a file, otherwise `false`.
1959
+ */
1960
+ async isFile(path) {
1961
+ const resolved = await this.resolve(path);
1962
+ if (!resolved) {
1963
+ return false;
1964
+ }
1965
+ return await this.#getStorage(resolved)?.adapter?.isFile(resolved) ?? false;
1966
+ }
1967
+ /**
1810
1968
  * Lists files in a given path.
1811
1969
  *
1812
1970
  * @param path - The path to list files from.
1813
1971
  * @returns An array of file names in the specified path.
1814
1972
  */
1815
1973
  listSync(path) {
1816
- let maskedMounts = [];
1817
- const allKeys = [];
1818
- for (const storage of this.#getStorages(path, true)) {
1819
- for (const key of storage.adapter.listSync(storage.relativeBase)) {
1820
- if (!maskedMounts.some((p) => `${storage.base}${normalizeKey(key)}`.startsWith(p))) {
1821
- allKeys.push(`${storage.base}${normalizeKey(key)}`);
1822
- }
1823
- }
1824
- maskedMounts = [
1825
- storage.base,
1826
- ...maskedMounts.filter((p) => !p.startsWith(storage.base))
1827
- ];
1828
- }
1829
- return allKeys.filter((key) => filterKeyByBase(key, path));
1974
+ return getUnique.getUnique(this.#getStorages(path, true).map((storage) => storage.adapter.listSync(storage.relativeBase ? storage.base ? append.appendPath(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)).flat());
1830
1975
  }
1831
1976
  /**
1832
1977
  * Lists files in a given path.
@@ -1835,20 +1980,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
1835
1980
  * @returns An array of file names in the specified path.
1836
1981
  */
1837
1982
  async list(path) {
1838
- let maskedMounts = [];
1839
- const allKeys = [];
1840
- for (const storage of this.#getStorages(path, true)) {
1841
- for (const key of await storage.adapter.list(storage.relativeBase)) {
1842
- if (!maskedMounts.some((p) => `${storage.base}${normalizeKey(key)}`.startsWith(p))) {
1843
- allKeys.push(`${storage.base}${normalizeKey(key)}`);
1844
- }
1845
- }
1846
- maskedMounts = [
1847
- storage.base,
1848
- ...maskedMounts.filter((p) => !p.startsWith(storage.base))
1849
- ];
1850
- }
1851
- return allKeys.filter((key) => filterKeyByBase(key, path));
1983
+ return getUnique.getUnique((await Promise.all(this.#getStorages(path, true).map(async (storage) => storage.adapter.list(storage.relativeBase ? storage.base ? append.appendPath(storage.relativeBase, storage.base) : storage.relativeBase : storage.base)))).flat());
1852
1984
  }
1853
1985
  /**
1854
1986
  * Removes a file in the virtual file system (VFS).
@@ -1900,12 +2032,16 @@ var VirtualFileSystem = class _VirtualFileSystem {
1900
2032
  */
1901
2033
  async glob(patterns) {
1902
2034
  const results = [];
1903
- for (const pattern of toArray.toArray(patterns)) {
2035
+ for (const pattern of normalizeGlobPatterns(this.#context.workspaceConfig.workspaceRoot, patterns)) {
1904
2036
  const normalized = this.#normalizePath(pattern);
1905
2037
  if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1906
- const resolved = this.resolveSync(normalized);
1907
- if (resolved && !results.includes(resolved)) {
1908
- results.push(resolved);
2038
+ if (this.isDirectorySync(normalized)) {
2039
+ results.push(...await this.list(normalized));
2040
+ } else {
2041
+ const resolved = await this.resolve(normalized);
2042
+ if (resolved && !results.includes(resolved)) {
2043
+ results.push(resolved);
2044
+ }
1909
2045
  }
1910
2046
  continue;
1911
2047
  }
@@ -1931,12 +2067,16 @@ var VirtualFileSystem = class _VirtualFileSystem {
1931
2067
  */
1932
2068
  globSync(patterns) {
1933
2069
  const results = [];
1934
- for (const pattern of toArray.toArray(patterns)) {
2070
+ for (const pattern of normalizeGlobPatterns(this.#context.workspaceConfig.workspaceRoot, patterns)) {
1935
2071
  const normalized = this.#normalizePath(pattern);
1936
2072
  if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
1937
- const resolved = this.resolveSync(normalized);
1938
- if (resolved && !results.includes(resolved)) {
1939
- results.push(resolved);
2073
+ if (this.isDirectorySync(normalized)) {
2074
+ results.push(...this.listSync(normalized));
2075
+ } else {
2076
+ const resolved = this.resolveSync(normalized);
2077
+ if (resolved && !results.includes(resolved)) {
2078
+ results.push(resolved);
2079
+ }
1940
2080
  }
1941
2081
  continue;
1942
2082
  }
@@ -1962,20 +2102,27 @@ var VirtualFileSystem = class _VirtualFileSystem {
1962
2102
  * @param destPath - The destination path to copy to
1963
2103
  */
1964
2104
  async copy(srcPath, destPath) {
1965
- if (filePathFns.hasFileExtension(srcPath)) {
1966
- const content = await this.read(srcPath);
2105
+ const src = srcPath instanceof URL ? url.fileURLToPath(srcPath) : srcPath;
2106
+ const dest = destPath instanceof URL ? url.fileURLToPath(destPath) : destPath;
2107
+ if (!isSetString.isSetString(src) && (!isSetObject.isSetObject(src) || !isSetString.isSetString(src.input)) || !isSetString.isSetString(dest)) {
2108
+ return;
2109
+ }
2110
+ const sourceStr = isString.isString(src) ? src : src.input ? src.input : this.#context.workspaceConfig.workspaceRoot;
2111
+ const source = await this.resolve(sourceStr);
2112
+ if (!source) {
2113
+ return;
2114
+ }
2115
+ if (this.isDirectorySync(source) || isSetString.isSetString(src) && src.includes("*") || isSetObject.isSetObject(src) && isSetString.isSetString(src.glob)) {
2116
+ await Promise.all((await this.glob(src)).map(async (file) => {
2117
+ return this.copy(file, append.appendPath(replace.replacePath(file, sourceStr), dest));
2118
+ }));
2119
+ } else {
2120
+ const content = await this.read(source);
1967
2121
  if (content !== void 0) {
1968
- await this.write(filePathFns.hasFileExtension(destPath) ? destPath : joinPaths.joinPaths(destPath, filePathFns.findFileName(srcPath)), content);
2122
+ await this.write(this.#normalizePath(dest), content, {
2123
+ skipFormat: true
2124
+ });
1969
2125
  }
1970
- } else {
1971
- await Promise.all((await this.list(srcPath)).map(async (file) => {
1972
- const relativePath2 = file.replace(this.#normalizePath(srcPath), "");
1973
- const destinationPath = this.#normalizePath(append.appendPath(destPath, relativePath2));
1974
- const content = await this.read(file);
1975
- if (content !== void 0) {
1976
- await this.write(destinationPath, content);
1977
- }
1978
- }));
1979
2126
  }
1980
2127
  }
1981
2128
  /**
@@ -1985,20 +2132,27 @@ var VirtualFileSystem = class _VirtualFileSystem {
1985
2132
  * @param destPath - The destination path to copy to
1986
2133
  */
1987
2134
  copySync(srcPath, destPath) {
1988
- if (filePathFns.hasFileExtension(srcPath)) {
1989
- const content = this.readSync(srcPath);
2135
+ const src = srcPath instanceof URL ? url.fileURLToPath(srcPath) : srcPath;
2136
+ const dest = destPath instanceof URL ? url.fileURLToPath(destPath) : destPath;
2137
+ if (!isSetString.isSetString(src) && (!isSetObject.isSetObject(src) || !isSetString.isSetString(src.input)) || !isSetString.isSetString(dest)) {
2138
+ return;
2139
+ }
2140
+ const sourceStr = isString.isString(src) ? src : src.input ? src.input : this.#context.workspaceConfig.workspaceRoot;
2141
+ const source = this.resolveSync(sourceStr);
2142
+ if (!source) {
2143
+ return;
2144
+ }
2145
+ if (this.isDirectorySync(source) || isSetString.isSetString(src) && src.includes("*") || isSetObject.isSetObject(src) && isSetString.isSetString(src.glob)) {
2146
+ this.globSync(src).map((file) => {
2147
+ return this.copySync(file, append.appendPath(filePathFns.findFilePath(replace.replacePath(file, sourceStr)), dest));
2148
+ });
2149
+ } else {
2150
+ const content = this.readSync(source);
1990
2151
  if (content !== void 0) {
1991
- this.writeSync(filePathFns.hasFileExtension(destPath) ? destPath : joinPaths.joinPaths(destPath, filePathFns.findFileName(srcPath)), content);
2152
+ this.writeSync(this.#normalizePath(filePathFns.hasFileExtension(dest) ? dest : append.appendPath(filePathFns.findFileName(source), dest)), content, {
2153
+ skipFormat: true
2154
+ });
1992
2155
  }
1993
- } else {
1994
- this.listSync(srcPath).forEach((file) => {
1995
- const relativePath2 = file.replace(this.#normalizePath(srcPath), "");
1996
- const destinationPath = this.#normalizePath(append.appendPath(destPath, relativePath2));
1997
- const content = this.readSync(file);
1998
- if (content !== void 0) {
1999
- this.writeSync(destinationPath, content);
2000
- }
2001
- });
2002
2156
  }
2003
2157
  }
2004
2158
  /**
@@ -2117,6 +2271,22 @@ var VirtualFileSystem = class _VirtualFileSystem {
2117
2271
  return adapter.setSync(relativeKey, data);
2118
2272
  }
2119
2273
  /**
2274
+ * Synchronously creates a directory at the specified path.
2275
+ *
2276
+ * @param dirPath - The path of the directory to create.
2277
+ */
2278
+ mkdirSync(dirPath) {
2279
+ return this.#getStorage(dirPath)?.adapter?.mkdirSync(dirPath);
2280
+ }
2281
+ /**
2282
+ * Creates a directory at the specified path.
2283
+ *
2284
+ * @param path - The path of the directory to create.
2285
+ */
2286
+ async mkdir(path) {
2287
+ return this.#getStorage(path)?.adapter?.mkdir(path);
2288
+ }
2289
+ /**
2120
2290
  * Retrieves the metadata of a file in the virtual file system (VFS).
2121
2291
  *
2122
2292
  * @param pathOrId - The path or ID of the file to retrieve metadata for.
@@ -2341,16 +2511,29 @@ var VirtualFileSystem = class _VirtualFileSystem {
2341
2511
 
2342
2512
  // ../powerlines/src/lib/contexts/context.ts
2343
2513
  var configCache = /* @__PURE__ */ new WeakMap();
2514
+ var agent = new undici.Agent({
2515
+ keepAliveTimeout: 1e4
2516
+ });
2517
+ undici.setGlobalDispatcher(agent.compose(undici.interceptors.retry({
2518
+ maxRetries: 3,
2519
+ minTimeout: 1e3,
2520
+ maxTimeout: 1e4,
2521
+ timeoutFactor: 2,
2522
+ retryAfter: true
2523
+ })));
2344
2524
  var PowerlinesContext = class _PowerlinesContext {
2345
2525
  static {
2346
2526
  chunkSHUYVCID_js.__name(this, "PowerlinesContext");
2347
2527
  }
2348
2528
  /**
2349
- * Internal reference to the API instance
2529
+ * Internal references storage
2530
+ *
2531
+ * @danger
2532
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
2350
2533
  *
2351
2534
  * @internal
2352
2535
  */
2353
- #api;
2536
+ #internal = {};
2354
2537
  #workspaceConfig;
2355
2538
  #checksum = null;
2356
2539
  #buildId = uuid.uuid();
@@ -2440,12 +2623,24 @@ var PowerlinesContext = class _PowerlinesContext {
2440
2623
  /**
2441
2624
  * Internal context fields and methods
2442
2625
  *
2626
+ * @danger
2627
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
2628
+ *
2443
2629
  * @internal
2444
2630
  */
2445
2631
  get $$internal() {
2446
- return {
2447
- api: this.#api
2448
- };
2632
+ return this.#internal;
2633
+ }
2634
+ /**
2635
+ * Internal context fields and methods
2636
+ *
2637
+ * @danger
2638
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
2639
+ *
2640
+ * @internal
2641
+ */
2642
+ set $$internal(value) {
2643
+ this.#internal = value;
2449
2644
  }
2450
2645
  /**
2451
2646
  * The resolved entry type definitions for the project
@@ -2672,19 +2867,27 @@ var PowerlinesContext = class _PowerlinesContext {
2672
2867
  });
2673
2868
  }
2674
2869
  }
2675
- const result = await fetch.fetchRequest(input, options);
2870
+ const response = await fetch.fetchRequest(input, {
2871
+ timeout: 12e3,
2872
+ ...options
2873
+ });
2874
+ const result = {
2875
+ body: await response.text(),
2876
+ status: response.status,
2877
+ statusText: response.statusText,
2878
+ headers: Object.fromEntries(response.headers.entries())
2879
+ };
2676
2880
  if (!this.config.skipCache && !options.skipCache) {
2677
2881
  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
- });
2882
+ this.requestCache.set(cacheKey, result);
2684
2883
  } catch {
2685
2884
  }
2686
2885
  }
2687
- return result;
2886
+ return new undici.Response(result.body, {
2887
+ status: result.status,
2888
+ statusText: result.statusText,
2889
+ headers: result.headers
2890
+ });
2688
2891
  }
2689
2892
  /**
2690
2893
  * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
@@ -3378,36 +3581,90 @@ var PowerlinesEnvironmentContext = class _PowerlinesEnvironmentContext extends P
3378
3581
  * Retrieves the hook handlers for a specific hook name
3379
3582
  */
3380
3583
  selectHooks(hook, options) {
3381
- const handlers = [];
3584
+ const result = [];
3382
3585
  if (this.hooks[hook]) {
3383
3586
  if (!isHookExternal(hook)) {
3384
3587
  const hooks = this.hooks[hook];
3385
3588
  if (options?.order) {
3386
3589
  if (options?.order === "pre") {
3387
- handlers.push(...(hooks.preOrdered ?? []).map((h) => h.handler));
3388
- handlers.push(...(hooks.preEnforced ?? []).map((h) => h.handler));
3590
+ result.push(...(hooks.preOrdered ?? []).map((h) => {
3591
+ const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
3592
+ if (!plugin) {
3593
+ throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
3594
+ }
3595
+ return {
3596
+ handle: h.handler,
3597
+ context: plugin.context
3598
+ };
3599
+ }));
3600
+ result.push(...(hooks.preEnforced ?? []).map((h) => {
3601
+ const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
3602
+ if (!plugin) {
3603
+ throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
3604
+ }
3605
+ return {
3606
+ handle: h.handler,
3607
+ context: plugin.context
3608
+ };
3609
+ }));
3389
3610
  } else if (options?.order === "post") {
3390
- handlers.push(...(hooks.postOrdered ?? []).map((h) => h.handler));
3391
- handlers.push(...(hooks.postEnforced ?? []).map((h) => h.handler));
3611
+ result.push(...(hooks.postOrdered ?? []).map((h) => {
3612
+ const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
3613
+ if (!plugin) {
3614
+ throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
3615
+ }
3616
+ return {
3617
+ handle: h.handler,
3618
+ context: plugin.context
3619
+ };
3620
+ }));
3621
+ result.push(...(hooks.postEnforced ?? []).map((h) => {
3622
+ const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
3623
+ if (!plugin) {
3624
+ throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
3625
+ }
3626
+ return {
3627
+ handle: h.handler,
3628
+ context: plugin.context
3629
+ };
3630
+ }));
3392
3631
  } else {
3393
- handlers.push(...(hooks.normal ?? []).map((h) => h.handler));
3632
+ result.push(...(hooks.normal ?? []).map((h) => {
3633
+ const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
3634
+ if (!plugin) {
3635
+ throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
3636
+ }
3637
+ return {
3638
+ handle: h.handler,
3639
+ context: plugin.context
3640
+ };
3641
+ }));
3394
3642
  }
3395
3643
  } else {
3396
- handlers.push(...this.selectHooks(hook, {
3644
+ result.push(...this.selectHooks(hook, {
3397
3645
  order: "pre"
3398
3646
  }));
3399
- handlers.push(...this.selectHooks(hook, {
3647
+ result.push(...this.selectHooks(hook, {
3400
3648
  order: "normal"
3401
3649
  }));
3402
- handlers.push(...this.selectHooks(hook, {
3650
+ result.push(...this.selectHooks(hook, {
3403
3651
  order: "post"
3404
3652
  }));
3405
3653
  }
3406
3654
  } else {
3407
- handlers.push(...this.hooks[hook].map((h) => h.handler));
3655
+ result.push(...this.hooks[hook].map((h) => {
3656
+ const plugin = this.plugins.find((p) => p.plugin.name === h.plugin.name);
3657
+ if (!plugin) {
3658
+ throw new Error(`Could not find plugin context for plugin "${h.plugin.name}".`);
3659
+ }
3660
+ return {
3661
+ handle: h.handler,
3662
+ context: plugin.context
3663
+ };
3664
+ }));
3408
3665
  }
3409
3666
  }
3410
- return handlers;
3667
+ return result;
3411
3668
  }
3412
3669
  constructor(config, workspaceConfig) {
3413
3670
  super(workspaceConfig);
@@ -3440,6 +3697,31 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
3440
3697
  return context;
3441
3698
  }
3442
3699
  /**
3700
+ * Internal context fields and methods
3701
+ *
3702
+ * @danger
3703
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
3704
+ *
3705
+ * @internal
3706
+ */
3707
+ get $$internal() {
3708
+ return super.$$internal;
3709
+ }
3710
+ /**
3711
+ * Internal context fields and methods
3712
+ *
3713
+ * @danger
3714
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
3715
+ *
3716
+ * @internal
3717
+ */
3718
+ set $$internal(value) {
3719
+ super.$$internal = value;
3720
+ for (const environment of Object.values(this.environments)) {
3721
+ environment.$$internal = super.$$internal;
3722
+ }
3723
+ }
3724
+ /**
3443
3725
  * A record of all environments by name
3444
3726
  */
3445
3727
  get environments() {
@@ -3613,7 +3895,9 @@ var PowerlinesAPI = class _PowerlinesAPI {
3613
3895
  */
3614
3896
  static async from(workspaceRoot, config) {
3615
3897
  const api = new _PowerlinesAPI(await PowerlinesAPIContext.from(workspaceRoot, config));
3616
- api.#context.$$internal.api = api;
3898
+ api.#context.$$internal = {
3899
+ api
3900
+ };
3617
3901
  for (const plugin of api.context.config.plugins ?? []) {
3618
3902
  await api.#addPlugin(plugin);
3619
3903
  }
@@ -3738,7 +4022,7 @@ ${console.formatLogMessage(context.config)}`);
3738
4022
  context.log(types.LogLevelLabel.TRACE, `Generating TypeScript declaration file ${context.dtsPath}.`);
3739
4023
  const directives = [];
3740
4024
  const asNextParam = /* @__PURE__ */ chunkSHUYVCID_js.__name((previousResult) => isObject.isObject(previousResult) ? previousResult.code : previousResult, "asNextParam");
3741
- let result = await this.callHook("generateTypes", {
4025
+ let result = await this.callHook("types", {
3742
4026
  environment: context,
3743
4027
  sequential: true,
3744
4028
  order: "pre",
@@ -3755,7 +4039,7 @@ ${console.formatLogMessage(context.config)}`);
3755
4039
  generatedTypes = result;
3756
4040
  }
3757
4041
  }
3758
- result = await this.callHook("generateTypes", {
4042
+ result = await this.callHook("types", {
3759
4043
  environment: context,
3760
4044
  sequential: true,
3761
4045
  order: "normal",
@@ -3772,7 +4056,7 @@ ${console.formatLogMessage(context.config)}`);
3772
4056
  generatedTypes = result;
3773
4057
  }
3774
4058
  }
3775
- result = await this.callHook("generateTypes", {
4059
+ result = await this.callHook("types", {
3776
4060
  environment: context,
3777
4061
  sequential: true,
3778
4062
  order: "post",
@@ -3945,15 +4229,12 @@ ${formatTypes(generatedTypes)}
3945
4229
  const destinationPath = joinPaths.joinPaths(append.appendPath(context.config.output.outputPath, context.workspaceConfig.workspaceRoot), "dist");
3946
4230
  if (sourcePath !== destinationPath) {
3947
4231
  context.log(types.LogLevelLabel.INFO, `Copying build output files from project's build directory (${context.config.output.buildPath}) to the workspace's output directory (${context.config.output.outputPath}).`);
3948
- await copyFile.copyFiles({
3949
- input: sourcePath,
3950
- glob: "**/*"
3951
- }, destinationPath);
4232
+ await context.fs.copy(sourcePath, destinationPath);
3952
4233
  }
3953
4234
  }
3954
4235
  await Promise.all(context.config.output.assets.map(async (asset) => {
3955
4236
  context.log(types.LogLevelLabel.DEBUG, `Copying asset(s): ${chalk5__default.default.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : joinPaths.joinPaths(replace.replacePath(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk5__default.default.greenBright(joinPaths.joinPaths(replace.replacePath(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk5__default.default.yellowBright(i)).join(", ")})` : ""}`);
3956
- await copyFile.copyFiles(asset, asset.output);
4237
+ await context.fs.copy(asset, asset.output);
3957
4238
  }));
3958
4239
  await this.callHook("build", {
3959
4240
  environment: context,