@storm-software/unbuild 0.41.21 → 0.41.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/bin/unbuild.cjs +798 -412
- package/bin/unbuild.js +826 -420
- package/dist/build.cjs +8 -8
- package/dist/build.js +7 -7
- package/dist/{chunk-3GQAWCBQ.js → chunk-3RG5ZIWI.js} +0 -3
- package/dist/{chunk-HZNOKNKE.js → chunk-4KHUAP4R.js} +13 -10
- package/dist/{chunk-BFBEOACU.cjs → chunk-ALGMIE4E.cjs} +471 -257
- package/dist/{chunk-5FQ2QYFQ.js → chunk-ATN45QRM.js} +418 -204
- package/dist/{chunk-F4MPFQDI.cjs → chunk-FAW45G3E.cjs} +13 -10
- package/dist/{chunk-3BXXHK3F.cjs → chunk-MO3MUSJO.cjs} +7 -15
- package/dist/chunk-OBGZSXTJ.cjs +10 -0
- package/dist/{chunk-DUDE4LYM.js → chunk-PCGRQKDH.js} +2 -10
- package/dist/{chunk-PWE7CANF.cjs → chunk-Q2G4VMOW.cjs} +198 -130
- package/dist/{chunk-ITHOVA3D.cjs → chunk-Q3NBYYR4.cjs} +4 -12
- package/dist/{chunk-ZB2JWLJS.cjs → chunk-Q4VUCJPK.cjs} +51 -16
- package/dist/chunk-WQLDD6CA.js +106 -0
- package/dist/{chunk-3BDIPKMO.js → chunk-XQLLOGJZ.js} +197 -129
- package/dist/{chunk-SMAV5VSP.js → chunk-XWLZOFQ4.js} +6 -14
- package/dist/clean.cjs +4 -4
- package/dist/clean.js +3 -3
- package/dist/index.cjs +9 -9
- package/dist/index.js +8 -8
- package/dist/plugins/analyze.cjs +4 -4
- package/dist/plugins/analyze.js +3 -3
- package/dist/plugins/on-error.cjs +4 -4
- package/dist/plugins/on-error.js +3 -3
- package/dist/plugins/swc.cjs +5 -8
- package/dist/plugins/swc.js +4 -7
- package/dist/plugins/tsc.cjs +4 -4
- package/dist/plugins/tsc.js +3 -3
- package/dist/plugins/type-definitions.cjs +9 -6
- package/dist/plugins/type-definitions.js +9 -6
- package/dist/types.cjs +1 -1
- package/dist/types.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-BGYQAVKQ.cjs +0 -13
- package/dist/chunk-XXRSY6EE.js +0 -71
- /package/dist/{chunk-OULCUN6I.js → chunk-GGNOJ77I.js} +0 -0
- /package/dist/{chunk-ORA4UQMU.cjs → chunk-SFZRYJZ2.cjs} +0 -0
package/bin/unbuild.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
2
|
|
|
5
3
|
// ../config/src/schema.ts
|
|
6
4
|
import z from "zod";
|
|
@@ -102,23 +100,39 @@ var RegistryConfigSchema = z.object({
|
|
|
102
100
|
cyclone: RegistryUrlConfigSchema,
|
|
103
101
|
container: RegistryUrlConfigSchema
|
|
104
102
|
}).default({}).describe("A list of remote registry URLs used by Storm Software");
|
|
105
|
-
var ColorConfigSchema = SingleThemeColorConfigSchema.or(
|
|
103
|
+
var ColorConfigSchema = SingleThemeColorConfigSchema.or(
|
|
104
|
+
MultiThemeColorConfigSchema
|
|
105
|
+
).describe("Colors used for various workspace elements");
|
|
106
106
|
var ColorConfigMapSchema = z.union([
|
|
107
|
-
z.object({
|
|
108
|
-
base: ColorConfigSchema
|
|
109
|
-
}),
|
|
107
|
+
z.object({ base: ColorConfigSchema }),
|
|
110
108
|
z.record(z.string(), ColorConfigSchema)
|
|
111
109
|
]);
|
|
112
|
-
var ExtendsItemSchema = z.string().trim().describe(
|
|
113
|
-
|
|
110
|
+
var ExtendsItemSchema = z.string().trim().describe(
|
|
111
|
+
"The path to a base config file to use as a configuration preset file. Documentation can be found at https://github.com/unjs/c12#extending-configuration."
|
|
112
|
+
);
|
|
113
|
+
var ExtendsSchema = ExtendsItemSchema.or(
|
|
114
|
+
z.array(ExtendsItemSchema)
|
|
115
|
+
).describe(
|
|
116
|
+
"The path to a base config file to use as a configuration preset file. Documentation can be found at https://github.com/unjs/c12#extending-configuration."
|
|
117
|
+
);
|
|
114
118
|
var WorkspaceBotConfigSchema = z.object({
|
|
115
|
-
name: z.string().trim().default("stormie-bot").describe(
|
|
119
|
+
name: z.string().trim().default("stormie-bot").describe(
|
|
120
|
+
"The workspace bot user's name (this is the bot that will be used to perform various tasks)"
|
|
121
|
+
),
|
|
116
122
|
email: z.string().trim().email().default("bot@stormsoftware.com").describe("The email of the workspace bot")
|
|
117
|
-
}).describe(
|
|
123
|
+
}).describe(
|
|
124
|
+
"The workspace's bot user's config used to automated various operations tasks"
|
|
125
|
+
);
|
|
118
126
|
var WorkspaceReleaseConfigSchema = z.object({
|
|
119
|
-
banner: z.string().trim().default(STORM_DEFAULT_RELEASE_BANNER).describe(
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
banner: z.string().trim().default(STORM_DEFAULT_RELEASE_BANNER).describe(
|
|
128
|
+
"A URL to a banner image used to display the workspace's release"
|
|
129
|
+
),
|
|
130
|
+
header: z.string().trim().optional().describe(
|
|
131
|
+
"A header message appended to the start of the workspace's release notes"
|
|
132
|
+
),
|
|
133
|
+
footer: z.string().trim().default(STORM_DEFAULT_RELEASE_FOOTER).describe(
|
|
134
|
+
"A footer message appended to the end of the workspace's release notes"
|
|
135
|
+
)
|
|
122
136
|
}).describe("The workspace's release config used during the release process");
|
|
123
137
|
var WorkspaceAccountConfigSchema = z.object({
|
|
124
138
|
twitter: z.string().trim().default(STORM_DEFAULT_ACCOUNT_TWITTER).describe("A Twitter/X account associated with the organization/project"),
|
|
@@ -127,23 +141,41 @@ var WorkspaceAccountConfigSchema = z.object({
|
|
|
127
141
|
slack: z.string().trim().default(STORM_DEFAULT_ACCOUNT_SLACK).describe("A Slack account associated with the organization/project"),
|
|
128
142
|
medium: z.string().trim().default(STORM_DEFAULT_ACCOUNT_MEDIUM).describe("A Medium account associated with the organization/project"),
|
|
129
143
|
github: z.string().trim().default(STORM_DEFAULT_ACCOUNT_GITHUB).describe("A GitHub account associated with the organization/project")
|
|
130
|
-
}).describe(
|
|
144
|
+
}).describe(
|
|
145
|
+
"The workspace's account config used to store various social media links"
|
|
146
|
+
);
|
|
131
147
|
var WorkspaceDirectoryConfigSchema = z.object({
|
|
132
|
-
cache: z.string().trim().optional().describe(
|
|
148
|
+
cache: z.string().trim().optional().describe(
|
|
149
|
+
"The directory used to store the environment's cached file data"
|
|
150
|
+
),
|
|
133
151
|
data: z.string().trim().optional().describe("The directory used to store the environment's data files"),
|
|
134
|
-
config: z.string().trim().optional().describe(
|
|
152
|
+
config: z.string().trim().optional().describe(
|
|
153
|
+
"The directory used to store the environment's configuration files"
|
|
154
|
+
),
|
|
135
155
|
temp: z.string().trim().optional().describe("The directory used to store the environment's temp files"),
|
|
136
156
|
log: z.string().trim().optional().describe("The directory used to store the environment's temp files"),
|
|
137
|
-
build: z.string().trim().default("dist").describe(
|
|
138
|
-
|
|
157
|
+
build: z.string().trim().default("dist").describe(
|
|
158
|
+
"The directory used to store the workspace's distributable files after a build (relative to the workspace root)"
|
|
159
|
+
)
|
|
160
|
+
}).describe(
|
|
161
|
+
"Various directories used by the workspace to store data, cache, and configuration files"
|
|
162
|
+
);
|
|
139
163
|
var errorConfigSchema = z.object({
|
|
140
164
|
codesFile: z.string().trim().default(STORM_DEFAULT_ERROR_CODES_FILE).describe("The path to the workspace's error codes JSON file"),
|
|
141
|
-
url: z.string().trim().url().optional().describe(
|
|
165
|
+
url: z.string().trim().url().optional().describe(
|
|
166
|
+
"A URL to a page that looks up the workspace's error messages given a specific error code"
|
|
167
|
+
)
|
|
142
168
|
}).describe("The workspace's error config used during the error process");
|
|
143
169
|
var stormWorkspaceConfigSchema = z.object({
|
|
144
|
-
$schema: z.string().trim().default(
|
|
170
|
+
$schema: z.string().trim().default(
|
|
171
|
+
"https://cdn.jsdelivr.net/npm/@storm-software/config/schemas/storm-workspace.schema.json"
|
|
172
|
+
).optional().nullish().describe(
|
|
173
|
+
"The URL to the JSON schema file that describes the Storm configuration file"
|
|
174
|
+
),
|
|
145
175
|
extends: ExtendsSchema.optional(),
|
|
146
|
-
name: z.string().trim().toLowerCase().optional().describe(
|
|
176
|
+
name: z.string().trim().toLowerCase().optional().describe(
|
|
177
|
+
"The name of the service/package/scope using this configuration"
|
|
178
|
+
),
|
|
147
179
|
namespace: z.string().trim().toLowerCase().optional().describe("The namespace of the package"),
|
|
148
180
|
organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
|
|
149
181
|
repository: z.string().trim().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
|
|
@@ -159,21 +191,16 @@ var stormWorkspaceConfigSchema = z.object({
|
|
|
159
191
|
release: WorkspaceReleaseConfigSchema,
|
|
160
192
|
account: WorkspaceAccountConfigSchema,
|
|
161
193
|
error: errorConfigSchema,
|
|
162
|
-
mode: z.enum([
|
|
163
|
-
"development",
|
|
164
|
-
"staging",
|
|
165
|
-
"production"
|
|
166
|
-
]).default("production").describe("The current runtime environment mode for the package"),
|
|
194
|
+
mode: z.enum(["development", "staging", "production"]).default("production").describe("The current runtime environment mode for the package"),
|
|
167
195
|
workspaceRoot: z.string().trim().describe("The root directory of the workspace"),
|
|
168
|
-
externalPackagePatterns: z.array(z.string()).default([]).describe(
|
|
196
|
+
externalPackagePatterns: z.array(z.string()).default([]).describe(
|
|
197
|
+
"The build will use these package patterns to determine if they should be external to the bundle"
|
|
198
|
+
),
|
|
169
199
|
skipCache: z.boolean().default(false).describe("Should all known types of workspace caching be skipped?"),
|
|
170
200
|
directories: WorkspaceDirectoryConfigSchema,
|
|
171
|
-
packageManager: z.enum([
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
"pnpm",
|
|
175
|
-
"bun"
|
|
176
|
-
]).default("npm").describe("The JavaScript/TypeScript package manager used by the repository"),
|
|
201
|
+
packageManager: z.enum(["npm", "yarn", "pnpm", "bun"]).default("npm").describe(
|
|
202
|
+
"The JavaScript/TypeScript package manager used by the repository"
|
|
203
|
+
),
|
|
177
204
|
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
178
205
|
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
179
206
|
logLevel: z.enum([
|
|
@@ -186,13 +213,23 @@ var stormWorkspaceConfigSchema = z.object({
|
|
|
186
213
|
"debug",
|
|
187
214
|
"trace",
|
|
188
215
|
"all"
|
|
189
|
-
]).default("info").describe(
|
|
190
|
-
|
|
216
|
+
]).default("info").describe(
|
|
217
|
+
"The log level used to filter out lower priority log messages. If not provided, this is defaulted using the `environment` config value (if `environment` is set to `production` then `level` is `error`, else `level` is `debug`)."
|
|
218
|
+
),
|
|
219
|
+
skipConfigLogging: z.boolean().optional().describe(
|
|
220
|
+
"Should the logging of the current Storm Workspace configuration be skipped?"
|
|
221
|
+
),
|
|
191
222
|
registry: RegistryConfigSchema,
|
|
192
|
-
configFile: z.string().trim().nullable().default(null).describe(
|
|
193
|
-
|
|
223
|
+
configFile: z.string().trim().nullable().default(null).describe(
|
|
224
|
+
"The filepath of the Storm config. When this field is null, no config file was found in the current workspace."
|
|
225
|
+
),
|
|
226
|
+
colors: ColorConfigSchema.or(ColorConfigMapSchema).describe(
|
|
227
|
+
"Storm theme config values used for styling various package elements"
|
|
228
|
+
),
|
|
194
229
|
extensions: z.record(z.any()).optional().default({}).describe("Configuration of each used extension")
|
|
195
|
-
}).describe(
|
|
230
|
+
}).describe(
|
|
231
|
+
"Storm Workspace config values used during various dev-ops processes. This type is a combination of the StormPackageConfig and StormProject types. It represents the config of the entire monorepo."
|
|
232
|
+
);
|
|
196
233
|
|
|
197
234
|
// ../config-tools/src/create-storm-config.ts
|
|
198
235
|
import defu2 from "defu";
|
|
@@ -257,11 +294,10 @@ function normalizeWindowsPath(input = "") {
|
|
|
257
294
|
}
|
|
258
295
|
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
259
296
|
}
|
|
260
|
-
__name(normalizeWindowsPath, "normalizeWindowsPath");
|
|
261
297
|
var _UNC_REGEX = /^[/\\]{2}/;
|
|
262
298
|
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
263
299
|
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
264
|
-
var correctPaths =
|
|
300
|
+
var correctPaths = function(path2) {
|
|
265
301
|
if (!path2 || path2.length === 0) {
|
|
266
302
|
return ".";
|
|
267
303
|
}
|
|
@@ -289,8 +325,8 @@ var correctPaths = /* @__PURE__ */ __name(function(path2) {
|
|
|
289
325
|
return `//${path2}`;
|
|
290
326
|
}
|
|
291
327
|
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
292
|
-
}
|
|
293
|
-
var joinPaths =
|
|
328
|
+
};
|
|
329
|
+
var joinPaths = function(...segments) {
|
|
294
330
|
let path2 = "";
|
|
295
331
|
for (const seg of segments) {
|
|
296
332
|
if (!seg) {
|
|
@@ -310,7 +346,7 @@ var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
|
310
346
|
}
|
|
311
347
|
}
|
|
312
348
|
return correctPaths(path2);
|
|
313
|
-
}
|
|
349
|
+
};
|
|
314
350
|
function normalizeString(path2, allowAboveRoot) {
|
|
315
351
|
let res = "";
|
|
316
352
|
let lastSegmentLength = 0;
|
|
@@ -371,10 +407,9 @@ function normalizeString(path2, allowAboveRoot) {
|
|
|
371
407
|
}
|
|
372
408
|
return res;
|
|
373
409
|
}
|
|
374
|
-
|
|
375
|
-
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
410
|
+
var isAbsolute = function(p) {
|
|
376
411
|
return _IS_ABSOLUTE_RE.test(p);
|
|
377
|
-
}
|
|
412
|
+
};
|
|
378
413
|
|
|
379
414
|
// ../config-tools/src/utilities/find-up.ts
|
|
380
415
|
import { existsSync } from "node:fs";
|
|
@@ -383,10 +418,14 @@ var MAX_PATH_SEARCH_DEPTH = 30;
|
|
|
383
418
|
var depth = 0;
|
|
384
419
|
function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
|
|
385
420
|
const _startPath = startPath ?? process.cwd();
|
|
386
|
-
if (endDirectoryNames.some(
|
|
421
|
+
if (endDirectoryNames.some(
|
|
422
|
+
(endDirName) => existsSync(join(_startPath, endDirName))
|
|
423
|
+
)) {
|
|
387
424
|
return _startPath;
|
|
388
425
|
}
|
|
389
|
-
if (endFileNames.some(
|
|
426
|
+
if (endFileNames.some(
|
|
427
|
+
(endFileName) => existsSync(join(_startPath, endFileName))
|
|
428
|
+
)) {
|
|
390
429
|
return _startPath;
|
|
391
430
|
}
|
|
392
431
|
if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
@@ -395,7 +434,6 @@ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
|
|
|
395
434
|
}
|
|
396
435
|
return void 0;
|
|
397
436
|
}
|
|
398
|
-
__name(findFolderUp, "findFolderUp");
|
|
399
437
|
|
|
400
438
|
// ../config-tools/src/utilities/find-workspace-root.ts
|
|
401
439
|
var rootFiles = [
|
|
@@ -442,21 +480,31 @@ var rootDirectories = [
|
|
|
442
480
|
];
|
|
443
481
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
444
482
|
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
445
|
-
return correctPaths(
|
|
446
|
-
|
|
447
|
-
|
|
483
|
+
return correctPaths(
|
|
484
|
+
process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
return correctPaths(
|
|
488
|
+
findFolderUp(
|
|
489
|
+
pathInsideMonorepo ?? process.cwd(),
|
|
490
|
+
rootFiles,
|
|
491
|
+
rootDirectories
|
|
492
|
+
)
|
|
493
|
+
);
|
|
448
494
|
}
|
|
449
|
-
__name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
|
|
450
495
|
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
451
496
|
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
452
497
|
if (!result) {
|
|
453
|
-
throw new Error(
|
|
454
|
-
|
|
455
|
-
|
|
498
|
+
throw new Error(
|
|
499
|
+
`Cannot find workspace root upwards from known path. Files search list includes:
|
|
500
|
+
${rootFiles.join(
|
|
501
|
+
"\n"
|
|
502
|
+
)}
|
|
503
|
+
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
504
|
+
);
|
|
456
505
|
}
|
|
457
506
|
return result;
|
|
458
507
|
}
|
|
459
|
-
__name(findWorkspaceRoot, "findWorkspaceRoot");
|
|
460
508
|
|
|
461
509
|
// ../config-tools/src/utilities/get-default-config.ts
|
|
462
510
|
var DEFAULT_COLOR_CONFIG = {
|
|
@@ -487,7 +535,7 @@ var DEFAULT_COLOR_CONFIG = {
|
|
|
487
535
|
negative: "#dc2626"
|
|
488
536
|
}
|
|
489
537
|
};
|
|
490
|
-
var getDefaultConfig =
|
|
538
|
+
var getDefaultConfig = async (root) => {
|
|
491
539
|
let license = STORM_DEFAULT_LICENSE;
|
|
492
540
|
let homepage = STORM_DEFAULT_HOMEPAGE;
|
|
493
541
|
let name = void 0;
|
|
@@ -495,7 +543,10 @@ var getDefaultConfig = /* @__PURE__ */ __name(async (root) => {
|
|
|
495
543
|
let repository = void 0;
|
|
496
544
|
const workspaceRoot = findWorkspaceRoot(root);
|
|
497
545
|
if (existsSync2(join2(workspaceRoot, "package.json"))) {
|
|
498
|
-
const file = await readFile(
|
|
546
|
+
const file = await readFile(
|
|
547
|
+
joinPaths(workspaceRoot, "package.json"),
|
|
548
|
+
"utf8"
|
|
549
|
+
);
|
|
499
550
|
if (file) {
|
|
500
551
|
const packageJson = JSON.parse(file);
|
|
501
552
|
if (packageJson.name) {
|
|
@@ -532,36 +583,36 @@ var getDefaultConfig = /* @__PURE__ */ __name(async (root) => {
|
|
|
532
583
|
url: `${homepage || STORM_DEFAULT_HOMEPAGE}/errors`
|
|
533
584
|
}
|
|
534
585
|
};
|
|
535
|
-
}
|
|
586
|
+
};
|
|
536
587
|
|
|
537
588
|
// ../config-tools/src/logger/chalk.ts
|
|
538
589
|
import chalk from "chalk";
|
|
539
590
|
var chalkDefault = {
|
|
540
|
-
hex:
|
|
541
|
-
bgHex:
|
|
542
|
-
whiteBright:
|
|
543
|
-
}),
|
|
544
|
-
whiteBright:
|
|
545
|
-
gray:
|
|
591
|
+
hex: (_) => (message) => message,
|
|
592
|
+
bgHex: (_) => ({
|
|
593
|
+
whiteBright: (message) => message
|
|
594
|
+
}),
|
|
595
|
+
whiteBright: (message) => message,
|
|
596
|
+
gray: (message) => message,
|
|
546
597
|
bold: {
|
|
547
|
-
hex:
|
|
548
|
-
bgHex:
|
|
549
|
-
whiteBright:
|
|
550
|
-
}),
|
|
551
|
-
whiteBright:
|
|
598
|
+
hex: (_) => (message) => message,
|
|
599
|
+
bgHex: (_) => ({
|
|
600
|
+
whiteBright: (message) => message
|
|
601
|
+
}),
|
|
602
|
+
whiteBright: (message) => message
|
|
552
603
|
},
|
|
553
604
|
dim: {
|
|
554
|
-
hex:
|
|
555
|
-
gray:
|
|
605
|
+
hex: (_) => (message) => message,
|
|
606
|
+
gray: (message) => message
|
|
556
607
|
}
|
|
557
608
|
};
|
|
558
|
-
var getChalk =
|
|
609
|
+
var getChalk = () => {
|
|
559
610
|
let _chalk = chalk;
|
|
560
611
|
if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright) {
|
|
561
612
|
_chalk = chalkDefault;
|
|
562
613
|
}
|
|
563
614
|
return _chalk;
|
|
564
|
-
}
|
|
615
|
+
};
|
|
565
616
|
|
|
566
617
|
// ../config-tools/src/logger/is-unicode-supported.ts
|
|
567
618
|
function isUnicodeSupported() {
|
|
@@ -573,10 +624,9 @@ function isUnicodeSupported() {
|
|
|
573
624
|
process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
|
|
574
625
|
process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERM === "rxvt-unicode" || process.env.TERM === "rxvt-unicode-256color" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
575
626
|
}
|
|
576
|
-
__name(isUnicodeSupported, "isUnicodeSupported");
|
|
577
627
|
|
|
578
628
|
// ../config-tools/src/logger/console-icons.ts
|
|
579
|
-
var useIcon =
|
|
629
|
+
var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
|
|
580
630
|
var CONSOLE_ICONS = {
|
|
581
631
|
[LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
|
|
582
632
|
[LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
|
|
@@ -589,12 +639,12 @@ var CONSOLE_ICONS = {
|
|
|
589
639
|
};
|
|
590
640
|
|
|
591
641
|
// ../config-tools/src/logger/format-timestamp.ts
|
|
592
|
-
var formatTimestamp =
|
|
642
|
+
var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
|
|
593
643
|
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
|
|
594
|
-
}
|
|
644
|
+
};
|
|
595
645
|
|
|
596
646
|
// ../config-tools/src/logger/get-log-level.ts
|
|
597
|
-
var getLogLevel =
|
|
647
|
+
var getLogLevel = (label) => {
|
|
598
648
|
switch (label) {
|
|
599
649
|
case "all":
|
|
600
650
|
return LogLevel.ALL;
|
|
@@ -615,8 +665,8 @@ var getLogLevel = /* @__PURE__ */ __name((label) => {
|
|
|
615
665
|
default:
|
|
616
666
|
return LogLevel.INFO;
|
|
617
667
|
}
|
|
618
|
-
}
|
|
619
|
-
var getLogLevelLabel =
|
|
668
|
+
};
|
|
669
|
+
var getLogLevelLabel = (logLevel = LogLevel.INFO) => {
|
|
620
670
|
if (logLevel >= LogLevel.ALL) {
|
|
621
671
|
return LogLevelLabel.ALL;
|
|
622
672
|
}
|
|
@@ -642,14 +692,14 @@ var getLogLevelLabel = /* @__PURE__ */ __name((logLevel = LogLevel.INFO) => {
|
|
|
642
692
|
return LogLevelLabel.SILENT;
|
|
643
693
|
}
|
|
644
694
|
return LogLevelLabel.INFO;
|
|
645
|
-
}
|
|
646
|
-
var isVerbose =
|
|
695
|
+
};
|
|
696
|
+
var isVerbose = (label = LogLevelLabel.SILENT) => {
|
|
647
697
|
const logLevel = typeof label === "string" ? getLogLevel(label) : label;
|
|
648
698
|
return logLevel >= LogLevel.DEBUG;
|
|
649
|
-
}
|
|
699
|
+
};
|
|
650
700
|
|
|
651
701
|
// ../config-tools/src/logger/console.ts
|
|
652
|
-
var getLogFn =
|
|
702
|
+
var getLogFn = (logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
|
|
653
703
|
const colors = !config.colors?.dark && !config.colors?.["base"] && !config.colors?.["base"]?.dark ? DEFAULT_COLOR_CONFIG : config.colors?.dark && typeof config.colors.dark === "string" ? config.colors : config.colors?.["base"]?.dark && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : config.colors?.["base"] ? config.colors?.["base"] : DEFAULT_COLOR_CONFIG;
|
|
654
704
|
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
|
|
655
705
|
if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
|
|
@@ -658,118 +708,147 @@ var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}, _c
|
|
|
658
708
|
}
|
|
659
709
|
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
|
|
660
710
|
return (message) => {
|
|
661
|
-
console.error(
|
|
711
|
+
console.error(
|
|
712
|
+
`
|
|
662
713
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
663
|
-
`
|
|
714
|
+
`
|
|
715
|
+
);
|
|
664
716
|
};
|
|
665
717
|
}
|
|
666
718
|
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
|
|
667
719
|
return (message) => {
|
|
668
|
-
console.error(
|
|
720
|
+
console.error(
|
|
721
|
+
`
|
|
669
722
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
670
|
-
`
|
|
723
|
+
`
|
|
724
|
+
);
|
|
671
725
|
};
|
|
672
726
|
}
|
|
673
727
|
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
|
|
674
728
|
return (message) => {
|
|
675
|
-
console.warn(
|
|
729
|
+
console.warn(
|
|
730
|
+
`
|
|
676
731
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
677
|
-
`
|
|
732
|
+
`
|
|
733
|
+
);
|
|
678
734
|
};
|
|
679
735
|
}
|
|
680
736
|
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
|
|
681
737
|
return (message) => {
|
|
682
|
-
console.info(
|
|
738
|
+
console.info(
|
|
739
|
+
`
|
|
683
740
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
684
|
-
`
|
|
741
|
+
`
|
|
742
|
+
);
|
|
685
743
|
};
|
|
686
744
|
}
|
|
687
745
|
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
|
|
688
746
|
return (message) => {
|
|
689
|
-
console.info(
|
|
747
|
+
console.info(
|
|
748
|
+
`
|
|
690
749
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
691
|
-
`
|
|
750
|
+
`
|
|
751
|
+
);
|
|
692
752
|
};
|
|
693
753
|
}
|
|
694
754
|
if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
|
|
695
755
|
return (message) => {
|
|
696
|
-
console.debug(
|
|
756
|
+
console.debug(
|
|
757
|
+
`
|
|
697
758
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
698
|
-
`
|
|
759
|
+
`
|
|
760
|
+
);
|
|
699
761
|
};
|
|
700
762
|
}
|
|
701
763
|
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
|
|
702
764
|
return (message) => {
|
|
703
|
-
console.debug(
|
|
765
|
+
console.debug(
|
|
766
|
+
`
|
|
704
767
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
705
|
-
`
|
|
768
|
+
`
|
|
769
|
+
);
|
|
706
770
|
};
|
|
707
771
|
}
|
|
708
772
|
return (message) => {
|
|
709
|
-
console.log(
|
|
773
|
+
console.log(
|
|
774
|
+
`
|
|
710
775
|
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
|
|
711
|
-
`
|
|
776
|
+
`
|
|
777
|
+
);
|
|
712
778
|
};
|
|
713
|
-
}
|
|
714
|
-
var writeFatal =
|
|
715
|
-
var writeError =
|
|
716
|
-
var writeWarning =
|
|
717
|
-
var writeInfo =
|
|
718
|
-
var writeSuccess =
|
|
719
|
-
var writeDebug =
|
|
720
|
-
var writeTrace =
|
|
721
|
-
var getStopwatch =
|
|
779
|
+
};
|
|
780
|
+
var writeFatal = (message, config) => getLogFn(LogLevel.FATAL, config)(message);
|
|
781
|
+
var writeError = (message, config) => getLogFn(LogLevel.ERROR, config)(message);
|
|
782
|
+
var writeWarning = (message, config) => getLogFn(LogLevel.WARN, config)(message);
|
|
783
|
+
var writeInfo = (message, config) => getLogFn(LogLevel.INFO, config)(message);
|
|
784
|
+
var writeSuccess = (message, config) => getLogFn(LogLevel.SUCCESS, config)(message);
|
|
785
|
+
var writeDebug = (message, config) => getLogFn(LogLevel.DEBUG, config)(message);
|
|
786
|
+
var writeTrace = (message, config) => getLogFn(LogLevel.TRACE, config)(message);
|
|
787
|
+
var getStopwatch = (name) => {
|
|
722
788
|
const start = process.hrtime();
|
|
723
789
|
return () => {
|
|
724
790
|
const end = process.hrtime(start);
|
|
725
|
-
console.info(
|
|
726
|
-
|
|
727
|
-
`
|
|
791
|
+
console.info(
|
|
792
|
+
`
|
|
793
|
+
> \u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(
|
|
794
|
+
end[0] * 1e3 + end[1] / 1e6
|
|
795
|
+
)}ms to complete
|
|
796
|
+
`
|
|
797
|
+
);
|
|
728
798
|
};
|
|
729
|
-
}
|
|
799
|
+
};
|
|
730
800
|
var MAX_DEPTH = 4;
|
|
731
|
-
var formatLogMessage =
|
|
801
|
+
var formatLogMessage = (message, options = {}, depth2 = 0) => {
|
|
732
802
|
if (depth2 > MAX_DEPTH) {
|
|
733
803
|
return "<max depth>";
|
|
734
804
|
}
|
|
735
805
|
const prefix = options.prefix ?? "-";
|
|
736
806
|
const skip = options.skip ?? [];
|
|
737
807
|
return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
|
|
738
|
-
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
}
|
|
747
|
-
var _isFunction =
|
|
808
|
+
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth2 + 1)}`).join("\n")}` : typeof message === "object" ? `
|
|
809
|
+
${Object.keys(message).filter((key) => !skip.includes(key)).map(
|
|
810
|
+
(key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
|
|
811
|
+
message[key],
|
|
812
|
+
{ prefix: `${prefix}-`, skip },
|
|
813
|
+
depth2 + 1
|
|
814
|
+
) : message[key]}`
|
|
815
|
+
).join("\n")}` : message;
|
|
816
|
+
};
|
|
817
|
+
var _isFunction = (value) => {
|
|
748
818
|
try {
|
|
749
819
|
return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
|
|
750
820
|
} catch (e) {
|
|
751
821
|
return false;
|
|
752
822
|
}
|
|
753
|
-
}
|
|
823
|
+
};
|
|
754
824
|
|
|
755
825
|
// ../config-tools/src/utilities/process-handler.ts
|
|
756
|
-
var exitWithError =
|
|
826
|
+
var exitWithError = (config) => {
|
|
757
827
|
writeFatal("Exiting script with an error status...", config);
|
|
758
828
|
process.exit(1);
|
|
759
|
-
}
|
|
760
|
-
var exitWithSuccess =
|
|
829
|
+
};
|
|
830
|
+
var exitWithSuccess = (config) => {
|
|
761
831
|
writeSuccess("Script completed successfully. Exiting...", config);
|
|
762
832
|
process.exit(0);
|
|
763
|
-
}
|
|
764
|
-
var handleProcess =
|
|
765
|
-
writeTrace(
|
|
833
|
+
};
|
|
834
|
+
var handleProcess = (config) => {
|
|
835
|
+
writeTrace(
|
|
836
|
+
`Using the following arguments to process the script: ${process.argv.join(", ")}`,
|
|
837
|
+
config
|
|
838
|
+
);
|
|
766
839
|
process.on("unhandledRejection", (error) => {
|
|
767
|
-
writeError(
|
|
840
|
+
writeError(
|
|
841
|
+
`An Unhandled Rejection occurred while running the program: ${error}`,
|
|
842
|
+
config
|
|
843
|
+
);
|
|
768
844
|
exitWithError(config);
|
|
769
845
|
});
|
|
770
846
|
process.on("uncaughtException", (error) => {
|
|
771
|
-
writeError(
|
|
772
|
-
|
|
847
|
+
writeError(
|
|
848
|
+
`An Uncaught Exception occurred while running the program: ${error.message}
|
|
849
|
+
Stacktrace: ${error.stack}`,
|
|
850
|
+
config
|
|
851
|
+
);
|
|
773
852
|
exitWithError(config);
|
|
774
853
|
});
|
|
775
854
|
process.on("SIGTERM", (signal) => {
|
|
@@ -784,10 +863,10 @@ Stacktrace: ${error.stack}`, config);
|
|
|
784
863
|
writeError(`The program terminated with signal code: ${signal}`, config);
|
|
785
864
|
exitWithError(config);
|
|
786
865
|
});
|
|
787
|
-
}
|
|
866
|
+
};
|
|
788
867
|
|
|
789
868
|
// ../config-tools/src/config-file/get-config-file.ts
|
|
790
|
-
var getConfigFileByName =
|
|
869
|
+
var getConfigFileByName = async (fileName, filePath, options = {}) => {
|
|
791
870
|
const workspacePath = filePath || findWorkspaceRoot(filePath);
|
|
792
871
|
const configs = await Promise.all([
|
|
793
872
|
loadConfig({
|
|
@@ -797,7 +876,10 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
797
876
|
envName: fileName?.toUpperCase(),
|
|
798
877
|
jitiOptions: {
|
|
799
878
|
debug: false,
|
|
800
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
879
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
880
|
+
process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
|
|
881
|
+
"jiti"
|
|
882
|
+
)
|
|
801
883
|
},
|
|
802
884
|
...options
|
|
803
885
|
}),
|
|
@@ -808,32 +890,45 @@ var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, opti
|
|
|
808
890
|
envName: fileName?.toUpperCase(),
|
|
809
891
|
jitiOptions: {
|
|
810
892
|
debug: false,
|
|
811
|
-
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
893
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
894
|
+
process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
|
|
895
|
+
"jiti"
|
|
896
|
+
)
|
|
812
897
|
},
|
|
813
898
|
configFile: fileName,
|
|
814
899
|
...options
|
|
815
900
|
})
|
|
816
901
|
]);
|
|
817
902
|
return defu(configs[0] ?? {}, configs[1] ?? {});
|
|
818
|
-
}
|
|
819
|
-
var getConfigFile =
|
|
903
|
+
};
|
|
904
|
+
var getConfigFile = async (filePath, additionalFileNames = []) => {
|
|
820
905
|
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
821
906
|
const result = await getConfigFileByName("storm-workspace", workspacePath);
|
|
822
907
|
let config = result.config;
|
|
823
908
|
const configFile = result.configFile;
|
|
824
909
|
if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
|
|
825
|
-
writeTrace(
|
|
826
|
-
|
|
827
|
-
|
|
910
|
+
writeTrace(
|
|
911
|
+
`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`,
|
|
912
|
+
{
|
|
913
|
+
logLevel: "all"
|
|
914
|
+
}
|
|
915
|
+
);
|
|
828
916
|
}
|
|
829
917
|
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
830
|
-
const results = await Promise.all(
|
|
918
|
+
const results = await Promise.all(
|
|
919
|
+
additionalFileNames.map(
|
|
920
|
+
(fileName) => getConfigFileByName(fileName, workspacePath)
|
|
921
|
+
)
|
|
922
|
+
);
|
|
831
923
|
for (const result2 of results) {
|
|
832
924
|
if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
|
|
833
925
|
if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
|
|
834
|
-
writeTrace(
|
|
835
|
-
|
|
836
|
-
|
|
926
|
+
writeTrace(
|
|
927
|
+
`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`,
|
|
928
|
+
{
|
|
929
|
+
logLevel: "all"
|
|
930
|
+
}
|
|
931
|
+
);
|
|
837
932
|
}
|
|
838
933
|
config = defu(result2.config ?? {}, config ?? {});
|
|
839
934
|
}
|
|
@@ -844,20 +939,22 @@ var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames
|
|
|
844
939
|
}
|
|
845
940
|
config.configFile = configFile;
|
|
846
941
|
return config;
|
|
847
|
-
}
|
|
942
|
+
};
|
|
848
943
|
|
|
849
944
|
// ../config-tools/src/env/get-env.ts
|
|
850
|
-
var getExtensionEnv =
|
|
945
|
+
var getExtensionEnv = (extensionName) => {
|
|
851
946
|
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
852
947
|
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
853
|
-
const name = key.replace(prefix, "").split("_").map(
|
|
948
|
+
const name = key.replace(prefix, "").split("_").map(
|
|
949
|
+
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
950
|
+
).join("");
|
|
854
951
|
if (name) {
|
|
855
952
|
ret[name] = process.env[key];
|
|
856
953
|
}
|
|
857
954
|
return ret;
|
|
858
955
|
}, {});
|
|
859
|
-
}
|
|
860
|
-
var getConfigEnv =
|
|
956
|
+
};
|
|
957
|
+
var getConfigEnv = () => {
|
|
861
958
|
const prefix = "STORM_";
|
|
862
959
|
let config = {
|
|
863
960
|
extends: process.env[`${prefix}EXTENDS`] || void 0,
|
|
@@ -925,14 +1022,25 @@ var getConfigEnv = /* @__PURE__ */ __name(() => {
|
|
|
925
1022
|
cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
|
|
926
1023
|
container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
|
|
927
1024
|
},
|
|
928
|
-
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
|
|
1025
|
+
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(
|
|
1026
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
1027
|
+
) ? getLogLevelLabel(
|
|
1028
|
+
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
1029
|
+
) : process.env[`${prefix}LOG_LEVEL`] : void 0,
|
|
929
1030
|
skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
|
|
930
1031
|
};
|
|
931
|
-
const themeNames = Object.keys(process.env).filter(
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1032
|
+
const themeNames = Object.keys(process.env).filter(
|
|
1033
|
+
(envKey) => envKey.startsWith(`${prefix}COLOR_`) && COLOR_KEYS.every(
|
|
1034
|
+
(colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)
|
|
1035
|
+
)
|
|
1036
|
+
);
|
|
1037
|
+
config.colors = themeNames.length > 0 ? themeNames.reduce(
|
|
1038
|
+
(ret, themeName) => {
|
|
1039
|
+
ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
|
|
1040
|
+
return ret;
|
|
1041
|
+
},
|
|
1042
|
+
{}
|
|
1043
|
+
) : getThemeColorConfigEnv(prefix);
|
|
936
1044
|
if (config.docs === STORM_DEFAULT_DOCS) {
|
|
937
1045
|
if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
|
|
938
1046
|
config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
|
|
@@ -953,23 +1061,17 @@ var getConfigEnv = /* @__PURE__ */ __name(() => {
|
|
|
953
1061
|
config = {
|
|
954
1062
|
...config,
|
|
955
1063
|
...parsed,
|
|
956
|
-
colors: {
|
|
957
|
-
|
|
958
|
-
...parsed.colors
|
|
959
|
-
},
|
|
960
|
-
extensions: {
|
|
961
|
-
...config.extensions,
|
|
962
|
-
...parsed.extensions
|
|
963
|
-
}
|
|
1064
|
+
colors: { ...config.colors, ...parsed.colors },
|
|
1065
|
+
extensions: { ...config.extensions, ...parsed.extensions }
|
|
964
1066
|
};
|
|
965
1067
|
}
|
|
966
1068
|
return config;
|
|
967
|
-
}
|
|
968
|
-
var getThemeColorConfigEnv =
|
|
1069
|
+
};
|
|
1070
|
+
var getThemeColorConfigEnv = (prefix, theme) => {
|
|
969
1071
|
const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
|
|
970
1072
|
return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
|
|
971
|
-
}
|
|
972
|
-
var getSingleThemeColorConfigEnv =
|
|
1073
|
+
};
|
|
1074
|
+
var getSingleThemeColorConfigEnv = (prefix) => {
|
|
973
1075
|
return {
|
|
974
1076
|
dark: process.env[`${prefix}DARK`],
|
|
975
1077
|
light: process.env[`${prefix}LIGHT`],
|
|
@@ -986,14 +1088,16 @@ var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
|
986
1088
|
positive: process.env[`${prefix}POSITIVE`],
|
|
987
1089
|
negative: process.env[`${prefix}NEGATIVE`]
|
|
988
1090
|
};
|
|
989
|
-
}
|
|
990
|
-
var getMultiThemeColorConfigEnv =
|
|
1091
|
+
};
|
|
1092
|
+
var getMultiThemeColorConfigEnv = (prefix) => {
|
|
991
1093
|
return {
|
|
992
|
-
light: getBaseThemeColorConfigEnv(
|
|
1094
|
+
light: getBaseThemeColorConfigEnv(
|
|
1095
|
+
`${prefix}_LIGHT_`
|
|
1096
|
+
),
|
|
993
1097
|
dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
|
|
994
1098
|
};
|
|
995
|
-
}
|
|
996
|
-
var getBaseThemeColorConfigEnv =
|
|
1099
|
+
};
|
|
1100
|
+
var getBaseThemeColorConfigEnv = (prefix) => {
|
|
997
1101
|
return {
|
|
998
1102
|
foreground: process.env[`${prefix}FOREGROUND`],
|
|
999
1103
|
background: process.env[`${prefix}BACKGROUND`],
|
|
@@ -1010,13 +1114,16 @@ var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
|
|
|
1010
1114
|
positive: process.env[`${prefix}POSITIVE`],
|
|
1011
1115
|
negative: process.env[`${prefix}NEGATIVE`]
|
|
1012
1116
|
};
|
|
1013
|
-
}
|
|
1117
|
+
};
|
|
1014
1118
|
|
|
1015
1119
|
// ../config-tools/src/env/set-env.ts
|
|
1016
|
-
var setExtensionEnv =
|
|
1120
|
+
var setExtensionEnv = (extensionName, extension) => {
|
|
1017
1121
|
for (const key of Object.keys(extension ?? {})) {
|
|
1018
1122
|
if (extension[key]) {
|
|
1019
|
-
const result = key?.replace(
|
|
1123
|
+
const result = key?.replace(
|
|
1124
|
+
/([A-Z])+/g,
|
|
1125
|
+
(input) => input ? input[0]?.toUpperCase() + input.slice(1) : ""
|
|
1126
|
+
).split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
|
|
1020
1127
|
let extensionKey;
|
|
1021
1128
|
if (result.length === 0) {
|
|
1022
1129
|
return;
|
|
@@ -1031,8 +1138,8 @@ var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
|
|
|
1031
1138
|
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
|
|
1032
1139
|
}
|
|
1033
1140
|
}
|
|
1034
|
-
}
|
|
1035
|
-
var setConfigEnv =
|
|
1141
|
+
};
|
|
1142
|
+
var setConfigEnv = (config) => {
|
|
1036
1143
|
const prefix = "STORM_";
|
|
1037
1144
|
if (config.extends) {
|
|
1038
1145
|
process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
|
|
@@ -1121,7 +1228,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
1121
1228
|
}
|
|
1122
1229
|
if (config.directories) {
|
|
1123
1230
|
if (!config.skipCache && config.directories.cache) {
|
|
1124
|
-
process.env[`${prefix}CACHE_DIR`] = correctPaths(
|
|
1231
|
+
process.env[`${prefix}CACHE_DIR`] = correctPaths(
|
|
1232
|
+
config.directories.cache
|
|
1233
|
+
);
|
|
1125
1234
|
process.env[`${prefix}CACHE_DIRECTORY`] = process.env[`${prefix}CACHE_DIR`];
|
|
1126
1235
|
}
|
|
1127
1236
|
if (config.directories.data) {
|
|
@@ -1129,7 +1238,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
1129
1238
|
process.env[`${prefix}DATA_DIRECTORY`] = process.env[`${prefix}DATA_DIR`];
|
|
1130
1239
|
}
|
|
1131
1240
|
if (config.directories.config) {
|
|
1132
|
-
process.env[`${prefix}CONFIG_DIR`] = correctPaths(
|
|
1241
|
+
process.env[`${prefix}CONFIG_DIR`] = correctPaths(
|
|
1242
|
+
config.directories.config
|
|
1243
|
+
);
|
|
1133
1244
|
process.env[`${prefix}CONFIG_DIRECTORY`] = process.env[`${prefix}CONFIG_DIR`];
|
|
1134
1245
|
}
|
|
1135
1246
|
if (config.directories.temp) {
|
|
@@ -1141,7 +1252,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
1141
1252
|
process.env[`${prefix}LOG_DIRECTORY`] = process.env[`${prefix}LOG_DIR`];
|
|
1142
1253
|
}
|
|
1143
1254
|
if (config.directories.build) {
|
|
1144
|
-
process.env[`${prefix}BUILD_DIR`] = correctPaths(
|
|
1255
|
+
process.env[`${prefix}BUILD_DIR`] = correctPaths(
|
|
1256
|
+
config.directories.build
|
|
1257
|
+
);
|
|
1145
1258
|
process.env[`${prefix}BUILD_DIRECTORY`] = process.env[`${prefix}BUILD_DIR`];
|
|
1146
1259
|
}
|
|
1147
1260
|
}
|
|
@@ -1162,7 +1275,10 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
1162
1275
|
setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
|
|
1163
1276
|
}
|
|
1164
1277
|
} else {
|
|
1165
|
-
setThemeColorConfigEnv(
|
|
1278
|
+
setThemeColorConfigEnv(
|
|
1279
|
+
`${prefix}COLOR_`,
|
|
1280
|
+
config.colors
|
|
1281
|
+
);
|
|
1166
1282
|
}
|
|
1167
1283
|
if (config.repository) {
|
|
1168
1284
|
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
@@ -1174,7 +1290,9 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
1174
1290
|
process.env[`${prefix}PRE_ID`] = String(config.preid);
|
|
1175
1291
|
}
|
|
1176
1292
|
if (config.externalPackagePatterns) {
|
|
1177
|
-
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(
|
|
1293
|
+
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(
|
|
1294
|
+
config.externalPackagePatterns
|
|
1295
|
+
);
|
|
1178
1296
|
}
|
|
1179
1297
|
if (config.registry) {
|
|
1180
1298
|
if (config.registry.github) {
|
|
@@ -1187,20 +1305,28 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
1187
1305
|
process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
|
|
1188
1306
|
}
|
|
1189
1307
|
if (config.registry.cyclone) {
|
|
1190
|
-
process.env[`${prefix}REGISTRY_CYCLONE`] = String(
|
|
1308
|
+
process.env[`${prefix}REGISTRY_CYCLONE`] = String(
|
|
1309
|
+
config.registry.cyclone
|
|
1310
|
+
);
|
|
1191
1311
|
}
|
|
1192
1312
|
if (config.registry.container) {
|
|
1193
|
-
process.env[`${prefix}REGISTRY_CONTAINER`] = String(
|
|
1313
|
+
process.env[`${prefix}REGISTRY_CONTAINER`] = String(
|
|
1314
|
+
config.registry.container
|
|
1315
|
+
);
|
|
1194
1316
|
}
|
|
1195
1317
|
}
|
|
1196
1318
|
if (config.logLevel) {
|
|
1197
1319
|
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
1198
1320
|
process.env.LOG_LEVEL = String(config.logLevel);
|
|
1199
|
-
process.env.NX_VERBOSE_LOGGING = String(
|
|
1321
|
+
process.env.NX_VERBOSE_LOGGING = String(
|
|
1322
|
+
getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
|
|
1323
|
+
);
|
|
1200
1324
|
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
1201
1325
|
}
|
|
1202
1326
|
if (config.skipConfigLogging !== void 0) {
|
|
1203
|
-
process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(
|
|
1327
|
+
process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(
|
|
1328
|
+
config.skipConfigLogging
|
|
1329
|
+
);
|
|
1204
1330
|
}
|
|
1205
1331
|
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
1206
1332
|
for (const key of Object.keys(config.extensions ?? {})) {
|
|
@@ -1208,11 +1334,11 @@ var setConfigEnv = /* @__PURE__ */ __name((config) => {
|
|
|
1208
1334
|
setExtensionEnv(key, config.extensions[key]);
|
|
1209
1335
|
}
|
|
1210
1336
|
}
|
|
1211
|
-
}
|
|
1212
|
-
var setThemeColorConfigEnv =
|
|
1337
|
+
};
|
|
1338
|
+
var setThemeColorConfigEnv = (prefix, config) => {
|
|
1213
1339
|
return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
|
|
1214
|
-
}
|
|
1215
|
-
var setSingleThemeColorConfigEnv =
|
|
1340
|
+
};
|
|
1341
|
+
var setSingleThemeColorConfigEnv = (prefix, config) => {
|
|
1216
1342
|
if (config.dark) {
|
|
1217
1343
|
process.env[`${prefix}DARK`] = config.dark;
|
|
1218
1344
|
}
|
|
@@ -1255,14 +1381,14 @@ var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
|
1255
1381
|
if (config.negative) {
|
|
1256
1382
|
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
1257
1383
|
}
|
|
1258
|
-
}
|
|
1259
|
-
var setMultiThemeColorConfigEnv =
|
|
1384
|
+
};
|
|
1385
|
+
var setMultiThemeColorConfigEnv = (prefix, config) => {
|
|
1260
1386
|
return {
|
|
1261
1387
|
light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
|
|
1262
1388
|
dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
|
|
1263
1389
|
};
|
|
1264
|
-
}
|
|
1265
|
-
var setBaseThemeColorConfigEnv =
|
|
1390
|
+
};
|
|
1391
|
+
var setBaseThemeColorConfigEnv = (prefix, config) => {
|
|
1266
1392
|
if (config.foreground) {
|
|
1267
1393
|
process.env[`${prefix}FOREGROUND`] = config.foreground;
|
|
1268
1394
|
}
|
|
@@ -1305,12 +1431,12 @@ var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
|
|
|
1305
1431
|
if (config.negative) {
|
|
1306
1432
|
process.env[`${prefix}NEGATIVE`] = config.negative;
|
|
1307
1433
|
}
|
|
1308
|
-
}
|
|
1434
|
+
};
|
|
1309
1435
|
|
|
1310
1436
|
// ../config-tools/src/create-storm-config.ts
|
|
1311
1437
|
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
1312
1438
|
var _static_cache = void 0;
|
|
1313
|
-
var createStormWorkspaceConfig =
|
|
1439
|
+
var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
|
|
1314
1440
|
let result;
|
|
1315
1441
|
if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
|
|
1316
1442
|
let _workspaceRoot = workspaceRoot;
|
|
@@ -1321,16 +1447,19 @@ var createStormWorkspaceConfig = /* @__PURE__ */ __name(async (extensionName, sc
|
|
|
1321
1447
|
const configFile = await getConfigFile(_workspaceRoot);
|
|
1322
1448
|
if (!configFile) {
|
|
1323
1449
|
if (!skipLogs) {
|
|
1324
|
-
writeWarning(
|
|
1325
|
-
|
|
1326
|
-
|
|
1450
|
+
writeWarning(
|
|
1451
|
+
"No Storm Workspace configuration file found in the current repository. Please ensure this is the expected behavior - you can add a `storm-workspace.json` file to the root of your workspace if it is not.\n",
|
|
1452
|
+
{ logLevel: "all" }
|
|
1453
|
+
);
|
|
1327
1454
|
}
|
|
1328
1455
|
if (useDefault === false) {
|
|
1329
1456
|
return void 0;
|
|
1330
1457
|
}
|
|
1331
1458
|
}
|
|
1332
1459
|
const defaultConfig = await getDefaultConfig(_workspaceRoot);
|
|
1333
|
-
result = await stormWorkspaceConfigSchema.parseAsync(
|
|
1460
|
+
result = await stormWorkspaceConfigSchema.parseAsync(
|
|
1461
|
+
defu2(configEnv, configFile, defaultConfig)
|
|
1462
|
+
);
|
|
1334
1463
|
result.workspaceRoot ??= _workspaceRoot;
|
|
1335
1464
|
} else {
|
|
1336
1465
|
result = _static_cache.data;
|
|
@@ -1346,11 +1475,9 @@ var createStormWorkspaceConfig = /* @__PURE__ */ __name(async (extensionName, sc
|
|
|
1346
1475
|
data: result
|
|
1347
1476
|
};
|
|
1348
1477
|
return result;
|
|
1349
|
-
}
|
|
1350
|
-
var createConfigExtension =
|
|
1351
|
-
const extension_cache_key = {
|
|
1352
|
-
extensionName
|
|
1353
|
-
};
|
|
1478
|
+
};
|
|
1479
|
+
var createConfigExtension = (extensionName, schema) => {
|
|
1480
|
+
const extension_cache_key = { extensionName };
|
|
1354
1481
|
if (_extension_cache.has(extension_cache_key)) {
|
|
1355
1482
|
return _extension_cache.get(extension_cache_key);
|
|
1356
1483
|
}
|
|
@@ -1360,27 +1487,40 @@ var createConfigExtension = /* @__PURE__ */ __name((extensionName, schema) => {
|
|
|
1360
1487
|
}
|
|
1361
1488
|
_extension_cache.set(extension_cache_key, extension);
|
|
1362
1489
|
return extension;
|
|
1363
|
-
}
|
|
1364
|
-
var loadStormWorkspaceConfig =
|
|
1365
|
-
const config = await createStormWorkspaceConfig(
|
|
1490
|
+
};
|
|
1491
|
+
var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
|
|
1492
|
+
const config = await createStormWorkspaceConfig(
|
|
1493
|
+
void 0,
|
|
1494
|
+
void 0,
|
|
1495
|
+
workspaceRoot,
|
|
1496
|
+
skipLogs,
|
|
1497
|
+
true
|
|
1498
|
+
);
|
|
1366
1499
|
setConfigEnv(config);
|
|
1367
1500
|
if (!skipLogs && !config.skipConfigLogging) {
|
|
1368
|
-
writeTrace(
|
|
1369
|
-
|
|
1501
|
+
writeTrace(
|
|
1502
|
+
`\u2699\uFE0F Using Storm Workspace configuration:
|
|
1503
|
+
${formatLogMessage(config)}`,
|
|
1504
|
+
config
|
|
1505
|
+
);
|
|
1370
1506
|
}
|
|
1371
1507
|
return config;
|
|
1372
|
-
}
|
|
1508
|
+
};
|
|
1373
1509
|
|
|
1374
1510
|
// ../config-tools/src/get-config.ts
|
|
1375
|
-
var getConfig =
|
|
1511
|
+
var getConfig = (workspaceRoot, skipLogs = false) => {
|
|
1376
1512
|
return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
|
|
1377
|
-
}
|
|
1513
|
+
};
|
|
1378
1514
|
|
|
1379
1515
|
// bin/unbuild.ts
|
|
1380
1516
|
import { Command, Option } from "commander";
|
|
1381
1517
|
|
|
1382
1518
|
// src/build.ts
|
|
1383
|
-
import {
|
|
1519
|
+
import {
|
|
1520
|
+
createProjectGraphAsync as createProjectGraphAsync3,
|
|
1521
|
+
readCachedProjectGraph as readCachedProjectGraph3,
|
|
1522
|
+
writeJsonFile
|
|
1523
|
+
} from "@nx/devkit";
|
|
1384
1524
|
import { getHelperDependency as getHelperDependency2, HelperDependency as HelperDependency2 } from "@nx/js";
|
|
1385
1525
|
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies3 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1386
1526
|
|
|
@@ -1401,7 +1541,7 @@ import { relative } from "path";
|
|
|
1401
1541
|
import { CopyAssetsHandler } from "@nx/js/src/utils/assets/copy-assets-handler";
|
|
1402
1542
|
import { glob } from "glob";
|
|
1403
1543
|
import { readFile as readFile2, writeFile } from "node:fs/promises";
|
|
1404
|
-
var copyAssets =
|
|
1544
|
+
var copyAssets = async (config, assets, outputPath, projectRoot, sourceRoot, generatePackageJson2 = true, includeSrc = false, banner, footer) => {
|
|
1405
1545
|
const pendingAssets = Array.from(assets ?? []);
|
|
1406
1546
|
pendingAssets.push({
|
|
1407
1547
|
input: projectRoot,
|
|
@@ -1427,8 +1567,11 @@ var copyAssets = /* @__PURE__ */ __name(async (config, assets, outputPath, proje
|
|
|
1427
1567
|
output: "src/"
|
|
1428
1568
|
});
|
|
1429
1569
|
}
|
|
1430
|
-
writeTrace(
|
|
1431
|
-
|
|
1570
|
+
writeTrace(
|
|
1571
|
+
`\u{1F4DD} Copying the following assets to the output directory:
|
|
1572
|
+
${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${pendingAsset} -> ${outputPath}` : ` - ${pendingAsset.input}/${pendingAsset.glob} -> ${joinPaths(outputPath, pendingAsset.output)}`).join("\n")}`,
|
|
1573
|
+
config
|
|
1574
|
+
);
|
|
1432
1575
|
const assetHandler = new CopyAssetsHandler({
|
|
1433
1576
|
projectDir: projectRoot,
|
|
1434
1577
|
rootDir: config.workspaceRoot,
|
|
@@ -1437,28 +1580,45 @@ ${pendingAssets.map((pendingAsset) => typeof pendingAsset === "string" ? ` - ${p
|
|
|
1437
1580
|
});
|
|
1438
1581
|
await assetHandler.processAllAssetsOnce();
|
|
1439
1582
|
if (includeSrc === true) {
|
|
1440
|
-
writeDebug(
|
|
1583
|
+
writeDebug(
|
|
1584
|
+
`\u{1F4DD} Adding banner and writing source files: ${joinPaths(
|
|
1585
|
+
outputPath,
|
|
1586
|
+
"src"
|
|
1587
|
+
)}`,
|
|
1588
|
+
config
|
|
1589
|
+
);
|
|
1441
1590
|
const files = await glob([
|
|
1442
1591
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.ts"),
|
|
1443
1592
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.tsx"),
|
|
1444
1593
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.js"),
|
|
1445
1594
|
joinPaths(config.workspaceRoot, outputPath, "src/**/*.jsx")
|
|
1446
1595
|
]);
|
|
1447
|
-
await Promise.allSettled(
|
|
1596
|
+
await Promise.allSettled(
|
|
1597
|
+
files.map(
|
|
1598
|
+
async (file) => writeFile(
|
|
1599
|
+
file,
|
|
1600
|
+
`${banner && typeof banner === "string" ? banner.startsWith("//") ? banner : `// ${banner}` : ""}
|
|
1448
1601
|
|
|
1449
1602
|
${await readFile2(file, "utf8")}
|
|
1450
1603
|
|
|
1451
|
-
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`
|
|
1604
|
+
${footer && typeof footer === "string" ? footer.startsWith("//") ? footer : `// ${footer}` : ""}`
|
|
1605
|
+
)
|
|
1606
|
+
)
|
|
1607
|
+
);
|
|
1452
1608
|
}
|
|
1453
|
-
}
|
|
1609
|
+
};
|
|
1454
1610
|
|
|
1455
1611
|
// ../build-tools/src/utilities/generate-package-json.ts
|
|
1456
1612
|
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1457
1613
|
import { Glob } from "glob";
|
|
1458
1614
|
import { existsSync as existsSync3, readFileSync } from "node:fs";
|
|
1459
1615
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
1460
|
-
import {
|
|
1461
|
-
|
|
1616
|
+
import {
|
|
1617
|
+
createProjectGraphAsync,
|
|
1618
|
+
readCachedProjectGraph,
|
|
1619
|
+
readProjectsConfigurationFromProjectGraph
|
|
1620
|
+
} from "nx/src/project-graph/project-graph";
|
|
1621
|
+
var addPackageDependencies = async (workspaceRoot, projectRoot, projectName, packageJson) => {
|
|
1462
1622
|
let projectGraph;
|
|
1463
1623
|
try {
|
|
1464
1624
|
projectGraph = readCachedProjectGraph();
|
|
@@ -1467,16 +1627,35 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
1467
1627
|
projectGraph = readCachedProjectGraph();
|
|
1468
1628
|
}
|
|
1469
1629
|
if (!projectGraph) {
|
|
1470
|
-
throw new Error(
|
|
1630
|
+
throw new Error(
|
|
1631
|
+
"The Build process failed because the project graph is not available. Please run the build command again."
|
|
1632
|
+
);
|
|
1471
1633
|
}
|
|
1472
|
-
const projectDependencies = calculateProjectBuildableDependencies(
|
|
1634
|
+
const projectDependencies = calculateProjectBuildableDependencies(
|
|
1635
|
+
void 0,
|
|
1636
|
+
projectGraph,
|
|
1637
|
+
workspaceRoot,
|
|
1638
|
+
projectName,
|
|
1639
|
+
process.env.NX_TASK_TARGET_TARGET || "build",
|
|
1640
|
+
process.env.NX_TASK_TARGET_CONFIGURATION || "production",
|
|
1641
|
+
true
|
|
1642
|
+
);
|
|
1473
1643
|
const localPackages = [];
|
|
1474
|
-
for (const project of projectDependencies.dependencies.filter(
|
|
1644
|
+
for (const project of projectDependencies.dependencies.filter(
|
|
1645
|
+
(dep) => dep.node.type === "lib" && dep.node.data?.root !== projectRoot && dep.node.data?.root !== workspaceRoot
|
|
1646
|
+
)) {
|
|
1475
1647
|
const projectNode = project.node;
|
|
1476
1648
|
if (projectNode.data.root) {
|
|
1477
|
-
const projectPackageJsonPath = joinPaths(
|
|
1649
|
+
const projectPackageJsonPath = joinPaths(
|
|
1650
|
+
workspaceRoot,
|
|
1651
|
+
projectNode.data.root,
|
|
1652
|
+
"package.json"
|
|
1653
|
+
);
|
|
1478
1654
|
if (existsSync3(projectPackageJsonPath)) {
|
|
1479
|
-
const projectPackageJsonContent = await readFile3(
|
|
1655
|
+
const projectPackageJsonContent = await readFile3(
|
|
1656
|
+
projectPackageJsonPath,
|
|
1657
|
+
"utf8"
|
|
1658
|
+
);
|
|
1480
1659
|
const projectPackageJson = JSON.parse(projectPackageJsonContent);
|
|
1481
1660
|
if (projectPackageJson.private !== true) {
|
|
1482
1661
|
localPackages.push(projectPackageJson);
|
|
@@ -1485,19 +1664,33 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
1485
1664
|
}
|
|
1486
1665
|
}
|
|
1487
1666
|
if (localPackages.length > 0) {
|
|
1488
|
-
writeTrace(
|
|
1489
|
-
|
|
1667
|
+
writeTrace(
|
|
1668
|
+
`\u{1F4E6} Adding local packages to package.json: ${localPackages.map((p) => p.name).join(", ")}`
|
|
1669
|
+
);
|
|
1670
|
+
const projectJsonFile = await readFile3(
|
|
1671
|
+
joinPaths(projectRoot, "project.json"),
|
|
1672
|
+
"utf8"
|
|
1673
|
+
);
|
|
1490
1674
|
const projectJson = JSON.parse(projectJsonFile);
|
|
1491
1675
|
const projectName2 = projectJson.name;
|
|
1492
1676
|
const projectConfigurations = readProjectsConfigurationFromProjectGraph(projectGraph);
|
|
1493
1677
|
if (!projectConfigurations?.projects?.[projectName2]) {
|
|
1494
|
-
throw new Error(
|
|
1678
|
+
throw new Error(
|
|
1679
|
+
"The Build process failed because the project does not have a valid configuration in the project.json file. Check if the file exists in the root of the project."
|
|
1680
|
+
);
|
|
1495
1681
|
}
|
|
1496
1682
|
const implicitDependencies = projectConfigurations.projects?.[projectName2].implicitDependencies?.reduce((ret, dep) => {
|
|
1497
1683
|
if (projectConfigurations.projects?.[dep]) {
|
|
1498
|
-
const depPackageJsonPath = joinPaths(
|
|
1684
|
+
const depPackageJsonPath = joinPaths(
|
|
1685
|
+
workspaceRoot,
|
|
1686
|
+
projectConfigurations.projects[dep].root,
|
|
1687
|
+
"package.json"
|
|
1688
|
+
);
|
|
1499
1689
|
if (existsSync3(depPackageJsonPath)) {
|
|
1500
|
-
const depPackageJsonContent = readFileSync(
|
|
1690
|
+
const depPackageJsonContent = readFileSync(
|
|
1691
|
+
depPackageJsonPath,
|
|
1692
|
+
"utf8"
|
|
1693
|
+
);
|
|
1501
1694
|
const depPackageJson = JSON.parse(depPackageJsonContent);
|
|
1502
1695
|
if (depPackageJson.private !== true && !ret.includes(depPackageJson.name)) {
|
|
1503
1696
|
ret.push(depPackageJson.name);
|
|
@@ -1522,10 +1715,13 @@ var addPackageDependencies = /* @__PURE__ */ __name(async (workspaceRoot, projec
|
|
|
1522
1715
|
writeTrace("\u{1F4E6} No local packages dependencies to add to package.json");
|
|
1523
1716
|
}
|
|
1524
1717
|
return packageJson;
|
|
1525
|
-
}
|
|
1526
|
-
var addWorkspacePackageJsonFields =
|
|
1718
|
+
};
|
|
1719
|
+
var addWorkspacePackageJsonFields = async (workspaceConfig, projectRoot, sourceRoot, projectName, includeSrc = false, packageJson) => {
|
|
1527
1720
|
const workspaceRoot = workspaceConfig.workspaceRoot ? workspaceConfig.workspaceRoot : findWorkspaceRoot();
|
|
1528
|
-
const workspacePackageJsonContent = await readFile3(
|
|
1721
|
+
const workspacePackageJsonContent = await readFile3(
|
|
1722
|
+
joinPaths(workspaceRoot, "package.json"),
|
|
1723
|
+
"utf8"
|
|
1724
|
+
);
|
|
1529
1725
|
const workspacePackageJson = JSON.parse(workspacePackageJsonContent);
|
|
1530
1726
|
packageJson.type ??= "module";
|
|
1531
1727
|
packageJson.sideEffects ??= false;
|
|
@@ -1536,9 +1732,7 @@ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (workspaceConfi
|
|
|
1536
1732
|
}
|
|
1537
1733
|
packageJson.source ??= `${joinPaths(distSrc, "index.ts").replaceAll("\\", "/")}`;
|
|
1538
1734
|
}
|
|
1539
|
-
packageJson.files ??= [
|
|
1540
|
-
"dist/**/*"
|
|
1541
|
-
];
|
|
1735
|
+
packageJson.files ??= ["dist/**/*"];
|
|
1542
1736
|
if (includeSrc === true && !packageJson.files.includes("src")) {
|
|
1543
1737
|
packageJson.files.push("src/**/*");
|
|
1544
1738
|
}
|
|
@@ -1554,20 +1748,16 @@ var addWorkspacePackageJsonFields = /* @__PURE__ */ __name(async (workspaceConfi
|
|
|
1554
1748
|
packageJson.author ??= workspacePackageJson.author;
|
|
1555
1749
|
packageJson.maintainers ??= workspacePackageJson.maintainers;
|
|
1556
1750
|
if (!packageJson.maintainers && packageJson.author) {
|
|
1557
|
-
packageJson.maintainers = [
|
|
1558
|
-
packageJson.author
|
|
1559
|
-
];
|
|
1751
|
+
packageJson.maintainers = [packageJson.author];
|
|
1560
1752
|
}
|
|
1561
1753
|
packageJson.contributors ??= workspacePackageJson.contributors;
|
|
1562
1754
|
if (!packageJson.contributors && packageJson.author) {
|
|
1563
|
-
packageJson.contributors = [
|
|
1564
|
-
packageJson.author
|
|
1565
|
-
];
|
|
1755
|
+
packageJson.contributors = [packageJson.author];
|
|
1566
1756
|
}
|
|
1567
1757
|
packageJson.repository ??= workspacePackageJson.repository;
|
|
1568
1758
|
packageJson.repository.directory ??= projectRoot ? projectRoot : joinPaths("packages", projectName);
|
|
1569
1759
|
return packageJson;
|
|
1570
|
-
}
|
|
1760
|
+
};
|
|
1571
1761
|
|
|
1572
1762
|
// ../build-tools/src/utilities/get-entry-points.ts
|
|
1573
1763
|
import { glob as glob2 } from "glob";
|
|
@@ -1577,7 +1767,10 @@ import { existsSync as existsSync4 } from "node:fs";
|
|
|
1577
1767
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
1578
1768
|
|
|
1579
1769
|
// ../build-tools/src/utilities/task-graph.ts
|
|
1580
|
-
import {
|
|
1770
|
+
import {
|
|
1771
|
+
createTaskGraph,
|
|
1772
|
+
mapTargetDefaultsToDependencies
|
|
1773
|
+
} from "nx/src/tasks-runner/create-task-graph";
|
|
1581
1774
|
|
|
1582
1775
|
// src/build.ts
|
|
1583
1776
|
import defu3 from "defu";
|
|
@@ -1586,7 +1779,9 @@ import { existsSync as existsSync5 } from "node:fs";
|
|
|
1586
1779
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
1587
1780
|
import { relative as relative2 } from "node:path";
|
|
1588
1781
|
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
1589
|
-
import {
|
|
1782
|
+
import {
|
|
1783
|
+
build as unbuild
|
|
1784
|
+
} from "unbuild";
|
|
1590
1785
|
|
|
1591
1786
|
// src/clean.ts
|
|
1592
1787
|
import { rm } from "node:fs/promises";
|
|
@@ -1596,30 +1791,20 @@ async function clean(name = "Unbuild", directory, config) {
|
|
|
1596
1791
|
await cleanDirectories(name, directory, config);
|
|
1597
1792
|
stopwatch();
|
|
1598
1793
|
}
|
|
1599
|
-
__name(clean, "clean");
|
|
1600
1794
|
async function cleanDirectories(name = "Unbuild", directory, config) {
|
|
1601
|
-
await rm(directory, {
|
|
1602
|
-
recursive: true,
|
|
1603
|
-
force: true
|
|
1604
|
-
});
|
|
1795
|
+
await rm(directory, { recursive: true, force: true });
|
|
1605
1796
|
}
|
|
1606
|
-
__name(cleanDirectories, "cleanDirectories");
|
|
1607
1797
|
|
|
1608
1798
|
// src/plugins/analyze.ts
|
|
1609
|
-
var formatBytes =
|
|
1799
|
+
var formatBytes = (bytes) => {
|
|
1610
1800
|
if (bytes === 0) return "0 Byte";
|
|
1611
1801
|
const k = 1e3;
|
|
1612
1802
|
const dm = 3;
|
|
1613
|
-
const sizes = [
|
|
1614
|
-
"Bytes",
|
|
1615
|
-
"KB",
|
|
1616
|
-
"MB",
|
|
1617
|
-
"GB"
|
|
1618
|
-
];
|
|
1803
|
+
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
1619
1804
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1620
1805
|
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
|
|
1621
|
-
}
|
|
1622
|
-
var analyzePlugin =
|
|
1806
|
+
};
|
|
1807
|
+
var analyzePlugin = (options) => {
|
|
1623
1808
|
return {
|
|
1624
1809
|
name: "storm:analyzer",
|
|
1625
1810
|
renderChunk(source, chunk) {
|
|
@@ -1628,38 +1813,52 @@ var analyzePlugin = /* @__PURE__ */ __name((options) => {
|
|
|
1628
1813
|
writeInfo(` - ${fileName} ${sourceBytes}`, options.config);
|
|
1629
1814
|
}
|
|
1630
1815
|
};
|
|
1631
|
-
}
|
|
1816
|
+
};
|
|
1632
1817
|
|
|
1633
1818
|
// src/plugins/on-error.ts
|
|
1634
|
-
var onErrorPlugin =
|
|
1819
|
+
var onErrorPlugin = (options) => ({
|
|
1635
1820
|
name: "storm:on-error",
|
|
1636
1821
|
buildEnd(error) {
|
|
1637
1822
|
if (error) {
|
|
1638
|
-
writeError(
|
|
1823
|
+
writeError(
|
|
1824
|
+
`The following errors occurred during the build:
|
|
1639
1825
|
${error ? error.message : "Unknown build error"}
|
|
1640
1826
|
|
|
1641
|
-
`,
|
|
1827
|
+
`,
|
|
1828
|
+
options.config
|
|
1829
|
+
);
|
|
1642
1830
|
throw new Error("Storm unbuild process failed with errors.");
|
|
1643
1831
|
}
|
|
1644
1832
|
},
|
|
1645
1833
|
renderError(error) {
|
|
1646
|
-
writeError(
|
|
1834
|
+
writeError(
|
|
1835
|
+
`The following errors occurred during the build:
|
|
1647
1836
|
${error ? error.message : "Unknown build error"}
|
|
1648
1837
|
|
|
1649
|
-
`,
|
|
1838
|
+
`,
|
|
1839
|
+
options.config
|
|
1840
|
+
);
|
|
1650
1841
|
throw new Error("Storm unbuild process failed with errors.");
|
|
1651
1842
|
}
|
|
1652
|
-
})
|
|
1843
|
+
});
|
|
1653
1844
|
|
|
1654
1845
|
// src/plugins/tsc.ts
|
|
1655
|
-
import {
|
|
1846
|
+
import {
|
|
1847
|
+
createProjectGraphAsync as createProjectGraphAsync2,
|
|
1848
|
+
readCachedProjectGraph as readCachedProjectGraph2
|
|
1849
|
+
} from "@nx/devkit";
|
|
1656
1850
|
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1657
|
-
import {
|
|
1851
|
+
import {
|
|
1852
|
+
getHelperDependency,
|
|
1853
|
+
HelperDependency
|
|
1854
|
+
} from "@nx/js/src/utils/compiler-helper-dependency";
|
|
1658
1855
|
import ts2Plugin from "rollup-plugin-typescript2";
|
|
1659
1856
|
|
|
1660
1857
|
// src/utilities/helpers.ts
|
|
1661
1858
|
import { joinPathFragments } from "@nx/devkit";
|
|
1662
|
-
import {
|
|
1859
|
+
import {
|
|
1860
|
+
computeCompilerOptionsPaths
|
|
1861
|
+
} from "@nx/js/src/utils/buildable-libs-utils";
|
|
1663
1862
|
import { dirname, extname } from "node:path";
|
|
1664
1863
|
import { pathToFileURL } from "node:url";
|
|
1665
1864
|
import ts from "typescript";
|
|
@@ -1667,12 +1866,20 @@ async function loadConfig2(configPath) {
|
|
|
1667
1866
|
if (!/\.(js|mjs)$/.test(extname(configPath))) {
|
|
1668
1867
|
throw new Error("Unsupported config file format");
|
|
1669
1868
|
}
|
|
1670
|
-
return import(pathToFileURL(configPath).toString()).then(
|
|
1869
|
+
return import(pathToFileURL(configPath).toString()).then(
|
|
1870
|
+
(config) => config.default
|
|
1871
|
+
);
|
|
1671
1872
|
}
|
|
1672
|
-
__name(loadConfig2, "loadConfig");
|
|
1673
1873
|
async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
|
|
1674
|
-
const tsConfigFile = ts.readConfigFile(
|
|
1675
|
-
|
|
1874
|
+
const tsConfigFile = ts.readConfigFile(
|
|
1875
|
+
joinPathFragments(config.workspaceRoot, projectRoot, tsConfigPath),
|
|
1876
|
+
ts.sys.readFile
|
|
1877
|
+
);
|
|
1878
|
+
const tsConfig = ts.parseJsonConfigFileContent(
|
|
1879
|
+
tsConfigFile.config,
|
|
1880
|
+
ts.sys,
|
|
1881
|
+
dirname(joinPathFragments(config.workspaceRoot, projectRoot, tsConfigPath))
|
|
1882
|
+
);
|
|
1676
1883
|
const compilerOptions = {
|
|
1677
1884
|
rootDir: projectRoot,
|
|
1678
1885
|
declaration: true,
|
|
@@ -1681,10 +1888,9 @@ async function createTsCompilerOptions(config, tsConfigPath, projectRoot, depend
|
|
|
1681
1888
|
writeTrace(compilerOptions, config);
|
|
1682
1889
|
return compilerOptions;
|
|
1683
1890
|
}
|
|
1684
|
-
__name(createTsCompilerOptions, "createTsCompilerOptions");
|
|
1685
1891
|
|
|
1686
1892
|
// src/plugins/tsc.ts
|
|
1687
|
-
var tscPlugin =
|
|
1893
|
+
var tscPlugin = async (options) => {
|
|
1688
1894
|
let projectGraph;
|
|
1689
1895
|
try {
|
|
1690
1896
|
projectGraph = readCachedProjectGraph2();
|
|
@@ -1693,22 +1899,45 @@ var tscPlugin = /* @__PURE__ */ __name(async (options) => {
|
|
|
1693
1899
|
projectGraph = readCachedProjectGraph2();
|
|
1694
1900
|
}
|
|
1695
1901
|
if (!projectGraph) {
|
|
1696
|
-
throw new Error(
|
|
1697
|
-
|
|
1698
|
-
|
|
1902
|
+
throw new Error(
|
|
1903
|
+
"The build process failed because the project graph is not available. Please run the build command again."
|
|
1904
|
+
);
|
|
1905
|
+
}
|
|
1906
|
+
const result = calculateProjectBuildableDependencies2(
|
|
1907
|
+
void 0,
|
|
1908
|
+
projectGraph,
|
|
1909
|
+
options.config.workspaceRoot,
|
|
1910
|
+
options.projectName,
|
|
1911
|
+
process.env.NX_TASK_TARGET_TARGET || "build",
|
|
1912
|
+
process.env.NX_TASK_TARGET_CONFIGURATION || "production",
|
|
1913
|
+
true
|
|
1914
|
+
);
|
|
1699
1915
|
let dependencies = result.dependencies;
|
|
1700
|
-
const tsLibDependency = getHelperDependency(
|
|
1916
|
+
const tsLibDependency = getHelperDependency(
|
|
1917
|
+
HelperDependency.tsc,
|
|
1918
|
+
options.tsconfig,
|
|
1919
|
+
dependencies,
|
|
1920
|
+
projectGraph,
|
|
1921
|
+
true
|
|
1922
|
+
);
|
|
1701
1923
|
if (tsLibDependency) {
|
|
1702
|
-
dependencies = dependencies.filter(
|
|
1924
|
+
dependencies = dependencies.filter(
|
|
1925
|
+
(deps) => deps.name !== tsLibDependency.name
|
|
1926
|
+
);
|
|
1703
1927
|
dependencies.push(tsLibDependency);
|
|
1704
1928
|
}
|
|
1705
|
-
const compilerOptions = await createTsCompilerOptions(
|
|
1929
|
+
const compilerOptions = await createTsCompilerOptions(
|
|
1930
|
+
options.config,
|
|
1931
|
+
options.tsconfig,
|
|
1932
|
+
options.projectRoot,
|
|
1933
|
+
dependencies
|
|
1934
|
+
);
|
|
1706
1935
|
return ts2Plugin({
|
|
1707
1936
|
check: options.declaration !== false,
|
|
1708
1937
|
tsconfig: options.tsconfig,
|
|
1709
1938
|
tsconfigOverride: compilerOptions
|
|
1710
1939
|
});
|
|
1711
|
-
}
|
|
1940
|
+
};
|
|
1712
1941
|
|
|
1713
1942
|
// src/build.ts
|
|
1714
1943
|
async function resolveOptions(options, config) {
|
|
@@ -1729,16 +1958,26 @@ async function resolveOptions(options, config) {
|
|
|
1729
1958
|
projectGraph = readCachedProjectGraph3();
|
|
1730
1959
|
}
|
|
1731
1960
|
if (!projectGraph) {
|
|
1732
|
-
throw new Error(
|
|
1733
|
-
|
|
1734
|
-
|
|
1961
|
+
throw new Error(
|
|
1962
|
+
"The build process failed because the project graph is not available. Please run the build command again."
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1965
|
+
const projectJsonPath = joinPaths(
|
|
1966
|
+
config.workspaceRoot,
|
|
1967
|
+
options.projectRoot,
|
|
1968
|
+
"project.json"
|
|
1969
|
+
);
|
|
1735
1970
|
if (!existsSync5(projectJsonPath)) {
|
|
1736
1971
|
throw new Error("Cannot find project.json configuration");
|
|
1737
1972
|
}
|
|
1738
1973
|
const projectJsonContent = await readFile5(projectJsonPath, "utf8");
|
|
1739
1974
|
const projectJson = JSON.parse(projectJsonContent);
|
|
1740
1975
|
const projectName = projectJson.name;
|
|
1741
|
-
const packageJsonPath = joinPaths(
|
|
1976
|
+
const packageJsonPath = joinPaths(
|
|
1977
|
+
config.workspaceRoot,
|
|
1978
|
+
options.projectRoot,
|
|
1979
|
+
"package.json"
|
|
1980
|
+
);
|
|
1742
1981
|
if (!existsSync5(packageJsonPath)) {
|
|
1743
1982
|
throw new Error("Cannot find package.json configuration");
|
|
1744
1983
|
}
|
|
@@ -1761,17 +2000,31 @@ async function resolveOptions(options, config) {
|
|
|
1761
2000
|
if (!existsSync5(sourceRoot)) {
|
|
1762
2001
|
throw new Error("Cannot find sourceRoot directory");
|
|
1763
2002
|
}
|
|
1764
|
-
const result = calculateProjectBuildableDependencies3(
|
|
2003
|
+
const result = calculateProjectBuildableDependencies3(
|
|
2004
|
+
void 0,
|
|
2005
|
+
projectGraph,
|
|
2006
|
+
config.workspaceRoot,
|
|
2007
|
+
projectName,
|
|
2008
|
+
process.env.NX_TASK_TARGET_TARGET || "build",
|
|
2009
|
+
process.env.NX_TASK_TARGET_CONFIGURATION || "production",
|
|
2010
|
+
true
|
|
2011
|
+
);
|
|
1765
2012
|
let dependencies = result.dependencies;
|
|
1766
|
-
const tsLibDependency = getHelperDependency2(
|
|
2013
|
+
const tsLibDependency = getHelperDependency2(
|
|
2014
|
+
HelperDependency2.tsc,
|
|
2015
|
+
tsconfig,
|
|
2016
|
+
dependencies,
|
|
2017
|
+
projectGraph,
|
|
2018
|
+
true
|
|
2019
|
+
);
|
|
1767
2020
|
if (tsLibDependency) {
|
|
1768
|
-
dependencies = dependencies.filter(
|
|
2021
|
+
dependencies = dependencies.filter(
|
|
2022
|
+
(deps) => deps.name !== tsLibDependency.name
|
|
2023
|
+
);
|
|
1769
2024
|
dependencies.push(tsLibDependency);
|
|
1770
2025
|
}
|
|
1771
2026
|
const name = options.name || projectName;
|
|
1772
|
-
const entries = options.entry ?? [
|
|
1773
|
-
sourceRoot
|
|
1774
|
-
];
|
|
2027
|
+
const entries = options.entry ?? [sourceRoot];
|
|
1775
2028
|
const resolvedOptions = {
|
|
1776
2029
|
...options,
|
|
1777
2030
|
name,
|
|
@@ -1791,7 +2044,14 @@ async function resolveOptions(options, config) {
|
|
|
1791
2044
|
while (entryPath.startsWith("/")) {
|
|
1792
2045
|
entryPath = entryPath.substring(1);
|
|
1793
2046
|
}
|
|
1794
|
-
const outDir = joinPaths(
|
|
2047
|
+
const outDir = joinPaths(
|
|
2048
|
+
relative2(
|
|
2049
|
+
joinPaths(config.workspaceRoot, options.projectRoot),
|
|
2050
|
+
config.workspaceRoot
|
|
2051
|
+
),
|
|
2052
|
+
outputPath,
|
|
2053
|
+
"dist"
|
|
2054
|
+
);
|
|
1795
2055
|
ret.push({
|
|
1796
2056
|
name: `${name}-esm`,
|
|
1797
2057
|
builder: "mkdist",
|
|
@@ -1869,7 +2129,9 @@ async function resolveOptions(options, config) {
|
|
|
1869
2129
|
}
|
|
1870
2130
|
}
|
|
1871
2131
|
};
|
|
1872
|
-
dependencies = dependencies.filter(
|
|
2132
|
+
dependencies = dependencies.filter(
|
|
2133
|
+
(dep) => dep.node.type === "npm" || dep.node.type === "lib" || dep.node.type === "app"
|
|
2134
|
+
);
|
|
1873
2135
|
if (dependencies.length > 0) {
|
|
1874
2136
|
resolvedOptions.dependencies = dependencies.map((dep) => dep.name);
|
|
1875
2137
|
}
|
|
@@ -1877,7 +2139,9 @@ async function resolveOptions(options, config) {
|
|
|
1877
2139
|
resolvedOptions.devDependencies = Object.keys(packageJson.devDependencies);
|
|
1878
2140
|
}
|
|
1879
2141
|
if (packageJson.peerDependencies) {
|
|
1880
|
-
resolvedOptions.peerDependencies = Object.keys(
|
|
2142
|
+
resolvedOptions.peerDependencies = Object.keys(
|
|
2143
|
+
packageJson.peerDependencies
|
|
2144
|
+
);
|
|
1881
2145
|
}
|
|
1882
2146
|
if (options.rollup) {
|
|
1883
2147
|
let rollup = {};
|
|
@@ -1892,38 +2156,45 @@ async function resolveOptions(options, config) {
|
|
|
1892
2156
|
resolvedOptions.rollup = defu3(resolvedOptions.rollup ?? {}, rollup);
|
|
1893
2157
|
}
|
|
1894
2158
|
resolvedOptions.hooks = {
|
|
1895
|
-
"rollup:options":
|
|
2159
|
+
"rollup:options": async (ctx, opts) => {
|
|
1896
2160
|
if (options.plugins && options.plugins.length > 0) {
|
|
1897
|
-
writeDebug(
|
|
2161
|
+
writeDebug(
|
|
2162
|
+
` \u{1F9E9} Found ${options.plugins.length} plugins in provided build options`,
|
|
2163
|
+
config
|
|
2164
|
+
);
|
|
1898
2165
|
opts.plugins = options.plugins;
|
|
1899
2166
|
} else {
|
|
1900
|
-
writeDebug(
|
|
2167
|
+
writeDebug(
|
|
2168
|
+
` \u{1F9E9} No plugins found in provided build options, using default plugins`,
|
|
2169
|
+
config
|
|
2170
|
+
);
|
|
1901
2171
|
opts.plugins = await Promise.all([
|
|
1902
2172
|
analyzePlugin(resolvedOptions),
|
|
1903
2173
|
tscPlugin(resolvedOptions),
|
|
1904
2174
|
onErrorPlugin(resolvedOptions)
|
|
1905
2175
|
]);
|
|
1906
2176
|
}
|
|
1907
|
-
},
|
|
1908
|
-
"mkdist:entry:options":
|
|
2177
|
+
},
|
|
2178
|
+
"mkdist:entry:options": async (ctx, entry, opts) => {
|
|
1909
2179
|
opts.esbuild ||= {};
|
|
1910
2180
|
opts.esbuild.platform ??= resolvedOptions.platform;
|
|
1911
2181
|
opts.esbuild.minify ??= resolvedOptions.minify ?? !resolvedOptions.debug;
|
|
1912
2182
|
opts.esbuild.sourcemap ??= resolvedOptions.sourcemap ?? !!options.debug;
|
|
1913
2183
|
if (options.loaders) {
|
|
1914
2184
|
if (typeof options.loaders === "function") {
|
|
1915
|
-
opts.loaders = await Promise.resolve(
|
|
2185
|
+
opts.loaders = await Promise.resolve(
|
|
2186
|
+
options.loaders(ctx, entry, opts)
|
|
2187
|
+
);
|
|
1916
2188
|
} else {
|
|
1917
2189
|
opts.loaders = options.loaders;
|
|
1918
2190
|
}
|
|
1919
2191
|
}
|
|
1920
|
-
}
|
|
2192
|
+
}
|
|
1921
2193
|
};
|
|
1922
2194
|
stopwatch();
|
|
1923
2195
|
return resolvedOptions;
|
|
1924
2196
|
}
|
|
1925
|
-
|
|
1926
|
-
var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", sourceRoot, projectRoot) => {
|
|
2197
|
+
var addPackageJsonExport = (file, type = "module", sourceRoot, projectRoot) => {
|
|
1927
2198
|
let root = sourceRoot.replace(projectRoot, "");
|
|
1928
2199
|
while (root.startsWith(".")) {
|
|
1929
2200
|
root = root.substring(1);
|
|
@@ -1952,7 +2223,7 @@ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", source
|
|
|
1952
2223
|
default: type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
|
|
1953
2224
|
}
|
|
1954
2225
|
};
|
|
1955
|
-
}
|
|
2226
|
+
};
|
|
1956
2227
|
async function generatePackageJson(options) {
|
|
1957
2228
|
if (options.generatePackageJson !== false && existsSync5(joinPaths(options.projectRoot, "package.json"))) {
|
|
1958
2229
|
writeDebug(" \u270D\uFE0F Writing package.json file", options.config);
|
|
@@ -1961,100 +2232,154 @@ async function generatePackageJson(options) {
|
|
|
1961
2232
|
if (!existsSync5(packageJsonPath)) {
|
|
1962
2233
|
throw new Error("Cannot find package.json configuration");
|
|
1963
2234
|
}
|
|
1964
|
-
const packageJsonContent = await readFile5(
|
|
2235
|
+
const packageJsonContent = await readFile5(
|
|
2236
|
+
joinPaths(
|
|
2237
|
+
options.config.workspaceRoot,
|
|
2238
|
+
options.projectRoot,
|
|
2239
|
+
"package.json"
|
|
2240
|
+
),
|
|
2241
|
+
"utf8"
|
|
2242
|
+
);
|
|
1965
2243
|
if (!packageJsonContent) {
|
|
1966
2244
|
throw new Error("Cannot find package.json configuration file");
|
|
1967
2245
|
}
|
|
1968
2246
|
let packageJson = JSON.parse(packageJsonContent);
|
|
1969
|
-
packageJson = await addPackageDependencies(
|
|
1970
|
-
|
|
2247
|
+
packageJson = await addPackageDependencies(
|
|
2248
|
+
options.config.workspaceRoot,
|
|
2249
|
+
options.projectRoot,
|
|
2250
|
+
options.projectName,
|
|
2251
|
+
packageJson
|
|
2252
|
+
);
|
|
2253
|
+
packageJson = await addWorkspacePackageJsonFields(
|
|
2254
|
+
options.config,
|
|
2255
|
+
options.projectRoot,
|
|
2256
|
+
options.sourceRoot,
|
|
2257
|
+
options.projectName,
|
|
2258
|
+
false,
|
|
2259
|
+
packageJson
|
|
2260
|
+
);
|
|
1971
2261
|
packageJson.exports ??= {};
|
|
1972
|
-
await Promise.all(
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
ret.
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2262
|
+
await Promise.all(
|
|
2263
|
+
options.entries.reduce((ret, entry) => {
|
|
2264
|
+
let entryPath = typeof entry === "string" ? entry : entry.input;
|
|
2265
|
+
entryPath = entryPath.replaceAll("\\", "/");
|
|
2266
|
+
while (entryPath.startsWith(".")) {
|
|
2267
|
+
entryPath = entryPath.substring(1);
|
|
2268
|
+
}
|
|
2269
|
+
while (entryPath.startsWith("/")) {
|
|
2270
|
+
entryPath = entryPath.substring(1);
|
|
2271
|
+
}
|
|
2272
|
+
entryPath = `./${joinPaths(options.projectRoot, entryPath)}`;
|
|
2273
|
+
if (!ret.includes(entryPath)) {
|
|
2274
|
+
ret.push(entryPath);
|
|
2275
|
+
}
|
|
2276
|
+
return ret;
|
|
2277
|
+
}, []).map(async (entryPath) => {
|
|
2278
|
+
const files = await new Glob2("**/*.{ts,tsx}", {
|
|
2279
|
+
absolute: false,
|
|
2280
|
+
cwd: entryPath,
|
|
2281
|
+
root: entryPath
|
|
2282
|
+
}).walk();
|
|
2283
|
+
files.forEach((file) => {
|
|
2284
|
+
addPackageJsonExport(
|
|
2285
|
+
file,
|
|
2286
|
+
packageJson.type,
|
|
2287
|
+
options.sourceRoot,
|
|
2288
|
+
options.projectRoot
|
|
2289
|
+
);
|
|
2290
|
+
const split = file.split(".");
|
|
2291
|
+
split.pop();
|
|
2292
|
+
const entry = split.join(".").replaceAll("\\", "/");
|
|
2293
|
+
packageJson.exports[`./${entry}`] ??= addPackageJsonExport(
|
|
2294
|
+
entry,
|
|
2295
|
+
packageJson.type,
|
|
2296
|
+
options.sourceRoot,
|
|
2297
|
+
options.projectRoot
|
|
2298
|
+
);
|
|
2299
|
+
});
|
|
2300
|
+
})
|
|
2301
|
+
);
|
|
2000
2302
|
packageJson.main ??= "./dist/index.cjs";
|
|
2001
2303
|
packageJson.module ??= "./dist/index.mjs";
|
|
2002
2304
|
packageJson.types ??= "./dist/index.d.ts";
|
|
2003
2305
|
packageJson.exports ??= {};
|
|
2004
|
-
packageJson.exports = Object.keys(packageJson.exports).reduce(
|
|
2005
|
-
|
|
2006
|
-
ret[key.replace("/index", "")]
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2306
|
+
packageJson.exports = Object.keys(packageJson.exports).reduce(
|
|
2307
|
+
(ret, key) => {
|
|
2308
|
+
if (key.endsWith("/index") && !ret[key.replace("/index", "")]) {
|
|
2309
|
+
ret[key.replace("/index", "")] = packageJson.exports[key];
|
|
2310
|
+
}
|
|
2311
|
+
return ret;
|
|
2312
|
+
},
|
|
2313
|
+
packageJson.exports
|
|
2314
|
+
);
|
|
2010
2315
|
packageJson.exports["./package.json"] ??= "./package.json";
|
|
2011
|
-
packageJson.exports["."] ??= addPackageJsonExport(
|
|
2316
|
+
packageJson.exports["."] ??= addPackageJsonExport(
|
|
2317
|
+
"index",
|
|
2318
|
+
packageJson.type,
|
|
2319
|
+
options.sourceRoot,
|
|
2320
|
+
options.projectRoot
|
|
2321
|
+
);
|
|
2012
2322
|
await writeJsonFile(joinPaths(options.outDir, "package.json"), packageJson);
|
|
2013
2323
|
stopwatch();
|
|
2014
2324
|
}
|
|
2015
2325
|
return options;
|
|
2016
2326
|
}
|
|
2017
|
-
__name(generatePackageJson, "generatePackageJson");
|
|
2018
2327
|
async function executeUnbuild(options) {
|
|
2019
|
-
writeDebug(
|
|
2020
|
-
|
|
2328
|
+
writeDebug(
|
|
2329
|
+
` \u{1F680} Running ${options.name} (${options.projectRoot}) build`,
|
|
2330
|
+
options.config
|
|
2331
|
+
);
|
|
2332
|
+
const stopwatch = getStopwatch(
|
|
2333
|
+
`${options.name} (${options.projectRoot}) build`
|
|
2334
|
+
);
|
|
2021
2335
|
try {
|
|
2022
2336
|
const config = {
|
|
2023
2337
|
...options,
|
|
2024
2338
|
config: null,
|
|
2025
2339
|
rootDir: joinPaths(options.config.workspaceRoot, options.projectRoot)
|
|
2026
2340
|
};
|
|
2027
|
-
writeTrace(
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2341
|
+
writeTrace(
|
|
2342
|
+
`Running with unbuild configuration:
|
|
2343
|
+
${formatLogMessage({ ...config, env: "<Hidden>" })}
|
|
2344
|
+
`,
|
|
2345
|
+
options.config
|
|
2346
|
+
);
|
|
2033
2347
|
await unbuild(options.projectRoot, false, config);
|
|
2034
2348
|
} finally {
|
|
2035
2349
|
stopwatch();
|
|
2036
2350
|
}
|
|
2037
2351
|
return options;
|
|
2038
2352
|
}
|
|
2039
|
-
__name(executeUnbuild, "executeUnbuild");
|
|
2040
2353
|
async function copyBuildAssets(options) {
|
|
2041
|
-
writeDebug(
|
|
2354
|
+
writeDebug(
|
|
2355
|
+
` \u{1F4CB} Copying asset files to output directory: ${options.outDir}`,
|
|
2356
|
+
options.config
|
|
2357
|
+
);
|
|
2042
2358
|
const stopwatch = getStopwatch(`${options.name} asset copy`);
|
|
2043
|
-
await copyAssets(
|
|
2359
|
+
await copyAssets(
|
|
2360
|
+
options.config,
|
|
2361
|
+
options.assets ?? [],
|
|
2362
|
+
options.outDir,
|
|
2363
|
+
options.projectRoot,
|
|
2364
|
+
options.sourceRoot,
|
|
2365
|
+
options.generatePackageJson,
|
|
2366
|
+
options.includeSrc
|
|
2367
|
+
);
|
|
2044
2368
|
stopwatch();
|
|
2045
2369
|
return options;
|
|
2046
2370
|
}
|
|
2047
|
-
__name(copyBuildAssets, "copyBuildAssets");
|
|
2048
2371
|
async function cleanOutputPath(options) {
|
|
2049
2372
|
if (options.clean !== false && options.outDir) {
|
|
2050
|
-
writeDebug(
|
|
2373
|
+
writeDebug(
|
|
2374
|
+
` \u{1F9F9} Cleaning ${options.name} output path: ${options.outDir}`,
|
|
2375
|
+
options.config
|
|
2376
|
+
);
|
|
2051
2377
|
const stopwatch = getStopwatch(`${options.name} output clean`);
|
|
2052
2378
|
await cleanDirectories(options.name, options.outDir, options.config);
|
|
2053
2379
|
stopwatch();
|
|
2054
2380
|
}
|
|
2055
2381
|
return options;
|
|
2056
2382
|
}
|
|
2057
|
-
__name(cleanOutputPath, "cleanOutputPath");
|
|
2058
2383
|
async function build(options) {
|
|
2059
2384
|
const projectRoot = options.projectRoot;
|
|
2060
2385
|
if (!projectRoot) {
|
|
@@ -2078,15 +2403,20 @@ async function build(options) {
|
|
|
2078
2403
|
if (options.buildOnly !== true) {
|
|
2079
2404
|
await copyBuildAssets(resolvedOptions);
|
|
2080
2405
|
}
|
|
2081
|
-
writeSuccess(
|
|
2406
|
+
writeSuccess(
|
|
2407
|
+
` \u{1F3C1} The ${resolvedOptions.name} build completed successfully`,
|
|
2408
|
+
config
|
|
2409
|
+
);
|
|
2082
2410
|
} catch (error) {
|
|
2083
|
-
writeFatal(
|
|
2411
|
+
writeFatal(
|
|
2412
|
+
"Fatal errors that the build process could not recover from have occured. The build process has been terminated.",
|
|
2413
|
+
config
|
|
2414
|
+
);
|
|
2084
2415
|
throw error;
|
|
2085
2416
|
} finally {
|
|
2086
2417
|
stopwatch();
|
|
2087
2418
|
}
|
|
2088
2419
|
}
|
|
2089
|
-
__name(build, "build");
|
|
2090
2420
|
|
|
2091
2421
|
// bin/unbuild.ts
|
|
2092
2422
|
async function createProgram(config) {
|
|
@@ -2101,34 +2431,57 @@ async function createProgram(config) {
|
|
|
2101
2431
|
const program = new Command("storm-unbuild");
|
|
2102
2432
|
program.version("1.0.0", "-v --version", "display CLI version");
|
|
2103
2433
|
program.description("\u26A1 Run the Storm Unbuild pipeline").showHelpAfterError().showSuggestionAfterError();
|
|
2104
|
-
const projectRootOption = new Option(
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
const
|
|
2109
|
-
"
|
|
2110
|
-
"
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
"
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2434
|
+
const projectRootOption = new Option(
|
|
2435
|
+
"-p --project-root <path>",
|
|
2436
|
+
"The path to the root of the project to build. This path is defined relative to the workspace root."
|
|
2437
|
+
).makeOptionMandatory(true);
|
|
2438
|
+
const sourceRootOption = new Option(
|
|
2439
|
+
"-s --source-root <path>",
|
|
2440
|
+
"The path of the project's source folder to build"
|
|
2441
|
+
);
|
|
2442
|
+
const nameOption = new Option(
|
|
2443
|
+
"-n --name <value>",
|
|
2444
|
+
"The name of the project to build"
|
|
2445
|
+
);
|
|
2446
|
+
const outputPathOption = new Option(
|
|
2447
|
+
"-o --output-path <path>",
|
|
2448
|
+
"The path of the project's source folder to build"
|
|
2449
|
+
).default("dist/{projectRoot}");
|
|
2450
|
+
const platformOption = new Option(
|
|
2451
|
+
"-p --platform <value>",
|
|
2452
|
+
"The platform to build the distribution for"
|
|
2453
|
+
).choices(["node", "neutral", "browser"]).default("node");
|
|
2454
|
+
const formatOption = new Option(
|
|
2455
|
+
"-f, --format <value...>",
|
|
2456
|
+
"The format to build the distribution in"
|
|
2457
|
+
).choices(["esm", "cjs", "iife"]).argParser((value, previous) => {
|
|
2118
2458
|
if (previous === void 0) {
|
|
2119
|
-
return [
|
|
2120
|
-
value
|
|
2121
|
-
];
|
|
2459
|
+
return [value];
|
|
2122
2460
|
} else if (!previous.includes(value)) {
|
|
2123
2461
|
previous.push(value);
|
|
2124
2462
|
}
|
|
2125
2463
|
return previous;
|
|
2126
2464
|
}).default("esm");
|
|
2127
|
-
const cleanOption = new Option(
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
const
|
|
2465
|
+
const cleanOption = new Option(
|
|
2466
|
+
"-c --clean",
|
|
2467
|
+
"Should the output directory be cleaned before building"
|
|
2468
|
+
).default(true);
|
|
2469
|
+
const noCleanOption = new Option(
|
|
2470
|
+
"--no-clean",
|
|
2471
|
+
"Should the output directory be cleaned before building"
|
|
2472
|
+
).default(false);
|
|
2473
|
+
const bundleOption = new Option(
|
|
2474
|
+
"-b --bundle",
|
|
2475
|
+
"Should the output be bundled"
|
|
2476
|
+
).default(true);
|
|
2477
|
+
const noBundleOption = new Option(
|
|
2478
|
+
"--no-bundle",
|
|
2479
|
+
"Should the output be bundled"
|
|
2480
|
+
).default(false);
|
|
2481
|
+
const targetOption = new Option(
|
|
2482
|
+
"-t --target <value>",
|
|
2483
|
+
"The target to build the distribution for"
|
|
2484
|
+
).choices([
|
|
2132
2485
|
"ESNext",
|
|
2133
2486
|
"ES2015",
|
|
2134
2487
|
"ES2016",
|
|
@@ -2140,31 +2493,72 @@ async function createProgram(config) {
|
|
|
2140
2493
|
"ES2022",
|
|
2141
2494
|
"ES2023"
|
|
2142
2495
|
]).default("ESNext");
|
|
2143
|
-
const watchOption = new Option(
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
const
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
const
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2496
|
+
const watchOption = new Option(
|
|
2497
|
+
"-w --watch",
|
|
2498
|
+
"Should the build process watch for changes"
|
|
2499
|
+
).default(false);
|
|
2500
|
+
const debugOption = new Option(
|
|
2501
|
+
"-d --debug",
|
|
2502
|
+
"Should the build process run in debug mode"
|
|
2503
|
+
).default(false);
|
|
2504
|
+
const bannerOption = new Option(
|
|
2505
|
+
"--banner <value>",
|
|
2506
|
+
"The banner to prepend to the output"
|
|
2507
|
+
);
|
|
2508
|
+
const footerOption = new Option(
|
|
2509
|
+
"--footer <value>",
|
|
2510
|
+
"The footer to prepend to the output"
|
|
2511
|
+
);
|
|
2512
|
+
const splittingOption = new Option(
|
|
2513
|
+
"--splitting",
|
|
2514
|
+
"Should the output be split into multiple files"
|
|
2515
|
+
).default(true);
|
|
2516
|
+
const treeShakingOption = new Option(
|
|
2517
|
+
"--tree-shaking",
|
|
2518
|
+
"Should tree shaking be enabled"
|
|
2519
|
+
).default(true);
|
|
2520
|
+
const generatePackageJsonOption = new Option(
|
|
2521
|
+
"--generate-package-json",
|
|
2522
|
+
"Should a package.json be generated for the output"
|
|
2523
|
+
).default(true);
|
|
2524
|
+
const emitOnAllOption = new Option(
|
|
2525
|
+
"--emit-on-all",
|
|
2526
|
+
"Should the output be emitted on all platforms"
|
|
2527
|
+
).default(false);
|
|
2528
|
+
const metafileOption = new Option(
|
|
2529
|
+
"--metafile",
|
|
2530
|
+
"Should a metafile be generated for the output"
|
|
2531
|
+
).default(true);
|
|
2532
|
+
const minifyOption = new Option(
|
|
2533
|
+
"--minify",
|
|
2534
|
+
"Should the output be minified"
|
|
2535
|
+
).default(true);
|
|
2536
|
+
const includeSrcOption = new Option(
|
|
2537
|
+
"--include-src",
|
|
2538
|
+
"Should the source files be included in the output"
|
|
2539
|
+
).default(false);
|
|
2540
|
+
const verboseOption = new Option(
|
|
2541
|
+
"--verbose",
|
|
2542
|
+
"Should the build process be verbose"
|
|
2543
|
+
).default(false);
|
|
2544
|
+
const dtsOption = new Option(
|
|
2545
|
+
"--emit-types",
|
|
2546
|
+
"Should types be emitted for the output"
|
|
2547
|
+
).default(true);
|
|
2548
|
+
program.command("build", { isDefault: true }).alias("bundle").description("Run a TypeScript build using Unbuild.").addOption(nameOption).addOption(projectRootOption).addOption(sourceRootOption).addOption(outputPathOption).addOption(platformOption).addOption(formatOption).addOption(targetOption).addOption(bundleOption).addOption(noBundleOption).addOption(cleanOption).addOption(noCleanOption).addOption(watchOption).addOption(debugOption).addOption(bannerOption).addOption(footerOption).addOption(splittingOption).addOption(treeShakingOption).addOption(generatePackageJsonOption).addOption(emitOnAllOption).addOption(metafileOption).addOption(minifyOption).addOption(includeSrcOption).addOption(verboseOption).addOption(dtsOption).action(buildAction(config));
|
|
2549
|
+
program.command("clean").alias("clear").description(
|
|
2550
|
+
"Clean the output directory of the project. This command will remove the 'dist' folder."
|
|
2551
|
+
).addOption(nameOption).action(cleanAction(config));
|
|
2160
2552
|
return program;
|
|
2161
2553
|
} catch (e) {
|
|
2162
|
-
writeFatal(
|
|
2554
|
+
writeFatal(
|
|
2555
|
+
`A fatal error occurred while running the program: ${e.message}`,
|
|
2556
|
+
config
|
|
2557
|
+
);
|
|
2163
2558
|
process.exit(1);
|
|
2164
2559
|
}
|
|
2165
2560
|
}
|
|
2166
|
-
|
|
2167
|
-
var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
2561
|
+
var buildAction = (config) => async (options) => {
|
|
2168
2562
|
try {
|
|
2169
2563
|
await build({
|
|
2170
2564
|
...options,
|
|
@@ -2206,20 +2600,26 @@ var buildAction = /* @__PURE__ */ __name((config) => async (options) => {
|
|
|
2206
2600
|
}
|
|
2207
2601
|
});
|
|
2208
2602
|
} catch (e) {
|
|
2209
|
-
writeFatal(
|
|
2603
|
+
writeFatal(
|
|
2604
|
+
`A fatal error occurred while cleaning the Unbuild output directory: ${e.message}`,
|
|
2605
|
+
config
|
|
2606
|
+
);
|
|
2210
2607
|
exitWithError(config);
|
|
2211
2608
|
process.exit(1);
|
|
2212
2609
|
}
|
|
2213
|
-
}
|
|
2214
|
-
var cleanAction =
|
|
2610
|
+
};
|
|
2611
|
+
var cleanAction = (config) => async (options) => {
|
|
2215
2612
|
try {
|
|
2216
2613
|
await clean(options.name, options.output, config);
|
|
2217
2614
|
} catch (e) {
|
|
2218
|
-
writeFatal(
|
|
2615
|
+
writeFatal(
|
|
2616
|
+
`A fatal error occurred while cleaning the ESBuild output directory: ${e.message}`,
|
|
2617
|
+
config
|
|
2618
|
+
);
|
|
2219
2619
|
exitWithError(config);
|
|
2220
2620
|
process.exit(1);
|
|
2221
2621
|
}
|
|
2222
|
-
}
|
|
2622
|
+
};
|
|
2223
2623
|
void (async () => {
|
|
2224
2624
|
const config = await getConfig();
|
|
2225
2625
|
const stopwatch = getStopwatch("Storm ESBuild executable");
|
|
@@ -2227,12 +2627,18 @@ void (async () => {
|
|
|
2227
2627
|
handleProcess(config);
|
|
2228
2628
|
const program = await createProgram(config);
|
|
2229
2629
|
await program.parseAsync(process.argv);
|
|
2230
|
-
writeSuccess(
|
|
2630
|
+
writeSuccess(
|
|
2631
|
+
`\u{1F389} Storm ESBuild executable has completed successfully!`,
|
|
2632
|
+
config
|
|
2633
|
+
);
|
|
2231
2634
|
exitWithSuccess(config);
|
|
2232
2635
|
} catch (error) {
|
|
2233
|
-
writeFatal(
|
|
2636
|
+
writeFatal(
|
|
2637
|
+
`A fatal error occurred while running Storm ESBuild executable:
|
|
2234
2638
|
|
|
2235
|
-
${error.message}`,
|
|
2639
|
+
${error.message}`,
|
|
2640
|
+
config
|
|
2641
|
+
);
|
|
2236
2642
|
exitWithError(config);
|
|
2237
2643
|
process.exit(1);
|
|
2238
2644
|
} finally {
|