@powerlines/plugin-webpack 0.5.137 → 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 -2
- 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,84 +0,0 @@
|
|
|
1
|
-
import { declare } from "@babel/helper-plugin-utils";
|
|
2
|
-
import * as t from "@babel/types";
|
|
3
|
-
|
|
4
|
-
//#region ../powerlines/src/internal/babel/module-resolver-plugin.ts
|
|
5
|
-
function resolveModulePath(nodePath, state) {
|
|
6
|
-
if (!t.isStringLiteral(nodePath.node)) return;
|
|
7
|
-
const resolvedPath = state.context?.fs.resolveSync(nodePath.node.value);
|
|
8
|
-
if (resolvedPath) nodePath.replaceWith(t.stringLiteral(resolvedPath.replace(/\.(?:ts|mts|cts)x?$/, "")));
|
|
9
|
-
}
|
|
10
|
-
const TRANSFORM_FUNCTIONS = [
|
|
11
|
-
"require",
|
|
12
|
-
"require.resolve",
|
|
13
|
-
"System.import",
|
|
14
|
-
"jest.genMockFromModule",
|
|
15
|
-
"jest.mock",
|
|
16
|
-
"jest.unmock",
|
|
17
|
-
"jest.doMock",
|
|
18
|
-
"jest.dontMock",
|
|
19
|
-
"jest.setMock",
|
|
20
|
-
"jest.requireActual",
|
|
21
|
-
"jest.requireMock",
|
|
22
|
-
"require.requireActual",
|
|
23
|
-
"require.requireMock"
|
|
24
|
-
];
|
|
25
|
-
function matchesPattern(state, calleePath, pattern) {
|
|
26
|
-
const { node } = calleePath;
|
|
27
|
-
if (t.isMemberExpression(node)) return calleePath.matchesPattern(pattern);
|
|
28
|
-
if (!t.isIdentifier(node) || pattern.includes(".")) return false;
|
|
29
|
-
const name = pattern.split(".")[0];
|
|
30
|
-
return node.name === name;
|
|
31
|
-
}
|
|
32
|
-
const importVisitors = {
|
|
33
|
-
CallExpression: (nodePath, state) => {
|
|
34
|
-
if (state.moduleResolverVisited.has(nodePath)) return;
|
|
35
|
-
const calleePath = nodePath.get("callee");
|
|
36
|
-
if (calleePath && TRANSFORM_FUNCTIONS.some((pattern) => matchesPattern(state, calleePath, pattern)) || t.isImport(nodePath.node.callee)) {
|
|
37
|
-
state.moduleResolverVisited.add(nodePath);
|
|
38
|
-
resolveModulePath(nodePath.get("arguments.0"), state);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"ImportDeclaration|ExportDeclaration|ExportAllDeclaration": (nodePath, state) => {
|
|
42
|
-
if (!nodePath || !nodePath.get("source") || state.moduleResolverVisited.has(nodePath)) return;
|
|
43
|
-
state.moduleResolverVisited.add(nodePath);
|
|
44
|
-
resolveModulePath(nodePath.get("source"), state);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const moduleResolverBabelPlugin = (context) => {
|
|
48
|
-
return declare(function builder(api) {
|
|
49
|
-
let moduleResolverVisited = /* @__PURE__ */ new Set();
|
|
50
|
-
return {
|
|
51
|
-
name: "powerlines:module-resolver",
|
|
52
|
-
manipulateOptions(opts) {
|
|
53
|
-
opts.filename ??= "unknown";
|
|
54
|
-
},
|
|
55
|
-
pre() {
|
|
56
|
-
moduleResolverVisited = /* @__PURE__ */ new Set();
|
|
57
|
-
},
|
|
58
|
-
visitor: { Program: {
|
|
59
|
-
enter(programPath, state) {
|
|
60
|
-
programPath.traverse(importVisitors, {
|
|
61
|
-
...state,
|
|
62
|
-
context,
|
|
63
|
-
moduleResolverVisited,
|
|
64
|
-
api
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
exit(programPath, state) {
|
|
68
|
-
programPath.traverse(importVisitors, {
|
|
69
|
-
...state,
|
|
70
|
-
context,
|
|
71
|
-
moduleResolverVisited,
|
|
72
|
-
api
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
} },
|
|
76
|
-
post() {
|
|
77
|
-
moduleResolverVisited.clear();
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
export { moduleResolverBabelPlugin };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let defu = require("defu");
|
|
3
|
-
defu = require_rolldown_runtime.__toESM(defu);
|
|
4
|
-
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
5
|
-
|
|
6
|
-
//#region ../powerlines/src/internal/helpers/environment.ts
|
|
7
|
-
const DEFAULT_ENVIRONMENT = "default";
|
|
8
|
-
const GLOBAL_ENVIRONMENT = "__GLOBAL__";
|
|
9
|
-
function createEnvironment(name, userConfig) {
|
|
10
|
-
return (0, defu.default)(userConfig.environments?.[name] ?? {}, {
|
|
11
|
-
name,
|
|
12
|
-
title: userConfig.title || (0, __stryke_string_format_title_case.titleCase)(userConfig.name),
|
|
13
|
-
ssr: false,
|
|
14
|
-
mainFields: userConfig.build?.platform === "browser" ? [
|
|
15
|
-
"browser",
|
|
16
|
-
"module",
|
|
17
|
-
"jsnext:main",
|
|
18
|
-
"jsnext"
|
|
19
|
-
] : [
|
|
20
|
-
"module",
|
|
21
|
-
"jsnext:main",
|
|
22
|
-
"jsnext"
|
|
23
|
-
],
|
|
24
|
-
extensions: [
|
|
25
|
-
".mjs",
|
|
26
|
-
".js",
|
|
27
|
-
".mts",
|
|
28
|
-
".ts",
|
|
29
|
-
".jsx",
|
|
30
|
-
".tsx",
|
|
31
|
-
".json"
|
|
32
|
-
],
|
|
33
|
-
consumer: userConfig.build?.platform === "browser" ? "client" : "server",
|
|
34
|
-
preview: userConfig.build?.platform === "browser" ? {
|
|
35
|
-
port: 5173,
|
|
36
|
-
open: true,
|
|
37
|
-
strictPort: false,
|
|
38
|
-
host: "localhost",
|
|
39
|
-
allowedHosts: ["."],
|
|
40
|
-
cors: true,
|
|
41
|
-
headers: {}
|
|
42
|
-
} : void 0
|
|
43
|
-
}, userConfig);
|
|
44
|
-
}
|
|
45
|
-
function createDefaultEnvironment(userConfig) {
|
|
46
|
-
return createEnvironment(DEFAULT_ENVIRONMENT, userConfig);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
|
-
exports.GLOBAL_ENVIRONMENT = GLOBAL_ENVIRONMENT;
|
|
51
|
-
exports.createDefaultEnvironment = createDefaultEnvironment;
|
|
52
|
-
exports.createEnvironment = createEnvironment;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import defu$1 from "defu";
|
|
2
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
3
|
-
|
|
4
|
-
//#region ../powerlines/src/internal/helpers/environment.ts
|
|
5
|
-
const DEFAULT_ENVIRONMENT = "default";
|
|
6
|
-
const GLOBAL_ENVIRONMENT = "__GLOBAL__";
|
|
7
|
-
function createEnvironment(name, userConfig) {
|
|
8
|
-
return defu$1(userConfig.environments?.[name] ?? {}, {
|
|
9
|
-
name,
|
|
10
|
-
title: userConfig.title || titleCase(userConfig.name),
|
|
11
|
-
ssr: false,
|
|
12
|
-
mainFields: userConfig.build?.platform === "browser" ? [
|
|
13
|
-
"browser",
|
|
14
|
-
"module",
|
|
15
|
-
"jsnext:main",
|
|
16
|
-
"jsnext"
|
|
17
|
-
] : [
|
|
18
|
-
"module",
|
|
19
|
-
"jsnext:main",
|
|
20
|
-
"jsnext"
|
|
21
|
-
],
|
|
22
|
-
extensions: [
|
|
23
|
-
".mjs",
|
|
24
|
-
".js",
|
|
25
|
-
".mts",
|
|
26
|
-
".ts",
|
|
27
|
-
".jsx",
|
|
28
|
-
".tsx",
|
|
29
|
-
".json"
|
|
30
|
-
],
|
|
31
|
-
consumer: userConfig.build?.platform === "browser" ? "client" : "server",
|
|
32
|
-
preview: userConfig.build?.platform === "browser" ? {
|
|
33
|
-
port: 5173,
|
|
34
|
-
open: true,
|
|
35
|
-
strictPort: false,
|
|
36
|
-
host: "localhost",
|
|
37
|
-
allowedHosts: ["."],
|
|
38
|
-
cors: true,
|
|
39
|
-
headers: {}
|
|
40
|
-
} : void 0
|
|
41
|
-
}, userConfig);
|
|
42
|
-
}
|
|
43
|
-
function createDefaultEnvironment(userConfig) {
|
|
44
|
-
return createEnvironment(DEFAULT_ENVIRONMENT, userConfig);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { GLOBAL_ENVIRONMENT, createDefaultEnvironment, createEnvironment };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_ts_morph = require('../../lib/typescript/ts-morph.cjs');
|
|
3
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
|
-
let typescript = require("typescript");
|
|
5
|
-
|
|
6
|
-
//#region ../powerlines/src/internal/helpers/generate-types.ts
|
|
7
|
-
/**
|
|
8
|
-
* Formats the generated TypeScript types source code.
|
|
9
|
-
*
|
|
10
|
-
* @param code - The generated TypeScript code.
|
|
11
|
-
* @returns The formatted TypeScript code.
|
|
12
|
-
*/
|
|
13
|
-
function formatTypes(code) {
|
|
14
|
-
return code.replace(/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g, "").replaceAll("#private;", "").replace(/__Ω/g, "");
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Emits TypeScript declaration types for the provided files using the given TypeScript configuration.
|
|
18
|
-
*
|
|
19
|
-
* @param context - The context containing options and environment paths.
|
|
20
|
-
* @param files - The list of files to generate types for.
|
|
21
|
-
* @returns A promise that resolves to the generated TypeScript declaration types.
|
|
22
|
-
*/
|
|
23
|
-
async function emitTypes(context, files) {
|
|
24
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Running the TypeScript compiler for ${files.length} generated runtime files.`);
|
|
25
|
-
const program = require_ts_morph.createProgram(context, { skipAddingFilesFromTsConfig: true });
|
|
26
|
-
program.addSourceFilesAtPaths(files);
|
|
27
|
-
const result = program.emitToMemory({ emitOnlyDtsFiles: true });
|
|
28
|
-
let builtinModules = "";
|
|
29
|
-
for (const file of result.getFiles()) if (!file.filePath.endsWith(".map")) {
|
|
30
|
-
if (context.builtins.some((builtin) => builtin === file.filePath || context.fs.metadata[builtin]?.id && context.fs.metadata[builtin]?.id === file.filePath)) {
|
|
31
|
-
const module$1 = await context.fs.resolve(file.filePath);
|
|
32
|
-
builtinModules += `
|
|
33
|
-
declare module "${module$1}" {
|
|
34
|
-
${file.text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const diagnosticMessages = [];
|
|
40
|
-
result.getDiagnostics().forEach((diagnostic) => {
|
|
41
|
-
if (diagnostic.getSourceFile()?.getBaseName()) diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${(0, typescript.flattenDiagnosticMessageText)(diagnostic.getMessageText().toString(), "\n")}`);
|
|
42
|
-
else diagnosticMessages.push((0, typescript.flattenDiagnosticMessageText)(diagnostic.getMessageText().toString(), "\n"));
|
|
43
|
-
});
|
|
44
|
-
const diagnosticMessage = diagnosticMessages.join("\n");
|
|
45
|
-
if (diagnosticMessage) throw new Error(`TypeScript compilation failed: \n\n${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
|
|
46
|
-
return formatTypes(builtinModules);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
|
-
exports.emitTypes = emitTypes;
|
|
51
|
-
exports.formatTypes = formatTypes;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { createProgram } from "../../lib/typescript/ts-morph.mjs";
|
|
2
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
3
|
-
import { flattenDiagnosticMessageText } from "typescript";
|
|
4
|
-
|
|
5
|
-
//#region ../powerlines/src/internal/helpers/generate-types.ts
|
|
6
|
-
/**
|
|
7
|
-
* Formats the generated TypeScript types source code.
|
|
8
|
-
*
|
|
9
|
-
* @param code - The generated TypeScript code.
|
|
10
|
-
* @returns The formatted TypeScript code.
|
|
11
|
-
*/
|
|
12
|
-
function formatTypes(code) {
|
|
13
|
-
return code.replace(/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g, "").replaceAll("#private;", "").replace(/__Ω/g, "");
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Emits TypeScript declaration types for the provided files using the given TypeScript configuration.
|
|
17
|
-
*
|
|
18
|
-
* @param context - The context containing options and environment paths.
|
|
19
|
-
* @param files - The list of files to generate types for.
|
|
20
|
-
* @returns A promise that resolves to the generated TypeScript declaration types.
|
|
21
|
-
*/
|
|
22
|
-
async function emitTypes(context, files) {
|
|
23
|
-
context.log(LogLevelLabel.TRACE, `Running the TypeScript compiler for ${files.length} generated runtime files.`);
|
|
24
|
-
const program = createProgram(context, { skipAddingFilesFromTsConfig: true });
|
|
25
|
-
program.addSourceFilesAtPaths(files);
|
|
26
|
-
const result = program.emitToMemory({ emitOnlyDtsFiles: true });
|
|
27
|
-
let builtinModules = "";
|
|
28
|
-
for (const file of result.getFiles()) if (!file.filePath.endsWith(".map")) {
|
|
29
|
-
if (context.builtins.some((builtin) => builtin === file.filePath || context.fs.metadata[builtin]?.id && context.fs.metadata[builtin]?.id === file.filePath)) {
|
|
30
|
-
const module = await context.fs.resolve(file.filePath);
|
|
31
|
-
builtinModules += `
|
|
32
|
-
declare module "${module}" {
|
|
33
|
-
${file.text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
|
|
34
|
-
}
|
|
35
|
-
`;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const diagnosticMessages = [];
|
|
39
|
-
result.getDiagnostics().forEach((diagnostic) => {
|
|
40
|
-
if (diagnostic.getSourceFile()?.getBaseName()) diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n")}`);
|
|
41
|
-
else diagnosticMessages.push(flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n"));
|
|
42
|
-
});
|
|
43
|
-
const diagnosticMessage = diagnosticMessages.join("\n");
|
|
44
|
-
if (diagnosticMessage) throw new Error(`TypeScript compilation failed: \n\n${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
|
|
45
|
-
return formatTypes(builtinModules);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { emitTypes, formatTypes };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
3
|
-
let defu = require("defu");
|
|
4
|
-
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
5
|
-
let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
6
|
-
let __stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
7
|
-
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
8
|
-
let chalk = require("chalk");
|
|
9
|
-
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
10
|
-
|
|
11
|
-
//#region ../powerlines/src/internal/helpers/hooks.ts
|
|
12
|
-
const mergeResults = (0, defu.createDefu)((obj, key, value) => {
|
|
13
|
-
if ((0, __stryke_type_checks_is_string.isString)(obj[key]) && (0, __stryke_type_checks_is_string.isString)(value)) {
|
|
14
|
-
obj[key] = `${obj[key] || ""}\n${value || ""}`.trim();
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
return false;
|
|
18
|
-
});
|
|
19
|
-
/**
|
|
20
|
-
* Calls a hook with the given context, options, and arguments.
|
|
21
|
-
*
|
|
22
|
-
* @param context - The context to use when calling the hook.
|
|
23
|
-
* @param key - The hook to call.
|
|
24
|
-
* @param options - Options for calling the hook.
|
|
25
|
-
* @param args - Arguments to pass to the hook.
|
|
26
|
-
* @returns The return value of the hook.
|
|
27
|
-
*/
|
|
28
|
-
async function callHook(context, key, options, ...args) {
|
|
29
|
-
const hooks = context.selectHooks(key, options);
|
|
30
|
-
if (hooks.length > 0) {
|
|
31
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, ` 🧩 Calling plugin hook: ${chalk.default.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)}`);
|
|
32
|
-
const invokeHook = async (hook, hookArgs) => {
|
|
33
|
-
return Reflect.apply(hook.handler, hook.context, hookArgs);
|
|
34
|
-
};
|
|
35
|
-
let results = [];
|
|
36
|
-
if (options?.sequential === false) results = await Promise.all(hooks.map(async (hook) => {
|
|
37
|
-
if (!(0, __stryke_type_checks_is_function.isFunction)(hook.handler)) throw new Error(`Plugin hook handler for hook "${key}" is not a function.`);
|
|
38
|
-
return invokeHook(hook, [...args]);
|
|
39
|
-
}));
|
|
40
|
-
else for (const hook of hooks) {
|
|
41
|
-
if (!(0, __stryke_type_checks_is_function.isFunction)(hook.handler)) throw new Error(`Plugin hook handler for hook "${key}" is not a function.`);
|
|
42
|
-
if (options?.result === "first" || options?.asNextParam === false) {
|
|
43
|
-
results.push(await Promise.resolve(invokeHook(hook, [...args])));
|
|
44
|
-
if (options?.result === "first" && (0, __stryke_type_checks_is_set.isSet)(results[results.length - 1])) break;
|
|
45
|
-
} else {
|
|
46
|
-
const sequenceArgs = [...args];
|
|
47
|
-
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];
|
|
48
|
-
const result = await Promise.resolve(invokeHook(hook, [...sequenceArgs]));
|
|
49
|
-
if (result) {
|
|
50
|
-
if (options?.result === "last") results = [result];
|
|
51
|
-
else if ((0, __stryke_type_checks_is_string.isString)(result)) results = [`${(0, __stryke_type_checks_is_string.isString)(results[0]) ? results[0] || "" : ""}\n${result || ""}`.trim()];
|
|
52
|
-
else if ((0, __stryke_type_checks_is_object.isObject)(result)) results = [mergeResults(result, results[0] ?? {})];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const definedResults = results.filter((result) => (0, __stryke_type_checks_is_set.isSet)(result));
|
|
57
|
-
if (definedResults.length > 0) {
|
|
58
|
-
let mergedResult = void 0;
|
|
59
|
-
for (const result of definedResults) mergedResult = (0, defu.defu)(result, mergedResult ?? {});
|
|
60
|
-
return mergedResult;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
exports.callHook = callHook;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
2
|
-
import { createDefu, defu } from "defu";
|
|
3
|
-
import { isFunction } from "@stryke/type-checks/is-function";
|
|
4
|
-
import { isObject } from "@stryke/type-checks/is-object";
|
|
5
|
-
import { isSet } from "@stryke/type-checks/is-set";
|
|
6
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
7
|
-
import chalk from "chalk";
|
|
8
|
-
|
|
9
|
-
//#region ../powerlines/src/internal/helpers/hooks.ts
|
|
10
|
-
const mergeResults = createDefu((obj, key, value) => {
|
|
11
|
-
if (isString(obj[key]) && isString(value)) {
|
|
12
|
-
obj[key] = `${obj[key] || ""}\n${value || ""}`.trim();
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
});
|
|
17
|
-
/**
|
|
18
|
-
* Calls a hook with the given context, options, and arguments.
|
|
19
|
-
*
|
|
20
|
-
* @param context - The context to use when calling the hook.
|
|
21
|
-
* @param key - The hook to call.
|
|
22
|
-
* @param options - Options for calling the hook.
|
|
23
|
-
* @param args - Arguments to pass to the hook.
|
|
24
|
-
* @returns The return value of the hook.
|
|
25
|
-
*/
|
|
26
|
-
async function callHook(context, key, options, ...args) {
|
|
27
|
-
const hooks = context.selectHooks(key, options);
|
|
28
|
-
if (hooks.length > 0) {
|
|
29
|
-
context.log(LogLevelLabel.DEBUG, ` 🧩 Calling plugin hook: ${chalk.bold.cyanBright(`${key}${options?.order ? ` (${options.order})` : ""}`)}`);
|
|
30
|
-
const invokeHook = async (hook, hookArgs) => {
|
|
31
|
-
return Reflect.apply(hook.handler, hook.context, hookArgs);
|
|
32
|
-
};
|
|
33
|
-
let results = [];
|
|
34
|
-
if (options?.sequential === false) results = await Promise.all(hooks.map(async (hook) => {
|
|
35
|
-
if (!isFunction(hook.handler)) throw new Error(`Plugin hook handler for hook "${key}" is not a function.`);
|
|
36
|
-
return invokeHook(hook, [...args]);
|
|
37
|
-
}));
|
|
38
|
-
else for (const hook of hooks) {
|
|
39
|
-
if (!isFunction(hook.handler)) throw new Error(`Plugin hook handler for hook "${key}" is not a function.`);
|
|
40
|
-
if (options?.result === "first" || options?.asNextParam === false) {
|
|
41
|
-
results.push(await Promise.resolve(invokeHook(hook, [...args])));
|
|
42
|
-
if (options?.result === "first" && isSet(results[results.length - 1])) break;
|
|
43
|
-
} else {
|
|
44
|
-
const sequenceArgs = [...args];
|
|
45
|
-
if (results.length > 0 && sequenceArgs.length > 0) sequenceArgs[0] = isFunction(options.asNextParam) ? await Promise.resolve(options.asNextParam(results[0])) : results[0];
|
|
46
|
-
const result = await Promise.resolve(invokeHook(hook, [...sequenceArgs]));
|
|
47
|
-
if (result) {
|
|
48
|
-
if (options?.result === "last") results = [result];
|
|
49
|
-
else if (isString(result)) results = [`${isString(results[0]) ? results[0] || "" : ""}\n${result || ""}`.trim()];
|
|
50
|
-
else if (isObject(result)) results = [mergeResults(result, results[0] ?? {})];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const definedResults = results.filter((result) => isSet(result));
|
|
55
|
-
if (definedResults.length > 0) {
|
|
56
|
-
let mergedResult = void 0;
|
|
57
|
-
for (const result of definedResults) mergedResult = defu(result, mergedResult ?? {});
|
|
58
|
-
return mergedResult;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//#endregion
|
|
64
|
-
export { callHook };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_install = require('./install.cjs');
|
|
3
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
|
-
let __stryke_string_format_package = require("@stryke/string-format/package");
|
|
5
|
-
|
|
6
|
-
//#region ../powerlines/src/internal/helpers/install-dependencies.ts
|
|
7
|
-
/**
|
|
8
|
-
* Install missing project dependencies.
|
|
9
|
-
*
|
|
10
|
-
* @param context - The build context.
|
|
11
|
-
*/
|
|
12
|
-
async function installDependencies(context) {
|
|
13
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Checking and installing missing project dependencies.`);
|
|
14
|
-
context.dependencies ??= {};
|
|
15
|
-
context.devDependencies ??= {};
|
|
16
|
-
if (Object.keys(context.dependencies).length === 0 && Object.keys(context.devDependencies).length === 0) {
|
|
17
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `No dependencies or devDependencies to install. Skipping installation step.`);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.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")}`);
|
|
21
|
-
await Promise.all([Promise.all(Object.entries(context.dependencies).map(async ([name, version]) => require_install.installPackage(context, `${(0, __stryke_string_format_package.getPackageName)(name)}@${String(version)}`, false))), Promise.all(Object.entries(context.devDependencies).map(async ([name, version]) => require_install.installPackage(context, `${(0, __stryke_string_format_package.getPackageName)(name)}@${String(version)}`, true)))]);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
exports.installDependencies = installDependencies;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { installPackage } from "./install.mjs";
|
|
2
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
3
|
-
import { getPackageName } from "@stryke/string-format/package";
|
|
4
|
-
|
|
5
|
-
//#region ../powerlines/src/internal/helpers/install-dependencies.ts
|
|
6
|
-
/**
|
|
7
|
-
* Install missing project dependencies.
|
|
8
|
-
*
|
|
9
|
-
* @param context - The build context.
|
|
10
|
-
*/
|
|
11
|
-
async function installDependencies(context) {
|
|
12
|
-
context.log(LogLevelLabel.TRACE, `Checking and installing missing project dependencies.`);
|
|
13
|
-
context.dependencies ??= {};
|
|
14
|
-
context.devDependencies ??= {};
|
|
15
|
-
if (Object.keys(context.dependencies).length === 0 && Object.keys(context.devDependencies).length === 0) {
|
|
16
|
-
context.log(LogLevelLabel.TRACE, `No dependencies or devDependencies to install. Skipping installation step.`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
context.log(LogLevelLabel.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")}`);
|
|
20
|
-
await Promise.all([Promise.all(Object.entries(context.dependencies).map(async ([name, version]) => installPackage(context, `${getPackageName(name)}@${String(version)}`, false))), Promise.all(Object.entries(context.devDependencies).map(async ([name, version]) => installPackage(context, `${getPackageName(name)}@${String(version)}`, true)))]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { installDependencies };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
3
|
-
let __stryke_fs_install = require("@stryke/fs/install");
|
|
4
|
-
let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
5
|
-
let __stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
6
|
-
let __stryke_string_format_package = require("@stryke/string-format/package");
|
|
7
|
-
|
|
8
|
-
//#region ../powerlines/src/internal/helpers/install.ts
|
|
9
|
-
/**
|
|
10
|
-
* Installs a package if it is not already installed.
|
|
11
|
-
*
|
|
12
|
-
* @param context - The resolved options
|
|
13
|
-
* @param packageName - The name of the package to install
|
|
14
|
-
* @param dev - Whether to install the package as a dev dependency
|
|
15
|
-
*/
|
|
16
|
-
async function installPackage(context, packageName, dev = false) {
|
|
17
|
-
if (!await (0, __stryke_fs_package_fns.isPackageListed)((0, __stryke_string_format_package.getPackageName)(packageName), { cwd: context.config.projectRoot })) if (context.config.skipInstalls !== true) {
|
|
18
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. It will be installed automatically.`);
|
|
19
|
-
const result = await (0, __stryke_fs_install.install)(packageName, {
|
|
20
|
-
cwd: context.config.projectRoot,
|
|
21
|
-
dev
|
|
22
|
-
});
|
|
23
|
-
if ((0, __stryke_type_checks_is_number.isNumber)(result.exitCode) && result.exitCode > 0) {
|
|
24
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.ERROR, result.stderr);
|
|
25
|
-
throw new Error(`An error occurred while installing the package "${packageName}"`);
|
|
26
|
-
}
|
|
27
|
-
} else context.log(__storm_software_config_tools_types.LogLevelLabel.WARN, `The package "${packageName}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`);
|
|
28
|
-
else if ((0, __stryke_string_format_package.hasPackageVersion)(packageName) && !process.env.POWERLINES_SKIP_VERSION_CHECK) {
|
|
29
|
-
if (!await (0, __stryke_fs_package_fns.doesPackageMatch)((0, __stryke_string_format_package.getPackageName)(packageName), (0, __stryke_string_format_package.getPackageVersion)(packageName), context.config.projectRoot)) {
|
|
30
|
-
const packageListing = await (0, __stryke_fs_package_fns.getPackageListing)((0, __stryke_string_format_package.getPackageName)(packageName), { cwd: context.config.projectRoot });
|
|
31
|
-
if (!packageListing?.version.startsWith("catalog:") && !packageListing?.version.startsWith("workspace:")) context.log(__storm_software_config_tools_types.LogLevelLabel.WARN, `The package "${(0, __stryke_string_format_package.getPackageName)(packageName)}" is installed but does not match the expected version ${(0, __stryke_string_format_package.getPackageVersion)(packageName)} (installed version: ${packageListing?.version || "<Unknown>"}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
exports.installPackage = installPackage;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
2
|
-
import { install } from "@stryke/fs/install";
|
|
3
|
-
import { doesPackageMatch, getPackageListing, isPackageListed } from "@stryke/fs/package-fns";
|
|
4
|
-
import { isNumber } from "@stryke/type-checks/is-number";
|
|
5
|
-
import { getPackageName, getPackageVersion, hasPackageVersion } from "@stryke/string-format/package";
|
|
6
|
-
|
|
7
|
-
//#region ../powerlines/src/internal/helpers/install.ts
|
|
8
|
-
/**
|
|
9
|
-
* Installs a package if it is not already installed.
|
|
10
|
-
*
|
|
11
|
-
* @param context - The resolved options
|
|
12
|
-
* @param packageName - The name of the package to install
|
|
13
|
-
* @param dev - Whether to install the package as a dev dependency
|
|
14
|
-
*/
|
|
15
|
-
async function installPackage(context, packageName, dev = false) {
|
|
16
|
-
if (!await isPackageListed(getPackageName(packageName), { cwd: context.config.projectRoot })) if (context.config.skipInstalls !== true) {
|
|
17
|
-
context.log(LogLevelLabel.WARN, `The package "${packageName}" is not installed. It will be installed automatically.`);
|
|
18
|
-
const result = await install(packageName, {
|
|
19
|
-
cwd: context.config.projectRoot,
|
|
20
|
-
dev
|
|
21
|
-
});
|
|
22
|
-
if (isNumber(result.exitCode) && result.exitCode > 0) {
|
|
23
|
-
context.log(LogLevelLabel.ERROR, result.stderr);
|
|
24
|
-
throw new Error(`An error occurred while installing the package "${packageName}"`);
|
|
25
|
-
}
|
|
26
|
-
} else context.log(LogLevelLabel.WARN, `The package "${packageName}" is not installed. Since the "skipInstalls" option is set to true, it will not be installed automatically.`);
|
|
27
|
-
else if (hasPackageVersion(packageName) && !process.env.POWERLINES_SKIP_VERSION_CHECK) {
|
|
28
|
-
if (!await doesPackageMatch(getPackageName(packageName), getPackageVersion(packageName), context.config.projectRoot)) {
|
|
29
|
-
const packageListing = await getPackageListing(getPackageName(packageName), { cwd: context.config.projectRoot });
|
|
30
|
-
if (!packageListing?.version.startsWith("catalog:") && !packageListing?.version.startsWith("workspace:")) context.log(LogLevelLabel.WARN, `The package "${getPackageName(packageName)}" is installed but does not match the expected version ${getPackageVersion(packageName)} (installed version: ${packageListing?.version || "<Unknown>"}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the "STORM_STACK_SKIP_VERSION_CHECK" environment variable.`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { installPackage };
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_tsconfig = require('../../lib/typescript/tsconfig.cjs');
|
|
3
|
-
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
4
|
-
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
5
|
-
let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
6
|
-
let chalk = require("chalk");
|
|
7
|
-
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
8
|
-
let __donedeal0_superdiff = require("@donedeal0/superdiff");
|
|
9
|
-
let __stryke_fs_json = require("@stryke/fs/json");
|
|
10
|
-
let __stryke_json_storm_json = require("@stryke/json/storm-json");
|
|
11
|
-
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
12
|
-
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
13
|
-
|
|
14
|
-
//#region ../powerlines/src/internal/helpers/resolve-tsconfig.ts
|
|
15
|
-
function getTsconfigDtsPath(context) {
|
|
16
|
-
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.projectRoot), (0, __stryke_path_file_path_fns.findFilePath)(context.dtsPath)), (0, __stryke_path_file_path_fns.findFileName)(context.dtsPath));
|
|
17
|
-
}
|
|
18
|
-
async function resolveTsconfigChanges(context) {
|
|
19
|
-
const tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
|
|
20
|
-
const tsconfigJson = await (0, __stryke_fs_json.readJsonFile)(require_tsconfig.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig));
|
|
21
|
-
tsconfigJson.compilerOptions ??= {};
|
|
22
|
-
if (context.config.output.dts !== false) {
|
|
23
|
-
const dtsRelativePath = getTsconfigDtsPath(context);
|
|
24
|
-
if (!tsconfigJson.include?.some((filePattern) => require_tsconfig.isIncludeMatchFound(filePattern, [context.dtsPath, dtsRelativePath]))) {
|
|
25
|
-
tsconfigJson.include ??= [];
|
|
26
|
-
tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (!tsconfig.options.lib?.some((lib) => [
|
|
30
|
-
"lib.esnext.d.ts",
|
|
31
|
-
"lib.es2021.d.ts",
|
|
32
|
-
"lib.es2022.d.ts",
|
|
33
|
-
"lib.es2023.d.ts"
|
|
34
|
-
].includes(lib.toLowerCase()))) {
|
|
35
|
-
tsconfigJson.compilerOptions.lib ??= [];
|
|
36
|
-
tsconfigJson.compilerOptions.lib.push("esnext");
|
|
37
|
-
}
|
|
38
|
-
if (tsconfig.options.esModuleInterop !== true) tsconfigJson.compilerOptions.esModuleInterop = true;
|
|
39
|
-
if (tsconfig.options.isolatedModules !== true) tsconfigJson.compilerOptions.isolatedModules = true;
|
|
40
|
-
if (context.config.build.platform === "node") {
|
|
41
|
-
if (!tsconfig.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
|
|
42
|
-
tsconfigJson.compilerOptions.types ??= [];
|
|
43
|
-
tsconfigJson.compilerOptions.types.push("node");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return tsconfigJson;
|
|
47
|
-
}
|
|
48
|
-
async function initializeTsconfig(context) {
|
|
49
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
|
|
50
|
-
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\"");
|
|
51
|
-
const tsconfigFilePath = require_tsconfig.getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
52
|
-
context.tsconfig.originalTsconfigJson = await (0, __stryke_fs_json.readJsonFile)(tsconfigFilePath);
|
|
53
|
-
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
54
|
-
context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
|
|
55
|
-
await context.fs.write(tsconfigFilePath, __stryke_json_storm_json.StormJSON.stringify(context.tsconfig.tsconfigJson));
|
|
56
|
-
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
|
|
57
|
-
}
|
|
58
|
-
async function resolveTsconfig(context) {
|
|
59
|
-
const updateTsconfigJson = await (0, __stryke_fs_json.readJsonFile)(context.tsconfig.tsconfigFilePath);
|
|
60
|
-
if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) delete updateTsconfigJson.compilerOptions.types;
|
|
61
|
-
const result = (0, __donedeal0_superdiff.getObjectDiff)(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
|
|
62
|
-
ignoreArrayOrder: true,
|
|
63
|
-
showOnly: {
|
|
64
|
-
statuses: [
|
|
65
|
-
"added",
|
|
66
|
-
"deleted",
|
|
67
|
-
"updated"
|
|
68
|
-
],
|
|
69
|
-
granularity: "deep"
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
const changes = [];
|
|
73
|
-
const getChanges = (difference, property) => {
|
|
74
|
-
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);
|
|
75
|
-
else changes.push({
|
|
76
|
-
field: property ? `${property}.${difference.property}` : difference.property,
|
|
77
|
-
status: difference.status,
|
|
78
|
-
previous: difference.status === "added" ? "---" : __stryke_json_storm_json.StormJSON.stringify(difference.previousValue),
|
|
79
|
-
current: difference.status === "deleted" ? "---" : __stryke_json_storm_json.StormJSON.stringify(difference.currentValue)
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
for (const diff of result.diff) getChanges(diff);
|
|
83
|
-
if (changes.length > 0) context.log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
|
|
84
|
-
|
|
85
|
-
${changes.map((change, i) => `${chalk.default.bold.whiteBright(`${i + 1}. ${(0, __stryke_string_format_title_case.titleCase)(change.status)} the ${change.field} field: `)}
|
|
86
|
-
${chalk.default.red(` - Previous: ${change.previous} `)}
|
|
87
|
-
${chalk.default.green(` - Updated: ${change.current} `)}
|
|
88
|
-
`).join("\n")}
|
|
89
|
-
`);
|
|
90
|
-
await context.fs.write(context.tsconfig.tsconfigFilePath, __stryke_json_storm_json.StormJSON.stringify(updateTsconfigJson));
|
|
91
|
-
context.tsconfig = require_tsconfig.getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
92
|
-
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
//#endregion
|
|
96
|
-
exports.getTsconfigDtsPath = getTsconfigDtsPath;
|
|
97
|
-
exports.initializeTsconfig = initializeTsconfig;
|
|
98
|
-
exports.resolveTsconfig = resolveTsconfig;
|