@powerlines/engine 0.47.3 → 0.49.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 (249) 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 +28 -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 +24 -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 +24 -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 +27 -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 +68 -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 +27 -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 +70 -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-BgyEi2hF.d.mts +138 -0
  65. package/dist/api-BgyEi2hF.d.mts.map +1 -0
  66. package/dist/api-DcHfCjQK.d.cts +138 -0
  67. package/dist/api-DcHfCjQK.d.cts.map +1 -0
  68. package/dist/api.cjs +39 -1268
  69. package/dist/api.d.cts +11 -300
  70. package/dist/api.d.cts.map +1 -1
  71. package/dist/api.d.mts +11 -300
  72. package/dist/api.d.mts.map +1 -1
  73. package/dist/api.mjs +31 -1264
  74. package/dist/api.mjs.map +1 -1
  75. package/dist/config-ByLyzMI0.d.mts +204 -0
  76. package/dist/config-ByLyzMI0.d.mts.map +1 -0
  77. package/dist/config-DKEmqMrh.d.cts +204 -0
  78. package/dist/config-DKEmqMrh.d.cts.map +1 -0
  79. package/dist/context/engine-context.cjs +177 -0
  80. package/dist/context/engine-context.d.cts +2 -0
  81. package/dist/context/engine-context.d.mts +2 -0
  82. package/dist/context/engine-context.mjs +175 -0
  83. package/dist/context/engine-context.mjs.map +1 -0
  84. package/dist/context/index.cjs +2 -9
  85. package/dist/context/index.d.cts +2 -150
  86. package/dist/context/index.d.mts +2 -150
  87. package/dist/context/index.mjs +2 -4
  88. package/dist/context-D0_a0kRO.d.cts +149 -0
  89. package/dist/context-D0_a0kRO.d.cts.map +1 -0
  90. package/dist/context-DcXV6_GL.d.mts +149 -0
  91. package/dist/context-DcXV6_GL.d.mts.map +1 -0
  92. package/dist/engine-Dz6BvkFY.cjs +590 -0
  93. package/dist/engine-context-B8K6Jtkk.d.cts +53 -0
  94. package/dist/engine-context-B8K6Jtkk.d.cts.map +1 -0
  95. package/dist/engine-context-DKlA5Pgu.d.mts +53 -0
  96. package/dist/engine-context-DKlA5Pgu.d.mts.map +1 -0
  97. package/dist/engine-q6YKXXcB.mjs +571 -0
  98. package/dist/engine-q6YKXXcB.mjs.map +1 -0
  99. package/dist/engine.cjs +6 -0
  100. package/dist/engine.d.cts +143 -0
  101. package/dist/engine.d.cts.map +1 -0
  102. package/dist/engine.d.mts +143 -0
  103. package/dist/engine.d.mts.map +1 -0
  104. package/dist/engine.mjs +3 -0
  105. package/dist/helpers/create-execution-host.cjs +57 -0
  106. package/dist/helpers/create-execution-host.d.cts +20 -0
  107. package/dist/helpers/create-execution-host.d.cts.map +1 -0
  108. package/dist/helpers/create-execution-host.d.mts +20 -0
  109. package/dist/helpers/create-execution-host.d.mts.map +1 -0
  110. package/dist/helpers/create-execution-host.mjs +57 -0
  111. package/dist/helpers/create-execution-host.mjs.map +1 -0
  112. package/dist/helpers/finalize.cjs +26 -0
  113. package/dist/helpers/finalize.d.cts +12 -0
  114. package/dist/helpers/finalize.d.cts.map +1 -0
  115. package/dist/helpers/finalize.d.mts +12 -0
  116. package/dist/helpers/finalize.d.mts.map +1 -0
  117. package/dist/helpers/finalize.mjs +26 -0
  118. package/dist/helpers/finalize.mjs.map +1 -0
  119. package/dist/helpers/index.cjs +12 -0
  120. package/dist/helpers/index.d.cts +5 -0
  121. package/dist/helpers/index.d.mts +5 -0
  122. package/dist/helpers/index.mjs +6 -0
  123. package/dist/helpers/rpc.cjs +139 -0
  124. package/dist/helpers/rpc.d.cts +7 -0
  125. package/dist/helpers/rpc.d.cts.map +1 -0
  126. package/dist/helpers/rpc.d.mts +7 -0
  127. package/dist/helpers/rpc.d.mts.map +1 -0
  128. package/dist/helpers/rpc.mjs +139 -0
  129. package/dist/helpers/rpc.mjs.map +1 -0
  130. package/dist/helpers/stream.cjs +119 -0
  131. package/dist/helpers/stream.d.cts +45 -0
  132. package/dist/helpers/stream.d.cts.map +1 -0
  133. package/dist/helpers/stream.d.mts +45 -0
  134. package/dist/helpers/stream.d.mts.map +1 -0
  135. package/dist/helpers/stream.mjs +117 -0
  136. package/dist/helpers/stream.mjs.map +1 -0
  137. package/dist/index-BVVgDSdq.d.cts +1 -0
  138. package/dist/index-BVVgDSdq.d.mts +1 -0
  139. package/dist/index.cjs +8 -748
  140. package/dist/index.d.cts +6 -140
  141. package/dist/index.d.mts +6 -140
  142. package/dist/index.mjs +4 -747
  143. package/package.json +102 -132
  144. package/dist/_internal/worker.cjs +0 -5192
  145. package/dist/_internal/worker.d.cts +0 -46
  146. package/dist/_internal/worker.d.cts.map +0 -1
  147. package/dist/_internal/worker.d.mts +0 -46
  148. package/dist/_internal/worker.d.mts.map +0 -1
  149. package/dist/_internal/worker.mjs +0 -5153
  150. package/dist/_internal/worker.mjs.map +0 -1
  151. package/dist/base-context-DLemGRbd.cjs +0 -322
  152. package/dist/base-context-DUha4Lz-.mjs +0 -315
  153. package/dist/base-context-DUha4Lz-.mjs.map +0 -1
  154. package/dist/context/index.d.cts.map +0 -1
  155. package/dist/context/index.d.mts.map +0 -1
  156. package/dist/engine-context-BfFiKN53.mjs +0 -86
  157. package/dist/engine-context-BfFiKN53.mjs.map +0 -1
  158. package/dist/engine-context-D0y88i_J.cjs +0 -91
  159. package/dist/execution-context-CE5H90Um.mjs +0 -2845
  160. package/dist/execution-context-CE5H90Um.mjs.map +0 -1
  161. package/dist/execution-context-CnyaM3Ul.cjs +0 -2889
  162. package/dist/execution-context-NyDjVZ6T.d.cts +0 -647
  163. package/dist/execution-context-NyDjVZ6T.d.cts.map +0 -1
  164. package/dist/execution-context-YrjFeD9k.d.mts +0 -647
  165. package/dist/execution-context-YrjFeD9k.d.mts.map +0 -1
  166. package/dist/fs-CeEdzPKE.cjs +0 -262
  167. package/dist/fs-Dcle8lUp.mjs +0 -226
  168. package/dist/fs-Dcle8lUp.mjs.map +0 -1
  169. package/dist/index.d.cts.map +0 -1
  170. package/dist/index.d.mts.map +0 -1
  171. package/dist/index.mjs.map +0 -1
  172. package/dist/rpc/client.cjs +0 -74
  173. package/dist/rpc/client.d.cts +0 -31
  174. package/dist/rpc/client.d.cts.map +0 -1
  175. package/dist/rpc/client.d.mts +0 -31
  176. package/dist/rpc/client.d.mts.map +0 -1
  177. package/dist/rpc/client.mjs +0 -71
  178. package/dist/rpc/client.mjs.map +0 -1
  179. package/dist/rpc/serialization.cjs +0 -82
  180. package/dist/rpc/serialization.d.cts +0 -46
  181. package/dist/rpc/serialization.d.cts.map +0 -1
  182. package/dist/rpc/serialization.d.mts +0 -46
  183. package/dist/rpc/serialization.d.mts.map +0 -1
  184. package/dist/rpc/serialization.mjs +0 -76
  185. package/dist/rpc/serialization.mjs.map +0 -1
  186. package/dist/rpc/server.cjs +0 -69
  187. package/dist/rpc/server.d.cts +0 -29
  188. package/dist/rpc/server.d.cts.map +0 -1
  189. package/dist/rpc/server.d.mts +0 -29
  190. package/dist/rpc/server.d.mts.map +0 -1
  191. package/dist/rpc/server.mjs +0 -66
  192. package/dist/rpc/server.mjs.map +0 -1
  193. package/dist/rpc/types.cjs +0 -0
  194. package/dist/rpc/types.d.cts +0 -70
  195. package/dist/rpc/types.d.cts.map +0 -1
  196. package/dist/rpc/types.d.mts +0 -70
  197. package/dist/rpc/types.d.mts.map +0 -1
  198. package/dist/rpc/types.mjs +0 -1
  199. package/dist/schemas.cjs +0 -9
  200. package/dist/schemas.d.cts +0 -127
  201. package/dist/schemas.d.cts.map +0 -1
  202. package/dist/schemas.d.mts +0 -127
  203. package/dist/schemas.d.mts.map +0 -1
  204. package/dist/schemas.mjs +0 -3
  205. package/dist/storage/base.cjs +0 -216
  206. package/dist/storage/base.d.cts +0 -199
  207. package/dist/storage/base.d.cts.map +0 -1
  208. package/dist/storage/base.d.mts +0 -199
  209. package/dist/storage/base.d.mts.map +0 -1
  210. package/dist/storage/base.mjs +0 -215
  211. package/dist/storage/base.mjs.map +0 -1
  212. package/dist/storage/file-system.cjs +0 -180
  213. package/dist/storage/file-system.d.cts +0 -127
  214. package/dist/storage/file-system.d.cts.map +0 -1
  215. package/dist/storage/file-system.d.mts +0 -127
  216. package/dist/storage/file-system.d.mts.map +0 -1
  217. package/dist/storage/file-system.mjs +0 -179
  218. package/dist/storage/file-system.mjs.map +0 -1
  219. package/dist/storage/helpers.cjs +0 -37
  220. package/dist/storage/helpers.d.cts +0 -25
  221. package/dist/storage/helpers.d.cts.map +0 -1
  222. package/dist/storage/helpers.d.mts +0 -25
  223. package/dist/storage/helpers.d.mts.map +0 -1
  224. package/dist/storage/helpers.mjs +0 -34
  225. package/dist/storage/helpers.mjs.map +0 -1
  226. package/dist/storage/index.cjs +0 -12
  227. package/dist/storage/index.d.cts +0 -5
  228. package/dist/storage/index.d.mts +0 -5
  229. package/dist/storage/index.mjs +0 -6
  230. package/dist/storage/virtual.cjs +0 -98
  231. package/dist/storage/virtual.d.cts +0 -80
  232. package/dist/storage/virtual.d.cts.map +0 -1
  233. package/dist/storage/virtual.d.mts +0 -80
  234. package/dist/storage/virtual.d.mts.map +0 -1
  235. package/dist/storage/virtual.mjs +0 -97
  236. package/dist/storage/virtual.mjs.map +0 -1
  237. package/dist/ts-morph-BbM83PT9.cjs +0 -114
  238. package/dist/ts-morph-C6YBNc46.mjs +0 -102
  239. package/dist/ts-morph-C6YBNc46.mjs.map +0 -1
  240. package/dist/tsconfig-DeKMGasE.cjs +0 -198
  241. package/dist/tsconfig-HzJsMUrr.mjs +0 -155
  242. package/dist/tsconfig-HzJsMUrr.mjs.map +0 -1
  243. package/dist/typescript/index.cjs +0 -13
  244. package/dist/typescript/index.d.cts +0 -106
  245. package/dist/typescript/index.d.cts.map +0 -1
  246. package/dist/typescript/index.d.mts +0 -106
  247. package/dist/typescript/index.d.mts.map +0 -1
  248. package/dist/typescript/index.mjs +0 -4
  249. /package/dist/{chunk-C0xms8kb.cjs → chunk-C_NdSu1c.cjs} +0 -0
