@powerlines/plugin-webpack 0.5.136 → 0.5.138
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/helpers/unplugin.cjs +2 -3
- package/dist/helpers/unplugin.mjs +1 -2
- package/dist/index.cjs +3 -4
- package/dist/index.mjs +4 -5
- package/dist/powerlines/src/types/babel.d.mts +1 -3
- package/dist/powerlines/src/types/config.d.mts +1 -3
- package/dist/powerlines/src/types/context.d.mts +5 -5
- package/dist/powerlines/src/types/fs.d.mts +1 -1
- package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
- package/package.json +5 -10
- package/dist/powerlines/schemas/fs.cjs +0 -226
- package/dist/powerlines/schemas/fs.mjs +0 -224
- package/dist/powerlines/src/api.cjs +0 -580
- package/dist/powerlines/src/api.mjs +0 -578
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
- package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
- package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
- package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
- package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
- package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -66
- package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -64
- package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
- package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
- package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
- package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
- package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
- package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
- package/dist/powerlines/src/lib/build/webpack.cjs +0 -47
- package/dist/powerlines/src/lib/build/webpack.mjs +0 -45
- package/dist/powerlines/src/lib/config-file.cjs +0 -79
- package/dist/powerlines/src/lib/config-file.mjs +0 -76
- package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
- package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
- package/dist/powerlines/src/lib/contexts/context.cjs +0 -933
- package/dist/powerlines/src/lib/contexts/context.mjs +0 -931
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -195
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -194
- package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
- package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
- package/dist/powerlines/src/lib/entry.cjs +0 -69
- package/dist/powerlines/src/lib/entry.mjs +0 -67
- package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
- package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
- package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
- package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
- package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
- package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
- package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
- package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
- package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
- package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
- package/dist/powerlines/src/lib/logger.cjs +0 -58
- package/dist/powerlines/src/lib/logger.mjs +0 -55
- package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
- package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
- package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
- package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -29
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -27
- package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
- package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
- package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
- package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
- package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
- package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
- package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -167
- package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -156
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
- package/dist/powerlines/src/types/build.cjs +0 -23
- package/dist/powerlines/src/types/build.mjs +0 -21
- package/dist/powerlines/src/types/commands.cjs +0 -16
- package/dist/powerlines/src/types/commands.mjs +0 -15
- package/dist/powerlines/src/types/plugin.cjs +0 -33
- package/dist/powerlines/src/types/plugin.mjs +0 -32
|
@@ -1,580 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_module_resolver_plugin = require('./internal/babel/module-resolver-plugin.cjs');
|
|
3
|
-
const require_generate_types = require('./internal/helpers/generate-types.cjs');
|
|
4
|
-
const require_hooks = require('./internal/helpers/hooks.cjs');
|
|
5
|
-
const require_install_dependencies = require('./internal/helpers/install-dependencies.cjs');
|
|
6
|
-
const require_tsconfig = require('./lib/typescript/tsconfig.cjs');
|
|
7
|
-
const require_resolve_tsconfig = require('./internal/helpers/resolve-tsconfig.cjs');
|
|
8
|
-
const require_helpers = require('./plugin-utils/helpers.cjs');
|
|
9
|
-
const require_meta = require('./lib/utilities/meta.cjs');
|
|
10
|
-
const require_api_context = require('./lib/contexts/api-context.cjs');
|
|
11
|
-
const require_file_header = require('./lib/utilities/file-header.cjs');
|
|
12
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
13
|
-
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
14
|
-
let __babel_core = require("@babel/core");
|
|
15
|
-
let __storm_software_config_tools_logger_console = require("@storm-software/config-tools/logger/console");
|
|
16
|
-
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
17
|
-
let __stryke_fs_helpers = require("@stryke/fs/helpers");
|
|
18
|
-
let __stryke_fs_install = require("@stryke/fs/install");
|
|
19
|
-
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
20
|
-
let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
21
|
-
let __stryke_fs_resolve = require("@stryke/fs/resolve");
|
|
22
|
-
let __stryke_path_append = require("@stryke/path/append");
|
|
23
|
-
let __stryke_path_replace = require("@stryke/path/replace");
|
|
24
|
-
let __stryke_type_checks_is_error = require("@stryke/type-checks/is-error");
|
|
25
|
-
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
26
|
-
let __stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
27
|
-
let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
28
|
-
let __stryke_type_checks_is_promise = require("@stryke/type-checks/is-promise");
|
|
29
|
-
let __stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
30
|
-
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
31
|
-
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
32
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
33
|
-
let chalk = require("chalk");
|
|
34
|
-
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
35
|
-
let handlebars = require("handlebars");
|
|
36
|
-
handlebars = require_rolldown_runtime.__toESM(handlebars);
|
|
37
|
-
|
|
38
|
-
//#region ../powerlines/src/api.ts
|
|
39
|
-
/**
|
|
40
|
-
* The Powerlines API class
|
|
41
|
-
*
|
|
42
|
-
* @remarks
|
|
43
|
-
* This class is responsible for managing the Powerlines project lifecycle, including initialization, building, and finalization.
|
|
44
|
-
*
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
var PowerlinesAPI = class PowerlinesAPI {
|
|
48
|
-
/**
|
|
49
|
-
* The Powerlines context
|
|
50
|
-
*/
|
|
51
|
-
#context;
|
|
52
|
-
/**
|
|
53
|
-
* The Powerlines context
|
|
54
|
-
*/
|
|
55
|
-
get context() {
|
|
56
|
-
return this.#context;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Create a new Powerlines API instance
|
|
60
|
-
*
|
|
61
|
-
* @param context - The Powerlines context
|
|
62
|
-
*/
|
|
63
|
-
constructor(context) {
|
|
64
|
-
this.#context = context;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Initialize a Powerlines API instance
|
|
68
|
-
*
|
|
69
|
-
* @param workspaceRoot - The directory of the underlying workspace the Powerlines project exists in
|
|
70
|
-
* @param config - An object containing the configuration required to run Powerlines tasks.
|
|
71
|
-
* @returns A new instance of the Powerlines API
|
|
72
|
-
*/
|
|
73
|
-
static async from(workspaceRoot, config) {
|
|
74
|
-
const api = new PowerlinesAPI(await require_api_context.PowerlinesAPIContext.from(workspaceRoot, config));
|
|
75
|
-
api.#context.$$internal = {
|
|
76
|
-
api,
|
|
77
|
-
addPlugin: api.#addPlugin.bind(api)
|
|
78
|
-
};
|
|
79
|
-
for (const plugin of api.context.config.plugins ?? []) await api.#addPlugin(plugin);
|
|
80
|
-
if (api.context.plugins.length === 0) api.context.log(__storm_software_config_tools_types.LogLevelLabel.WARN, "No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
|
|
81
|
-
const pluginConfig = await api.callHook("config", {
|
|
82
|
-
environment: await api.context.getEnvironment(),
|
|
83
|
-
sequential: true,
|
|
84
|
-
result: "merge"
|
|
85
|
-
});
|
|
86
|
-
await api.context.withUserConfig(pluginConfig, { isHighPriority: false });
|
|
87
|
-
return api;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Prepare the Powerlines API
|
|
91
|
-
*
|
|
92
|
-
* @remarks
|
|
93
|
-
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
94
|
-
*
|
|
95
|
-
* @param inlineConfig - The inline configuration for the prepare command
|
|
96
|
-
*/
|
|
97
|
-
async prepare(inlineConfig = { command: "prepare" }) {
|
|
98
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, " 🏗️ Preparing the Powerlines project");
|
|
99
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, " ⚙️ Aggregating configuration options for the Powerlines project");
|
|
100
|
-
await this.context.withInlineConfig(inlineConfig);
|
|
101
|
-
await this.#executeEnvironments(async (context) => {
|
|
102
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
|
|
103
|
-
await this.callHook("configResolved", {
|
|
104
|
-
environment: context,
|
|
105
|
-
order: "pre"
|
|
106
|
-
});
|
|
107
|
-
await require_resolve_tsconfig.initializeTsconfig(context);
|
|
108
|
-
await this.callHook("configResolved", {
|
|
109
|
-
environment: context,
|
|
110
|
-
order: "normal"
|
|
111
|
-
});
|
|
112
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `The configuration provided ${(0, __stryke_convert_to_array.toArray)(context.config.entry).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")}` : ""}.`);
|
|
113
|
-
await require_resolve_tsconfig.resolveTsconfig(context);
|
|
114
|
-
await require_install_dependencies.installDependencies(context);
|
|
115
|
-
await this.callHook("configResolved", {
|
|
116
|
-
environment: context,
|
|
117
|
-
order: "post"
|
|
118
|
-
});
|
|
119
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved: \n\n${(0, __storm_software_config_tools_logger_console.formatLogMessage)(context.config)}`);
|
|
120
|
-
if (!context.fs.existsSync(context.cachePath)) await (0, __stryke_fs_helpers.createDirectory)(context.cachePath);
|
|
121
|
-
if (!context.fs.existsSync(context.dataPath)) await (0, __stryke_fs_helpers.createDirectory)(context.dataPath);
|
|
122
|
-
await this.callHook("prepare", {
|
|
123
|
-
environment: context,
|
|
124
|
-
order: "pre"
|
|
125
|
-
});
|
|
126
|
-
await this.callHook("prepare", {
|
|
127
|
-
environment: context,
|
|
128
|
-
order: "normal"
|
|
129
|
-
});
|
|
130
|
-
if (context.config.output.dts !== false) {
|
|
131
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
|
|
132
|
-
if (context.fs.existsSync(context.dtsPath)) await context.fs.remove(context.dtsPath);
|
|
133
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
|
|
134
|
-
const builtinFilePaths = await Promise.all((await context.getBuiltins()).map(async (file) => {
|
|
135
|
-
const result$1 = await (0, __babel_core.transformAsync)(file.code.toString(), {
|
|
136
|
-
highlightCode: true,
|
|
137
|
-
code: true,
|
|
138
|
-
ast: false,
|
|
139
|
-
cloneInputAst: false,
|
|
140
|
-
comments: true,
|
|
141
|
-
sourceType: "module",
|
|
142
|
-
configFile: false,
|
|
143
|
-
babelrc: false,
|
|
144
|
-
envName: context.config.mode,
|
|
145
|
-
caller: { name: "powerlines" },
|
|
146
|
-
...context.config.transform.babel,
|
|
147
|
-
filename: file.path,
|
|
148
|
-
plugins: [["@babel/plugin-syntax-typescript"], [require_module_resolver_plugin.moduleResolverBabelPlugin(context)]]
|
|
149
|
-
});
|
|
150
|
-
if (!result$1?.code) throw new Error(`Powerlines - Generate Types failed to compile ${file.id}`);
|
|
151
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Writing transformed built-in runtime file ${file.id}.`);
|
|
152
|
-
await context.emitBuiltin(result$1.code, file.id, file.path);
|
|
153
|
-
return file.path;
|
|
154
|
-
}));
|
|
155
|
-
if (!await (0, __stryke_fs_resolve.resolvePackage)("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
156
|
-
const files = builtinFilePaths.reduce((ret, fileName) => {
|
|
157
|
-
const formatted = (0, __stryke_path_replace.replacePath)(fileName, context.workspaceConfig.workspaceRoot);
|
|
158
|
-
if (!ret.includes(formatted)) ret.push(formatted);
|
|
159
|
-
return ret;
|
|
160
|
-
}, []);
|
|
161
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
|
|
162
|
-
let types = await require_generate_types.emitTypes(context, files);
|
|
163
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Generating TypeScript declaration file ${context.dtsPath}.`);
|
|
164
|
-
const directives = [];
|
|
165
|
-
const asNextParam = (previousResult) => (0, __stryke_type_checks_is_object.isObject)(previousResult) ? previousResult.code : previousResult;
|
|
166
|
-
let result = await this.callHook("types", {
|
|
167
|
-
environment: context,
|
|
168
|
-
sequential: true,
|
|
169
|
-
order: "pre",
|
|
170
|
-
result: "merge",
|
|
171
|
-
asNextParam
|
|
172
|
-
}, types);
|
|
173
|
-
if (result) {
|
|
174
|
-
if ((0, __stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
175
|
-
types = result.code;
|
|
176
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
177
|
-
} else if ((0, __stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
178
|
-
}
|
|
179
|
-
result = await this.callHook("types", {
|
|
180
|
-
environment: context,
|
|
181
|
-
sequential: true,
|
|
182
|
-
order: "normal",
|
|
183
|
-
result: "merge",
|
|
184
|
-
asNextParam
|
|
185
|
-
}, types);
|
|
186
|
-
if (result) {
|
|
187
|
-
if ((0, __stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
188
|
-
types = result.code;
|
|
189
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
190
|
-
} else if ((0, __stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
191
|
-
}
|
|
192
|
-
result = await this.callHook("types", {
|
|
193
|
-
environment: context,
|
|
194
|
-
sequential: true,
|
|
195
|
-
order: "post",
|
|
196
|
-
result: "merge",
|
|
197
|
-
asNextParam
|
|
198
|
-
}, types);
|
|
199
|
-
if (result) {
|
|
200
|
-
if ((0, __stryke_type_checks_is_set_object.isSetObject)(result)) {
|
|
201
|
-
types = result.code;
|
|
202
|
-
if (Array.isArray(result.directives) && result.directives.length > 0) directives.push(...result.directives);
|
|
203
|
-
} else if ((0, __stryke_type_checks_is_set_string.isSetString)(result)) types = result;
|
|
204
|
-
}
|
|
205
|
-
if (types?.trim() || directives.length > 0) await context.fs.write(context.dtsPath, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
|
|
206
|
-
|
|
207
|
-
` : ""}${require_file_header.getFileHeader(context, {
|
|
208
|
-
directive: null,
|
|
209
|
-
prettierIgnore: false
|
|
210
|
-
})}
|
|
211
|
-
|
|
212
|
-
${require_generate_types.formatTypes(types)}
|
|
213
|
-
`);
|
|
214
|
-
else {
|
|
215
|
-
const dtsRelativePath = require_resolve_tsconfig.getTsconfigDtsPath(context);
|
|
216
|
-
if (context.tsconfig.tsconfigJson.include && require_tsconfig.isIncludeMatchFound(dtsRelativePath, context.tsconfig.tsconfigJson.include)) {
|
|
217
|
-
const normalizedDtsRelativePath = dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath;
|
|
218
|
-
context.tsconfig.tsconfigJson.include = context.tsconfig.tsconfigJson.include.filter((includeValue) => includeValue?.toString() !== normalizedDtsRelativePath);
|
|
219
|
-
await context.fs.write(context.tsconfig.tsconfigFilePath, JSON.stringify(context.tsconfig.tsconfigJson, null, 2));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
224
|
-
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
225
|
-
await this.callHook("prepare", {
|
|
226
|
-
environment: context,
|
|
227
|
-
order: "post"
|
|
228
|
-
});
|
|
229
|
-
await require_meta.writeMetaFile(context);
|
|
230
|
-
context.persistedMeta = context.meta;
|
|
231
|
-
});
|
|
232
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.INFO, "Powerlines API has been prepared successfully");
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Create a new Powerlines project
|
|
236
|
-
*
|
|
237
|
-
* @remarks
|
|
238
|
-
* This method will create a new Powerlines project in the current directory.
|
|
239
|
-
*
|
|
240
|
-
* @param inlineConfig - The inline configuration for the new command
|
|
241
|
-
* @returns A promise that resolves when the project has been created
|
|
242
|
-
*/
|
|
243
|
-
async new(inlineConfig) {
|
|
244
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.INFO, "🆕 Creating a new Powerlines project");
|
|
245
|
-
await this.prepare(inlineConfig);
|
|
246
|
-
await this.#executeEnvironments(async (context) => {
|
|
247
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
|
|
248
|
-
await this.callHook("new", {
|
|
249
|
-
environment: context,
|
|
250
|
-
order: "pre"
|
|
251
|
-
});
|
|
252
|
-
const files = await (0, __stryke_fs_list_files.listFiles)((0, __stryke_path_join_paths.joinPaths)(context.powerlinesPath, "files/common/**/*.hbs"));
|
|
253
|
-
for (const file of files) {
|
|
254
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Adding template file: ${file}`);
|
|
255
|
-
const template = handlebars.default.compile(file);
|
|
256
|
-
await context.fs.write((0, __stryke_path_join_paths.joinPaths)(context.config.projectRoot, file.replace(".hbs", "")), template(context));
|
|
257
|
-
}
|
|
258
|
-
await this.callHook("new", {
|
|
259
|
-
environment: context,
|
|
260
|
-
order: "normal"
|
|
261
|
-
});
|
|
262
|
-
if (context.config.projectType === "application") {
|
|
263
|
-
const files$1 = await (0, __stryke_fs_list_files.listFiles)((0, __stryke_path_join_paths.joinPaths)(context.powerlinesPath, "files/application/**/*.hbs"));
|
|
264
|
-
for (const file of files$1) {
|
|
265
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Adding application template file: ${file}`);
|
|
266
|
-
const template = handlebars.default.compile(file);
|
|
267
|
-
await context.fs.write((0, __stryke_path_join_paths.joinPaths)(context.config.projectRoot, file.replace(".hbs", "")), template(context));
|
|
268
|
-
}
|
|
269
|
-
} else {
|
|
270
|
-
const files$1 = await (0, __stryke_fs_list_files.listFiles)((0, __stryke_path_join_paths.joinPaths)(context.powerlinesPath, "files/library/**/*.hbs"));
|
|
271
|
-
for (const file of files$1) {
|
|
272
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Adding library template file: ${file}`);
|
|
273
|
-
const template = handlebars.default.compile(file);
|
|
274
|
-
await context.fs.write((0, __stryke_path_join_paths.joinPaths)(context.config.projectRoot, file.replace(".hbs", "")), template(context));
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
await this.callHook("new", {
|
|
278
|
-
environment: context,
|
|
279
|
-
order: "post"
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Powerlines - New command completed");
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Clean any previously prepared artifacts
|
|
286
|
-
*
|
|
287
|
-
* @remarks
|
|
288
|
-
* This method will remove the previous Powerlines artifacts from the project.
|
|
289
|
-
*
|
|
290
|
-
* @param inlineConfig - The inline configuration for the clean command
|
|
291
|
-
* @returns A promise that resolves when the clean command has completed
|
|
292
|
-
*/
|
|
293
|
-
async clean(inlineConfig = { command: "clean" }) {
|
|
294
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.INFO, "🧹 Cleaning the previous Powerlines artifacts");
|
|
295
|
-
await this.prepare(inlineConfig);
|
|
296
|
-
await this.#executeEnvironments(async (context) => {
|
|
297
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Cleaning the project's dist and artifacts directories.");
|
|
298
|
-
await context.fs.remove((0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.output.buildPath));
|
|
299
|
-
await context.fs.remove((0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.output.artifactsPath));
|
|
300
|
-
await this.callHook("clean", {
|
|
301
|
-
environment: context,
|
|
302
|
-
sequential: false
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Powerlines - Clean command completed");
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Lint the project
|
|
309
|
-
*
|
|
310
|
-
* @param inlineConfig - The inline configuration for the lint command
|
|
311
|
-
* @returns A promise that resolves when the lint command has completed
|
|
312
|
-
*/
|
|
313
|
-
async lint(inlineConfig = { command: "lint" }) {
|
|
314
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.INFO, "📋 Linting the Powerlines project");
|
|
315
|
-
await this.prepare(inlineConfig);
|
|
316
|
-
await this.#executeEnvironments(async (context) => {
|
|
317
|
-
if (context.config.lint !== false) await this.callHook("lint", {
|
|
318
|
-
environment: context,
|
|
319
|
-
sequential: false
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Powerlines linting completed");
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Build the project
|
|
326
|
-
*
|
|
327
|
-
* @remarks
|
|
328
|
-
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
329
|
-
*
|
|
330
|
-
* @param inlineConfig - The inline configuration for the build command
|
|
331
|
-
* @returns A promise that resolves when the build command has completed
|
|
332
|
-
*/
|
|
333
|
-
async build(inlineConfig = { command: "build" }) {
|
|
334
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.INFO, "📦 Building the Powerlines project");
|
|
335
|
-
await this.prepare(inlineConfig);
|
|
336
|
-
if (this.context.config.singleBuild) await this.#handleBuild(await this.#context.toEnvironment());
|
|
337
|
-
else await this.#executeEnvironments(async (context) => {
|
|
338
|
-
await this.#handleBuild(context);
|
|
339
|
-
});
|
|
340
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Powerlines build completed");
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Prepare the documentation for the project
|
|
344
|
-
*
|
|
345
|
-
* @param inlineConfig - The inline configuration for the docs command
|
|
346
|
-
* @returns A promise that resolves when the documentation generation has completed
|
|
347
|
-
*/
|
|
348
|
-
async docs(inlineConfig = { command: "docs" }) {
|
|
349
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.INFO, "📓 Generating documentation for the Powerlines project");
|
|
350
|
-
await this.prepare(inlineConfig);
|
|
351
|
-
await this.#executeEnvironments(async (context) => {
|
|
352
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Writing documentation for the Powerlines project artifacts.");
|
|
353
|
-
await this.prepare(inlineConfig);
|
|
354
|
-
await this.#executeEnvironments(async (context$1) => {
|
|
355
|
-
await this.callHook("docs", { environment: context$1 });
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
this.#context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Powerlines documentation generation completed");
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Deploy the project source code
|
|
362
|
-
*
|
|
363
|
-
* @remarks
|
|
364
|
-
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
365
|
-
*
|
|
366
|
-
* @param inlineConfig - The inline configuration for the deploy command
|
|
367
|
-
*/
|
|
368
|
-
async deploy(inlineConfig = { command: "deploy" }) {
|
|
369
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.INFO, "📦 Deploying the Powerlines project");
|
|
370
|
-
await this.prepare(inlineConfig);
|
|
371
|
-
await this.#executeEnvironments(async (context) => {
|
|
372
|
-
await this.callHook("deploy", { environment: context });
|
|
373
|
-
});
|
|
374
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Powerlines deploy completed");
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Finalization process
|
|
378
|
-
*
|
|
379
|
-
* @remarks
|
|
380
|
-
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
381
|
-
*
|
|
382
|
-
* @returns A promise that resolves when the finalization process has completed
|
|
383
|
-
*/
|
|
384
|
-
async finalize() {
|
|
385
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Powerlines finalize execution started");
|
|
386
|
-
await this.#executeEnvironments(async (context) => {
|
|
387
|
-
await this.callHook("finalize", { environment: context });
|
|
388
|
-
await context.fs.dispose();
|
|
389
|
-
});
|
|
390
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Powerlines finalize execution completed");
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Invokes the configured plugin hooks
|
|
394
|
-
*
|
|
395
|
-
* @remarks
|
|
396
|
-
* By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
|
|
397
|
-
*
|
|
398
|
-
* @param hook - The hook to call
|
|
399
|
-
* @param options - The options to provide to the hook
|
|
400
|
-
* @param args - The arguments to pass to the hook
|
|
401
|
-
* @returns The result of the hook call
|
|
402
|
-
*/
|
|
403
|
-
async callHook(hook, options, ...args) {
|
|
404
|
-
return require_hooks.callHook((0, __stryke_type_checks_is_set_object.isSetObject)(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
|
|
405
|
-
sequential: true,
|
|
406
|
-
...options
|
|
407
|
-
}, ...args);
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Dispose of the Powerlines API instance
|
|
411
|
-
*
|
|
412
|
-
* @remarks
|
|
413
|
-
* This method will finalize the Powerlines API instance, cleaning up any resources used.
|
|
414
|
-
*/
|
|
415
|
-
async [Symbol.asyncDispose]() {
|
|
416
|
-
await this.finalize();
|
|
417
|
-
}
|
|
418
|
-
async #handleBuild(context) {
|
|
419
|
-
await this.callHook("build", {
|
|
420
|
-
environment: context,
|
|
421
|
-
order: "pre"
|
|
422
|
-
});
|
|
423
|
-
await this.callHook("build", {
|
|
424
|
-
environment: context,
|
|
425
|
-
order: "normal"
|
|
426
|
-
});
|
|
427
|
-
if (context.config.output.buildPath !== context.config.output.outputPath) {
|
|
428
|
-
const sourcePath = (0, __stryke_path_append.appendPath)(context.config.output.buildPath, context.workspaceConfig.workspaceRoot);
|
|
429
|
-
const destinationPath = (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_append.appendPath)(context.config.output.outputPath, context.workspaceConfig.workspaceRoot), "dist");
|
|
430
|
-
if (context.fs.existsSync(sourcePath) && sourcePath !== destinationPath) {
|
|
431
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.INFO, `Copying build output files from project's build directory (${context.config.output.buildPath}) to the workspace's output directory (${context.config.output.outputPath}).`);
|
|
432
|
-
await context.fs.copy(sourcePath, destinationPath);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
await Promise.all(context.config.output.assets.map(async (asset) => {
|
|
436
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Copying asset(s): ${chalk.default.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : (0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_replace.replacePath)(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk.default.greenBright((0, __stryke_path_join_paths.joinPaths)((0, __stryke_path_replace.replacePath)(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk.default.yellowBright(i)).join(", ")})` : ""}`);
|
|
437
|
-
await context.fs.copy(asset, asset.output);
|
|
438
|
-
}));
|
|
439
|
-
await this.callHook("build", {
|
|
440
|
-
environment: context,
|
|
441
|
-
order: "post"
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Get the configured environments
|
|
446
|
-
*
|
|
447
|
-
* @returns The configured environments
|
|
448
|
-
*/
|
|
449
|
-
async #getEnvironments() {
|
|
450
|
-
if (!this.context.config.environments || Object.keys(this.context.config.environments).length <= 1) {
|
|
451
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "No environments are configured for this Powerlines project. Using the default environment.");
|
|
452
|
-
return [await this.context.getEnvironment()];
|
|
453
|
-
}
|
|
454
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`);
|
|
455
|
-
return (await Promise.all(Object.entries(this.context.config.environments).map(async ([name, config]) => {
|
|
456
|
-
if (!await this.context.getEnvironmentSafe(name)) {
|
|
457
|
-
const resolvedEnvironment = await this.callHook("configEnvironment", { environment: name }, name, config);
|
|
458
|
-
if (resolvedEnvironment) this.context.environments[name] = await this.context.in(resolvedEnvironment);
|
|
459
|
-
}
|
|
460
|
-
return this.context.environments[name];
|
|
461
|
-
}))).filter((context) => (0, __stryke_type_checks_is_set.isSet)(context));
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Execute a handler function for each environment
|
|
465
|
-
*
|
|
466
|
-
* @param handle - The handler function to execute for each environment
|
|
467
|
-
*/
|
|
468
|
-
async #executeEnvironments(handle) {
|
|
469
|
-
await Promise.all((await this.#getEnvironments()).map(async (context) => {
|
|
470
|
-
return Promise.resolve(handle(context));
|
|
471
|
-
}));
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Add a Powerlines plugin used in the build process
|
|
475
|
-
*
|
|
476
|
-
* @param config - The import path of the plugin to add
|
|
477
|
-
*/
|
|
478
|
-
async #addPlugin(config) {
|
|
479
|
-
if (config) {
|
|
480
|
-
const result = await this.#initPlugin(config);
|
|
481
|
-
if (!result) return;
|
|
482
|
-
for (const plugin of result) {
|
|
483
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Successfully initialized the ${chalk.default.bold.cyanBright(plugin.name)} plugin`);
|
|
484
|
-
await this.context.addPlugin(plugin);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Initialize a Powerlines plugin
|
|
490
|
-
*
|
|
491
|
-
* @param config - The configuration for the plugin
|
|
492
|
-
* @returns The initialized plugin instance, or null if the plugin was a duplicate
|
|
493
|
-
* @throws Will throw an error if the plugin cannot be found or is invalid
|
|
494
|
-
*/
|
|
495
|
-
async #initPlugin(config) {
|
|
496
|
-
let awaited = config;
|
|
497
|
-
if ((0, __stryke_type_checks_is_promise.isPromiseLike)(config)) awaited = await Promise.resolve(config);
|
|
498
|
-
if (!require_helpers.isPluginConfig(awaited)) {
|
|
499
|
-
const invalid = require_helpers.findInvalidPluginConfig(awaited);
|
|
500
|
-
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`);
|
|
501
|
-
}
|
|
502
|
-
let plugins;
|
|
503
|
-
if (require_helpers.isPlugin(awaited)) plugins = [awaited];
|
|
504
|
-
else if ((0, __stryke_type_checks_is_function.isFunction)(awaited)) plugins = (0, __stryke_convert_to_array.toArray)(await Promise.resolve(awaited()));
|
|
505
|
-
else if ((0, __stryke_type_checks_is_string.isString)(awaited)) {
|
|
506
|
-
const resolved = await this.#resolvePlugin(awaited);
|
|
507
|
-
if ((0, __stryke_type_checks_is_function.isFunction)(resolved)) plugins = (0, __stryke_convert_to_array.toArray)(await Promise.resolve(resolved()));
|
|
508
|
-
else plugins = (0, __stryke_convert_to_array.toArray)(resolved);
|
|
509
|
-
} else if (Array.isArray(awaited) && awaited.every(require_helpers.isPlugin)) plugins = awaited;
|
|
510
|
-
else if (Array.isArray(awaited) && awaited.every(require_helpers.isPluginConfig)) {
|
|
511
|
-
plugins = [];
|
|
512
|
-
for (const pluginConfig of awaited) {
|
|
513
|
-
const initialized = await this.#initPlugin(pluginConfig);
|
|
514
|
-
if (initialized) plugins.push(...initialized);
|
|
515
|
-
}
|
|
516
|
-
} else if (require_helpers.isPluginConfigTuple(awaited) || require_helpers.isPluginConfigObject(awaited)) {
|
|
517
|
-
let pluginConfig;
|
|
518
|
-
let pluginOptions;
|
|
519
|
-
if (require_helpers.isPluginConfigTuple(awaited)) {
|
|
520
|
-
pluginConfig = awaited[0];
|
|
521
|
-
pluginOptions = awaited?.length === 2 ? awaited[1] : void 0;
|
|
522
|
-
} else {
|
|
523
|
-
pluginConfig = awaited.plugin;
|
|
524
|
-
pluginOptions = awaited.options;
|
|
525
|
-
}
|
|
526
|
-
if ((0, __stryke_type_checks_is_set_string.isSetString)(pluginConfig)) {
|
|
527
|
-
const resolved = await this.#resolvePlugin(pluginConfig);
|
|
528
|
-
if ((0, __stryke_type_checks_is_function.isFunction)(resolved)) plugins = (0, __stryke_convert_to_array.toArray)(await Promise.resolve(pluginOptions ? resolved(pluginOptions) : resolved()));
|
|
529
|
-
else plugins = (0, __stryke_convert_to_array.toArray)(resolved);
|
|
530
|
-
} else if ((0, __stryke_type_checks_is_function.isFunction)(pluginConfig)) plugins = (0, __stryke_convert_to_array.toArray)(await Promise.resolve(pluginConfig(pluginOptions)));
|
|
531
|
-
else if (Array.isArray(pluginConfig) && pluginConfig.every(require_helpers.isPlugin)) plugins = pluginConfig;
|
|
532
|
-
else if (require_helpers.isPlugin(pluginConfig)) plugins = (0, __stryke_convert_to_array.toArray)(pluginConfig);
|
|
533
|
-
}
|
|
534
|
-
if (!plugins) throw new Error(`The plugin configuration ${JSON.stringify(awaited)} is invalid. This configuration must point to a valid Powerlines plugin module.`);
|
|
535
|
-
if (plugins.length > 0 && !plugins.every(require_helpers.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.`);
|
|
536
|
-
const result = [];
|
|
537
|
-
for (const plugin of plugins) if (require_helpers.checkDedupe(plugin, this.context.plugins)) this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Duplicate ${chalk.default.bold.cyanBright(plugin.name)} plugin dependency detected - Skipping initialization.`);
|
|
538
|
-
else {
|
|
539
|
-
result.push(plugin);
|
|
540
|
-
this.context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Initializing the ${chalk.default.bold.cyanBright(plugin.name)} plugin...`);
|
|
541
|
-
}
|
|
542
|
-
return result;
|
|
543
|
-
}
|
|
544
|
-
async #resolvePlugin(pluginPath) {
|
|
545
|
-
if (pluginPath.startsWith("@") && pluginPath.split("/").filter(Boolean).length > 2) {
|
|
546
|
-
const splits = pluginPath.split("/").filter(Boolean);
|
|
547
|
-
pluginPath = `${splits[0]}/${splits[1]}`;
|
|
548
|
-
}
|
|
549
|
-
const isInstalled = (0, __stryke_fs_package_fns.isPackageExists)(pluginPath, { paths: [this.context.workspaceConfig.workspaceRoot, this.context.config.projectRoot] });
|
|
550
|
-
if (!isInstalled && this.context.config.skipInstalls !== true) {
|
|
551
|
-
this.#context.log(__storm_software_config_tools_types.LogLevelLabel.WARN, `The plugin package "${pluginPath}" is not installed. It will be installed automatically.`);
|
|
552
|
-
const result = await (0, __stryke_fs_install.install)(pluginPath, { cwd: this.context.config.projectRoot });
|
|
553
|
-
if ((0, __stryke_type_checks_is_number.isNumber)(result.exitCode) && result.exitCode > 0) {
|
|
554
|
-
this.#context.log(__storm_software_config_tools_types.LogLevelLabel.ERROR, result.stderr);
|
|
555
|
-
throw new Error(`An error occurred while installing the build plugin package "${pluginPath}" `);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
try {
|
|
559
|
-
const module$1 = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve((0, __stryke_path_join_paths.joinPaths)(pluginPath, "plugin")));
|
|
560
|
-
const result = module$1.plugin ?? module$1.default;
|
|
561
|
-
if (!result) throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
|
|
562
|
-
return result;
|
|
563
|
-
} catch (error) {
|
|
564
|
-
try {
|
|
565
|
-
const module$1 = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(pluginPath));
|
|
566
|
-
const result = module$1.plugin ?? module$1.default;
|
|
567
|
-
if (!result) throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
|
|
568
|
-
return result;
|
|
569
|
-
} catch {
|
|
570
|
-
if (!isInstalled) throw new Error(`The plugin package "${pluginPath}" is not installed. Please install the package using the command: "npm install ${pluginPath} --save-dev"`);
|
|
571
|
-
else throw new Error(`An error occurred while importing the build plugin package "${pluginPath}":
|
|
572
|
-
${(0, __stryke_type_checks_is_error.isError)(error) ? error.message : String(error)}
|
|
573
|
-
|
|
574
|
-
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\`.`);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
//#endregion
|