@powerlines/plugin-vite 0.14.122 → 0.14.124

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.
Files changed (141) hide show
  1. package/dist/helpers/index.cjs +3 -2
  2. package/dist/helpers/index.d.cts +3 -1
  3. package/dist/helpers/index.d.mts +3 -1
  4. package/dist/helpers/index.mjs +2 -1
  5. package/dist/helpers/unplugin.cjs +2 -11
  6. package/dist/helpers/unplugin.d.cts +2 -6
  7. package/dist/helpers/unplugin.d.mts +2 -6
  8. package/dist/helpers/unplugin.mjs +1 -9
  9. package/dist/helpers-CmEjzAn_.mjs +1 -0
  10. package/dist/helpers-LF26RHol.cjs +0 -0
  11. package/dist/index-BR1oNnaF.d.cts +1 -0
  12. package/dist/index-DEHBdV_z.d.mts +1 -0
  13. package/dist/index-_wQ5ClJU.d.cts +1 -0
  14. package/dist/index-vkGVyY9v.d.mts +1 -0
  15. package/dist/index.cjs +170 -9
  16. package/dist/index.d.cts +4 -3
  17. package/dist/index.d.mts +5 -5
  18. package/dist/index.mjs +165 -3
  19. package/dist/plugin-Dc12T6ZF.d.mts +1960 -0
  20. package/dist/plugin-jZ9N9Mz-.mjs +1 -0
  21. package/dist/plugin-pBKbb5K9.cjs +0 -0
  22. package/dist/plugin-vkCGh5de.d.cts +1957 -0
  23. package/dist/types/index.cjs +2 -0
  24. package/dist/types/index.d.cts +2 -1
  25. package/dist/types/index.d.mts +2 -1
  26. package/dist/types/index.mjs +3 -0
  27. package/dist/types/internal.d.cts +191 -3
  28. package/dist/types/internal.d.mts +191 -3
  29. package/dist/types/plugin.cjs +1 -0
  30. package/dist/types/plugin.d.cts +1 -12
  31. package/dist/types/plugin.d.mts +1 -12
  32. package/dist/types/plugin.mjs +2 -0
  33. package/dist/types-BtDR9wb1.mjs +1 -0
  34. package/dist/types-o3zWarRp.cjs +0 -0
  35. package/dist/unplugin-B3TcDD6I.mjs +4617 -0
  36. package/dist/unplugin-Bv2agFkI.cjs +4661 -0
  37. package/dist/unplugin-D_zrAqRh.d.mts +7 -0
  38. package/dist/unplugin-F1UAxbOS.d.cts +7 -0
  39. package/package.json +5 -5
  40. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  41. package/dist/powerlines/schemas/fs.cjs +0 -226
  42. package/dist/powerlines/schemas/fs.mjs +0 -224
  43. package/dist/powerlines/src/api.cjs +0 -580
  44. package/dist/powerlines/src/api.mjs +0 -578
  45. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
  46. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
  47. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
  48. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
  49. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
  50. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
  51. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -63
  52. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -48
  53. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -50
  54. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -61
  55. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
  56. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
  57. package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
  58. package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
  59. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
  60. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
  61. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  62. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  63. package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
  64. package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
  65. package/dist/powerlines/src/lib/build/vite.cjs +0 -74
  66. package/dist/powerlines/src/lib/build/vite.mjs +0 -71
  67. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  68. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  69. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  70. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  71. package/dist/powerlines/src/lib/contexts/context.cjs +0 -931
  72. package/dist/powerlines/src/lib/contexts/context.mjs +0 -929
  73. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -160
  74. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -159
  75. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
  76. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
  77. package/dist/powerlines/src/lib/entry.cjs +0 -69
  78. package/dist/powerlines/src/lib/entry.mjs +0 -67
  79. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  80. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  81. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  82. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  83. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  84. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  85. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  86. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  87. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
  88. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
  89. package/dist/powerlines/src/lib/logger.cjs +0 -58
  90. package/dist/powerlines/src/lib/logger.mjs +0 -55
  91. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
  92. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
  93. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  94. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  95. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  96. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  97. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -17
  98. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -16
  99. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
  100. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
  101. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
  102. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
  103. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  104. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  105. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
  106. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
  107. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  108. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  109. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -148
  110. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -138
  111. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  112. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  113. package/dist/powerlines/src/types/api.d.cts +0 -104
  114. package/dist/powerlines/src/types/api.d.mts +0 -104
  115. package/dist/powerlines/src/types/babel.d.mts +0 -4
  116. package/dist/powerlines/src/types/build.cjs +0 -15
  117. package/dist/powerlines/src/types/build.d.cts +0 -154
  118. package/dist/powerlines/src/types/build.d.mts +0 -154
  119. package/dist/powerlines/src/types/build.mjs +0 -14
  120. package/dist/powerlines/src/types/commands.cjs +0 -16
  121. package/dist/powerlines/src/types/commands.d.cts +0 -8
  122. package/dist/powerlines/src/types/commands.d.mts +0 -9
  123. package/dist/powerlines/src/types/commands.mjs +0 -15
  124. package/dist/powerlines/src/types/config.d.cts +0 -416
  125. package/dist/powerlines/src/types/config.d.mts +0 -418
  126. package/dist/powerlines/src/types/context.d.cts +0 -514
  127. package/dist/powerlines/src/types/context.d.mts +0 -514
  128. package/dist/powerlines/src/types/fs.d.cts +0 -486
  129. package/dist/powerlines/src/types/fs.d.mts +0 -486
  130. package/dist/powerlines/src/types/hooks.d.cts +0 -30
  131. package/dist/powerlines/src/types/hooks.d.mts +0 -30
  132. package/dist/powerlines/src/types/internal.d.cts +0 -58
  133. package/dist/powerlines/src/types/internal.d.mts +0 -58
  134. package/dist/powerlines/src/types/plugin.cjs +0 -32
  135. package/dist/powerlines/src/types/plugin.d.cts +0 -234
  136. package/dist/powerlines/src/types/plugin.d.mts +0 -234
  137. package/dist/powerlines/src/types/plugin.mjs +0 -31
  138. package/dist/powerlines/src/types/resolved.d.cts +0 -82
  139. package/dist/powerlines/src/types/resolved.d.mts +0 -83
  140. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  141. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
