powerlines 0.41.23 → 0.42.1
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.
- package/dist/{api-BYbfR23c.cjs → api-BEe2vHNH.cjs} +140 -74
- package/dist/{api-BAybLTQ1.mjs → api-fW_vtcef.mjs} +141 -75
- package/dist/api-fW_vtcef.mjs.map +1 -0
- package/dist/astro.cjs +1 -1
- package/dist/astro.mjs +1 -1
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.mjs +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +16 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +16 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/next.cjs +1 -1
- package/dist/next.mjs +1 -1
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.mjs +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.mjs +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/tsdown.cjs +1 -1
- package/dist/tsdown.mjs +1 -1
- package/dist/tsup.cjs +1 -1
- package/dist/tsup.mjs +1 -1
- package/dist/unloader.cjs +1 -1
- package/dist/unloader.mjs +1 -1
- package/dist/unplugin.cjs +1 -1
- package/dist/unplugin.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +12 -12
- package/dist/api-BAybLTQ1.mjs.map +0 -1
|
@@ -76,7 +76,7 @@ let unplugin = require("unplugin");
|
|
|
76
76
|
|
|
77
77
|
//#region package.json
|
|
78
78
|
var name = "powerlines";
|
|
79
|
-
var version = "0.
|
|
79
|
+
var version = "0.42.1";
|
|
80
80
|
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/_internal/helpers/generate-types.ts
|
|
@@ -3232,6 +3232,54 @@ 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: "typegen" }) {
|
|
3243
|
+
this.context.info(" 🏗️ Generating typescript declarations for the Powerlines project");
|
|
3244
|
+
this.context.debug(" Aggregating configuration options for the Powerlines project");
|
|
3245
|
+
inlineConfig.command ??= "typegen";
|
|
3246
|
+
await this.context.withInlineConfig(inlineConfig);
|
|
3247
|
+
await this.#executeEnvironments(async (context) => {
|
|
3248
|
+
context.debug(`Initializing the processing options for the Powerlines project.`);
|
|
3249
|
+
await this.callHook("configResolved", {
|
|
3250
|
+
environment: context,
|
|
3251
|
+
order: "pre"
|
|
3252
|
+
});
|
|
3253
|
+
await initializeTsconfig(context);
|
|
3254
|
+
await this.callHook("configResolved", {
|
|
3255
|
+
environment: context,
|
|
3256
|
+
order: "normal"
|
|
3257
|
+
});
|
|
3258
|
+
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")}` : ""}`);
|
|
3259
|
+
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.`);
|
|
3260
|
+
await resolveTsconfig(context);
|
|
3261
|
+
await installDependencies(context);
|
|
3262
|
+
await this.callHook("configResolved", {
|
|
3263
|
+
environment: context,
|
|
3264
|
+
order: "post"
|
|
3265
|
+
});
|
|
3266
|
+
context.trace(`Powerlines configuration has been resolved: \n\n${(0, _storm_software_config_tools_logger_console.formatLogMessage)({
|
|
3267
|
+
...context.config,
|
|
3268
|
+
userConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.userConfig) ? (0, _stryke_helpers_omit.omit)(context.config.userConfig, ["plugins"]) : void 0,
|
|
3269
|
+
inlineConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.inlineConfig) ? (0, _stryke_helpers_omit.omit)(context.config.inlineConfig, ["plugins"]) : void 0,
|
|
3270
|
+
plugins: context.plugins.map((plugin) => plugin.plugin.name)
|
|
3271
|
+
})}`);
|
|
3272
|
+
if (!context.fs.existsSync(context.cachePath)) await (0, _stryke_fs_helpers.createDirectory)(context.cachePath);
|
|
3273
|
+
if (!context.fs.existsSync(context.dataPath)) await (0, _stryke_fs_helpers.createDirectory)(context.dataPath);
|
|
3274
|
+
await this.#typegen(context);
|
|
3275
|
+
this.context.debug("Formatting files generated during the typegen step.");
|
|
3276
|
+
await (0, require_utils.utils_exports.format)(context, context.typegenPath, await context.fs.read(context.typegenPath) ?? "");
|
|
3277
|
+
await writeMetaFile(context);
|
|
3278
|
+
context.persistedMeta = context.meta;
|
|
3279
|
+
});
|
|
3280
|
+
this.context.debug("✔ Powerlines typegen has completed successfully");
|
|
3281
|
+
}
|
|
3282
|
+
/**
|
|
3235
3283
|
* Prepare the Powerlines API
|
|
3236
3284
|
*
|
|
3237
3285
|
* @remarks
|
|
@@ -3242,6 +3290,7 @@ var PowerlinesAPI = class PowerlinesAPI {
|
|
|
3242
3290
|
async prepare(inlineConfig = { command: "prepare" }) {
|
|
3243
3291
|
this.context.info(" 🏗️ Preparing the Powerlines project");
|
|
3244
3292
|
this.context.debug(" Aggregating configuration options for the Powerlines project");
|
|
3293
|
+
inlineConfig.command ??= "prepare";
|
|
3245
3294
|
await this.context.withInlineConfig(inlineConfig);
|
|
3246
3295
|
await this.#executeEnvironments(async (context) => {
|
|
3247
3296
|
context.debug(`Initializing the processing options for the Powerlines project.`);
|
|
@@ -3282,78 +3331,7 @@ var PowerlinesAPI = class PowerlinesAPI {
|
|
|
3282
3331
|
environment: context,
|
|
3283
3332
|
order: "post"
|
|
3284
3333
|
});
|
|
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.");
|
|
3334
|
+
if (context.config.output.typegen !== false) await this.#typegen(context);
|
|
3357
3335
|
this.context.debug("Formatting files generated during the prepare step.");
|
|
3358
3336
|
await Promise.all([(0, require_utils.utils_exports.formatFolder)(context, context.builtinsPath), (0, require_utils.utils_exports.formatFolder)(context, context.entryPath)]);
|
|
3359
3337
|
await writeMetaFile(context);
|
|
@@ -3372,6 +3350,7 @@ ${formatTypes(types)}
|
|
|
3372
3350
|
*/
|
|
3373
3351
|
async new(inlineConfig) {
|
|
3374
3352
|
this.context.info(" 🆕 Creating a new Powerlines project");
|
|
3353
|
+
inlineConfig.command ??= "new";
|
|
3375
3354
|
await this.prepare(inlineConfig);
|
|
3376
3355
|
await this.#executeEnvironments(async (context) => {
|
|
3377
3356
|
context.debug("Initializing the processing options for the Powerlines project.");
|
|
@@ -3422,6 +3401,7 @@ ${formatTypes(types)}
|
|
|
3422
3401
|
*/
|
|
3423
3402
|
async clean(inlineConfig = { command: "clean" }) {
|
|
3424
3403
|
this.context.info(" 🧹 Cleaning the previous Powerlines artifacts");
|
|
3404
|
+
inlineConfig.command ??= "clean";
|
|
3425
3405
|
await this.prepare(inlineConfig);
|
|
3426
3406
|
await this.#executeEnvironments(async (context) => {
|
|
3427
3407
|
context.debug("Cleaning the project's dist and artifacts directories.");
|
|
@@ -3442,6 +3422,7 @@ ${formatTypes(types)}
|
|
|
3442
3422
|
*/
|
|
3443
3423
|
async lint(inlineConfig = { command: "lint" }) {
|
|
3444
3424
|
this.context.info(" 📝 Linting the Powerlines project");
|
|
3425
|
+
inlineConfig.command ??= "lint";
|
|
3445
3426
|
await this.prepare(inlineConfig);
|
|
3446
3427
|
await this.#executeEnvironments(async (context) => {
|
|
3447
3428
|
await this.callHook("lint", {
|
|
@@ -3465,6 +3446,7 @@ ${formatTypes(types)}
|
|
|
3465
3446
|
await this.context.generateChecksum();
|
|
3466
3447
|
if (this.context.meta.checksum !== this.context.persistedMeta?.checksum || this.context.config.skipCache) {
|
|
3467
3448
|
this.context.info("The project has been modified since the last time `prepare` was ran. Re-preparing the project.");
|
|
3449
|
+
inlineConfig.command ??= "build";
|
|
3468
3450
|
await this.prepare(inlineConfig);
|
|
3469
3451
|
}
|
|
3470
3452
|
if (this.context.config.singleBuild) await this.#handleBuild(await this.#context.toEnvironment());
|
|
@@ -3481,9 +3463,11 @@ ${formatTypes(types)}
|
|
|
3481
3463
|
*/
|
|
3482
3464
|
async docs(inlineConfig = { command: "docs" }) {
|
|
3483
3465
|
this.context.info(" 📓 Generating documentation for the Powerlines project");
|
|
3466
|
+
inlineConfig.command ??= "docs";
|
|
3484
3467
|
await this.prepare(inlineConfig);
|
|
3485
3468
|
await this.#executeEnvironments(async (context) => {
|
|
3486
3469
|
context.debug("Writing documentation for the Powerlines project artifacts.");
|
|
3470
|
+
inlineConfig.command ??= "docs";
|
|
3487
3471
|
await this.prepare(inlineConfig);
|
|
3488
3472
|
await this.#executeEnvironments(async (context) => {
|
|
3489
3473
|
await this.callHook("docs", { environment: context });
|
|
@@ -3501,6 +3485,7 @@ ${formatTypes(types)}
|
|
|
3501
3485
|
*/
|
|
3502
3486
|
async deploy(inlineConfig = { command: "deploy" }) {
|
|
3503
3487
|
this.context.info(" 🚀 Deploying the Powerlines project");
|
|
3488
|
+
inlineConfig.command ??= "deploy";
|
|
3504
3489
|
await this.prepare(inlineConfig);
|
|
3505
3490
|
await this.#executeEnvironments(async (context) => {
|
|
3506
3491
|
await this.callHook("deploy", { environment: context });
|
|
@@ -3569,7 +3554,7 @@ ${formatTypes(types)}
|
|
|
3569
3554
|
}
|
|
3570
3555
|
}
|
|
3571
3556
|
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,
|
|
3557
|
+
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
3558
|
await context.fs.copy(asset, asset.output);
|
|
3574
3559
|
}));
|
|
3575
3560
|
await this.callHook("build", {
|
|
@@ -3711,6 +3696,87 @@ Note: Please ensure the plugin package's default export is a class that extends
|
|
|
3711
3696
|
}
|
|
3712
3697
|
}
|
|
3713
3698
|
}
|
|
3699
|
+
/**
|
|
3700
|
+
* Generate the Powerlines TypeScript declaration file
|
|
3701
|
+
*
|
|
3702
|
+
* @remarks
|
|
3703
|
+
* This method will generate the TypeScript declaration file for the Powerlines project, including any types provided by plugins.
|
|
3704
|
+
*
|
|
3705
|
+
* @param context - The environment context to use for generating the TypeScript declaration file
|
|
3706
|
+
* @returns A promise that resolves when the TypeScript declaration file has been generated
|
|
3707
|
+
*/
|
|
3708
|
+
async #typegen(context) {
|
|
3709
|
+
context.debug(`Preparing the TypeScript definitions for the Powerlines project.`);
|
|
3710
|
+
if (context.fs.existsSync(context.typegenPath)) await context.fs.remove(context.typegenPath);
|
|
3711
|
+
if (!await (0, _stryke_fs_resolve.resolvePackage)("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
3712
|
+
context.debug("Running TypeScript compiler for built-in runtime module files.");
|
|
3713
|
+
let types = await emitBuiltinTypes(context, (await context.getBuiltins()).reduce((ret, builtin) => {
|
|
3714
|
+
const formatted = (0, _stryke_path_replace.replacePath)(builtin.path, context.workspaceConfig.workspaceRoot);
|
|
3715
|
+
if (!ret.includes(formatted)) ret.push(formatted);
|
|
3716
|
+
return ret;
|
|
3717
|
+
}, []));
|
|
3718
|
+
context.debug(`Generating TypeScript declaration file ${context.typegenPath}.`);
|
|
3719
|
+
const directives = [];
|
|
3720
|
+
const asNextParam = (previousResult) => (0, _stryke_type_checks_is_object.isObject)(previousResult) ? previousResult.code : previousResult;
|
|
3721
|
+
let result = await this.callHook("typegen", {
|
|
3722
|
+
environment: context,
|
|
3723
|
+
sequential: true,
|
|
3724
|
+
order: "pre",
|
|
3725
|
+
result: "merge",
|
|
3726
|
+
asNextParam
|
|
3727
|
+
}, types);
|
|
3728
|
+
if (result) {
|
|
3729
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
3730
|
+
types = result.code;
|
|
3731
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
3732
|
+
} else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
3733
|
+
}
|
|
3734
|
+
result = await this.callHook("typegen", {
|
|
3735
|
+
environment: context,
|
|
3736
|
+
sequential: true,
|
|
3737
|
+
order: "normal",
|
|
3738
|
+
result: "merge",
|
|
3739
|
+
asNextParam
|
|
3740
|
+
}, types);
|
|
3741
|
+
if (result) {
|
|
3742
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
3743
|
+
types = result.code;
|
|
3744
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
3745
|
+
} else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
3746
|
+
}
|
|
3747
|
+
result = await this.callHook("typegen", {
|
|
3748
|
+
environment: context,
|
|
3749
|
+
sequential: true,
|
|
3750
|
+
order: "post",
|
|
3751
|
+
result: "merge",
|
|
3752
|
+
asNextParam
|
|
3753
|
+
}, types);
|
|
3754
|
+
if (result) {
|
|
3755
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
3756
|
+
types = result.code;
|
|
3757
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
3758
|
+
} else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
3759
|
+
}
|
|
3760
|
+
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")}
|
|
3761
|
+
|
|
3762
|
+
` : ""}${(0, require_utils.utils_exports.getTypescriptFileHeader)(context, {
|
|
3763
|
+
directive: null,
|
|
3764
|
+
prettierIgnore: false
|
|
3765
|
+
})}
|
|
3766
|
+
|
|
3767
|
+
${formatTypes(types)}
|
|
3768
|
+
`);
|
|
3769
|
+
else {
|
|
3770
|
+
const dtsRelativePath = getTsconfigDtsPath(context);
|
|
3771
|
+
if (context.tsconfig.tsconfigJson.include && require_tsconfig.isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
|
|
3772
|
+
const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
|
|
3773
|
+
context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
|
|
3774
|
+
await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
|
|
3778
|
+
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
3779
|
+
}
|
|
3714
3780
|
};
|
|
3715
3781
|
|
|
3716
3782
|
//#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.
|
|
75
|
+
var version = "0.42.1";
|
|
76
76
|
|
|
77
77
|
//#endregion
|
|
78
78
|
//#region src/_internal/helpers/generate-types.ts
|
|
@@ -3229,6 +3229,54 @@ 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: "typegen" }) {
|
|
3240
|
+
this.context.info(" 🏗️ Generating typescript declarations for the Powerlines project");
|
|
3241
|
+
this.context.debug(" Aggregating configuration options for the Powerlines project");
|
|
3242
|
+
inlineConfig.command ??= "typegen";
|
|
3243
|
+
await this.context.withInlineConfig(inlineConfig);
|
|
3244
|
+
await this.#executeEnvironments(async (context) => {
|
|
3245
|
+
context.debug(`Initializing the processing options for the Powerlines project.`);
|
|
3246
|
+
await this.callHook("configResolved", {
|
|
3247
|
+
environment: context,
|
|
3248
|
+
order: "pre"
|
|
3249
|
+
});
|
|
3250
|
+
await initializeTsconfig(context);
|
|
3251
|
+
await this.callHook("configResolved", {
|
|
3252
|
+
environment: context,
|
|
3253
|
+
order: "normal"
|
|
3254
|
+
});
|
|
3255
|
+
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")}` : ""}`);
|
|
3256
|
+
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.`);
|
|
3257
|
+
await resolveTsconfig(context);
|
|
3258
|
+
await installDependencies(context);
|
|
3259
|
+
await this.callHook("configResolved", {
|
|
3260
|
+
environment: context,
|
|
3261
|
+
order: "post"
|
|
3262
|
+
});
|
|
3263
|
+
context.trace(`Powerlines configuration has been resolved: \n\n${formatLogMessage({
|
|
3264
|
+
...context.config,
|
|
3265
|
+
userConfig: isSetObject(context.config.userConfig) ? omit(context.config.userConfig, ["plugins"]) : void 0,
|
|
3266
|
+
inlineConfig: isSetObject(context.config.inlineConfig) ? omit(context.config.inlineConfig, ["plugins"]) : void 0,
|
|
3267
|
+
plugins: context.plugins.map((plugin) => plugin.plugin.name)
|
|
3268
|
+
})}`);
|
|
3269
|
+
if (!context.fs.existsSync(context.cachePath)) await createDirectory(context.cachePath);
|
|
3270
|
+
if (!context.fs.existsSync(context.dataPath)) await createDirectory(context.dataPath);
|
|
3271
|
+
await this.#typegen(context);
|
|
3272
|
+
this.context.debug("Formatting files generated during the typegen step.");
|
|
3273
|
+
await (0, utils_exports.format)(context, context.typegenPath, await context.fs.read(context.typegenPath) ?? "");
|
|
3274
|
+
await writeMetaFile(context);
|
|
3275
|
+
context.persistedMeta = context.meta;
|
|
3276
|
+
});
|
|
3277
|
+
this.context.debug("✔ Powerlines typegen has completed successfully");
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3232
3280
|
* Prepare the Powerlines API
|
|
3233
3281
|
*
|
|
3234
3282
|
* @remarks
|
|
@@ -3239,6 +3287,7 @@ var PowerlinesAPI = class PowerlinesAPI {
|
|
|
3239
3287
|
async prepare(inlineConfig = { command: "prepare" }) {
|
|
3240
3288
|
this.context.info(" 🏗️ Preparing the Powerlines project");
|
|
3241
3289
|
this.context.debug(" Aggregating configuration options for the Powerlines project");
|
|
3290
|
+
inlineConfig.command ??= "prepare";
|
|
3242
3291
|
await this.context.withInlineConfig(inlineConfig);
|
|
3243
3292
|
await this.#executeEnvironments(async (context) => {
|
|
3244
3293
|
context.debug(`Initializing the processing options for the Powerlines project.`);
|
|
@@ -3279,78 +3328,7 @@ var PowerlinesAPI = class PowerlinesAPI {
|
|
|
3279
3328
|
environment: context,
|
|
3280
3329
|
order: "post"
|
|
3281
3330
|
});
|
|
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.");
|
|
3331
|
+
if (context.config.output.typegen !== false) await this.#typegen(context);
|
|
3354
3332
|
this.context.debug("Formatting files generated during the prepare step.");
|
|
3355
3333
|
await Promise.all([(0, utils_exports.formatFolder)(context, context.builtinsPath), (0, utils_exports.formatFolder)(context, context.entryPath)]);
|
|
3356
3334
|
await writeMetaFile(context);
|
|
@@ -3369,6 +3347,7 @@ ${formatTypes(types)}
|
|
|
3369
3347
|
*/
|
|
3370
3348
|
async new(inlineConfig) {
|
|
3371
3349
|
this.context.info(" 🆕 Creating a new Powerlines project");
|
|
3350
|
+
inlineConfig.command ??= "new";
|
|
3372
3351
|
await this.prepare(inlineConfig);
|
|
3373
3352
|
await this.#executeEnvironments(async (context) => {
|
|
3374
3353
|
context.debug("Initializing the processing options for the Powerlines project.");
|
|
@@ -3419,6 +3398,7 @@ ${formatTypes(types)}
|
|
|
3419
3398
|
*/
|
|
3420
3399
|
async clean(inlineConfig = { command: "clean" }) {
|
|
3421
3400
|
this.context.info(" 🧹 Cleaning the previous Powerlines artifacts");
|
|
3401
|
+
inlineConfig.command ??= "clean";
|
|
3422
3402
|
await this.prepare(inlineConfig);
|
|
3423
3403
|
await this.#executeEnvironments(async (context) => {
|
|
3424
3404
|
context.debug("Cleaning the project's dist and artifacts directories.");
|
|
@@ -3439,6 +3419,7 @@ ${formatTypes(types)}
|
|
|
3439
3419
|
*/
|
|
3440
3420
|
async lint(inlineConfig = { command: "lint" }) {
|
|
3441
3421
|
this.context.info(" 📝 Linting the Powerlines project");
|
|
3422
|
+
inlineConfig.command ??= "lint";
|
|
3442
3423
|
await this.prepare(inlineConfig);
|
|
3443
3424
|
await this.#executeEnvironments(async (context) => {
|
|
3444
3425
|
await this.callHook("lint", {
|
|
@@ -3462,6 +3443,7 @@ ${formatTypes(types)}
|
|
|
3462
3443
|
await this.context.generateChecksum();
|
|
3463
3444
|
if (this.context.meta.checksum !== this.context.persistedMeta?.checksum || this.context.config.skipCache) {
|
|
3464
3445
|
this.context.info("The project has been modified since the last time `prepare` was ran. Re-preparing the project.");
|
|
3446
|
+
inlineConfig.command ??= "build";
|
|
3465
3447
|
await this.prepare(inlineConfig);
|
|
3466
3448
|
}
|
|
3467
3449
|
if (this.context.config.singleBuild) await this.#handleBuild(await this.#context.toEnvironment());
|
|
@@ -3478,9 +3460,11 @@ ${formatTypes(types)}
|
|
|
3478
3460
|
*/
|
|
3479
3461
|
async docs(inlineConfig = { command: "docs" }) {
|
|
3480
3462
|
this.context.info(" 📓 Generating documentation for the Powerlines project");
|
|
3463
|
+
inlineConfig.command ??= "docs";
|
|
3481
3464
|
await this.prepare(inlineConfig);
|
|
3482
3465
|
await this.#executeEnvironments(async (context) => {
|
|
3483
3466
|
context.debug("Writing documentation for the Powerlines project artifacts.");
|
|
3467
|
+
inlineConfig.command ??= "docs";
|
|
3484
3468
|
await this.prepare(inlineConfig);
|
|
3485
3469
|
await this.#executeEnvironments(async (context) => {
|
|
3486
3470
|
await this.callHook("docs", { environment: context });
|
|
@@ -3498,6 +3482,7 @@ ${formatTypes(types)}
|
|
|
3498
3482
|
*/
|
|
3499
3483
|
async deploy(inlineConfig = { command: "deploy" }) {
|
|
3500
3484
|
this.context.info(" 🚀 Deploying the Powerlines project");
|
|
3485
|
+
inlineConfig.command ??= "deploy";
|
|
3501
3486
|
await this.prepare(inlineConfig);
|
|
3502
3487
|
await this.#executeEnvironments(async (context) => {
|
|
3503
3488
|
await this.callHook("deploy", { environment: context });
|
|
@@ -3566,7 +3551,7 @@ ${formatTypes(types)}
|
|
|
3566
3551
|
}
|
|
3567
3552
|
}
|
|
3568
3553
|
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(
|
|
3554
|
+
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
3555
|
await context.fs.copy(asset, asset.output);
|
|
3571
3556
|
}));
|
|
3572
3557
|
await this.callHook("build", {
|
|
@@ -3708,8 +3693,89 @@ Note: Please ensure the plugin package's default export is a class that extends
|
|
|
3708
3693
|
}
|
|
3709
3694
|
}
|
|
3710
3695
|
}
|
|
3696
|
+
/**
|
|
3697
|
+
* Generate the Powerlines TypeScript declaration file
|
|
3698
|
+
*
|
|
3699
|
+
* @remarks
|
|
3700
|
+
* This method will generate the TypeScript declaration file for the Powerlines project, including any types provided by plugins.
|
|
3701
|
+
*
|
|
3702
|
+
* @param context - The environment context to use for generating the TypeScript declaration file
|
|
3703
|
+
* @returns A promise that resolves when the TypeScript declaration file has been generated
|
|
3704
|
+
*/
|
|
3705
|
+
async #typegen(context) {
|
|
3706
|
+
context.debug(`Preparing the TypeScript definitions for the Powerlines project.`);
|
|
3707
|
+
if (context.fs.existsSync(context.typegenPath)) await context.fs.remove(context.typegenPath);
|
|
3708
|
+
if (!await resolvePackage("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
3709
|
+
context.debug("Running TypeScript compiler for built-in runtime module files.");
|
|
3710
|
+
let types = await emitBuiltinTypes(context, (await context.getBuiltins()).reduce((ret, builtin) => {
|
|
3711
|
+
const formatted = replacePath(builtin.path, context.workspaceConfig.workspaceRoot);
|
|
3712
|
+
if (!ret.includes(formatted)) ret.push(formatted);
|
|
3713
|
+
return ret;
|
|
3714
|
+
}, []));
|
|
3715
|
+
context.debug(`Generating TypeScript declaration file ${context.typegenPath}.`);
|
|
3716
|
+
const directives = [];
|
|
3717
|
+
const asNextParam = (previousResult) => isObject(previousResult) ? previousResult.code : previousResult;
|
|
3718
|
+
let result = await this.callHook("typegen", {
|
|
3719
|
+
environment: context,
|
|
3720
|
+
sequential: true,
|
|
3721
|
+
order: "pre",
|
|
3722
|
+
result: "merge",
|
|
3723
|
+
asNextParam
|
|
3724
|
+
}, types);
|
|
3725
|
+
if (result) {
|
|
3726
|
+
if (isSetObject(result)) {
|
|
3727
|
+
types = result.code;
|
|
3728
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
3729
|
+
} else if (isSetString(result)) types = result;
|
|
3730
|
+
}
|
|
3731
|
+
result = await this.callHook("typegen", {
|
|
3732
|
+
environment: context,
|
|
3733
|
+
sequential: true,
|
|
3734
|
+
order: "normal",
|
|
3735
|
+
result: "merge",
|
|
3736
|
+
asNextParam
|
|
3737
|
+
}, types);
|
|
3738
|
+
if (result) {
|
|
3739
|
+
if (isSetObject(result)) {
|
|
3740
|
+
types = result.code;
|
|
3741
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
3742
|
+
} else if (isSetString(result)) types = result;
|
|
3743
|
+
}
|
|
3744
|
+
result = await this.callHook("typegen", {
|
|
3745
|
+
environment: context,
|
|
3746
|
+
sequential: true,
|
|
3747
|
+
order: "post",
|
|
3748
|
+
result: "merge",
|
|
3749
|
+
asNextParam
|
|
3750
|
+
}, types);
|
|
3751
|
+
if (result) {
|
|
3752
|
+
if (isSetObject(result)) {
|
|
3753
|
+
types = result.code;
|
|
3754
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
3755
|
+
} else if (isSetString(result)) types = result;
|
|
3756
|
+
}
|
|
3757
|
+
if (isSetString(types?.trim()) || directives.length > 0) await context.fs.write(context.typegenPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
|
|
3758
|
+
|
|
3759
|
+
` : ""}${(0, utils_exports.getTypescriptFileHeader)(context, {
|
|
3760
|
+
directive: null,
|
|
3761
|
+
prettierIgnore: false
|
|
3762
|
+
})}
|
|
3763
|
+
|
|
3764
|
+
${formatTypes(types)}
|
|
3765
|
+
`);
|
|
3766
|
+
else {
|
|
3767
|
+
const dtsRelativePath = getTsconfigDtsPath(context);
|
|
3768
|
+
if (context.tsconfig.tsconfigJson.include && isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
|
|
3769
|
+
const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
|
|
3770
|
+
context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
|
|
3771
|
+
await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
|
|
3775
|
+
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
3776
|
+
}
|
|
3711
3777
|
};
|
|
3712
3778
|
|
|
3713
3779
|
//#endregion
|
|
3714
3780
|
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-
|
|
3781
|
+
//# sourceMappingURL=api-fW_vtcef.mjs.map
|