powerlines 0.41.20 → 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.
- package/dist/{api-DSbiwkgX.cjs → api-BGV1CwNT.cjs} +144 -87
- package/dist/{api-D2cw-NSF.mjs → api-Cq6oqcq8.mjs} +145 -88
- package/dist/api-Cq6oqcq8.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 +9 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -0
- 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 +2 -2
- package/dist/tsdown.mjs +2 -2
- package/dist/tsdown.mjs.map +1 -1
- package/dist/tsup.cjs +2 -2
- package/dist/tsup.mjs +2 -2
- package/dist/tsup.mjs.map +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 +31 -31
- package/dist/api-D2cw-NSF.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.0";
|
|
80
80
|
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/_internal/helpers/generate-types.ts
|
|
@@ -1170,8 +1170,8 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1170
1170
|
...this.#context.config.output.storage
|
|
1171
1171
|
};
|
|
1172
1172
|
this.#storage.virtual ??= new require_virtual.VirtualStorageAdapter(context, { base: "/_virtual" });
|
|
1173
|
-
this.#storage[this.#context.config.output.
|
|
1174
|
-
this.#storage[this.#context.config.output.
|
|
1173
|
+
this.#storage[this.#context.config.output.publishPath] ??= new require_virtual.FileSystemStorageAdapter(context, { base: this.#context.config.output.publishPath });
|
|
1174
|
+
this.#storage[this.#context.config.output.path] ??= new require_virtual.FileSystemStorageAdapter(context, { base: this.#context.config.output.path });
|
|
1175
1175
|
if (this.#context.config.output.storage !== "fs") {
|
|
1176
1176
|
this.#storage[this.#context.artifactsPath] ??= new require_virtual.VirtualStorageAdapter(context, { base: this.#context.artifactsPath });
|
|
1177
1177
|
this.#storage[this.#context.builtinsPath] ??= new require_virtual.VirtualStorageAdapter(context, { base: this.#context.builtinsPath });
|
|
@@ -2576,7 +2576,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2576
2576
|
version: this.packageJson?.version,
|
|
2577
2577
|
description: this.packageJson?.description,
|
|
2578
2578
|
output: (0, require_plugin_utils.plugin_utils_exports.mergeConfig)(config.output ?? {}, {
|
|
2579
|
-
|
|
2579
|
+
publishPath: cacheKey.root ? (0, _stryke_path_join.joinPaths)(this.workspaceConfig?.directories?.build || "dist", cacheKey.root) : this.workspaceConfig?.directories?.build || "dist",
|
|
2580
2580
|
artifactsPath: `.${config.framework ?? "powerlines"}`,
|
|
2581
2581
|
dts: true,
|
|
2582
2582
|
typegen: (0, _stryke_path_join.joinPaths)(cacheKey.root, `${config.framework ?? "powerlines"}.d.ts`),
|
|
@@ -2615,17 +2615,17 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2615
2615
|
this.config.output.format = (0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(this.config.output?.format ?? (this.config.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
|
|
2616
2616
|
if (this.config.output.dts !== false && !this.config.output.typegen) this.config.output.typegen = `${this.config.root ? `${this.config.root}/` : ""}${this.config.framework ?? "powerlines"}.d.ts`;
|
|
2617
2617
|
if (this.config.root && this.config.root !== "." && this.config.root !== "./" && this.config.root !== this.workspaceConfig.workspaceRoot) {
|
|
2618
|
-
this.config.output.
|
|
2619
|
-
this.config.output.
|
|
2618
|
+
this.config.output.path ??= (0, _stryke_path_join.joinPaths)(this.config.root, "dist");
|
|
2619
|
+
this.config.output.publishPath ??= (0, _stryke_path_join.joinPaths)("dist", this.config.root);
|
|
2620
2620
|
} else {
|
|
2621
|
-
this.config.output.
|
|
2622
|
-
this.config.output.
|
|
2621
|
+
this.config.output.path ??= "dist";
|
|
2622
|
+
this.config.output.publishPath ??= this.config.output.path;
|
|
2623
2623
|
}
|
|
2624
2624
|
this.config.output.assets = (0, _stryke_helpers_get_unique.getUniqueBy)(this.config.output.assets.map((asset) => {
|
|
2625
2625
|
return {
|
|
2626
2626
|
glob: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) ? asset.glob : asset,
|
|
2627
2627
|
input: (0, _stryke_type_checks_is_string.isString)(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.workspaceConfig.workspaceRoot : (0, _stryke_path_is_parent_path.isParentPath)(asset.input, this.workspaceConfig.workspaceRoot) || asset.input === this.workspaceConfig.workspaceRoot ? asset.input : (0, _stryke_path_append.appendPath)(asset.input, this.workspaceConfig.workspaceRoot),
|
|
2628
|
-
output: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) && asset.output ? (0, _stryke_path_is_parent_path.isParentPath)(asset.output, this.workspaceConfig.workspaceRoot) ? asset.output : (0, _stryke_path_append.appendPath)((0, _stryke_path_join.joinPaths)(this.config.output.
|
|
2628
|
+
output: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) && asset.output ? (0, _stryke_path_is_parent_path.isParentPath)(asset.output, this.workspaceConfig.workspaceRoot) ? asset.output : (0, _stryke_path_append.appendPath)((0, _stryke_path_join.joinPaths)(this.config.output.publishPath, (0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)(asset.output, (0, _stryke_path_replace.replacePath)(this.config.output.publishPath, this.workspaceConfig.workspaceRoot)), this.config.output.publishPath)), this.workspaceConfig.workspaceRoot) : (0, _stryke_path_append.appendPath)(this.config.output.publishPath, this.workspaceConfig.workspaceRoot),
|
|
2629
2629
|
ignore: (0, _stryke_type_checks_is_set_object.isSetObject)(asset) && asset.ignore ? (0, _stryke_convert_to_array.toArray)(asset.ignore) : void 0
|
|
2630
2630
|
};
|
|
2631
2631
|
}), (a) => `${a.input}-${a.glob}-${a.output}`);
|
|
@@ -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);
|
|
@@ -3425,7 +3401,7 @@ ${formatTypes(types)}
|
|
|
3425
3401
|
await this.prepare(inlineConfig);
|
|
3426
3402
|
await this.#executeEnvironments(async (context) => {
|
|
3427
3403
|
context.debug("Cleaning the project's dist and artifacts directories.");
|
|
3428
|
-
await context.fs.remove((0, _stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.output.
|
|
3404
|
+
await context.fs.remove((0, _stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.output.path));
|
|
3429
3405
|
await context.fs.remove((0, _stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.root, context.config.output.artifactsPath));
|
|
3430
3406
|
await this.callHook("clean", {
|
|
3431
3407
|
environment: context,
|
|
@@ -3560,16 +3536,16 @@ ${formatTypes(types)}
|
|
|
3560
3536
|
environment: context,
|
|
3561
3537
|
order: "normal"
|
|
3562
3538
|
});
|
|
3563
|
-
if (context.config.output.
|
|
3564
|
-
const sourcePath = (0, _stryke_path_append.appendPath)(context.config.output.
|
|
3565
|
-
const destinationPath = (0, _stryke_path_join_paths.joinPaths)((0, _stryke_path_append.appendPath)(context.config.output.
|
|
3539
|
+
if (context.config.output.path !== context.config.output.publishPath) {
|
|
3540
|
+
const sourcePath = (0, _stryke_path_append.appendPath)(context.config.output.path, context.workspaceConfig.workspaceRoot);
|
|
3541
|
+
const destinationPath = (0, _stryke_path_join_paths.joinPaths)((0, _stryke_path_append.appendPath)(context.config.output.publishPath, context.workspaceConfig.workspaceRoot), "dist");
|
|
3566
3542
|
if (context.fs.existsSync(sourcePath) && sourcePath !== destinationPath) {
|
|
3567
|
-
context.debug(`Copying
|
|
3543
|
+
context.debug(`Copying output files from project's output directory (${context.config.output.path}) to the publish output directory (${context.config.output.publishPath}).`);
|
|
3568
3544
|
await context.fs.copy(sourcePath, destinationPath);
|
|
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,
|
|
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.
|
|
75
|
+
var version = "0.42.0";
|
|
76
76
|
|
|
77
77
|
//#endregion
|
|
78
78
|
//#region src/_internal/helpers/generate-types.ts
|
|
@@ -1166,8 +1166,8 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1166
1166
|
...this.#context.config.output.storage
|
|
1167
1167
|
};
|
|
1168
1168
|
this.#storage.virtual ??= new VirtualStorageAdapter(context, { base: "/_virtual" });
|
|
1169
|
-
this.#storage[this.#context.config.output.
|
|
1170
|
-
this.#storage[this.#context.config.output.
|
|
1169
|
+
this.#storage[this.#context.config.output.publishPath] ??= new FileSystemStorageAdapter(context, { base: this.#context.config.output.publishPath });
|
|
1170
|
+
this.#storage[this.#context.config.output.path] ??= new FileSystemStorageAdapter(context, { base: this.#context.config.output.path });
|
|
1171
1171
|
if (this.#context.config.output.storage !== "fs") {
|
|
1172
1172
|
this.#storage[this.#context.artifactsPath] ??= new VirtualStorageAdapter(context, { base: this.#context.artifactsPath });
|
|
1173
1173
|
this.#storage[this.#context.builtinsPath] ??= new VirtualStorageAdapter(context, { base: this.#context.builtinsPath });
|
|
@@ -2572,7 +2572,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2572
2572
|
version: this.packageJson?.version,
|
|
2573
2573
|
description: this.packageJson?.description,
|
|
2574
2574
|
output: (0, plugin_utils_exports.mergeConfig)(config.output ?? {}, {
|
|
2575
|
-
|
|
2575
|
+
publishPath: cacheKey.root ? joinPaths$1(this.workspaceConfig?.directories?.build || "dist", cacheKey.root) : this.workspaceConfig?.directories?.build || "dist",
|
|
2576
2576
|
artifactsPath: `.${config.framework ?? "powerlines"}`,
|
|
2577
2577
|
dts: true,
|
|
2578
2578
|
typegen: joinPaths$1(cacheKey.root, `${config.framework ?? "powerlines"}.d.ts`),
|
|
@@ -2611,17 +2611,17 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2611
2611
|
this.config.output.format = getUnique(toArray(this.config.output?.format ?? (this.config.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
|
|
2612
2612
|
if (this.config.output.dts !== false && !this.config.output.typegen) this.config.output.typegen = `${this.config.root ? `${this.config.root}/` : ""}${this.config.framework ?? "powerlines"}.d.ts`;
|
|
2613
2613
|
if (this.config.root && this.config.root !== "." && this.config.root !== "./" && this.config.root !== this.workspaceConfig.workspaceRoot) {
|
|
2614
|
-
this.config.output.
|
|
2615
|
-
this.config.output.
|
|
2614
|
+
this.config.output.path ??= joinPaths$1(this.config.root, "dist");
|
|
2615
|
+
this.config.output.publishPath ??= joinPaths$1("dist", this.config.root);
|
|
2616
2616
|
} else {
|
|
2617
|
-
this.config.output.
|
|
2618
|
-
this.config.output.
|
|
2617
|
+
this.config.output.path ??= "dist";
|
|
2618
|
+
this.config.output.publishPath ??= this.config.output.path;
|
|
2619
2619
|
}
|
|
2620
2620
|
this.config.output.assets = getUniqueBy(this.config.output.assets.map((asset) => {
|
|
2621
2621
|
return {
|
|
2622
2622
|
glob: isSetObject(asset) ? asset.glob : asset,
|
|
2623
2623
|
input: isString(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.workspaceConfig.workspaceRoot : isParentPath(asset.input, this.workspaceConfig.workspaceRoot) || asset.input === this.workspaceConfig.workspaceRoot ? asset.input : appendPath(asset.input, this.workspaceConfig.workspaceRoot),
|
|
2624
|
-
output: isSetObject(asset) && asset.output ? isParentPath(asset.output, this.workspaceConfig.workspaceRoot) ? asset.output : appendPath(joinPaths$1(this.config.output.
|
|
2624
|
+
output: isSetObject(asset) && asset.output ? isParentPath(asset.output, this.workspaceConfig.workspaceRoot) ? asset.output : appendPath(joinPaths$1(this.config.output.publishPath, replacePath(replacePath(asset.output, replacePath(this.config.output.publishPath, this.workspaceConfig.workspaceRoot)), this.config.output.publishPath)), this.workspaceConfig.workspaceRoot) : appendPath(this.config.output.publishPath, this.workspaceConfig.workspaceRoot),
|
|
2625
2625
|
ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
|
|
2626
2626
|
};
|
|
2627
2627
|
}), (a) => `${a.input}-${a.glob}-${a.output}`);
|
|
@@ -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);
|
|
@@ -3422,7 +3398,7 @@ ${formatTypes(types)}
|
|
|
3422
3398
|
await this.prepare(inlineConfig);
|
|
3423
3399
|
await this.#executeEnvironments(async (context) => {
|
|
3424
3400
|
context.debug("Cleaning the project's dist and artifacts directories.");
|
|
3425
|
-
await context.fs.remove(joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.
|
|
3401
|
+
await context.fs.remove(joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.path));
|
|
3426
3402
|
await context.fs.remove(joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, context.config.output.artifactsPath));
|
|
3427
3403
|
await this.callHook("clean", {
|
|
3428
3404
|
environment: context,
|
|
@@ -3557,16 +3533,16 @@ ${formatTypes(types)}
|
|
|
3557
3533
|
environment: context,
|
|
3558
3534
|
order: "normal"
|
|
3559
3535
|
});
|
|
3560
|
-
if (context.config.output.
|
|
3561
|
-
const sourcePath = appendPath(context.config.output.
|
|
3562
|
-
const destinationPath = joinPaths(appendPath(context.config.output.
|
|
3536
|
+
if (context.config.output.path !== context.config.output.publishPath) {
|
|
3537
|
+
const sourcePath = appendPath(context.config.output.path, context.workspaceConfig.workspaceRoot);
|
|
3538
|
+
const destinationPath = joinPaths(appendPath(context.config.output.publishPath, context.workspaceConfig.workspaceRoot), "dist");
|
|
3563
3539
|
if (context.fs.existsSync(sourcePath) && sourcePath !== destinationPath) {
|
|
3564
|
-
context.debug(`Copying
|
|
3540
|
+
context.debug(`Copying output files from project's output directory (${context.config.output.path}) to the publish output directory (${context.config.output.publishPath}).`);
|
|
3565
3541
|
await context.fs.copy(sourcePath, destinationPath);
|
|
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 :
|
|
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-
|
|
3772
|
+
//# sourceMappingURL=api-Cq6oqcq8.mjs.map
|