@storm-software/config-tools 1.37.0 → 1.38.1
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 +30 -24
- package/LICENSE +201 -0
- package/README.md +43 -7
- package/declarations.d.ts +26 -23
- package/index.cjs +72683 -0
- package/index.js +72641 -0
- package/meta.cjs.json +1 -0
- package/meta.esm.json +1 -0
- package/package.json +3 -2
- package/utilities/chalk.cjs +1610 -0
- package/utilities/chalk.js +1606 -0
- package/utilities/find-workspace-root.cjs +111 -0
- package/utilities/find-workspace-root.js +84 -0
- package/utilities/logger.cjs +1785 -0
- package/utilities/logger.js +1770 -0
- package/.eslintrc.json +0 -37
- package/jest.config.ts +0 -3
- package/project.json +0 -67
- package/src/config-file/get-config-file.ts +0 -69
- package/src/config-file/index.ts +0 -1
- package/src/create-storm-config.ts +0 -134
- package/src/env/get-env.ts +0 -141
- package/src/env/index.ts +0 -2
- package/src/env/set-env.ts +0 -207
- package/src/index.ts +0 -14
- package/src/types.ts +0 -45
- package/src/utilities/apply-workspace-tokens.ts +0 -83
- package/src/utilities/chalk.ts +0 -53
- package/src/utilities/correct-paths.ts +0 -12
- package/src/utilities/file-path-utils.ts +0 -26
- package/src/utilities/find-up.ts +0 -21
- package/src/utilities/find-workspace-root.ts +0 -68
- package/src/utilities/get-default-config.ts +0 -106
- package/src/utilities/get-log-level.ts +0 -64
- package/src/utilities/index.ts +0 -10
- package/src/utilities/logger.ts +0 -239
- package/src/utilities/process-handler.ts +0 -44
- package/src/utilities/run.ts +0 -37
- package/tsconfig.json +0 -15
- package/tsconfig.spec.json +0 -16
package/src/utilities/logger.ts
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { LogLevel, LogLevelLabel } from "../types";
|
|
2
|
-
import type { StormConfig } from "@storm-software/config";
|
|
3
|
-
import { getLogLevel } from "./get-log-level";
|
|
4
|
-
import { getChalk } from "./chalk";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get the log function for a log level
|
|
8
|
-
*
|
|
9
|
-
* @param config - The Storm configuration
|
|
10
|
-
* @param logLevel - The log level
|
|
11
|
-
* @returns The log function
|
|
12
|
-
*/
|
|
13
|
-
export const getLogFn = (
|
|
14
|
-
config: Partial<StormConfig> = {},
|
|
15
|
-
logLevel: number | LogLevel = LogLevel.INFO
|
|
16
|
-
): ((message?: string) => void) => {
|
|
17
|
-
let _chalk = getChalk();
|
|
18
|
-
|
|
19
|
-
const configLogLevel = (config.logLevel ??
|
|
20
|
-
process.env?.STORM_LOG_LEVEL ??
|
|
21
|
-
LogLevelLabel.INFO) as LogLevelLabel;
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
(typeof logLevel === "number" &&
|
|
25
|
-
(logLevel >= getLogLevel(configLogLevel) ||
|
|
26
|
-
logLevel <= LogLevel.SILENT)) ||
|
|
27
|
-
(typeof logLevel === "string" &&
|
|
28
|
-
getLogLevel(logLevel) >= getLogLevel(configLogLevel))
|
|
29
|
-
) {
|
|
30
|
-
return (_: string) => {
|
|
31
|
-
/* noop */
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
(typeof logLevel === "number" && LogLevel.FATAL >= logLevel) ||
|
|
37
|
-
(typeof logLevel === "string" && LogLevel.FATAL >= getLogLevel(logLevel))
|
|
38
|
-
) {
|
|
39
|
-
return (message?: string) => {
|
|
40
|
-
console.error(
|
|
41
|
-
`
|
|
42
|
-
${_chalk.bold.hex(config?.colors?.error ? config.colors.error : "#7d1a1a")(">")} ${_chalk.bold
|
|
43
|
-
.bgHex(config?.colors?.fatal ? config.colors.fatal : "#7d1a1a")
|
|
44
|
-
.whiteBright(" 💀 Fatal ")} ${_chalk.hex(
|
|
45
|
-
config?.colors?.error ? config.colors.error : "#1fb2a6"
|
|
46
|
-
)(message)}
|
|
47
|
-
|
|
48
|
-
`
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
(typeof logLevel === "number" && LogLevel.ERROR >= logLevel) ||
|
|
55
|
-
(typeof logLevel === "string" && LogLevel.ERROR >= getLogLevel(logLevel))
|
|
56
|
-
) {
|
|
57
|
-
return (message?: string) => {
|
|
58
|
-
console.error(
|
|
59
|
-
`
|
|
60
|
-
${_chalk.bold.hex(config?.colors?.error ? config.colors.error : "#7d1a1a")(">")} ${_chalk.bold
|
|
61
|
-
.bgHex(config?.colors?.error ? config.colors.error : "#7d1a1a")
|
|
62
|
-
.whiteBright(" ✘ Error ")} ${_chalk.hex(
|
|
63
|
-
config?.colors?.error ? config.colors.error : "#7d1a1a"
|
|
64
|
-
)(message)}
|
|
65
|
-
`
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
(typeof logLevel === "number" && LogLevel.WARN >= logLevel) ||
|
|
72
|
-
(typeof logLevel === "string" && LogLevel.WARN >= getLogLevel(logLevel))
|
|
73
|
-
) {
|
|
74
|
-
return (message?: string) => {
|
|
75
|
-
console.warn(
|
|
76
|
-
`
|
|
77
|
-
${_chalk.bold.hex(config?.colors?.warning ? config.colors.warning : "#fcc419")("> ")} ${_chalk.bold
|
|
78
|
-
.bgHex(config?.colors?.warning ? config.colors.warning : "#fcc419")
|
|
79
|
-
.whiteBright(" ⚠ Warn ")} ${_chalk.hex(
|
|
80
|
-
config?.colors?.warning ? config.colors.warning : "#fcc419"
|
|
81
|
-
)(message)}
|
|
82
|
-
`
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
(typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) ||
|
|
89
|
-
(typeof logLevel === "string" && LogLevel.SUCCESS >= getLogLevel(logLevel))
|
|
90
|
-
) {
|
|
91
|
-
return (message?: string) => {
|
|
92
|
-
console.info(
|
|
93
|
-
`
|
|
94
|
-
${_chalk.bold.hex(config?.colors?.success ? config.colors.success : "#087f5b")(">")} ${_chalk.bold
|
|
95
|
-
.bgHex(config?.colors?.success ? config.colors.success : "#087f5b")
|
|
96
|
-
.whiteBright(" ✓ Success ")} ${_chalk.hex(
|
|
97
|
-
config?.colors?.success ? config.colors.success : "#087f5b"
|
|
98
|
-
)(message)}
|
|
99
|
-
`
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
(typeof logLevel === "number" && LogLevel.INFO >= logLevel) ||
|
|
106
|
-
(typeof logLevel === "string" && LogLevel.INFO >= getLogLevel(logLevel))
|
|
107
|
-
) {
|
|
108
|
-
return (message?: string) => {
|
|
109
|
-
console.info(
|
|
110
|
-
`
|
|
111
|
-
${_chalk.bold.hex(config?.colors?.info ? config.colors.info : "#0ea5e9")(">")} ${_chalk.bold
|
|
112
|
-
.bgHex(config?.colors?.info ? config.colors.info : "#0ea5e9")
|
|
113
|
-
.whiteBright(" ℹ Info ")} ${_chalk.hex(
|
|
114
|
-
config?.colors?.info ? config.colors.info : "#0ea5e9"
|
|
115
|
-
)(message)}
|
|
116
|
-
`
|
|
117
|
-
);
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
(typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) ||
|
|
123
|
-
(typeof logLevel === "string" && LogLevel.DEBUG >= getLogLevel(logLevel))
|
|
124
|
-
) {
|
|
125
|
-
return (message?: string) => {
|
|
126
|
-
console.debug(
|
|
127
|
-
`
|
|
128
|
-
${_chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">")} ${_chalk.bold
|
|
129
|
-
.bgHex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")
|
|
130
|
-
.whiteBright(" 🛠 Debug ")} ${_chalk.hex(
|
|
131
|
-
config?.colors?.primary ? config.colors.primary : "#1fb2a6"
|
|
132
|
-
)(message)}
|
|
133
|
-
`
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return (message?: string) => {
|
|
139
|
-
console.log(
|
|
140
|
-
`
|
|
141
|
-
${_chalk.bold.hex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")(">")} ${_chalk.bold
|
|
142
|
-
.bgHex(config?.colors?.primary ? config.colors.primary : "#1fb2a6")
|
|
143
|
-
.whiteBright(" ✉ System ")} ${_chalk.hex(
|
|
144
|
-
config?.colors?.primary ? config.colors.primary : "#1fb2a6"
|
|
145
|
-
)(message)}
|
|
146
|
-
`
|
|
147
|
-
);
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Write a message to the console at the `fatal` log level
|
|
153
|
-
*
|
|
154
|
-
* @param config - The Storm configuration
|
|
155
|
-
* @param message - The message to write
|
|
156
|
-
*/
|
|
157
|
-
export const writeFatal = (config?: Partial<StormConfig>, message?: string) =>
|
|
158
|
-
getLogFn(config, LogLevel.FATAL)(message);
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Write a message to the console at the `error` log level
|
|
162
|
-
*
|
|
163
|
-
* @param config - The Storm configuration
|
|
164
|
-
* @param message - The message to write
|
|
165
|
-
*/
|
|
166
|
-
export const writeError = (config?: Partial<StormConfig>, message?: string) =>
|
|
167
|
-
getLogFn(config, LogLevel.ERROR)(message);
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Write a message to the console at the `warning` log level
|
|
171
|
-
*
|
|
172
|
-
* @param config - The Storm configuration
|
|
173
|
-
* @param message - The message to write
|
|
174
|
-
*/
|
|
175
|
-
export const writeWarning = (config?: Partial<StormConfig>, message?: string) =>
|
|
176
|
-
getLogFn(config, LogLevel.WARN)(message);
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Write a message to the console at the `info` log level
|
|
180
|
-
*
|
|
181
|
-
* @param config - The Storm configuration
|
|
182
|
-
* @param message - The message to write
|
|
183
|
-
*/
|
|
184
|
-
export const writeInfo = (config?: Partial<StormConfig>, message?: string) =>
|
|
185
|
-
getLogFn(config, LogLevel.INFO)(message);
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Write a message to the console at the `success` log level
|
|
189
|
-
*
|
|
190
|
-
* @param config - The Storm configuration
|
|
191
|
-
* @param message - The message to write
|
|
192
|
-
*/
|
|
193
|
-
export const writeSuccess = (config?: Partial<StormConfig>, message?: string) =>
|
|
194
|
-
getLogFn(config, LogLevel.SUCCESS)(message);
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Write a message to the console at the `debug` log level
|
|
198
|
-
*
|
|
199
|
-
* @param config - The Storm configuration
|
|
200
|
-
* @param message - The message to write
|
|
201
|
-
*/
|
|
202
|
-
export const writeDebug = (config?: Partial<StormConfig>, message?: string) =>
|
|
203
|
-
getLogFn(config, LogLevel.DEBUG)(message);
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Write a message to the console at the `trace` log level
|
|
207
|
-
*
|
|
208
|
-
* @param config - The Storm configuration
|
|
209
|
-
* @param message - The message to write
|
|
210
|
-
*/
|
|
211
|
-
export const writeTrace = (config?: Partial<StormConfig>, message?: string) =>
|
|
212
|
-
getLogFn(config, LogLevel.TRACE)(message);
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Write a message to the console at the `all` log level
|
|
216
|
-
*
|
|
217
|
-
* @param config - The Storm configuration
|
|
218
|
-
* @param message - The message to write
|
|
219
|
-
*/
|
|
220
|
-
export const writeSystem = (config?: Partial<StormConfig>, message?: string) =>
|
|
221
|
-
getLogFn(config, LogLevel.ALL)(message);
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Get a stopwatch function
|
|
225
|
-
*
|
|
226
|
-
* @param name - The name of the process
|
|
227
|
-
* @returns The stopwatch function
|
|
228
|
-
*/
|
|
229
|
-
export const getStopwatch = (name: string) => {
|
|
230
|
-
const start = process.hrtime();
|
|
231
|
-
return () => {
|
|
232
|
-
const end = process.hrtime(start);
|
|
233
|
-
console.info(
|
|
234
|
-
`\n> ⏱️ The${name ? ` ${name}` : ""} process took ${Math.round(
|
|
235
|
-
end[0] * 1000 + end[1] / 1000000
|
|
236
|
-
)}ms to complete\n\n`
|
|
237
|
-
);
|
|
238
|
-
};
|
|
239
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { StormConfig } from "@storm-software/config";
|
|
2
|
-
import { writeError, writeFatal, writeSuccess, writeTrace } from "./logger";
|
|
3
|
-
|
|
4
|
-
export const exitWithError = (config: Partial<StormConfig>) => {
|
|
5
|
-
writeFatal(config, "Exiting script with an error status...");
|
|
6
|
-
process.exit(1);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const exitWithSuccess = (config: Partial<StormConfig>) => {
|
|
10
|
-
writeSuccess(config, "Script completed successfully. Exiting...");
|
|
11
|
-
process.exit(0);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const handleProcess = (config: Partial<StormConfig>) => {
|
|
15
|
-
writeTrace(
|
|
16
|
-
config,
|
|
17
|
-
`Using the following arguments to process the script: ${process.argv.join(", ")}`
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
process.on("unhandledRejection", (error) => {
|
|
21
|
-
writeError(config, `An Unhandled Rejection occurred while running the program: ${error}`);
|
|
22
|
-
exitWithError(config);
|
|
23
|
-
});
|
|
24
|
-
process.on("uncaughtException", (error) => {
|
|
25
|
-
writeError(
|
|
26
|
-
config,
|
|
27
|
-
`An Uncaught Exception occurred while running the program: ${error.message} \nStacktrace: ${error.stack}`
|
|
28
|
-
);
|
|
29
|
-
exitWithError(config);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
process.on("SIGTERM", (signal: NodeJS.Signals) => {
|
|
33
|
-
writeError(config, `The program terminated with signal code: ${signal}`);
|
|
34
|
-
exitWithError(config);
|
|
35
|
-
});
|
|
36
|
-
process.on("SIGINT", (signal: NodeJS.Signals) => {
|
|
37
|
-
writeError(config, `The program terminated with signal code: ${signal}`);
|
|
38
|
-
exitWithError(config);
|
|
39
|
-
});
|
|
40
|
-
process.on("SIGHUP", (signal: NodeJS.Signals) => {
|
|
41
|
-
writeError(config, `The program terminated with signal code: ${signal}`);
|
|
42
|
-
exitWithError(config);
|
|
43
|
-
});
|
|
44
|
-
};
|
package/src/utilities/run.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { StormConfig } from "@storm-software/config";
|
|
2
|
-
import { execSync } from "node:child_process";
|
|
3
|
-
|
|
4
|
-
export const LARGE_BUFFER = 1024 * 1000000;
|
|
5
|
-
export type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
|
|
6
|
-
export type StdioOptions =
|
|
7
|
-
| IOType
|
|
8
|
-
| Array<IOType | "ipc" | number | null | undefined>;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Run a command line process
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* A wrapper around execSync to run our command line processes
|
|
15
|
-
*
|
|
16
|
-
* @param config - The Storm configuration object
|
|
17
|
-
* @param command - The command to run
|
|
18
|
-
* @param cwd - The current working directory
|
|
19
|
-
* @returns The result of the command
|
|
20
|
-
*/
|
|
21
|
-
export const run = (
|
|
22
|
-
config: StormConfig,
|
|
23
|
-
command: string,
|
|
24
|
-
cwd: string = config.workspaceRoot ?? process.cwd(),
|
|
25
|
-
stdio: StdioOptions = "inherit"
|
|
26
|
-
) => {
|
|
27
|
-
return execSync(command, {
|
|
28
|
-
cwd,
|
|
29
|
-
env: {
|
|
30
|
-
...process.env,
|
|
31
|
-
FORCE_COLOR: "true"
|
|
32
|
-
},
|
|
33
|
-
stdio,
|
|
34
|
-
maxBuffer: LARGE_BUFFER,
|
|
35
|
-
killSignal: "SIGTERM"
|
|
36
|
-
});
|
|
37
|
-
};
|
package/tsconfig.json
DELETED
package/tsconfig.spec.json
DELETED