@storm-software/config-tools 1.169.3 → 1.169.5
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/README.md +1 -1
- package/dist/chunk-3HILQOD7.js +40 -0
- package/dist/chunk-3TLEBPG2.cjs +55 -0
- package/dist/chunk-4DF7JJF3.js +92 -0
- package/dist/chunk-7BYG54D7.cjs +40 -0
- package/dist/chunk-BISNOW2V.cjs +47 -0
- package/dist/chunk-BYLFGW3E.cjs +40 -0
- package/dist/chunk-DBNZROVM.js +40 -0
- package/dist/chunk-FE4JVWUW.js +135 -0
- package/dist/chunk-G6IQUR2B.js +47 -0
- package/dist/chunk-GK6OSUUD.js +135 -0
- package/dist/chunk-GMHWE7ZI.js +55 -0
- package/dist/chunk-JYKZS46U.cjs +158 -0
- package/dist/chunk-PKYL423F.cjs +135 -0
- package/dist/chunk-Q6MCB3G2.cjs +92 -0
- package/dist/chunk-QPYH54PX.cjs +135 -0
- package/dist/chunk-SA3JCBON.js +158 -0
- package/dist/chunk-VTGRS36E.cjs +40 -0
- package/dist/chunk-YGCYQLTS.js +40 -0
- package/dist/config-file/get-config-file.cjs +8 -8
- package/dist/config-file/get-config-file.js +7 -7
- package/dist/config-file/index.cjs +8 -8
- package/dist/config-file/index.js +7 -7
- package/dist/create-storm-config.cjs +10 -10
- package/dist/create-storm-config.js +9 -9
- package/dist/env/index.cjs +2 -2
- package/dist/env/index.js +4 -4
- package/dist/get-config.cjs +11 -11
- package/dist/get-config.js +10 -10
- package/dist/index.cjs +17 -17
- package/dist/index.js +18 -18
- package/dist/logger/console.cjs +4 -4
- package/dist/logger/console.js +3 -3
- package/dist/logger/create-logger.cjs +5 -5
- package/dist/logger/create-logger.js +4 -4
- package/dist/logger/index.cjs +8 -8
- package/dist/logger/index.js +8 -8
- package/dist/utilities/index.cjs +7 -7
- package/dist/utilities/index.js +6 -6
- package/dist/utilities/process-handler.cjs +5 -5
- package/dist/utilities/process-handler.js +4 -4
- package/dist/utilities/toml.cjs +6 -6
- package/dist/utilities/toml.js +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadStormWorkspaceConfig,
|
|
3
|
+
tryLoadStormWorkspaceConfig
|
|
4
|
+
} from "./chunk-FE4JVWUW.js";
|
|
5
|
+
import {
|
|
6
|
+
findWorkspaceRoot
|
|
7
|
+
} from "./chunk-VLWSWYG7.js";
|
|
8
|
+
|
|
9
|
+
// src/get-config.ts
|
|
10
|
+
var getConfig = (workspaceRoot, skipLogs = false) => {
|
|
11
|
+
return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
|
|
12
|
+
};
|
|
13
|
+
var getWorkspaceConfig = (skipLogs = false, options = {}) => {
|
|
14
|
+
let workspaceRoot = options.workspaceRoot;
|
|
15
|
+
if (!workspaceRoot) {
|
|
16
|
+
workspaceRoot = findWorkspaceRoot(options.cwd);
|
|
17
|
+
}
|
|
18
|
+
return getConfig(workspaceRoot, skipLogs);
|
|
19
|
+
};
|
|
20
|
+
var tryGetWorkspaceConfig = async (skipLogs = false, options = {}) => {
|
|
21
|
+
try {
|
|
22
|
+
let workspaceRoot = options.workspaceRoot;
|
|
23
|
+
if (!workspaceRoot) {
|
|
24
|
+
workspaceRoot = findWorkspaceRoot(options.cwd);
|
|
25
|
+
}
|
|
26
|
+
return tryLoadStormWorkspaceConfig(
|
|
27
|
+
workspaceRoot,
|
|
28
|
+
skipLogs,
|
|
29
|
+
options.useDefault
|
|
30
|
+
);
|
|
31
|
+
} catch {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
getConfig,
|
|
38
|
+
getWorkspaceConfig,
|
|
39
|
+
tryGetWorkspaceConfig
|
|
40
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkJYKZS46Ucjs = require('./chunk-JYKZS46U.cjs');
|
|
7
|
+
|
|
8
|
+
// src/utilities/process-handler.ts
|
|
9
|
+
var exitWithError = (config) => {
|
|
10
|
+
_chunkJYKZS46Ucjs.writeFatal.call(void 0, "Exiting script with an error status...", config);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
};
|
|
13
|
+
var exitWithSuccess = (config) => {
|
|
14
|
+
_chunkJYKZS46Ucjs.writeSuccess.call(void 0, "Script completed successfully. Exiting...", config);
|
|
15
|
+
process.exit(0);
|
|
16
|
+
};
|
|
17
|
+
var handleProcess = (config) => {
|
|
18
|
+
_chunkJYKZS46Ucjs.writeTrace.call(void 0,
|
|
19
|
+
`Using the following arguments to process the script: ${process.argv.join(", ")}`,
|
|
20
|
+
config
|
|
21
|
+
);
|
|
22
|
+
process.on("unhandledRejection", (error) => {
|
|
23
|
+
_chunkJYKZS46Ucjs.writeError.call(void 0,
|
|
24
|
+
`An Unhandled Rejection occurred while running the program: ${error}`,
|
|
25
|
+
config
|
|
26
|
+
);
|
|
27
|
+
exitWithError(config);
|
|
28
|
+
});
|
|
29
|
+
process.on("uncaughtException", (error) => {
|
|
30
|
+
_chunkJYKZS46Ucjs.writeError.call(void 0,
|
|
31
|
+
`An Uncaught Exception occurred while running the program: ${error.message}
|
|
32
|
+
Stacktrace: ${error.stack}`,
|
|
33
|
+
config
|
|
34
|
+
);
|
|
35
|
+
exitWithError(config);
|
|
36
|
+
});
|
|
37
|
+
process.on("SIGTERM", (signal) => {
|
|
38
|
+
_chunkJYKZS46Ucjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
|
|
39
|
+
exitWithError(config);
|
|
40
|
+
});
|
|
41
|
+
process.on("SIGINT", (signal) => {
|
|
42
|
+
_chunkJYKZS46Ucjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
|
|
43
|
+
exitWithError(config);
|
|
44
|
+
});
|
|
45
|
+
process.on("SIGHUP", (signal) => {
|
|
46
|
+
_chunkJYKZS46Ucjs.writeError.call(void 0, `The program terminated with signal code: ${signal}`, config);
|
|
47
|
+
exitWithError(config);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
exports.exitWithError = exitWithError; exports.exitWithSuccess = exitWithSuccess; exports.handleProcess = handleProcess;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeTrace
|
|
3
|
+
} from "./chunk-SA3JCBON.js";
|
|
4
|
+
import {
|
|
5
|
+
findWorkspaceRoot
|
|
6
|
+
} from "./chunk-VLWSWYG7.js";
|
|
7
|
+
import {
|
|
8
|
+
joinPaths
|
|
9
|
+
} from "./chunk-FRR2ZRWD.js";
|
|
10
|
+
|
|
11
|
+
// src/config-file/get-config-file.ts
|
|
12
|
+
import { loadConfig } from "c12";
|
|
13
|
+
import defu from "defu";
|
|
14
|
+
var getConfigFileByName = async (fileName, filePath, options = {}) => {
|
|
15
|
+
const workspacePath = filePath || findWorkspaceRoot(filePath);
|
|
16
|
+
const configs = await Promise.all([
|
|
17
|
+
loadConfig({
|
|
18
|
+
cwd: workspacePath,
|
|
19
|
+
packageJson: true,
|
|
20
|
+
name: fileName,
|
|
21
|
+
envName: fileName?.toUpperCase(),
|
|
22
|
+
jitiOptions: {
|
|
23
|
+
debug: false,
|
|
24
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
25
|
+
process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
|
|
26
|
+
"jiti"
|
|
27
|
+
)
|
|
28
|
+
},
|
|
29
|
+
...options
|
|
30
|
+
}),
|
|
31
|
+
loadConfig({
|
|
32
|
+
cwd: workspacePath,
|
|
33
|
+
packageJson: true,
|
|
34
|
+
name: fileName,
|
|
35
|
+
envName: fileName?.toUpperCase(),
|
|
36
|
+
jitiOptions: {
|
|
37
|
+
debug: false,
|
|
38
|
+
fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : joinPaths(
|
|
39
|
+
process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
|
|
40
|
+
"jiti"
|
|
41
|
+
)
|
|
42
|
+
},
|
|
43
|
+
configFile: fileName,
|
|
44
|
+
...options
|
|
45
|
+
})
|
|
46
|
+
]);
|
|
47
|
+
return defu(configs[0] ?? {}, configs[1] ?? {});
|
|
48
|
+
};
|
|
49
|
+
var getConfigFile = async (filePath, additionalFileNames = []) => {
|
|
50
|
+
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
51
|
+
const result = await getConfigFileByName("storm-workspace", workspacePath);
|
|
52
|
+
let config = result.config;
|
|
53
|
+
const configFile = result.configFile;
|
|
54
|
+
if (config && configFile && Object.keys(config).length > 0 && !config.skipConfigLogging) {
|
|
55
|
+
writeTrace(
|
|
56
|
+
`Found Storm configuration file "${configFile.includes(`${workspacePath}/`) ? configFile.replace(`${workspacePath}/`, "") : configFile}" at "${workspacePath}"`,
|
|
57
|
+
{
|
|
58
|
+
logLevel: "all"
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
if (additionalFileNames && additionalFileNames.length > 0) {
|
|
63
|
+
const results = await Promise.all(
|
|
64
|
+
additionalFileNames.map(
|
|
65
|
+
(fileName) => getConfigFileByName(fileName, workspacePath)
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
for (const result2 of results) {
|
|
69
|
+
if (result2?.config && result2?.configFile && Object.keys(result2.config).length > 0) {
|
|
70
|
+
if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
|
|
71
|
+
writeTrace(
|
|
72
|
+
`Found alternative configuration file "${result2.configFile.includes(`${workspacePath}/`) ? result2.configFile.replace(`${workspacePath}/`, "") : result2.configFile}" at "${workspacePath}"`,
|
|
73
|
+
{
|
|
74
|
+
logLevel: "all"
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
config = defu(result2.config ?? {}, config ?? {});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!config || Object.keys(config).length === 0) {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
config.configFile = configFile;
|
|
86
|
+
return config;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
getConfigFileByName,
|
|
91
|
+
getConfigFile
|
|
92
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkPKYL423Fcjs = require('./chunk-PKYL423F.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkAEZINHEAcjs = require('./chunk-AEZINHEA.cjs');
|
|
8
|
+
|
|
9
|
+
// src/get-config.ts
|
|
10
|
+
var getConfig = (workspaceRoot, skipLogs = false) => {
|
|
11
|
+
return _chunkPKYL423Fcjs.loadStormWorkspaceConfig.call(void 0, workspaceRoot, skipLogs);
|
|
12
|
+
};
|
|
13
|
+
var getWorkspaceConfig = (skipLogs = false, options = {}) => {
|
|
14
|
+
let workspaceRoot = options.workspaceRoot;
|
|
15
|
+
if (!workspaceRoot) {
|
|
16
|
+
workspaceRoot = _chunkAEZINHEAcjs.findWorkspaceRoot.call(void 0, options.cwd);
|
|
17
|
+
}
|
|
18
|
+
return getConfig(workspaceRoot, skipLogs);
|
|
19
|
+
};
|
|
20
|
+
var tryGetWorkspaceConfig = async (skipLogs = false, options = {}) => {
|
|
21
|
+
try {
|
|
22
|
+
let workspaceRoot = options.workspaceRoot;
|
|
23
|
+
if (!workspaceRoot) {
|
|
24
|
+
workspaceRoot = _chunkAEZINHEAcjs.findWorkspaceRoot.call(void 0, options.cwd);
|
|
25
|
+
}
|
|
26
|
+
return _chunkPKYL423Fcjs.tryLoadStormWorkspaceConfig.call(void 0,
|
|
27
|
+
workspaceRoot,
|
|
28
|
+
skipLogs,
|
|
29
|
+
options.useDefault
|
|
30
|
+
);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.getConfig = getConfig; exports.getWorkspaceConfig = getWorkspaceConfig; exports.tryGetWorkspaceConfig = tryGetWorkspaceConfig;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkJYKZS46Ucjs = require('./chunk-JYKZS46U.cjs');
|
|
4
|
+
|
|
5
|
+
// src/utilities/toml.ts
|
|
6
|
+
var _jtoml = require('@ltd/j-toml'); var _jtoml2 = _interopRequireDefault(_jtoml);
|
|
7
|
+
function parseCargoTomlWithTree(tree, projectRoot, projectName) {
|
|
8
|
+
const cargoTomlString = _optionalChain([tree, 'access', _ => _.read, 'call', _2 => _2(`${projectRoot}/Cargo.toml`), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
9
|
+
if (!cargoTomlString) {
|
|
10
|
+
_chunkJYKZS46Ucjs.writeError.call(void 0, `Cannot find a Cargo.toml file in the ${projectName}`);
|
|
11
|
+
throw new Error();
|
|
12
|
+
}
|
|
13
|
+
return parseCargoToml(cargoTomlString);
|
|
14
|
+
}
|
|
15
|
+
function parseCargoToml(cargoString) {
|
|
16
|
+
if (!cargoString) {
|
|
17
|
+
throw new Error("Cargo.toml is empty");
|
|
18
|
+
}
|
|
19
|
+
return _jtoml2.default.parse(cargoString, {
|
|
20
|
+
x: { comment: true }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function stringifyCargoToml(cargoToml) {
|
|
24
|
+
const tomlString = _jtoml2.default.stringify(cargoToml, {
|
|
25
|
+
newlineAround: "section"
|
|
26
|
+
});
|
|
27
|
+
if (Array.isArray(tomlString)) {
|
|
28
|
+
return tomlString.join("\n");
|
|
29
|
+
}
|
|
30
|
+
return tomlString;
|
|
31
|
+
}
|
|
32
|
+
function modifyCargoTable(toml, section, key, value) {
|
|
33
|
+
toml[section] ??= _jtoml2.default.Section({});
|
|
34
|
+
toml[section][key] = typeof value === "object" && !Array.isArray(value) ? _jtoml2.default.inline(value) : typeof value === "function" ? value() : value;
|
|
35
|
+
}
|
|
36
|
+
function modifyCargoNestedTable(toml, section, key, value) {
|
|
37
|
+
toml[section] ??= {};
|
|
38
|
+
toml[section][key] = _jtoml2.default.Section(value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
exports.parseCargoTomlWithTree = parseCargoTomlWithTree; exports.parseCargoToml = parseCargoToml; exports.stringifyCargoToml = stringifyCargoToml; exports.modifyCargoTable = modifyCargoTable; exports.modifyCargoNestedTable = modifyCargoNestedTable;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkJYKZS46Ucjs = require('./chunk-JYKZS46U.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkAEZINHEAcjs = require('./chunk-AEZINHEA.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkC5OTFOQBcjs = require('./chunk-C5OTFOQB.cjs');
|
|
11
|
+
|
|
12
|
+
// src/logger/create-logger.ts
|
|
13
|
+
var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
|
|
14
|
+
async function createLogger(config) {
|
|
15
|
+
const workspaceRoot = _chunkAEZINHEAcjs.findWorkspaceRoot.call(void 0, );
|
|
16
|
+
if (!workspaceRoot) {
|
|
17
|
+
throw new Error("Cannot find workspace root");
|
|
18
|
+
}
|
|
19
|
+
const writeFatal = _chunkJYKZS46Ucjs.getLogFn.call(void 0, _chunkC5OTFOQBcjs.LogLevel.FATAL, config, _chalk2.default);
|
|
20
|
+
const writeError = _chunkJYKZS46Ucjs.getLogFn.call(void 0, _chunkC5OTFOQBcjs.LogLevel.ERROR, config, _chalk2.default);
|
|
21
|
+
const writeWarning = _chunkJYKZS46Ucjs.getLogFn.call(void 0, _chunkC5OTFOQBcjs.LogLevel.WARN, config, _chalk2.default);
|
|
22
|
+
const writeInfo = _chunkJYKZS46Ucjs.getLogFn.call(void 0, _chunkC5OTFOQBcjs.LogLevel.INFO, config, _chalk2.default);
|
|
23
|
+
const writeSuccess = _chunkJYKZS46Ucjs.getLogFn.call(void 0, _chunkC5OTFOQBcjs.LogLevel.SUCCESS, config, _chalk2.default);
|
|
24
|
+
const writeDebug = _chunkJYKZS46Ucjs.getLogFn.call(void 0, _chunkC5OTFOQBcjs.LogLevel.DEBUG, config, _chalk2.default);
|
|
25
|
+
const writeTrace = _chunkJYKZS46Ucjs.getLogFn.call(void 0, _chunkC5OTFOQBcjs.LogLevel.DEBUG, config, _chalk2.default);
|
|
26
|
+
return {
|
|
27
|
+
fatal: writeFatal,
|
|
28
|
+
error: writeError,
|
|
29
|
+
warning: writeWarning,
|
|
30
|
+
info: writeInfo,
|
|
31
|
+
success: writeSuccess,
|
|
32
|
+
debug: writeDebug,
|
|
33
|
+
trace: writeTrace,
|
|
34
|
+
getStopwatch: _chunkJYKZS46Ucjs.getStopwatch
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
exports.createLogger = createLogger;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadStormWorkspaceConfig,
|
|
3
|
+
tryLoadStormWorkspaceConfig
|
|
4
|
+
} from "./chunk-GK6OSUUD.js";
|
|
5
|
+
import {
|
|
6
|
+
findWorkspaceRoot
|
|
7
|
+
} from "./chunk-VLWSWYG7.js";
|
|
8
|
+
|
|
9
|
+
// src/get-config.ts
|
|
10
|
+
var getConfig = (workspaceRoot, skipLogs = false) => {
|
|
11
|
+
return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
|
|
12
|
+
};
|
|
13
|
+
var getWorkspaceConfig = (skipLogs = false, options = {}) => {
|
|
14
|
+
let workspaceRoot = options.workspaceRoot;
|
|
15
|
+
if (!workspaceRoot) {
|
|
16
|
+
workspaceRoot = findWorkspaceRoot(options.cwd);
|
|
17
|
+
}
|
|
18
|
+
return getConfig(workspaceRoot, skipLogs);
|
|
19
|
+
};
|
|
20
|
+
var tryGetWorkspaceConfig = async (skipLogs = false, options = {}) => {
|
|
21
|
+
try {
|
|
22
|
+
let workspaceRoot = options.workspaceRoot;
|
|
23
|
+
if (!workspaceRoot) {
|
|
24
|
+
workspaceRoot = findWorkspaceRoot(options.cwd);
|
|
25
|
+
}
|
|
26
|
+
return tryLoadStormWorkspaceConfig(
|
|
27
|
+
workspaceRoot,
|
|
28
|
+
skipLogs,
|
|
29
|
+
options.useDefault
|
|
30
|
+
);
|
|
31
|
+
} catch {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
getConfig,
|
|
38
|
+
getWorkspaceConfig,
|
|
39
|
+
tryGetWorkspaceConfig
|
|
40
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfigFile
|
|
3
|
+
} from "./chunk-4DF7JJF3.js";
|
|
4
|
+
import {
|
|
5
|
+
formatLogMessage,
|
|
6
|
+
writeTrace,
|
|
7
|
+
writeWarning
|
|
8
|
+
} from "./chunk-SA3JCBON.js";
|
|
9
|
+
import {
|
|
10
|
+
getDefaultConfig
|
|
11
|
+
} from "./chunk-JX5NLB4S.js";
|
|
12
|
+
import {
|
|
13
|
+
findWorkspaceRoot
|
|
14
|
+
} from "./chunk-VLWSWYG7.js";
|
|
15
|
+
import {
|
|
16
|
+
getConfigEnv,
|
|
17
|
+
getExtensionEnv
|
|
18
|
+
} from "./chunk-RSKVXFI5.js";
|
|
19
|
+
import {
|
|
20
|
+
setConfigEnv
|
|
21
|
+
} from "./chunk-XS7LVKAI.js";
|
|
22
|
+
|
|
23
|
+
// src/create-storm-config.ts
|
|
24
|
+
import { stormWorkspaceConfigSchema } from "@storm-software/config/schema";
|
|
25
|
+
import defu from "defu";
|
|
26
|
+
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
27
|
+
var _static_cache = void 0;
|
|
28
|
+
var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
|
|
29
|
+
let result;
|
|
30
|
+
if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
|
|
31
|
+
let _workspaceRoot = workspaceRoot;
|
|
32
|
+
if (!_workspaceRoot) {
|
|
33
|
+
_workspaceRoot = findWorkspaceRoot();
|
|
34
|
+
}
|
|
35
|
+
const configEnv = getConfigEnv();
|
|
36
|
+
const configFile = await getConfigFile(_workspaceRoot);
|
|
37
|
+
if (!configFile) {
|
|
38
|
+
if (!skipLogs) {
|
|
39
|
+
writeWarning(
|
|
40
|
+
"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",
|
|
41
|
+
{ logLevel: "all" }
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (useDefault === false) {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const defaultConfig = await getDefaultConfig(_workspaceRoot);
|
|
49
|
+
result = await stormWorkspaceConfigSchema.parseAsync(
|
|
50
|
+
defu(configEnv, configFile, defaultConfig)
|
|
51
|
+
);
|
|
52
|
+
result.workspaceRoot ??= _workspaceRoot;
|
|
53
|
+
} else {
|
|
54
|
+
result = _static_cache.data;
|
|
55
|
+
}
|
|
56
|
+
if (schema && extensionName) {
|
|
57
|
+
result.extensions = {
|
|
58
|
+
...result.extensions,
|
|
59
|
+
[extensionName]: createConfigExtension(extensionName, schema)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
_static_cache = {
|
|
63
|
+
timestamp: Date.now(),
|
|
64
|
+
data: result
|
|
65
|
+
};
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
var createConfigExtension = (extensionName, schema) => {
|
|
69
|
+
const extension_cache_key = { extensionName };
|
|
70
|
+
if (_extension_cache.has(extension_cache_key)) {
|
|
71
|
+
return _extension_cache.get(extension_cache_key);
|
|
72
|
+
}
|
|
73
|
+
let extension = getExtensionEnv(extensionName);
|
|
74
|
+
if (schema) {
|
|
75
|
+
extension = schema.parse(extension);
|
|
76
|
+
}
|
|
77
|
+
_extension_cache.set(extension_cache_key, extension);
|
|
78
|
+
return extension;
|
|
79
|
+
};
|
|
80
|
+
var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
|
|
81
|
+
const config = await createStormWorkspaceConfig(
|
|
82
|
+
void 0,
|
|
83
|
+
void 0,
|
|
84
|
+
workspaceRoot,
|
|
85
|
+
skipLogs,
|
|
86
|
+
true
|
|
87
|
+
);
|
|
88
|
+
setConfigEnv(config);
|
|
89
|
+
if (!skipLogs && !config.skipConfigLogging) {
|
|
90
|
+
writeTrace(
|
|
91
|
+
`\u2699\uFE0F Using Storm Workspace configuration:
|
|
92
|
+
${formatLogMessage(config)}`,
|
|
93
|
+
config
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return config;
|
|
97
|
+
};
|
|
98
|
+
var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
|
|
99
|
+
try {
|
|
100
|
+
const config = await createStormWorkspaceConfig(
|
|
101
|
+
void 0,
|
|
102
|
+
void 0,
|
|
103
|
+
workspaceRoot,
|
|
104
|
+
skipLogs,
|
|
105
|
+
useDefault
|
|
106
|
+
);
|
|
107
|
+
if (!config) {
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
setConfigEnv(config);
|
|
111
|
+
if (!skipLogs && !config.skipConfigLogging) {
|
|
112
|
+
writeTrace(
|
|
113
|
+
`\u2699\uFE0F Using Storm Workspace configuration:
|
|
114
|
+
${formatLogMessage(config)}`,
|
|
115
|
+
config
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return config;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (!skipLogs) {
|
|
121
|
+
writeWarning(
|
|
122
|
+
`\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
|
|
123
|
+
{ logLevel: "all" }
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return void 0;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
createStormWorkspaceConfig,
|
|
132
|
+
createConfigExtension,
|
|
133
|
+
loadStormWorkspaceConfig,
|
|
134
|
+
tryLoadStormWorkspaceConfig
|
|
135
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeError
|
|
3
|
+
} from "./chunk-SA3JCBON.js";
|
|
4
|
+
|
|
5
|
+
// src/utilities/toml.ts
|
|
6
|
+
import TOML from "@ltd/j-toml";
|
|
7
|
+
function parseCargoTomlWithTree(tree, projectRoot, projectName) {
|
|
8
|
+
const cargoTomlString = tree.read(`${projectRoot}/Cargo.toml`)?.toString();
|
|
9
|
+
if (!cargoTomlString) {
|
|
10
|
+
writeError(`Cannot find a Cargo.toml file in the ${projectName}`);
|
|
11
|
+
throw new Error();
|
|
12
|
+
}
|
|
13
|
+
return parseCargoToml(cargoTomlString);
|
|
14
|
+
}
|
|
15
|
+
function parseCargoToml(cargoString) {
|
|
16
|
+
if (!cargoString) {
|
|
17
|
+
throw new Error("Cargo.toml is empty");
|
|
18
|
+
}
|
|
19
|
+
return TOML.parse(cargoString, {
|
|
20
|
+
x: { comment: true }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function stringifyCargoToml(cargoToml) {
|
|
24
|
+
const tomlString = TOML.stringify(cargoToml, {
|
|
25
|
+
newlineAround: "section"
|
|
26
|
+
});
|
|
27
|
+
if (Array.isArray(tomlString)) {
|
|
28
|
+
return tomlString.join("\n");
|
|
29
|
+
}
|
|
30
|
+
return tomlString;
|
|
31
|
+
}
|
|
32
|
+
function modifyCargoTable(toml, section, key, value) {
|
|
33
|
+
toml[section] ??= TOML.Section({});
|
|
34
|
+
toml[section][key] = typeof value === "object" && !Array.isArray(value) ? TOML.inline(value) : typeof value === "function" ? value() : value;
|
|
35
|
+
}
|
|
36
|
+
function modifyCargoNestedTable(toml, section, key, value) {
|
|
37
|
+
toml[section] ??= {};
|
|
38
|
+
toml[section][key] = TOML.Section(value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
parseCargoTomlWithTree,
|
|
43
|
+
parseCargoToml,
|
|
44
|
+
stringifyCargoToml,
|
|
45
|
+
modifyCargoTable,
|
|
46
|
+
modifyCargoNestedTable
|
|
47
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getConfigEnv,
|
|
3
|
+
getExtensionEnv
|
|
4
|
+
} from "./chunk-RSKVXFI5.js";
|
|
5
|
+
import {
|
|
6
|
+
setConfigEnv
|
|
7
|
+
} from "./chunk-XS7LVKAI.js";
|
|
8
|
+
import {
|
|
9
|
+
getConfigFile
|
|
10
|
+
} from "./chunk-XO6ICAFH.js";
|
|
11
|
+
import {
|
|
12
|
+
formatLogMessage,
|
|
13
|
+
writeTrace,
|
|
14
|
+
writeWarning
|
|
15
|
+
} from "./chunk-QJUAU656.js";
|
|
16
|
+
import {
|
|
17
|
+
getDefaultConfig
|
|
18
|
+
} from "./chunk-JX5NLB4S.js";
|
|
19
|
+
import {
|
|
20
|
+
findWorkspaceRoot
|
|
21
|
+
} from "./chunk-VLWSWYG7.js";
|
|
22
|
+
|
|
23
|
+
// src/create-storm-config.ts
|
|
24
|
+
import { stormWorkspaceConfigSchema } from "@storm-software/config/schema";
|
|
25
|
+
import defu from "defu";
|
|
26
|
+
var _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
27
|
+
var _static_cache = void 0;
|
|
28
|
+
var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
|
|
29
|
+
let result;
|
|
30
|
+
if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
|
|
31
|
+
let _workspaceRoot = workspaceRoot;
|
|
32
|
+
if (!_workspaceRoot) {
|
|
33
|
+
_workspaceRoot = findWorkspaceRoot();
|
|
34
|
+
}
|
|
35
|
+
const configEnv = getConfigEnv();
|
|
36
|
+
const configFile = await getConfigFile(_workspaceRoot);
|
|
37
|
+
if (!configFile) {
|
|
38
|
+
if (!skipLogs) {
|
|
39
|
+
writeWarning(
|
|
40
|
+
"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",
|
|
41
|
+
{ logLevel: "all" }
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
if (useDefault === false) {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const defaultConfig = await getDefaultConfig(_workspaceRoot);
|
|
49
|
+
result = await stormWorkspaceConfigSchema.parseAsync(
|
|
50
|
+
defu(configEnv, configFile, defaultConfig)
|
|
51
|
+
);
|
|
52
|
+
result.workspaceRoot ??= _workspaceRoot;
|
|
53
|
+
} else {
|
|
54
|
+
result = _static_cache.data;
|
|
55
|
+
}
|
|
56
|
+
if (schema && extensionName) {
|
|
57
|
+
result.extensions = {
|
|
58
|
+
...result.extensions,
|
|
59
|
+
[extensionName]: createConfigExtension(extensionName, schema)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
_static_cache = {
|
|
63
|
+
timestamp: Date.now(),
|
|
64
|
+
data: result
|
|
65
|
+
};
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
var createConfigExtension = (extensionName, schema) => {
|
|
69
|
+
const extension_cache_key = { extensionName };
|
|
70
|
+
if (_extension_cache.has(extension_cache_key)) {
|
|
71
|
+
return _extension_cache.get(extension_cache_key);
|
|
72
|
+
}
|
|
73
|
+
let extension = getExtensionEnv(extensionName);
|
|
74
|
+
if (schema) {
|
|
75
|
+
extension = schema.parse(extension);
|
|
76
|
+
}
|
|
77
|
+
_extension_cache.set(extension_cache_key, extension);
|
|
78
|
+
return extension;
|
|
79
|
+
};
|
|
80
|
+
var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
|
|
81
|
+
const config = await createStormWorkspaceConfig(
|
|
82
|
+
void 0,
|
|
83
|
+
void 0,
|
|
84
|
+
workspaceRoot,
|
|
85
|
+
skipLogs,
|
|
86
|
+
true
|
|
87
|
+
);
|
|
88
|
+
setConfigEnv(config);
|
|
89
|
+
if (!skipLogs && !config.skipConfigLogging) {
|
|
90
|
+
writeTrace(
|
|
91
|
+
`\u2699\uFE0F Using Storm Workspace configuration:
|
|
92
|
+
${formatLogMessage(config)}`,
|
|
93
|
+
config
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return config;
|
|
97
|
+
};
|
|
98
|
+
var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
|
|
99
|
+
try {
|
|
100
|
+
const config = await createStormWorkspaceConfig(
|
|
101
|
+
void 0,
|
|
102
|
+
void 0,
|
|
103
|
+
workspaceRoot,
|
|
104
|
+
skipLogs,
|
|
105
|
+
useDefault
|
|
106
|
+
);
|
|
107
|
+
if (!config) {
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
setConfigEnv(config);
|
|
111
|
+
if (!skipLogs && !config.skipConfigLogging) {
|
|
112
|
+
writeTrace(
|
|
113
|
+
`\u2699\uFE0F Using Storm Workspace configuration:
|
|
114
|
+
${formatLogMessage(config)}`,
|
|
115
|
+
config
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return config;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (!skipLogs) {
|
|
121
|
+
writeWarning(
|
|
122
|
+
`\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
|
|
123
|
+
{ logLevel: "all" }
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
return void 0;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
createStormWorkspaceConfig,
|
|
132
|
+
createConfigExtension,
|
|
133
|
+
loadStormWorkspaceConfig,
|
|
134
|
+
tryLoadStormWorkspaceConfig
|
|
135
|
+
};
|