@storm-software/config-tools 1.5.5 → 1.5.7
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 +14 -0
- package/index.cjs +457 -34
- package/index.js +414 -0
- package/meta.cjs.json +1 -1
- package/meta.esm.json +1 -1
- package/package.json +2 -1
- package/declarations.d.js +0 -0
- package/packages/config-tools/declarations.d.cjs +0 -15
- package/packages/config-tools/src/config-file/get-config-file.cjs +0 -61
- package/packages/config-tools/src/config-file/index.cjs +0 -21
- package/packages/config-tools/src/create-storm-config.cjs +0 -61
- package/packages/config-tools/src/env/get-env.cjs +0 -92
- package/packages/config-tools/src/env/index.cjs +0 -23
- package/packages/config-tools/src/env/set-env.cjs +0 -102
- package/packages/config-tools/src/index.cjs +0 -31
- package/packages/config-tools/src/schema.cjs +0 -89
- package/packages/config-tools/src/types.cjs +0 -46
- package/packages/config-tools/src/utilities/get-default-config.cjs +0 -102
- package/packages/config-tools/src/utilities/get-log-level.cjs +0 -68
- package/packages/config-tools/src/utilities/index.cjs +0 -23
- package/packages/testing-tools/src/index.cjs +0 -23
- package/packages/testing-tools/src/jest/package.config.cjs +0 -37
- package/packages/testing-tools/src/jest/workspace.config.cjs +0 -72
- package/src/config-file/get-config-file.js +0 -38
- package/src/config-file/index.js +0 -1
- package/src/create-storm-config.js +0 -37
- package/src/env/get-env.js +0 -68
- package/src/env/index.js +0 -2
- package/src/env/set-env.js +0 -78
- package/src/index.js +0 -6
- package/src/schema.js +0 -55
- package/src/types.js +0 -22
- package/src/utilities/get-default-config.js +0 -77
- package/src/utilities/get-log-level.js +0 -44
- package/src/utilities/index.js +0 -2
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var src_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(src_exports);
|
|
17
|
-
__reExport(src_exports, require("./jest/package.config"), module.exports);
|
|
18
|
-
__reExport(src_exports, require("./jest/workspace.config"), module.exports);
|
|
19
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
-
0 && (module.exports = {
|
|
21
|
-
...require("./jest/package.config"),
|
|
22
|
-
...require("./jest/workspace.config")
|
|
23
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var package_config_exports = {};
|
|
19
|
-
__export(package_config_exports, {
|
|
20
|
-
getJestConfig: () => getJestConfig
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(package_config_exports);
|
|
23
|
-
var import_path = require("path");
|
|
24
|
-
const getJestConfig = (projectDir, isNode = true, displayName) => ({
|
|
25
|
-
displayName: displayName ? displayName : projectDir.replaceAll("\\", "-").replaceAll("/", "-"),
|
|
26
|
-
preset: "@storm-software/testing-tools/jest/preset.js",
|
|
27
|
-
testEnvironment: isNode ? "node" : "jsdom",
|
|
28
|
-
transform: {
|
|
29
|
-
"^.+\\.[tj]s$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.spec.json" }]
|
|
30
|
-
},
|
|
31
|
-
moduleFileExtensions: ["ts", "js", "html"],
|
|
32
|
-
coverageDirectory: (0, import_path.join)("../../coverage", projectDir)
|
|
33
|
-
});
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
getJestConfig
|
|
37
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var workspace_config_exports = {};
|
|
19
|
-
__export(workspace_config_exports, {
|
|
20
|
-
default: () => workspace_config_default
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(workspace_config_exports);
|
|
23
|
-
var import_jest = require("@nx/jest");
|
|
24
|
-
var workspace_config_default = {
|
|
25
|
-
/**
|
|
26
|
-
* When the projects configuration is provided with an array of paths or glob patterns, Jest will run tests in all of the specified projects at the same time.
|
|
27
|
-
* This is great for monorepos or when working on multiple projects at the same time.
|
|
28
|
-
*/
|
|
29
|
-
projects: (0, import_jest.getJestProjects)(),
|
|
30
|
-
/**
|
|
31
|
-
* Indicates whether the coverage information should be collected while executing the test. Because this retrofits all
|
|
32
|
-
* executed files with coverage collection statements, it may significantly slow down your tests. Default: false
|
|
33
|
-
*/
|
|
34
|
-
collectCoverage: process.env.CI ? true : false,
|
|
35
|
-
/**
|
|
36
|
-
* An array of glob patterns indicating a set of files for which coverage information should be collected.
|
|
37
|
-
* If a file matches the specified glob pattern, coverage information will be collected for it even if no tests exist
|
|
38
|
-
* for this file and it's never required in the test suite. Default: undefined
|
|
39
|
-
*/
|
|
40
|
-
// collectCoverageFrom: ["**/*(!*.spec).tsx", "**/*(!*.spec).ts"],
|
|
41
|
-
/**
|
|
42
|
-
* The directory where Jest should output its coverage files. Default: undefined
|
|
43
|
-
*/
|
|
44
|
-
coverageDirectory: "<rootDir>/coverage",
|
|
45
|
-
/**
|
|
46
|
-
* An array of regexp pattern strings that are matched against all file paths before executing the test. If the file path
|
|
47
|
-
* matches any of the patterns, coverage information will be skipped.
|
|
48
|
-
*/
|
|
49
|
-
coveragePathIgnorePatterns: [
|
|
50
|
-
"\\.spec\\.ts$",
|
|
51
|
-
"\\.test\\.ts$",
|
|
52
|
-
"<rootDir>/dist",
|
|
53
|
-
"<rootDir>/test",
|
|
54
|
-
"<rootDir>/__generated__",
|
|
55
|
-
"<rootDir>/node_modules"
|
|
56
|
-
],
|
|
57
|
-
/**
|
|
58
|
-
* The test environment that will be used for testing. The default environment in Jest is a Node.js environment.
|
|
59
|
-
* If you are building a web app, you can use a browser-like environment through jsdom instead.
|
|
60
|
-
*/
|
|
61
|
-
testEnvironment: "jest-environment-jsdom",
|
|
62
|
-
/**
|
|
63
|
-
* A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter can be used.
|
|
64
|
-
* Default: ["json", "lcov", "text"]
|
|
65
|
-
*/
|
|
66
|
-
coverageReporters: ["lcov", "json"],
|
|
67
|
-
setupFiles: ["@storm-software/testing-tools/jest/__mocks__/jest.setup.js"],
|
|
68
|
-
moduleNameMapper: {
|
|
69
|
-
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "@storm-software/testing-tools/jest/__mocks__/file.mock.js",
|
|
70
|
-
"\\.(css|less)$": "@storm-software/testing-tools/jest/__mocks__/style.mock.js"
|
|
71
|
-
}
|
|
72
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { cosmiconfig } from "cosmiconfig";
|
|
2
|
-
let _static_cache = void 0;
|
|
3
|
-
const getConfigFileName = (fileName) => cosmiconfig(fileName, { cache: true }).search();
|
|
4
|
-
const getConfigFile = async () => {
|
|
5
|
-
if (_static_cache) {
|
|
6
|
-
return _static_cache;
|
|
7
|
-
}
|
|
8
|
-
let cosmiconfigResult = await getConfigFileName("storm");
|
|
9
|
-
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
10
|
-
cosmiconfigResult = await getConfigFileName("storm-software");
|
|
11
|
-
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
12
|
-
cosmiconfigResult = await getConfigFileName("storm-stack");
|
|
13
|
-
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
14
|
-
cosmiconfigResult = await getConfigFileName("storm-cloud");
|
|
15
|
-
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
16
|
-
cosmiconfigResult = await getConfigFileName("acidic");
|
|
17
|
-
if (!cosmiconfigResult || cosmiconfigResult.isEmpty) {
|
|
18
|
-
cosmiconfigResult = await getConfigFileName("acid");
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (!cosmiconfigResult || Object.keys(cosmiconfigResult).length === 0 || cosmiconfigResult.isEmpty || !cosmiconfigResult.filepath) {
|
|
25
|
-
console.warn(
|
|
26
|
-
"No Storm config file found in the current workspace. Please ensure this is the expected behavior - you can add a `storm.config.js` file to the root of your workspace if it is not."
|
|
27
|
-
);
|
|
28
|
-
return void 0;
|
|
29
|
-
}
|
|
30
|
-
const config = cosmiconfigResult.config ?? {};
|
|
31
|
-
cosmiconfigResult.filepath && (config.configFile = cosmiconfigResult.filepath);
|
|
32
|
-
config.runtimeVersion = "0.0.1";
|
|
33
|
-
_static_cache = config;
|
|
34
|
-
return config;
|
|
35
|
-
};
|
|
36
|
-
export {
|
|
37
|
-
getConfigFile
|
|
38
|
-
};
|
package/src/config-file/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./get-config-file";
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { getConfigEnv, getExtensionEnv } from "./env/get-env";
|
|
2
|
-
import { StormConfigSchema } from "./schema";
|
|
3
|
-
const _extension_cache = /* @__PURE__ */ new WeakMap();
|
|
4
|
-
let _static_cache = void 0;
|
|
5
|
-
const createStormConfig = (extensionName, schema) => {
|
|
6
|
-
let result;
|
|
7
|
-
if (!_static_cache) {
|
|
8
|
-
let config = getConfigEnv();
|
|
9
|
-
result = StormConfigSchema.parse(config);
|
|
10
|
-
} else {
|
|
11
|
-
result = _static_cache;
|
|
12
|
-
}
|
|
13
|
-
if (schema && extensionName) {
|
|
14
|
-
result.extensions = {
|
|
15
|
-
...result.extensions,
|
|
16
|
-
[extensionName]: createConfigExtension(extensionName, schema)
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
_static_cache = result;
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
const createConfigExtension = (extensionName, schema) => {
|
|
23
|
-
const extension_cache_key = { extensionName };
|
|
24
|
-
if (_extension_cache.has(extension_cache_key)) {
|
|
25
|
-
return _extension_cache.get(extension_cache_key);
|
|
26
|
-
}
|
|
27
|
-
let extension = getExtensionEnv(extensionName);
|
|
28
|
-
if (schema) {
|
|
29
|
-
extension = schema.parse(extension);
|
|
30
|
-
}
|
|
31
|
-
_extension_cache.set(extension_cache_key, extension);
|
|
32
|
-
return extension;
|
|
33
|
-
};
|
|
34
|
-
export {
|
|
35
|
-
createConfigExtension,
|
|
36
|
-
createStormConfig
|
|
37
|
-
};
|
package/src/env/get-env.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { LogLevelLabel } from "../types";
|
|
2
|
-
import { getLogLevelLabel } from "../utilities";
|
|
3
|
-
const getExtensionEnv = (extensionName) => {
|
|
4
|
-
const prefix = `STORM_EXTENSION_${extensionName.toUpperCase()}_`;
|
|
5
|
-
return Object.keys(process.env).filter((key) => key.startsWith(prefix)).reduce((ret, key) => {
|
|
6
|
-
const name = key.replace(prefix, "").split("_").map(
|
|
7
|
-
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
8
|
-
).join("");
|
|
9
|
-
name && (ret[name] = process.env[key]);
|
|
10
|
-
return ret;
|
|
11
|
-
}, {});
|
|
12
|
-
};
|
|
13
|
-
const getConfigEnv = () => {
|
|
14
|
-
const prefix = `STORM_`;
|
|
15
|
-
let config = {
|
|
16
|
-
name: process.env[`${prefix}NAME`],
|
|
17
|
-
namespace: process.env[`${prefix}NAMESPACE`],
|
|
18
|
-
owner: process.env[`${prefix}OWNER`],
|
|
19
|
-
worker: process.env[`${prefix}WORKER`],
|
|
20
|
-
organization: process.env[`${prefix}ORGANIZATION`],
|
|
21
|
-
license: process.env[`${prefix}LICENSE`],
|
|
22
|
-
homepage: process.env[`${prefix}HOMEPAGE`],
|
|
23
|
-
timezone: process.env[`${prefix}TIMEZONE`] ?? process.env.TZ,
|
|
24
|
-
locale: process.env[`${prefix}LOCALE`] ?? process.env.LOCALE,
|
|
25
|
-
configFile: process.env[`${prefix}CONFIG_FILE`],
|
|
26
|
-
workspaceRoot: process.env[`${prefix}WORKSPACE_ROOT`],
|
|
27
|
-
packageDirectory: process.env[`${prefix}PACKAGE_DIRECTORY`],
|
|
28
|
-
buildDirectory: process.env[`${prefix}BUILD_DIRECTORY`],
|
|
29
|
-
runtimeVersion: process.env[`${prefix}RUNTIME_VERSION`],
|
|
30
|
-
runtimeDirectory: process.env[`${prefix}RUNTIME_DIRECTORY`],
|
|
31
|
-
env: process.env[`${prefix}ENV`] ?? process.env.NODE_ENV ?? process.env.ENVIRONMENT,
|
|
32
|
-
ci: Boolean(
|
|
33
|
-
process.env[`${prefix}CI`] ?? process.env.CI ?? process.env.CONTINUOUS_INTEGRATION
|
|
34
|
-
),
|
|
35
|
-
colors: {
|
|
36
|
-
primary: process.env[`${prefix}COLOR_PRIMARY`],
|
|
37
|
-
background: process.env[`${prefix}COLOR_BACKGROUND`],
|
|
38
|
-
success: process.env[`${prefix}COLOR_SUCCESS`],
|
|
39
|
-
info: process.env[`${prefix}COLOR_INFO`],
|
|
40
|
-
warning: process.env[`${prefix}COLOR_WARNING`],
|
|
41
|
-
error: process.env[`${prefix}COLOR_ERROR`],
|
|
42
|
-
fatal: process.env[`${prefix}COLOR_FATAL`]
|
|
43
|
-
},
|
|
44
|
-
repository: process.env[`${prefix}REPOSITORY`],
|
|
45
|
-
branch: process.env[`${prefix}BRANCH`],
|
|
46
|
-
preMajor: Boolean(process.env[`${prefix}PRE_MAJOR`]),
|
|
47
|
-
logLevel: process.env[`${prefix}LOG_LEVEL`] !== null && process.env[`${prefix}LOG_LEVEL`] !== void 0 ? Number.isSafeInteger(
|
|
48
|
-
Number.parseInt(process.env[`${prefix}LOG_LEVEL`])
|
|
49
|
-
) ? getLogLevelLabel(Number.parseInt(process.env[`${prefix}LOG_LEVEL`])) : process.env[`${prefix}LOG_LEVEL`] : LogLevelLabel.INFO,
|
|
50
|
-
extensions: {}
|
|
51
|
-
};
|
|
52
|
-
const serializedConfig = process.env[`${prefix}CONFIG`];
|
|
53
|
-
if (serializedConfig) {
|
|
54
|
-
config = Object.assign(config, JSON.parse(serializedConfig));
|
|
55
|
-
}
|
|
56
|
-
const extensionPrefix = `${prefix}EXTENSION_`;
|
|
57
|
-
return Object.keys(process.env).filter((key) => key.startsWith(extensionPrefix)).reduce((ret, key) => {
|
|
58
|
-
const extensionName = key.substring(prefix.length, key.indexOf("_", prefix.length)).split("_").map(
|
|
59
|
-
(i) => i.length > 0 ? i.trim().charAt(0).toUpperCase() + i.trim().slice(1) : ""
|
|
60
|
-
).join("");
|
|
61
|
-
extensionName && (ret.extensions[extensionName] = getExtensionEnv(extensionName));
|
|
62
|
-
return ret;
|
|
63
|
-
}, config);
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
getConfigEnv,
|
|
67
|
-
getExtensionEnv
|
|
68
|
-
};
|
package/src/env/index.js
DELETED
package/src/env/set-env.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { LogLevel } from "../types";
|
|
2
|
-
import { getLogLevel } from "../utilities/get-log-level";
|
|
3
|
-
const setExtensionEnv = (extensionName, extension) => {
|
|
4
|
-
Object.keys(extension ?? {}).forEach((key) => {
|
|
5
|
-
if (extension[key]) {
|
|
6
|
-
let result = key?.replace(
|
|
7
|
-
/([A-Z])+/g,
|
|
8
|
-
(input) => input ? input[0].toUpperCase() + input.slice(1) : ""
|
|
9
|
-
).split(/(?=[A-Z])|[\.\-\s_]/).map((x) => x.toLowerCase()) ?? [];
|
|
10
|
-
let extensionKey;
|
|
11
|
-
if (result.length === 0) {
|
|
12
|
-
return;
|
|
13
|
-
} else if (result.length === 1) {
|
|
14
|
-
extensionKey = result[0].toUpperCase();
|
|
15
|
-
} else {
|
|
16
|
-
extensionKey = result.reduce((ret, part) => {
|
|
17
|
-
return `${ret}_${part.toLowerCase()}`;
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
process.env[`STORM_EXTENSION_${extensionName.toUpperCase()}_${extensionKey.toUpperCase()}`] = extension[key];
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
const setConfigEnv = (config) => {
|
|
25
|
-
const prefix = `STORM_`;
|
|
26
|
-
process.env[`${prefix}NAME`] = config.name;
|
|
27
|
-
process.env[`${prefix}NAMESPACE`] = config.namespace;
|
|
28
|
-
process.env[`${prefix}OWNER`] = config.owner;
|
|
29
|
-
process.env[`${prefix}WORKER`] = config.worker;
|
|
30
|
-
process.env[`${prefix}ORGANIZATION`] = config.organization;
|
|
31
|
-
process.env[`${prefix}LICENSE`] = config.license;
|
|
32
|
-
process.env[`${prefix}HOMEPAGE`] = config.homepage;
|
|
33
|
-
process.env[`${prefix}TIMEZONE`] = config.timezone;
|
|
34
|
-
process.env.TZ = config.timezone;
|
|
35
|
-
process.env.DEFAULT_TIMEZONE = config.timezone;
|
|
36
|
-
process.env[`${prefix}LOCALE`] = config.locale;
|
|
37
|
-
process.env.LOCALE = config.locale;
|
|
38
|
-
process.env.DEFAULT_LOCALE = config.locale;
|
|
39
|
-
process.env.LANG = config.locale ? `${config.locale.replaceAll("-", "_")}.UTF-8` : "en_US.UTF-8";
|
|
40
|
-
process.env[`${prefix}CONFIG_FILE`] = config.configFile;
|
|
41
|
-
process.env[`${prefix}WORKSPACE_ROOT`] = config.workspaceRoot;
|
|
42
|
-
process.env.NX_WORKSPACE_ROOT = config.workspaceRoot;
|
|
43
|
-
process.env.NX_WORKSPACE_ROOT_PATH = config.workspaceRoot;
|
|
44
|
-
process.env[`${prefix}PACKAGE_DIRECTORY`] = config.packageDirectory;
|
|
45
|
-
process.env[`${prefix}BUILD_DIRECTORY`] = config.buildDirectory;
|
|
46
|
-
process.env[`${prefix}RUNTIME_VERSION`] = config.runtimeVersion;
|
|
47
|
-
process.env[`${prefix}RUNTIME_DIRECTORY`] = config.runtimeDirectory;
|
|
48
|
-
process.env[`${prefix}ENV`] = config.env;
|
|
49
|
-
process.env.NODE_ENV = config.env;
|
|
50
|
-
process.env.ENVIRONMENT = config.env;
|
|
51
|
-
process.env[`${prefix}CI`] = String(config.ci);
|
|
52
|
-
process.env.CI = String(config.ci);
|
|
53
|
-
process.env.CONTINUOUS_INTEGRATION = String(config.ci);
|
|
54
|
-
process.env[`${prefix}COLOR_PRIMARY`] = config.colors.primary;
|
|
55
|
-
process.env[`${prefix}COLOR_BACKGROUND`] = config.colors.background;
|
|
56
|
-
process.env[`${prefix}COLOR_SUCCESS`] = config.colors.success;
|
|
57
|
-
process.env[`${prefix}COLOR_INFO`] = config.colors.info;
|
|
58
|
-
process.env[`${prefix}COLOR_WARNING`] = config.colors.warning;
|
|
59
|
-
process.env[`${prefix}COLOR_ERROR`] = config.colors.error;
|
|
60
|
-
process.env[`${prefix}COLOR_FATAL`] = config.colors.fatal;
|
|
61
|
-
process.env[`${prefix}REPOSITORY`] = config.repository;
|
|
62
|
-
process.env[`${prefix}BRANCH`] = config.branch;
|
|
63
|
-
process.env[`${prefix}PRE_MAJOR`] = String(config.preMajor);
|
|
64
|
-
process.env[`${prefix}LOG_LEVEL`] = String(config.logLevel);
|
|
65
|
-
process.env.LOG_LEVEL = String(config.logLevel);
|
|
66
|
-
process.env.NX_VERBOSE_LOGGING = String(
|
|
67
|
-
getLogLevel(config.logLevel) >= LogLevel.DEBUG ? true : false
|
|
68
|
-
);
|
|
69
|
-
process.env.RUST_BACKTRACE = getLogLevel(config.logLevel) >= LogLevel.DEBUG ? "full" : "none";
|
|
70
|
-
process.env[`${prefix}CONFIG`] = JSON.stringify(config);
|
|
71
|
-
Object.keys(config.extensions ?? {}).forEach((key) => {
|
|
72
|
-
config.extensions[key] && Object.keys(config.extensions[key]) && setExtensionEnv(key, config.extensions[key]);
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
export {
|
|
76
|
-
setConfigEnv,
|
|
77
|
-
setExtensionEnv
|
|
78
|
-
};
|
package/src/index.js
DELETED
package/src/schema.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
const ColorConfigSchema = z.object({
|
|
3
|
-
primary: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The primary color of the workspace"),
|
|
4
|
-
background: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#1d232a").describe("The background color of the workspace"),
|
|
5
|
-
success: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#087f5b").describe("The success color of the workspace"),
|
|
6
|
-
info: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#0ea5e9").describe("The informational color of the workspace"),
|
|
7
|
-
warning: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#fcc419").describe("The warning color of the workspace"),
|
|
8
|
-
error: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#990000").describe("The error color of the workspace"),
|
|
9
|
-
fatal: z.string().trim().toLowerCase().regex(/^#([0-9a-f]{3}){1,2}$/i).length(7).default("#7d1a1a").describe("The fatal color of the workspace")
|
|
10
|
-
}).describe("Colors used for various workspace elements");
|
|
11
|
-
const StormConfigSchema = z.object({
|
|
12
|
-
name: z.string().trim().toLowerCase().describe("The name of the package"),
|
|
13
|
-
namespace: z.string().trim().toLowerCase().default("storm-software").describe("The namespace of the package"),
|
|
14
|
-
organization: z.string().trim().default("storm-software").describe("The organization of the workspace"),
|
|
15
|
-
repository: z.string().trim().url().optional().describe("The repo URL of the workspace (i.e. GitHub)"),
|
|
16
|
-
license: z.string().trim().default("Apache License 2.0").describe("The root directory of the package"),
|
|
17
|
-
homepage: z.string().trim().url().default("https://stormsoftware.org").describe("The homepage of the workspace"),
|
|
18
|
-
branch: z.string().trim().default("main").describe("The branch of the workspace"),
|
|
19
|
-
preMajor: z.boolean().default(false).describe(
|
|
20
|
-
"An indicator specifying if the package is still in it's pre-major version"
|
|
21
|
-
),
|
|
22
|
-
owner: z.string().trim().default("@storm-software/development").describe("The owner of the package"),
|
|
23
|
-
worker: z.string().trim().default("stormie-bot").describe(
|
|
24
|
-
"The worker of the package (this is the bot that will be used to perform various tasks)"
|
|
25
|
-
),
|
|
26
|
-
env: z.enum(["development", "staging", "production"]).default("production").describe("The current runtime environment of the package"),
|
|
27
|
-
ci: z.boolean().default(true).describe(
|
|
28
|
-
"An indicator specifying if the current environment is a CI environment"
|
|
29
|
-
),
|
|
30
|
-
workspaceRoot: z.string().trim().describe("The root directory of the workspace"),
|
|
31
|
-
packageDirectory: z.string().trim().optional().describe("The root directory of the package"),
|
|
32
|
-
buildDirectory: z.string().trim().default("dist").describe("The build directory for the workspace"),
|
|
33
|
-
runtimeDirectory: z.string().trim().default("node_modules/.storm").describe("The runtime directory of Storm"),
|
|
34
|
-
runtimeVersion: z.string().trim().regex(
|
|
35
|
-
/^(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-]+)*))?$/
|
|
36
|
-
).default("1.0.0").describe("The global version of the Storm runtime"),
|
|
37
|
-
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
38
|
-
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
39
|
-
logLevel: z.enum(["silent", "fatal", "error", "warn", "info", "debug", "trace"]).optional().describe(
|
|
40
|
-
"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`)."
|
|
41
|
-
),
|
|
42
|
-
configFile: z.string().trim().nullable().default(null).describe(
|
|
43
|
-
"The filepath of the Storm config. When this field is null, no config file was found in the current workspace."
|
|
44
|
-
),
|
|
45
|
-
colors: ColorConfigSchema.describe(
|
|
46
|
-
"Storm theme config values used for styling various package elements"
|
|
47
|
-
),
|
|
48
|
-
extensions: z.record(z.any()).default({}).describe("Configuration of each used extension")
|
|
49
|
-
}).describe(
|
|
50
|
-
"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."
|
|
51
|
-
);
|
|
52
|
-
export {
|
|
53
|
-
ColorConfigSchema,
|
|
54
|
-
StormConfigSchema
|
|
55
|
-
};
|
package/src/types.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const LogLevel = {
|
|
2
|
-
SILENT: 0,
|
|
3
|
-
FATAL: 10,
|
|
4
|
-
ERROR: 20,
|
|
5
|
-
WARN: 30,
|
|
6
|
-
INFO: 40,
|
|
7
|
-
DEBUG: 60,
|
|
8
|
-
TRACE: 70
|
|
9
|
-
};
|
|
10
|
-
const LogLevelLabel = {
|
|
11
|
-
SILENT: "silent",
|
|
12
|
-
FATAL: "fatal",
|
|
13
|
-
ERROR: "error",
|
|
14
|
-
WARN: "warn",
|
|
15
|
-
INFO: "info",
|
|
16
|
-
DEBUG: "debug",
|
|
17
|
-
TRACE: "trace"
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
LogLevel,
|
|
21
|
-
LogLevelLabel
|
|
22
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "fs";
|
|
2
|
-
import { findWorkspaceRoot } from "nx/src/utils/find-workspace-root.js";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import { StormConfigSchema } from "../schema";
|
|
5
|
-
const DefaultColorConfig = {
|
|
6
|
-
primary: "#1fb2a6",
|
|
7
|
-
background: "#1d232a",
|
|
8
|
-
success: "#087f5b",
|
|
9
|
-
info: "#0ea5e9",
|
|
10
|
-
warning: "#fcc419",
|
|
11
|
-
error: "#990000",
|
|
12
|
-
fatal: "#7d1a1a"
|
|
13
|
-
};
|
|
14
|
-
const DefaultStormConfig = {
|
|
15
|
-
namespace: "storm-software",
|
|
16
|
-
license: "Apache License 2.0",
|
|
17
|
-
homepage: "https://stormsoftware.org",
|
|
18
|
-
preMajor: false,
|
|
19
|
-
owner: "@storm-software/development",
|
|
20
|
-
worker: "stormie-bot",
|
|
21
|
-
runtimeDirectory: "node_modules/.storm",
|
|
22
|
-
timezone: "America/New_York",
|
|
23
|
-
locale: "en-US",
|
|
24
|
-
env: "production",
|
|
25
|
-
branch: "main",
|
|
26
|
-
organization: "storm-software",
|
|
27
|
-
ci: true,
|
|
28
|
-
configFile: null,
|
|
29
|
-
runtimeVersion: "1.0.0",
|
|
30
|
-
colors: { ...DefaultColorConfig },
|
|
31
|
-
extensions: {}
|
|
32
|
-
};
|
|
33
|
-
const getDefaultConfig = (config = {}) => {
|
|
34
|
-
let name = "storm-workspace";
|
|
35
|
-
let namespace = "storm-software";
|
|
36
|
-
let repository = "https://github.com/storm-software/storm-stack";
|
|
37
|
-
let license = DefaultStormConfig.license;
|
|
38
|
-
let homepage = DefaultStormConfig.homepage;
|
|
39
|
-
const workspaceRoot = getWorkspaceRoot() ?? process.cwd();
|
|
40
|
-
if (existsSync(join(workspaceRoot, "package.json"))) {
|
|
41
|
-
const file = readFileSync(join(workspaceRoot, "package.json"), {
|
|
42
|
-
encoding: "utf-8"
|
|
43
|
-
});
|
|
44
|
-
if (file) {
|
|
45
|
-
const packageJson = JSON.parse(file);
|
|
46
|
-
packageJson.name && (name = packageJson.name);
|
|
47
|
-
packageJson.namespace && (namespace = packageJson.namespace);
|
|
48
|
-
packageJson.repository?.url && (repository = packageJson.repository?.url);
|
|
49
|
-
packageJson.license && (license = packageJson.license);
|
|
50
|
-
packageJson.homepage && (homepage = packageJson.homepage);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return StormConfigSchema.parse(
|
|
54
|
-
Object.assign(config, {
|
|
55
|
-
...DefaultStormConfig,
|
|
56
|
-
colors: { ...DefaultColorConfig },
|
|
57
|
-
workspaceRoot,
|
|
58
|
-
name,
|
|
59
|
-
namespace,
|
|
60
|
-
repository,
|
|
61
|
-
license: license ?? DefaultStormConfig.license,
|
|
62
|
-
homepage: homepage ?? DefaultStormConfig.homepage,
|
|
63
|
-
extensions: {}
|
|
64
|
-
})
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
const getWorkspaceRoot = () => {
|
|
68
|
-
const root = findWorkspaceRoot(process.cwd());
|
|
69
|
-
process.env.STORM_WORKSPACE_ROOT ??= root?.dir;
|
|
70
|
-
process.env.NX_WORKSPACE_ROOT_PATH ??= root?.dir;
|
|
71
|
-
return root?.dir;
|
|
72
|
-
};
|
|
73
|
-
export {
|
|
74
|
-
DefaultColorConfig,
|
|
75
|
-
DefaultStormConfig,
|
|
76
|
-
getDefaultConfig
|
|
77
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { LogLevel, LogLevelLabel } from "../types";
|
|
2
|
-
const getLogLevel = (label) => {
|
|
3
|
-
switch (label) {
|
|
4
|
-
case "trace":
|
|
5
|
-
return LogLevel.TRACE;
|
|
6
|
-
case "debug":
|
|
7
|
-
return LogLevel.DEBUG;
|
|
8
|
-
case "info":
|
|
9
|
-
return LogLevel.INFO;
|
|
10
|
-
case "warn":
|
|
11
|
-
return LogLevel.WARN;
|
|
12
|
-
case "error":
|
|
13
|
-
return LogLevel.ERROR;
|
|
14
|
-
case "fatal":
|
|
15
|
-
return LogLevel.FATAL;
|
|
16
|
-
case "silent":
|
|
17
|
-
return LogLevel.SILENT;
|
|
18
|
-
default:
|
|
19
|
-
return LogLevel.INFO;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const getLogLevelLabel = (logLevel) => {
|
|
23
|
-
if (logLevel >= LogLevel.TRACE) {
|
|
24
|
-
return LogLevelLabel.TRACE;
|
|
25
|
-
} else if (logLevel >= LogLevel.DEBUG) {
|
|
26
|
-
return LogLevelLabel.DEBUG;
|
|
27
|
-
} else if (logLevel >= LogLevel.INFO) {
|
|
28
|
-
return LogLevelLabel.INFO;
|
|
29
|
-
} else if (logLevel >= LogLevel.WARN) {
|
|
30
|
-
return LogLevelLabel.WARN;
|
|
31
|
-
} else if (logLevel >= LogLevel.ERROR) {
|
|
32
|
-
return LogLevelLabel.ERROR;
|
|
33
|
-
} else if (logLevel >= LogLevel.FATAL) {
|
|
34
|
-
return LogLevelLabel.FATAL;
|
|
35
|
-
} else if (logLevel <= LogLevel.SILENT) {
|
|
36
|
-
return LogLevelLabel.SILENT;
|
|
37
|
-
} else {
|
|
38
|
-
return LogLevelLabel.INFO;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
export {
|
|
42
|
-
getLogLevel,
|
|
43
|
-
getLogLevelLabel
|
|
44
|
-
};
|
package/src/utilities/index.js
DELETED