powerlines 0.41.23 → 0.42.0

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.
@@ -76,7 +76,7 @@ let unplugin = require("unplugin");
76
76
 
77
77
  //#region package.json
78
78
  var name = "powerlines";
79
- var version = "0.41.23";
79
+ var version = "0.42.0";
80
80
 
81
81
  //#endregion
82
82
  //#region src/_internal/helpers/generate-types.ts
@@ -3232,6 +3232,53 @@ var PowerlinesAPI = class PowerlinesAPI {
3232
3232
  return api;
3233
3233
  }
3234
3234
  /**
3235
+ * Generate the Powerlines typescript declaration file
3236
+ *
3237
+ * @remarks
3238
+ * This method will only generate the typescript declaration file for the Powerlines project. It is generally recommended to run the full `prepare` command, which will run this method as part of its process.
3239
+ *
3240
+ * @param inlineConfig - The inline configuration for the typegen command
3241
+ */
3242
+ async typegen(inlineConfig = { command: "prepare" }) {
3243
+ this.context.info(" 🏗️ Generating typescript declarations for the Powerlines project");
3244
+ this.context.debug(" Aggregating configuration options for the Powerlines project");
3245
+ await this.context.withInlineConfig(inlineConfig);
3246
+ await this.#executeEnvironments(async (context) => {
3247
+ context.debug(`Initializing the processing options for the Powerlines project.`);
3248
+ await this.callHook("configResolved", {
3249
+ environment: context,
3250
+ order: "pre"
3251
+ });
3252
+ await initializeTsconfig(context);
3253
+ await this.callHook("configResolved", {
3254
+ environment: context,
3255
+ order: "normal"
3256
+ });
3257
+ if (context.entry.length > 0) context.debug(`The configuration provided ${(0, _stryke_type_checks_is_object.isObject)(context.config.input) ? Object.keys(context.config.input).length : (0, _stryke_convert_to_array.toArray)(context.config.input).length} entry point(s), Powerlines has found ${context.entry.length} entry files(s) for the ${context.config.title} project${context.entry.length > 0 && context.entry.length < 10 ? `: \n${context.entry.map((entry) => `- ${entry.file}${entry.output ? ` -> ${entry.output}` : ""}`).join(" \n")}` : ""}`);
3258
+ else context.warn(`No entry files were found for the ${context.config.title} project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`);
3259
+ await resolveTsconfig(context);
3260
+ await installDependencies(context);
3261
+ await this.callHook("configResolved", {
3262
+ environment: context,
3263
+ order: "post"
3264
+ });
3265
+ context.trace(`Powerlines configuration has been resolved: \n\n${(0, _storm_software_config_tools_logger_console.formatLogMessage)({
3266
+ ...context.config,
3267
+ userConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.userConfig) ? (0, _stryke_helpers_omit.omit)(context.config.userConfig, ["plugins"]) : void 0,
3268
+ inlineConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.inlineConfig) ? (0, _stryke_helpers_omit.omit)(context.config.inlineConfig, ["plugins"]) : void 0,
3269
+ plugins: context.plugins.map((plugin) => plugin.plugin.name)
3270
+ })}`);
3271
+ if (!context.fs.existsSync(context.cachePath)) await (0, _stryke_fs_helpers.createDirectory)(context.cachePath);
3272
+ if (!context.fs.existsSync(context.dataPath)) await (0, _stryke_fs_helpers.createDirectory)(context.dataPath);
3273
+ await this.#typegen(context);
3274
+ this.context.debug("Formatting files generated during the typegen step.");
3275
+ await (0, require_utils.utils_exports.format)(context, context.typegenPath, await context.fs.read(context.typegenPath) ?? "");
3276
+ await writeMetaFile(context);
3277
+ context.persistedMeta = context.meta;
3278
+ });
3279
+ this.context.debug("✔ Powerlines typegen has completed successfully");
3280
+ }
3281
+ /**
3235
3282
  * Prepare the Powerlines API
3236
3283
  *
3237
3284
  * @remarks
@@ -3282,78 +3329,7 @@ var PowerlinesAPI = class PowerlinesAPI {
3282
3329
  environment: context,
3283
3330
  order: "post"
3284
3331
  });
3285
- if (context.config.output.typegen !== false) {
3286
- context.debug(`Preparing the TypeScript definitions for the Powerlines project.`);
3287
- if (context.fs.existsSync(context.typegenPath)) await context.fs.remove(context.typegenPath);
3288
- if (!await (0, _stryke_fs_resolve.resolvePackage)("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
3289
- context.debug("Running TypeScript compiler for built-in runtime module files.");
3290
- let types = await emitBuiltinTypes(context, (await context.getBuiltins()).reduce((ret, builtin) => {
3291
- const formatted = (0, _stryke_path_replace.replacePath)(builtin.path, context.workspaceConfig.workspaceRoot);
3292
- if (!ret.includes(formatted)) ret.push(formatted);
3293
- return ret;
3294
- }, []));
3295
- context.debug(`Generating TypeScript declaration file ${context.typegenPath}.`);
3296
- const directives = [];
3297
- const asNextParam = (previousResult) => (0, _stryke_type_checks_is_object.isObject)(previousResult) ? previousResult.code : previousResult;
3298
- let result = await this.callHook("types", {
3299
- environment: context,
3300
- sequential: true,
3301
- order: "pre",
3302
- result: "merge",
3303
- asNextParam
3304
- }, types);
3305
- if (result) {
3306
- if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
3307
- types = result.code;
3308
- if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3309
- } else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
3310
- }
3311
- result = await this.callHook("types", {
3312
- environment: context,
3313
- sequential: true,
3314
- order: "normal",
3315
- result: "merge",
3316
- asNextParam
3317
- }, types);
3318
- if (result) {
3319
- if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
3320
- types = result.code;
3321
- if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3322
- } else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
3323
- }
3324
- result = await this.callHook("types", {
3325
- environment: context,
3326
- sequential: true,
3327
- order: "post",
3328
- result: "merge",
3329
- asNextParam
3330
- }, types);
3331
- if (result) {
3332
- if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
3333
- types = result.code;
3334
- if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3335
- } else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
3336
- }
3337
- if ((0, _stryke_type_checks_is_set_string.isSetString)(types?.trim()) || directives.length > 0) await context.fs.write(context.typegenPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3338
-
3339
- ` : ""}${(0, require_utils.utils_exports.getTypescriptFileHeader)(context, {
3340
- directive: null,
3341
- prettierIgnore: false
3342
- })}
3343
-
3344
- ${formatTypes(types)}
3345
- `);
3346
- else {
3347
- const dtsRelativePath = getTsconfigDtsPath(context);
3348
- if (context.tsconfig.tsconfigJson.include && require_tsconfig.isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
3349
- const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
3350
- context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
3351
- await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
3352
- }
3353
- }
3354
- }
3355
- context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
3356
- if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
3332
+ if (context.config.output.typegen !== false) await this.#typegen(context);
3357
3333
  this.context.debug("Formatting files generated during the prepare step.");
3358
3334
  await Promise.all([(0, require_utils.utils_exports.formatFolder)(context, context.builtinsPath), (0, require_utils.utils_exports.formatFolder)(context, context.entryPath)]);
3359
3335
  await writeMetaFile(context);
@@ -3569,7 +3545,7 @@ ${formatTypes(types)}
3569
3545
  }
3570
3546
  }
3571
3547
  await Promise.all(context.config.output.assets.map(async (asset) => {
3572
- context.trace(`Copying asset(s): ${chalk.default.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : (0, _stryke_path_append.appendPath)(asset.glob, (0, _stryke_path_replace.replacePath)(asset.input, context.workspaceConfig.workspaceRoot)))} -> ${chalk.default.greenBright((0, _stryke_path_join_paths.joinPaths)((0, _stryke_path_replace.replacePath)(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk.default.yellowBright(i)).join(", ")})` : ""}`);
3548
+ context.trace(`Copying asset(s): ${chalk.default.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : (0, _stryke_path_append.appendPath)(asset.glob, (0, _stryke_path_replace.replacePath)(asset.input, context.workspaceConfig.workspaceRoot)))} -> ${chalk.default.greenBright((0, _stryke_path_append.appendPath)(asset.glob, (0, _stryke_path_replace.replacePath)(asset.output, context.workspaceConfig.workspaceRoot)))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk.default.yellowBright(i)).join(", ")})` : ""}`);
3573
3549
  await context.fs.copy(asset, asset.output);
3574
3550
  }));
3575
3551
  await this.callHook("build", {
@@ -3711,6 +3687,87 @@ Note: Please ensure the plugin package's default export is a class that extends
3711
3687
  }
3712
3688
  }
3713
3689
  }
3690
+ /**
3691
+ * Generate the Powerlines TypeScript declaration file
3692
+ *
3693
+ * @remarks
3694
+ * This method will generate the TypeScript declaration file for the Powerlines project, including any types provided by plugins.
3695
+ *
3696
+ * @param context - The environment context to use for generating the TypeScript declaration file
3697
+ * @returns A promise that resolves when the TypeScript declaration file has been generated
3698
+ */
3699
+ async #typegen(context) {
3700
+ context.debug(`Preparing the TypeScript definitions for the Powerlines project.`);
3701
+ if (context.fs.existsSync(context.typegenPath)) await context.fs.remove(context.typegenPath);
3702
+ if (!await (0, _stryke_fs_resolve.resolvePackage)("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
3703
+ context.debug("Running TypeScript compiler for built-in runtime module files.");
3704
+ let types = await emitBuiltinTypes(context, (await context.getBuiltins()).reduce((ret, builtin) => {
3705
+ const formatted = (0, _stryke_path_replace.replacePath)(builtin.path, context.workspaceConfig.workspaceRoot);
3706
+ if (!ret.includes(formatted)) ret.push(formatted);
3707
+ return ret;
3708
+ }, []));
3709
+ context.debug(`Generating TypeScript declaration file ${context.typegenPath}.`);
3710
+ const directives = [];
3711
+ const asNextParam = (previousResult) => (0, _stryke_type_checks_is_object.isObject)(previousResult) ? previousResult.code : previousResult;
3712
+ let result = await this.callHook("typegen", {
3713
+ environment: context,
3714
+ sequential: true,
3715
+ order: "pre",
3716
+ result: "merge",
3717
+ asNextParam
3718
+ }, types);
3719
+ if (result) {
3720
+ if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
3721
+ types = result.code;
3722
+ if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3723
+ } else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
3724
+ }
3725
+ result = await this.callHook("typegen", {
3726
+ environment: context,
3727
+ sequential: true,
3728
+ order: "normal",
3729
+ result: "merge",
3730
+ asNextParam
3731
+ }, types);
3732
+ if (result) {
3733
+ if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
3734
+ types = result.code;
3735
+ if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3736
+ } else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
3737
+ }
3738
+ result = await this.callHook("typegen", {
3739
+ environment: context,
3740
+ sequential: true,
3741
+ order: "post",
3742
+ result: "merge",
3743
+ asNextParam
3744
+ }, types);
3745
+ if (result) {
3746
+ if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
3747
+ types = result.code;
3748
+ if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3749
+ } else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
3750
+ }
3751
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(types?.trim()) || directives.length > 0) await context.fs.write(context.typegenPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3752
+
3753
+ ` : ""}${(0, require_utils.utils_exports.getTypescriptFileHeader)(context, {
3754
+ directive: null,
3755
+ prettierIgnore: false
3756
+ })}
3757
+
3758
+ ${formatTypes(types)}
3759
+ `);
3760
+ else {
3761
+ const dtsRelativePath = getTsconfigDtsPath(context);
3762
+ if (context.tsconfig.tsconfigJson.include && require_tsconfig.isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
3763
+ const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
3764
+ context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
3765
+ await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
3766
+ }
3767
+ }
3768
+ context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
3769
+ if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
3770
+ }
3714
3771
  };
