@powerlines/nx 0.11.242 → 0.11.244

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 (66) hide show
  1. package/dist/src/base/base-executor.d.mts +1 -1
  2. package/dist/src/base/base-executor.d.ts +1 -1
  3. package/dist/src/base/base-executor.js +1 -1
  4. package/dist/src/base/base-executor.mjs +1 -1
  5. package/dist/src/base/base-executor.untyped.d.mts +1 -1
  6. package/dist/src/base/index.d.mts +2 -2
  7. package/dist/src/base/index.d.ts +1 -1
  8. package/dist/src/base/index.js +1 -1
  9. package/dist/src/base/index.mjs +1 -1
  10. package/dist/src/{base-executor-BoGtGSyI.mjs → base-executor-8Ir8WQy3.mjs} +221 -146
  11. package/dist/src/base-executor-8Ir8WQy3.mjs.map +1 -0
  12. package/dist/src/{base-executor-gEMcEAww.js → base-executor-CI2DPk2i.js} +220 -145
  13. package/dist/src/{base-executor-kPTbnW7K.d.mts → base-executor-Cg8BJvfR.d.mts} +23 -1
  14. package/dist/src/base-executor-Cg8BJvfR.d.mts.map +1 -0
  15. package/dist/src/{base-executor-DR21ys32.js → base-executor-D9bYd7jN.js} +220 -145
  16. package/dist/src/{base-executor-D3qCz-UO.mjs → base-executor-DPkS_FBw.mjs} +221 -146
  17. package/dist/src/base-executor-DPkS_FBw.mjs.map +1 -0
  18. package/dist/src/{base-executor-CZijjH-b.d.ts → base-executor-DglM2tyD.d.ts} +23 -1
  19. package/dist/src/base-executor-DglM2tyD.d.ts.map +1 -0
  20. package/dist/src/base-executor.untyped-7SvGKXcO.d.mts +7 -0
  21. package/dist/src/base-executor.untyped-7SvGKXcO.d.mts.map +1 -0
  22. package/dist/src/base-executor.untyped-imww7Gm9.d.mts +7 -0
  23. package/dist/src/base-executor.untyped-imww7Gm9.d.mts.map +1 -0
  24. package/dist/src/executors/build/executor.d.mts +1 -1
  25. package/dist/src/executors/build/executor.d.ts +1 -1
  26. package/dist/src/executors/build/executor.js +1 -1
  27. package/dist/src/executors/build/executor.mjs +1 -1
  28. package/dist/src/executors/build/untyped.d.mts +2 -2
  29. package/dist/src/executors/build/untyped.d.ts +2 -2
  30. package/dist/src/executors/clean/executor.d.mts +1 -1
  31. package/dist/src/executors/clean/executor.d.ts +1 -1
  32. package/dist/src/executors/clean/executor.js +1 -1
  33. package/dist/src/executors/clean/executor.mjs +1 -1
  34. package/dist/src/executors/clean/untyped.d.mts +2 -2
  35. package/dist/src/executors/clean/untyped.d.ts +2 -2
  36. package/dist/src/executors/docs/executor.d.mts +1 -1
  37. package/dist/src/executors/docs/executor.d.ts +1 -1
  38. package/dist/src/executors/docs/executor.js +1 -1
  39. package/dist/src/executors/docs/executor.mjs +1 -1
  40. package/dist/src/executors/lint/executor.d.mts +1 -1
  41. package/dist/src/executors/lint/executor.d.ts +1 -1
  42. package/dist/src/executors/lint/executor.js +1 -1
  43. package/dist/src/executors/lint/executor.mjs +1 -1
  44. package/dist/src/executors/lint/untyped.d.mts +2 -2
  45. package/dist/src/executors/lint/untyped.d.ts +2 -2
  46. package/dist/src/executors/prepare/executor.d.mts +1 -1
  47. package/dist/src/executors/prepare/executor.d.ts +1 -1
  48. package/dist/src/executors/prepare/executor.js +1 -1
  49. package/dist/src/executors/prepare/executor.mjs +1 -1
  50. package/dist/src/executors/prepare/untyped.d.mts +2 -2
  51. package/dist/src/executors/prepare/untyped.d.ts +2 -2
  52. package/dist/src/generators/sync/untyped.d.mts +2 -2
  53. package/dist/src/generators/sync/untyped.d.ts +2 -2
  54. package/dist/src/index.d.mts +2 -2
  55. package/dist/src/index.d.ts +1 -1
  56. package/dist/src/index.js +1 -1
  57. package/dist/src/index.mjs +1 -1
  58. package/package.json +16 -16
  59. package/dist/src/base-executor-BoGtGSyI.mjs.map +0 -1
  60. package/dist/src/base-executor-CZijjH-b.d.ts.map +0 -1
  61. package/dist/src/base-executor-D3qCz-UO.mjs.map +0 -1
  62. package/dist/src/base-executor-kPTbnW7K.d.mts.map +0 -1
  63. package/dist/src/base-executor.untyped-BgwzwrUY.d.mts +0 -7
  64. package/dist/src/base-executor.untyped-BgwzwrUY.d.mts.map +0 -1
  65. package/dist/src/base-executor.untyped-Dh9l8ijM.d.mts +0 -7
  66. package/dist/src/base-executor.untyped-Dh9l8ijM.d.mts.map +0 -1
