powerlines 0.42.26 → 0.42.28
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-C4dPy8XP.mjs +901 -0
- package/dist/api-C4dPy8XP.mjs.map +1 -0
- package/dist/api-LEq5A1pG.cjs +922 -0
- package/dist/api-LEq5A1pG.cjs.map +1 -0
- package/dist/{api-CvAosB7E.cjs → api-context-BSrRdlnu.cjs} +103 -1070
- package/dist/api-context-BSrRdlnu.cjs.map +1 -0
- package/dist/{api-Dtr_u8iv.mjs → api-context-p1enWkF-.mjs} +102 -1058
- package/dist/api-context-p1enWkF-.mjs.map +1 -0
- package/dist/context/index.cjs +5 -5
- package/dist/context/index.d.cts +3 -3
- package/dist/context/index.d.cts.map +1 -1
- package/dist/context/index.d.mts +4 -4
- package/dist/context/index.d.mts.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.mjs +1 -1
- package/dist/farm.cjs +2 -2
- package/dist/farm.cjs.map +1 -1
- package/dist/farm.mjs +1 -1
- package/dist/index.cjs +8 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.cjs +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.mjs +1 -1
- package/dist/rolldown.cjs +2 -2
- package/dist/rolldown.cjs.map +1 -1
- package/dist/rolldown.mjs +1 -1
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.cjs.map +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.d.mts +1 -1
- package/dist/storage/index.mjs +1 -1
- package/dist/ts-morph-B85ZbV1Q.mjs +102 -0
- package/dist/ts-morph-B85ZbV1Q.mjs.map +1 -0
- package/dist/ts-morph-Cf4wz3E0.cjs +115 -0
- package/dist/ts-morph-Cf4wz3E0.cjs.map +1 -0
- package/dist/{tsconfig-BC3TZxD4.cjs → tsconfig-ChmbpAO7.cjs} +1 -111
- package/dist/tsconfig-ChmbpAO7.cjs.map +1 -0
- package/dist/{tsconfig-CXwGIrfR.mjs → tsconfig-DoV1dUYg.mjs} +2 -100
- package/dist/tsconfig-DoV1dUYg.mjs.map +1 -0
- package/dist/{types-ro7jWCtL.d.mts → types-9O-s0Fpu.d.mts} +1 -1
- package/dist/types-9O-s0Fpu.d.mts.map +1 -0
- package/dist/typescript/index.cjs +4 -3
- package/dist/typescript/index.mjs +2 -1
- package/dist/unloader.cjs +2 -2
- package/dist/unloader.cjs.map +1 -1
- package/dist/unloader.mjs +1 -1
- package/dist/unplugin.cjs +98 -2
- package/dist/unplugin.cjs.map +1 -0
- package/dist/unplugin.mjs +96 -2
- package/dist/unplugin.mjs.map +1 -0
- package/dist/{virtual-BvouNuwf.cjs → virtual-BNy8T32w.cjs} +1 -1
- package/dist/{virtual-BvouNuwf.cjs.map → virtual-BNy8T32w.cjs.map} +1 -1
- package/dist/{virtual-B0n7dKeA.mjs → virtual-PaZGNIrj.mjs} +1 -1
- package/dist/{virtual-B0n7dKeA.mjs.map → virtual-PaZGNIrj.mjs.map} +1 -1
- package/dist/vite.cjs +3 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +2 -2
- package/dist/webpack.cjs +2 -2
- package/dist/webpack.cjs.map +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +19 -19
- package/dist/api-CvAosB7E.cjs.map +0 -1
- package/dist/api-Dtr_u8iv.mjs.map +0 -1
- package/dist/tsconfig-BC3TZxD4.cjs.map +0 -1
- package/dist/tsconfig-CXwGIrfR.mjs.map +0 -1
- package/dist/types-ro7jWCtL.d.mts.map +0 -1
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-AIJqnxB6.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_utils = require('./utils.cjs');
|
|
3
3
|
const require_plugin_utils = require('./plugin-utils.cjs');
|
|
4
4
|
const require_constants = require('./constants.cjs');
|
|
5
|
+
const require_tsconfig = require('./tsconfig-ChmbpAO7.cjs');
|
|
5
6
|
const require_config = require('./config.cjs');
|
|
6
|
-
const
|
|
7
|
-
const require_virtual = require('./virtual-BvouNuwf.cjs');
|
|
7
|
+
const require_virtual = require('./virtual-BNy8T32w.cjs');
|
|
8
8
|
let _stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
|
|
9
|
-
let _storm_software_config_tools_logger_console = require("@storm-software/config-tools/logger/console");
|
|
10
9
|
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
11
|
-
let _stryke_fs_copy_file = require("@stryke/fs/copy-file");
|
|
12
10
|
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
13
|
-
let _stryke_fs_helpers = require("@stryke/fs/helpers");
|
|
14
|
-
let _stryke_fs_install = require("@stryke/fs/install");
|
|
15
|
-
let _stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
16
|
-
let _stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
17
11
|
let _stryke_fs_resolve = require("@stryke/fs/resolve");
|
|
18
12
|
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
19
13
|
let _stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
@@ -22,11 +16,8 @@ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
|
22
16
|
let _stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
23
17
|
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
24
18
|
let _stryke_path_replace = require("@stryke/path/replace");
|
|
25
|
-
let _stryke_type_checks_is_error = require("@stryke/type-checks/is-error");
|
|
26
19
|
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
27
|
-
let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
28
20
|
let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
29
|
-
let _stryke_type_checks_is_promise = require("@stryke/type-checks/is-promise");
|
|
30
21
|
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
31
22
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
32
23
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
@@ -35,15 +26,12 @@ let chalk = require("chalk");
|
|
|
35
26
|
chalk = require_chunk.__toESM(chalk);
|
|
36
27
|
let defu = require("defu");
|
|
37
28
|
defu = require_chunk.__toESM(defu);
|
|
38
|
-
let handlebars = require("handlebars");
|
|
39
|
-
handlebars = require_chunk.__toESM(handlebars);
|
|
40
29
|
let _stryke_string_format_pretty_bytes = require("@stryke/string-format/pretty-bytes");
|
|
41
|
-
let
|
|
42
|
-
let
|
|
30
|
+
let bundle_require = require("bundle-require");
|
|
31
|
+
let _stryke_helpers_get_field = require("@stryke/helpers/get-field");
|
|
43
32
|
let _stryke_fs_json = require("@stryke/fs/json");
|
|
44
33
|
require("@stryke/fs/remove-file");
|
|
45
34
|
let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
46
|
-
let _donedeal0_superdiff = require("@donedeal0/superdiff");
|
|
47
35
|
let _stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
48
36
|
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
49
37
|
let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
@@ -55,7 +43,6 @@ let _stryke_http_fetch = require("@stryke/http/fetch");
|
|
|
55
43
|
let _stryke_path_join = require("@stryke/path/join");
|
|
56
44
|
let _stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
|
|
57
45
|
let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
|
|
58
|
-
let bundle_require = require("bundle-require");
|
|
59
46
|
let compatx = require("compatx");
|
|
60
47
|
let flat_cache = require("flat-cache");
|
|
61
48
|
let oxc_parser = require("oxc-parser");
|
|
@@ -71,80 +58,7 @@ let _stryke_path_slash = require("@stryke/path/slash");
|
|
|
71
58
|
let _stryke_type_checks_is_regexp = require("@stryke/type-checks/is-regexp");
|
|
72
59
|
let node_buffer = require("node:buffer");
|
|
73
60
|
let node_url = require("node:url");
|
|
74
|
-
let _powerlines_core_lib_logger = require("@powerlines/core/lib/logger");
|
|
75
|
-
let _powerlines_core_lib_utilities_source_file = require("@powerlines/core/lib/utilities/source-file");
|
|
76
|
-
let unplugin = require("unplugin");
|
|
77
|
-
|
|
78
|
-
//#region package.json
|
|
79
|
-
var name = "powerlines";
|
|
80
|
-
var version = "0.42.26";
|
|
81
61
|
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/_internal/helpers/generate-types.ts
|
|
84
|
-
const getModuleCommentBlockRegex = (moduleId) => new RegExp(`\\/\\*\\*(?s:.)*?@module\\s+${moduleId}(?s:.)*?\\*\\/\\s+`);
|
|
85
|
-
/**
|
|
86
|
-
* Formats the generated TypeScript types source code.
|
|
87
|
-
*
|
|
88
|
-
* @param code - The generated TypeScript code.
|
|
89
|
-
* @returns The formatted TypeScript code.
|
|
90
|
-
*/
|
|
91
|
-
function formatTypes(code) {
|
|
92
|
-
return code.replace(/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g, "").replaceAll("#private;", "").replace(/__Ω/g, "");
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Emits TypeScript declaration types for the provided files using the given TypeScript configuration.
|
|
96
|
-
*
|
|
97
|
-
* @param context - The context containing options and environment paths.
|
|
98
|
-
* @param files - The list of files to generate types for.
|
|
99
|
-
* @returns A promise that resolves to the generated TypeScript declaration types.
|
|
100
|
-
*/
|
|
101
|
-
async function emitBuiltinTypes(context, files) {
|
|
102
|
-
if (files.length === 0) {
|
|
103
|
-
context.debug("No files provided for TypeScript types generation. Typescript compilation for built-in modules will be skipped.");
|
|
104
|
-
return "";
|
|
105
|
-
}
|
|
106
|
-
context.debug(`Running the TypeScript compiler for ${files.length} generated built-in module files.`);
|
|
107
|
-
const program = require_tsconfig.createProgram(context, {
|
|
108
|
-
skipAddingFilesFromTsConfig: true,
|
|
109
|
-
compilerOptions: {
|
|
110
|
-
declaration: true,
|
|
111
|
-
declarationMap: false,
|
|
112
|
-
emitDeclarationOnly: true,
|
|
113
|
-
sourceMap: false,
|
|
114
|
-
outDir: (0, _stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot),
|
|
115
|
-
composite: false,
|
|
116
|
-
incremental: false,
|
|
117
|
-
tsBuildInfoFile: void 0
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
program.addSourceFilesAtPaths(files);
|
|
121
|
-
const result = program.emitToMemory({ emitOnlyDtsFiles: true });
|
|
122
|
-
const diagnostics = result.getDiagnostics();
|
|
123
|
-
if (diagnostics && diagnostics.length > 0) if (diagnostics.some((d) => d.getCategory() === ts_morph.DiagnosticCategory.Error)) throw new Error(`The Typescript emit process failed while generating built-in types: \n ${diagnostics.filter((d) => d.getCategory() === ts_morph.DiagnosticCategory.Error).map((d) => `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : ""} ${String(d.getMessageText())} (at ${d.getStart()}:${d.getLength()})`).join("\n")}`);
|
|
124
|
-
else if (diagnostics.some((d) => d.getCategory() === ts_morph.DiagnosticCategory.Warning)) context.warn(`The Typescript emit process completed with warnings while generating built-in types: \n ${diagnostics.filter((d) => d.getCategory() === ts_morph.DiagnosticCategory.Warning).map((d) => `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : ""} ${String(d.getMessageText())} (at ${d.getStart()}:${d.getLength()})`).join("\n")}`);
|
|
125
|
-
else context.debug(`The Typescript emit process completed with diagnostic messages while generating built-in types: \n ${diagnostics.map((d) => `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : ""} ${String(d.getMessageText())} (at ${d.getStart()}:${d.getLength()})`).join("\n")}`);
|
|
126
|
-
const emittedFiles = result.getFiles();
|
|
127
|
-
context.debug(`The TypeScript compiler emitted ${emittedFiles.length} files for built-in types.`);
|
|
128
|
-
let builtinModules = "";
|
|
129
|
-
for (const emittedFile of emittedFiles) {
|
|
130
|
-
context.trace(`Processing emitted type declaration file: ${emittedFile.filePath}`);
|
|
131
|
-
const filePath = (0, _stryke_path_append.appendPath)(emittedFile.filePath, context.workspaceConfig.workspaceRoot);
|
|
132
|
-
if (!filePath.endsWith(".map") && (0, _stryke_path_file_path_fns.findFileName)(filePath) !== "tsconfig.tsbuildinfo" && (0, _stryke_path_is_parent_path.isParentPath)(filePath, context.builtinsPath)) {
|
|
133
|
-
const moduleId = `${context.config.framework}:${(0, _stryke_path_replace.replaceExtension)((0, _stryke_path_replace.replacePath)(filePath, context.builtinsPath), "", { fullExtension: true })}`;
|
|
134
|
-
const moduleComment = emittedFile.text.match(getModuleCommentBlockRegex(moduleId))?.find((comment) => (0, _stryke_type_checks_is_set_string.isSetString)(comment?.trim()));
|
|
135
|
-
builtinModules += `${moduleComment ? `\n${moduleComment.trim()}` : ""}
|
|
136
|
-
declare module "${moduleId}" {
|
|
137
|
-
${emittedFile.text.replace(moduleComment ?? "", "").trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
|
|
138
|
-
}
|
|
139
|
-
`;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
builtinModules = formatTypes(builtinModules);
|
|
143
|
-
context.debug(`A TypeScript declaration file (size: ${(0, _stryke_string_format_pretty_bytes.prettyBytes)(new Blob((0, _stryke_convert_to_array.toArray)(builtinModules)).size)}) emitted for the built-in modules types.`);
|
|
144
|
-
return builtinModules;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
//#endregion
|
|
148
62
|
//#region src/_internal/helpers/hooks.ts
|
|
149
63
|
const mergeResultObjects = (0, defu.createDefu)((obj, key, value) => {
|
|
150
64
|
if ((0, _stryke_type_checks_is_string.isString)(obj[key]) && (0, _stryke_type_checks_is_string.isString)(value)) {
|
|
@@ -209,7 +123,7 @@ async function callHook(context, key, options, ...args) {
|
|
|
209
123
|
if (results.length > 0 && sequenceArgs.length > 0) sequenceArgs[0] = (0, _stryke_type_checks_is_function.isFunction)(options.asNextParam) ? await Promise.resolve(options.asNextParam(results[0])) : results[0];
|
|
210
124
|
const result = await Promise.resolve(invokeHook(hook, [...sequenceArgs]));
|
|
211
125
|
if (result) if (options.result === "last") results = [result];
|
|
212
|
-
else if (options.result === "merge" && options.merge) results = [results.length > 0 && results[0] ? options.merge(result, results[0]) : result];
|
|
126
|
+
else if (options.result === "merge" && options.merge) results = [results.length > 0 && results[0] ? await Promise.resolve(options.merge(result, results[0])) : result];
|
|
213
127
|
else results = mergeResults(result, results);
|
|
214
128
|
}
|
|
215
129
|
}
|
|
@@ -221,53 +135,38 @@ async function callHook(context, key, options, ...args) {
|
|
|
221
135
|
}
|
|
222
136
|
}
|
|
223
137
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
throw new Error(`An error occurred while installing the package "${packageName}"`);
|
|
138
|
+
function extractHooks(context, hooks, plugin, key, parentKey) {
|
|
139
|
+
const combinedKey = parentKey ? `${parentKey}:${key}` : key;
|
|
140
|
+
const pluginField = (0, _stryke_helpers_get_field.getField)(plugin, combinedKey.replace(/:/g, "."));
|
|
141
|
+
if ((0, require_plugin_utils.plugin_utils_exports.isPluginHookField)(combinedKey) && (0, require_plugin_utils.plugin_utils_exports.isPluginHook)(pluginField)) {
|
|
142
|
+
const pluginHook = pluginField;
|
|
143
|
+
if (!(0, require_plugin_utils.plugin_utils_exports.isPluginHook)(pluginHook)) return hooks;
|
|
144
|
+
hooks[combinedKey] ??= {
|
|
145
|
+
preEnforced: [],
|
|
146
|
+
preOrdered: [],
|
|
147
|
+
normal: [],
|
|
148
|
+
postEnforced: [],
|
|
149
|
+
postOrdered: []
|
|
150
|
+
};
|
|
151
|
+
if (plugin.enforce) {
|
|
152
|
+
const hookListOrder = `${plugin.enforce}Enforced`;
|
|
153
|
+
hooks[combinedKey][hookListOrder] ??= [];
|
|
154
|
+
const bucket = hooks[combinedKey][hookListOrder];
|
|
155
|
+
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, plugin, pluginHook, bucket);
|
|
156
|
+
return hooks;
|
|
244
157
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
158
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(pluginHook) || !pluginHook.order) {
|
|
159
|
+
hooks[combinedKey].normal ??= [];
|
|
160
|
+
const bucket = hooks[combinedKey].normal;
|
|
161
|
+
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, plugin, pluginHook, bucket);
|
|
162
|
+
return hooks;
|
|
250
163
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
* Install missing project dependencies.
|
|
258
|
-
*
|
|
259
|
-
* @param context - The build context.
|
|
260
|
-
*/
|
|
261
|
-
async function installDependencies(context) {
|
|
262
|
-
context.debug(`Checking and installing missing project dependencies.`);
|
|
263
|
-
context.dependencies ??= {};
|
|
264
|
-
context.devDependencies ??= {};
|
|
265
|
-
if (Object.keys(context.dependencies).length === 0 && Object.keys(context.devDependencies).length === 0) {
|
|
266
|
-
context.debug(`No dependencies or devDependencies to install. Skipping installation step.`);
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
context.debug(`The following packages are required: \nDependencies: \n${Object.entries(context.dependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}\n\nDevDependencies: \n${Object.entries(context.devDependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}`);
|
|
270
|
-
await Promise.all([Promise.all(Object.entries(context.dependencies).map(async ([name, version]) => installPackage(context, `${(0, _stryke_string_format_package.getPackageName)(name)}@${String(version)}`, false))), Promise.all(Object.entries(context.devDependencies).map(async ([name, version]) => installPackage(context, `${(0, _stryke_string_format_package.getPackageName)(name)}@${String(version)}`, true)))]);
|
|
164
|
+
const hookListOrder = `${pluginHook.order}Ordered`;
|
|
165
|
+
hooks[combinedKey][hookListOrder] ??= [];
|
|
166
|
+
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, plugin, pluginHook, hooks[combinedKey][hookListOrder]);
|
|
167
|
+
return hooks;
|
|
168
|
+
} else if ((0, _stryke_type_checks_is_set_object.isSetObject)(pluginField)) return Object.keys(pluginField).map((pluginKey) => extractHooks(context, hooks, plugin, pluginKey, combinedKey)).reduce((ret, current) => (0, defu.defu)(ret, current), hooks);
|
|
169
|
+
return hooks;
|
|
271
170
|
}
|
|
272
171
|
|
|
273
172
|
//#endregion
|
|
@@ -298,88 +197,6 @@ async function writeMetaFile(context) {
|
|
|
298
197
|
await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
|
|
299
198
|
}
|
|
300
199
|
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/_internal/helpers/resolve-tsconfig.ts
|
|
303
|
-
function getTsconfigDtsPath(context) {
|
|
304
|
-
return (0, _stryke_path_join_paths.joinPaths)((0, _stryke_path_file_path_fns.relativePath)((0, _stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.root), (0, _stryke_path_file_path_fns.findFilePath)(context.typesPath)), (0, _stryke_path_file_path_fns.findFileName)(context.typesPath));
|
|
305
|
-
}
|
|
306
|
-
async function resolveTsconfigChanges(context) {
|
|
307
|
-
const tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig, context.config.tsconfigRaw);
|
|
308
|
-
const tsconfigJson = await (0, _stryke_fs_json.readJsonFile)(require_tsconfig.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig));
|
|
309
|
-
tsconfigJson.compilerOptions ??= {};
|
|
310
|
-
if (context.config.output.dts !== false) {
|
|
311
|
-
const dtsRelativePath = getTsconfigDtsPath(context);
|
|
312
|
-
if (!tsconfigJson.include?.some((filePattern) => require_tsconfig.isIncludeMatchFound(filePattern, [context.typesPath, dtsRelativePath]))) {
|
|
313
|
-
tsconfigJson.include ??= [];
|
|
314
|
-
tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
if (!tsconfig.options.lib?.some((lib) => [
|
|
318
|
-
"lib.esnext.d.ts",
|
|
319
|
-
"lib.es2021.d.ts",
|
|
320
|
-
"lib.es2022.d.ts",
|
|
321
|
-
"lib.es2023.d.ts"
|
|
322
|
-
].includes(lib.toLowerCase()))) {
|
|
323
|
-
tsconfigJson.compilerOptions.lib ??= [];
|
|
324
|
-
tsconfigJson.compilerOptions.lib.push("esnext");
|
|
325
|
-
}
|
|
326
|
-
if (tsconfig.options.esModuleInterop !== true) tsconfigJson.compilerOptions.esModuleInterop = true;
|
|
327
|
-
if (tsconfig.options.isolatedModules !== true) tsconfigJson.compilerOptions.isolatedModules = true;
|
|
328
|
-
if (context.config.platform === "node") {
|
|
329
|
-
if (!tsconfig.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
|
|
330
|
-
tsconfigJson.compilerOptions.types ??= [];
|
|
331
|
-
tsconfigJson.compilerOptions.types.push("node");
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return tsconfigJson;
|
|
335
|
-
}
|
|
336
|
-
async function initializeTsconfig(context) {
|
|
337
|
-
context.debug("Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
|
|
338
|
-
if (!(0, _stryke_fs_package_fns.isPackageExists)("typescript")) throw new Error("The TypeScript package is not installed. Please install the package using the command: \"npm install typescript --save-dev\"");
|
|
339
|
-
const tsconfigFilePath = require_tsconfig.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
|
|
340
|
-
context.tsconfig.originalTsconfigJson = await (0, _stryke_fs_json.readJsonFile)(tsconfigFilePath);
|
|
341
|
-
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
342
|
-
context.debug("Writing updated TypeScript configuration (tsconfig.json) file to disk.");
|
|
343
|
-
await context.fs.write(tsconfigFilePath, _stryke_json_storm_json.StormJSON.stringify(context.tsconfig.tsconfigJson));
|
|
344
|
-
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
|
|
345
|
-
}
|
|
346
|
-
async function resolveTsconfig(context) {
|
|
347
|
-
const updateTsconfigJson = await (0, _stryke_fs_json.readJsonFile)(context.tsconfig.tsconfigFilePath);
|
|
348
|
-
if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) delete updateTsconfigJson.compilerOptions.types;
|
|
349
|
-
const result = (0, _donedeal0_superdiff.getObjectDiff)(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
|
|
350
|
-
ignoreArrayOrder: true,
|
|
351
|
-
showOnly: {
|
|
352
|
-
statuses: [
|
|
353
|
-
"added",
|
|
354
|
-
"deleted",
|
|
355
|
-
"updated"
|
|
356
|
-
],
|
|
357
|
-
granularity: "deep"
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
const changes = [];
|
|
361
|
-
const getChanges = (difference, property) => {
|
|
362
|
-
if (difference.status === "added" || difference.status === "deleted" || difference.status === "updated") if (difference.diff) for (const diff of difference.diff) getChanges(diff, property ? `${property}.${difference.property}` : difference.property);
|
|
363
|
-
else changes.push({
|
|
364
|
-
field: property ? `${property}.${difference.property}` : difference.property,
|
|
365
|
-
status: difference.status,
|
|
366
|
-
previous: difference.status === "added" ? "---" : _stryke_json_storm_json.StormJSON.stringify(difference.previousValue),
|
|
367
|
-
current: difference.status === "deleted" ? "---" : _stryke_json_storm_json.StormJSON.stringify(difference.currentValue)
|
|
368
|
-
});
|
|
369
|
-
};
|
|
370
|
-
for (const diff of result.diff) getChanges(diff);
|
|
371
|
-
if (changes.length > 0) context.warn(`Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
|
|
372
|
-
|
|
373
|
-
${changes.map((change, i) => `${chalk.default.bold.whiteBright(`${i + 1}. ${(0, _stryke_string_format_title_case.titleCase)(change.status)} the ${change.field} field: `)}
|
|
374
|
-
${chalk.default.red(` - Previous: ${change.previous} `)}
|
|
375
|
-
${chalk.default.green(` - Updated: ${change.current} `)}
|
|
376
|
-
`).join("\n")}
|
|
377
|
-
`);
|
|
378
|
-
await context.fs.write(context.tsconfig.tsconfigFilePath, _stryke_json_storm_json.StormJSON.stringify(updateTsconfigJson));
|
|
379
|
-
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
|
|
380
|
-
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
381
|
-
}
|
|
382
|
-
|
|
383
200
|
//#endregion
|
|
384
201
|
//#region src/_internal/helpers/environment.ts
|
|
385
202
|
function createEnvironment(name, userConfig) {
|
|
@@ -1202,7 +1019,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1202
1019
|
if ((0, _stryke_type_checks_is_set.isSet)(resolved)) throw new Error(`Resolved path is not a string: ${String(resolved)}`);
|
|
1203
1020
|
return false;
|
|
1204
1021
|
}
|
|
1205
|
-
return this.#getStorage(resolved)?.adapter?.preset === "virtual";
|
|
1022
|
+
return this.#getStorage(resolved)?.adapter?.preset === "virtual" || resolved.startsWith(`${this.#context.config.framework}:`) || path.startsWith(`${this.#context.config.framework}:`);
|
|
1206
1023
|
}
|
|
1207
1024
|
/**
|
|
1208
1025
|
* Checks if a path is a directory in the virtual file system (VFS).
|
|
@@ -1282,7 +1099,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1282
1099
|
* @returns `true` if the file is virtual, otherwise `false`.
|
|
1283
1100
|
*/
|
|
1284
1101
|
isResolvableId(path, importer, options) {
|
|
1285
|
-
return path.startsWith(`${this.#context.config.framework}:`) || this.isVirtual(path, importer, options);
|
|
1102
|
+
return path.startsWith(`${this.#context.config.framework}:`) || this.isVirtual(path, importer, options) || this.isAlias(path) || this.isTsconfigPath(path);
|
|
1286
1103
|
}
|
|
1287
1104
|
/**
|
|
1288
1105
|
* Lists files in a given path.
|
|
@@ -1614,6 +1431,35 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1614
1431
|
return path;
|
|
1615
1432
|
}
|
|
1616
1433
|
/**
|
|
1434
|
+
* Checks if a given module ID is an alias.
|
|
1435
|
+
*
|
|
1436
|
+
* @remarks
|
|
1437
|
+
* This function can be used to determine if a module ID matches any configured aliases.
|
|
1438
|
+
*
|
|
1439
|
+
* @param id - The module ID to check.
|
|
1440
|
+
* @returns A boolean indicating whether the module ID is an alias.
|
|
1441
|
+
*/
|
|
1442
|
+
isAlias(id) {
|
|
1443
|
+
const path = id;
|
|
1444
|
+
if (this.#context.config.resolve.alias) {
|
|
1445
|
+
if (Array.isArray(this.#context.config.resolve.alias) && this.#context.config.resolve.alias.length > 0) return this.#context.config.resolve.alias.filter((alias) => (0, _stryke_type_checks_is_set_string.isSetString)(alias.find) && (alias.find === path || path.startsWith(`${alias.find}/`)) || (0, _stryke_type_checks_is_regexp.isRegExp)(alias.find) && alias.find.test(path)).length > 0;
|
|
1446
|
+
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(this.#context.config.resolve.alias)) return Object.keys(this.#context.config.resolve.alias).filter((key) => key === path || path.startsWith(`${key}/`)).length > 0;
|
|
1447
|
+
}
|
|
1448
|
+
return false;
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Checks if a given module ID is a tsconfig path.
|
|
1452
|
+
*
|
|
1453
|
+
* @remarks
|
|
1454
|
+
* This function can be used to determine if a module ID matches any configured tsconfig paths.
|
|
1455
|
+
*
|
|
1456
|
+
* @param id - The module ID to check.
|
|
1457
|
+
* @returns A boolean indicating whether the module ID is a tsconfig path.
|
|
1458
|
+
*/
|
|
1459
|
+
isTsconfigPath(id) {
|
|
1460
|
+
return !!(this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).length > 0 && (0, bundle_require.match)(id, this.#context.resolvePatterns));
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1617
1463
|
* A helper function to resolve modules in the virtual file system (VFS).
|
|
1618
1464
|
*
|
|
1619
1465
|
* @remarks
|
|
@@ -1826,7 +1672,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
1826
1672
|
*/
|
|
1827
1673
|
resolver;
|
|
1828
1674
|
/**
|
|
1829
|
-
* The resolved
|
|
1675
|
+
* The resolved tsconfig file paths for the project
|
|
1830
1676
|
*/
|
|
1831
1677
|
resolvePatterns = [];
|
|
1832
1678
|
/**
|
|
@@ -2201,7 +2047,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2201
2047
|
extensions: this.config.resolve.extensions
|
|
2202
2048
|
}, options));
|
|
2203
2049
|
if (!result) return;
|
|
2204
|
-
const external = Boolean(!(0, bundle_require.match)(moduleId, this.config.resolve.noExternal) && ((0, bundle_require.match)(moduleId, this.config.resolve.external) || moduleId.startsWith("node:") || (!this.fs.
|
|
2050
|
+
const external = Boolean(!(0, bundle_require.match)(moduleId, this.config.resolve.noExternal) && ((0, bundle_require.match)(moduleId, this.config.resolve.external) || moduleId.startsWith("node:") || (!this.fs.isVirtual(moduleId, importer, options) || this.fs.isVirtual(moduleId, importer, options) && this.config.projectType !== "application") && this.config.resolve.skipNodeModulesBundle && !/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(moduleId)));
|
|
2205
2051
|
return {
|
|
2206
2052
|
id: result,
|
|
2207
2053
|
external,
|
|
@@ -2700,96 +2546,6 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2700
2546
|
}
|
|
2701
2547
|
};
|
|
2702
2548
|
|
|
2703
|
-
//#endregion
|
|
2704
|
-
//#region src/unplugin.ts
|
|
2705
|
-
var unplugin_exports = /* @__PURE__ */ require_chunk.__exportAll({ createUnpluginFactory: () => createUnpluginFactory });
|
|
2706
|
-
require_chunk.__reExport(unplugin_exports, require("@powerlines/core/lib/unplugin"));
|
|
2707
|
-
/**
|
|
2708
|
-
* Creates a Powerlines unplugin factory that generates a plugin instance.
|
|
2709
|
-
*
|
|
2710
|
-
* @param variant - The build variant for which to create the unplugin.
|
|
2711
|
-
* @param decorate - An optional function to decorate the unplugin options.
|
|
2712
|
-
* @returns The unplugin factory that generates a plugin instance.
|
|
2713
|
-
*/
|
|
2714
|
-
function createUnpluginFactory(variant, decorate) {
|
|
2715
|
-
return (config, meta) => {
|
|
2716
|
-
const log = (0, _powerlines_core_lib_logger.createLog)("unplugin", config);
|
|
2717
|
-
log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Initializing Unplugin");
|
|
2718
|
-
try {
|
|
2719
|
-
const userConfig = {
|
|
2720
|
-
...config,
|
|
2721
|
-
variant,
|
|
2722
|
-
unplugin: meta
|
|
2723
|
-
};
|
|
2724
|
-
let api;
|
|
2725
|
-
async function buildStart() {
|
|
2726
|
-
log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
|
|
2727
|
-
api = await PowerlinesAPI.from((0, _stryke_fs_get_workspace_root.getWorkspaceRoot)(process.cwd()), userConfig);
|
|
2728
|
-
(0, unplugin.setParseImpl)(api.context.parse);
|
|
2729
|
-
log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Preparing build artifacts for the Powerlines project...");
|
|
2730
|
-
await api.prepare({ command: "build" });
|
|
2731
|
-
}
|
|
2732
|
-
async function resolveId(id, importer, options = { isEntry: false }) {
|
|
2733
|
-
return api.context.resolve(id, importer, options);
|
|
2734
|
-
}
|
|
2735
|
-
async function load(id) {
|
|
2736
|
-
const environment = await api.context.getEnvironment();
|
|
2737
|
-
let result = await api.callHook("load", {
|
|
2738
|
-
environment,
|
|
2739
|
-
order: "pre"
|
|
2740
|
-
}, id);
|
|
2741
|
-
if (result) return result;
|
|
2742
|
-
result = await api.callHook("load", {
|
|
2743
|
-
environment,
|
|
2744
|
-
order: "normal"
|
|
2745
|
-
}, id);
|
|
2746
|
-
if (result) return result;
|
|
2747
|
-
result = await environment.load(id);
|
|
2748
|
-
if (result) return result;
|
|
2749
|
-
return api.callHook("load", {
|
|
2750
|
-
environment,
|
|
2751
|
-
order: "post"
|
|
2752
|
-
}, id);
|
|
2753
|
-
}
|
|
2754
|
-
async function transform(code, id) {
|
|
2755
|
-
return api.callHook("transform", {
|
|
2756
|
-
environment: await api.context.getEnvironment(),
|
|
2757
|
-
result: "merge",
|
|
2758
|
-
asNextParam: (previousResult) => (0, _powerlines_core_lib_utilities_source_file.getString)(previousResult)
|
|
2759
|
-
}, (0, _powerlines_core_lib_utilities_source_file.getString)(code), id);
|
|
2760
|
-
}
|
|
2761
|
-
async function writeBundle() {
|
|
2762
|
-
log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
|
|
2763
|
-
await api.callHook("writeBundle", { environment: await api.context.getEnvironment() });
|
|
2764
|
-
}
|
|
2765
|
-
const options = {
|
|
2766
|
-
name: "powerlines",
|
|
2767
|
-
api,
|
|
2768
|
-
resolveId: {
|
|
2769
|
-
filter: { id: { include: [/.*/] } },
|
|
2770
|
-
handler: resolveId
|
|
2771
|
-
},
|
|
2772
|
-
load: {
|
|
2773
|
-
filter: { id: { include: [/.*/, /^storm:/] } },
|
|
2774
|
-
handler: load
|
|
2775
|
-
},
|
|
2776
|
-
transform,
|
|
2777
|
-
buildStart,
|
|
2778
|
-
writeBundle
|
|
2779
|
-
};
|
|
2780
|
-
const result = decorate ? decorate(api, options) : options;
|
|
2781
|
-
log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Unplugin initialized successfully.");
|
|
2782
|
-
return {
|
|
2783
|
-
api,
|
|
2784
|
-
...result
|
|
2785
|
-
};
|
|
2786
|
-
} catch (error) {
|
|
2787
|
-
log(_storm_software_config_tools_types.LogLevelLabel.FATAL, error?.message);
|
|
2788
|
-
throw error;
|
|
2789
|
-
}
|
|
2790
|
-
};
|
|
2791
|
-
}
|
|
2792
|
-
|
|
2793
2549
|
//#endregion
|
|
2794
2550
|
//#region src/context/plugin-context.ts
|
|
2795
2551
|
/**
|
|
@@ -2930,129 +2686,38 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
2930
2686
|
plugin: resolvedPlugin,
|
|
2931
2687
|
context
|
|
2932
2688
|
});
|
|
2933
|
-
this.#hooks = Object.keys(resolvedPlugin).filter((key) => !require_constants.constants_exports.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) =>
|
|
2934
|
-
const hook = key;
|
|
2935
|
-
if ((0, require_plugin_utils.plugin_utils_exports.isPluginHookField)(hook)) {
|
|
2936
|
-
const pluginHook = resolvedPlugin[hook];
|
|
2937
|
-
if (!(0, require_plugin_utils.plugin_utils_exports.isPluginHook)(pluginHook)) return ret;
|
|
2938
|
-
ret[hook] ??= {
|
|
2939
|
-
preEnforced: [],
|
|
2940
|
-
preOrdered: [],
|
|
2941
|
-
normal: [],
|
|
2942
|
-
postEnforced: [],
|
|
2943
|
-
postOrdered: []
|
|
2944
|
-
};
|
|
2945
|
-
if (resolvedPlugin.enforce) {
|
|
2946
|
-
const hookListOrder = `${resolvedPlugin.enforce}Enforced`;
|
|
2947
|
-
ret[hook][hookListOrder] ??= [];
|
|
2948
|
-
const bucket = ret[hook][hookListOrder];
|
|
2949
|
-
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, bucket);
|
|
2950
|
-
return ret;
|
|
2951
|
-
}
|
|
2952
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(pluginHook) || !pluginHook.order) {
|
|
2953
|
-
ret[hook].normal ??= [];
|
|
2954
|
-
const bucket = ret[hook].normal;
|
|
2955
|
-
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, bucket);
|
|
2956
|
-
return ret;
|
|
2957
|
-
}
|
|
2958
|
-
const hookListOrder = `${pluginHook.order}Ordered`;
|
|
2959
|
-
ret[hook][hookListOrder] ??= [];
|
|
2960
|
-
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, ret[hook][hookListOrder]);
|
|
2961
|
-
return ret;
|
|
2962
|
-
} else if ((0, require_plugin_utils.plugin_utils_exports.isUnpluginHookField)(hook)) {
|
|
2963
|
-
const unpluginPlugin = resolvedPlugin[hook];
|
|
2964
|
-
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(unpluginPlugin)) return ret;
|
|
2965
|
-
for (const field of Object.keys(unpluginPlugin)) {
|
|
2966
|
-
const variantField = field;
|
|
2967
|
-
const pluginHook = unpluginPlugin[variantField];
|
|
2968
|
-
if (!(0, require_plugin_utils.plugin_utils_exports.isPluginHook)(pluginHook)) continue;
|
|
2969
|
-
ret[hook] ??= {};
|
|
2970
|
-
ret[hook][variantField] ??= {
|
|
2971
|
-
preEnforced: [],
|
|
2972
|
-
preOrdered: [],
|
|
2973
|
-
normal: [],
|
|
2974
|
-
postEnforced: [],
|
|
2975
|
-
postOrdered: []
|
|
2976
|
-
};
|
|
2977
|
-
if (resolvedPlugin.enforce) {
|
|
2978
|
-
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${resolvedPlugin.enforce}Enforced`]);
|
|
2979
|
-
return ret;
|
|
2980
|
-
}
|
|
2981
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(pluginHook) || !pluginHook.order) {
|
|
2982
|
-
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, ret[hook][variantField].normal);
|
|
2983
|
-
return ret;
|
|
2984
|
-
}
|
|
2985
|
-
(0, require_plugin_utils.plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${pluginHook.order}Ordered`]);
|
|
2986
|
-
}
|
|
2987
|
-
} else this.warn(`Unknown plugin hook field: ${String(hook)}`);
|
|
2988
|
-
return ret;
|
|
2989
|
-
}, this.hooks);
|
|
2689
|
+
this.#hooks = Object.keys(resolvedPlugin).filter((key) => !require_constants.constants_exports.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => extractHooks(context, ret, resolvedPlugin, key), this.hooks);
|
|
2990
2690
|
}
|
|
2991
2691
|
/**
|
|
2992
2692
|
* Retrieves the hook handlers for a specific hook name
|
|
2993
2693
|
*/
|
|
2994
2694
|
selectHooks(key, options) {
|
|
2995
2695
|
const result = [];
|
|
2996
|
-
if ((0, require_plugin_utils.plugin_utils_exports.
|
|
2997
|
-
const
|
|
2998
|
-
if (
|
|
2999
|
-
const
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
result.push(...mapHooksToResult(fieldHooks.postEnforced ?? []));
|
|
3020
|
-
} else result.push(...mapHooksToResult(fieldHooks.normal ?? []));
|
|
3021
|
-
} else {
|
|
3022
|
-
result.push(...this.selectHooks(key, { order: "pre" }));
|
|
3023
|
-
result.push(...this.selectHooks(key, { order: "normal" }));
|
|
3024
|
-
result.push(...this.selectHooks(key, { order: "post" }));
|
|
3025
|
-
}
|
|
3026
|
-
}
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
} else if ((0, require_plugin_utils.plugin_utils_exports.isPluginHookField)(key)) {
|
|
3030
|
-
if (this.hooks[key]) {
|
|
3031
|
-
const fieldHooks = this.hooks[key];
|
|
3032
|
-
if (options?.order) {
|
|
3033
|
-
const mapHooksToResult = (hooksList) => hooksList.map((hook) => {
|
|
3034
|
-
const plugin = this.plugins.find((p) => p.plugin.name === hook.plugin.name);
|
|
3035
|
-
if (!plugin) throw new Error(`Could not find plugin context for plugin "${hook.plugin.name}".`);
|
|
3036
|
-
return {
|
|
3037
|
-
handler: hook.handler,
|
|
3038
|
-
plugin: hook.plugin,
|
|
3039
|
-
context: plugin.context
|
|
3040
|
-
};
|
|
3041
|
-
});
|
|
3042
|
-
if (options?.order === "pre") {
|
|
3043
|
-
result.push(...mapHooksToResult(fieldHooks.preOrdered ?? []));
|
|
3044
|
-
result.push(...mapHooksToResult(fieldHooks.preEnforced ?? []));
|
|
3045
|
-
} else if (options?.order === "post") {
|
|
3046
|
-
result.push(...mapHooksToResult(fieldHooks.postOrdered ?? []));
|
|
3047
|
-
result.push(...mapHooksToResult(fieldHooks.postEnforced ?? []));
|
|
3048
|
-
} else result.push(...mapHooksToResult(fieldHooks.normal ?? []));
|
|
3049
|
-
} else {
|
|
3050
|
-
result.push(...this.selectHooks(key, { order: "pre" }));
|
|
3051
|
-
result.push(...this.selectHooks(key, { order: "normal" }));
|
|
3052
|
-
result.push(...this.selectHooks(key, { order: "post" }));
|
|
3053
|
-
}
|
|
2696
|
+
if ((0, require_plugin_utils.plugin_utils_exports.isPluginHookField)(key) && this.hooks[key]) {
|
|
2697
|
+
const hooks = this.hooks[key];
|
|
2698
|
+
if (hooks) if (options?.order) {
|
|
2699
|
+
const mapHooksToResult = (hooksList) => hooksList.map((hook) => {
|
|
2700
|
+
const plugin = this.plugins.find((p) => p.plugin.name === hook.plugin.name);
|
|
2701
|
+
if (!plugin) throw new Error(`Could not find plugin context for plugin "${hook.plugin.name}".`);
|
|
2702
|
+
return {
|
|
2703
|
+
handler: hook.handler,
|
|
2704
|
+
plugin: hook.plugin,
|
|
2705
|
+
context: plugin.context
|
|
2706
|
+
};
|
|
2707
|
+
});
|
|
2708
|
+
if (options?.order === "pre") {
|
|
2709
|
+
result.push(...mapHooksToResult(hooks.preOrdered ?? []));
|
|
2710
|
+
result.push(...mapHooksToResult(hooks.preEnforced ?? []));
|
|
2711
|
+
} else if (options?.order === "post") {
|
|
2712
|
+
result.push(...mapHooksToResult(hooks.postOrdered ?? []));
|
|
2713
|
+
result.push(...mapHooksToResult(hooks.postEnforced ?? []));
|
|
2714
|
+
} else result.push(...mapHooksToResult(hooks.normal ?? []));
|
|
2715
|
+
} else {
|
|
2716
|
+
result.push(...this.selectHooks(key, { order: "pre" }));
|
|
2717
|
+
result.push(...this.selectHooks(key, { order: "normal" }));
|
|
2718
|
+
result.push(...this.selectHooks(key, { order: "post" }));
|
|
3054
2719
|
}
|
|
3055
|
-
}
|
|
2720
|
+
}
|
|
3056
2721
|
return result;
|
|
3057
2722
|
}
|
|
3058
2723
|
constructor(config, workspaceConfig) {
|
|
@@ -3252,626 +2917,6 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3252
2917
|
}
|
|
3253
2918
|
};
|
|
3254
2919
|
|
|
3255
|
-
//#endregion
|
|
3256
|
-
//#region src/api.ts
|
|
3257
|
-
/**
|
|
3258
|
-
* The Powerlines API class
|
|
3259
|
-
*
|
|
3260
|
-
* @remarks
|
|
3261
|
-
* This class is responsible for managing the Powerlines project lifecycle, including initialization, building, and finalization.
|
|
3262
|
-
*
|
|
3263
|
-
* @public
|
|
3264
|
-
*/
|
|
3265
|
-
var PowerlinesAPI = class PowerlinesAPI {
|
|
3266
|
-
/**
|
|
3267
|
-
* The Powerlines context
|
|
3268
|
-
*/
|
|
3269
|
-
#context;
|
|
3270
|
-
/**
|
|
3271
|
-
* The Powerlines context
|
|
3272
|
-
*/
|
|
3273
|
-
get context() {
|
|
3274
|
-
return this.#context;
|
|
3275
|
-
}
|
|
3276
|
-
/**
|
|
3277
|
-
* Create a new Powerlines API instance
|
|
3278
|
-
*
|
|
3279
|
-
* @param context - The Powerlines context
|
|
3280
|
-
*/
|
|
3281
|
-
constructor(context) {
|
|
3282
|
-
this.#context = context;
|
|
3283
|
-
}
|
|
3284
|
-
/**
|
|
3285
|
-
* Initialize a Powerlines API instance
|
|
3286
|
-
*
|
|
3287
|
-
* @param workspaceRoot - The directory of the underlying workspace the Powerlines project exists in
|
|
3288
|
-
* @param config - An object containing the configuration required to run Powerlines tasks.
|
|
3289
|
-
* @returns A new instance of the Powerlines API
|
|
3290
|
-
*/
|
|
3291
|
-
static async from(workspaceRoot, config) {
|
|
3292
|
-
const api = new PowerlinesAPI(await PowerlinesAPIContext.from(workspaceRoot, config));
|
|
3293
|
-
api.#context.$$internal = {
|
|
3294
|
-
api,
|
|
3295
|
-
addPlugin: api.#addPlugin.bind(api)
|
|
3296
|
-
};
|
|
3297
|
-
api.context.info(`🔌 The Powerlines Engine v${version} has started`);
|
|
3298
|
-
for (const plugin of api.context.config.plugins ?? []) await api.#addPlugin(plugin);
|
|
3299
|
-
if (api.context.plugins.length === 0) api.context.warn("No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
|
|
3300
|
-
const pluginConfig = await api.callHook("config", {
|
|
3301
|
-
environment: await api.context.getEnvironment(),
|
|
3302
|
-
sequential: true,
|
|
3303
|
-
result: "merge",
|
|
3304
|
-
merge: mergeConfigs
|
|
3305
|
-
});
|
|
3306
|
-
await api.context.withUserConfig(pluginConfig, { isHighPriority: false });
|
|
3307
|
-
return api;
|
|
3308
|
-
}
|
|
3309
|
-
/**
|
|
3310
|
-
* Generate the Powerlines typescript declaration file
|
|
3311
|
-
*
|
|
3312
|
-
* @remarks
|
|
3313
|
-
* 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.
|
|
3314
|
-
*
|
|
3315
|
-
* @param inlineConfig - The inline configuration for the types command
|
|
3316
|
-
*/
|
|
3317
|
-
async types(inlineConfig = { command: "types" }) {
|
|
3318
|
-
this.context.info(" 🏗️ Generating typescript declarations for the Powerlines project");
|
|
3319
|
-
this.context.debug(" Aggregating configuration options for the Powerlines project");
|
|
3320
|
-
inlineConfig.command ??= "types";
|
|
3321
|
-
await this.context.withInlineConfig(inlineConfig);
|
|
3322
|
-
await this.#executeEnvironments(async (context) => {
|
|
3323
|
-
context.debug(`Initializing the processing options for the Powerlines project.`);
|
|
3324
|
-
await this.callHook("configResolved", {
|
|
3325
|
-
environment: context,
|
|
3326
|
-
order: "pre"
|
|
3327
|
-
});
|
|
3328
|
-
await initializeTsconfig(context);
|
|
3329
|
-
await this.callHook("configResolved", {
|
|
3330
|
-
environment: context,
|
|
3331
|
-
order: "normal"
|
|
3332
|
-
});
|
|
3333
|
-
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")}` : ""}`);
|
|
3334
|
-
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.`);
|
|
3335
|
-
await resolveTsconfig(context);
|
|
3336
|
-
await installDependencies(context);
|
|
3337
|
-
await this.callHook("configResolved", {
|
|
3338
|
-
environment: context,
|
|
3339
|
-
order: "post"
|
|
3340
|
-
});
|
|
3341
|
-
context.trace(`Powerlines configuration has been resolved: \n\n${(0, _storm_software_config_tools_logger_console.formatLogMessage)({
|
|
3342
|
-
...context.config,
|
|
3343
|
-
userConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.userConfig) ? (0, _stryke_helpers_omit.omit)(context.config.userConfig, ["plugins"]) : void 0,
|
|
3344
|
-
inlineConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.inlineConfig) ? (0, _stryke_helpers_omit.omit)(context.config.inlineConfig, ["plugins"]) : void 0,
|
|
3345
|
-
plugins: context.plugins.map((plugin) => plugin.plugin.name)
|
|
3346
|
-
})}`);
|
|
3347
|
-
if (!context.fs.existsSync(context.cachePath)) await (0, _stryke_fs_helpers.createDirectory)(context.cachePath);
|
|
3348
|
-
if (!context.fs.existsSync(context.dataPath)) await (0, _stryke_fs_helpers.createDirectory)(context.dataPath);
|
|
3349
|
-
if (context.config.skipCache === true || context.persistedMeta?.checksum !== context.meta.checksum) context.debug(`Using previously prepared files as the meta checksum has not changed.`);
|
|
3350
|
-
else {
|
|
3351
|
-
context.info(`Running \`prepare\` command as the meta checksum has changed since the last run.`);
|
|
3352
|
-
await this.prepare((0, defu.default)({ output: { types: false } }, inlineConfig));
|
|
3353
|
-
}
|
|
3354
|
-
await this.#types(context);
|
|
3355
|
-
this.context.debug("Formatting files generated during the types step.");
|
|
3356
|
-
await (0, require_utils.utils_exports.format)(context, context.typesPath, await context.fs.read(context.typesPath) ?? "");
|
|
3357
|
-
await writeMetaFile(context);
|
|
3358
|
-
context.persistedMeta = context.meta;
|
|
3359
|
-
});
|
|
3360
|
-
this.context.debug("✔ Powerlines types generation has completed successfully");
|
|
3361
|
-
}
|
|
3362
|
-
/**
|
|
3363
|
-
* Prepare the Powerlines API
|
|
3364
|
-
*
|
|
3365
|
-
* @remarks
|
|
3366
|
-
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
3367
|
-
*
|
|
3368
|
-
* @param inlineConfig - The inline configuration for the prepare command
|
|
3369
|
-
*/
|
|
3370
|
-
async prepare(inlineConfig = { command: "prepare" }) {
|
|
3371
|
-
this.context.info(" 🏗️ Preparing the Powerlines project");
|
|
3372
|
-
this.context.debug(" Aggregating configuration options for the Powerlines project");
|
|
3373
|
-
inlineConfig.command ??= "prepare";
|
|
3374
|
-
await this.context.withInlineConfig(inlineConfig);
|
|
3375
|
-
await this.#executeEnvironments(async (context) => {
|
|
3376
|
-
context.debug(`Initializing the processing options for the Powerlines project.`);
|
|
3377
|
-
await this.callHook("configResolved", {
|
|
3378
|
-
environment: context,
|
|
3379
|
-
order: "pre"
|
|
3380
|
-
});
|
|
3381
|
-
await initializeTsconfig(context);
|
|
3382
|
-
await this.callHook("configResolved", {
|
|
3383
|
-
environment: context,
|
|
3384
|
-
order: "normal"
|
|
3385
|
-
});
|
|
3386
|
-
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")}` : ""}`);
|
|
3387
|
-
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.`);
|
|
3388
|
-
await resolveTsconfig(context);
|
|
3389
|
-
await installDependencies(context);
|
|
3390
|
-
await this.callHook("configResolved", {
|
|
3391
|
-
environment: context,
|
|
3392
|
-
order: "post"
|
|
3393
|
-
});
|
|
3394
|
-
context.trace(`Powerlines configuration has been resolved: \n\n${(0, _storm_software_config_tools_logger_console.formatLogMessage)({
|
|
3395
|
-
...context.config,
|
|
3396
|
-
userConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.userConfig) ? (0, _stryke_helpers_omit.omit)(context.config.userConfig, ["plugins"]) : void 0,
|
|
3397
|
-
inlineConfig: (0, _stryke_type_checks_is_set_object.isSetObject)(context.config.inlineConfig) ? (0, _stryke_helpers_omit.omit)(context.config.inlineConfig, ["plugins"]) : void 0,
|
|
3398
|
-
plugins: context.plugins.map((plugin) => plugin.plugin.name)
|
|
3399
|
-
})}`);
|
|
3400
|
-
if (!context.fs.existsSync(context.cachePath)) await (0, _stryke_fs_helpers.createDirectory)(context.cachePath);
|
|
3401
|
-
if (!context.fs.existsSync(context.dataPath)) await (0, _stryke_fs_helpers.createDirectory)(context.dataPath);
|
|
3402
|
-
await this.callHook("prepare", {
|
|
3403
|
-
environment: context,
|
|
3404
|
-
order: "pre"
|
|
3405
|
-
});
|
|
3406
|
-
await this.callHook("prepare", {
|
|
3407
|
-
environment: context,
|
|
3408
|
-
order: "normal"
|
|
3409
|
-
});
|
|
3410
|
-
await this.callHook("prepare", {
|
|
3411
|
-
environment: context,
|
|
3412
|
-
order: "post"
|
|
3413
|
-
});
|
|
3414
|
-
if (context.config.output.types !== false) await this.#types(context);
|
|
3415
|
-
this.context.debug("Formatting files generated during the prepare step.");
|
|
3416
|
-
await Promise.all([(0, require_utils.utils_exports.formatFolder)(context, context.builtinsPath), (0, require_utils.utils_exports.formatFolder)(context, context.entryPath)]);
|
|
3417
|
-
await writeMetaFile(context);
|
|
3418
|
-
context.persistedMeta = context.meta;
|
|
3419
|
-
});
|
|
3420
|
-
this.context.debug("✔ Powerlines preparation has completed successfully");
|
|
3421
|
-
}
|
|
3422
|
-
/**
|
|
3423
|
-
* Create a new Powerlines project
|
|
3424
|
-
*
|
|
3425
|
-
* @remarks
|
|
3426
|
-
* This method will create a new Powerlines project in the current directory.
|
|
3427
|
-
*
|
|
3428
|
-
* @param inlineConfig - The inline configuration for the new command
|
|
3429
|
-
* @returns A promise that resolves when the project has been created
|
|
3430
|
-
*/
|
|
3431
|
-
async new(inlineConfig) {
|
|
3432
|
-
this.context.info(" 🆕 Creating a new Powerlines project");
|
|
3433
|
-
inlineConfig.command ??= "new";
|
|
3434
|
-
await this.prepare(inlineConfig);
|
|
3435
|
-
await this.#executeEnvironments(async (context) => {
|
|
3436
|
-
context.debug("Initializing the processing options for the Powerlines project.");
|
|
3437
|
-
await this.callHook("new", {
|
|
3438
|
-
environment: context,
|
|
3439
|
-
order: "pre"
|
|
3440
|
-
});
|
|
3441
|
-
const files = await (0, _stryke_fs_list_files.listFiles)((0, _stryke_path_join_paths.joinPaths)(context.powerlinesPath, "files/common/**/*.hbs"));
|
|
3442
|
-
for (const file of files) {
|
|
3443
|
-
context.trace(`Adding template file to project: ${file}`);
|
|
3444
|
-
const template = handlebars.default.compile(file);
|
|
3445
|
-
await context.fs.write((0, _stryke_path_join_paths.joinPaths)(context.config.root, file.replace(".hbs", "")), template(context));
|
|
3446
|
-
}
|
|
3447
|
-
await this.callHook("new", {
|
|
3448
|
-
environment: context,
|
|
3449
|
-
order: "normal"
|
|
3450
|
-
});
|
|
3451
|
-
if (context.config.projectType === "application") {
|
|
3452
|
-
const files = await (0, _stryke_fs_list_files.listFiles)((0, _stryke_path_join_paths.joinPaths)(context.powerlinesPath, "files/application/**/*.hbs"));
|
|
3453
|
-
for (const file of files) {
|
|
3454
|
-
context.trace(`Adding application template file: ${file}`);
|
|
3455
|
-
const template = handlebars.default.compile(file);
|
|
3456
|
-
await context.fs.write((0, _stryke_path_join_paths.joinPaths)(context.config.root, file.replace(".hbs", "")), template(context));
|
|
3457
|
-
}
|
|
3458
|
-
} else {
|
|
3459
|
-
const files = await (0, _stryke_fs_list_files.listFiles)((0, _stryke_path_join_paths.joinPaths)(context.powerlinesPath, "files/library/**/*.hbs"));
|
|
3460
|
-
for (const file of files) {
|
|
3461
|
-
context.trace(`Adding library template file: ${file}`);
|
|
3462
|
-
const template = handlebars.default.compile(file);
|
|
3463
|
-
await context.fs.write((0, _stryke_path_join_paths.joinPaths)(context.config.root, file.replace(".hbs", "")), template(context));
|
|
3464
|
-
}
|
|
3465
|
-
}
|
|
3466
|
-
await this.callHook("new", {
|
|
3467
|
-
environment: context,
|
|
3468
|
-
order: "post"
|
|
3469
|
-
});
|
|
3470
|
-
});
|
|
3471
|
-
this.context.debug("✔ Powerlines new command completed successfully");
|
|
3472
|
-
}
|
|
3473
|
-
/**
|
|
3474
|
-
* Clean any previously prepared artifacts
|
|
3475
|
-
*
|
|
3476
|
-
* @remarks
|
|
3477
|
-
* This method will remove the previous Powerlines artifacts from the project.
|
|
3478
|
-
*
|
|
3479
|
-
* @param inlineConfig - The inline configuration for the clean command
|
|
3480
|
-
* @returns A promise that resolves when the clean command has completed
|
|
3481
|
-
*/
|
|
3482
|
-
async clean(inlineConfig = { command: "clean" }) {
|
|
3483
|
-
this.context.info(" 🧹 Cleaning the previous Powerlines artifacts");
|
|
3484
|
-
inlineConfig.command ??= "clean";
|
|
3485
|
-
await this.prepare(inlineConfig);
|
|
3486
|
-
await this.#executeEnvironments(async (context) => {
|
|
3487
|
-
context.debug("Cleaning the project's dist and artifacts directories.");
|
|
3488
|
-
await context.fs.remove((0, _stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.output.path));
|
|
3489
|
-
await context.fs.remove((0, _stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.root, context.config.output.artifactsPath));
|
|
3490
|
-
await this.callHook("clean", {
|
|
3491
|
-
environment: context,
|
|
3492
|
-
sequential: false
|
|
3493
|
-
});
|
|
3494
|
-
});
|
|
3495
|
-
this.context.debug("✔ Powerlines cleaning completed successfully");
|
|
3496
|
-
}
|
|
3497
|
-
/**
|
|
3498
|
-
* Lint the project
|
|
3499
|
-
*
|
|
3500
|
-
* @param inlineConfig - The inline configuration for the lint command
|
|
3501
|
-
* @returns A promise that resolves when the lint command has completed
|
|
3502
|
-
*/
|
|
3503
|
-
async lint(inlineConfig = { command: "lint" }) {
|
|
3504
|
-
this.context.info(" 📝 Linting the Powerlines project");
|
|
3505
|
-
inlineConfig.command ??= "lint";
|
|
3506
|
-
await this.prepare(inlineConfig);
|
|
3507
|
-
await this.#executeEnvironments(async (context) => {
|
|
3508
|
-
await this.callHook("lint", {
|
|
3509
|
-
environment: context,
|
|
3510
|
-
sequential: false
|
|
3511
|
-
});
|
|
3512
|
-
});
|
|
3513
|
-
this.context.debug("✔ Powerlines linting completed successfully");
|
|
3514
|
-
}
|
|
3515
|
-
/**
|
|
3516
|
-
* Build the project
|
|
3517
|
-
*
|
|
3518
|
-
* @remarks
|
|
3519
|
-
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
3520
|
-
*
|
|
3521
|
-
* @param inlineConfig - The inline configuration for the build command
|
|
3522
|
-
* @returns A promise that resolves when the build command has completed
|
|
3523
|
-
*/
|
|
3524
|
-
async build(inlineConfig = { command: "build" }) {
|
|
3525
|
-
this.context.info(" 📦 Building the Powerlines project");
|
|
3526
|
-
await this.context.generateChecksum();
|
|
3527
|
-
if (this.context.meta.checksum !== this.context.persistedMeta?.checksum || this.context.config.skipCache) {
|
|
3528
|
-
this.context.info(!this.context.persistedMeta?.checksum ? "No previous build cache found. Preparing the project for the initial build." : this.context.meta.checksum !== this.context.persistedMeta.checksum ? "The project has been modified since the last time `prepare` was ran. Re-preparing the project." : "The project is configured to skip cache. Re-preparing the project.");
|
|
3529
|
-
inlineConfig.command ??= "build";
|
|
3530
|
-
await this.prepare(inlineConfig);
|
|
3531
|
-
}
|
|
3532
|
-
if (this.context.config.singleBuild) await this.#handleBuild(await this.#context.toEnvironment());
|
|
3533
|
-
else await this.#executeEnvironments(async (context) => {
|
|
3534
|
-
await this.#handleBuild(context);
|
|
3535
|
-
});
|
|
3536
|
-
this.context.debug("✔ Powerlines build completed successfully");
|
|
3537
|
-
}
|
|
3538
|
-
/**
|
|
3539
|
-
* Prepare the documentation for the project
|
|
3540
|
-
*
|
|
3541
|
-
* @param inlineConfig - The inline configuration for the docs command
|
|
3542
|
-
* @returns A promise that resolves when the documentation generation has completed
|
|
3543
|
-
*/
|
|
3544
|
-
async docs(inlineConfig = { command: "docs" }) {
|
|
3545
|
-
this.context.info(" 📓 Generating documentation for the Powerlines project");
|
|
3546
|
-
inlineConfig.command ??= "docs";
|
|
3547
|
-
await this.prepare(inlineConfig);
|
|
3548
|
-
await this.#executeEnvironments(async (context) => {
|
|
3549
|
-
context.debug("Writing documentation for the Powerlines project artifacts.");
|
|
3550
|
-
inlineConfig.command ??= "docs";
|
|
3551
|
-
await this.prepare(inlineConfig);
|
|
3552
|
-
await this.#executeEnvironments(async (context) => {
|
|
3553
|
-
await this.callHook("docs", { environment: context });
|
|
3554
|
-
});
|
|
3555
|
-
});
|
|
3556
|
-
this.context.debug("✔ Powerlines documentation generation completed successfully");
|
|
3557
|
-
}
|
|
3558
|
-
/**
|
|
3559
|
-
* Deploy the project source code
|
|
3560
|
-
*
|
|
3561
|
-
* @remarks
|
|
3562
|
-
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
3563
|
-
*
|
|
3564
|
-
* @param inlineConfig - The inline configuration for the deploy command
|
|
3565
|
-
*/
|
|
3566
|
-
async deploy(inlineConfig = { command: "deploy" }) {
|
|
3567
|
-
this.context.info(" 🚀 Deploying the Powerlines project");
|
|
3568
|
-
inlineConfig.command ??= "deploy";
|
|
3569
|
-
await this.prepare(inlineConfig);
|
|
3570
|
-
await this.#executeEnvironments(async (context) => {
|
|
3571
|
-
await this.callHook("deploy", { environment: context });
|
|
3572
|
-
});
|
|
3573
|
-
this.context.debug("✔ Powerlines deploy completed successfully");
|
|
3574
|
-
}
|
|
3575
|
-
/**
|
|
3576
|
-
* Finalization process
|
|
3577
|
-
*
|
|
3578
|
-
* @remarks
|
|
3579
|
-
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
3580
|
-
*
|
|
3581
|
-
* @returns A promise that resolves when the finalization process has completed
|
|
3582
|
-
*/
|
|
3583
|
-
async finalize() {
|
|
3584
|
-
this.context.info(" 🏁 Powerlines finalization processes started");
|
|
3585
|
-
await this.#executeEnvironments(async (context) => {
|
|
3586
|
-
await this.callHook("finalize", { environment: context });
|
|
3587
|
-
await context.fs.dispose();
|
|
3588
|
-
if ((0, _stryke_fs_exists.existsSync)(context.cachePath) && !(await (0, _stryke_fs_list_files.listFiles)((0, _stryke_path_join_paths.joinPaths)(context.cachePath, "**/*")))?.length) await (0, _stryke_fs_helpers.removeDirectory)(context.cachePath);
|
|
3589
|
-
});
|
|
3590
|
-
this.context.debug("✔ Powerlines finalization completed successfully");
|
|
3591
|
-
}
|
|
3592
|
-
/**
|
|
3593
|
-
* Invokes the configured plugin hooks
|
|
3594
|
-
*
|
|
3595
|
-
* @remarks
|
|
3596
|
-
* By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
|
|
3597
|
-
*
|
|
3598
|
-
* @param hook - The hook to call
|
|
3599
|
-
* @param options - The options to provide to the hook
|
|
3600
|
-
* @param args - The arguments to pass to the hook
|
|
3601
|
-
* @returns The result of the hook call
|
|
3602
|
-
*/
|
|
3603
|
-
async callHook(hook, options, ...args) {
|
|
3604
|
-
return callHook((0, _stryke_type_checks_is_set_object.isSetObject)(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
|
|
3605
|
-
sequential: true,
|
|
3606
|
-
...options
|
|
3607
|
-
}, ...args);
|
|
3608
|
-
}
|
|
3609
|
-
/**
|
|
3610
|
-
* Dispose of the Powerlines API instance
|
|
3611
|
-
*
|
|
3612
|
-
* @remarks
|
|
3613
|
-
* This method will finalize the Powerlines API instance, cleaning up any resources used.
|
|
3614
|
-
*/
|
|
3615
|
-
async [Symbol.asyncDispose]() {
|
|
3616
|
-
await this.finalize();
|
|
3617
|
-
}
|
|
3618
|
-
async #handleBuild(context) {
|
|
3619
|
-
await this.callHook("build", {
|
|
3620
|
-
environment: context,
|
|
3621
|
-
order: "pre"
|
|
3622
|
-
});
|
|
3623
|
-
context.debug("Formatting the generated entry files before the build process starts.");
|
|
3624
|
-
await (0, require_utils.utils_exports.formatFolder)(context, context.entryPath);
|
|
3625
|
-
await this.callHook("build", {
|
|
3626
|
-
environment: context,
|
|
3627
|
-
order: "normal"
|
|
3628
|
-
});
|
|
3629
|
-
if (context.config.output.copy) {
|
|
3630
|
-
context.debug("Copying project's files from build output directory.");
|
|
3631
|
-
const destinationPath = (0, _stryke_path_is_parent_path.isParentPath)((0, _stryke_path_append.appendPath)(context.config.output.path, context.workspaceConfig.workspaceRoot), (0, _stryke_path_append.appendPath)(context.config.root, context.workspaceConfig.workspaceRoot)) ? (0, _stryke_path_join_paths.joinPaths)(context.config.output.copy.path, (0, _stryke_path_file_path_fns.relativePath)((0, _stryke_path_append.appendPath)(context.config.root, context.workspaceConfig.workspaceRoot), (0, _stryke_path_append.appendPath)(context.config.output.path, context.workspaceConfig.workspaceRoot))) : (0, _stryke_path_join_paths.joinPaths)(context.config.output.copy.path, "dist");
|
|
3632
|
-
const sourcePath = (0, _stryke_path_append.appendPath)(context.config.output.path, context.workspaceConfig.workspaceRoot);
|
|
3633
|
-
if ((0, _stryke_fs_exists.existsSync)(sourcePath) && sourcePath !== destinationPath) {
|
|
3634
|
-
context.debug(`Copying files from project's build output directory (${context.config.output.path}) to the project's copy/publish directory (${destinationPath}).`);
|
|
3635
|
-
await (0, _stryke_fs_copy_file.copyFiles)(sourcePath, destinationPath);
|
|
3636
|
-
} else context.warn(`The source path for the copy operation ${!(0, _stryke_fs_exists.existsSync)(sourcePath) ? "does not exist" : "is the same as the destination path"}. Source: ${sourcePath}, Destination: ${destinationPath}. Skipping copying of build output files.`);
|
|
3637
|
-
if (context.config.output.copy.assets && Array.isArray(context.config.output.copy.assets)) await Promise.all(context.config.output.copy.assets.map(async (asset) => {
|
|
3638
|
-
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(", ")})` : ""}`);
|
|
3639
|
-
await context.fs.copy(asset, asset.output);
|
|
3640
|
-
}));
|
|
3641
|
-
} else context.debug("No copy configuration found for the project output. Skipping the copying of build output files.");
|
|
3642
|
-
await this.callHook("build", {
|
|
3643
|
-
environment: context,
|
|
3644
|
-
order: "post"
|
|
3645
|
-
});
|
|
3646
|
-
}
|
|
3647
|
-
/**
|
|
3648
|
-
* Get the configured environments
|
|
3649
|
-
*
|
|
3650
|
-
* @returns The configured environments
|
|
3651
|
-
*/
|
|
3652
|
-
async #getEnvironments() {
|
|
3653
|
-
if (!this.context.config.environments || Object.keys(this.context.config.environments).length <= 1) {
|
|
3654
|
-
this.context.debug("No environments are configured for this Powerlines project. Using the default environment.");
|
|
3655
|
-
return [await this.context.getEnvironment()];
|
|
3656
|
-
}
|
|
3657
|
-
this.context.debug(`Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`);
|
|
3658
|
-
return (await Promise.all(Object.entries(this.context.config.environments).map(async ([name, config]) => {
|
|
3659
|
-
if (!await this.context.getEnvironmentSafe(name)) {
|
|
3660
|
-
const resolvedEnvironment = await this.callHook("configEnvironment", { environment: name }, name, config);
|
|
3661
|
-
if (resolvedEnvironment) this.context.environments[name] = await this.context.in(resolvedEnvironment);
|
|
3662
|
-
}
|
|
3663
|
-
return this.context.environments[name];
|
|
3664
|
-
}))).filter((context) => (0, _stryke_type_checks_is_set.isSet)(context));
|
|
3665
|
-
}
|
|
3666
|
-
/**
|
|
3667
|
-
* Execute a handler function for each environment
|
|
3668
|
-
*
|
|
3669
|
-
* @param handle - The handler function to execute for each environment
|
|
3670
|
-
*/
|
|
3671
|
-
async #executeEnvironments(handle) {
|
|
3672
|
-
await Promise.all((await this.#getEnvironments()).map(async (context) => {
|
|
3673
|
-
return Promise.resolve(handle(context));
|
|
3674
|
-
}));
|
|
3675
|
-
}
|
|
3676
|
-
/**
|
|
3677
|
-
* Add a Powerlines plugin used in the build process
|
|
3678
|
-
*
|
|
3679
|
-
* @param config - The import path of the plugin to add
|
|
3680
|
-
*/
|
|
3681
|
-
async #addPlugin(config) {
|
|
3682
|
-
if (config) {
|
|
3683
|
-
const result = await this.#initPlugin(config);
|
|
3684
|
-
if (!result) return;
|
|
3685
|
-
for (const plugin of result) {
|
|
3686
|
-
this.context.debug(`Successfully initialized the ${chalk.default.bold.cyanBright(plugin.name)} plugin`);
|
|
3687
|
-
await this.context.addPlugin(plugin);
|
|
3688
|
-
}
|
|
3689
|
-
}
|
|
3690
|
-
}
|
|
3691
|
-
/**
|
|
3692
|
-
* Initialize a Powerlines plugin
|
|
3693
|
-
*
|
|
3694
|
-
* @param config - The configuration for the plugin
|
|
3695
|
-
* @returns The initialized plugin instance, or null if the plugin was a duplicate
|
|
3696
|
-
* @throws Will throw an error if the plugin cannot be found or is invalid
|
|
3697
|
-
*/
|
|
3698
|
-
async #initPlugin(config) {
|
|
3699
|
-
let awaited = config;
|
|
3700
|
-
if ((0, _stryke_type_checks_is_promise.isPromiseLike)(config)) awaited = await Promise.resolve(config);
|
|
3701
|
-
if (!(0, require_plugin_utils.plugin_utils_exports.isPluginConfig)(awaited)) {
|
|
3702
|
-
const invalid = (0, require_plugin_utils.plugin_utils_exports.findInvalidPluginConfig)(awaited);
|
|
3703
|
-
throw new Error(`Invalid ${invalid && invalid.length > 1 ? "plugins" : "plugin"} specified in the configuration - ${invalid && invalid.length > 0 ? JSON.stringify(awaited) : invalid?.join("\n\n")} \n\nPlease ensure the value is one of the following: \n - an instance of \`Plugin\` \n - a plugin name \n - an object with the \`plugin\` and \`options\` properties \n - a tuple array with the plugin and options \n - a factory function that returns a plugin or array of plugins \n - an array of plugins or plugin configurations`);
|
|
3704
|
-
}
|
|
3705
|
-
let plugins;
|
|
3706
|
-
if ((0, require_plugin_utils.plugin_utils_exports.isPlugin)(awaited)) plugins = [awaited];
|
|
3707
|
-
else if ((0, _stryke_type_checks_is_function.isFunction)(awaited)) plugins = (0, _stryke_convert_to_array.toArray)(await Promise.resolve(awaited()));
|
|
3708
|
-
else if ((0, _stryke_type_checks_is_string.isString)(awaited)) {
|
|
3709
|
-
const resolved = await this.#resolvePlugin(awaited);
|
|
3710
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(resolved)) plugins = (0, _stryke_convert_to_array.toArray)(await Promise.resolve(resolved()));
|
|
3711
|
-
else plugins = (0, _stryke_convert_to_array.toArray)(resolved);
|
|
3712
|
-
} else if (Array.isArray(awaited) && awaited.every(require_plugin_utils.plugin_utils_exports.isPlugin)) plugins = awaited;
|
|
3713
|
-
else if (Array.isArray(awaited) && awaited.every(require_plugin_utils.plugin_utils_exports.isPluginConfig)) {
|
|
3714
|
-
plugins = [];
|
|
3715
|
-
for (const pluginConfig of awaited) {
|
|
3716
|
-
const initialized = await this.#initPlugin(pluginConfig);
|
|
3717
|
-
if (initialized) plugins.push(...initialized);
|
|
3718
|
-
}
|
|
3719
|
-
} else if ((0, require_plugin_utils.plugin_utils_exports.isPluginConfigTuple)(awaited) || (0, require_plugin_utils.plugin_utils_exports.isPluginConfigObject)(awaited)) {
|
|
3720
|
-
let pluginConfig;
|
|
3721
|
-
let pluginOptions;
|
|
3722
|
-
if ((0, require_plugin_utils.plugin_utils_exports.isPluginConfigTuple)(awaited)) {
|
|
3723
|
-
pluginConfig = awaited[0];
|
|
3724
|
-
pluginOptions = awaited?.length === 2 ? awaited[1] : void 0;
|
|
3725
|
-
} else {
|
|
3726
|
-
pluginConfig = awaited.plugin;
|
|
3727
|
-
pluginOptions = awaited.options;
|
|
3728
|
-
}
|
|
3729
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(pluginConfig)) {
|
|
3730
|
-
const resolved = await this.#resolvePlugin(pluginConfig);
|
|
3731
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(resolved)) plugins = (0, _stryke_convert_to_array.toArray)(await Promise.resolve(pluginOptions ? resolved(pluginOptions) : resolved()));
|
|
3732
|
-
else plugins = (0, _stryke_convert_to_array.toArray)(resolved);
|
|
3733
|
-
} else if ((0, _stryke_type_checks_is_function.isFunction)(pluginConfig)) plugins = (0, _stryke_convert_to_array.toArray)(await Promise.resolve(pluginConfig(pluginOptions)));
|
|
3734
|
-
else if (Array.isArray(pluginConfig) && pluginConfig.every(require_plugin_utils.plugin_utils_exports.isPlugin)) plugins = pluginConfig;
|
|
3735
|
-
else if ((0, require_plugin_utils.plugin_utils_exports.isPlugin)(pluginConfig)) plugins = (0, _stryke_convert_to_array.toArray)(pluginConfig);
|
|
3736
|
-
}
|
|
3737
|
-
if (!plugins) throw new Error(`The plugin configuration ${JSON.stringify(awaited)} is invalid. This configuration must point to a valid Powerlines plugin module.`);
|
|
3738
|
-
if (plugins.length > 0 && !plugins.every(require_plugin_utils.plugin_utils_exports.isPlugin)) throw new Error(`The plugin option ${JSON.stringify(plugins)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);
|
|
3739
|
-
const result = [];
|
|
3740
|
-
for (const plugin of plugins) if ((0, require_plugin_utils.plugin_utils_exports.checkDedupe)(plugin, this.context.plugins)) this.context.trace(`Duplicate ${chalk.default.bold.cyanBright(plugin.name)} plugin dependency detected - Skipping initialization.`);
|
|
3741
|
-
else {
|
|
3742
|
-
result.push(plugin);
|
|
3743
|
-
this.context.trace(`Initializing the ${chalk.default.bold.cyanBright(plugin.name)} plugin...`);
|
|
3744
|
-
}
|
|
3745
|
-
return result;
|
|
3746
|
-
}
|
|
3747
|
-
async #resolvePlugin(pluginPath) {
|
|
3748
|
-
if (pluginPath.startsWith("@") && pluginPath.split("/").filter(Boolean).length > 2) {
|
|
3749
|
-
const splits = pluginPath.split("/").filter(Boolean);
|
|
3750
|
-
pluginPath = `${splits[0]}/${splits[1]}`;
|
|
3751
|
-
}
|
|
3752
|
-
const isInstalled = (0, _stryke_fs_package_fns.isPackageExists)(pluginPath, { paths: [this.context.workspaceConfig.workspaceRoot, this.context.config.root] });
|
|
3753
|
-
if (!isInstalled && this.context.config.autoInstall) {
|
|
3754
|
-
this.#context.warn(`The plugin package "${pluginPath}" is not installed. It will be installed automatically.`);
|
|
3755
|
-
const result = await (0, _stryke_fs_install.install)(pluginPath, { cwd: this.context.config.root });
|
|
3756
|
-
if ((0, _stryke_type_checks_is_number.isNumber)(result.exitCode) && result.exitCode > 0) {
|
|
3757
|
-
this.#context.error(result.stderr);
|
|
3758
|
-
throw new Error(`An error occurred while installing the build plugin package "${pluginPath}" `);
|
|
3759
|
-
}
|
|
3760
|
-
}
|
|
3761
|
-
try {
|
|
3762
|
-
const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve((0, _stryke_path_join_paths.joinPaths)(pluginPath, "plugin")));
|
|
3763
|
-
const result = module.plugin ?? module.default;
|
|
3764
|
-
if (!result) throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
|
|
3765
|
-
return result;
|
|
3766
|
-
} catch (error) {
|
|
3767
|
-
try {
|
|
3768
|
-
const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(pluginPath));
|
|
3769
|
-
const result = module.plugin ?? module.default;
|
|
3770
|
-
if (!result) throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
|
|
3771
|
-
return result;
|
|
3772
|
-
} catch {
|
|
3773
|
-
if (!isInstalled) throw new Error(`The plugin package "${pluginPath}" is not installed. Please install the package using the command: "npm install ${pluginPath} --save-dev"`);
|
|
3774
|
-
else throw new Error(`An error occurred while importing the build plugin package "${pluginPath}":
|
|
3775
|
-
${(0, _stryke_type_checks_is_error.isError)(error) ? error.message : String(error)}
|
|
3776
|
-
|
|
3777
|
-
Note: Please ensure the plugin package's default export is a class that extends \`Plugin\` with a constructor that excepts a single arguments of type \`PluginOptions\`.`);
|
|
3778
|
-
}
|
|
3779
|
-
}
|
|
3780
|
-
}
|
|
3781
|
-
/**
|
|
3782
|
-
* Generate the Powerlines TypeScript declaration file
|
|
3783
|
-
*
|
|
3784
|
-
* @remarks
|
|
3785
|
-
* This method will generate the TypeScript declaration file for the Powerlines project, including any types provided by plugins.
|
|
3786
|
-
*
|
|
3787
|
-
* @param context - The environment context to use for generating the TypeScript declaration file
|
|
3788
|
-
* @returns A promise that resolves when the TypeScript declaration file has been generated
|
|
3789
|
-
*/
|
|
3790
|
-
async #types(context) {
|
|
3791
|
-
context.debug(`Preparing the TypeScript definitions for the Powerlines project.`);
|
|
3792
|
-
if (context.fs.existsSync(context.typesPath)) await context.fs.remove(context.typesPath);
|
|
3793
|
-
if (!await (0, _stryke_fs_resolve.resolvePackage)("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
3794
|
-
context.debug("Running TypeScript compiler for built-in runtime module files.");
|
|
3795
|
-
let types = (await emitBuiltinTypes(context, (await context.getBuiltins()).reduce((ret, builtin) => {
|
|
3796
|
-
const formatted = (0, _stryke_path_replace.replacePath)(builtin.path, context.workspaceConfig.workspaceRoot);
|
|
3797
|
-
if (!ret.includes(formatted)) ret.push(formatted);
|
|
3798
|
-
return ret;
|
|
3799
|
-
}, []))).trim();
|
|
3800
|
-
context.debug(`Generating TypeScript declaration file ${context.typesPath}.`);
|
|
3801
|
-
let directives = [];
|
|
3802
|
-
const merge = (currentResult, previousResult) => {
|
|
3803
|
-
if (!(0, _stryke_type_checks_is_set_string.isSetString)(currentResult) && !(0, _stryke_type_checks_is_set_object.isSetObject)(currentResult) && !(0, _stryke_type_checks_is_set_string.isSetString)(previousResult) && !(0, _stryke_type_checks_is_set_object.isSetObject)(previousResult)) return types;
|
|
3804
|
-
const previous = ((0, _stryke_type_checks_is_set_string.isSetString)(previousResult) ? previousResult : (0, _stryke_type_checks_is_set_object.isSetObject)(previousResult) ? previousResult.code : "").trim().replace(types, "").trim();
|
|
3805
|
-
return {
|
|
3806
|
-
directives: [...(0, _stryke_type_checks_is_set_object.isSetObject)(currentResult) && currentResult.directives ? currentResult.directives : [], ...(0, _stryke_type_checks_is_set_object.isSetObject)(previousResult) && previousResult.directives ? previousResult.directives : []],
|
|
3807
|
-
code: `${types}\n${previous}\n${((0, _stryke_type_checks_is_set_string.isSetString)(currentResult) ? currentResult : (0, _stryke_type_checks_is_set_object.isSetObject)(currentResult) ? currentResult.code : "").trim().replace(previous, "").trim().replace(types, "").trim()}`
|
|
3808
|
-
};
|
|
3809
|
-
};
|
|
3810
|
-
const asNextParam = (previousResult) => (0, _stryke_type_checks_is_object.isObject)(previousResult) ? previousResult.code : previousResult;
|
|
3811
|
-
let result = await this.callHook("types", {
|
|
3812
|
-
environment: context,
|
|
3813
|
-
sequential: true,
|
|
3814
|
-
order: "pre",
|
|
3815
|
-
result: "merge",
|
|
3816
|
-
merge,
|
|
3817
|
-
asNextParam
|
|
3818
|
-
}, types);
|
|
3819
|
-
if (result) {
|
|
3820
|
-
if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
3821
|
-
types = result.code;
|
|
3822
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) directives = (0, _stryke_helpers_get_unique.getUnique)([...directives, ...result.directives]).filter(Boolean);
|
|
3823
|
-
} else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
3824
|
-
}
|
|
3825
|
-
result = await this.callHook("types", {
|
|
3826
|
-
environment: context,
|
|
3827
|
-
sequential: true,
|
|
3828
|
-
order: "normal",
|
|
3829
|
-
result: "merge",
|
|
3830
|
-
merge,
|
|
3831
|
-
asNextParam
|
|
3832
|
-
}, types);
|
|
3833
|
-
if (result) {
|
|
3834
|
-
if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
3835
|
-
types = result.code;
|
|
3836
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) directives = (0, _stryke_helpers_get_unique.getUnique)([...directives, ...result.directives]).filter(Boolean);
|
|
3837
|
-
} else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
3838
|
-
}
|
|
3839
|
-
result = await this.callHook("types", {
|
|
3840
|
-
environment: context,
|
|
3841
|
-
sequential: true,
|
|
3842
|
-
order: "post",
|
|
3843
|
-
result: "merge",
|
|
3844
|
-
merge,
|
|
3845
|
-
asNextParam
|
|
3846
|
-
}, types);
|
|
3847
|
-
if (result) {
|
|
3848
|
-
if ((0, _stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
3849
|
-
types = result.code;
|
|
3850
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) directives = (0, _stryke_helpers_get_unique.getUnique)([...directives, ...result.directives]).filter(Boolean);
|
|
3851
|
-
} else if ((0, _stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
3852
|
-
}
|
|
3853
|
-
if ((0, _stryke_type_checks_is_set_string.isSetString)(types?.trim()) || directives.length > 0) await context.fs.write(context.typesPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
|
|
3854
|
-
|
|
3855
|
-
` : ""}${(0, require_utils.utils_exports.getTypescriptFileHeader)(context, {
|
|
3856
|
-
directive: null,
|
|
3857
|
-
prettierIgnore: false
|
|
3858
|
-
})}
|
|
3859
|
-
|
|
3860
|
-
${formatTypes(types)}
|
|
3861
|
-
`);
|
|
3862
|
-
else {
|
|
3863
|
-
const dtsRelativePath = getTsconfigDtsPath(context);
|
|
3864
|
-
if (context.tsconfig.tsconfigJson.include && require_tsconfig.isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
|
|
3865
|
-
const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
|
|
3866
|
-
context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
|
|
3867
|
-
await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
|
|
3868
|
-
}
|
|
3869
|
-
}
|
|
3870
|
-
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
|
|
3871
|
-
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
3872
|
-
}
|
|
3873
|
-
};
|
|
3874
|
-
|
|
3875
2920
|
//#endregion
|
|
3876
2921
|
Object.defineProperty(exports, 'FileId', {
|
|
3877
2922
|
enumerable: true,
|
|
@@ -3903,12 +2948,6 @@ Object.defineProperty(exports, 'FileSystem', {
|
|
|
3903
2948
|
return FileSystem;
|
|
3904
2949
|
}
|
|
3905
2950
|
});
|
|
3906
|
-
Object.defineProperty(exports, 'PowerlinesAPI', {
|
|
3907
|
-
enumerable: true,
|
|
3908
|
-
get: function () {
|
|
3909
|
-
return PowerlinesAPI;
|
|
3910
|
-
}
|
|
3911
|
-
});
|
|
3912
2951
|
Object.defineProperty(exports, 'PowerlinesAPIContext', {
|
|
3913
2952
|
enumerable: true,
|
|
3914
2953
|
get: function () {
|
|
@@ -3933,34 +2972,28 @@ Object.defineProperty(exports, '_capnpFileId', {
|
|
|
3933
2972
|
return _capnpFileId;
|
|
3934
2973
|
}
|
|
3935
2974
|
});
|
|
3936
|
-
Object.defineProperty(exports, '
|
|
2975
|
+
Object.defineProperty(exports, 'callHook', {
|
|
3937
2976
|
enumerable: true,
|
|
3938
2977
|
get: function () {
|
|
3939
|
-
return
|
|
2978
|
+
return callHook;
|
|
3940
2979
|
}
|
|
3941
2980
|
});
|
|
3942
|
-
Object.defineProperty(exports, '
|
|
3943
|
-
enumerable: true,
|
|
3944
|
-
get: function () {
|
|
3945
|
-
return createUnpluginFactory;
|
|
3946
|
-
}
|
|
3947
|
-
});
|
|
3948
|
-
Object.defineProperty(exports, 'name', {
|
|
2981
|
+
Object.defineProperty(exports, 'createPluginContext', {
|
|
3949
2982
|
enumerable: true,
|
|
3950
2983
|
get: function () {
|
|
3951
|
-
return
|
|
2984
|
+
return createPluginContext;
|
|
3952
2985
|
}
|
|
3953
2986
|
});
|
|
3954
|
-
Object.defineProperty(exports, '
|
|
2987
|
+
Object.defineProperty(exports, 'mergeConfigs', {
|
|
3955
2988
|
enumerable: true,
|
|
3956
2989
|
get: function () {
|
|
3957
|
-
return
|
|
2990
|
+
return mergeConfigs;
|
|
3958
2991
|
}
|
|
3959
2992
|
});
|
|
3960
|
-
Object.defineProperty(exports, '
|
|
2993
|
+
Object.defineProperty(exports, 'writeMetaFile', {
|
|
3961
2994
|
enumerable: true,
|
|
3962
2995
|
get: function () {
|
|
3963
|
-
return
|
|
2996
|
+
return writeMetaFile;
|
|
3964
2997
|
}
|
|
3965
2998
|
});
|
|
3966
|
-
//# sourceMappingURL=api-
|
|
2999
|
+
//# sourceMappingURL=api-context-BSrRdlnu.cjs.map
|