@storm-software/workspace-tools 1.45.0 → 1.45.2

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