@storm-software/config-tools 1.190.44 → 1.190.45

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.
@@ -1,35 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
-
4
- var _chunkMKPGN5UTcjs = require('./chunk-MKPGN5UT.cjs');
5
-
6
-
7
- var _chunk7QBTVNMRcjs = require('./chunk-7QBTVNMR.cjs');
8
-
9
- // src/logger/create-logger.ts
10
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
11
- async function createLogger(config) {
12
- const writeFatal = _chunkMKPGN5UTcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.FATAL, config, { chalk: _chalk2.default });
13
- const writeError = _chunkMKPGN5UTcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.ERROR, config, { chalk: _chalk2.default });
14
- const writeWarning = _chunkMKPGN5UTcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.WARN, config, { chalk: _chalk2.default });
15
- const writeInfo = _chunkMKPGN5UTcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.INFO, config, { chalk: _chalk2.default });
16
- const writeSuccess = _chunkMKPGN5UTcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.SUCCESS, config, { chalk: _chalk2.default });
17
- const writeDebug = _chunkMKPGN5UTcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.DEBUG, config, { chalk: _chalk2.default });
18
- const writePerformance = _chunkMKPGN5UTcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.PERFORMANCE, config, { chalk: _chalk2.default });
19
- const writeTrace = _chunkMKPGN5UTcjs.getLogFn.call(void 0, _chunk7QBTVNMRcjs.LogLevel.TRACE, config, { chalk: _chalk2.default });
20
- return {
21
- fatal: writeFatal,
22
- error: writeError,
23
- warning: writeWarning,
24
- info: writeInfo,
25
- success: writeSuccess,
26
- performance: writePerformance,
27
- debug: writeDebug,
28
- trace: writeTrace,
29
- getStopwatch: _chunkMKPGN5UTcjs.getStopwatch
30
- };
31
- }
32
-
33
-
34
-
35
- exports.createLogger = createLogger;
@@ -1,102 +0,0 @@
1
- import {
2
- findWorkspaceRoot
3
- } from "./chunk-S4V6UG5D.js";
4
- import {
5
- joinPaths
6
- } from "./chunk-V3GMJ4TX.js";
7
-
8
- // src/utilities/get-default-config.ts
9
- import {
10
- STORM_DEFAULT_ERROR_CODES_FILE,
11
- STORM_DEFAULT_LICENSE
12
- } from "@storm-software/config";
13
- import { existsSync } from "node:fs";
14
- import { readFile } from "node:fs/promises";
15
- import { join } from "node:path";
16
- async function getPackageJsonConfig(root) {
17
- let license = STORM_DEFAULT_LICENSE;
18
- let homepage = void 0;
19
- let support = void 0;
20
- let name = void 0;
21
- let namespace = void 0;
22
- let repository = void 0;
23
- const workspaceRoot = findWorkspaceRoot(root);
24
- if (existsSync(join(workspaceRoot, "package.json"))) {
25
- const file = await readFile(
26
- joinPaths(workspaceRoot, "package.json"),
27
- "utf8"
28
- );
29
- if (file) {
30
- const packageJson = JSON.parse(file);
31
- if (packageJson.name) {
32
- name = packageJson.name;
33
- }
34
- if (packageJson.namespace) {
35
- namespace = packageJson.namespace;
36
- }
37
- if (packageJson.repository) {
38
- if (typeof packageJson.repository === "string") {
39
- repository = packageJson.repository;
40
- } else if (packageJson.repository.url) {
41
- repository = packageJson.repository.url;
42
- }
43
- }
44
- if (packageJson.license) {
45
- license = packageJson.license;
46
- }
47
- if (packageJson.homepage) {
48
- homepage = packageJson.homepage;
49
- }
50
- if (packageJson.bugs) {
51
- if (typeof packageJson.bugs === "string") {
52
- support = packageJson.bugs;
53
- } else if (packageJson.bugs.url) {
54
- support = packageJson.bugs.url;
55
- }
56
- }
57
- }
58
- }
59
- return {
60
- workspaceRoot,
61
- name,
62
- namespace,
63
- repository,
64
- license,
65
- homepage,
66
- support
67
- };
68
- }
69
- function applyDefaultConfig(config) {
70
- if (!config.support && config.contact) {
71
- config.support = config.contact;
72
- }
73
- if (!config.contact && config.support) {
74
- config.contact = config.support;
75
- }
76
- if (config.homepage) {
77
- if (!config.docs) {
78
- config.docs = `${config.homepage}/docs`;
79
- }
80
- if (!config.license) {
81
- config.license = `${config.homepage}/license`;
82
- }
83
- if (!config.support) {
84
- config.support = `${config.homepage}/support`;
85
- }
86
- if (!config.contact) {
87
- config.contact = `${config.homepage}/contact`;
88
- }
89
- if (!config.error?.codesFile || !config?.error?.url) {
90
- config.error ??= { codesFile: STORM_DEFAULT_ERROR_CODES_FILE };
91
- if (config.homepage) {
92
- config.error.url ??= `${config.homepage}/errors`;
93
- }
94
- }
95
- }
96
- return config;
97
- }
98
-
99
- export {
100
- getPackageJsonConfig,
101
- applyDefaultConfig
102
- };
@@ -1,47 +0,0 @@
1
- import {
2
- writeError
3
- } from "./chunk-CHETDXSD.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
- };
@@ -1,92 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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 _chunkMKPGN5UTcjs = require('./chunk-MKPGN5UT.cjs');
4
-
5
-
6
- var _chunkA5XFS6G4cjs = require('./chunk-A5XFS6G4.cjs');
7
-
8
-
9
- var _chunkBDATZ3UBcjs = require('./chunk-BDATZ3UB.cjs');
10
-
11
- // src/config-file/get-config-file.ts
12
- var _c12 = require('c12');
13
- var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
14
- var getConfigFileByName = async (fileName, filePath, options = {}) => {
15
- const workspacePath = filePath || _chunkA5XFS6G4cjs.findWorkspaceRoot.call(void 0, filePath);
16
- const configs = await Promise.all([
17
- _c12.loadConfig.call(void 0, {
18
- cwd: workspacePath,
19
- packageJson: true,
20
- name: fileName,
21
- envName: _optionalChain([fileName, 'optionalAccess', _ => _.toUpperCase, 'call', _2 => _2()]),
22
- jitiOptions: {
23
- debug: false,
24
- fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : _chunkBDATZ3UBcjs.joinPaths.call(void 0,
25
- process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
26
- "jiti"
27
- )
28
- },
29
- ...options
30
- }),
31
- _c12.loadConfig.call(void 0, {
32
- cwd: workspacePath,
33
- packageJson: true,
34
- name: fileName,
35
- envName: _optionalChain([fileName, 'optionalAccess', _3 => _3.toUpperCase, 'call', _4 => _4()]),
36
- jitiOptions: {
37
- debug: false,
38
- fsCache: process.env.STORM_SKIP_CACHE === "true" ? false : _chunkBDATZ3UBcjs.joinPaths.call(void 0,
39
- process.env.STORM_CACHE_DIR || "node_modules/.cache/storm",
40
- "jiti"
41
- )
42
- },
43
- configFile: fileName,
44
- ...options
45
- })
46
- ]);
47
- return _defu2.default.call(void 0, _nullishCoalesce(configs[0], () => ( {})), _nullishCoalesce(configs[1], () => ( {})));
48
- };
49
- var getConfigFile = async (filePath, additionalFileNames = []) => {
50
- const workspacePath = filePath ? filePath : _chunkA5XFS6G4cjs.findWorkspaceRoot.call(void 0, 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
- _chunkMKPGN5UTcjs.writeTrace.call(void 0,
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 (_optionalChain([result2, 'optionalAccess', _5 => _5.config]) && _optionalChain([result2, 'optionalAccess', _6 => _6.configFile]) && Object.keys(result2.config).length > 0) {
70
- if (!config.skipConfigLogging && !result2.config.skipConfigLogging) {
71
- _chunkMKPGN5UTcjs.writeTrace.call(void 0,
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 = _defu2.default.call(void 0, _nullishCoalesce(result2.config, () => ( {})), _nullishCoalesce(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
-
90
-
91
-
92
- exports.getConfigFileByName = getConfigFileByName; exports.getConfigFile = getConfigFile;
@@ -1,35 +0,0 @@
1
- import {
2
- getLogFn,
3
- getStopwatch
4
- } from "./chunk-CHETDXSD.js";
5
- import {
6
- LogLevel
7
- } from "./chunk-RALMUN5C.js";
8
-
9
- // src/logger/create-logger.ts
10
- import chalk from "chalk";
11
- async function createLogger(config) {
12
- const writeFatal = getLogFn(LogLevel.FATAL, config, { chalk });
13
- const writeError = getLogFn(LogLevel.ERROR, config, { chalk });
14
- const writeWarning = getLogFn(LogLevel.WARN, config, { chalk });
15
- const writeInfo = getLogFn(LogLevel.INFO, config, { chalk });
16
- const writeSuccess = getLogFn(LogLevel.SUCCESS, config, { chalk });
17
- const writeDebug = getLogFn(LogLevel.DEBUG, config, { chalk });
18
- const writePerformance = getLogFn(LogLevel.PERFORMANCE, config, { chalk });
19
- const writeTrace = getLogFn(LogLevel.TRACE, config, { chalk });
20
- return {
21
- fatal: writeFatal,
22
- error: writeError,
23
- warning: writeWarning,
24
- info: writeInfo,
25
- success: writeSuccess,
26
- performance: writePerformance,
27
- debug: writeDebug,
28
- trace: writeTrace,
29
- getStopwatch
30
- };
31
- }
32
-
33
- export {
34
- createLogger
35
- };
@@ -1,55 +0,0 @@
1
- import {
2
- writeError,
3
- writeFatal,
4
- writeSuccess,
5
- writeTrace
6
- } from "./chunk-CHETDXSD.js";
7
-
8
- // src/utilities/process-handler.ts
9
- var exitWithError = (config) => {
10
- writeFatal("Exiting script with an error status...", config);
11
- process.exit(1);
12
- };
13
- var exitWithSuccess = (config) => {
14
- writeSuccess("Script completed successfully. Exiting...", config);
15
- process.exit(0);
16
- };
17
- var handleProcess = (config) => {
18
- writeTrace(
19
- `Using the following arguments to process the script: ${process.argv.join(", ")}`,
20
- config
21
- );
22
- process.on("unhandledRejection", (error) => {
23
- writeError(
24
- `An Unhandled Rejection occurred while running the program: ${error}`,
25
- config
26
- );
27
- exitWithError(config);
28
- });
29
- process.on("uncaughtException", (error) => {
30
- writeError(
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
- writeError(`The program terminated with signal code: ${signal}`, config);
39
- exitWithError(config);
40
- });
41
- process.on("SIGINT", (signal) => {
42
- writeError(`The program terminated with signal code: ${signal}`, config);
43
- exitWithError(config);
44
- });
45
- process.on("SIGHUP", (signal) => {
46
- writeError(`The program terminated with signal code: ${signal}`, config);
47
- exitWithError(config);
48
- });
49
- };
50
-
51
- export {
52
- exitWithError,
53
- exitWithSuccess,
54
- handleProcess
55
- };
@@ -1,40 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _chunkPEXQLPTNcjs = require('./chunk-PEXQLPTN.cjs');
5
-
6
-
7
- var _chunkA5XFS6G4cjs = require('./chunk-A5XFS6G4.cjs');
8
-
9
- // src/get-config.ts
10
- function getConfig(workspaceRoot, skipLogs = false) {
11
- return _chunkPEXQLPTNcjs.loadStormWorkspaceConfig.call(void 0, workspaceRoot, skipLogs);
12
- }
13
- function getWorkspaceConfig(skipLogs = true, options = {}) {
14
- let workspaceRoot = options.workspaceRoot;
15
- if (!workspaceRoot) {
16
- workspaceRoot = _chunkA5XFS6G4cjs.findWorkspaceRoot.call(void 0, options.cwd);
17
- }
18
- return getConfig(workspaceRoot, skipLogs);
19
- }
20
- async function tryGetWorkspaceConfig(skipLogs = true, options = {}) {
21
- try {
22
- let workspaceRoot = options.workspaceRoot;
23
- if (!workspaceRoot) {
24
- workspaceRoot = _chunkA5XFS6G4cjs.findWorkspaceRoot.call(void 0, options.cwd);
25
- }
26
- return _chunkPEXQLPTNcjs.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;
@@ -1,47 +0,0 @@
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 _chunkMKPGN5UTcjs = require('./chunk-MKPGN5UT.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
- _chunkMKPGN5UTcjs.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;