@powerlines/engine 0.15.0 โ†’ 0.15.1

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 (195) hide show
  1. package/dist/api/build.cjs +66 -0
  2. package/dist/api/build.d.cts +14 -0
  3. package/dist/api/build.d.cts.map +1 -0
  4. package/dist/api/build.d.mts +14 -0
  5. package/dist/api/build.d.mts.map +1 -0
  6. package/dist/api/build.mjs +64 -0
  7. package/dist/api/build.mjs.map +1 -0
  8. package/dist/api/clean.cjs +29 -0
  9. package/dist/api/clean.d.cts +14 -0
  10. package/dist/api/clean.d.cts.map +1 -0
  11. package/dist/api/clean.d.mts +14 -0
  12. package/dist/api/clean.d.mts.map +1 -0
  13. package/dist/api/clean.mjs +28 -0
  14. package/dist/api/clean.mjs.map +1 -0
  15. package/dist/api/create.cjs +59 -0
  16. package/dist/api/create.d.cts +14 -0
  17. package/dist/api/create.d.cts.map +1 -0
  18. package/dist/api/create.d.mts +14 -0
  19. package/dist/api/create.d.mts.map +1 -0
  20. package/dist/api/create.mjs +57 -0
  21. package/dist/api/create.mjs.map +1 -0
  22. package/dist/api/deploy.cjs +25 -0
  23. package/dist/api/deploy.d.cts +17 -0
  24. package/dist/api/deploy.d.cts.map +1 -0
  25. package/dist/api/deploy.d.mts +17 -0
  26. package/dist/api/deploy.d.mts.map +1 -0
  27. package/dist/api/deploy.mjs +24 -0
  28. package/dist/api/deploy.mjs.map +1 -0
  29. package/dist/api/docs.cjs +25 -0
  30. package/dist/api/docs.d.cts +17 -0
  31. package/dist/api/docs.d.cts.map +1 -0
  32. package/dist/api/docs.d.mts +17 -0
  33. package/dist/api/docs.d.mts.map +1 -0
  34. package/dist/api/docs.mjs +24 -0
  35. package/dist/api/docs.mjs.map +1 -0
  36. package/dist/api/lint.cjs +28 -0
  37. package/dist/api/lint.d.cts +17 -0
  38. package/dist/api/lint.d.cts.map +1 -0
  39. package/dist/api/lint.d.mts +17 -0
  40. package/dist/api/lint.d.mts.map +1 -0
  41. package/dist/api/lint.mjs +27 -0
  42. package/dist/api/lint.mjs.map +1 -0
  43. package/dist/api/prepare.cjs +69 -0
  44. package/dist/api/prepare.d.cts +14 -0
  45. package/dist/api/prepare.d.cts.map +1 -0
  46. package/dist/api/prepare.d.mts +14 -0
  47. package/dist/api/prepare.d.mts.map +1 -0
  48. package/dist/api/prepare.mjs +68 -0
  49. package/dist/api/prepare.mjs.map +1 -0
  50. package/dist/api/test.cjs +28 -0
  51. package/dist/api/test.d.cts +17 -0
  52. package/dist/api/test.d.cts.map +1 -0
  53. package/dist/api/test.d.mts +17 -0
  54. package/dist/api/test.d.mts.map +1 -0
  55. package/dist/api/test.mjs +27 -0
  56. package/dist/api/test.mjs.map +1 -0
  57. package/dist/api/types.cjs +71 -0
  58. package/dist/api/types.d.cts +17 -0
  59. package/dist/api/types.d.cts.map +1 -0
  60. package/dist/api/types.d.mts +17 -0
  61. package/dist/api/types.d.mts.map +1 -0
  62. package/dist/api/types.mjs +70 -0
  63. package/dist/api/types.mjs.map +1 -0
  64. package/dist/api-6w4hZL6n.d.cts +135 -0
  65. package/dist/api-6w4hZL6n.d.cts.map +1 -0
  66. package/dist/api-Cdw4v0W4.d.mts +135 -0
  67. package/dist/api-Cdw4v0W4.d.mts.map +1 -0
  68. package/dist/config-BNe23XHx.d.mts +204 -0
  69. package/dist/config-BNe23XHx.d.mts.map +1 -0
  70. package/dist/config-D6xUniHh.d.cts +204 -0
  71. package/dist/config-D6xUniHh.d.cts.map +1 -0
  72. package/dist/context/engine-context.cjs +175 -0
  73. package/dist/context/engine-context.d.cts +2 -0
  74. package/dist/context/engine-context.d.mts +2 -0
  75. package/dist/context/engine-context.mjs +173 -0
  76. package/dist/context/engine-context.mjs.map +1 -0
  77. package/dist/context/index.cjs +2 -9
  78. package/dist/context/index.d.cts +2 -660
  79. package/dist/context/index.d.mts +2 -660
  80. package/dist/context/index.mjs +2 -4
  81. package/dist/context-DzgsMSWr.d.mts +149 -0
  82. package/dist/context-DzgsMSWr.d.mts.map +1 -0
  83. package/dist/context-epL7NPvL.d.cts +149 -0
  84. package/dist/context-epL7NPvL.d.cts.map +1 -0
  85. package/dist/engine-context-DEotmVzB.d.mts +54 -0
  86. package/dist/engine-context-DEotmVzB.d.mts.map +1 -0
  87. package/dist/engine-context-Dw8odBCo.d.cts +54 -0
  88. package/dist/engine-context-Dw8odBCo.d.cts.map +1 -0
  89. package/dist/engine.cjs +268 -0
  90. package/dist/engine.d.cts +143 -0
  91. package/dist/engine.d.cts.map +1 -0
  92. package/dist/engine.d.mts +143 -0
  93. package/dist/engine.d.mts.map +1 -0
  94. package/dist/engine.mjs +264 -0
  95. package/dist/engine.mjs.map +1 -0
  96. package/dist/execution-host.cjs +44 -0
  97. package/dist/execution-host.d.cts +14 -0
  98. package/dist/execution-host.d.cts.map +1 -0
  99. package/dist/execution-host.d.mts +14 -0
  100. package/dist/execution-host.d.mts.map +1 -0
  101. package/dist/execution-host.mjs +36 -0
  102. package/dist/execution-host.mjs.map +1 -0
  103. package/dist/helpers/create-execution-host.cjs +51 -0
  104. package/dist/helpers/create-execution-host.d.cts +21 -0
  105. package/dist/helpers/create-execution-host.d.cts.map +1 -0
  106. package/dist/helpers/create-execution-host.d.mts +21 -0
  107. package/dist/helpers/create-execution-host.d.mts.map +1 -0
  108. package/dist/helpers/create-execution-host.mjs +50 -0
  109. package/dist/helpers/create-execution-host.mjs.map +1 -0
  110. package/dist/helpers/execution-host-worker.cjs +308 -0
  111. package/dist/helpers/execution-host-worker.d.cts +68 -0
  112. package/dist/helpers/execution-host-worker.d.cts.map +1 -0
  113. package/dist/helpers/execution-host-worker.d.mts +68 -0
  114. package/dist/helpers/execution-host-worker.d.mts.map +1 -0
  115. package/dist/helpers/execution-host-worker.mjs +307 -0
  116. package/dist/helpers/execution-host-worker.mjs.map +1 -0
  117. package/dist/helpers/finalize.cjs +27 -0
  118. package/dist/helpers/finalize.d.cts +12 -0
  119. package/dist/helpers/finalize.d.cts.map +1 -0
  120. package/dist/helpers/finalize.d.mts +12 -0
  121. package/dist/helpers/finalize.d.mts.map +1 -0
  122. package/dist/helpers/finalize.mjs +26 -0
  123. package/dist/helpers/finalize.mjs.map +1 -0
  124. package/dist/helpers/rpc.cjs +140 -0
  125. package/dist/helpers/rpc.d.cts +7 -0
  126. package/dist/helpers/rpc.d.cts.map +1 -0
  127. package/dist/helpers/rpc.d.mts +7 -0
  128. package/dist/helpers/rpc.d.mts.map +1 -0
  129. package/dist/helpers/rpc.mjs +139 -0
  130. package/dist/helpers/rpc.mjs.map +1 -0
  131. package/dist/index-CNgSR_kt.d.mts +1 -0
  132. package/dist/index-D_TYgLX3.d.cts +1 -0
  133. package/dist/index.cjs +13 -567
  134. package/dist/index.d.cts +9 -126
  135. package/dist/index.d.mts +9 -126
  136. package/dist/index.mjs +7 -567
  137. package/package.json +101 -129
  138. package/dist/_internal/worker.cjs +0 -4843
  139. package/dist/_internal/worker.d.cts +0 -38
  140. package/dist/_internal/worker.d.cts.map +0 -1
  141. package/dist/_internal/worker.d.mts +0 -38
  142. package/dist/_internal/worker.d.mts.map +0 -1
  143. package/dist/_internal/worker.mjs +0 -4804
  144. package/dist/_internal/worker.mjs.map +0 -1
  145. package/dist/api.cjs +0 -1274
  146. package/dist/api.d.cts +0 -265
  147. package/dist/api.d.cts.map +0 -1
  148. package/dist/api.d.mts +0 -265
  149. package/dist/api.d.mts.map +0 -1
  150. package/dist/api.mjs +0 -1270
  151. package/dist/api.mjs.map +0 -1
  152. package/dist/base-context-BUnL_9z8.mjs +0 -241
  153. package/dist/base-context-BUnL_9z8.mjs.map +0 -1
  154. package/dist/base-context-CFvO2N9I.cjs +0 -248
  155. package/dist/context/index.d.cts.map +0 -1
  156. package/dist/context/index.d.mts.map +0 -1
  157. package/dist/engine-context-BuD9AGfd.mjs +0 -41
  158. package/dist/engine-context-BuD9AGfd.mjs.map +0 -1
  159. package/dist/engine-context-NO6enYev.cjs +0 -45
  160. package/dist/execution-context-BgGV4xyW.cjs +0 -2614
  161. package/dist/execution-context-D_CXpe9I.mjs +0 -2570
  162. package/dist/execution-context-D_CXpe9I.mjs.map +0 -1
  163. package/dist/fs-D1nIP45P.mjs +0 -226
  164. package/dist/fs-D1nIP45P.mjs.map +0 -1
  165. package/dist/fs-XogSgMqT.cjs +0 -262
  166. package/dist/index.d.cts.map +0 -1
  167. package/dist/index.d.mts.map +0 -1
  168. package/dist/index.mjs.map +0 -1
  169. package/dist/schemas.cjs +0 -9
  170. package/dist/schemas.d.cts +0 -127
  171. package/dist/schemas.d.cts.map +0 -1
  172. package/dist/schemas.d.mts +0 -127
  173. package/dist/schemas.d.mts.map +0 -1
  174. package/dist/schemas.mjs +0 -3
  175. package/dist/storage/index.cjs +0 -9
  176. package/dist/storage/index.d.cts +0 -419
  177. package/dist/storage/index.d.cts.map +0 -1
  178. package/dist/storage/index.d.mts +0 -419
  179. package/dist/storage/index.d.mts.map +0 -1
  180. package/dist/storage/index.mjs +0 -3
  181. package/dist/ts-morph-BaLPVAdB.cjs +0 -114
  182. package/dist/ts-morph-D0CaA37w.mjs +0 -102
  183. package/dist/ts-morph-D0CaA37w.mjs.map +0 -1
  184. package/dist/tsconfig-Cstsoprg.mjs +0 -155
  185. package/dist/tsconfig-Cstsoprg.mjs.map +0 -1
  186. package/dist/tsconfig-DeyWQC2N.cjs +0 -198
  187. package/dist/typescript/index.cjs +0 -13
  188. package/dist/typescript/index.d.cts +0 -106
  189. package/dist/typescript/index.d.cts.map +0 -1
  190. package/dist/typescript/index.d.mts +0 -106
  191. package/dist/typescript/index.d.mts.map +0 -1
  192. package/dist/typescript/index.mjs +0 -4
  193. package/dist/virtual-BNdKVkRw.cjs +0 -548
  194. package/dist/virtual-gIlTc3Lj.mjs +0 -513
  195. package/dist/virtual-gIlTc3Lj.mjs.map +0 -1