@@ -1,2 +1,2 @@
1
- import { n as withExecutor, t as PowerlinesExecutorContext } from "../base-executor-kPTbnW7K.mjs";
1
+ import { n as withExecutor, t as PowerlinesExecutorContext } from "../base-executor-Cg8BJvfR.mjs";
2
2
  export { PowerlinesExecutorContext, withExecutor };
@@ -1,2 +1,2 @@
1
- import { n as withExecutor, t as PowerlinesExecutorContext } from "../base-executor-CZijjH-b.js";
1
+ import { n as withExecutor, t as PowerlinesExecutorContext } from "../base-executor-DglM2tyD.js";
2
2
  export { PowerlinesExecutorContext, withExecutor };
@@ -1,4 +1,4 @@
1
1
  require('../config-CGQhS8tm.js');
2
- const require_base_executor = require('../base-executor-DR21ys32.js');
2
+ const require_base_executor = require('../base-executor-CI2DPk2i.js');
3
3
 
4
4
  exports.withExecutor = require_base_executor.withExecutor;
@@ -1,4 +1,4 @@
1
- import { t as withExecutor } from "../base-executor-D3qCz-UO.mjs";
1
+ import { t as withExecutor } from "../base-executor-8Ir8WQy3.mjs";
2
2
  import "../config-LoR-NIJg.mjs";
3
3
 
4
4
  export { withExecutor };
@@ -1,2 +1,2 @@
1
- import { t as _default } from "../base-executor.untyped-Dh9l8ijM.mjs";
1
+ import { t as _default } from "../base-executor.untyped-imww7Gm9.mjs";
2
2
  export { _default as default };
@@ -1,4 +1,4 @@
1
- import { n as withExecutor, t as PowerlinesExecutorContext } from "../base-executor-kPTbnW7K.mjs";
2
- import "../base-executor.untyped-Dh9l8ijM.mjs";
1
+ import { n as withExecutor, t as PowerlinesExecutorContext } from "../base-executor-Cg8BJvfR.mjs";
2
+ import "../base-executor.untyped-imww7Gm9.mjs";
3
3
  import "../index-LhFpnU-f.mjs";
4
4
  export { PowerlinesExecutorContext, withExecutor };
@@ -1,2 +1,2 @@
1
- import { n as withExecutor, t as PowerlinesExecutorContext } from "../base-executor-CZijjH-b.js";
1
+ import { n as withExecutor, t as PowerlinesExecutorContext } from "../base-executor-DglM2tyD.js";
2
2
  export { PowerlinesExecutorContext, withExecutor };
@@ -1,5 +1,5 @@
1
1
  require('../config-CGQhS8tm.js');
2
- const require_base_executor = require('../base-executor-DR21ys32.js');
2
+ const require_base_executor = require('../base-executor-CI2DPk2i.js');
3
3
  require('../base-executor.untyped-Cz1Zw_02.js');
4
4
  require('../base-B7jekb-W.js');
5
5
 
@@ -1,4 +1,4 @@
1
- import { t as withExecutor } from "../base-executor-D3qCz-UO.mjs";
1
+ import { t as withExecutor } from "../base-executor-8Ir8WQy3.mjs";
2
2
  import "../config-LoR-NIJg.mjs";
3
3
  import "../base-executor.untyped-C1pQETnQ.mjs";