@@ -1,322 +0,0 @@
1
- const require_chunk = require('./chunk-C0xms8kb.cjs');
2
- let _powerlines_core_plugin_utils = require("@powerlines/core/plugin-utils");
3
- let _powerlines_core_plugin_utils_logging = require("@powerlines/core/plugin-utils/logging");
4
- let _stryke_fs_resolve = require("@stryke/fs/resolve");
5
- let _stryke_path_append = require("@stryke/path/append");
6
- let _stryke_path_join_paths = require("@stryke/path/join-paths");
7
- let _stryke_path_replace = require("@stryke/path/replace");
8
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
9
- let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
10
- let chalk = require("chalk");
11
- chalk = require_chunk.__toESM(chalk, 1);
12
- let defu = require("defu");
13
- defu = require_chunk.__toESM(defu, 1);
14
- let _stryke_env_get_env_paths = require("@stryke/env/get-env-paths");
15
- let node_fs = require("node:fs");
16
- let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
17
- let _powerlines_core_lib_config = require("@powerlines/core/lib/config");
18
- let _storm_software_config_tools_get_config = require("@storm-software/config-tools/get-config");
19
- let _stryke_env_environment_checks = require("@stryke/env/environment-checks");
20
- let _stryke_fs = require("@stryke/fs");
21
- let _stryke_path = require("@stryke/path");
22
- let date_fns_formatDistanceToNowStrict = require("date-fns/formatDistanceToNowStrict");
23
- let jiti = require("jiti");
24
-
25
- //#region src/_internal/helpers/resolver.ts
26
- /**
27
- * Create a Jiti resolver for the given workspace and project root.
28
- *
29
- * @param options - The options for creating the resolver.
30
- * @returns A Jiti instance configured for the specified workspace and project root.
31
- */
32
- function resolveOptions(options) {
33
- return (0, defu.default)(options, {
34
- interopDefault: true,
35
- fsCache: options.mode !== "development" ? (0, _stryke_path_join_paths.joinPaths)(options.cacheDir, "jiti") : false,
36
- moduleCache: options.mode !== "development"
37
- });
38
- }
39
- /**
40
- * Create a Jiti resolver for the given workspace and project root.
41
- *
42
- * @param options - The options for creating the resolver.
43
- * @returns A Jiti instance configured for the specified workspace and project root.
44
- */
45
- function createResolver(options) {
46
- const baseResolver = (0, jiti.createJiti)((0, _stryke_path_join_paths.joinPaths)(options.workspaceRoot, options.root), resolveOptions(options));
47
- baseResolver.plugin = (0, jiti.createJiti)((0, _stryke_path_join_paths.joinPaths)(options.workspaceRoot, options.root), resolveOptions(options));
48
- return baseResolver;
49
- }
50
-
51
- //#endregion
52
- //#region src/context/base-context.ts
53
- var PowerlinesBaseContext = class {
54
- #timestamp = Date.now();
55
- /**
56
- * The path to the Powerlines package
57
- */
58
- powerlinesPath;
59
- /**
60
- * The module resolver for the project
61
- */
62
- resolver;
63
- /**
64
- * The options provided to the Powerlines process, resolved with default values and merged with any configuration provided by plugins or other sources. This is typically the final configuration used during the build process, but may also include additional options that are relevant to the context and its interactions with the Powerlines engine.
65
- */
66
- options;
67
- /**
68
- * The parsed `package.json` file for the project
69
- */
70
- packageJson;
71
- /**
72
- * The parsed `project.json` file for the project
73
- */
74
- projectJson = void 0;
75
- /**
76
- * The parsed configuration file for the project
77
- */
78
- configFile;
79
- /**
80
- * The logger instance for the context, which can be used to create log messages with consistent formatting and metadata. This logger is extended by plugin contexts to include additional metadata such as the plugin name and category, which can be used to filter and format log messages in a more granular way.
81
- */
82
- get logger() {
83
- return this.createLogger({});
84
- }
85
- /**
86
- * A timestamp representing when the context was initialized
87
- */
88
- get timestamp() {
89
- return this.#timestamp;
90
- }
91
- get logLevel() {
92
- return (0, _powerlines_core_plugin_utils.resolveLogLevel)(this.options.logLevel, this.options.mode);
93
- }
94
- /**
95
- * The environment paths for the project
96
- */
97
- get envPaths() {
98
- return (0, _stryke_env_get_env_paths.getEnvPaths)({
99
- orgId: this.options.organization,
100
- appId: this.options.framework || "powerlines",
101
- workspaceRoot: this.options.cwd
102
- });
103
- }
104
- /**
105
- * A logging function for fatal messages
106
- *
107
- * @param message - The message to log.
108
- */
109
- fatal(message) {
110
- this.logger.error(message);
111
- }
112
- /**
113
- * A logging function for error messages
114
- *
115
- * @param message - The message to log.
116
- */
117
- error(message) {
118
- this.logger.error(message);
119
- }
120
- /**
121
- * A logging function for warning messages
122
- *
123
- * @param message - The message to log.
124
- */
125
- warn(message) {
126
- this.logger.warn(message);
127
- }
128
- /**
129
- * A logging function for informational messages
130
- *
131
- * @param message - The message to log.
132
- */
133
- info(message) {
134
- this.logger.info(message);
135
- }
136
- /**
137
- * A logging function for debug messages
138
- *
139
- * @param message - The message to log.
140
- */
141
- debug(message) {
142
- this.logger.debug(message);
143
- }
144
- /**
145
- * A logging function for trace messages
146
- *
147
- * @param message - The message to log.
148
- */
149
- trace(message) {
150
- this.logger.trace(message);
151
- }
152
- /**
153
- * A function to create a timer for measuring the duration of asynchronous operations
154
- *
155
- * @example
156
- * ```ts
157
- * const stopTimer = context.timer("Your Async Operation");
158
- * await performAsyncOperation();
159
- * stopTimer(); // "Your Async Operation completed in 123.45 milliseconds"
160
- * ```
161
- *
162
- * @param name - The name of the timer.
163
- * @returns A function that, when called, stops the timer and logs the duration.
164
- */
165
- timer(name) {
166
- const startDate = Date.now();
167
- const startDuration = performance.now();
168
- return () => {
169
- const duration = performance.now() - startDuration;
170
- this.logger.info({
171
- meta: { category: "performance" },
172
- message: `${chalk.default.bold.cyanBright(name)} completed in ${chalk.default.bold.cyanBright(duration < 1e3 ? `${duration.toFixed(2)} milliseconds` : (0, date_fns_formatDistanceToNowStrict.formatDistanceToNowStrict)(startDate))}`
173
- });
174
- };
175
- }
176
- /**
177
- * Create a new logger instance
178
- *
179
- * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
180
- * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.
181
- * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
182
- */
183
- createLogger(options, logFn) {
184
- return (0, _powerlines_core_plugin_utils_logging.createLogger)(this.options.name || this.options.root || "powerlines", {
185
- ...this.configFile.config,
186
- ...this.options,
187
- ...options
188
- }, logFn);
189
- }
190
- /**
191
- * Extend the base logger with additional configuration options
192
- *
193
- * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
194
- * @returns A new logger client instance that extends the base logger with the provided configuration options.
195
- */
196
- extendLogger(options) {
197
- return (0, _powerlines_core_plugin_utils_logging.extendLogger)(this.logger, options);
198
- }
199
- /**
200
- * The input options used to initialize the context, which may be used when cloning the context to ensure the same configuration is applied to the new context
201
- */
202
- initialOptions = {};
203
- /**
204
- * The initial configuration provided when initializing the context, which may be used during the setup process to ensure that the configuration is properly merged and applied to the context. This is typically the user configuration provided in the Powerlines configuration file, but may also include additional configuration options provided by plugins or other sources.
205
- */
206
- initialConfig = {};
207
- /**
208
- * Initialize the context with the provided configuration options and set up the resolver and user configuration file. This method is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup as the original context.
209
- *
210
- * @param options - The configuration options to initialize the context with, which can include properties such as the project root, mode, log level, and other settings that affect the behavior of the context and its plugins.
211
- * @param initialConfig - The initial configuration to initialize the context with, which is typically the user configuration provided in the Powerlines configuration file. This can also include additional configuration options provided by plugins or other sources that should be merged with the user configuration during initialization
212
- */
213
- constructor(options, initialConfig = {}) {
214
- this.initialOptions = options;
215
- this.initialConfig = initialConfig;
216
- }
217
- /**
218
- * Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.
219
- *
220
- * @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
221
- */
222
- async getWorkspaceConfig() {
223
- return (0, _storm_software_config_tools_get_config.tryGetWorkspaceConfig)(false, this.options || this.initialOptions ? {
224
- cwd: this.options?.root || this.initialOptions?.root ? (0, _stryke_path_append.appendPath)(this.options?.root || this.initialOptions?.root || ".", this.options?.cwd || this.initialOptions?.cwd) : void 0,
225
- workspaceRoot: this.options?.cwd || this.initialOptions?.cwd
226
- } : void 0);
227
- }
228
- /**
229
- * Initialize the context with the provided configuration options
230
- *
231
- * @remarks
232
- * This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
233
- */
234
- async init() {
235
- if (!this.powerlinesPath) {
236
- const powerlinesPath = await (0, _stryke_fs_resolve.resolvePackage)("powerlines");
237
- if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
238
- this.powerlinesPath = powerlinesPath;
239
- }
240
- this.options = (0, defu.default)(this.initialOptions, this.initialConfig, {
241
- cwd: process.cwd(),
242
- mode: await this.getDefaultMode(),
243
- logLevel: await this.getDefaultLogLevel(),
244
- framework: "powerlines"
245
- });
246
- if (!this.options.root) if (this.options.configFile) {
247
- const configFile = (0, _stryke_path_append.appendPath)(this.options.configFile, this.options.cwd);
248
- if (!(0, node_fs.existsSync)(configFile)) throw new Error(`The user-provided configuration file at "${this.options.configFile}" does not exist. Please ensure this path is correct and try again.`);
249
- if (!(0, _stryke_fs.isFile)(configFile)) throw new Error(`The user-provided configuration file at "${this.options.configFile}" is not a file. Please ensure this path is correct and try again.`);
250
- this.options.root = (0, _stryke_path.relativePath)(this.options.cwd, (0, _stryke_path.findFilePath)(configFile));
251
- } else this.options.root = ".";
252
- else this.options.root = (0, _stryke_path_replace.replacePath)(this.options.root, this.options.cwd);
253
- this.resolver = createResolver({
254
- workspaceRoot: this.options.cwd,
255
- root: this.options.root,
256
- cacheDir: this.envPaths.cache,
257
- mode: this.options.mode
258
- });
259
- await this.resolvePackageConfigs();
260
- this.configFile = await (0, _powerlines_core_lib_config.loadUserConfigFile)(this.options, this.resolver);
261
- if (this.configFile.config) {
262
- if ((0, _stryke_type_checks_is_set_string.isSetString)(this.configFile.configFile)) this.options.configFile ??= (0, _stryke_path_replace.replacePath)(this.configFile.configFile, this.options.cwd);
263
- if (!this.options.name) {
264
- if ((0, _stryke_type_checks_is_set_object.isSetObject)(this.configFile.config) && (0, _stryke_type_checks_is_set_string.isSetString)(this.configFile.config.name)) this.options.name = this.configFile.config.name;
265
- else if (Array.isArray(this.configFile.config)) {
266
- for (const config of this.configFile.config) if ((0, _stryke_type_checks_is_set_object.isSetObject)(config) && (0, _stryke_type_checks_is_set_string.isSetString)(config.name)) {
267
- this.options.name = config.name;
268
- break;
269
- }
270
- }
271
- }
272
- if (!this.options.name) this.options.name = this.projectJson?.name || this.packageJson?.name;
273
- }
274
- }
275
- /**
276
- * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
277
- *
278
- * @remarks
279
- * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
280
- *
281
- * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
282
- * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
283
- * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
284
- */
285
- async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
286
- if (cwd || root) {
287
- const projectJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root || ".", cwd || "."), "project.json");
288
- if ((0, node_fs.existsSync)(projectJsonPath)) this.projectJson = await (0, _stryke_fs.readJsonFile)(projectJsonPath);
289
- const packageJsonPath = (0, _stryke_path.joinPaths)((0, _stryke_path_append.appendPath)(root || ".", cwd || "."), "package.json");
290
- if ((0, node_fs.existsSync)(packageJsonPath)) {
291
- this.packageJson = await (0, _stryke_fs.readJsonFile)(packageJsonPath);
292
- this.options.organization ??= (0, _stryke_type_checks_is_set_object.isSetObject)(this.packageJson?.author) ? (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author?.name) : (0, _stryke_string_format_kebab_case.kebabCase)(this.packageJson?.author);
293
- }
294
- }
295
- }
296
- /**
297
- * Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to "production".
298
- *
299
- * @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
300
- */
301
- async getDefaultMode() {
302
- const workspaceConfig = await this.getWorkspaceConfig();
303
- return _stryke_env_environment_checks.isProduction ? "production" : _stryke_env_environment_checks.isDevelopment ? "development" : _stryke_env_environment_checks.isTest ? "test" : workspaceConfig?.mode || "production";
304
- }
305
- /**
306
- * Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to "info" for development mode and "warn" for production mode.
307
- *
308
- * @returns A promise that resolves to the default log level for the current execution, which can be "fatal", "error", "warn", "info", "debug", or "trace".
309
- */
310
- async getDefaultLogLevel() {
311
- const workspaceConfig = await this.getWorkspaceConfig();
312
- return (0, _powerlines_core_plugin_utils.resolveLogLevel)(workspaceConfig?.logLevel ? workspaceConfig.logLevel === "success" || workspaceConfig.logLevel === "performance" ? "info" : workspaceConfig.logLevel === "all" ? "debug" : workspaceConfig.logLevel === "fatal" ? "error" : workspaceConfig.logLevel : void 0, this.options?.mode || this.initialOptions?.mode || workspaceConfig?.mode || await this.getDefaultMode());
313
- }
314
- };
315
-
316
- //#endregion
317
- Object.defineProperty(exports, 'PowerlinesBaseContext', {
318
- enumerable: true,
319
- get: function () {
320
- return PowerlinesBaseContext;
321
- }
322
- });
@@ -1,315 +0,0 @@
1
- import { resolveLogLevel } from "@powerlines/core/plugin-utils";
2
- import { createLogger as createLogger$1, extendLogger } from "@powerlines/core/plugin-utils/logging";
3
- import { resolvePackage } from "@stryke/fs/resolve";
4
- import { appendPath } from "@stryke/path/append";
5
- import { joinPaths } from "@stryke/path/join-paths";
6
- import { replacePath } from "@stryke/path/replace";
7
- import { isSetObject } from "@stryke/type-checks/is-set-object";
8
- import { isSetString } from "@stryke/type-checks/is-set-string";
9
- import chalk from "chalk";
10
- import defu from "defu";
11
- import { getEnvPaths } from "@stryke/env/get-env-paths";
12
- import { existsSync } from "node:fs";
13
- import { kebabCase } from "@stryke/string-format/kebab-case";
14
- import { loadUserConfigFile } from "@powerlines/core/lib/config";
15
- import { tryGetWorkspaceConfig } from "@storm-software/config-tools/get-config";
16
- import { isDevelopment, isProduction, isTest } from "@stryke/env/environment-checks";
17
- import { isFile, readJsonFile } from "@stryke/fs";
18
- import { findFilePath, joinPaths as joinPaths$1, relativePath } from "@stryke/path";
19
- import { formatDistanceToNowStrict } from "date-fns/formatDistanceToNowStrict";
20
- import { createJiti } from "jiti";
21
-
22
- //#region src/_internal/helpers/resolver.ts
23
- /**
24
- * Create a Jiti resolver for the given workspace and project root.
25
- *
26
- * @param options - The options for creating the resolver.
27
- * @returns A Jiti instance configured for the specified workspace and project root.
28
- */
29
- function resolveOptions(options) {
30
- return defu(options, {
31
- interopDefault: true,
32
- fsCache: options.mode !== "development" ? joinPaths(options.cacheDir, "jiti") : false,
33
- moduleCache: options.mode !== "development"
34
- });
35
- }
36
- /**
37
- * Create a Jiti resolver for the given workspace and project root.
38
- *
39
- * @param options - The options for creating the resolver.
40
- * @returns A Jiti instance configured for the specified workspace and project root.
41
- */
42
- function createResolver(options) {
43
- const baseResolver = createJiti(joinPaths(options.workspaceRoot, options.root), resolveOptions(options));
44
- baseResolver.plugin = createJiti(joinPaths(options.workspaceRoot, options.root), resolveOptions(options));
45
- return baseResolver;
46
- }
47
-
48
- //#endregion
49
- //#region src/context/base-context.ts
50
- var PowerlinesBaseContext = class {
51
- #timestamp = Date.now();
52
- /**
53
- * The path to the Powerlines package
54
- */
55
- powerlinesPath;
56
- /**
57
- * The module resolver for the project
58
- */
59
- resolver;
60
- /**
61
- * The options provided to the Powerlines process, resolved with default values and merged with any configuration provided by plugins or other sources. This is typically the final configuration used during the build process, but may also include additional options that are relevant to the context and its interactions with the Powerlines engine.
62
- */
63
- options;
64
- /**
65
- * The parsed `package.json` file for the project
66
- */
67
- packageJson;
68
- /**
69
- * The parsed `project.json` file for the project
70
- */
71
- projectJson = void 0;
72
- /**
73
- * The parsed configuration file for the project
74
- */
75
- configFile;
76
- /**
77
- * The logger instance for the context, which can be used to create log messages with consistent formatting and metadata. This logger is extended by plugin contexts to include additional metadata such as the plugin name and category, which can be used to filter and format log messages in a more granular way.
78
- */
79
- get logger() {
80
- return this.createLogger({});
81
- }
82
- /**
83
- * A timestamp representing when the context was initialized
84
- */
85
- get timestamp() {
86
- return this.#timestamp;
87
- }
88
- get logLevel() {
89
- return resolveLogLevel(this.options.logLevel, this.options.mode);
90
- }
91
- /**
92
- * The environment paths for the project
93
- */
94
- get envPaths() {
95
- return getEnvPaths({
96
- orgId: this.options.organization,
97
- appId: this.options.framework || "powerlines",
98
- workspaceRoot: this.options.cwd
99
- });
100
- }
101
- /**
102
- * A logging function for fatal messages
103
- *
104
- * @param message - The message to log.
105
- */
106
- fatal(message) {
107
- this.logger.error(message);
108
- }
109
- /**
110
- * A logging function for error messages
111
- *
112
- * @param message - The message to log.
113
- */
114
- error(message) {
115
- this.logger.error(message);
116
- }
117
- /**
118
- * A logging function for warning messages
119
- *
120
- * @param message - The message to log.
121
- */
122
- warn(message) {
123
- this.logger.warn(message);
124
- }
125
- /**
126
- * A logging function for informational messages
127
- *
128
- * @param message - The message to log.
129
- */
130
- info(message) {
131
- this.logger.info(message);
132
- }
133
- /**
134
- * A logging function for debug messages
135
- *
136
- * @param message - The message to log.
137
- */
138
- debug(message) {
139
- this.logger.debug(message);
140
- }
141
- /**
142
- * A logging function for trace messages
143
- *
144
- * @param message - The message to log.
145
- */
146
- trace(message) {
147
- this.logger.trace(message);
148
- }
149
- /**
150
- * A function to create a timer for measuring the duration of asynchronous operations
151
- *
152
- * @example
153
- * ```ts
154
- * const stopTimer = context.timer("Your Async Operation");
155
- * await performAsyncOperation();
156
- * stopTimer(); // "Your Async Operation completed in 123.45 milliseconds"
157
- * ```
158
- *
159
- * @param name - The name of the timer.
160
- * @returns A function that, when called, stops the timer and logs the duration.
161
- */
162
- timer(name) {
163
- const startDate = Date.now();
164
- const startDuration = performance.now();
165
- return () => {
166
- const duration = performance.now() - startDuration;
167
- this.logger.info({
168
- meta: { category: "performance" },
169
- message: `${chalk.bold.cyanBright(name)} completed in ${chalk.bold.cyanBright(duration < 1e3 ? `${duration.toFixed(2)} milliseconds` : formatDistanceToNowStrict(startDate))}`
170
- });
171
- };
172
- }
173
- /**
174
- * Create a new logger instance
175
- *
176
- * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
177
- * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.
178
- * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
179
- */
180
- createLogger(options, logFn) {
181
- return createLogger$1(this.options.name || this.options.root || "powerlines", {
182
- ...this.configFile.config,
183
- ...this.options,
184
- ...options
185
- }, logFn);
186
- }
187
- /**
188
- * Extend the base logger with additional configuration options
189
- *
190
- * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
191
- * @returns A new logger client instance that extends the base logger with the provided configuration options.
192
- */
193
- extendLogger(options) {
194
- return extendLogger(this.logger, options);
195
- }
196
- /**
197
- * The input options used to initialize the context, which may be used when cloning the context to ensure the same configuration is applied to the new context
198
- */
199
- initialOptions = {};
200
- /**
201
- * The initial configuration provided when initializing the context, which may be used during the setup process to ensure that the configuration is properly merged and applied to the context. This is typically the user configuration provided in the Powerlines configuration file, but may also include additional configuration options provided by plugins or other sources.
202
- */
203
- initialConfig = {};
204
- /**
205
- * Initialize the context with the provided configuration options and set up the resolver and user configuration file. This method is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup as the original context.
206
- *
207
- * @param options - The configuration options to initialize the context with, which can include properties such as the project root, mode, log level, and other settings that affect the behavior of the context and its plugins.
208
- * @param initialConfig - The initial configuration to initialize the context with, which is typically the user configuration provided in the Powerlines configuration file. This can also include additional configuration options provided by plugins or other sources that should be merged with the user configuration during initialization
209
- */
210
- constructor(options, initialConfig = {}) {
211
- this.initialOptions = options;
212
- this.initialConfig = initialConfig;
213
- }
214
- /**
215
- * Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.
216
- *
217
- * @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
218
- */
219
- async getWorkspaceConfig() {
220
- return tryGetWorkspaceConfig(false, this.options || this.initialOptions ? {
221
- cwd: this.options?.root || this.initialOptions?.root ? appendPath(this.options?.root || this.initialOptions?.root || ".", this.options?.cwd || this.initialOptions?.cwd) : void 0,
222
- workspaceRoot: this.options?.cwd || this.initialOptions?.cwd
223
- } : void 0);
224
- }
225
- /**
226
- * Initialize the context with the provided configuration options
227
- *
228
- * @remarks
229
- * This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
230
- */
231
- async init() {
232
- if (!this.powerlinesPath) {
233
- const powerlinesPath = await resolvePackage("powerlines");
234
- if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
235
- this.powerlinesPath = powerlinesPath;
236
- }
237
- this.options = defu(this.initialOptions, this.initialConfig, {
238
- cwd: process.cwd(),
239
- mode: await this.getDefaultMode(),
240
- logLevel: await this.getDefaultLogLevel(),
241
- framework: "powerlines"
242
- });
243
- if (!this.options.root) if (this.options.configFile) {
244
- const configFile = appendPath(this.options.configFile, this.options.cwd);
245
- if (!existsSync(configFile)) throw new Error(`The user-provided configuration file at "${this.options.configFile}" does not exist. Please ensure this path is correct and try again.`);
246
- if (!isFile(configFile)) throw new Error(`The user-provided configuration file at "${this.options.configFile}" is not a file. Please ensure this path is correct and try again.`);
247
- this.options.root = relativePath(this.options.cwd, findFilePath(configFile));
248
- } else this.options.root = ".";
249
- else this.options.root = replacePath(this.options.root, this.options.cwd);
250
- this.resolver = createResolver({
251
- workspaceRoot: this.options.cwd,
252
- root: this.options.root,
253
- cacheDir: this.envPaths.cache,
254
- mode: this.options.mode
255
- });
256
- await this.resolvePackageConfigs();
257
- this.configFile = await loadUserConfigFile(this.options, this.resolver);
258
- if (this.configFile.config) {
259
- if (isSetString(this.configFile.configFile)) this.options.configFile ??= replacePath(this.configFile.configFile, this.options.cwd);
260
- if (!this.options.name) {
261
- if (isSetObject(this.configFile.config) && isSetString(this.configFile.config.name)) this.options.name = this.configFile.config.name;
262
- else if (Array.isArray(this.configFile.config)) {
263
- for (const config of this.configFile.config) if (isSetObject(config) && isSetString(config.name)) {
264
- this.options.name = config.name;
265
- break;
266
- }
267
- }
268
- }
269
- if (!this.options.name) this.options.name = this.projectJson?.name || this.packageJson?.name;
270
- }
271
- }
272
- /**
273
- * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
274
- *
275
- * @remarks
276
- * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
277
- *
278
- * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
279
- * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
280
- * @returns A promise that resolves when the package configurations have been loaded and stored in the context.
281
- */
282
- async resolvePackageConfigs(cwd = this.options.cwd, root = this.options.root) {
283
- if (cwd || root) {
284
- const projectJsonPath = joinPaths$1(appendPath(root || ".", cwd || "."), "project.json");
285
- if (existsSync(projectJsonPath)) this.projectJson = await readJsonFile(projectJsonPath);
286
- const packageJsonPath = joinPaths$1(appendPath(root || ".", cwd || "."), "package.json");
287
- if (existsSync(packageJsonPath)) {
288
- this.packageJson = await readJsonFile(packageJsonPath);
289
- this.options.organization ??= isSetObject(this.packageJson?.author) ? kebabCase(this.packageJson?.author?.name) : kebabCase(this.packageJson?.author);
290
- }
291
- }
292
- }
293
- /**
294
- * Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to "production".
295
- *
296
- * @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
297
- */
298
- async getDefaultMode() {
299
- const workspaceConfig = await this.getWorkspaceConfig();
300
- return isProduction ? "production" : isDevelopment ? "development" : isTest ? "test" : workspaceConfig?.mode || "production";
301
- }
302
- /**
303
- * Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to "info" for development mode and "warn" for production mode.
304
- *
305
- * @returns A promise that resolves to the default log level for the current execution, which can be "fatal", "error", "warn", "info", "debug", or "trace".
306
- */
307
- async getDefaultLogLevel() {
308
- const workspaceConfig = await this.getWorkspaceConfig();
309
- return resolveLogLevel(workspaceConfig?.logLevel ? workspaceConfig.logLevel === "success" || workspaceConfig.logLevel === "performance" ? "info" : workspaceConfig.logLevel === "all" ? "debug" : workspaceConfig.logLevel === "fatal" ? "error" : workspaceConfig.logLevel : void 0, this.options?.mode || this.initialOptions?.mode || workspaceConfig?.mode || await this.getDefaultMode());
310
- }
311
- };
312
-
313
- //#endregion
314
- export { PowerlinesBaseContext as t };
315
- //# sourceMappingURL=base-context-DUha4Lz-.mjs.map