@storm-software/workspace-tools
Version:
Tools for managing a Storm workspace, including various Nx generators and executors for common development tasks.
1,124 lines (1,104 loc) • 50.3 kB
JavaScript
import {
findWorkspaceRoot
} from "./chunk-FR3YQN55.mjs";
import {
correctPaths,
joinPaths
} from "./chunk-ATIBREWM.mjs";
import {
__name
} from "./chunk-2BPV2XV2.mjs";
// ../config/src/schema.ts
import z from "zod";
// ../config/src/constants.ts
var STORM_DEFAULT_DOCS = "https://docs.stormsoftware.com";
var STORM_DEFAULT_HOMEPAGE = "https://stormsoftware.com";
var STORM_DEFAULT_CONTACT = "https://stormsoftware.com/contact";
var STORM_DEFAULT_LICENSING = "https://license.stormsoftware.com";
var STORM_DEFAULT_LICENSE = "Apache-2.0";
var STORM_DEFAULT_RELEASE_BANNER = "https://public.storm-cdn.com/brand-banner.png";
var STORM_DEFAULT_ACCOUNT_TWITTER = "StormSoftwareHQ";
var STORM_DEFAULT_ACCOUNT_DISCORD = "https://discord.gg/MQ6YVzakM5";
var STORM_DEFAULT_ACCOUNT_TELEGRAM = "https://t.me/storm_software";
var STORM_DEFAULT_ACCOUNT_SLACK = "https://join.slack.com/t/storm-software/shared_invite/zt-2gsmk04hs-i6yhK_r6urq0dkZYAwq2pA";
var STORM_DEFAULT_ACCOUNT_MEDIUM = "https://medium.com/storm-software";
var STORM_DEFAULT_ACCOUNT_GITHUB = "https://github.com/storm-software";
var STORM_DEFAULT_RELEASE_FOOTER = `
Storm Software is an open source software development organization with the mission is to make software development more accessible. Our ideal future is one where anyone can create software without years of prior development experience serving as a barrier to entry. We hope to achieve this via LLMs, Generative AI, and intuitive, high-level data modeling/programming languages.
Join us on [Discord](${STORM_DEFAULT_ACCOUNT_DISCORD}) to chat with the team, receive release notifications, ask questions, and get involved.
If this sounds interesting, and you would like to help us in creating the next generation of development tools, please reach out on our [website](${STORM_DEFAULT_CONTACT}) or join our [Slack](${STORM_DEFAULT_ACCOUNT_SLACK}) channel!
`;
// ../config/src/schema.ts
var DarkColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1d1e22").describe("The dark background color of the workspace");
var LightColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#f4f4f5").describe("The light background color of the workspace");
var BrandColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1fb2a6").describe("The primary brand specific color of the workspace");
var AlternateColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The alternate brand specific color of the workspace");
var AccentColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The secondary brand specific color of the workspace");
var LinkColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The color used to display hyperlink text");
var HelpColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#8256D0").describe("The second brand specific color of the workspace");
var SuccessColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#12B66A").describe("The success color of the workspace");
var InfoColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0070E0").describe("The informational color of the workspace");
var WarningColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#fcc419").describe("The warning color of the workspace");
var DangerColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#D8314A").describe("The danger color of the workspace");
var FatalColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).optional().describe("The fatal color of the workspace");
var PositiveColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#4ade80").describe("The positive number color of the workspace");
var NegativeColorSchema = z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#ef4444").describe("The negative number color of the workspace");
var DarkThemeColorConfigSchema = z.object({
foreground: LightColorSchema,
background: DarkColorSchema,
brand: BrandColorSchema,
alternate: AlternateColorSchema,
accent: AccentColorSchema,
link: LinkColorSchema,
help: HelpColorSchema,
success: SuccessColorSchema,
info: InfoColorSchema,
warning: WarningColorSchema,
danger: DangerColorSchema,
fatal: FatalColorSchema,
positive: PositiveColorSchema,
negative: NegativeColorSchema
});
var LightThemeColorConfigSchema = z.object({
foreground: DarkColorSchema,
background: LightColorSchema,
brand: BrandColorSchema,
alternate: AlternateColorSchema,
accent: AccentColorSchema,
link: LinkColorSchema,
help: HelpColorSchema,
success: SuccessColorSchema,
info: InfoColorSchema,
warning: WarningColorSchema,
danger: DangerColorSchema,
fatal: FatalColorSchema,
positive: PositiveColorSchema,
negative: NegativeColorSchema
});
var MultiThemeColorConfigSchema = z.object({
dark: DarkThemeColorConfigSchema,
light: LightThemeColorConfigSchema
});
var SingleThemeColorConfigSchema = z.object({
dark: DarkColorSchema,
light: LightColorSchema,
brand: BrandColorSchema,
alternate: AlternateColorSchema,
accent: AccentColorSchema,
link: LinkColorSchema,
help: HelpColorSchema,
success: SuccessColorSchema,
info: InfoColorSchema,
warning: WarningColorSchema,
danger: DangerColorSchema,
fatal: FatalColorSchema,
positive: PositiveColorSchema,
negative: NegativeColorSchema
});
var RegistryUrlConfigSchema = z.string().trim().toLowerCase().url().optional().describe("A remote registry URL used to publish distributable packages");
var RegistryConfigSchema = z.object({
github: RegistryUrlConfigSchema,
npm: RegistryUrlConfigSchema,
cargo: RegistryUrlConfigSchema,
cyclone: RegistryUrlConfigSchema,
container: RegistryUrlConfigSchema
}).default({}).describe("A list of remote registry URLs used by Storm Software");
var ColorConfigSchema = SingleThemeColorConfigSchema.or(MultiThemeColorConfigSchema).describe("Colors used for various workspace elements");
var ColorConfigMapSchema = z.union([
z.object({
base: ColorConfigSchema
}),
z.record(z.string(), ColorConfigSchema)
]);
var ExtendsItemSchema = z.string().trim().describe("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.");
var ExtendsSchema = ExtendsItemSchema.or(z.array(ExtendsItemSchema)).describe("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.");
var WorkspaceBotConfigSchema = z.object({
name: z.string().trim().default("stormie-bot").describe("The workspace bot user's name (this is the bot that will be used to perform various tasks)"),
email: z.string().trim().email().default("bot@stormsoftware.com").describe("The email of the workspace bot")
}).describe("The workspace's bot user's config used to automated various operations tasks");
var WorkspaceReleaseConfigSchema = z.object({
banner: z.string().trim().default(STORM_DEFAULT_RELEASE_BANNER).describe("A URL to a banner image used to display the workspace's release"),
header: z.string().trim().optional().describe("A header message appended to the start of the workspace's release notes"),
footer: z.string().trim().default(STORM_DEFAULT_RELEASE_FOOTER).describe("A footer message appended to the end of the workspace's release notes")
}).describe("The workspace's release config used during the release process");
var WorkspaceAccountConfigSchema = z.object({
twitter: z.string().trim().default(STORM_DEFAULT_ACCOUNT_TWITTER).describe("A Twitter/X account associated with the organization/project"),
discord: z.string().trim().default(STORM_DEFAULT_ACCOUNT_DISCORD).describe("A Discord account associated with the organization/project"),
telegram: z.string().trim().default(STORM_DEFAULT_ACCOUNT_TELEGRAM).describe("A Telegram account associated with the organization/project"),
slack: z.string().trim().default(STORM_DEFAULT_ACCOUNT_SLACK).describe("A Slack account associated with the organization/project"),
medium: z.string().trim().default(STORM_DEFAULT_ACCOUNT_MEDIUM).describe("A Medium account associated with the organization/project"),
github: z.string().trim().default(STORM_DEFAULT_ACCOUNT_GITHUB).describe("A GitHub account associated with the organization/project")
}).describe("The workspace's account config used to store various social media links");
var WorkspaceDirectoryConfigSchema = z.object({
cache: z.string().trim().optional().describe("The directory used to store the environment's cached file data"),
data: z.string().trim().optional().describe("The directory used to store the environment's data files"),
config: z.string().trim().optional().describe("The directory used to store the environment's configuration files"),
temp: z.string().trim().optional().describe("The directory used to store the environment's temp files"),
log: z.string().trim().optional().describe("The directory used to store the environment's temp files"),
build: z.string().trim().default("dist").describe("The directory used to store the workspace's distributable files after a build (relative to the workspace root)")
}).describe("Various directories used by the workspace to store data, cache, and configuration files");
var errorConfigSchema = z.object({
codesFile: z.string().trim().default(STORM_DEFAULT_RELEASE_BANNER).describe("The path to the workspace's error codes JSON file"),
url: z.string().trim().url().optional().describe("A URL to a page that looks up the workspace's error messages given a specific error code")
}).describe("The workspace's error config used during the error process");
var stormWorkspaceConfigSchema = z.object({
$schema: z.string().trim().default("https://cdn.jsdelivr.net/npm/@storm-software/config/schemas/storm-workspace.schema.json").optional().nullish().describe("The URL to the JSON schema file that describes the Storm configuration file"),
extends: ExtendsSchema.optional(),
name: z.string().trim().toLowerCase().optional().describe("The name of the service/package/scope using this configuration"),
namespace: z.string().trim().toLowerCase().optional().describe("The namespace of the package"),
organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
repository: z.string().trim().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
license: z.string().trim().default("Apache-2.0").describe("The license type of the package"),
homepage: z.string().trim().url().default(STORM_DEFAULT_HOMEPAGE).describe("The homepage of the workspace"),
docs: z.string().trim().url().default(STORM_DEFAULT_DOCS).describe("The base documentation site for the workspace"),
licensing: z.string().trim().url().default(STORM_DEFAULT_LICENSING).describe("The base licensing site for the workspace"),
contact: z.string().trim().url().default(STORM_DEFAULT_CONTACT).describe("The base contact site for the workspace"),
branch: z.string().trim().default("main").describe("The branch of the workspace"),
preid: z.string().optional().describe("A tag specifying the version pre-release identifier"),
owner: z.string().trim().default("@storm-software/admin").describe("The owner of the package"),
bot: WorkspaceBotConfigSchema,
release: WorkspaceReleaseConfigSchema,
account: WorkspaceAccountConfigSchema,
error: errorConfigSchema,
mode: z.enum([
"development",
"staging",
"production"
]).default("production").describe("The current runtime environment mode for the package"),
workspaceRoot: z.string().trim().default("").describe("The root directory of the workspace"),
externalPackagePatterns: z.array(z.string()).default([]).describe("The build will use these package patterns to determine if they should be external to the bundle"),
skipCache: z.boolean().default(false).describe("Should all known types of workspace caching be skipped?"),
directories: WorkspaceDirectoryConfigSchema,
packageManager: z.enum([
"npm",
"yarn",
"pnpm",
"bun"
]).default("npm").describe("The JavaScript/TypeScript package manager used by the repository"),
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
logLevel: z.enum([
"silent",
"fatal",
"error",
"warn",
"success",
"info",
"debug",
"trace",
"all"
]).default("info").describe("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`)."),
skipConfigLogging: z.boolean().optional().describe("Should the logging of the current Storm Workspace configuration be skipped?"),
registry: RegistryConfigSchema,
configFile: z.string().trim().nullable().default(null).describe("The filepath of the Storm config. When this field is null, no config file was found in the current workspace."),
colors: ColorConfigSchema.or(ColorConfigMapSchema).describe("Storm theme config values used for styling various package elements"),
extensions: z.record(z.any()).optional().default({}).describe("Configuration of each used extension")
}).describe("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.");
// ../config/src/types.ts
var COLOR_KEYS = [
"dark",
"light",
"base",
"brand",
"alternate",
"accent",
"link",
"success",
"help",
"info",
"warning",
"danger",
"fatal",
"positive",
"negative"
];
// ../config-tools/src/types.ts
var LogLevel = {
SILENT: 0,
FATAL: 10,
ERROR: 20,
WARN: 30,
SUCCESS: 35,
INFO: 40,
DEBUG: 60,
TRACE: 70,
ALL: 100
};
var LogLevelLabel = {
SILENT: "silent",
FATAL: "fatal",
ERROR: "error",
WARN: "warn",
SUCCESS: "success",
INFO: "info",
DEBUG: "debug",
TRACE: "trace",
ALL: "all"
};
// ../config-tools/src/utilities/get-default-config.ts
import { existsSync } from "node:fs";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
var DEFAULT_COLOR_CONFIG = {
light: {
background: "#fafafa",
foreground: "#1d1e22",
brand: "#1fb2a6",
alternate: "#db2777",
help: "#5C4EE5",
success: "#087f5b",
info: "#0550ae",
warning: "#e3b341",
danger: "#D8314A",
positive: "#22c55e",
negative: "#dc2626"
},
dark: {
background: "#1d1e22",
foreground: "#cbd5e1",
brand: "#2dd4bf",
alternate: "#db2777",
help: "#818cf8",
success: "#10b981",
info: "#58a6ff",
warning: "#f3d371",
danger: "#D8314A",
positive: "#22c55e",
negative: "#dc2626"
}
};
var getDefaultConfig = /* @__PURE__ */ __name(async (root) => {
let license = STORM_DEFAULT_LICENSE;
let homepage = STORM_DEFAULT_HOMEPAGE;
let name = void 0;
let namespace = void 0;
let repository = void 0;
const workspaceRoot = findWorkspaceRoot(root);
if (existsSync(join(workspaceRoot, "package.json"))) {
const file = await readFile(joinPaths(workspaceRoot, "package.json"), "utf8");
if (file) {
const packageJson = JSON.parse(file);
if (packageJson.name) {
name = packageJson.name;
}
if (packageJson.namespace) {
namespace = packageJson.namespace;
}
if (packageJson.repository) {
if (typeof packageJson.repository === "string") {
repository = packageJson.repository;
} else if (packageJson.repository.url) {
repository = packageJson.repository.url;
}
}
if (packageJson.license) {
license = packageJson.license;
}
if (packageJson.homepage) {
homepage = packageJson.homepage;
}
}
}
return {
workspaceRoot,
name,
namespace,
repository,
license,
homepage,
docs: `${homepage || STORM_DEFAULT_HOMEPAGE}/docs`,
licensing: `${homepage || STORM_DEFAULT_HOMEPAGE}/license`,
error: {
url: `${homepage || STORM_DEFAULT_HOMEPAGE}/errors`
}
};
}, "getDefaultConfig");
// ../config-tools/src/logger/chalk.ts
import chalk from "chalk";
var chalkDefault = {
hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
bgHex: /* @__PURE__ */ __name((_) => ({
whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
}), "bgHex"),
whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright"),
gray: /* @__PURE__ */ __name((message) => message, "gray"),
bold: {
hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
bgHex: /* @__PURE__ */ __name((_) => ({
whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
}), "bgHex"),
whiteBright: /* @__PURE__ */ __name((message) => message, "whiteBright")
},
dim: {
hex: /* @__PURE__ */ __name((_) => (message) => message, "hex"),
gray: /* @__PURE__ */ __name((message) => message, "gray")
}
};
var getChalk = /* @__PURE__ */ __name(() => {
let _chalk = chalk;
if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright) {
_chalk = chalkDefault;
}
return _chalk;
}, "getChalk");
// ../config-tools/src/logger/is-unicode-supported.ts
function isUnicodeSupported() {
if (process.platform !== "win32") {
return process.env.TERM !== "linux";
}
return Boolean(process.env.WT_SESSION) || // Windows Terminal
Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
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";
}
__name(isUnicodeSupported, "isUnicodeSupported");
// ../config-tools/src/logger/console-icons.ts
var useIcon = /* @__PURE__ */ __name((c, fallback) => isUnicodeSupported() ? c : fallback, "useIcon");
var CONSOLE_ICONS = {
[LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
[LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
[LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
[LogLevelLabel.INFO]: useIcon("\u2139", "i"),
[LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
[LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
[LogLevelLabel.TRACE]: useIcon("\u{1F6E0}", "T"),
[LogLevelLabel.ALL]: useIcon("\u2709", "\u2192")
};
// ../config-tools/src/logger/format-timestamp.ts
var formatTimestamp = /* @__PURE__ */ __name((date = /* @__PURE__ */ new Date()) => {
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
}, "formatTimestamp");
// ../config-tools/src/logger/get-log-level.ts
var getLogLevel = /* @__PURE__ */ __name((label) => {
switch (label) {
case "all":
return LogLevel.ALL;
case "trace":
return LogLevel.TRACE;
case "debug":
return LogLevel.DEBUG;
case "info":
return LogLevel.INFO;
case "warn":
return LogLevel.WARN;
case "error":
return LogLevel.ERROR;
case "fatal":
return LogLevel.FATAL;
case "silent":
return LogLevel.SILENT;
default:
return LogLevel.INFO;
}
}, "getLogLevel");
var getLogLevelLabel = /* @__PURE__ */ __name((logLevel = LogLevel.INFO) => {
if (logLevel >= LogLevel.ALL) {
return LogLevelLabel.ALL;
}
if (logLevel >= LogLevel.TRACE) {
return LogLevelLabel.TRACE;
}
if (logLevel >= LogLevel.DEBUG) {
return LogLevelLabel.DEBUG;
}
if (logLevel >= LogLevel.INFO) {
return LogLevelLabel.INFO;
}
if (logLevel >= LogLevel.WARN) {
return LogLevelLabel.WARN;
}
if (logLevel >= LogLevel.ERROR) {
return LogLevelLabel.ERROR;
}
if (logLevel >= LogLevel.FATAL) {
return LogLevelLabel.FATAL;
}
if (logLevel <= LogLevel.SILENT) {
return LogLevelLabel.SILENT;
}
return LogLevelLabel.INFO;
}, "getLogLevelLabel");
var isVerbose = /* @__PURE__ */ __name((label = LogLevelLabel.SILENT) => {
const logLevel = typeof label === "string" ? getLogLevel(label) : label;
return logLevel >= LogLevel.DEBUG;
}, "isVerbose");
// ../config-tools/src/logger/console.ts
var getLogFn = /* @__PURE__ */ __name((logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
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;
const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
return (_) => {
};
}
if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
return (message) => {
console.error(`
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? "#7d1a1a")(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
};
}
if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
return (message) => {
console.error(`
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? "#f85149")(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
};
}
if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
return (message) => {
console.warn(`
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? "#e3b341")(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
};
}
if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
return (message) => {
console.info(`
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? "#56d364")(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
};
}
if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
return (message) => {
console.info(`
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? "#58a6ff")(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
};
}
if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
return (message) => {
console.debug(`
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
};
}
if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
return (message) => {
console.debug(`
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
};
}
return (message) => {
console.log(`
${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? "#1fb2a6")(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
};
}, "getLogFn");
var writeFatal = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.FATAL, config)(message), "writeFatal");
var writeError = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.ERROR, config)(message), "writeError");
var writeWarning = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.WARN, config)(message), "writeWarning");
var writeInfo = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.INFO, config)(message), "writeInfo");
var writeSuccess = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.SUCCESS, config)(message), "writeSuccess");
var writeDebug = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.DEBUG, config)(message), "writeDebug");
var writeTrace = /* @__PURE__ */ __name((message, config) => getLogFn(LogLevel.TRACE, config)(message), "writeTrace");
var getStopwatch = /* @__PURE__ */ __name((name) => {
const start = process.hrtime();
return () => {
const end = process.hrtime(start);
console.info(`
> \u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(end[0] * 1e3 + end[1] / 1e6)}ms to complete
`);
};
}, "getStopwatch");
var MAX_DEPTH = 4;
var formatLogMessage = /* @__PURE__ */ __name((message, options = {}, depth = 0) => {
if (depth > MAX_DEPTH) {
return "<max depth>";
}
const prefix = options.prefix ?? "-";
const skip = options.skip ?? [];
return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, {
prefix: `${prefix}-`,
skip
}, depth + 1)}`).join("\n")}` : typeof message === "object" ? `
${Object.keys(message).filter((key) => !skip.includes(key)).map((key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(message[key], {
prefix: `${prefix}-`,
skip
}, depth + 1) : message[key]}`).join("\n")}` : message;
}, "formatLogMessage");
var _isFunction = /* @__PURE__ */ __name((value) => {
try {
return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
} catch (e) {
return false;
}
}, "_isFunction");
// ../config-tools/src/create-storm-config.ts
import defu2 from "defu";
// ../config-tools/src/config-file/get-config-file.ts
import { loadConfig } from "c12";
import defu from "defu";
var getConfigFileByName = /* @__PURE__ */ __name(async (fileName, filePath, options = {}) => {
const workspacePath = filePath || findWorkspaceRoot(filePath);
const configs = await Promise.all([
loadConfig({
cwd: workspacePath,
packageJson: true,
name: fileName,
envName: fileName?.toUpperCase(),
jitiOptions: {
debug: false,
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
},
...options
}),
loadConfig({
cwd: workspacePath,
packageJson: true,
name: fileName,
envName: fileName?.toUpperCase(),
jitiOptions: {
debug: false,
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(process.env.STORM_CACHE_DIR || "node_modules/.cache/storm", "jiti")
},
configFile: fileName,
...options
})
]);
return defu(configs[0] ?? {}, configs[1] ?? {});
}, "getConfigFileByName");
var getConfigFile = /* @__PURE__ */ __name(async (filePath, additionalFileNames = []) => {
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
const result = await getConfigFileByName("storm-workspace", workspacePath);
let config = result.config;
const configFile = result.configFile;
if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
writeTrace(`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`, {
logLevel: "all"
});
}
if (additionalFileNames && additionalFileNames.length > 0) {
const results = await Promise.all(additionalFileNames.map((fileName) => getConfigFileByName(fileName, workspacePath)));
for (const result2 of results) {
if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
writeTrace(`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`, {
logLevel: "all"
});
}
config = defu(result2.config ?? {}, config ?? {});
}
}
}
if (!config) {
return void 0;
}
config.configFile = configFile;
return config;
}, "getConfigFile");
// ../config-tools/src/env/get-env.ts
var getExtensionEnv = /* @__PURE__ */ __name((extensionName) => {
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
const name = key.replace(prefix, "").split("_").map((i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : "").join("");
if (name) {
ret[name] = process.env[key];
}
return ret;
}, {});
}, "getExtensionEnv");
var getConfigEnv = /* @__PURE__ */ __name(() => {
const prefix = "STORM_";
let config = {
extends: process.env[`${prefix}EXTENDS`] || void 0,
name: process.env[`${prefix}NAME`] || void 0,
namespace: process.env[`${prefix}NAMESPACE`] || void 0,
owner: process.env[`${prefix}OWNER`] || void 0,
bot: {
name: process.env[`${prefix}BOT_NAME`] || void 0,
email: process.env[`${prefix}BOT_EMAIL`] || void 0
},
release: {
banner: process.env[`${prefix}RELEASE_BANNER`] || void 0,
header: process.env[`${prefix}RELEASE_HEADER`] || void 0,
footer: process.env[`${prefix}RELEASE_FOOTER`] || void 0
},
error: {
codesFile: process.env[`${prefix}ERROR_CODES_FILE`] || void 0,
url: process.env[`${prefix}ERROR_URL`] || void 0
},
account: {
twitter: process.env[`${prefix}ACCOUNT_TWITTER`] || void 0,
discord: process.env[`${prefix}ACCOUNT_DISCORD`] || void 0,
telegram: process.env[`${prefix}ACCOUNT_TELEGRAM`] || void 0,
slack: process.env[`${prefix}ACCOUNT_SLACK`] || void 0,
medium: process.env[`${prefix}ACCOUNT_MEDIUM`] || void 0,
github: process.env[`${prefix}ACCOUNT_GITHUB`] || void 0
},
organization: process.env[`${prefix}ORGANIZATION`] || void 0,
packageManager: process.env[`${prefix}PACKAGE_MANAGER`] || void 0,
license: process.env[`${prefix}LICENSE`] || void 0,
homepage: process.env[`${prefix}HOMEPAGE`] || void 0,
docs: process.env[`${prefix}DOCS`] || void 0,
licensing: process.env[`${prefix}LICENSING`] || void 0,
contact: process.env[`${prefix}CONTACT`] || void 0,
timezone: process.env[`${prefix}TIMEZONE`] || process.env.TZ || void 0,
locale: process.env[`${prefix}LOCALE`] || process.env.LOCALE || void 0,
configFile: process.env[`${prefix}CONFIG_FILE`] ? correctPaths(process.env[`${prefix}CONFIG_FILE`]) : void 0,
workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`] ? correctPaths(process.env[`${prefix}WORKSPACE_ROOT`]) : void 0,
directories: {
cache: process.env[`${prefix}CACHE_DIR`] ? correctPaths(process.env[`${prefix}CACHE_DIR`]) : void 0,
data: process.env[`${prefix}DATA_DIR`] ? correctPaths(process.env[`${prefix}DATA_DIR`]) : void 0,
config: process.env[`${prefix}CONFIG_DIR`] ? correctPaths(process.env[`${prefix}CONFIG_DIR`]) : void 0,
temp: process.env[`${prefix}TEMP_DIR`] ? correctPaths(process.env[`${prefix}TEMP_DIR`]) : void 0,
log: process.env[`${prefix}LOG_DIR`] ? correctPaths(process.env[`${prefix}LOG_DIR`]) : void 0,
build: process.env[`${prefix}BUILD_DIR`] ? correctPaths(process.env[`${prefix}BUILD_DIR`]) : void 0
},
skipCache: process.env[`${prefix}SKIP_CACHE`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CACHE`]) : void 0,
mode: (process.env[`${prefix}MODE`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT) || void 0,
// ci:
// process.env[`${prefix}CI`] !== undefined
// ? Boolean(
// process.env[`${prefix}CI`] ??
// process.env.CI ??
// process.env.CONTINUOUS_INTEGRATION
// )
// : undefined,
repository: process.env[`${prefix}REPOSITORY`] || void 0,
branch: process.env[`${prefix}BRANCH`] || void 0,
preid: process.env[`${prefix}PRE_ID`] || void 0,
externalPackagePatterns: process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] ? JSON.parse(process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`]) : [],
registry: {
github: process.env[`${prefix}REGISTRY_GITHUB`] || void 0,
npm: process.env[`${prefix}REGISTRY_NPM`] || void 0,
cargo: process.env[`${prefix}REGISTRY_CARGO`] || void 0,
cyclone: process.env[`${prefix}REGISTRY_CYCLONE`] || void 0,
container: process.env[`${prefix}REGISTRY_CONTAINER`] || void 0
},
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? process.env[`${prefix}LOG_LEVEL`] && Number.isSafeInteger(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : void 0,
skipConfigLogging: process.env[`${prefix}SKIP_CONFIG_LOGGING`] !== void 0 ? Boolean(process.env[`${prefix}SKIP_CONFIG_LOGGING`]) : void 0
};
const themeNames = Object.keys(process.env).filter((envKey) => envKey.startsWith(`${prefix}COLOR_`) && COLOR_KEYS.every((colorKey) => !envKey.startsWith(`${prefix}COLOR_LIGHT_${colorKey}`) && !envKey.startsWith(`${prefix}COLOR_DARK_${colorKey}`)));
config.colors = themeNames.length > 0 ? themeNames.reduce((ret, themeName) => {
ret[themeName] = getThemeColorConfigEnv(prefix, themeName);
return ret;
}, {}) : getThemeColorConfigEnv(prefix);
if (config.docs === STORM_DEFAULT_DOCS) {
if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
config.docs = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/docs`;
} else {
config.docs = `${config.homepage}/docs`;
}
}
if (config.licensing === STORM_DEFAULT_LICENSING) {
if (config.homepage === STORM_DEFAULT_HOMEPAGE) {
config.licensing = `${STORM_DEFAULT_HOMEPAGE}/projects/${config.name}/licensing`;
} else {
config.licensing = `${config.homepage}/docs`;
}
}
const serializedConfig = process.env[`${prefix}CONFIG`];
if (serializedConfig) {
const parsed = JSON.parse(serializedConfig);
config = {
...config,
...parsed,
colors: {
...config.colors,
...parsed.colors
},
extensions: {
...config.extensions,
...parsed.extensions
}
};
}
return config;
}, "getConfigEnv");
var getThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, theme) => {
const themeName = `COLOR_${theme && theme !== "base" ? `${theme}_` : ""}`.toUpperCase();
return process.env[`${prefix}${themeName}LIGHT_BRAND`] || process.env[`${prefix}${themeName}DARK_BRAND`] ? getMultiThemeColorConfigEnv(prefix + themeName) : getSingleThemeColorConfigEnv(prefix + themeName);
}, "getThemeColorConfigEnv");
var getSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
return {
dark: process.env[`${prefix}DARK`],
light: process.env[`${prefix}LIGHT`],
brand: process.env[`${prefix}BRAND`],
alternate: process.env[`${prefix}ALTERNATE`],
accent: process.env[`${prefix}ACCENT`],
link: process.env[`${prefix}LINK`],
help: process.env[`${prefix}HELP`],
success: process.env[`${prefix}SUCCESS`],
info: process.env[`${prefix}INFO`],
warning: process.env[`${prefix}WARNING`],
danger: process.env[`${prefix}DANGER`],
fatal: process.env[`${prefix}FATAL`],
positive: process.env[`${prefix}POSITIVE`],
negative: process.env[`${prefix}NEGATIVE`]
};
}, "getSingleThemeColorConfigEnv");
var getMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
return {
light: getBaseThemeColorConfigEnv(`${prefix}_LIGHT_`),
dark: getBaseThemeColorConfigEnv(`${prefix}_DARK_`)
};
}, "getMultiThemeColorConfigEnv");
var getBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix) => {
return {
foreground: process.env[`${prefix}FOREGROUND`],
background: process.env[`${prefix}BACKGROUND`],
brand: process.env[`${prefix}BRAND`],
alternate: process.env[`${prefix}ALTERNATE`],
accent: process.env[`${prefix}ACCENT`],
link: process.env[`${prefix}LINK`],
help: process.env[`${prefix}HELP`],
success: process.env[`${prefix}SUCCESS`],
info: process.env[`${prefix}INFO`],
warning: process.env[`${prefix}WARNING`],
danger: process.env[`${prefix}DANGER`],
fatal: process.env[`${prefix}FATAL`],
positive: process.env[`${prefix}POSITIVE`],
negative: process.env[`${prefix}NEGATIVE`]
};
}, "getBaseThemeColorConfigEnv");
// ../config-tools/src/env/set-env.ts
var setExtensionEnv = /* @__PURE__ */ __name((extensionName, extension) => {
for (const key of Object.keys(extension ?? {})) {
if (extension[key]) {
const result = key?.replace(/([A-Z])+/g, (input) => input ? input[0]?.toUpperCase() + input.slice(1) : "").split(/(?=[A-Z])|[.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
let extensionKey;
if (result.length === 0) {
return;
}
if (result.length === 1) {
extensionKey = result[0]?.toUpperCase() ?? "";
} else {
extensionKey = result.reduce((ret, part) => {
return `${ret}_${part.toLowerCase()}`;
});
}
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
}
}
}, "setExtensionEnv");
var setConfigEnv = /* @__PURE__ */ __name((config) => {
const prefix = "STORM_";
if (config.extends) {
process.env[`${prefix}EXTENDS`] = Array.isArray(config.extends) ? JSON.stringify(config.extends) : config.extends;
}
if (config.name) {
process.env[`${prefix}NAME`] = config.name;
}
if (config.namespace) {
process.env[`${prefix}NAMESPACE`] = config.namespace;
}
if (config.owner) {
process.env[`${prefix}OWNER`] = config.owner;
}
if (config.bot) {
process.env[`${prefix}BOT_NAME`] = config.bot.name;
process.env[`${prefix}BOT_EMAIL`] = config.bot.email;
}
if (config.error) {
process.env[`${prefix}ERROR_CODES_FILE`] = config.error.codesFile;
process.env[`${prefix}ERROR_URL`] = config.error.url;
}
if (config.release) {
process.env[`${prefix}RELEASE_BANNER`] = config.release.banner;
process.env[`${prefix}RELEASE_HEADER`] = config.release.header;
process.env[`${prefix}RELEASE_FOOTER`] = config.release.footer;
}
if (config.account) {
if (config.account.twitter) {
process.env[`${prefix}ACCOUNT_TWITTER`] = config.account.twitter;
}
if (config.account.discord) {
process.env[`${prefix}ACCOUNT_DISCORD`] = config.account.discord;
}
if (config.account.telegram) {
process.env[`${prefix}ACCOUNT_TELEGRAM`] = config.account.telegram;
}
if (config.account.slack) {
process.env[`${prefix}ACCOUNT_SLACK`] = config.account.slack;
}
if (config.account.medium) {
process.env[`${prefix}ACCOUNT_MEDIUM`] = config.account.medium;
}
if (config.account.github) {
process.env[`${prefix}ACCOUNT_GITHUB`] = config.account.github;
}
}
if (config.organization) {
process.env[`${prefix}ORGANIZATION`] = config.organization;
}
if (config.packageManager) {
process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
}
if (config.license) {
process.env[`${prefix}LICENSE`] = config.license;
}
if (config.homepage) {
process.env[`${prefix}HOMEPAGE`] = config.homepage;
}
if (config.docs) {
process.env[`${prefix}DOCS`] = config.docs;
}
if (config.licensing) {
process.env[`${prefix}LICENSING`] = config.licensing;
}
if (config.contact) {
process.env[`${prefix}CONTACT`] = config.contact;
}
if (config.timezone) {
process.env[`${prefix}TIMEZONE`] = config.timezone;
process.env.TZ = config.timezone;
process.env.DEFAULT_TIMEZONE = config.timezone;
}
if (config.locale) {
process.env[`${prefix}LOCALE`] = config.locale;
process.env.LOCALE = config.locale;
process.env.DEFAULT_LOCALE = config.locale;
process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
}
if (config.configFile) {
process.env[`${prefix}CONFIG_FILE`] = correctPaths(config.configFile);
}
if (config.workspaceRoot) {
process.env[`${prefix}WORKSPACE_ROOT`] = correctPaths(config.workspaceRoot);
process.env.NX_WORKSPACE_ROOT = correctPaths(config.workspaceRoot);
process.env.NX_WORKSPACE_ROOT_PATH = correctPaths(config.workspaceRoot);
}
if (config.directories) {
if (!config.skipCache && config.directories.cache) {
process.env[`${prefix}CACHE_DIR`] = correctPaths(config.directories.cache);
}
if (config.directories.data) {
process.env[`${prefix}DATA_DIR`] = correctPaths(config.directories.data);
}
if (config.directories.config) {
process.env[`${prefix}CONFIG_DIR`] = correctPaths(config.directories.config);
}
if (config.directories.temp) {
process.env[`${prefix}TEMP_DIR`] = correctPaths(config.directories.temp);
}
if (config.directories.log) {
process.env[`${prefix}LOG_DIR`] = correctPaths(config.directories.log);
}
if (config.directories.build) {
process.env[`${prefix}BUILD_DIR`] = correctPaths(config.directories.build);
}
}
if (config.skipCache !== void 0) {
process.env[`${prefix}SKIP_CACHE`] = String(config.skipCache);
if (config.skipCache) {
process.env.NX_SKIP_NX_CACHE ??= String(config.skipCache);
process.env.NX_CACHE_PROJECT_GRAPH ??= String(config.skipCache);
}
}
if (config.mode) {
process.env[`${prefix}MODE`] = config.mode;
process.env.NODE_ENV = config.mode;
process.env.ENVIRONMENT = config.mode;
}
if (config.colors?.base?.light || config.colors?.base?.dark) {
for (const key of Object.keys(config.colors)) {
setThemeColorConfigEnv(`${prefix}COLOR_${key}_`, config.colors[key]);
}
} else {
setThemeColorConfigEnv(`${prefix}COLOR_`, config.colors);
}
if (config.repository) {
process.env[`${prefix}REPOSITORY`] = config.repository;
}
if (config.branch) {
process.env[`${prefix}BRANCH`] = config.branch;
}
if (config.preid) {
process.env[`${prefix}PRE_ID`] = String(config.preid);
}
if (config.externalPackagePatterns) {
process.env[`${prefix}EXTERNAL_PACKAGE_PATTERNS`] = JSON.stringify(config.externalPackagePatterns);
}
if (config.registry) {
if (config.registry.github) {
process.env[`${prefix}REGISTRY_GITHUB`] = String(config.registry.github);
}
if (config.registry.npm) {
process.env[`${prefix}REGISTRY_NPM`] = String(config.registry.npm);
}
if (config.registry.cargo) {
process.env[`${prefix}REGISTRY_CARGO`] = String(config.registry.cargo);
}
if (config.registry.cyclone) {
process.env[`${prefix}REGISTRY_CYCLONE`] = String(config.registry.cyclone);
}
if (config.registry.container) {
process.env[`${prefix}REGISTRY_CONTAINER`] = String(config.registry.container);
}
}
if (config.logLevel) {
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
process.env.LOG_LEVEL = String(config.logLevel);
process.env.NX_VERBOSE_LOGGING = String(getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false);
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
}
if (config.skipConfigLogging !== void 0) {
process.env[`${prefix}SKIP_CONFIG_LOGGING`] = String(config.skipConfigLogging);
}
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
for (const key of Object.keys(config.extensions ?? {})) {
if (config.extensions[key] && Object.keys(config.extensions[key])) {
setExtensionEnv(key, config.extensions[key]);
}
}
}, "setConfigEnv");
var setThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
return config?.light?.brand || config?.dark?.brand ? setMultiThemeColorConfigEnv(prefix, config) : setSingleThemeColorConfigEnv(prefix, config);
}, "setThemeColorConfigEnv");
var setSingleThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
if (config.dark) {
process.env[`${prefix}DARK`] = config.dark;
}
if (config.light) {
process.env[`${prefix}LIGHT`] = config.light;
}
if (config.brand) {
process.env[`${prefix}BRAND`] = config.brand;
}
if (config.alternate) {
process.env[`${prefix}ALTERNATE`] = config.alternate;
}
if (config.accent) {
process.env[`${prefix}ACCENT`] = config.accent;
}
if (config.link) {
process.env[`${prefix}LINK`] = config.link;
}
if (config.help) {
process.env[`${prefix}HELP`] = config.help;
}
if (config.success) {
process.env[`${prefix}SUCCESS`] = config.success;
}
if (config.info) {
process.env[`${prefix}INFO`] = config.info;
}
if (config.warning) {
process.env[`${prefix}WARNING`] = config.warning;
}
if (config.danger) {
process.env[`${prefix}DANGER`] = config.danger;
}
if (config.fatal) {
process.env[`${prefix}FATAL`] = config.fatal;
}
if (config.positive) {
process.env[`${prefix}POSITIVE`] = config.positive;
}
if (config.negative) {
process.env[`${prefix}NEGATIVE`] = config.negative;
}
}, "setSingleThemeColorConfigEnv");
var setMultiThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
return {
light: setBaseThemeColorConfigEnv(`${prefix}LIGHT_`, config.light),
dark: setBaseThemeColorConfigEnv(`${prefix}DARK_`, config.dark)
};
}, "setMultiThemeColorConfigEnv");
var setBaseThemeColorConfigEnv = /* @__PURE__ */ __name((prefix, config) => {
if (config.foreground) {
process.env[`${prefix}FOREGROUND`] = config.foreground;
}
if (config.background) {
process.env[`${prefix}BACKGROUND`] = config.background;
}
if (config.brand) {
process.env[`${prefix}BRAND`] = config.brand;
}
if (config.alternate) {
process.env[`${prefix}ALTERNATE`] = config.alternate;
}
if (config.accent) {
process.env[`${prefix}ACCENT`] = config.accent;
}
if (config.link) {
process.env[`${prefix}LINK`] = config.link;
}
if (config.help) {
process.env[`${prefix}HELP`] = config.help;
}
if (config.success) {
process.env[`${prefix}SUCCESS`] = config.success;
}
if (config.info) {
process.env[`${prefix}INFO`] = config.info;
}
if (config.warning) {
process.env[`${prefix}WARNING`] = config.warning;
}
if (config.danger) {
process.env[`${prefix}DANGER`] = config.danger;
}
if (config.fatal) {
process.env[`${prefix}FATAL`] = config.fatal;
}
if (config.positive) {
process.env[`${prefix}POSITIVE`] = config.positive;
}
if (config.negative) {
process.env[`${prefix}NEGATIVE`] = config.negative;
}
}, "setBaseThemeColorConfigEnv");
// ../config-tools/src/create-storm-config.ts
var _extension_cache = /* @__PURE__ */ new WeakMap();
var _static_cache = void 0;
var createStormWorkspaceConfig = /* @__PURE__ */ __name(async (extensionName, schema, workspaceRoot, skipLogs = false) => {
let result;
if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
let _workspaceRoot = workspaceRoot;
if (!_workspaceRoot) {
_workspaceRoot = findWorkspaceRoot();
}
const configEnv = getConfigEnv();
const defaultConfig = await getDefaultConfig(_workspaceRoot);
const configFile = await getConfigFile(_workspaceRoot);
if (!configFile && !skipLogs) {
writeWarning("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", {
logLevel: "all"
});
}
result = await stormWorkspaceConfigSchema.parseAsync(defu2(configEnv, configFile, defaultConfig));
result.workspaceRoot ??= _workspaceRoot;
} else {
result = _static_cache.data;
}
if (schema && extensionName) {
result.extensions = {
...result.extensions,
[extensionName]: createConfigExtension(extensionName, schema)
};
}
_static_cache = {
timestamp: Date.now(),
data: result
};
return result;
}, "createStormWorkspaceConfig");
var createConfigExtension = /* @__PURE__ */ __name((extensionName, schema) => {
const extension_cache_key = {
extensionName
};
if (_extension_cache.has(extension_cache_key)) {
return _extension_cache.get(extension_cache_key);
}
let extension = getExtensionEnv(extensionName);
if (schema) {
extension = schema.parse(extension);
}
_extension_cache.set(extension_cache_key, extension);
return extension;
}, "createConfigExtension");
var loadStormWorkspaceConfig = /* @__PURE__ */ __name(async (workspaceRoot, skipLogs = false) => {
const config = await createStormWorkspaceConfig(void 0, void 0, workspaceRoot, skipLogs);
setConfigEnv(config);
if (!skipLogs && !config.skipConfigLogging) {
writeTrace(`\u2699\uFE0F Using Storm Workspace configuration:
${formatLogMessage(config)}`, config);
}
return config;
}, "loadStormWorkspaceConfig");
// ../config-tools/src/get-config.ts
var getConfig = /* @__PURE__ */ __name((workspaceRoot, skipLogs = false) => {
return