powerlines 0.42.34 → 0.42.36

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.
@@ -2,7 +2,7 @@ const require_chunk = require('./chunk-AIJqnxB6.cjs');
2
2
  const require_ts_morph = require('./ts-morph-Cf4wz3E0.cjs');
3
3
  const require_utils = require('./utils.cjs');
4
4
  const require_plugin_utils = require('./plugin-utils.cjs');
5
- const require_api_context = require('./api-context-4t-rlsAr.cjs');
5
+ const require_api_context = require('./api-context-BurprRit.cjs');
6
6
  const require_tsconfig = require('./tsconfig-ChmbpAO7.cjs');
7
7
  let _storm_software_config_tools_logger_console = require("@storm-software/config-tools/logger/console");
8
8
  let _stryke_convert_to_array = require("@stryke/convert/to-array");
@@ -45,7 +45,7 @@ let _stryke_json_storm_json = require("@stryke/json/storm-json");
45
45
 
46
46
  //#region package.json
47
47
  var name = "powerlines";
48
- var version = "0.42.34";
48
+ var version = "0.42.36";
49
49
 
50
50
  //#endregion
51
51
  //#region src/_internal/helpers/generate-types.ts
@@ -58,7 +58,7 @@ var version = "0.42.34";
58
58
  function formatTypes(code = "") {
59
59
  return code.replaceAll("#private;", "").replace(/__Ω/g, "");
60
60
  }
61
- async function extractModuleDeclarations(context, filePath, id, code, fileToModuleMap) {
61
+ async function writeModuleDeclarations(context, filePath, id, code, fileToModuleMap) {
62
62
  const mappings = /* @__PURE__ */ new Map();
63
63
  const ambient = [];
64
64
  const sourceFile = new ts_morph.Project({ useInMemoryFileSystem: true }).createSourceFile("module.d.ts", code);
@@ -222,7 +222,7 @@ async function emitBuiltinTypes(context, files) {
222
222
  for (const entry of emittedBuiltinFiles) {
223
223
  context.trace(`Processing emitted type declaration file: ${entry.filePath}`);
224
224
  const moduleId = fileToModuleMap.get(entry.filePath);
225
- const moduleDecl = await extractModuleDeclarations(context, entry.filePath, moduleId, entry.text, fileToModuleMap);
225
+ const moduleDecl = await writeModuleDeclarations(context, entry.filePath, moduleId, entry.text, fileToModuleMap);
226
226
  if (!isFirst) code += "\n\n";
227
227
  isFirst = false;
228
228
  code += moduleDecl.content;
@@ -437,6 +437,7 @@ var PowerlinesAPI = class PowerlinesAPI {
437
437
  api,
438
438
  addPlugin: api.#addPlugin.bind(api)
439
439
  };
440
+ const timer = api.context.timer("Initialization");
440
441
  api.context.info(`🔌 The Powerlines Engine v${version} has started`);
441
442
  for (const plugin of api.context.config.plugins.flat(10) ?? []) await api.#addPlugin(plugin);
442
443
  if (api.context.plugins.length === 0) api.context.warn("No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
@@ -448,6 +449,7 @@ var PowerlinesAPI = class PowerlinesAPI {
448
449
  merge: require_api_context.mergeConfigs
449
450
  });
450
451
  await api.context.withUserConfig(pluginConfig, { isHighPriority: false });
452
+ timer();
451
453
  return api;
452
454
  }
453
455
  /**
@@ -459,6 +461,7 @@ var PowerlinesAPI = class PowerlinesAPI {
459
461
  * @param inlineConfig - The inline configuration for the types command
460
462
  */
461
463
  async types(inlineConfig = { command: "types" }) {
464
+ const timer = this.context.timer("Types");
462
465
  this.context.info(" 🏗️ Generating typescript declarations for the Powerlines project");
463
466
  this.context.debug(" Aggregating configuration options for the Powerlines project");
464
467
  inlineConfig.command ??= "types";
@@ -502,6 +505,7 @@ var PowerlinesAPI = class PowerlinesAPI {
502
505
  context.persistedMeta = context.meta;
503
506
  });
504
507
  this.context.debug("✔ Powerlines types generation has completed successfully");
508
+ timer();
505
509
  }
506
510
  /**
507
511
  * Prepare the Powerlines API
@@ -512,6 +516,7 @@ var PowerlinesAPI = class PowerlinesAPI {
512
516
  * @param inlineConfig - The inline configuration for the prepare command
513
517
  */
514
518
  async prepare(inlineConfig = { command: "prepare" }) {
519
+ const timer = this.context.timer("Prepare");
515
520
  this.context.info(" 🏗️ Preparing the Powerlines project");
516
521
  this.context.debug(" Aggregating configuration options for the Powerlines project");
517
522
  inlineConfig.command ??= "prepare";
@@ -562,6 +567,7 @@ var PowerlinesAPI = class PowerlinesAPI {
562
567
  context.persistedMeta = context.meta;
563
568
  });
564
569
  this.context.debug("✔ Powerlines preparation has completed successfully");
570
+ timer();
565
571
  }
566
572
  /**
567
573
  * Create a new Powerlines project
@@ -573,6 +579,7 @@ var PowerlinesAPI = class PowerlinesAPI {
573
579
  * @returns A promise that resolves when the project has been created
574
580
  */
575
581
  async new(inlineConfig) {
582
+ const timer = this.context.timer("New");
576
583
  this.context.info(" 🆕 Creating a new Powerlines project");
577
584
  inlineConfig.command ??= "new";
578
585
  await this.prepare(inlineConfig);
@@ -613,6 +620,7 @@ var PowerlinesAPI = class PowerlinesAPI {
613
620
  });
614
621
  });