@@ -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,63 +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_string = require("@stryke/type-checks/is-string");
5
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
6
- let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
7
- let __stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
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 hook - 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, hook, options, ...args) {
29
- const handlers = context.selectHooks(hook, options);
30
- if (handlers.length > 0) {
31
- context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, ` 🧩 Calling plugin hook: ${chalk.default.bold.cyanBright(`${hook}${options?.order ? ` (${options.order})` : ""}`)}`);
32
- let results = [];
33
- if (options?.sequential === false) results = await Promise.all(handlers.map(async (handler) => {
34
- if (!(0, __stryke_type_checks_is_function.isFunction)(handler.handle)) throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
35
- return Promise.resolve(handler.handle.apply(handler.context, [...args]));
36
- }));
37
- else for (const handler of handlers) {
38
- if (!(0, __stryke_type_checks_is_function.isFunction)(handler.handle)) throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
39
- if (options?.result === "first" || options?.asNextParam === false) {
40
- results.push(await Promise.resolve(handler.handle.apply(handler.context, [...args])));
41
- if (options?.result === "first" && (0, __stryke_type_checks_is_set.isSet)(results[results.length - 1])) break;
42
- } else {
43
- const sequenceArgs = [...args];
44
- 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];
45
- const result = await Promise.resolve(handler.handle.apply(handler.context, [...sequenceArgs]));
46
- if (result) {
47
- if (options?.result === "last") results = [result];
48
- 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()];
49
- else if ((0, __stryke_type_checks_is_object.isObject)(result)) results = [mergeResults(result, results[0] ?? {})];
50
- }
51
- }
52
- }
53
- const definedResults = results.filter((result) => (0, __stryke_type_checks_is_set.isSet)(result));
54
- if (definedResults.length > 0) {
55
- let mergedResult = void 0;
56
- for (const result of definedResults) mergedResult = (0, defu.defu)(result, mergedResult ?? {});
57
- return mergedResult;
58
- }
59
- }
60
- }
61
-
62
- //#endregion
63
- exports.callHook = callHook;
@@ -1,48 +0,0 @@
1
- import { SelectHooksOptions } from "../../types/context.cjs";
2
- import { MaybePromise } from "@stryke/types/base";
3
- import { ArrayValues } from "@stryke/types/array";
4
-
5
- //#region ../powerlines/src/internal/helpers/hooks.d.ts
6
- type CallHookOptions = SelectHooksOptions & (({
7
- /**
8
- * Whether to call the hooks sequentially or in parallel.
9
- *
10
- * @defaultValue true
11
- */
12
- sequential?: true;
13
- } & ({
14
- /**
15
- * How to handle multiple return values from hooks.
16
- * - "merge": Merge all non-undefined return values (if they are objects).
17
- * - "first": Return the first non-undefined value.
18
- *
19
- * @remarks
20
- * Merging only works if the return values are objects.
21
- *
22
- * @defaultValue "merge"
23
- */
24
- result: "first";
25
- } | {
26
- /**
27
- * How to handle multiple return values from hooks.
28
- * - "merge": Merge all non-undefined return values (if they are objects).
29
- * - "first": Return the first non-undefined value.
30
- *
31
- * @remarks
32
- * Merging only works if the return values are objects.
33
- *
34
- * @defaultValue "merge"
35
- */
36
- result?: "merge" | "last";
37
- /**
38
- * An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter
39
- */
40
- asNextParam?: false | ((previousResult: any) => MaybePromise<any>);
41
- })) | {
42
- /**
43
- * Whether to call the hooks sequentially or in parallel.
44
- */
45
- sequential: false;
46
- });
47
- //#endregion
48
- export { CallHookOptions };
@@ -1,50 +0,0 @@
1
- import "../../types/resolved.mjs";
2
- import "../../types/hooks.mjs";
3
- import { SelectHooksOptions } from "../../types/context.mjs";
4
- import { MaybePromise } from "@stryke/types/base";
5
- import { ArrayValues } from "@stryke/types/array";
6
-
7
- //#region ../powerlines/src/internal/helpers/hooks.d.ts
8
- type CallHookOptions = SelectHooksOptions & (({
9
- /**
10
- * Whether to call the hooks sequentially or in parallel.
11
- *
12
- * @defaultValue true
13
- */
14
- sequential?: true;
15
- } & ({
16
- /**
17
- * How to handle multiple return values from hooks.
18
- * - "merge": Merge all non-undefined return values (if they are objects).
19
- * - "first": Return the first non-undefined value.
20
- *
21
- * @remarks
22
- * Merging only works if the return values are objects.
23
- *
24
- * @defaultValue "merge"
25
- */
26
- result: "first";
27
- } | {
28
- /**
29
- * How to handle multiple return values from hooks.
30
- * - "merge": Merge all non-undefined return values (if they are objects).
31
- * - "first": Return the first non-undefined value.
32
- *
33
- * @remarks
34
- * Merging only works if the return values are objects.
35
- *
36
- * @defaultValue "merge"
37
- */
38
- result?: "merge" | "last";
39
- /**
40
- * An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter
41
- */
42
- asNextParam?: false | ((previousResult: any) => MaybePromise<any>);
43
- })) | {
44
- /**
45
- * Whether to call the hooks sequentially or in parallel.
46
- */
47
- sequential: false;
48
- });
49
- //#endregion
50
- export { CallHookOptions };
@@ -1,61 +0,0 @@
1
- import { LogLevelLabel } from "@storm-software/config-tools/types";
2
- import { createDefu, defu } from "defu";
3
- import { isString } from "@stryke/type-checks/is-string";
4
- import { isFunction } from "@stryke/type-checks/is-function";
5
- import { isObject } from "@stryke/type-checks/is-object";
6
- import { isSet } from "@stryke/type-checks/is-set";
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 hook - 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, hook, options, ...args) {
27
- const handlers = context.selectHooks(hook, options);
28
- if (handlers.length > 0) {
29
- context.log(LogLevelLabel.DEBUG, ` 🧩 Calling plugin hook: ${chalk.bold.cyanBright(`${hook}${options?.order ? ` (${options.order})` : ""}`)}`);
30
- let results = [];
31
- if (options?.sequential === false) results = await Promise.all(handlers.map(async (handler) => {
32
- if (!isFunction(handler.handle)) throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
33
- return Promise.resolve(handler.handle.apply(handler.context, [...args]));
34
- }));
35
- else for (const handler of handlers) {
36
- if (!isFunction(handler.handle)) throw new Error(`Plugin hook handler for hook "${hook}" is not a function.`);
37
- if (options?.result === "first" || options?.asNextParam === false) {
38
- results.push(await Promise.resolve(handler.handle.apply(handler.context, [...args])));
39
- if (options?.result === "first" && isSet(results[results.length - 1])) break;
40
- } else {
41
- const sequenceArgs = [...args];
42
- if (results.length > 0 && sequenceArgs.length > 0) sequenceArgs[0] = isFunction(options.asNextParam) ? await Promise.resolve(options.asNextParam(results[0])) : results[0];
43
- const result = await Promise.resolve(handler.handle.apply(handler.context, [...sequenceArgs]));
44
- if (result) {
45
- if (options?.result === "last") results = [result];
46
- else if (isString(result)) results = [`${isString(results[0]) ? results[0] || "" : ""}\n${result || ""}`.trim()];
47
- else if (isObject(result)) results = [mergeResults(result, results[0] ?? {})];
48
- }
49
- }
50
- }
51
- const definedResults = results.filter((result) => isSet(result));
52
- if (definedResults.length > 0) {
53
- let mergedResult = void 0;
54
- for (const result of definedResults) mergedResult = defu(result, mergedResult ?? {});
55
- return mergedResult;
56
- }
57
- }
58
- }
59
-
60
- //#endregion
61
- 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 };