4
4
  import "../base-BRSa-clf.mjs";
@@ -69,16 +69,16 @@ import { isDirectory, isFile } from "@stryke/fs/is-file";
69
69
  import { readFile, readFileSync } from "@stryke/fs/read-file";
70
70
  import { writeFile, writeFileSync } from "@stryke/fs/write-file";
71
71
  import { unlink } from "node:fs/promises";
72
- import { resolve as resolve$1 } from "node:path";
73
72
  import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
74
73
  import { getColor } from "@storm-software/config-tools/utilities/colors";
75
74
  import { noop } from "@stryke/helpers/noop";
76
75
  import "magic-string";
77
76
  import Diff from "diff-match-patch";
77
+ import { resolve as resolve$1 } from "node:path";
78
78
  import "unplugin";
79
79
 
80
80
  //#region ../powerlines/package.json
81
- var version = "0.40.0";
81
+ var version = "0.40.3";
82
82
 
83
83
  //#endregion
84
84
  //#region ../powerlines/src/typescript/ts-morph.ts
@@ -1163,6 +1163,178 @@ FileSystem._Ids = $.CompositeList(FileId);
1163
1163
  FileSystem._Storage = $.CompositeList(FileStorage);
1164
1164
  FileSystem._Metadata = $.CompositeList(FileMetadata);
1165
1165
 