615
622
  this.context.debug("✔ Powerlines new command completed successfully");
623
+ timer();
616
624
  }
617
625
  /**
618
626
  * Clean any previously prepared artifacts
@@ -624,6 +632,7 @@ var PowerlinesAPI = class PowerlinesAPI {
624
632
  * @returns A promise that resolves when the clean command has completed
625
633
  */
626
634
  async clean(inlineConfig = { command: "clean" }) {
635
+ const timer = this.context.timer("Clean");
627
636
  this.context.info(" 🧹 Cleaning the previous Powerlines artifacts");
628
637
  inlineConfig.command ??= "clean";
629
638
  await this.prepare(inlineConfig);
@@ -637,6 +646,7 @@ var PowerlinesAPI = class PowerlinesAPI {
637
646
  });
638
647
  });
639
648
  this.context.debug("✔ Powerlines cleaning completed successfully");
649
+ timer();
640
650
  }
641
651
  /**
642
652
  * Lint the project
@@ -645,6 +655,7 @@ var PowerlinesAPI = class PowerlinesAPI {
645
655
  * @returns A promise that resolves when the lint command has completed
646
656
  */
647
657
  async lint(inlineConfig = { command: "lint" }) {
658
+ const timer = this.context.timer("Lint");
648
659
  this.context.info(" 📝 Linting the Powerlines project");
649
660
  inlineConfig.command ??= "lint";
650
661
  await this.prepare(inlineConfig);
@@ -655,6 +666,7 @@ var PowerlinesAPI = class PowerlinesAPI {
655
666
  });
656
667
  });
657
668
  this.context.debug("✔ Powerlines linting completed successfully");
669
+ timer();
658
670
  }
659
671
  /**
660
672
  * Build the project
@@ -666,6 +678,7 @@ var PowerlinesAPI = class PowerlinesAPI {
666
678
  * @returns A promise that resolves when the build command has completed
667
679
  */
668
680
  async build(inlineConfig = { command: "build" }) {
681
+ const timer = this.context.timer("Build");
669
682
  this.context.info(" 📦 Building the Powerlines project");
670
683
  await this.context.generateChecksum();
671
684
  if (this.context.meta.checksum !== this.context.persistedMeta?.checksum || this.context.config.skipCache) {
@@ -678,6 +691,7 @@ var PowerlinesAPI = class PowerlinesAPI {
678
691
  await this.#handleBuild(context);
679
692
  });
680
693
  this.context.debug("✔ Powerlines build completed successfully");
694
+ timer();
681
695
  }
682
696
  /**
683
697
  * Prepare the documentation for the project
@@ -686,6 +700,7 @@ var PowerlinesAPI = class PowerlinesAPI {
686
700
  * @returns A promise that resolves when the documentation generation has completed
687
701
  */
688
702
  async docs(inlineConfig = { command: "docs" }) {
703
+ const timer = this.context.timer("Docs");
689
704
  this.context.info(" 📓 Generating documentation for the Powerlines project");
690
705
  inlineConfig.command ??= "docs";
691
706
  await this.prepare(inlineConfig);
@@ -698,6 +713,7 @@ var PowerlinesAPI = class PowerlinesAPI {
698
713
  });
699
714
  });