package/dist/api.mjs DELETED
@@ -1,1270 +0,0 @@
1
- import { a as mergeConfigs, i as callHook, s as writeMetaFile, t as PowerlinesExecutionContext } from "./execution-context-D_CXpe9I.mjs";
2
- import { a as isIncludeMatchFound, i as getTsconfigFilePath, r as getParsedTypeScriptConfig } from "./tsconfig-Cstsoprg.mjs";
3
- import { n as createProgram } from "./ts-morph-D0CaA37w.mjs";
4
- import { resolvePackage } from "@stryke/fs/resolve";
5
- import { isSet } from "@stryke/type-checks/is-set";
6
- import { isString } from "@stryke/type-checks/is-string";
7
- import { colorText } from "@powerlines/core/lib/logger";
8
- import { StormJSON } from "@stryke/json/storm-json";
9
- import chalk from "chalk";
10
- import defu from "defu";
11
- import { joinPaths } from "@stryke/path/join-paths";
12
- import { isDevelopment, isTest } from "@stryke/env/environment-checks";
13
- import { titleCase } from "@stryke/string-format/title-case";
14
- import { isSetObject } from "@stryke/type-checks/is-set-object";
15
- import { getTypescriptFileHeader } from "@powerlines/core/lib/utilities/file-header";
16
- import { format, formatFolder } from "@powerlines/core/lib/utilities/format";
17
- import { findInvalidPluginConfig, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple } from "@powerlines/core/plugin-utils";
18
- import { formatLogMessage } from "@storm-software/config-tools/logger/console";
19
- import { toArray } from "@stryke/convert/to-array";
20
- import { copyFiles } from "@stryke/fs/copy-file";
21
- import { existsSync } from "@stryke/fs/exists";
22
- import { createDirectory, removeDirectory } from "@stryke/fs/helpers";
23
- import { install } from "@stryke/fs/install";
24
- import { listFiles } from "@stryke/fs/list-files";
25
- import { doesPackageMatch, getPackageListing, isPackageExists, isPackageListed } from "@stryke/fs/package-fns";
26
- import { getUnique } from "@stryke/helpers/get-unique";
27
- import { omit } from "@stryke/helpers/omit";
28
- import { appendPath } from "@stryke/path/append";
29
- import { findFileName, findFilePath, relativePath } from "@stryke/path/file-path-fns";
30
- import { isParentPath } from "@stryke/path/is-parent-path";
31
- import { replaceExtension, replacePath } from "@stryke/path/replace";
32
- import { isError } from "@stryke/type-checks/is-error";
33
- import { isFunction } from "@stryke/type-checks/is-function";
34
- import { isNumber } from "@stryke/type-checks/is-number";
35
- import { isObject } from "@stryke/type-checks/is-object";
36
- import { isPromiseLike } from "@stryke/type-checks/is-promise";
37
- import { isSetString } from "@stryke/type-checks/is-set-string";
38
- import Handlebars from "handlebars";
39
- import { readJsonFile } from "@stryke/fs/json";
40
- import { prettyBytes } from "@stryke/string-format/pretty-bytes";
41
- import { DiagnosticCategory, Node, Project } from "ts-morph";
42
- import { getPackageName, getPackageVersion, hasPackageVersion } from "@stryke/string-format/package";
43
- import { getObjectDiff } from "@donedeal0/superdiff";
44
-
45
- //#region src/_internal/helpers/generate-types.ts
46
- /**
47
- * Formats the generated TypeScript types source code.
48
- *
49
- * @param code - The generated TypeScript code.
50
- * @returns The formatted TypeScript code.
51
- */
52
- function formatTypes(code = "") {
53
- return code.replaceAll("#private;", "").replace(/__ฮฉ/g, "");
54
- }
55
- async function extractModuleDeclarations(ctx, filePath, name, text) {
56
- const imports = [];
57
- const exports = [];
58
- const comment = text.match(new RegExp(`\\/\\*\\*(?s:.)*?@module\\s+${ctx.context.config.framework}:${name}(?s:.)*?\\*\\/\\s+`))?.find((comment) => isSetString(comment?.trim()));
59
- const sourceFile = new Project({ useInMemoryFileSystem: true }).createSourceFile("module.d.ts", text);
60
- for (const ref of sourceFile.getTypeReferenceDirectives()) if (ref.getFileName() && !ctx.context.builtins.some((builtin) => ref.getFileName().endsWith(builtin))) imports.push({
61
- name: ref.getFileName(),
62
- ambient: true
63
- });
64
- for (const statement of sourceFile.getStatements()) if (Node.isImportDeclaration(statement)) {
65
- const moduleSpec = statement.getModuleSpecifierValue();
66
- if (statement.getNamespaceImport()) imports.push({
67
- name: moduleSpec,
68
- specifiers: [{ name: statement.getNamespaceImport().getText() }],
69
- all: true
70
- });
71
- else if (statement.getNamedImports().length > 0 || statement.getDefaultImport()) {
72
- const specifiers = [];
73
- if (statement.getDefaultImport()) specifiers.push({
74
- name: statement.getDefaultImport().getText(),
75
- default: true,
76
- type: statement.isTypeOnly()
77
- });
78
- statement.getNamedImports().forEach((named) => {
79
- specifiers.push({
80
- name: named.getName(),
81
- alias: named.getAliasNode()?.getText(),
82
- type: statement.isTypeOnly()
83
- });
84
- });
85
- imports.push({
86
- name: moduleSpec,
87
- specifiers
88
- });
89
- }
90
- } else if (Node.isExportDeclaration(statement)) {
91
- const moduleSpec = statement.getModuleSpecifierValue();
92
- if (moduleSpec) {
93
- let resolvedSpec = moduleSpec;
94
- if (!ctx.context.builtins.includes(moduleSpec)) if (ctx.emitted.has(moduleSpec)) resolvedSpec = ctx.emitted.get(moduleSpec);
95
- else {
96
- const resolvedModule = await ctx.context.resolve(moduleSpec, filePath);
97
- if (isSetString(resolvedModule?.id)) resolvedSpec = resolvedModule.id;
98
- }
99
- const namedExports = statement.getNamedExports();
100
- if (namedExports.length > 0) exports.push({
101
- name: resolvedSpec,
102
- text: statement.getText(),
103
- fullText: statement.getFullText(),
104
- specifiers: namedExports.map((named) => ({
105
- name: named.getName(),
106
- alias: named.getAliasNode()?.getText(),
107
- type: statement.isTypeOnly()
108
- })),
109
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n").trim()
110
- });
111
- else exports.push({
112
- name: resolvedSpec,
113
- text: statement.getText(),
114
- fullText: statement.getFullText(),
115
- all: true,
116
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n").trim()
117
- });
118
- } else {
119
- const specifiers = statement.getNamedExports().map((named) => ({
120
- name: named.getName(),
121
- alias: named.getAliasNode()?.getText(),
122
- type: statement.isTypeOnly()
123
- }));
124
- if (specifiers.length > 0) exports.push({
125
- text: statement.getText(),
126
- fullText: statement.getFullText(),
127
- specifiers,
128
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
129
- });
130
- }
131
- } else if (Node.isExportAssignment(statement)) exports.push({
132
- text: statement.getText(),
133
- fullText: statement.getFullText(),
134
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
135
- });
136
- else if (Node.isFunctionDeclaration(statement) && statement.isExported() && statement.getNameNode()) exports.push({
137
- text: statement.getText(),
138
- fullText: statement.getFullText(),
139
- specifiers: [{ name: statement.getNameNode().getText() }],
140
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
141
- });
142
- else if (Node.isVariableStatement(statement) && statement.isExported()) exports.push({
143
- text: statement.getText(),
144
- fullText: statement.getFullText(),
145
- specifiers: statement.getDeclarationList().getDeclarations().filter((decl) => decl.getNameNode() && Node.isIdentifier(decl.getNameNode())).map((decl) => ({ name: decl.getNameNode().getText() })),
146
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
147
- });
148
- else if (Node.isClassDeclaration(statement) && statement.isExported()) {
149
- const nameNode = statement.getNameNode();
150
- exports.push({
151
- text: statement.getText(),
152
- fullText: statement.getFullText(),
153
- specifiers: nameNode ? [{ name: nameNode.getText() }] : void 0,
154
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
155
- });
156
- } else if (Node.isInterfaceDeclaration(statement) && statement.isExported()) {
157
- const nameNode = statement.getNameNode();
158
- exports.push({
159
- text: statement.getText(),
160
- fullText: statement.getFullText(),
161
- specifiers: nameNode ? [{ name: nameNode.getText() }] : void 0,
162
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
163
- });
164
- } else if (Node.isTypeAliasDeclaration(statement) && statement.isExported()) {
165
- const nameNode = statement.getNameNode();
166
- exports.push({
167
- text: statement.getText(),
168
- fullText: statement.getFullText(),
169
- specifiers: nameNode ? [{ name: nameNode.getText() }] : void 0,
170
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
171
- });
172
- } else if (ctx.context.config.output.sourceMap || !statement.getFullText().includes("//# sourceMappingURL=")) exports.push({
173
- text: statement.getText(),
174
- fullText: statement.getFullText(),
175
- comment: statement.getLeadingCommentRanges().filter((c) => isSetString(c.getText().trim()) && !c.getText().includes("@module")).map((c) => c.getText().trim()).join("\n")
176
- });
177
- return {
178
- name,
179
- text,
180
- sourceFile,
181
- comment,
182
- imports,
183
- exports
184
- };
185
- }
186
- /**
187
- * Emits TypeScript declaration types for the provided files using the given TypeScript configuration.
188
- *
189
- * @param context - The context containing options and environment paths.
190
- * @param files - The list of files to generate types for.
191
- * @returns A promise that resolves to the generated TypeScript declaration types.
192
- */
193
- async function emitBuiltinTypes(context, files) {
194
- if (files.length === 0) {
195
- context.debug("No files provided for TypeScript types generation. Typescript compilation for built-in modules will be skipped.");
196
- return {
197
- code: "",
198
- directives: []
199
- };
200
- }
201
- context.debug(`Running the TypeScript compiler for ${files.length} generated built-in module files.`);
202
- const program = createProgram(context, {
203
- skipAddingFilesFromTsConfig: true,
204
- compilerOptions: {
205
- declaration: true,
206
- declarationMap: false,
207
- emitDeclarationOnly: true,
208
- sourceMap: false,
209
- outDir: replacePath(context.builtinsPath, context.config.cwd),
210
- composite: false,
211
- incremental: false,
212
- tsBuildInfoFile: void 0
213
- }
214
- });
215
- program.addSourceFilesAtPaths(files);
216
- const emitResult = program.emitToMemory({ emitOnlyDtsFiles: true });
217
- const diagnostics = emitResult.getDiagnostics();
218
- if (diagnostics && diagnostics.length > 0) if (diagnostics.some((d) => d.getCategory() === DiagnosticCategory.Error)) throw new Error(`The Typescript emit process failed while generating built-in types: \n ${diagnostics.filter((d) => d.getCategory() === DiagnosticCategory.Error).map((d) => `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : ""} ${String(d.getMessageText())} (at ${d.getStart()}:${d.getLength()})`).join("\n")}`);
219
- else if (diagnostics.some((d) => d.getCategory() === DiagnosticCategory.Warning)) context.warn(`The Typescript emit process completed with warnings while generating built-in types: \n ${diagnostics.filter((d) => d.getCategory() === DiagnosticCategory.Warning).map((d) => `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : ""} ${String(d.getMessageText())} (at ${d.getStart()}:${d.getLength()})`).join("\n")}`);
220
- else context.debug(`The Typescript emit process completed with diagnostic messages while generating built-in types: \n ${diagnostics.map((d) => `-${d.getSourceFile() ? `${d.getSourceFile()?.getFilePath()}:` : ""} ${String(d.getMessageText())} (at ${d.getStart()}:${d.getLength()})`).join("\n")}`);
221
- const emittedFiles = emitResult.getFiles();
222
- context.debug(`The TypeScript compiler emitted ${emittedFiles.length} files for built-in types.`);
223
- if (emittedFiles.length === 0) {
224
- context.warn("The TypeScript compiler did not emit any files for built-in types. This may indicate an issue with the TypeScript configuration or the provided files.");
225
- return {
226
- code: "",
227
- directives: []
228
- };
229
- }
230
- const ctx = {
231
- context,
232
- modules: [],
233
- emitted: /* @__PURE__ */ new Map()
234
- };
235
- await Promise.all(emittedFiles.map(async (emittedFile) => {
236
- const filePath = appendPath(emittedFile.filePath, context.config.cwd);
237
- if (!filePath.endsWith(".map") && findFileName(filePath) !== "tsconfig.tsbuildinfo" && isParentPath(filePath, context.builtinsPath)) {
238
- const moduleName = replaceExtension(replacePath(replacePath(filePath, context.builtinsPath), replacePath(context.builtinsPath, context.config.cwd)), "", { fullExtension: true });
239
- if (context.builtins.includes(moduleName)) {
240
- ctx.emitted.set(filePath, moduleName);
241
- ctx.modules.push(await extractModuleDeclarations(ctx, filePath, moduleName, emittedFile.text));
242
- }
243
- }
244
- }));
245
- const commonDeclarations = [];
246
- for (const mod of ctx.modules) for (const importRef of mod.imports.filter((importRef) => context.builtins.some((builtin) => importRef.name.endsWith(`:${builtin}`)))) {
247
- const moduleRef = ctx.modules.find((moduleRef) => importRef.name.endsWith(`:${moduleRef.name}`));
248
- if (moduleRef) {
249
- let declaration;
250
- for (const decl of moduleRef.exports.filter((decl) => isSetObject(decl))) {
251
- const specifiers = decl.specifiers?.filter((specifier) => importRef.specifiers?.some((s) => (specifier.alias ? specifier.alias : specifier.name) === (s.alias ? s.alias : s.name)));
252
- if (specifiers && specifiers.length > 0) {
253
- importRef.specifiers = importRef.specifiers?.filter((s) => !specifiers.some((specifier) => (specifier.alias ? specifier.alias : specifier.name) === (s.alias ? s.alias : s.name)));
254
- if (importRef.specifiers && importRef.specifiers.length === 0 && !importRef.all && !importRef.ambient) mod.imports = mod.imports.filter((imp) => imp.name !== importRef.name);
255
- declaration = decl;
256
- break;
257
- }
258
- }
259
- if (declaration) {
260
- for (const decl of moduleRef.exports.filter((decl) => isSetObject(decl) && !decl.specifiers?.some((s) => declaration?.specifiers?.some((specifier) => (specifier.alias ? specifier.alias : specifier.name) === (s.alias ? s.alias : s.name))))) {
261
- const exportModuleRef = decl;
262
- if ((exportModuleRef.specifiers?.some((s) => s.alias || s.name) || exportModuleRef.name) && new RegExp(`(^|\\s|\\n|\\r\\n|\\(|\\)|<|>|{|}|\\[|\\]|\\!|\\?|\\.|,|\\*|&|:)(${exportModuleRef.specifiers?.map((s) => `${s.alias ? `${s.alias}|` : ""}${s.name}`).join("|") || exportModuleRef.name})($|\\s|\\n|\\r\\n|\\(|\\)|<|>|{|}|\\[|\\]|\\!|\\?|\\.|,|\\*|&|:|;)`).test(declaration.text)) commonDeclarations.push(exportModuleRef);
263
- }
264
- commonDeclarations.push(declaration);
265
- }
266
- }
267
- }
268
- let code = "";
269
- const directives = [];
270
- for (const commonDeclaration of commonDeclarations) {
271
- code += formatTypes(`${commonDeclaration.comment?.trim() ? commonDeclaration.comment.trim() : ""}${commonDeclaration.comment?.trim() ? "\n" : ""}${formatTypes(commonDeclaration.text.replace(/\s*export\s*/, "").replace(/\s*declare\s*interface\s*/, "interface ").replace(/\s*declare\s*type\s*/, "type "))}`);
272
- code += "\n\n";
273
- }
274
- for (const mod of ctx.modules) {
275
- code += mod.comment ? `${mod.comment.trim()}\n` : "";
276
- code += `declare module "${context.config.framework}:${mod.name}" { \n`;
277
- for (const importRef of mod.imports) if (importRef.ambient) code += directives.push(importRef.name);
278
- else if (importRef.all) code += `\timport * as ${findFileName(importRef.name)} from "${importRef.name}";\n`;
279
- else if (importRef.specifiers) {
280
- const typeOnly = importRef.specifiers.every((s) => s.type) ? " type" : "";
281
- const specifiers = importRef.specifiers.map((s) => s.alias ? `${s.name} as ${s.alias}` : s.name).join(", ");
282
- code += `\timport${typeOnly} { ${specifiers} } from "${importRef.name}";\n`;
283
- }
284
- if (mod.imports.length > 0) code += "\n";
285
- for (const exportRef of mod.exports.filter((e) => isString(e) || !e.specifiers || !commonDeclarations.some((commonDecl) => commonDecl.specifiers && commonDecl.specifiers.some((specifier) => e.specifiers?.some((s) => (s.alias ? s.alias : s.name) === (specifier.alias ? specifier.alias : specifier.name)))))) if (isSetString(exportRef)) code += `${exportRef}\n`;
286
- else if (exportRef.name) {
287
- if (exportRef.all) code += `${exportRef.comment?.trim() ? exportRef.comment.trim() : ""}${exportRef.comment?.trim() ? "\n" : ""}export * from "${exportRef.name}";\n`;
288
- else if (exportRef.specifiers) {
289
- if (exportRef.comment?.trim()) code += `${exportRef.comment.trim()}\n`;
290
- code += `\texport${exportRef.specifiers.every((s) => s.type) ? " type" : ""} { ${exportRef.specifiers.map((s) => s.alias ? `${s.name} as ${s.alias}` : s.name).join(", ")} } from "${exportRef.name}";\n`;
291
- }
292
- } else code += `${exportRef.comment?.trim() ? exportRef.comment.trim() : ""}${exportRef.comment?.trim() ? "\n" : ""}${formatTypes(exportRef.text.replace(/\s*export\s*declare\s*/, "export ").replace(/\s*declare\s*/, " "))}\n`;
293
- mod.exports.filter((e) => !isString(e) && e.specifiers && commonDeclarations.some((commonDeclaration) => commonDeclaration.specifiers && commonDeclaration.specifiers.some((specifier) => e.specifiers?.some((s) => (s.alias ? s.alias : s.name) === (specifier.alias ? specifier.alias : specifier.name))))).forEach((e, i, arr) => {
294
- if (i === 0) code += "\nexport { ";
295
- else code += ", ";
296
- code += `${e?.specifiers?.filter((s) => commonDeclarations.some((commonDeclaration) => commonDeclaration.specifiers && commonDeclaration.specifiers.some((specifier) => (s.alias ? s.alias : s.name) === (specifier.alias ? specifier.alias : specifier.name)))).map((s) => s.alias ? `${s.name} as ${s.alias}` : s.name).join(", ") || ""}`;
297
- if (i === arr.length - 1) code += ` };\n`;
298
- });
299
- code += "}";
300
- code += "\n\n";
301
- }
302
- code = await format(context, context.typesPath, code);
303
- context.debug(`A TypeScript declaration file (size: ${prettyBytes(new Blob(toArray(code)).size)}) emitted for the built-in modules types.`);
304
- return {
305
- code,
306
- directives
307
- };
308
- }
309
-
310
- //#endregion
311
- //#region src/_internal/helpers/install.ts
312
- /**
313
- * Installs a package if it is not already installed.
314
- *
315
- * @param context - The resolved options
316
- * @param packageName - The name of the package to install
317
- * @param dev - Whether to install the package as a dev dependency
318
- */
319
- async function installPackage(context, packageName, dev = false) {
320
- if (!await isPackageListed(getPackageName(packageName), { cwd: context.config.root })) if (context.config.autoInstall) {
321
- context.warn(`The package "${packageName}" is not installed. It will be installed automatically.`);
322
- const result = await install(packageName, {
323
- cwd: context.config.root,
324
- dev
325
- });
326
- if (isNumber(result.exitCode) && result.exitCode > 0) {
327
- context.error(result.stderr);
328
- throw new Error(`An error occurred while installing the package "${packageName}"`);
329
- }
330
- } else context.warn(`The package "${packageName}" is not installed. Since the "autoInstall" option is set to false, it will not be installed automatically.`);
331
- else if (hasPackageVersion(packageName) && !process.env.POWERLINES_SKIP_VERSION_CHECK) {
332
- if (!await doesPackageMatch(getPackageName(packageName), getPackageVersion(packageName), context.config.root)) {
333
- const packageListing = await getPackageListing(getPackageName(packageName), { cwd: context.config.root });
334
- if (!packageListing?.version.startsWith("catalog:") && !packageListing?.version.startsWith("workspace:")) context.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.`);
335
- }
336
- }
337
- }
338
-
339
- //#endregion
340
- //#region src/_internal/helpers/install-dependencies.ts
341
- /**
342
- * Install missing project dependencies.
343
- *
344
- * @param context - The build context.
345
- */
346
- async function installDependencies(context) {
347
- context.debug(`Checking and installing missing project dependencies.`);
348
- context.dependencies ??= {};
349
- context.devDependencies ??= {};
350
- if (Object.keys(context.dependencies).length === 0 && Object.keys(context.devDependencies).length === 0) {
351
- context.debug(`No dependencies or devDependencies to install. Skipping installation step.`);
352
- return;
353
- }
354
- context.debug(`The following packages are required: \nDependencies: \n${Object.entries(context.dependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}\n\nDevDependencies: \n${Object.entries(context.devDependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}`);
355
- 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)))]);
356
- }
357
-
358
- //#endregion
359
- //#region src/_internal/helpers/resolve-tsconfig.ts
360
- function getTsconfigDtsPath(context) {
361
- return joinPaths(relativePath(joinPaths(context.options.cwd, context.options.root), findFilePath(context.typesPath)), findFileName(context.typesPath));
362
- }
363
- async function resolveTsconfigChanges(context) {
364
- const tsconfig = getParsedTypeScriptConfig(context.options.cwd, context.options.root, context.config.tsconfig, context.config.tsconfigRaw);
365
- const tsconfigJson = await readJsonFile(getTsconfigFilePath(context.options.cwd, context.options.root, context.config.tsconfig));
366
- tsconfigJson.compilerOptions ??= {};
367
- if (context.config.output.dts !== false) {
368
- const dtsRelativePath = getTsconfigDtsPath(context);
369
- if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [context.typesPath, dtsRelativePath]))) {
370
- tsconfigJson.include ??= [];
371
- tsconfigJson.include.push(dtsRelativePath.startsWith("./") ? dtsRelativePath.slice(2) : dtsRelativePath);
372
- }
373
- }
374
- if (!tsconfig.options.lib?.some((lib) => [
375
- "lib.esnext.d.ts",
376
- "lib.es2021.d.ts",
377
- "lib.es2022.d.ts",
378
- "lib.es2023.d.ts"
379
- ].includes(lib.toLowerCase()))) {
380
- tsconfigJson.compilerOptions.lib ??= [];
381
- tsconfigJson.compilerOptions.lib.push("esnext");
382
- }
383
- if (tsconfig.options.esModuleInterop !== true) tsconfigJson.compilerOptions.esModuleInterop = true;
384
- if (tsconfig.options.isolatedModules !== true) tsconfigJson.compilerOptions.isolatedModules = true;
385
- if (context.config.platform === "node") {
386
- if (!tsconfig.options.types?.some((type) => type.toLowerCase() === "node" || type.toLowerCase() === "@types/node")) {
387
- tsconfigJson.compilerOptions.types ??= [];
388
- tsconfigJson.compilerOptions.types.push("node");
389
- }
390
- }
391
- return tsconfigJson;
392
- }
393
- async function initializeTsconfig(context) {
394
- context.debug("Initializing TypeScript configuration (tsconfig.json) for the Powerlines project.");
395
- if (!isPackageExists("typescript")) throw new Error("The TypeScript package is not installed. Please install the package using the command: \"npm install typescript --save-dev\"");
396
- const tsconfigFilePath = getTsconfigFilePath(context.config.cwd, context.config.root, context.config.tsconfig);
397
- context.tsconfig.originalTsconfigJson = await readJsonFile(tsconfigFilePath);
398
- context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
399
- context.debug("Writing updated TypeScript configuration (tsconfig.json) file to disk.");
400
- await context.fs.write(tsconfigFilePath, StormJSON.stringify(context.tsconfig.tsconfigJson));
401
- context.tsconfig = getParsedTypeScriptConfig(context.config.cwd, context.config.root, context.config.tsconfig, context.config.tsconfigRaw, context.tsconfig.originalTsconfigJson);
402
- }
403
- async function resolveTsconfig(context) {
404
- const updateTsconfigJson = await readJsonFile(context.tsconfig.tsconfigFilePath);
405
- if (updateTsconfigJson?.compilerOptions?.types && Array.isArray(updateTsconfigJson.compilerOptions.types) && !updateTsconfigJson.compilerOptions.types.length) delete updateTsconfigJson.compilerOptions.types;
406
- const result = getObjectDiff(context.tsconfig.originalTsconfigJson, updateTsconfigJson, {
407
- ignoreArrayOrder: true,
408
- showOnly: {
409
- statuses: [
410
- "added",
411
- "deleted",
412
- "updated"
413
- ],
414
- granularity: "deep"
415
- }
416
- });
417
- const changes = [];
418
- const getChanges = (difference, property) => {
419
- 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);
420
- else changes.push({
421
- field: property ? `${property}.${difference.property}` : difference.property,
422
- status: difference.status,
423
- previous: difference.status === "added" ? "---" : StormJSON.stringify(difference.previousValue),
424
- current: difference.status === "deleted" ? "---" : StormJSON.stringify(difference.currentValue)
425
- });
426
- };
427
- for (const diff of result.diff) getChanges(diff);
428
- if (changes.length > 0) context.warn(`Updating the following configuration values in "${context.tsconfig.tsconfigFilePath}" file:
429
-
430
- ${changes.map((change, i) => `${chalk.bold.whiteBright(`${i + 1}. ${titleCase(change.status)} the ${change.field} field: `)}
431
- ${chalk.red(` - Previous: ${change.previous} `)}
432
- ${chalk.green(` - Updated: ${change.current} `)}
433
- `).join("\n")}
434
- `);
435
- await context.fs.write(context.tsconfig.tsconfigFilePath, StormJSON.stringify(updateTsconfigJson));
436
- context.tsconfig = getParsedTypeScriptConfig(context.config.cwd, context.config.root, context.config.tsconfig);
437
- if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
438
- }
439
-
440
- //#endregion
441
- //#region src/_internal/execution.ts
442
- /**
443
- * The Powerlines Execution API class
444
- *
445
- * @remarks
446
- * This class is responsible for managing the Powerlines project lifecycle, including initialization, building, and finalization.
447
- *
448
- * @internal
449
- */
450
- var PowerlinesExecution = class PowerlinesExecution {
451
- /**
452
- * The Powerlines context
453
- */
454
- #context;
455
- async #handleBuild(context) {
456
- await this.callHook("build", {
457
- environment: context,
458
- order: "pre"
459
- });
460
- context.debug("Formatting the generated entry files before the build process starts.");
461
- await formatFolder(context, context.entryPath);
462
- await this.callHook("build", {
463
- environment: context,
464
- order: "normal"
465
- });
466
- if (context.config.output.copy) {
467
- context.debug("Copying project's files from build output directory.");
468
- const destinationPath = isParentPath(appendPath(context.config.output.path, context.config.cwd), appendPath(context.config.root, context.config.cwd)) ? joinPaths(context.config.output.copy.path, relativePath(appendPath(context.config.root, context.config.cwd), appendPath(context.config.output.path, context.config.cwd))) : joinPaths(context.config.output.copy.path, "dist");
469
- const sourcePath = context.config.output.path;
470
- if (existsSync(sourcePath) && sourcePath !== destinationPath) {
471
- context.debug(`Copying files from project's build output directory (${context.config.output.path}) to the project's copy/publish directory (${destinationPath}).`);
472
- await copyFiles(sourcePath, destinationPath);
473
- } else context.warn(`The source path for the copy operation ${!existsSync(sourcePath) ? "does not exist" : "is the same as the destination path"}. Source: ${sourcePath}, Destination: ${destinationPath}. Skipping copying of build output files.`);
474
- if (context.config.output.copy.assets && Array.isArray(context.config.output.copy.assets)) await Promise.all(context.config.output.copy.assets.map(async (asset) => {
475
- context.trace(`Copying asset(s): ${chalk.redBright(context.config.cwd === asset.input ? asset.glob : appendPath(asset.glob, replacePath(asset.input, context.config.cwd)))} -> ${chalk.greenBright(appendPath(asset.glob, replacePath(asset.output, context.config.cwd)))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk.yellowBright(i)).join(", ")})` : ""}`);
476
- await context.fs.copy(asset, asset.output);
477
- }));
478
- } else context.debug("No copy configuration found for the project output. Skipping the copying of build output files.");
479
- await this.callHook("build", {
480
- environment: context,
481
- order: "post"
482
- });
483
- }
484
- /**
485
- * Get the configured environments
486
- *
487
- * @returns The configured environments
488
- */
489
- async #getEnvironments() {
490
- if (!this.context.config.environments || Object.keys(this.context.config.environments).length <= 1) {
491
- this.context.debug("No environments are configured for this Powerlines project. Using the default environment.");
492
- return [await this.context.getEnvironment()];
493
- }
494
- this.context.debug(`Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`);
495
- return (await Promise.all(Object.entries(this.context.config.environments).map(async ([name, config]) => {
496
- if (!await this.context.getEnvironmentSafe(name)) {
497
- const resolvedEnvironment = await this.callHook("configEnvironment", { environment: name }, name, config);
498
- if (resolvedEnvironment) this.context.environments[name] = await this.context.in(resolvedEnvironment);
499
- }
500
- return this.context.environments[name];
501
- }))).filter((context) => isSet(context));
502
- }
503
- /**
504
- * Execute a handler function for each environment
505
- *
506
- * @param handle - The handler function to execute for each environment
507
- */
508
- async #executeEnvironments(handle) {
509
- await Promise.all((await this.#getEnvironments()).map(async (context) => {
510
- return Promise.resolve(handle(context));
511
- }));
512
- }
513
- /**
514
- * Initialize a Powerlines plugin
515
- *
516
- * @param config - The configuration for the plugin
517
- * @returns The initialized plugin instance, or null if the plugin was a duplicate
518
- * @throws Will throw an error if the plugin cannot be found or is invalid
519
- */
520
- async #initPlugin(config) {
521
- let awaited = config;
522
- if (isPromiseLike(config)) awaited = await Promise.resolve(config);
523
- if (!isPluginConfig(awaited)) {
524
- const invalid = findInvalidPluginConfig(awaited);
525
- 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`);
526
- }
527
- let plugins;
528
- if (isPlugin(awaited)) plugins = [awaited];
529
- else if (isFunction(awaited)) plugins = toArray(await Promise.resolve(awaited()));
530
- else if (isString(awaited)) {
531
- const resolved = await this.#resolvePlugin(awaited);
532
- if (isFunction(resolved)) plugins = toArray(await Promise.resolve(resolved()));
533
- else plugins = toArray(resolved);
534
- } else if (Array.isArray(awaited) && awaited.every(isPlugin)) plugins = awaited;
535
- else if (Array.isArray(awaited) && awaited.every(isPluginConfig)) {
536
- plugins = [];
537
- for (const pluginConfig of awaited) {
538
- const initialized = await this.#initPlugin(pluginConfig);
539
- if (initialized) plugins.push(...initialized);
540
- }
541
- } else if (isPluginConfigTuple(awaited) || isPluginConfigObject(awaited)) {
542
- let pluginConfig;
543
- let pluginOptions;
544
- if (isPluginConfigTuple(awaited)) {
545
- pluginConfig = awaited[0];
546
- pluginOptions = awaited?.length === 2 ? awaited[1] : void 0;
547
- } else {
548
- pluginConfig = awaited.plugin;
549
- pluginOptions = awaited.options;
550
- }
551
- if (isSetString(pluginConfig)) {
552
- const resolved = await this.#resolvePlugin(pluginConfig);
553
- if (isFunction(resolved)) plugins = toArray(await Promise.resolve(pluginOptions ? resolved(pluginOptions) : resolved()));
554
- else plugins = toArray(resolved);
555
- } else if (isFunction(pluginConfig)) plugins = toArray(await Promise.resolve(pluginConfig(pluginOptions)));
556
- else if (Array.isArray(pluginConfig) && pluginConfig.every(isPlugin)) plugins = pluginConfig;
557
- else if (isPlugin(pluginConfig)) plugins = toArray(pluginConfig);
558
- }
559
- if (!plugins) throw new Error(`The plugin configuration ${JSON.stringify(awaited)} is invalid. This configuration must point to a valid Powerlines plugin module.`);
560
- if (plugins.length > 0 && !plugins.every(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.`);
561
- const result = [];
562
- for (const plugin of plugins) if (isDuplicate(plugin, this.context.plugins)) this.context.trace(`Duplicate ${chalk.bold.cyanBright(plugin.name)} plugin dependency detected - Skipping initialization.`);
563
- else {
564
- result.push(plugin);
565
- this.context.trace(`Initializing the ${chalk.bold.cyanBright(plugin.name)} plugin...`);
566
- }
567
- return result;
568
- }
569
- async #resolvePlugin(pluginPath) {
570
- if (pluginPath.startsWith("@") && pluginPath.split("/").filter(Boolean).length > 2) {
571
- const splits = pluginPath.split("/").filter(Boolean);
572
- pluginPath = `${splits[0]}/${splits[1]}`;
573
- }
574
- const isInstalled = isPackageExists(pluginPath, { paths: [this.context.config.cwd, this.context.config.root] });
575
- if (!isInstalled && this.context.config.autoInstall) {
576
- this.#context.warn(`The plugin package "${pluginPath}" is not installed. It will be installed automatically.`);
577
- const result = await install(pluginPath, { cwd: this.context.config.root });
578
- if (isNumber(result.exitCode) && result.exitCode > 0) {
579
- this.#context.error(result.stderr);
580
- throw new Error(`An error occurred while installing the build plugin package "${pluginPath}" `);
581
- }
582
- }
583
- try {
584
- const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(joinPaths(pluginPath, "plugin")));
585
- const result = module.plugin ?? module.default;
586
- if (!result) throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
587
- return result;
588
- } catch (error) {
589
- try {
590
- const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(pluginPath));
591
- const result = module.plugin ?? module.default;
592
- if (!result) throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
593
- return result;
594
- } catch {
595
- if (!isInstalled) throw new Error(`The plugin package "${pluginPath}" is not installed. Please install the package using the command: "npm install ${pluginPath} --save-dev"`);
596
- else throw new Error(`An error occurred while importing the build plugin package "${pluginPath}":
597
- ${isError(error) ? error.message : String(error)}
598
-
599
- 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\`.`);
600
- }
601
- }
602
- }
603
- /**
604
- * Generate the Powerlines TypeScript declaration file
605
- *
606
- * @remarks
607
- * This method will generate the TypeScript declaration file for the Powerlines project, including any types provided by plugins.
608
- *
609
- * @param context - The environment context to use for generating the TypeScript declaration file
610
- * @returns A promise that resolves when the TypeScript declaration file has been generated
611
- */
612
- async #types(context) {
613
- context.debug(`Preparing the TypeScript definitions for the Powerlines project.`);
614
- if (context.fs.existsSync(context.typesPath)) await context.fs.remove(context.typesPath);
615
- if (!await resolvePackage("typescript")) throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
616
- context.debug("Running TypeScript compiler for built-in runtime module files.");
617
- let { code, directives } = await emitBuiltinTypes(context, (await context.getBuiltins()).reduce((ret, builtin) => {
618
- const formatted = replacePath(builtin.path, context.config.cwd);
619
- if (!ret.includes(formatted)) ret.push(formatted);
620
- return ret;
621
- }, []));
622
- context.debug(`Generating TypeScript declaration file ${context.typesPath}.`);
623
- const merge = async (currentResult, previousResult) => {
624
- if (!isSetString(currentResult) && !isSetObject(currentResult) && !isSetString(previousResult) && !isSetObject(previousResult)) return {
625
- code,
626
- directives
627
- };
628
- const previous = (await format(context, context.typesPath, isSetString(previousResult) ? previousResult : isSetObject(previousResult) ? previousResult.code : "")).trim().replace(code, "").trim();
629
- const current = (await format(context, context.typesPath, isSetString(currentResult) ? currentResult : isSetObject(currentResult) ? currentResult.code : "")).trim().replace(previous, "").trim().replace(code, "").trim();
630
- return {
631
- directives: [...isSetObject(currentResult) && currentResult.directives ? currentResult.directives : [], ...isSetObject(previousResult) && previousResult.directives ? previousResult.directives : []],
632
- code: await format(context, context.typesPath, `${!previous.includes(getTypescriptFileHeader(context)) && !current.includes(getTypescriptFileHeader(context)) ? `${code}\n` : ""}${previous}\n${current}`.trim())
633
- };
634
- };
635
- const asNextParam = (previousResult) => isObject(previousResult) ? previousResult.code : previousResult;
636
- let result = await this.callHook("types", {
637
- environment: context,
638
- sequential: true,
639
- order: "pre",
640
- result: "merge",
641
- merge,
642
- asNextParam
643
- }, code);
644
- if (result) {
645
- if (isSetObject(result)) {
646
- code = result.code;
647
- if (Array.isArray(result.directives) && result.directives.length > 0) directives = getUnique([...directives, ...result.directives]).filter(Boolean);
648
- } else if (isSetString(result)) code = result;
649
- }
650
- result = await this.callHook("types", {
651
- environment: context,
652
- sequential: true,
653
- order: "normal",
654
- result: "merge",
655
- merge,
656
- asNextParam
657
- }, code);
658
- if (result) {
659
- if (isSetObject(result)) {
660
- code = result.code;
661
- if (Array.isArray(result.directives) && result.directives.length > 0) directives = getUnique([...directives, ...result.directives]).filter(Boolean);
662
- } else if (isSetString(result)) code = result;
663
- }
664
- result = await this.callHook("types", {
665
- environment: context,
666
- sequential: true,
667
- order: "post",
668
- result: "merge",
669
- merge,
670
- asNextParam
671
- }, code);
672
- if (result) {
673
- if (isSetObject(result)) {
674
- code = result.code;
675
- if (Array.isArray(result.directives) && result.directives.length > 0) directives = getUnique([...directives, ...result.directives]).filter(Boolean);
676
- } else if (isSetString(result)) code = result;
677
- }
678
- if (isSetString(code?.trim()) || directives.length > 0) await context.fs.write(context.typesPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
679
-
680
- ` : ""}${getTypescriptFileHeader(context, {
681
- directive: null,
682
- prettierIgnore: false
683
- })}
684
-
685
- ${formatTypes(code)}
686
- `);
687
- }
688
- /**
689
- * The Powerlines context
690
- */
691
- get context() {
692
- return this.#context;
693
- }
694
- /**
695
- * Initialize a Powerlines API instance
696
- *
697
- * @param options - The options to initialize the API with
698
- * @returns A new instance of the Powerlines API
699
- */
700
- static async fromConfig(options, config) {
701
- const api = new PowerlinesExecution(await PowerlinesExecutionContext.fromOptions(options));
702
- api.#context.config.inlineConfig = config;
703
- await api.#context.setup();
704
- api.#context.$$internal = {
705
- api,
706
- addPlugin: api.addPlugin.bind(api)
707
- };
708
- const timer = api.context.timer("Initialization");
709
- for (const plugin of api.context.config.plugins.flat(10) ?? []) await api.addPlugin(plugin);
710
- if (api.context.plugins.length === 0) api.context.warn("No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
711
- else api.context.info(`Loaded ${api.context.plugins.length} ${titleCase(api.context.config.framework)} plugin${api.context.plugins.length > 1 ? "s" : ""}: \n${api.context.plugins.map((plugin, index) => ` ${index + 1}. ${colorText(plugin.name)}`).join("\n")}`);
712
- const pluginConfig = await api.callHook("config", {
713
- environment: await api.context.getEnvironment(),
714
- sequential: true,
715
- result: "merge",
716
- merge: mergeConfigs
717
- });
718
- if (pluginConfig) {
719
- api.#context.config.pluginConfig = pluginConfig;
720
- await api.#context.setup();
721
- }
722
- timer();
723
- return api;
724
- }
725
- /**
726
- * Generate the Powerlines typescript declaration file
727
- *
728
- * @remarks
729
- * This method will only generate the typescript declaration file for the Powerlines project. It is generally recommended to run the full `prepare` command, which will run this method as part of its process.
730
- *
731
- * @param inlineConfig - The inline configuration for the types command
732
- */
733
- async types(inlineConfig = { command: "types" }) {
734
- this.context.debug(" Aggregating configuration options for the Powerlines project");
735
- inlineConfig.command ??= "types";
736
- this.context.config.inlineConfig = inlineConfig;
737
- await this.context.setup();
738
- await this.#executeEnvironments(async (context) => {
739
- context.debug(`Initializing the processing options for the Powerlines project.`);
740
- await this.callHook("configResolved", {
741
- environment: context,
742
- order: "pre"
743
- });
744
- await initializeTsconfig(context);
745
- await this.callHook("configResolved", {
746
- environment: context,
747
- order: "normal"
748
- });
749
- if (context.entry.length > 0) context.debug(`The configuration provided ${isObject(context.config.input) ? Object.keys(context.config.input).length : toArray(context.config.input).length} entry point(s), Powerlines has found ${context.entry.length} entry files(s) for the ${context.config.title} project${context.entry.length > 0 && context.entry.length < 10 ? `: \n${context.entry.map((entry) => `- ${entry.file}${entry.output ? ` -> ${entry.output}` : ""}`).join(" \n")}` : ""}`);
750
- else context.warn(`No entry files were found for the ${context.config.title} project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`);
751
- await resolveTsconfig(context);
752
- await installDependencies(context);
753
- await this.callHook("configResolved", {
754
- environment: context,
755
- order: "post"
756
- });
757
- context.trace(`Powerlines configuration has been resolved: \n\n${formatLogMessage({
758
- ...context.config,
759
- userConfig: isSetObject(context.config.userConfig) ? omit(context.config.userConfig, ["plugins"]) : void 0,
760
- inlineConfig: isSetObject(context.config.inlineConfig) ? omit(context.config.inlineConfig, ["plugins"]) : void 0,
761
- plugins: context.plugins.map((plugin) => plugin.plugin.name)
762
- })}`);
763
- if (!context.fs.existsSync(context.cachePath)) await createDirectory(context.cachePath);
764
- if (!context.fs.existsSync(context.dataPath)) await createDirectory(context.dataPath);
765
- if (context.config.skipCache === true || context.persistedMeta?.checksum !== context.meta.checksum) context.debug(`Using previously prepared files as the meta checksum has not changed.`);
766
- else {
767
- context.info(`Running \`prepare\` command as the meta checksum has changed since the last run.`);
768
- await this.prepare(defu({ output: { types: false } }, inlineConfig));
769
- }
770
- await this.#types(context);
771
- this.context.debug("Formatting files generated during the types step.");
772
- await format(context, context.typesPath, await context.fs.read(context.typesPath) ?? "");
773
- await writeMetaFile(context);
774
- context.persistedMeta = context.meta;
775
- });
776
- }
777
- /**
778
- * Prepare the Powerlines API
779
- *
780
- * @remarks
781
- * This method will prepare the Powerlines API for use, initializing any necessary resources.
782
- *
783
- * @param inlineConfig - The inline configuration for the prepare command
784
- */
785
- async prepare(inlineConfig = { command: "prepare" }) {
786
- inlineConfig.command ??= "prepare";
787
- this.context.config.inlineConfig = inlineConfig;
788
- await this.context.setup();
789
- await this.#executeEnvironments(async (context) => {
790
- context.debug(`Initializing the processing options for the Powerlines project.`);
791
- await this.callHook("configResolved", {
792
- environment: context,
793
- order: "pre"
794
- });
795
- await initializeTsconfig(context);
796
- await this.callHook("configResolved", {
797
- environment: context,
798
- order: "normal"
799
- });
800
- if (context.entry.length > 0) context.debug(`The configuration provided ${isObject(context.config.input) ? Object.keys(context.config.input).length : toArray(context.config.input).length} entry point(s), Powerlines has found ${context.entry.length} entry files(s) for the ${context.config.title} project${context.entry.length > 0 && context.entry.length < 10 ? `: \n${context.entry.map((entry) => `- ${entry.file}${entry.output ? ` -> ${entry.output}` : ""}`).join(" \n")}` : ""}`);
801
- else context.warn(`No entry files were found for the ${context.config.title} project. Please ensure this is correct. Powerlines plugins generally require at least one entry point to function properly.`);
802
- await resolveTsconfig(context);
803
- await installDependencies(context);
804
- await this.callHook("configResolved", {
805
- environment: context,
806
- order: "post"
807
- });
808
- context.trace(`Powerlines configuration has been resolved: \n\n${formatLogMessage({
809
- ...context.config,
810
- userConfig: isSetObject(context.config.userConfig) ? omit(context.config.userConfig, ["plugins"]) : void 0,
811
- inlineConfig: isSetObject(context.config.inlineConfig) ? omit(context.config.inlineConfig, ["plugins"]) : void 0,
812
- plugins: context.plugins.map((plugin) => plugin.plugin.name)
813
- })}`);
814
- if (!context.fs.existsSync(context.cachePath)) await createDirectory(context.cachePath);
815
- if (!context.fs.existsSync(context.dataPath)) await createDirectory(context.dataPath);
816
- await this.callHook("prepare", {
817
- environment: context,
818
- order: "pre"
819
- });
820
- await this.callHook("prepare", {
821
- environment: context,
822
- order: "normal"
823
- });
824
- await this.callHook("prepare", {
825
- environment: context,
826
- order: "post"
827
- });
828
- if (context.config.output.types !== false) await this.#types(context);
829
- this.context.debug("Formatting files generated during the prepare step.");
830
- await Promise.all([formatFolder(context, context.builtinsPath), formatFolder(context, context.entryPath)]);
831
- await writeMetaFile(context);
832
- context.persistedMeta = context.meta;
833
- });
834
- }
835
- /**
836
- * Create a new Powerlines project
837
- *
838
- * @remarks
839
- * This method will create a new Powerlines project in the current directory.
840
- *
841
- * @param inlineConfig - The inline configuration for the new command
842
- * @returns A promise that resolves when the project has been created
843
- */
844
- async new(inlineConfig) {
845
- inlineConfig.command ??= "new";
846
- await this.prepare(inlineConfig);
847
- await this.#executeEnvironments(async (context) => {
848
- context.debug("Initializing the processing options for the Powerlines project.");
849
- await this.callHook("new", {
850
- environment: context,
851
- order: "pre"
852
- });
853
- const files = await listFiles(joinPaths(context.powerlinesPath, "files/common/**/*.hbs"));
854
- for (const file of files) {
855
- context.trace(`Adding template file to project: ${file}`);
856
- const template = Handlebars.compile(file);
857
- await context.fs.write(joinPaths(context.config.root, file.replace(".hbs", "")), template(context));
858
- }
859
- await this.callHook("new", {
860
- environment: context,
861
- order: "normal"
862
- });
863
- if (context.config.projectType === "application") {
864
- const files = await listFiles(joinPaths(context.powerlinesPath, "files/application/**/*.hbs"));
865
- for (const file of files) {
866
- context.trace(`Adding application template file: ${file}`);
867
- const template = Handlebars.compile(file);
868
- await context.fs.write(joinPaths(context.config.root, file.replace(".hbs", "")), template(context));
869
- }
870
- } else {
871
- const files = await listFiles(joinPaths(context.powerlinesPath, "files/library/**/*.hbs"));
872
- for (const file of files) {
873
- context.trace(`Adding library template file: ${file}`);
874
- const template = Handlebars.compile(file);
875
- await context.fs.write(joinPaths(context.config.root, file.replace(".hbs", "")), template(context));
876
- }
877
- }
878
- await this.callHook("new", {
879
- environment: context,
880
- order: "post"
881
- });
882
- });
883
- }
884
- /**
885
- * Clean any previously prepared artifacts
886
- *
887
- * @remarks
888
- * This method will remove the previous Powerlines artifacts from the project.
889
- *
890
- * @param inlineConfig - The inline configuration for the clean command
891
- * @returns A promise that resolves when the clean command has completed
892
- */
893
- async clean(inlineConfig = { command: "clean" }) {
894
- inlineConfig.command ??= "clean";
895
- await this.prepare(inlineConfig);
896
- await this.#executeEnvironments(async (context) => {
897
- context.debug("Cleaning the project's dist and artifacts directories.");
898
- await context.fs.remove(joinPaths(context.config.cwd, context.config.output.path));
899
- await context.fs.remove(joinPaths(context.config.cwd, context.config.root, context.config.output.artifactsPath));
900
- await this.callHook("clean", {
901
- environment: context,
902
- sequential: false
903
- });
904
- });
905
- }
906
- /**
907
- * Lint the project
908
- *
909
- * @param inlineConfig - The inline configuration for the lint command
910
- * @returns A promise that resolves when the lint command has completed
911
- */
912
- async lint(inlineConfig = { command: "lint" }) {
913
- inlineConfig.command ??= "lint";
914
- await this.prepare(inlineConfig);
915
- await this.#executeEnvironments(async (context) => {
916
- await this.callHook("lint", {
917
- environment: context,
918
- sequential: false
919
- });
920
- });
921
- }
922
- /**
923
- * Test the project source code
924
- *
925
- * @param inlineConfig - The inline configuration for the test command
926
- * @returns A promise that resolves when the test command has completed
927
- */
928
- async test(inlineConfig = { command: "test" }) {
929
- inlineConfig.command ??= "test";
930
- await this.prepare(inlineConfig);
931
- await this.#executeEnvironments(async (context) => {
932
- await this.callHook("test", {
933
- environment: context,
934
- sequential: false
935
- });
936
- });
937
- }
938
- /**
939
- * Build the project
940
- *
941
- * @remarks
942
- * This method will build the Powerlines project, generating the necessary artifacts.
943
- *
944
- * @param inlineConfig - The inline configuration for the build command
945
- * @returns A promise that resolves when the build command has completed
946
- */
947
- async build(inlineConfig = { command: "build" }) {
948
- inlineConfig.command ??= "build";
949
- await this.context.generateChecksum();
950
- if (this.context.meta.checksum !== this.context.persistedMeta?.checksum || this.context.config.skipCache) {
951
- this.context.info(!this.context.persistedMeta?.checksum ? "No previous build cache found. Preparing the project for the initial build." : this.context.meta.checksum !== this.context.persistedMeta.checksum ? "The project has been modified since the last time `prepare` was ran. Re-preparing the project." : "The project is configured to skip cache. Re-preparing the project.");
952
- await this.prepare(inlineConfig);
953
- } else {
954
- this.context.config.inlineConfig = inlineConfig;
955
- await this.context.setup();
956
- }
957
- if (this.context.config.singleBuild) await this.#handleBuild(await this.#context.toEnvironment());
958
- else await this.#executeEnvironments(async (context) => {
959
- await this.#handleBuild(context);
960
- });
961
- }
962
- /**
963
- * Prepare the documentation for the project
964
- *
965
- * @param inlineConfig - The inline configuration for the docs command
966
- * @returns A promise that resolves when the documentation generation has completed
967
- */
968
- async docs(inlineConfig = { command: "docs" }) {
969
- inlineConfig.command ??= "docs";
970
- await this.prepare(inlineConfig);
971
- await this.#executeEnvironments(async (context) => {
972
- context.debug("Writing documentation for the Powerlines project artifacts.");
973
- await this.callHook("docs", { environment: context });
974
- });
975
- }
976
- /**
977
- * Deploy the project source code
978
- *
979
- * @remarks
980
- * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
981
- *
982
- * @param inlineConfig - The inline configuration for the deploy command
983
- */
984
- async deploy(inlineConfig = { command: "deploy" }) {
985
- inlineConfig.command ??= "deploy";
986
- await this.prepare(inlineConfig);
987
- await this.#executeEnvironments(async (context) => {
988
- await this.callHook("deploy", { environment: context });
989
- });
990
- }
991
- /**
992
- * Finalization/cleanup processing for the Powerlines API
993
- *
994
- * @remarks
995
- * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
996
- *
997
- * @returns A promise that resolves when the finalization process has completed
998
- */
999
- async finalize() {
1000
- await this.#executeEnvironments(async (context) => {
1001
- await this.callHook("finalize", { environment: context });
1002
- await context.fs.dispose();
1003
- if (existsSync(context.cachePath) && !(await listFiles(joinPaths(context.cachePath, "**/*")))?.length) await removeDirectory(context.cachePath);
1004
- });
1005
- }
1006
- /**
1007
- * Invokes the configured plugin hooks
1008
- *
1009
- * @remarks
1010
- * By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
1011
- *
1012
- * @param hook - The hook to call
1013
- * @param options - The options to provide to the hook
1014
- * @param args - The arguments to pass to the hook
1015
- * @returns The result of the hook call
1016
- */
1017
- async callHook(hook, options, ...args) {
1018
- return callHook(isSetObject(options?.environment) ? options.environment : await this.#context.getEnvironment(options?.environment), hook, {
1019
- sequential: true,
1020
- ...options
1021
- }, ...args);
1022
- }
1023
- /**
1024
- * Create a new Powerlines API instance
1025
- *
1026
- * @param context - The Powerlines context
1027
- */
1028
- constructor(context) {
1029
- this.#context = context;
1030
- }
1031
- /**
1032
- * Add a Powerlines plugin used in the build process
1033
- *
1034
- * @param config - The import path of the plugin to add
1035
- */
1036
- async addPlugin(config) {
1037
- if (config) {
1038
- const result = await this.#initPlugin(config);
1039
- if (!result) return;
1040
- for (const plugin of result) {
1041
- this.context.debug(`Successfully initialized the ${chalk.bold.cyanBright(plugin.name)} plugin`);
1042
- await this.context.addPlugin(plugin);
1043
- }
1044
- }
1045
- }
1046
- };
1047
-
1048
- //#endregion
1049
- //#region src/api.ts
1050
- /**
1051
- * The Powerlines API class
1052
- *
1053
- * @remarks
1054
- * This class is responsible for managing the Powerlines project lifecycle, including initialization, building, and finalization.
1055
- *
1056
- * @public
1057
- */
1058
- var PowerlinesAPI = class PowerlinesAPI extends PowerlinesExecution {
1059
- /**
1060
- * Create a new Powerlines API instance
1061
- *
1062
- * @param context - The Powerlines context
1063
- */
1064
- constructor(context) {
1065
- super(context);
1066
- }
1067
- /**
1068
- * Initialize a Powerlines API instance
1069
- *
1070
- * @param options - The options to initialize the API with
1071
- * @returns A new instance of the Powerlines API
1072
- */
1073
- static async fromOptions(options, override) {
1074
- const api = new PowerlinesAPI(await PowerlinesExecutionContext.fromOptions({
1075
- cwd: process.cwd(),
1076
- mode: isDevelopment ? "development" : isTest ? "test" : "production",
1077
- framework: "powerlines",
1078
- ...options,
1079
- configIndex: 0
1080
- }));
1081
- if (override) {
1082
- api.context.config.inlineConfig = override;
1083
- await api.context.setup();
1084
- }
1085
- api.context.$$internal = {
1086
- api,
1087
- addPlugin: api.addPlugin.bind(api)
1088
- };
1089
- const timer = api.context.timer("Initialization");
1090
- for (const plugin of api.context.config.plugins.flat(10) ?? []) await api.addPlugin(plugin);
1091
- if (api.context.plugins.length === 0) api.context.warn("No Powerlines plugins were specified in the options. Please ensure this is correct, as it is generally not recommended.");
1092
- else api.context.info(`Loaded ${api.context.plugins.length} ${titleCase(api.context.config.framework)} plugin${api.context.plugins.length > 1 ? "s" : ""}: \n${api.context.plugins.map((plugin, index) => ` ${index + 1}. ${colorText(plugin.name)}`).join("\n")}`);
1093
- const pluginConfig = await api.callHook("config", {
1094
- environment: await api.context.getEnvironment(),
1095
- sequential: true,
1096
- result: "merge",
1097
- merge: mergeConfigs
1098
- });
1099
- if (isSetObject(pluginConfig)) {
1100
- api.context.config.pluginConfig = pluginConfig;
1101
- await api.context.setup();
1102
- }
1103
- timer();
1104
- return api;
1105
- }
1106
- /**
1107
- * Generate the Powerlines typescript declaration file
1108
- *
1109
- * @remarks
1110
- * This method will only generate the typescript declaration file for the Powerlines project. It is generally recommended to run the full `prepare` command, which will run this method as part of its process.
1111
- *
1112
- * @param inlineConfig - The inline configuration for the types command
1113
- */
1114
- async types(inlineConfig = { command: "types" }) {
1115
- const timer = this.context.timer("Types");
1116
- this.context.info(" ๐Ÿ—๏ธ Generating typescript declarations for the Powerlines project");
1117
- await super.types(inlineConfig);
1118
- this.context.debug("โœ” Powerlines types generation has completed successfully");
1119
- timer();
1120
- }
1121
- /**
1122
- * Prepare the Powerlines API
1123
- *
1124
- * @remarks
1125
- * This method will prepare the Powerlines API for use, initializing any necessary resources.
1126
- *
1127
- * @param inlineConfig - The inline configuration for the prepare command
1128
- */
1129
- async prepare(inlineConfig = { command: "prepare" }) {
1130
- const timer = this.context.timer("Prepare");
1131
- this.context.info(" ๐Ÿ—๏ธ Preparing the Powerlines project");
1132
- this.context.debug(" Aggregating configuration options for the Powerlines project");
1133
- await super.prepare(inlineConfig);
1134
- this.context.debug("โœ” Powerlines preparation has completed successfully");
1135
- timer();
1136
- }
1137
- /**
1138
- * Create a new Powerlines project
1139
- *
1140
- * @remarks
1141
- * This method will create a new Powerlines project in the current directory.
1142
- *
1143
- * @param inlineConfig - The inline configuration for the new command
1144
- * @returns A promise that resolves when the project has been created
1145
- */
1146
- async new(inlineConfig) {
1147
- const timer = this.context.timer("New");
1148
- this.context.info(" ๐Ÿ†• Creating a new Powerlines project");
1149
- await super.new(inlineConfig);
1150
- this.context.debug("โœ” Powerlines new command completed successfully");
1151
- timer();
1152
- }
1153
- /**
1154
- * Clean any previously prepared artifacts
1155
- *
1156
- * @remarks
1157
- * This method will remove the previous Powerlines artifacts from the project.
1158
- *
1159
- * @param inlineConfig - The inline configuration for the clean command
1160
- * @returns A promise that resolves when the clean command has completed
1161
- */
1162
- async clean(inlineConfig = { command: "clean" }) {
1163
- const timer = this.context.timer("Clean");
1164
- this.context.info(" ๐Ÿงน Cleaning the previous Powerlines artifacts");
1165
- await super.clean(inlineConfig);
1166
- this.context.debug("โœ” Powerlines cleaning completed successfully");
1167
- timer();
1168
- }
1169
- /**
1170
- * Lint the project
1171
- *
1172
- * @param inlineConfig - The inline configuration for the lint command
1173
- * @returns A promise that resolves when the lint command has completed
1174
- */
1175
- async lint(inlineConfig = { command: "lint" }) {
1176
- const timer = this.context.timer("Lint");
1177
- this.context.info(" ๐Ÿ“ Linting the Powerlines project");
1178
- await super.lint(inlineConfig);
1179
- this.context.debug("โœ” Powerlines linting completed successfully");
1180
- timer();
1181
- }
1182
- /**
1183
- * Test the project
1184
- *
1185
- * @remarks
1186
- * This method will run the tests for the Powerlines project.
1187
- *
1188
- * @param inlineConfig - The inline configuration for the test command
1189
- * @returns A promise that resolves when the test command has completed
1190
- */
1191
- async test(inlineConfig = { command: "test" }) {
1192
- const timer = this.context.timer("Test");
1193
- this.context.info(" ๐Ÿงช Running tests for the Powerlines project");
1194
- await super.test(inlineConfig);
1195
- this.context.debug("โœ” Powerlines testing completed successfully");
1196
- timer();
1197
- }
1198
- /**
1199
- * Build the project
1200
- *
1201
- * @remarks
1202
- * This method will build the Powerlines project, generating the necessary artifacts.
1203
- *
1204
- * @param inlineConfig - The inline configuration for the build command
1205
- * @returns A promise that resolves when the build command has completed
1206
- */
1207
- async build(inlineConfig = { command: "build" }) {
1208
- const timer = this.context.timer("Build");
1209
- this.context.info(" ๐Ÿ“ฆ Building the Powerlines project");
1210
- await super.build(inlineConfig);
1211
- this.context.debug("โœ” Powerlines build completed successfully");
1212
- timer();
1213
- }
1214
- /**
1215
- * Prepare the documentation for the project
1216
- *
1217
- * @param inlineConfig - The inline configuration for the docs command
1218
- * @returns A promise that resolves when the documentation generation has completed
1219
- */
1220
- async docs(inlineConfig = { command: "docs" }) {
1221
- const timer = this.context.timer("Docs");
1222
- this.context.info(" ๐Ÿ““ Generating documentation for the Powerlines project");
1223
- await super.docs(inlineConfig);
1224
- this.context.debug("โœ” Powerlines documentation generation completed successfully");
1225
- timer();
1226
- }
1227
- /**
1228
- * Deploy the project source code
1229
- *
1230
- * @remarks
1231
- * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
1232
- *
1233
- * @param inlineConfig - The inline configuration for the deploy command
1234
- */
1235
- async deploy(inlineConfig = { command: "deploy" }) {
1236
- const timer = this.context.timer("Deploy");
1237
- this.context.info(" ๐Ÿš€ Deploying the Powerlines project");
1238
- await super.deploy(inlineConfig);
1239
- this.context.debug("โœ” Powerlines deploy completed successfully");
1240
- timer();
1241
- }
1242
- /**
1243
- * Finalization/cleanup processing for the Powerlines API
1244
- *
1245
- * @remarks
1246
- * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
1247
- *
1248
- * @returns A promise that resolves when the finalization process has completed
1249
- */
1250
- async finalize() {
1251
- const timer = this.context.timer("Finalization");
1252
- this.context.info(" ๐Ÿ Powerlines finalization processes started");
1253
- await super.finalize();
1254
- this.context.debug("โœ” Powerlines finalization completed successfully");
1255
- timer();
1256
- }
1257
- /**
1258
- * Dispose of the Powerlines API instance
1259
- *
1260
- * @remarks
1261
- * This method will finalize the Powerlines API instance, cleaning up any resources used.
1262
- */
1263
- async [Symbol.asyncDispose]() {
1264
- await this.finalize();
1265
- }
1266
- };
1267
-
1268
- //#endregion
1269
- export { PowerlinesAPI };
1270
- //# sourceMappingURL=api.mjs.map