1166
+ //#endregion
1167
+ //#region ../core/src/lib/entry.ts
1168
+ function resolveEntryOutput(context, typeDefinition) {
1169
+ return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "src")), joinPaths(context.workspaceConfig.workspaceRoot, context.config.root)), joinPaths(context.config.root, "src")), context.config.root), "src"));
1170
+ }
1171
+ function resolveInput(context, typeDefinition, input, output) {
1172
+ return {
1173
+ ...typeDefinition,
1174
+ input: isSetString(input) ? { file: String(input) } : typeDefinition,
1175
+ output: output || resolveEntryOutput(context, typeDefinition)
1176
+ };
1177
+ }
1178
+ /**
1179
+ * Resolves multiple type definitions into their corresponding resolved entry type definitions.
1180
+ *
1181
+ * @param context - The current context
1182
+ * @param typeDefinitions - The type definitions to resolve.
1183
+ * @returns A promise that resolves to an array of resolved entry type definitions.
1184
+ */
1185
+ function resolveInputsSync(context, typeDefinitions) {
1186
+ return (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions) ? Object.values(typeDefinitions).flat() : toArray(typeDefinitions)).map((entry) => {
1187
+ if (isResolvedEntryTypeDefinition(entry)) return {
1188
+ ...entry,
1189
+ output: entry.output ? replacePathTokens(context, entry.output) : void 0,
1190
+ file: replacePathTokens(context, entry.file)
1191
+ };
1192
+ let typeDefinition;
1193
+ if (isString(entry)) typeDefinition = parseTypeDefinition(replacePathTokens(context, entry));
1194
+ else {
1195
+ typeDefinition = entry;
1196
+ typeDefinition.file = replacePathTokens(context, typeDefinition.file);
1197
+ }
1198
+ const filePath = isAbsolutePath(typeDefinition.file) ? typeDefinition.file : appendPath(typeDefinition.file, context.config.root);
1199
+ if (context.fs.isFileSync(filePath)) return resolveInput(context, {
1200
+ file: appendPath(filePath, context.workspaceConfig.workspaceRoot),
1201
+ name: typeDefinition.name
1202
+ });
1203
+ return context.fs.globSync(appendPath(filePath, context.workspaceConfig.workspaceRoot)).map((file) => resolveInput(context, {
1204
+ file,
1205
+ name: typeDefinition.name
1206
+ }));
1207
+ }).flat().filter(Boolean);
1208
+ }
1209
+ /**
1210
+ * Checks if the provided entry is a type definition.
1211
+ *
1212
+ * @param entry - The entry to check.
1213
+ * @returns True if the entry is a type definition, false otherwise.
1214
+ */
1215
+ function isTypeDefinition(entry) {
1216
+ return !isString(entry) && entry.file !== void 0;
1217
+ }
1218
+ /**
1219
+ * Checks if the provided entry is a resolved entry type definition.
1220
+ *
1221
+ * @param entry - The entry to check.
1222
+ * @returns True if the entry is a resolved entry type definition, false otherwise.
1223
+ */
1224
+ function isResolvedEntryTypeDefinition(entry) {
1225
+ return isTypeDefinition(entry) && entry.output !== void 0;
1226
+ }
1227
+ /**
1228
+ * Get unique inputs from the provided list.
1229
+ *
1230
+ * @param inputs - The entry points to process.
1231
+ * @returns An array of unique inputs (by file path or content hash).
1232
+ */
1233
+ function getUniqueInputs(inputs = []) {
1234
+ return isObject(inputs) ? inputs : getUniqueBy(toArray(inputs), (item) => isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 }));
1235
+ }
1236
+
1237
+ //#endregion
1238
+ //#region ../core/src/lib/logger.ts
1239
+ /**
1240
+ * Create a logging function with a specific name and options.
1241
+ *
1242
+ * @param name - The name of the logging function.
1243
+ * @param options - The options to configure the logging function.
1244
+ * @returns A logging function.
1245
+ */
1246
+ const createLog = (name, options = {}) => {
1247
+ const logLevel = options.logLevel === null ? LogLevelLabel.SILENT : options.logLevel || LogLevelLabel.INFO;
1248
+ if (logLevel === LogLevelLabel.SILENT) return noop;
1249
+ if (options.customLogger) return options.customLogger;
1250
+ return (type, ...args) => getLogFn(getLogLevel(type), {
1251
+ ...options,
1252
+ logLevel
1253
+ })(`${chalk.bold.hex(getColor("brand", options))(`${name ? kebabCase(name) : ""}${options.name ? `${name ? chalk.gray(" > ") : ""}${kebabCase(options.name)}` : ""}${chalk.gray(" > ")}`)}${args.join(" ")} `.trim());
1254
+ };
1255
+ const BADGE_COLORS = [
1256
+ "#00A0DD",
1257
+ "#6FCE4E",
1258
+ "#FBBF24",
1259
+ "#F43F5E",
1260
+ "#3B82F6",
1261
+ "#A855F7",
1262
+ "#469592",
1263
+ "#288EDF",
1264
+ "#D8B4FE",
1265
+ "#10B981",
1266
+ "#EF4444",
1267
+ "#F0EC56",
1268
+ "#F472B6",
1269
+ "#22D3EE",
1270
+ "#EAB308",
1271
+ "#84CC16",
1272
+ "#F87171",
1273
+ "#0EA5E9",
1274
+ "#D946EF",
1275
+ "#FACC15",
1276
+ "#34D399",
1277
+ "#8B5CF6"
1278
+ ];
1279
+ const extendLog = (logFn, name) => {
1280
+ return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
1281
+ };
1282
+
1283
+ //#endregion
1284
+ //#region ../core/src/lib/utilities/file-header.ts
1285
+ /**
1286
+ * Generates a file header comment with a warning about automatic overwriting.
1287
+ *
1288
+ * @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.
1289
+ * @param framework - The name of the framework to include in the warning message. Defaults to "powerlines".
1290
+ * @returns A string containing the file header warning message.
1291
+ */
1292
+ function getFileHeaderWarningText(overwrite = true, framework = "powerlines") {
1293
+ return overwrite !== false ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \`output.overwrite\` option is set to \`true\`.`;
1294
+ }
1295
+ /**
1296
+ * Generates a file header warning message based on the provided context.
1297
+ *
1298
+ * @param context - The Powerlines context.
1299
+ * @returns A string containing the file header warning message.
1300
+ */
1301
+ function getFileHeaderWarning(context) {
1302
+ return getFileHeaderWarningText(context.config.output?.overwrite, context.config.framework);
1303
+ }
1304
+ /**
1305
+ * Generates a file header comment for a generated source file, including a warning about automatic overwriting.
1306
+ *
1307
+ * @param context - The Powerlines context.
1308
+ * @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.
1309
+ * @returns A string containing the file header comment.
1310
+ */
1311
+ function getFileHeader(context, comment = "//") {
1312
+ return `
1313
+ ${comment} Generated by ${titleCase(context.config.framework) || "Powerlines"}
1314
+ ${comment} ${getFileHeaderWarning(context)}
1315
+ `;
1316
+ }
1317
+ /**
1318
+ * Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.
1319
+ *
1320
+ * @param context - The Powerlines context.
1321
+ * @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.
1322
+ * @returns A string containing the file header comment for a TypeScript file.
1323
+ */
1324
+ function getTypescriptFileHeader(context, options = {}) {
1325
+ const { directive = null, prettierIgnore = false } = options;
1326
+ return `/* eslint-disable */
1327
+ // biome-ignore lint: disable
1328
+ ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
1329
+ ${getFileHeader(context)}
1330
+
1331
+ `;
1332
+ }
1333
+
1334
+ //#endregion
1335
+ //#region ../core/src/lib/utilities/source-map.ts
1336
+ const dmp = new Diff();
1337
+
1166
1338
  //#endregion