700
715
  this.context.debug("✔ Powerlines documentation generation completed successfully");
716
+ timer();
701
717
  }
702
718
  /**
703
719
  * Deploy the project source code
@@ -708,6 +724,7 @@ var PowerlinesAPI = class PowerlinesAPI {
708
724
  * @param inlineConfig - The inline configuration for the deploy command
709
725
  */
710
726
  async deploy(inlineConfig = { command: "deploy" }) {
727
+ const timer = this.context.timer("Deploy");
711
728
  this.context.info(" 🚀 Deploying the Powerlines project");
712
729
  inlineConfig.command ??= "deploy";
713
730
  await this.prepare(inlineConfig);
@@ -715,9 +732,10 @@ var PowerlinesAPI = class PowerlinesAPI {
715
732
  await this.callHook("deploy", { environment: context });
716
733
  });
717
734
  this.context.debug("✔ Powerlines deploy completed successfully");
735
+ timer();
718
736
  }
719
737
  /**
720
- * Finalization process
738
+ * Finalization/cleanup processing for the Powerlines API
721
739
  *
722
740
  * @remarks
723
741
  * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
@@ -725,6 +743,7 @@ var PowerlinesAPI = class PowerlinesAPI {
725
743
  * @returns A promise that resolves when the finalization process has completed
726
744
  */
727
745
  async finalize() {
746
+ const timer = this.context.timer("Finalization");
728
747
  this.context.info(" 🏁 Powerlines finalization processes started");
729
748
  await this.#executeEnvironments(async (context) => {
730
749
  await this.callHook("finalize", { environment: context });
@@ -732,6 +751,7 @@ var PowerlinesAPI = class PowerlinesAPI {
732
751
  if ((0, _stryke_fs_exists.existsSync)(context.cachePath) && !(await (0, _stryke_fs_list_files.listFiles)((0, _stryke_path_join_paths.joinPaths)(context.cachePath, "**/*")))?.length) await (0, _stryke_fs_helpers.removeDirectory)(context.cachePath);
733
752
  });
734
753
  this.context.debug("✔ Powerlines finalization completed successfully");
754
+ timer();
735
755
  }