3715
3772
 
3716
3773
  //#endregion
@@ -72,7 +72,7 @@ import { setParseImpl } from "unplugin";
72
72
 
73
73
  //#region package.json
74
74
  var name = "powerlines";
75
- var version = "0.41.23";
75
+ var version = "0.42.0";
76
76
 
77
77
  //#endregion
78
78
  //#region src/_internal/helpers/generate-types.ts
@@ -3229,6 +3229,53 @@ var PowerlinesAPI = class PowerlinesAPI {
3229
3229
  return api;
3230
3230
  }
3231
3231
  /**
3232
+ * Generate the Powerlines typescript declaration file
3233
+ *
3234
+ * @remarks
3235
+ * This method will only generate the typescript declaration file for the Powerlines project. It is generally recommended to run the full `prepare` command, which will run this method as part of its process.
3236
+ *
3237
+ * @param inlineConfig - The inline configuration for the typegen command
3238
+ */
3239
+ async typegen(inlineConfig = { command: "prepare" }) {
3240
+ this.context.info(" 🏗️ Generating typescript declarations for the Powerlines project");
3241
+ this.context.debug(" Aggregating configuration options for the Powerlines project");
3242
+ await this.context.withInlineConfig(inlineConfig);
3243
+ await this.#executeEnvironments(async (context) => {
3244
+ context.debug(`Initializing the processing options for the Powerlines project.`);
3245
+ await this.callHook("configResolved", {
3246
+ environment: context,
3247
+ order: "pre"
3248
+ });
3249
+ await initializeTsconfig(context);
3250
+ await this.callHook("configResolved", {
3251
+ environment: context,
3252
+ order: "normal"
3253
+ });
3254
+ if (context.entry.length > 0) context.debug(`The configuration provided ${isObject(context.config.input) ? Object.keys(context.config.input).length : toArray(context.config.input).length} entry point(s), Powerlines has found ${context.entry.length} entry files(s) for the ${context.config.title} project${context.entry.length > 0 && context.entry.length < 10 ? `: \n${context.entry.map((entry) => `- ${entry.file}${entry.output ? ` -> ${entry.output}` : ""}`).join(" \n")}` : ""}`);
3255
+ else context.warn(`No entry files were found for the ${context.config.title} project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`);
3256
+ await resolveTsconfig(context);
3257
+ await installDependencies(context);
3258
+ await this.callHook("configResolved", {
3259
+ environment: context,
3260
+ order: "post"
3261
+ });
3262
+ context.trace(`Powerlines configuration has been resolved: \n\n${formatLogMessage({
3263
+ ...context.config,
3264
+ userConfig: isSetObject(context.config.userConfig) ? omit(context.config.userConfig, ["plugins"]) : void 0,
3265
+ inlineConfig: isSetObject(context.config.inlineConfig) ? omit(context.config.inlineConfig, ["plugins"]) : void 0,
3266
+ plugins: context.plugins.map((plugin) => plugin.plugin.name)
3267
+ })}`);
3268
+ if (!context.fs.existsSync(context.cachePath)) await createDirectory(context.cachePath);
3269
+ if (!context.fs.existsSync(context.dataPath)) await createDirectory(context.dataPath);
3270
+ await this.#typegen(context);
3271
+ this.context.debug("Formatting files generated during the typegen step.");
3272
+ await (0, utils_exports.format)(context, context.typegenPath, await context.fs.read(context.typegenPath) ?? "");
3273
+ await writeMetaFile(context);
3274
+ context.persistedMeta = context.meta;
3275
+ });
3276
+ this.context.debug("✔ Powerlines typegen has completed successfully");
3277
+ }
3278
+ /**
3232
3279
  * Prepare the Powerlines API
3233
3280
  *
3234
3281
  * @remarks
@@ -3279,78 +3326,7 @@ var PowerlinesAPI = class PowerlinesAPI {
3279
3326
  environment: context,
3280
3327
  order: "post"
3281
3328
  });
3282
- if (context.config.output.typegen !== false) {
3283
- context.debug(`Preparing the TypeScript definitions for the Powerlines project.`);
3284
- if (context.fs.existsSync(context.typegenPath)) await context.fs.remove(context.typegenPath);
3285
- if (!await resolvePackage("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
3286
- context.debug("Running TypeScript compiler for built-in runtime module files.");
3287
- let types = await emitBuiltinTypes(context, (await context.getBuiltins()).reduce((ret, builtin) => {
3288
- const formatted = replacePath(builtin.path, context.workspaceConfig.workspaceRoot);
3289
- if (!ret.includes(formatted)) ret.push(formatted);
3290
- return ret;
3291
- }, []));
3292
- context.debug(`Generating TypeScript declaration file ${context.typegenPath}.`);
3293
- const directives = [];
3294
- const asNextParam = (previousResult) => isObject(previousResult) ? previousResult.code : previousResult;
3295
- let result = await this.callHook("types", {
3296
- environment: context,
3297
- sequential: true,
3298
- order: "pre",
3299
- result: "merge",
3300
- asNextParam
3301
- }, types);
3302
- if (result) {
3303
- if (isSetObject(result)) {
3304
- types = result.code;
3305
- if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3306
- } else if (isSetString(result)) types = result;
3307
- }
3308
- result = await this.callHook("types", {
3309
- environment: context,
3310
- sequential: true,
3311
- order: "normal",
3312
- result: "merge",
3313
- asNextParam
3314
- }, types);
3315
- if (result) {
3316
- if (isSetObject(result)) {
3317
- types = result.code;
3318
- if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3319
- } else if (isSetString(result)) types = result;
3320
- }
3321
- result = await this.callHook("types", {
3322
- environment: context,
3323
- sequential: true,
3324
- order: "post",
3325
- result: "merge",
3326
- asNextParam
3327
- }, types);
3328
- if (result) {
3329
- if (isSetObject(result)) {
3330
- types = result.code;
3331
- if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3332
- } else if (isSetString(result)) types = result;
3333
- }
3334
- if (isSetString(types?.trim()) || directives.length > 0) await context.fs.write(context.typegenPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3335
-
3336
- ` : ""}${(0, utils_exports.getTypescriptFileHeader)(context, {
3337
- directive: null,
3338
- prettierIgnore: false
3339
- })}
3340
-
3341
- ${formatTypes(types)}
3342
- `);
3343
- else {
3344
- const dtsRelativePath = getTsconfigDtsPath(context);
3345
- if (context.tsconfig.tsconfigJson.include && isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
3346
- const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
3347
- context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
3348
- await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
3349
- }
3350
- }
3351
- }
3352
- context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
3353
- if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
3329
+ if (context.config.output.typegen !== false) await this.#typegen(context);
3354
3330
  this.context.debug("Formatting files generated during the prepare step.");
3355
3331
  await Promise.all([(0, utils_exports.formatFolder)(context, context.builtinsPath), (0, utils_exports.formatFolder)(context, context.entryPath)]);
3356
3332
  await writeMetaFile(context);
@@ -3566,7 +3542,7 @@ ${formatTypes(types)}
3566
3542
  }
3567
3543
  }
3568
3544
  await Promise.all(context.config.output.assets.map(async (asset) => {
3569
- context.trace(`Copying asset(s): ${chalk.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : appendPath(asset.glob, replacePath(asset.input, context.workspaceConfig.workspaceRoot)))} -> ${chalk.greenBright(joinPaths(replacePath(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk.yellowBright(i)).join(", ")})` : ""}`);
3545
+ context.trace(`Copying asset(s): ${chalk.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : appendPath(asset.glob, replacePath(asset.input, context.workspaceConfig.workspaceRoot)))} -> ${chalk.greenBright(appendPath(asset.glob, replacePath(asset.output, context.workspaceConfig.workspaceRoot)))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk.yellowBright(i)).join(", ")})` : ""}`);
3570
3546
  await context.fs.copy(asset, asset.output);
3571
3547
  }));
3572
3548
  await this.callHook("build", {
@@ -3708,8 +3684,89 @@ Note: Please ensure the plugin package's default export is a class that extends
3708
3684
  }
3709
3685
  }
3710
3686
  }
3687
+ /**
3688
+ * Generate the Powerlines TypeScript declaration file
3689
+ *
3690
+ * @remarks
3691
+ * This method will generate the TypeScript declaration file for the Powerlines project, including any types provided by plugins.
3692
+ *
3693
+ * @param context - The environment context to use for generating the TypeScript declaration file
3694
+ * @returns A promise that resolves when the TypeScript declaration file has been generated
3695
+ */
3696
+ async #typegen(context) {
3697
+ context.debug(`Preparing the TypeScript definitions for the Powerlines project.`);
3698
+ if (context.fs.existsSync(context.typegenPath)) await context.fs.remove(context.typegenPath);
3699
+ if (!await resolvePackage("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
3700
+ context.debug("Running TypeScript compiler for built-in runtime module files.");
3701
+ let types = await emitBuiltinTypes(context, (await context.getBuiltins()).reduce((ret, builtin) => {
3702
+ const formatted = replacePath(builtin.path, context.workspaceConfig.workspaceRoot);
3703
+ if (!ret.includes(formatted)) ret.push(formatted);
3704
+ return ret;
3705
+ }, []));
3706
+ context.debug(`Generating TypeScript declaration file ${context.typegenPath}.`);
3707
+ const directives = [];
3708
+ const asNextParam = (previousResult) => isObject(previousResult) ? previousResult.code : previousResult;
3709
+ let result = await this.callHook("typegen", {
3710
+ environment: context,
3711
+ sequential: true,
3712
+ order: "pre",
3713
+ result: "merge",
3714
+ asNextParam
3715
+ }, types);
3716
+ if (result) {
3717
+ if (isSetObject(result)) {
3718
+ types = result.code;
3719
+ if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3720
+ } else if (isSetString(result)) types = result;
3721
+ }
3722
+ result = await this.callHook("typegen", {
3723
+ environment: context,
3724
+ sequential: true,
3725
+ order: "normal",
3726
+ result: "merge",
3727
+ asNextParam
3728
+ }, types);
3729
+ if (result) {
3730
+ if (isSetObject(result)) {
3731
+ types = result.code;
3732
+ if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3733
+ } else if (isSetString(result)) types = result;
3734
+ }
3735
+ result = await this.callHook("typegen", {
3736
+ environment: context,
3737
+ sequential: true,
3738
+ order: "post",
3739
+ result: "merge",
3740
+ asNextParam
3741
+ }, types);
3742
+ if (result) {
3743
+ if (isSetObject(result)) {
3744
+ types = result.code;
3745
+ if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
3746
+ } else if (isSetString(result)) types = result;
3747
+ }
3748
+ if (isSetString(types?.trim()) || directives.length > 0) await context.fs.write(context.typegenPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
3749
+
3750
+ ` : ""}${(0, utils_exports.getTypescriptFileHeader)(context, {
3751
+ directive: null,
3752
+ prettierIgnore: false
3753
+ })}
3754
+
3755
+ ${formatTypes(types)}
3756
+ `);
3757
+ else {
3758
+ const dtsRelativePath = getTsconfigDtsPath(context);
3759
+ if (context.tsconfig.tsconfigJson.include && isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
3760
+ const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
3761
+ context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
3762
+ await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
3763
+ }
3764
+ }
3765
+ context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
3766
+ if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
3767
+ }
3711
3768
  };
3712
3769
 
3713
3770
  //#endregion
3714
3771
  export { createUnpluginFactory as a, FileMetadata as c, FileSystem as d, _capnpFileId as f, createPluginContext as i, FileMetadata_KeyValuePair as l, version as m, PowerlinesAPIContext as n, PowerlinesContext as o, name as p, PowerlinesEnvironmentContext as r, FileId as s, PowerlinesAPI as t, FileStorage as u };
3715
- //# sourceMappingURL=api-BAybLTQ1.mjs.map
3772
+ //# sourceMappingURL=api-Cq6oqcq8.mjs.map