1167
1339
  //#region ../powerlines/src/storage/base.ts
1168
1340
  /**
@@ -1461,7 +1633,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
1461
1633
  * @param value - The value to set.
1462
1634
  */
1463
1635
  setSync(key, value) {
1464
- if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) return writeFileSync(this.resolve(key), value);
1636
+ if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
1637
+ const existingValue = this.getSync(this.resolve(key));
1638
+ if (isSetString(existingValue) && existingValue.includes(getFileHeaderWarningText(true, this.context.config.framework))) return writeFileSync(this.resolve(key), existingValue.replace(getFileHeaderWarningText(true, this.context.config.framework), getFileHeaderWarningText(false, this.context.config.framework)));
1639
+ } else return writeFileSync(this.resolve(key), value);
1465
1640
  }
1466
1641
  /**
1467
1642
  * Asynchronously sets the value for a given key.
@@ -1470,7 +1645,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
1470
1645
  * @param value - The value to set.
1471
1646
  */
1472
1647
  async set(key, value) {
1473
- if (!this.isReadOnly && this.overwrite) return writeFile(this.resolve(key), value);
1648
+ if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
1649
+ const existingValue = await this.get(this.resolve(key));
1650
+ if (isSetString(existingValue) && existingValue.includes(getFileHeaderWarningText(true, this.context.config.framework))) return writeFile(this.resolve(key), existingValue.replace(getFileHeaderWarningText(true, this.context.config.framework), getFileHeaderWarningText(false, this.context.config.framework)));
1651
+ } else return writeFile(this.resolve(key), value);
1474
1652
  }