736
756
  /**
737
757
  * Invokes the configured plugin hooks
@@ -45,6 +45,7 @@ let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
45
45
  let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
46
46
  let bundle_require = require("bundle-require");
47
47
  let compatx = require("compatx");
48
+ let date_fns_formatDistanceToNowStrict = require("date-fns/formatDistanceToNowStrict");
48
49
  let flat_cache = require("flat-cache");
49
50
  let oxc_parser = require("oxc-parser");
50
51
  let undici = require("undici");
@@ -2342,6 +2343,27 @@ var PowerlinesContext = class PowerlinesContext {
2342
2343
  this.log(_storm_software_config_tools_types.LogLevelLabel.TRACE, (0, _stryke_type_checks_is_string.isString)(message) ? message : _stryke_json_storm_json.StormJSON.stringify(message));
2343
2344
  }
2344
2345
  /**
2346
+ * A function to create a timer for measuring the duration of asynchronous operations
2347
+ *
2348
+ * @example
2349
+ * ```ts
2350
+ * const stopTimer = context.timer("Your Async Operation");
2351
+ * await performAsyncOperation();
2352
+ * stopTimer(); // "Your Async Operation completed in 123.45 milliseconds"
2353
+ * ```
2354
+ *
2355
+ * @param name - The name of the timer.
2356
+ * @returns A function that, when called, stops the timer and logs the duration.
2357
+ */
2358
+ timer(name) {
2359
+ const startDate = Date.now();
2360
+ const startDuration = performance.now();
2361
+ return () => {
2362
+ const duration = performance.now() - startDuration;
2363
+ this.log(_storm_software_config_tools_types.LogLevelLabel.PERFORMANCE, `${chalk.default.bold.cyanBright(name)} completed in ${chalk.default.bold.cyanBright(duration < 1e3 ? `${duration.toFixed(2)} milliseconds` : (0, date_fns_formatDistanceToNowStrict.formatDistanceToNowStrict)(startDate))}`);
2364
+ };
2365
+ }
2366
+ /**
2345
2367
  * Create a new logger instance
2346
2368
  *
2347
2369
  * @param name - The name to use for the logger instance
@@ -2725,7 +2747,13 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
2725
2747
  plugin: resolvedPlugin,
2726
2748
  context
2727
2749
  });
2728
- this.#hooks = Object.keys(resolvedPlugin).filter((key) => !require_constants.constants_exports.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => extractHooks(context, ret, resolvedPlugin, key), this.hooks);
2750
+ this.#hooks = Object.entries(Object.keys(resolvedPlugin).filter((key) => !require_constants.constants_exports.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => extractHooks(context, ret, resolvedPlugin, key), this.hooks)).reduce((ret, [key, value]) => {
2751
+ if ((0, _stryke_type_checks_is_set_object.isSetObject)(value)) Object.entries(value).forEach(([type, list]) => {
2752
+ ret[key] ??= {};
2753
+ ret[key][type] = (0, require_plugin_utils.plugin_utils_exports.dedupeHooklist)(list);
2754
+ });
2755
+ return ret;
2756
+ }, {});
2729
2757
  }
2730
2758
  /**
2731
2759
  * Retrieves the hook handlers for a specific hook name
@@ -42,6 +42,7 @@ import { isNull } from "@stryke/type-checks/is-null";
42
42
  import { uuid } from "@stryke/unique-id/uuid";
43
43
  import { match, tsconfigPathsToRegExp } from "bundle-require";
44
44
  import { resolveCompatibilityDates } from "compatx";
45
+ import { formatDistanceToNowStrict } from "date-fns/formatDistanceToNowStrict";
45
46
  import { create } from "flat-cache";
46
47
  import { parse } from "oxc-parser";
47
48
  import { Agent, Response, interceptors, setGlobalDispatcher } from "undici";
@@ -2338,6 +2339,27 @@ var PowerlinesContext = class PowerlinesContext {
2338
2339
  this.log(LogLevelLabel.TRACE, isString(message) ? message : StormJSON.stringify(message));
2339
2340
  }
2340
2341
  /**
2342
+ * A function to create a timer for measuring the duration of asynchronous operations
2343
+ *
2344
+ * @example
2345
+ * ```ts
2346
+ * const stopTimer = context.timer("Your Async Operation");
2347
+ * await performAsyncOperation();
2348
+ * stopTimer(); // "Your Async Operation completed in 123.45 milliseconds"
2349
+ * ```
2350
+ *
2351
+ * @param name - The name of the timer.
2352
+ * @returns A function that, when called, stops the timer and logs the duration.
2353
+ */
2354
+ timer(name) {
2355
+ const startDate = Date.now();
2356
+ const startDuration = performance.now();
2357
+ return () => {
2358
+ const duration = performance.now() - startDuration;
2359
+ this.log(LogLevelLabel.PERFORMANCE, `${chalk.bold.cyanBright(name)} completed in ${chalk.bold.cyanBright(duration < 1e3 ? `${duration.toFixed(2)} milliseconds` : formatDistanceToNowStrict(startDate))}`);
2360
+ };
2361
+ }
2362
+ /**
2341
2363
  * Create a new logger instance
2342
2364
  *
2343
2365
  * @param name - The name to use for the logger instance
@@ -2721,7 +2743,13 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
2721
2743
  plugin: resolvedPlugin,
2722
2744
  context
2723
2745
  });
2724
- this.#hooks = Object.keys(resolvedPlugin).filter((key) => !constants_exports.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => extractHooks(context, ret, resolvedPlugin, key), this.hooks);
2746
+ this.#hooks = Object.entries(Object.keys(resolvedPlugin).filter((key) => !constants_exports.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => extractHooks(context, ret, resolvedPlugin, key), this.hooks)).reduce((ret, [key, value]) => {
2747
+ if (isSetObject(value)) Object.entries(value).forEach(([type, list]) => {
2748
+ ret[key] ??= {};
2749
+ ret[key][type] = (0, plugin_utils_exports.dedupeHooklist)(list);
2750
+ });
2751
+ return ret;
2752
+ }, {});
2725
2753
  }
2726
2754
  /**
2727
2755
  * Retrieves the hook handlers for a specific hook name
@@ -2953,4 +2981,4 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
2953
2981
 
2954
2982
  //#endregion
2955
2983
  export { FileId as a, FileStorage as c, writeMetaFile as d, callHook as f, PowerlinesContext as i, FileSystem as l, PowerlinesEnvironmentContext as n, FileMetadata as o, mergeConfigs as p, createPluginContext as r, FileMetadata_KeyValuePair as s, PowerlinesAPIContext as t, _capnpFileId as u };
2956
- //# sourceMappingURL=api-context-CmuOyg7q.mjs.map
2984
+ //# sourceMappingURL=api-context-CEJ3s11k.mjs.map