@storm-software/config-tools 1.23.7 → 1.23.11
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/CHANGELOG.md +54 -0
- package/LICENSE +201 -0
- package/index.cjs +504 -0
- package/index.js +504 -0
- package/meta.cjs.json +1 -0
- package/meta.esm.json +1 -0
- package/package.json +1 -1
- package/utilities/find-workspace-root.cjs +4 -0
- package/utilities/find-workspace-root.js +4 -0
- package/utilities/logger.cjs +24 -0
- package/utilities/logger.js +24 -0
- package/jest.config.ts +0 -3
- package/project.json +0 -66
- package/src/config-file/define-config.ts +0 -9
- package/src/config-file/get-config-file.ts +0 -56
- package/src/config-file/index.ts +0 -2
- package/src/create-storm-config.ts +0 -129
- package/src/env/get-env.ts +0 -112
- package/src/env/index.ts +0 -2
- package/src/env/set-env.ts +0 -162
- package/src/index.ts +0 -15
- package/src/schema.ts +0 -179
- package/src/types.ts +0 -53
- package/src/utilities/find-up.ts +0 -21
- package/src/utilities/find-workspace-root.ts +0 -66
- package/src/utilities/get-default-config.ts +0 -97
- package/src/utilities/get-log-level.ts +0 -64
- package/src/utilities/index.ts +0 -6
- package/src/utilities/logger.ts +0 -234
- package/src/utilities/process-handler.ts +0 -44
- package/src/utilities/run.ts +0 -30
- package/tsconfig.json +0 -11
- package/tsconfig.spec.json +0 -13
package/src/env/set-env.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { LogLevel, type StormConfig } from "../types";
|
|
2
|
-
import { getLogLevel } from "../utilities/get-log-level";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get the config for an extension module of Storm workspace from environment variables
|
|
6
|
-
*
|
|
7
|
-
* @param extensionName - The name of the extension module
|
|
8
|
-
* @returns The config for the specified Storm extension module. If the module does not exist, `undefined` is returned.
|
|
9
|
-
*/
|
|
10
|
-
export const setExtensionEnv = <TConfig extends Record<string, any> = Record<string, any>>(
|
|
11
|
-
extensionName: string,
|
|
12
|
-
extension: TConfig
|
|
13
|
-
) => {
|
|
14
|
-
for (const key of Object.keys(extension ?? {})) {
|
|
15
|
-
if (extension[key]) {
|
|
16
|
-
const result =
|
|
17
|
-
key
|
|
18
|
-
?.replace(/([A-Z])+/g, (input?: string) =>
|
|
19
|
-
input ? input[0].toUpperCase() + input.slice(1) : ""
|
|
20
|
-
)
|
|
21
|
-
.split(/(?=[A-Z])|[\.\-\s_]/)
|
|
22
|
-
.map((x: string) => x.toLowerCase()) ?? [];
|
|
23
|
-
|
|
24
|
-
let extensionKey: string;
|
|
25
|
-
if (result.length === 0) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (result.length === 1) {
|
|
29
|
-
extensionKey = result[0].toUpperCase();
|
|
30
|
-
} else {
|
|
31
|
-
extensionKey = result.reduce((ret: string, part: string) => {
|
|
32
|
-
return `${ret}_${part.toLowerCase()}`;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] =
|
|
37
|
-
extension[key];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get the config for the current Storm workspace
|
|
44
|
-
*
|
|
45
|
-
* @returns The config for the current Storm workspace from environment variables
|
|
46
|
-
*/
|
|
47
|
-
export const setConfigEnv = (config: StormConfig) => {
|
|
48
|
-
const prefix = "STORM_";
|
|
49
|
-
|
|
50
|
-
if (config.name) {
|
|
51
|
-
process.env[`${prefix}NAME`] = config.name;
|
|
52
|
-
}
|
|
53
|
-
if (config.namespace) {
|
|
54
|
-
process.env[`${prefix}NAMESPACE`] = config.namespace;
|
|
55
|
-
}
|
|
56
|
-
if (config.owner) {
|
|
57
|
-
process.env[`${prefix}OWNER`] = config.owner;
|
|
58
|
-
}
|
|
59
|
-
if (config.worker) {
|
|
60
|
-
process.env[`${prefix}WORKER`] = config.worker;
|
|
61
|
-
}
|
|
62
|
-
if (config.organization) {
|
|
63
|
-
process.env[`${prefix}ORGANIZATION`] = config.organization;
|
|
64
|
-
}
|
|
65
|
-
if (config.packageManager) {
|
|
66
|
-
process.env[`${prefix}PACKAGE_MANAGER`] = config.packageManager;
|
|
67
|
-
}
|
|
68
|
-
if (config.license) {
|
|
69
|
-
process.env[`${prefix}LICENSE`] = config.license;
|
|
70
|
-
}
|
|
71
|
-
if (config.homepage) {
|
|
72
|
-
process.env[`${prefix}HOMEPAGE`] = config.homepage;
|
|
73
|
-
}
|
|
74
|
-
if (config.timezone) {
|
|
75
|
-
process.env[`${prefix}TIMEZONE`] = config.timezone;
|
|
76
|
-
process.env.TZ = config.timezone;
|
|
77
|
-
process.env.DEFAULT_TIMEZONE = config.timezone;
|
|
78
|
-
}
|
|
79
|
-
if (config.locale) {
|
|
80
|
-
process.env[`${prefix}LOCALE`] = config.locale;
|
|
81
|
-
process.env.LOCALE = config.locale;
|
|
82
|
-
process.env.DEFAULT_LOCALE = config.locale;
|
|
83
|
-
process.env.LANG = config.locale
|
|
84
|
-
? `${config.locale.replaceAll("-", "_")}.UTF-8`
|
|
85
|
-
: "en_US.UTF-8";
|
|
86
|
-
}
|
|
87
|
-
if (config.configFile) {
|
|
88
|
-
process.env[`${prefix}CONFIG_FILE`] = config.configFile;
|
|
89
|
-
}
|
|
90
|
-
if (config.workspaceRoot) {
|
|
91
|
-
process.env[`${prefix}WORKSPACE_ROOT`] = config.workspaceRoot;
|
|
92
|
-
process.env.NX_WORKSPACE_ROOT = config.workspaceRoot;
|
|
93
|
-
process.env.NX_WORKSPACE_ROOT_PATH = config.workspaceRoot;
|
|
94
|
-
}
|
|
95
|
-
if (config.packageDirectory) {
|
|
96
|
-
process.env[`${prefix}PACKAGE_DIRECTORY`] = config.packageDirectory;
|
|
97
|
-
}
|
|
98
|
-
if (config.buildDirectory) {
|
|
99
|
-
process.env[`${prefix}BUILD_DIRECTORY`] = config.buildDirectory;
|
|
100
|
-
}
|
|
101
|
-
if (config.runtimeVersion) {
|
|
102
|
-
process.env[`${prefix}RUNTIME_VERSION`] = config.runtimeVersion;
|
|
103
|
-
}
|
|
104
|
-
if (config.runtimeDirectory) {
|
|
105
|
-
process.env[`${prefix}RUNTIME_DIRECTORY`] = config.runtimeDirectory;
|
|
106
|
-
}
|
|
107
|
-
if (config.env) {
|
|
108
|
-
process.env[`${prefix}ENV`] = config.env;
|
|
109
|
-
process.env.NODE_ENV = config.env;
|
|
110
|
-
process.env.ENVIRONMENT = config.env;
|
|
111
|
-
}
|
|
112
|
-
if (config.ci) {
|
|
113
|
-
process.env[`${prefix}CI`] = String(config.ci);
|
|
114
|
-
process.env.CI = String(config.ci);
|
|
115
|
-
process.env.CONTINUOUS_INTEGRATION = String(config.ci);
|
|
116
|
-
}
|
|
117
|
-
if (config.colors.primary) {
|
|
118
|
-
process.env[`${prefix}COLOR_PRIMARY`] = config.colors.primary;
|
|
119
|
-
}
|
|
120
|
-
if (config.colors.background) {
|
|
121
|
-
process.env[`${prefix}COLOR_BACKGROUND`] = config.colors.background;
|
|
122
|
-
}
|
|
123
|
-
if (config.colors.success) {
|
|
124
|
-
process.env[`${prefix}COLOR_SUCCESS`] = config.colors.success;
|
|
125
|
-
}
|
|
126
|
-
if (config.colors.info) {
|
|
127
|
-
process.env[`${prefix}COLOR_INFO`] = config.colors.info;
|
|
128
|
-
}
|
|
129
|
-
if (config.colors.warning) {
|
|
130
|
-
process.env[`${prefix}COLOR_WARNING`] = config.colors.warning;
|
|
131
|
-
}
|
|
132
|
-
if (config.colors.error) {
|
|
133
|
-
process.env[`${prefix}COLOR_ERROR`] = config.colors.error;
|
|
134
|
-
}
|
|
135
|
-
if (config.colors.fatal) {
|
|
136
|
-
process.env[`${prefix}COLOR_FATAL`] = config.colors.fatal;
|
|
137
|
-
}
|
|
138
|
-
if (config.repository) {
|
|
139
|
-
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
140
|
-
}
|
|
141
|
-
if (config.branch) {
|
|
142
|
-
process.env[`${prefix}BRANCH`] = config.branch;
|
|
143
|
-
}
|
|
144
|
-
if (config.preid) {
|
|
145
|
-
process.env[`${prefix}PRE_ID`] = String(config.preid);
|
|
146
|
-
}
|
|
147
|
-
if (config.logLevel) {
|
|
148
|
-
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
149
|
-
process.env.LOG_LEVEL = String(config.logLevel);
|
|
150
|
-
process.env.NX_VERBOSE_LOGGING = String(
|
|
151
|
-
getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
|
|
152
|
-
);
|
|
153
|
-
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
154
|
-
}
|
|
155
|
-
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
156
|
-
|
|
157
|
-
for (const key of Object.keys(config.extensions ?? {})) {
|
|
158
|
-
config.extensions[key] &&
|
|
159
|
-
Object.keys(config.extensions[key]) &&
|
|
160
|
-
setExtensionEnv(key, config.extensions[key]);
|
|
161
|
-
}
|
|
162
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The config-tools library used by Storm Software for building TypeScript applications.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* A package containing various utilities to support custom workspace configurations
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export * from "./config-file";
|
|
11
|
-
export * from "./create-storm-config";
|
|
12
|
-
export * from "./env";
|
|
13
|
-
export * from "./schema";
|
|
14
|
-
export * from "./types";
|
|
15
|
-
export * from "./utilities";
|
package/src/schema.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Storm theme color config values used for styling various workspace elements
|
|
5
|
-
*/
|
|
6
|
-
export const ColorConfigSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
primary: z
|
|
9
|
-
.string()
|
|
10
|
-
.trim()
|
|
11
|
-
.toLowerCase()
|
|
12
|
-
.regex(/^#([0-9a-f]{3}){1,2}$/i)
|
|
13
|
-
.length(7)
|
|
14
|
-
.default("#0ea5e9")
|
|
15
|
-
.describe("The primary color of the workspace"),
|
|
16
|
-
background: z
|
|
17
|
-
.string()
|
|
18
|
-
.trim()
|
|
19
|
-
.toLowerCase()
|
|
20
|
-
.regex(/^#([0-9a-f]{3}){1,2}$/i)
|
|
21
|
-
.length(7)
|
|
22
|
-
.default("#1d232a")
|
|
23
|
-
.describe("The background color of the workspace"),
|
|
24
|
-
success: z
|
|
25
|
-
.string()
|
|
26
|
-
.trim()
|
|
27
|
-
.toLowerCase()
|
|
28
|
-
.regex(/^#([0-9a-f]{3}){1,2}$/i)
|
|
29
|
-
.length(7)
|
|
30
|
-
.default("#087f5b")
|
|
31
|
-
.describe("The success color of the workspace"),
|
|
32
|
-
info: z
|
|
33
|
-
.string()
|
|
34
|
-
.trim()
|
|
35
|
-
.toLowerCase()
|
|
36
|
-
.regex(/^#([0-9a-f]{3}){1,2}$/i)
|
|
37
|
-
.length(7)
|
|
38
|
-
.default("#0ea5e9")
|
|
39
|
-
.describe("The informational color of the workspace"),
|
|
40
|
-
warning: z
|
|
41
|
-
.string()
|
|
42
|
-
.trim()
|
|
43
|
-
.toLowerCase()
|
|
44
|
-
.regex(/^#([0-9a-f]{3}){1,2}$/i)
|
|
45
|
-
.length(7)
|
|
46
|
-
.default("#fcc419")
|
|
47
|
-
.describe("The warning color of the workspace"),
|
|
48
|
-
error: z
|
|
49
|
-
.string()
|
|
50
|
-
.trim()
|
|
51
|
-
.toLowerCase()
|
|
52
|
-
.regex(/^#([0-9a-f]{3}){1,2}$/i)
|
|
53
|
-
.length(7)
|
|
54
|
-
.default("#990000")
|
|
55
|
-
.describe("The error color of the workspace"),
|
|
56
|
-
fatal: z
|
|
57
|
-
.string()
|
|
58
|
-
.trim()
|
|
59
|
-
.toLowerCase()
|
|
60
|
-
.regex(/^#([0-9a-f]{3}){1,2}$/i)
|
|
61
|
-
.length(7)
|
|
62
|
-
.default("#7d1a1a")
|
|
63
|
-
.describe("The fatal color of the workspace")
|
|
64
|
-
})
|
|
65
|
-
.describe("Colors used for various workspace elements");
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Storm Workspace config values used during various dev-ops processes. It represents the config of the entire monorepo.
|
|
69
|
-
*/
|
|
70
|
-
export const StormConfigSchema = z
|
|
71
|
-
.object({
|
|
72
|
-
name: z.string().trim().toLowerCase().optional().describe("The name of the package"),
|
|
73
|
-
namespace: z.string().trim().toLowerCase().optional().describe("The namespace of the package"),
|
|
74
|
-
organization: z
|
|
75
|
-
.string()
|
|
76
|
-
.trim()
|
|
77
|
-
.default("storm-software")
|
|
78
|
-
.describe("The organization of the workspace"),
|
|
79
|
-
repository: z
|
|
80
|
-
.string()
|
|
81
|
-
.trim()
|
|
82
|
-
.url()
|
|
83
|
-
.optional()
|
|
84
|
-
.describe("The repo URL of the workspace (i.e. GitHub)"),
|
|
85
|
-
license: z
|
|
86
|
-
.string()
|
|
87
|
-
.trim()
|
|
88
|
-
.default("Apache License 2.0")
|
|
89
|
-
.describe("The root directory of the package"),
|
|
90
|
-
homepage: z
|
|
91
|
-
.string()
|
|
92
|
-
.trim()
|
|
93
|
-
.url()
|
|
94
|
-
.default("https://stormsoftware.org")
|
|
95
|
-
.describe("The homepage of the workspace"),
|
|
96
|
-
branch: z.string().trim().default("main").describe("The branch of the workspace"),
|
|
97
|
-
preid: z.string().optional().describe("A tag specifying the version pre-release identifier"),
|
|
98
|
-
owner: z
|
|
99
|
-
.string()
|
|
100
|
-
.trim()
|
|
101
|
-
.default("@storm-software/development")
|
|
102
|
-
.describe("The owner of the package"),
|
|
103
|
-
worker: z
|
|
104
|
-
.string()
|
|
105
|
-
.trim()
|
|
106
|
-
.default("stormie-bot")
|
|
107
|
-
.describe(
|
|
108
|
-
"The worker of the package (this is the bot that will be used to perform various tasks)"
|
|
109
|
-
),
|
|
110
|
-
env: z
|
|
111
|
-
.enum(["development", "staging", "production"])
|
|
112
|
-
.default("production")
|
|
113
|
-
.describe("The current runtime environment of the package"),
|
|
114
|
-
ci: z
|
|
115
|
-
.boolean()
|
|
116
|
-
.default(true)
|
|
117
|
-
.describe("An indicator specifying if the current environment is a CI environment"),
|
|
118
|
-
workspaceRoot: z.string().trim().optional().describe("The root directory of the workspace"),
|
|
119
|
-
packageDirectory: z.string().trim().optional().describe("The root directory of the package"),
|
|
120
|
-
externalPackagePatterns: z
|
|
121
|
-
.array(z.string())
|
|
122
|
-
.default([])
|
|
123
|
-
.describe(
|
|
124
|
-
"The build will use these package patterns to determine if they should be external to the bundle"
|
|
125
|
-
),
|
|
126
|
-
buildDirectory: z
|
|
127
|
-
.string()
|
|
128
|
-
.trim()
|
|
129
|
-
.default("dist")
|
|
130
|
-
.describe("The build directory for the workspace"),
|
|
131
|
-
runtimeDirectory: z
|
|
132
|
-
.string()
|
|
133
|
-
.trim()
|
|
134
|
-
.default("node_modules/.storm")
|
|
135
|
-
.describe("The runtime directory of Storm"),
|
|
136
|
-
runtimeVersion: z
|
|
137
|
-
.string()
|
|
138
|
-
.trim()
|
|
139
|
-
.regex(
|
|
140
|
-
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
|
|
141
|
-
)
|
|
142
|
-
.default("1.0.0")
|
|
143
|
-
.describe("The global version of the Storm runtime"),
|
|
144
|
-
packageManager: z
|
|
145
|
-
.enum(["npm", "yarn", "pnpm", "bun"])
|
|
146
|
-
.default("npm")
|
|
147
|
-
.describe("The package manager used by the repository"),
|
|
148
|
-
timezone: z
|
|
149
|
-
.string()
|
|
150
|
-
.trim()
|
|
151
|
-
.default("America/New_York")
|
|
152
|
-
.describe("The default timezone of the workspace"),
|
|
153
|
-
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
154
|
-
logLevel: z
|
|
155
|
-
.enum(["silent", "fatal", "error", "warn", "info", "debug", "trace", "all"])
|
|
156
|
-
.default("debug")
|
|
157
|
-
.describe(
|
|
158
|
-
"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`)."
|
|
159
|
-
),
|
|
160
|
-
configFile: z
|
|
161
|
-
.string()
|
|
162
|
-
.trim()
|
|
163
|
-
.nullable()
|
|
164
|
-
.default(null)
|
|
165
|
-
.describe(
|
|
166
|
-
"The filepath of the Storm config. When this field is null, no config file was found in the current workspace."
|
|
167
|
-
),
|
|
168
|
-
colors: ColorConfigSchema.describe(
|
|
169
|
-
"Storm theme config values used for styling various package elements"
|
|
170
|
-
),
|
|
171
|
-
extensions: z
|
|
172
|
-
.record(z.any())
|
|
173
|
-
.optional()
|
|
174
|
-
.default({})
|
|
175
|
-
.describe("Configuration of each used extension")
|
|
176
|
-
})
|
|
177
|
-
.describe(
|
|
178
|
-
"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."
|
|
179
|
-
);
|
package/src/types.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type * as z from "zod";
|
|
2
|
-
import type { ColorConfigSchema, StormConfigSchema } from "./schema";
|
|
3
|
-
|
|
4
|
-
export type ColorConfig = z.infer<typeof ColorConfigSchema>;
|
|
5
|
-
export type ColorConfigInput = z.input<typeof ColorConfigSchema>;
|
|
6
|
-
|
|
7
|
-
type TStormConfig = z.infer<typeof StormConfigSchema>;
|
|
8
|
-
export type StormConfigInput = z.input<typeof StormConfigSchema>;
|
|
9
|
-
|
|
10
|
-
export type StormConfig<
|
|
11
|
-
TExtensionName extends keyof TStormConfig["extensions"] = keyof TStormConfig["extensions"],
|
|
12
|
-
TExtensionConfig extends
|
|
13
|
-
TStormConfig["extensions"][TExtensionName] = TStormConfig["extensions"][TExtensionName]
|
|
14
|
-
> = TStormConfig & {
|
|
15
|
-
extensions?:
|
|
16
|
-
| (TStormConfig["extensions"] & {
|
|
17
|
-
[extensionName in TExtensionName]: TExtensionConfig;
|
|
18
|
-
})
|
|
19
|
-
| Record<string, any>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type LogLevel = 0 | 10 | 20 | 30 | 40 | 45 | 60 | 70 | 100;
|
|
23
|
-
export const LogLevel = {
|
|
24
|
-
SILENT: 0 as LogLevel,
|
|
25
|
-
FATAL: 10 as LogLevel,
|
|
26
|
-
ERROR: 20 as LogLevel,
|
|
27
|
-
WARN: 30 as LogLevel,
|
|
28
|
-
INFO: 40 as LogLevel,
|
|
29
|
-
SUCCESS: 45 as LogLevel,
|
|
30
|
-
DEBUG: 60 as LogLevel,
|
|
31
|
-
TRACE: 70 as LogLevel,
|
|
32
|
-
ALL: 100 as LogLevel
|
|
33
|
-
} as const;
|
|
34
|
-
|
|
35
|
-
export type LogLevelLabel =
|
|
36
|
-
| "silent"
|
|
37
|
-
| "fatal"
|
|
38
|
-
| "error"
|
|
39
|
-
| "warn"
|
|
40
|
-
| "info"
|
|
41
|
-
| "debug"
|
|
42
|
-
| "trace"
|
|
43
|
-
| "all";
|
|
44
|
-
export const LogLevelLabel = {
|
|
45
|
-
SILENT: "silent" as LogLevelLabel,
|
|
46
|
-
FATAL: "fatal" as LogLevelLabel,
|
|
47
|
-
ERROR: "error" as LogLevelLabel,
|
|
48
|
-
WARN: "warn" as LogLevelLabel,
|
|
49
|
-
INFO: "info" as LogLevelLabel,
|
|
50
|
-
DEBUG: "debug" as LogLevelLabel,
|
|
51
|
-
TRACE: "trace" as LogLevelLabel,
|
|
52
|
-
ALL: "all" as LogLevelLabel
|
|
53
|
-
} as const;
|
package/src/utilities/find-up.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
|
|
4
|
-
const MAX_PATH_SEARCH_DEPTH = 30;
|
|
5
|
-
let depth = 0;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Gets the nearest "node_modules" folder by walking up from start path.
|
|
9
|
-
*/
|
|
10
|
-
export function findFolderUp(startPath: string, endFileNames: string[]): string | undefined {
|
|
11
|
-
const _startPath = startPath ?? process.cwd();
|
|
12
|
-
|
|
13
|
-
if (endFileNames.some((endFileName) => existsSync(join(_startPath, endFileName)))) {
|
|
14
|
-
return _startPath;
|
|
15
|
-
}
|
|
16
|
-
if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
17
|
-
const parent = join(_startPath, "..");
|
|
18
|
-
return findFolderUp(parent, endFileNames);
|
|
19
|
-
}
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { findFolderUp } from "./find-up";
|
|
2
|
-
|
|
3
|
-
const rootFiles = [
|
|
4
|
-
"lerna.json",
|
|
5
|
-
"storm.config.js",
|
|
6
|
-
"storm.config.ts",
|
|
7
|
-
".storm.json",
|
|
8
|
-
".storm.yaml",
|
|
9
|
-
".storm.yml",
|
|
10
|
-
".storm.js",
|
|
11
|
-
".storm.ts",
|
|
12
|
-
"nx.json",
|
|
13
|
-
"turbo.json",
|
|
14
|
-
"npm-workspace.json",
|
|
15
|
-
"yarn-workspace.json",
|
|
16
|
-
"pnpm-workspace.json",
|
|
17
|
-
"npm-workspace.yaml",
|
|
18
|
-
"yarn-workspace.yaml",
|
|
19
|
-
"pnpm-workspace.yaml",
|
|
20
|
-
"npm-workspace.yml",
|
|
21
|
-
"yarn-workspace.yml",
|
|
22
|
-
"pnpm-workspace.yml",
|
|
23
|
-
"npm-lock.json",
|
|
24
|
-
"yarn-lock.json",
|
|
25
|
-
"pnpm-lock.json",
|
|
26
|
-
"npm-lock.yaml",
|
|
27
|
-
"yarn-lock.yaml",
|
|
28
|
-
"pnpm-lock.yaml",
|
|
29
|
-
"npm-lock.yml",
|
|
30
|
-
"yarn-lock.yml",
|
|
31
|
-
"pnpm-lock.yml",
|
|
32
|
-
"bun.lockb"
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Find the monorepo root directory, searching upwards from `path`.
|
|
37
|
-
*
|
|
38
|
-
* @param pathInsideMonorepo - The path inside the monorepo to start searching from
|
|
39
|
-
* @returns The monorepo root directory
|
|
40
|
-
*/
|
|
41
|
-
export function findWorkspaceRootSafe(pathInsideMonorepo?: string): string | undefined {
|
|
42
|
-
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
43
|
-
return process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Find the monorepo root directory, searching upwards from `path`.
|
|
51
|
-
*
|
|
52
|
-
* @param pathInsideMonorepo - The path inside the monorepo to start searching from
|
|
53
|
-
* @returns The monorepo root directory
|
|
54
|
-
*/
|
|
55
|
-
export function findWorkspaceRoot(pathInsideMonorepo?: string): string {
|
|
56
|
-
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
57
|
-
if (!result) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
`Cannot find workspace root upwards from known path. Files search list includes: \n${rootFiles.join(
|
|
60
|
-
"\n"
|
|
61
|
-
)}\nPath: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { StormConfigSchema } from "../schema";
|
|
4
|
-
import type { ColorConfig, StormConfig } from "../types";
|
|
5
|
-
import { findWorkspaceRoot } from "./find-workspace-root";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Storm theme config values used for styling various workspace elements
|
|
9
|
-
*/
|
|
10
|
-
export const DEFAULT_COLOR_CONFIG: ColorConfig = {
|
|
11
|
-
primary: "#1fb2a6",
|
|
12
|
-
background: "#1d232a",
|
|
13
|
-
success: "#087f5b",
|
|
14
|
-
info: "#0ea5e9",
|
|
15
|
-
warning: "#fcc419",
|
|
16
|
-
error: "#990000",
|
|
17
|
-
fatal: "#7d1a1a"
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Storm Workspace config values used during various dev-ops processes
|
|
22
|
-
*/
|
|
23
|
-
export const DEFAULT_STORM_CONFIG: StormConfig = {
|
|
24
|
-
name: "storm",
|
|
25
|
-
namespace: "storm-software",
|
|
26
|
-
license: "Apache License 2.0",
|
|
27
|
-
homepage: "https://stormsoftware.org",
|
|
28
|
-
owner: "@storm-software/development",
|
|
29
|
-
worker: "stormie-bot",
|
|
30
|
-
runtimeDirectory: "node_modules/.storm",
|
|
31
|
-
packageManager: "npm",
|
|
32
|
-
timezone: "America/New_York",
|
|
33
|
-
locale: "en-US",
|
|
34
|
-
env: "production",
|
|
35
|
-
branch: "main",
|
|
36
|
-
organization: "storm-software",
|
|
37
|
-
ci: true,
|
|
38
|
-
configFile: null,
|
|
39
|
-
runtimeVersion: "1.0.0",
|
|
40
|
-
colors: { ...DEFAULT_COLOR_CONFIG },
|
|
41
|
-
extensions: {}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get the default Storm config values used during various dev-ops processes
|
|
46
|
-
*
|
|
47
|
-
* @returns The default Storm config values
|
|
48
|
-
*/
|
|
49
|
-
export const getDefaultConfig = (config: Partial<StormConfig> = {}, root?: string): StormConfig => {
|
|
50
|
-
let name = "storm-workspace";
|
|
51
|
-
let namespace = "storm-software";
|
|
52
|
-
let repository = "https://github.com/storm-software/storm-ops";
|
|
53
|
-
|
|
54
|
-
let license = DEFAULT_STORM_CONFIG.license;
|
|
55
|
-
let homepage = DEFAULT_STORM_CONFIG.homepage;
|
|
56
|
-
|
|
57
|
-
const workspaceRoot = findWorkspaceRoot(root);
|
|
58
|
-
if (existsSync(join(workspaceRoot, "package.json"))) {
|
|
59
|
-
const file = readFileSync(join(workspaceRoot, "package.json"), {
|
|
60
|
-
encoding: "utf-8"
|
|
61
|
-
});
|
|
62
|
-
if (file) {
|
|
63
|
-
const packageJson = JSON.parse(file);
|
|
64
|
-
|
|
65
|
-
if (packageJson.name) {
|
|
66
|
-
name = packageJson.name;
|
|
67
|
-
}
|
|
68
|
-
if (packageJson.namespace) {
|
|
69
|
-
namespace = packageJson.namespace;
|
|
70
|
-
}
|
|
71
|
-
if (packageJson.repository?.url) {
|
|
72
|
-
repository = packageJson.repository?.url;
|
|
73
|
-
}
|
|
74
|
-
if (packageJson.license) {
|
|
75
|
-
license = packageJson.license;
|
|
76
|
-
}
|
|
77
|
-
if (packageJson.homepage) {
|
|
78
|
-
homepage = packageJson.homepage;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return StormConfigSchema.parse({
|
|
84
|
-
...(DEFAULT_STORM_CONFIG as Required<StormConfig>),
|
|
85
|
-
...config,
|
|
86
|
-
colors: { ...DEFAULT_COLOR_CONFIG, ...config.colors },
|
|
87
|
-
workspaceRoot,
|
|
88
|
-
name,
|
|
89
|
-
namespace,
|
|
90
|
-
repository,
|
|
91
|
-
license: license ?? DEFAULT_STORM_CONFIG.license,
|
|
92
|
-
homepage: homepage ?? DEFAULT_STORM_CONFIG.homepage,
|
|
93
|
-
extensions: {
|
|
94
|
-
...config.extensions
|
|
95
|
-
}
|
|
96
|
-
}) as StormConfig;
|
|
97
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { LogLevel, LogLevelLabel } from "../types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Convert the log level label to a log level
|
|
5
|
-
*
|
|
6
|
-
* @param label - The log level label to convert
|
|
7
|
-
* @returns The log level
|
|
8
|
-
*/
|
|
9
|
-
export const getLogLevel = (label: string): LogLevel => {
|
|
10
|
-
switch (label) {
|
|
11
|
-
case "all":
|
|
12
|
-
return LogLevel.ALL;
|
|
13
|
-
case "trace":
|
|
14
|
-
return LogLevel.TRACE;
|
|
15
|
-
case "debug":
|
|
16
|
-
return LogLevel.DEBUG;
|
|
17
|
-
case "info":
|
|
18
|
-
return LogLevel.INFO;
|
|
19
|
-
case "warn":
|
|
20
|
-
return LogLevel.WARN;
|
|
21
|
-
case "error":
|
|
22
|
-
return LogLevel.ERROR;
|
|
23
|
-
case "fatal":
|
|
24
|
-
return LogLevel.FATAL;
|
|
25
|
-
case "silent":
|
|
26
|
-
return LogLevel.SILENT;
|
|
27
|
-
default:
|
|
28
|
-
return LogLevel.INFO;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Convert the log level to a log level label
|
|
34
|
-
*
|
|
35
|
-
* @param logLevel - The log level to convert
|
|
36
|
-
* @returns The log level label
|
|
37
|
-
*/
|
|
38
|
-
export const getLogLevelLabel = (logLevel: number): LogLevelLabel => {
|
|
39
|
-
if (logLevel >= LogLevel.ALL) {
|
|
40
|
-
return LogLevelLabel.ALL;
|
|
41
|
-
}
|
|
42
|
-
if (logLevel >= LogLevel.TRACE) {
|
|
43
|
-
return LogLevelLabel.TRACE;
|
|
44
|
-
}
|
|
45
|
-
if (logLevel >= LogLevel.DEBUG) {
|
|
46
|
-
return LogLevelLabel.DEBUG;
|
|
47
|
-
}
|
|
48
|
-
if (logLevel >= LogLevel.INFO) {
|
|
49
|
-
return LogLevelLabel.INFO;
|
|
50
|
-
}
|
|
51
|
-
if (logLevel >= LogLevel.WARN) {
|
|
52
|
-
return LogLevelLabel.WARN;
|
|
53
|
-
}
|
|
54
|
-
if (logLevel >= LogLevel.ERROR) {
|
|
55
|
-
return LogLevelLabel.ERROR;
|
|
56
|
-
}
|
|
57
|
-
if (logLevel >= LogLevel.FATAL) {
|
|
58
|
-
return LogLevelLabel.FATAL;
|
|
59
|
-
}
|
|
60
|
-
if (logLevel <= LogLevel.SILENT) {
|
|
61
|
-
return LogLevelLabel.SILENT;
|
|
62
|
-
}
|
|
63
|
-
return LogLevelLabel.INFO;
|
|
64
|
-
};
|