1475
1653
  /**
1476
1654
  * Synchronously removes a key from the storage.
@@ -1642,145 +1820,6 @@ var VirtualStorageAdapter = class extends BaseStorageAdapter {
1642
1820
  }
1643
1821
  };
1644
1822
 
1645
- //#endregion
1646
- //#region ../core/src/lib/entry.ts
1647
- function resolveEntryOutput(context, typeDefinition) {
1648
- return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "src")), joinPaths(context.workspaceConfig.workspaceRoot, context.config.root)), joinPaths(context.config.root, "src")), context.config.root), "src"));
1649
- }
1650
- function resolveInput(context, typeDefinition, input, output) {
1651
- return {
1652
- ...typeDefinition,
1653
- input: isSetString(input) ? { file: String(input) } : typeDefinition,
1654
- output: output || resolveEntryOutput(context, typeDefinition)
1655
- };
1656
- }
1657
- /**
1658
- * Resolves multiple type definitions into their corresponding resolved entry type definitions.
1659
- *
1660
- * @param context - The current context
1661
- * @param typeDefinitions - The type definitions to resolve.
1662
- * @returns A promise that resolves to an array of resolved entry type definitions.
1663
- */
1664
- function resolveInputsSync(context, typeDefinitions) {
1665
- return (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions) ? Object.values(typeDefinitions).flat() : toArray(typeDefinitions)).map((entry) => {
1666
- if (isResolvedEntryTypeDefinition(entry)) return {
1667
- ...entry,
1668
- output: entry.output ? replacePathTokens(context, entry.output) : void 0,
1669
- file: replacePathTokens(context, entry.file)
1670
- };
1671
- let typeDefinition;
1672
- if (isString(entry)) typeDefinition = parseTypeDefinition(replacePathTokens(context, entry));
1673
- else {
1674
- typeDefinition = entry;
1675
- typeDefinition.file = replacePathTokens(context, typeDefinition.file);
1676
- }
1677
- const filePath = isAbsolutePath(typeDefinition.file) ? typeDefinition.file : appendPath(typeDefinition.file, context.config.root);
1678
- if (context.fs.isFileSync(filePath)) return resolveInput(context, {
1679
- file: appendPath(filePath, context.workspaceConfig.workspaceRoot),
1680
- name: typeDefinition.name
1681
- });
1682
- return context.fs.globSync(appendPath(filePath, context.workspaceConfig.workspaceRoot)).map((file) => resolveInput(context, {
1683
- file,
1684
- name: typeDefinition.name
1685
- }));
1686
- }).flat().filter(Boolean);
1687
- }
1688
- /**
1689
- * Checks if the provided entry is a type definition.
1690
- *
1691
- * @param entry - The entry to check.
1692
- * @returns True if the entry is a type definition, false otherwise.
1693
- */
1694
- function isTypeDefinition(entry) {
1695
- return !isString(entry) && entry.file !== void 0;
1696
- }
1697
- /**
1698
- * Checks if the provided entry is a resolved entry type definition.
1699
- *
1700
- * @param entry - The entry to check.
1701
- * @returns True if the entry is a resolved entry type definition, false otherwise.
1702
- */
1703
- function isResolvedEntryTypeDefinition(entry) {
1704
- return isTypeDefinition(entry) && entry.output !== void 0;
1705
- }
1706
- /**
1707
- * Get unique inputs from the provided list.
1708
- *
1709
- * @param inputs - The entry points to process.
1710
- * @returns An array of unique inputs (by file path or content hash).
1711
- */
1712
- function getUniqueInputs(inputs = []) {
1713
- return isObject(inputs) ? inputs : getUniqueBy(toArray(inputs), (item) => isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 }));
1714
- }
1715
-
1716
- //#endregion
1717
- //#region ../core/src/lib/logger.ts
1718
- /**
1719
- * Create a logging function with a specific name and options.
1720
- *
1721
- * @param name - The name of the logging function.
1722
- * @param options - The options to configure the logging function.
1723
- * @returns A logging function.
1724
- */
1725
- const createLog = (name, options = {}) => {
1726
- const logLevel = options.logLevel === null ? LogLevelLabel.SILENT : options.logLevel || LogLevelLabel.INFO;
1727
- if (logLevel === LogLevelLabel.SILENT) return noop;
1728
- if (options.customLogger) return options.customLogger;
1729
- return (type, ...args) => getLogFn(getLogLevel(type), {
1730
- ...options,
1731
- logLevel
1732
- })(`${chalk.bold.hex(getColor("brand", options))(`${name ? kebabCase(name) : ""}${options.name ? `${name ? chalk.gray(" > ") : ""}${kebabCase(options.name)}` : ""}${chalk.gray(" > ")}`)}${args.join(" ")} `.trim());
1733
- };
1734
- const BADGE_COLORS = [
1735
- "#00A0DD",
1736
- "#6FCE4E",
1737
- "#FBBF24",
1738
- "#F43F5E",
1739
- "#3B82F6",
1740
- "#A855F7",
1741
- "#469592",
1742
- "#288EDF",
1743
- "#D8B4FE",
1744
- "#10B981",
1745
- "#EF4444",
1746
- "#F0EC56",
1747
- "#F472B6",
1748
- "#22D3EE",
1749
- "#EAB308",
1750
- "#84CC16",
1751
- "#F87171",
1752
- "#0EA5E9",
1753
- "#D946EF",
1754
- "#FACC15",
1755
- "#34D399",
1756
- "#8B5CF6"
1757
- ];
1758
- const extendLog = (logFn, name) => {
1759
- return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
1760
- };
1761
-
1762
- //#endregion
1763
- //#region ../core/src/lib/utilities/file-header.ts
1764
- function getBaseFileHeader(context) {
1765
- return `
1766
- // Generated by ${titleCase(context.config.framework) || "Powerlines"}
1767
- ${context.config.output?.overwrite !== false ? `// Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `// This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${titleCase(context.config.framework)} while the \`output.overwrite\` option is set to \`true\`.`}
1768
- `;
1769
- }
1770
- function getFileHeader(context, options = {}) {
1771
- const { directive = null, prettierIgnore = false } = options;
1772
- return `/* eslint-disable */
1773
- // biome-ignore lint: disable
1774
- ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
1775
- ${getBaseFileHeader(context)}
1776
-
1777
- `;
1778
- }
1779
-
1780
- //#endregion
1781
- //#region ../core/src/lib/utilities/source-map.ts
1782
- const dmp = new Diff();
1783
-
1784
1823
  //#endregion
1785
1824
  //#region ../powerlines/src/_internal/vfs.ts
1786
1825
  function toFilePath(path) {
@@ -2946,6 +2985,12 @@ var PowerlinesContext = class PowerlinesContext {
2946
2985
  return joinPaths$1(this.artifactsPath, "entry");
2947
2986
  }
2948
2987
  /**
2988
+ * Get the path to the infrastructure modules used by the project
2989
+ */
2990
+ get infrastructurePath() {
2991
+ return joinPaths$1(this.artifactsPath, "infrastructure");
2992
+ }
2993
+ /**
2949
2994
  * Get the path to the data directory for the project
2950
2995
  */
2951
2996
  get dataPath() {
@@ -3152,7 +3197,7 @@ var PowerlinesContext = class PowerlinesContext {
3152
3197
  if (alias) moduleId = alias.replacement;
3153
3198
  } else if (isSetObject(this.config.resolve.alias) && this.config.resolve.alias[id]) moduleId = this.config.resolve.alias[id];
3154
3199
  }
3155
- if (this.fs.isVirtual(moduleId)) {
3200
+ if (this.fs.isVirtual(moduleId) || importer && this.fs.isVirtual(importer)) {
3156
3201
  const result = await this.fs.resolve(moduleId, importer, {
3157
3202
  conditions: this.config.resolve.conditions,
3158
3203
  extensions: this.config.resolve.extensions,
@@ -3325,6 +3370,36 @@ var PowerlinesContext = class PowerlinesContext {
3325
3370
  } }));
3326
3371
  }
3327
3372
  /**
3373
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
3374
+ *
3375
+ * @param code - The source code of the builtin file
3376
+ * @param id - The unique identifier of the builtin file
3377
+ * @param options - Optional write file options
3378
+ */
3379
+ async emitInfrastructure(code, id, options = {}) {
3380
+ if (!this.infrastructurePath) throw new Error(`The infrastructure path is not set. Cannot emit infrastructure file with id "${id}".`);
3381
+ if (!isSetString(id)) throw new Error(`The infrastructure id must be a non-empty string. Received: ${String(id)}`);
3382
+ return this.emit(code, appendPath(id, this.infrastructurePath), defu$1(options, { meta: {
3383
+ type: "infrastructure",
3384
+ id
3385
+ } }));
3386
+ }
3387
+ /**
3388
+ * Synchronously resolves an infrastructure virtual file and writes it to the VFS if it does not already exist
3389
+ *
3390
+ * @param code - The source code of the infrastructure file
3391
+ * @param id - The unique identifier of the infrastructure file
3392
+ * @param options - Optional write file options
3393
+ */
3394
+ emitInfrastructureSync(code, id, options = {}) {
3395
+ if (!this.infrastructurePath) throw new Error(`The infrastructure path is not set. Cannot emit infrastructure file with id "${id}".`);
3396
+ if (!isSetString(id)) throw new Error(`The infrastructure id must be a non-empty string. Received: ${String(id)}`);
3397
+ return this.emitSync(code, appendPath(id, this.infrastructurePath), defu$1(options, { meta: {
3398
+ type: "infrastructure",
3399
+ id
3400
+ } }));
3401
+ }
3402
+ /**
3328
3403
  * Update the context using a new user configuration options
3329
3404
  *
3330
3405
  * @param userConfig - The new user configuration options.
@@ -4204,7 +4279,7 @@ var PowerlinesAPI = class PowerlinesAPI {
4204
4279
  }
4205
4280
  if (isSetString(types?.trim()) || directives.length > 0) await context.fs.write(context.dtsPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
4206
4281
 
4207
- ` : ""}${getFileHeader(context, {
4282
+ ` : ""}${getTypescriptFileHeader(context, {
4208
4283
  directive: null,
4209
4284
  prettierIgnore: false
4210
4285
  })}
@@ -4655,4 +4730,4 @@ ${error.stack}` : "Unknown error"}`);
4655
4730
 
4656
4731
  //#endregion
4657
4732
  export { withExecutor as t };
4658
- //# sourceMappingURL=base-executor-BoGtGSyI.mjs.map
4733
+ //# sourceMappingURL=base-executor-8Ir8WQy3.mjs.map