@storm-software/workspace-tools 1.45.1 → 1.45.3

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.
@@ -26236,6 +26236,189 @@ var import_devkit = __toESM(require_devkit());
26236
26236
 
26237
26237
  // packages/config-tools/src/config-file/get-config-file.ts
26238
26238
  var import_cosmiconfig = __toESM(require_dist(), 1);
26239
+
26240
+ // packages/config-tools/src/utilities/logger.ts
26241
+ var chalk = __toESM(require_source(), 1);
26242
+
26243
+ // packages/config-tools/src/types.ts
26244
+ var LogLevel = {
26245
+ SILENT: 0,
26246
+ FATAL: 10,
26247
+ ERROR: 20,
26248
+ WARN: 30,
26249
+ INFO: 40,
26250
+ SUCCESS: 45,
26251
+ DEBUG: 60,
26252
+ TRACE: 70,
26253
+ ALL: 100
26254
+ };
26255
+ var LogLevelLabel = {
26256
+ SILENT: "silent",
26257
+ FATAL: "fatal",
26258
+ ERROR: "error",
26259
+ WARN: "warn",
26260
+ INFO: "info",
26261
+ DEBUG: "debug",
26262
+ TRACE: "trace",
26263
+ ALL: "all"
26264
+ };
26265
+
26266
+ // packages/config-tools/src/utilities/get-log-level.ts
26267
+ var getLogLevel = (label) => {
26268
+ switch (label) {
26269
+ case "all":
26270
+ return LogLevel.ALL;
26271
+ case "trace":
26272
+ return LogLevel.TRACE;
26273
+ case "debug":
26274
+ return LogLevel.DEBUG;
26275
+ case "info":
26276
+ return LogLevel.INFO;
26277
+ case "warn":
26278
+ return LogLevel.WARN;
26279
+ case "error":
26280
+ return LogLevel.ERROR;
26281
+ case "fatal":
26282
+ return LogLevel.FATAL;
26283
+ case "silent":
26284
+ return LogLevel.SILENT;
26285
+ default:
26286
+ return LogLevel.INFO;
26287
+ }
26288
+ };
26289
+ var getLogLevelLabel = (logLevel) => {
26290
+ if (logLevel >= LogLevel.ALL) {
26291
+ return LogLevelLabel.ALL;
26292
+ }
26293
+ if (logLevel >= LogLevel.TRACE) {
26294
+ return LogLevelLabel.TRACE;
26295
+ }
26296
+ if (logLevel >= LogLevel.DEBUG) {
26297
+ return LogLevelLabel.DEBUG;
26298
+ }
26299
+ if (logLevel >= LogLevel.INFO) {
26300
+ return LogLevelLabel.INFO;
26301
+ }
26302
+ if (logLevel >= LogLevel.WARN) {
26303
+ return LogLevelLabel.WARN;
26304
+ }
26305
+ if (logLevel >= LogLevel.ERROR) {
26306
+ return LogLevelLabel.ERROR;
26307
+ }
26308
+ if (logLevel >= LogLevel.FATAL) {
26309
+ return LogLevelLabel.FATAL;
26310
+ }
26311
+ if (logLevel <= LogLevel.SILENT) {
26312
+ return LogLevelLabel.SILENT;
26313
+ }
26314
+ return LogLevelLabel.INFO;
26315
+ };
26316
+
26317
+ // packages/config-tools/src/utilities/logger.ts
26318
+ var getLogFn = (config = {}, logLevel = LogLevel.INFO) => {
26319
+ if (typeof logLevel === "number" && (logLevel >= getLogLevel(config.logLevel ?? process.env?.STORM_LOG_LEVEL) || logLevel <= LogLevel.SILENT) || typeof logLevel === "string" && getLogLevel(logLevel) >= getLogLevel(config.logLevel ?? process.env?.STORM_LOG_LEVEL)) {
26320
+ return (_) => {
26321
+ };
26322
+ }
26323
+ if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel || typeof logLevel === "string" && LogLevel.FATAL >= getLogLevel(logLevel)) {
26324
+ return (message) => {
26325
+ console.error(
26326
+ `
26327
+ ${chalk.bold.hex(config?.colors?.fatal ? config.colors.fatal : "#1fb2a6")(">")} ${chalk.bold.bgHex(config?.colors?.fatal ? config.colors.fatal : "#1fb2a6").white(" \u{1F480} Fatal ")} ${chalk.hex(
26328
+ config?.colors?.fatal ? config.colors.fatal : "#1fb2a6"
26329
+ )(message)}
26330
+
26331
+ `
26332
+ );
26333
+ };
26334
+ }
26335
+ if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel || typeof logLevel === "string" && LogLevel.ERROR >= getLogLevel(logLevel)) {
26336
+ return (message) => {
26337
+ console.error(
26338
+ `
26339
+ ${chalk.bold.hex(config?.colors?.error ? config.colors.error : "#7d1a1a")(">")} ${chalk.bold.bgHex(config?.colors?.error ? config.colors.error : "#7d1a1a").white(" \u{1F6D1} Error ")} ${chalk.hex(
26340
+ config?.colors?.error ? config.colors.error : "#7d1a1a"
26341
+ )(message)}
26342
+ `
26343
+ );
26344
+ };
26345
+ }
26346
+ if (typeof logLevel === "number" && LogLevel.WARN >= logLevel || typeof logLevel === "string" && LogLevel.WARN >= getLogLevel(logLevel)) {
26347
+ return (message) => {
26348
+ console.warn(
26349
+ `
26350
+ ${chalk.bold.hex(config?.colors?.warning ? config.colors.warning : "#fcc419")(">")} ${chalk.bold.bgHex(config?.colors?.warning ? config.colors.warning : "#fcc419").white(" \u26A0\uFE0F Warn ")} ${chalk.hex(
26351
+ config?.colors?.warning ? config.colors.warning : "#fcc419"
26352
+ )(message)}
26353
+ `
26354
+ );
26355
+ };
26356
+ }
26357
+ if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
26358
+ return (message) => {
26359
+ console.info(
26360
+ `
26361
+ ${chalk.bold.hex(config?.colors?.info ? config.colors.info : "#0ea5e9")(">")} ${chalk.bold.bgHex(config?.colors?.info ? config.colors.info : "#0ea5e9").white(" \u{1F4EC} Info ")} ${chalk.hex(
26362
+ config?.colors?.info ? config.colors.info : "#0ea5e9"
26363
+ )(message)}
26364
+ `
26365
+ );
26366
+ };
26367
+ }
26368
+ if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
26369
+ return (message) => {
26370
+ console.info(
26371
+ `
26372
+ ${chalk.bold.hex(config?.colors?.success ? config.colors.success : "#087f5b")(">")} ${chalk.bold.bgHex(config?.colors?.success ? config.colors.success : "#087f5b").white(" \u{1F389} Success ")} ${chalk.hex(
26373
+ config?.colors?.success ? config.colors.success : "#087f5b"
26374
+ )(message)}
26375
+ `
26376
+ );
26377
+ };
26378
+ }
26379
+ if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel || typeof logLevel === "string" && LogLevel.DEBUG >= getLogLevel(logLevel)) {
26380
+ return (message) => {
26381
+ console.debug(
26382
+ `
26383
+ ${chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">")} ${chalk.bold.bgHex(config?.colors?.primary ? config.colors.primary : "#1fb2a6").white(" \u{1F9EA} Debug ")} ${chalk.hex(
26384
+ config?.colors?.primary ? config.colors.primary : "#1fb2a6"
26385
+ )(message)}
26386
+ `
26387
+ );
26388
+ };
26389
+ }
26390
+ return (message) => {
26391
+ console.log(
26392
+ `
26393
+ ${chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">")} ${chalk.bold.bgHex(config?.colors?.primary ? config.colors.primary : "#1fb2a6").white(" \u{1F4E2} System ")} ${chalk.hex(
26394
+ config?.colors?.primary ? config.colors.primary : "#1fb2a6"
26395
+ )(message)}
26396
+ `
26397
+ );
26398
+ };
26399
+ };
26400
+ var writeFatal = (config, message) => getLogFn(config, LogLevel.FATAL)(message);
26401
+ var writeError = (config, message) => getLogFn(config, LogLevel.ERROR)(message);
26402
+ var writeWarning = (config, message) => getLogFn(config, LogLevel.WARN)(message);
26403
+ var writeInfo = (config, message) => getLogFn(config, LogLevel.INFO)(message);
26404
+ var writeSuccess = (config, message) => getLogFn(config, LogLevel.SUCCESS)(message);
26405
+ var writeDebug = (config, message) => getLogFn(config, LogLevel.DEBUG)(message);
26406
+ var writeTrace = (config, message) => getLogFn(config, LogLevel.TRACE)(message);
26407
+ var getStopwatch = (name) => {
26408
+ const start = process.hrtime();
26409
+ return () => {
26410
+ const end = process.hrtime(start);
26411
+ console.info(
26412
+ chalk.dim(
26413
+ `\u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(
26414
+ end[0] * 1e3 + end[1] / 1e6
26415
+ )}ms to complete`
26416
+ )
26417
+ );
26418
+ };
26419
+ };
26420
+
26421
+ // packages/config-tools/src/config-file/get-config-file.ts
26239
26422
  var _static_cache = void 0;
26240
26423
  var getConfigFileName = async (fileName, filePath) => (0, import_cosmiconfig.cosmiconfig)(fileName, { cache: true }).search(filePath);
26241
26424
  var getConfigFile = async (filePath) => {
@@ -26262,6 +26445,10 @@ var getConfigFile = async (filePath) => {
26262
26445
  console.warn(
26263
26446
  "No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.config.js` file to the root of your workspace if it is not."
26264
26447
  );
26448
+ writeWarning(
26449
+ { logLevel: "error" },
26450
+ "No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.config.js` file to the root of your workspace if it is not."
26451
+ );
26265
26452
  return void 0;
26266
26453
  }
26267
26454
  const config = cosmiconfigResult.config ?? {};
@@ -26342,6 +26529,10 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
26342
26529
  return result;
26343
26530
  }
26344
26531
 
26532
+ // packages/config-tools/src/utilities/get-default-config.ts
26533
+ var import_node_fs2 = require("node:fs");
26534
+ var import_node_path2 = require("node:path");
26535
+
26345
26536
  // node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
26346
26537
  var util;
26347
26538
  (function(util2) {
@@ -30002,183 +30193,50 @@ var DefaultStormConfig = {
30002
30193
  colors: { ...DefaultColorConfig },
30003
30194
  extensions: {}
30004
30195
  };
30005
-
30006
- // packages/config-tools/src/types.ts
30007
- var LogLevel = {
30008
- SILENT: 0,
30009
- FATAL: 10,
30010
- ERROR: 20,
30011
- WARN: 30,
30012
- INFO: 40,
30013
- SUCCESS: 45,
30014
- DEBUG: 60,
30015
- TRACE: 70,
30016
- ALL: 100
30017
- };
30018
- var LogLevelLabel = {
30019
- SILENT: "silent",
30020
- FATAL: "fatal",
30021
- ERROR: "error",
30022
- WARN: "warn",
30023
- INFO: "info",
30024
- DEBUG: "debug",
30025
- TRACE: "trace",
30026
- ALL: "all"
30027
- };
30028
-
30029
- // packages/config-tools/src/utilities/get-log-level.ts
30030
- var getLogLevel = (label) => {
30031
- switch (label) {
30032
- case "all":
30033
- return LogLevel.ALL;
30034
- case "trace":
30035
- return LogLevel.TRACE;
30036
- case "debug":
30037
- return LogLevel.DEBUG;
30038
- case "info":
30039
- return LogLevel.INFO;
30040
- case "warn":
30041
- return LogLevel.WARN;
30042
- case "error":
30043
- return LogLevel.ERROR;
30044
- case "fatal":
30045
- return LogLevel.FATAL;
30046
- case "silent":
30047
- return LogLevel.SILENT;
30048
- default:
30049
- return LogLevel.INFO;
30050
- }
30051
- };
30052
- var getLogLevelLabel = (logLevel) => {
30053
- if (logLevel >= LogLevel.ALL) {
30054
- return LogLevelLabel.ALL;
30055
- }
30056
- if (logLevel >= LogLevel.TRACE) {
30057
- return LogLevelLabel.TRACE;
30058
- }
30059
- if (logLevel >= LogLevel.DEBUG) {
30060
- return LogLevelLabel.DEBUG;
30061
- }
30062
- if (logLevel >= LogLevel.INFO) {
30063
- return LogLevelLabel.INFO;
30064
- }
30065
- if (logLevel >= LogLevel.WARN) {
30066
- return LogLevelLabel.WARN;
30067
- }
30068
- if (logLevel >= LogLevel.ERROR) {
30069
- return LogLevelLabel.ERROR;
30070
- }
30071
- if (logLevel >= LogLevel.FATAL) {
30072
- return LogLevelLabel.FATAL;
30073
- }
30074
- if (logLevel <= LogLevel.SILENT) {
30075
- return LogLevelLabel.SILENT;
30076
- }
30077
- return LogLevelLabel.INFO;
30078
- };
30079
-
30080
- // packages/config-tools/src/utilities/logger.ts
30081
- var chalk = __toESM(require_source(), 1);
30082
- var getLogFn = (config = {}, logLevel = LogLevel.INFO) => {
30083
- if (typeof logLevel === "number" && (logLevel >= getLogLevel(config.logLevel ?? process.env?.STORM_LOG_LEVEL) || logLevel <= LogLevel.SILENT) || typeof logLevel === "string" && getLogLevel(logLevel) >= getLogLevel(config.logLevel ?? process.env?.STORM_LOG_LEVEL)) {
30084
- return (_) => {
30085
- };
30086
- }
30087
- if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel || typeof logLevel === "string" && LogLevel.FATAL >= getLogLevel(logLevel)) {
30088
- return (message) => {
30089
- console.error(
30090
- `
30091
- ${chalk.bold.hex(config?.colors?.fatal ? config.colors.fatal : "#1fb2a6")(">")} ${chalk.bold.bgHex(config?.colors?.fatal ? config.colors.fatal : "#1fb2a6").white(" \u{1F480} Fatal ")} ${chalk.hex(
30092
- config?.colors?.fatal ? config.colors.fatal : "#1fb2a6"
30093
- )(message)}
30094
-
30095
- `
30096
- );
30097
- };
30098
- }
30099
- if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel || typeof logLevel === "string" && LogLevel.ERROR >= getLogLevel(logLevel)) {
30100
- return (message) => {
30101
- console.error(
30102
- `
30103
- ${chalk.bold.hex(config?.colors?.error ? config.colors.error : "#7d1a1a")(">")} ${chalk.bold.bgHex(config?.colors?.error ? config.colors.error : "#7d1a1a").white(" \u{1F6D1} Error ")} ${chalk.hex(
30104
- config?.colors?.error ? config.colors.error : "#7d1a1a"
30105
- )(message)}
30106
- `
30107
- );
30108
- };
30109
- }
30110
- if (typeof logLevel === "number" && LogLevel.WARN >= logLevel || typeof logLevel === "string" && LogLevel.WARN >= getLogLevel(logLevel)) {
30111
- return (message) => {
30112
- console.warn(
30113
- `
30114
- ${chalk.bold.hex(config?.colors?.warning ? config.colors.warning : "#fcc419")(">")} ${chalk.bold.bgHex(config?.colors?.warning ? config.colors.warning : "#fcc419").white(" \u26A0\uFE0F Warn ")} ${chalk.hex(
30115
- config?.colors?.warning ? config.colors.warning : "#fcc419"
30116
- )(message)}
30117
- `
30118
- );
30119
- };
30120
- }
30121
- if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
30122
- return (message) => {
30123
- console.info(
30124
- `
30125
- ${chalk.bold.hex(config?.colors?.info ? config.colors.info : "#0ea5e9")(">")} ${chalk.bold.bgHex(config?.colors?.info ? config.colors.info : "#0ea5e9").white(" \u{1F4EC} Info ")} ${chalk.hex(
30126
- config?.colors?.info ? config.colors.info : "#0ea5e9"
30127
- )(message)}
30128
- `
30129
- );
30130
- };
30131
- }
30132
- if (typeof logLevel === "number" && LogLevel.INFO >= logLevel || typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel)) {
30133
- return (message) => {
30134
- console.info(
30135
- `
30136
- ${chalk.bold.hex(config?.colors?.success ? config.colors.success : "#087f5b")(">")} ${chalk.bold.bgHex(config?.colors?.success ? config.colors.success : "#087f5b").white(" \u{1F389} Success ")} ${chalk.hex(
30137
- config?.colors?.success ? config.colors.success : "#087f5b"
30138
- )(message)}
30139
- `
30140
- );
30141
- };
30142
- }
30143
- if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel || typeof logLevel === "string" && LogLevel.DEBUG >= getLogLevel(logLevel)) {
30144
- return (message) => {
30145
- console.debug(
30146
- `
30147
- ${chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">")} ${chalk.bold.bgHex(config?.colors?.primary ? config.colors.primary : "#1fb2a6").white(" \u{1F9EA} Debug ")} ${chalk.hex(
30148
- config?.colors?.primary ? config.colors.primary : "#1fb2a6"
30149
- )(message)}
30150
- `
30151
- );
30152
- };
30196
+ var getDefaultConfig = (config = {}, root) => {
30197
+ let name = "storm-workspace";
30198
+ let namespace = "storm-software";
30199
+ let repository = "https://github.com/storm-software/storm-ops";
30200
+ let license = DefaultStormConfig.license;
30201
+ let homepage = DefaultStormConfig.homepage;
30202
+ const workspaceRoot = findWorkspaceRoot(root);
30203
+ if ((0, import_node_fs2.existsSync)((0, import_node_path2.join)(workspaceRoot, "package.json"))) {
30204
+ const file = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(workspaceRoot, "package.json"), {
30205
+ encoding: "utf-8"
30206
+ });
30207
+ if (file) {
30208
+ const packageJson = JSON.parse(file);
30209
+ if (packageJson.name) {
30210
+ name = packageJson.name;
30211
+ }
30212
+ if (packageJson.namespace) {
30213
+ namespace = packageJson.namespace;
30214
+ }
30215
+ if (packageJson.repository?.url) {
30216
+ repository = packageJson.repository?.url;
30217
+ }
30218
+ if (packageJson.license) {
30219
+ license = packageJson.license;
30220
+ }
30221
+ if (packageJson.homepage) {
30222
+ homepage = packageJson.homepage;
30223
+ }
30224
+ }
30153
30225
  }
30154
- return (message) => {
30155
- console.log(
30156
- `
30157
- ${chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">")} ${chalk.bold.bgHex(config?.colors?.primary ? config.colors.primary : "#1fb2a6").white(" \u{1F4E2} System ")} ${chalk.hex(
30158
- config?.colors?.primary ? config.colors.primary : "#1fb2a6"
30159
- )(message)}
30160
- `
30161
- );
30162
- };
30163
- };
30164
- var writeFatal = (config, message) => getLogFn(config, LogLevel.FATAL)(message);
30165
- var writeError = (config, message) => getLogFn(config, LogLevel.ERROR)(message);
30166
- var writeInfo = (config, message) => getLogFn(config, LogLevel.INFO)(message);
30167
- var writeSuccess = (config, message) => getLogFn(config, LogLevel.SUCCESS)(message);
30168
- var writeDebug = (config, message) => getLogFn(config, LogLevel.DEBUG)(message);
30169
- var writeTrace = (config, message) => getLogFn(config, LogLevel.TRACE)(message);
30170
- var getStopwatch = (name) => {
30171
- const start = process.hrtime();
30172
- return () => {
30173
- const end = process.hrtime(start);
30174
- console.info(
30175
- chalk.dim(
30176
- `\u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(
30177
- end[0] * 1e3 + end[1] / 1e6
30178
- )}ms to complete`
30179
- )
30180
- );
30181
- };
30226
+ return StormConfigSchema.parse({
30227
+ ...DefaultStormConfig,
30228
+ ...config,
30229
+ colors: { ...DefaultColorConfig, ...config.colors },
30230
+ workspaceRoot,
30231
+ name,
30232
+ namespace,
30233
+ repository,
30234
+ license: license ?? DefaultStormConfig.license,
30235
+ homepage: homepage ?? DefaultStormConfig.homepage,
30236
+ extensions: {
30237
+ ...config.extensions
30238
+ }
30239
+ });
30182
30240
  };
30183
30241
 
30184
30242
  // packages/config-tools/src/env/set-env.ts
@@ -30368,39 +30426,21 @@ var getConfigEnv = () => {
30368
30426
 
30369
30427
  // packages/config-tools/src/create-storm-config.ts
30370
30428
  var loadStormConfig = async (workspaceRoot) => {
30429
+ let config = {};
30371
30430
  let _workspaceRoot = workspaceRoot;
30372
30431
  if (!_workspaceRoot) {
30373
30432
  _workspaceRoot = findWorkspaceRoot();
30374
30433
  }
30375
- const configFile = await getConfigFile(_workspaceRoot);
30376
- const configEnv = getConfigEnv();
30377
- for (const key of Object.keys(configEnv)) {
30378
- if (configEnv[key] !== void 0 && configEnv[key] !== null) {
30379
- if (key === "colors") {
30380
- configFile.colors = {
30381
- primary: process.env.STORM_COLOR_PRIMARY ?? configFile.colors?.primary,
30382
- background: process.env.STORM_COLOR_BACKGROUND ?? configFile.colors?.background,
30383
- success: process.env.STORM_COLOR_SUCCESS ?? configFile.colors?.success,
30384
- info: process.env.STORM_COLOR_INFO ?? configFile.colors?.info,
30385
- warning: process.env.STORM_COLOR_WARNING ?? configFile.colors?.warning,
30386
- error: process.env.STORM_COLOR_ERROR ?? configFile.colors?.error,
30387
- fatal: process.env.STORM_COLOR_FATAL ?? configFile.colors?.fatal
30388
- };
30389
- } else {
30390
- configFile[key] = configEnv[key];
30391
- }
30392
- }
30393
- }
30394
- const config = StormConfigSchema.parse(configFile);
30434
+ config = StormConfigSchema.parse(
30435
+ await getDefaultConfig(
30436
+ {
30437
+ ...await getConfigFile(_workspaceRoot),
30438
+ ...getConfigEnv()
30439
+ },
30440
+ _workspaceRoot
30441
+ )
30442
+ );
30395
30443
  setConfigEnv(config);
30396
- console.debug("\r\n\r\n");
30397
- console.debug(`Loaded Storm config from ${config.configFile}`);
30398
- for (const key of Object.keys(configFile)) {
30399
- console.debug(`
30400
- ----- ${key} ----- `);
30401
- console.debug(configFile[key]);
30402
- }
30403
- console.debug("\r\n\r\n");
30404
30444
  return config;
30405
30445
  };
30406
30446