@storm-software/config-tools 1.190.120 → 1.190.122

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.
Files changed (157) hide show
  1. package/README.md +1 -1
  2. package/bin/config.cjs +1272 -105
  3. package/bin/config.mjs +1271 -0
  4. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  5. package/dist/config-file/get-config-file.cjs +63 -79
  6. package/dist/config-file/get-config-file.d.cts +5 -5
  7. package/dist/config-file/{get-config-file.d.ts → get-config-file.d.mts} +7 -5
  8. package/dist/config-file/get-config-file.mjs +66 -0
  9. package/dist/config-file/index.cjs +4 -1
  10. package/dist/config-file/index.d.cts +2 -3
  11. package/dist/config-file/index.d.mts +4 -0
  12. package/dist/config-file/index.mjs +5 -0
  13. package/dist/create-storm-config.cjs +105 -136
  14. package/dist/create-storm-config.d.cts +5 -5
  15. package/dist/{create-storm-config.d.ts → create-storm-config.d.mts} +7 -5
  16. package/dist/create-storm-config.mjs +113 -0
  17. package/dist/env/get-env.cjs +190 -214
  18. package/dist/env/get-env.d.cts +5 -5
  19. package/dist/env/{get-env.d.ts → get-env.d.mts} +7 -5
  20. package/dist/env/get-env.mjs +203 -0
  21. package/dist/env/index.cjs +7 -2
  22. package/dist/env/index.d.cts +3 -4
  23. package/dist/env/index.d.mts +5 -0
  24. package/dist/env/index.mjs +6 -0
  25. package/dist/env/set-env.cjs +218 -374
  26. package/dist/env/set-env.d.cts +8 -8
  27. package/dist/env/{set-env.d.ts → set-env.d.mts} +10 -8
  28. package/dist/env/set-env.mjs +231 -0
  29. package/dist/get-config.cjs +40 -29
  30. package/dist/get-config.d.cts +18 -18
  31. package/dist/{get-config.d.ts → get-config.d.mts} +20 -18
  32. package/dist/get-config.mjs +46 -0
  33. package/dist/index.cjs +98 -7
  34. package/dist/index.d.cts +27 -28
  35. package/dist/index.d.mts +29 -0
  36. package/dist/index.mjs +26 -0
  37. package/dist/logger/chalk.cjs +38 -29
  38. package/dist/logger/chalk.d.cts +18 -17
  39. package/dist/logger/chalk.d.mts +37 -0
  40. package/dist/logger/chalk.mjs +43 -0
  41. package/dist/logger/console-icons.cjs +15 -14
  42. package/dist/logger/console-icons.d.cts +5 -8
  43. package/dist/logger/console-icons.d.mts +7 -0
  44. package/dist/logger/console-icons.mjs +20 -0
  45. package/dist/logger/console.cjs +187 -183
  46. package/dist/logger/console.d.cts +25 -25
  47. package/dist/logger/{console.d.ts → console.d.mts} +27 -25
  48. package/dist/logger/console.mjs +185 -0
  49. package/dist/logger/create-logger.cjs +31 -24
  50. package/dist/logger/create-logger.d.cts +5 -6
  51. package/dist/logger/{create-logger.d.ts → create-logger.d.mts} +7 -6
  52. package/dist/logger/create-logger.mjs +34 -0
  53. package/dist/logger/format-timestamp.cjs +12 -4
  54. package/dist/logger/format-timestamp.d.cts +3 -2
  55. package/dist/logger/{format-timestamp.d.ts → format-timestamp.d.mts} +5 -2
  56. package/dist/logger/format-timestamp.mjs +16 -0
  57. package/dist/logger/get-log-level.cjs +50 -60
  58. package/dist/logger/get-log-level.d.cts +4 -5
  59. package/dist/logger/{get-log-level.d.ts → get-log-level.d.mts} +6 -5
  60. package/dist/logger/get-log-level.mjs +54 -0
  61. package/dist/logger/index.cjs +29 -7
  62. package/dist/logger/index.d.cts +8 -10
  63. package/dist/logger/index.d.mts +10 -0
  64. package/dist/logger/index.mjs +11 -0
  65. package/dist/logger/is-unicode-supported.cjs +6 -10
  66. package/dist/logger/is-unicode-supported.d.cts +3 -2
  67. package/dist/logger/is-unicode-supported.d.mts +6 -0
  68. package/dist/logger/is-unicode-supported.mjs +10 -0
  69. package/dist/types.cjs +26 -25
  70. package/dist/types.d.cts +39 -41
  71. package/dist/types.d.mts +53 -0
  72. package/dist/types.mjs +30 -0
  73. package/dist/utilities/apply-workspace-tokens.cjs +31 -70
  74. package/dist/utilities/apply-workspace-tokens.d.cts +4 -5
  75. package/dist/utilities/{apply-workspace-tokens.d.ts → apply-workspace-tokens.d.mts} +6 -5
  76. package/dist/utilities/apply-workspace-tokens.mjs +37 -0
  77. package/dist/utilities/colors.cjs +91 -74
  78. package/dist/utilities/colors.d.cts +4 -4
  79. package/dist/utilities/{colors.d.ts → colors.d.mts} +6 -4
  80. package/dist/utilities/colors.mjs +97 -0
  81. package/dist/utilities/correct-paths.cjs +166 -196
  82. package/dist/utilities/correct-paths.d.cts +4 -4
  83. package/dist/utilities/{correct-paths.d.ts → correct-paths.d.mts} +6 -4
  84. package/dist/utilities/correct-paths.mjs +190 -0
  85. package/dist/utilities/file-path-utils.cjs +42 -27
  86. package/dist/utilities/file-path-utils.d.cts +15 -14
  87. package/dist/utilities/{file-path-utils.d.ts → file-path-utils.d.mts} +17 -14
  88. package/dist/utilities/file-path-utils.mjs +48 -0
  89. package/dist/utilities/find-up.cjs +12 -18
  90. package/dist/utilities/find-up.d.cts +3 -2
  91. package/dist/utilities/{find-up.d.ts → find-up.d.mts} +5 -2
  92. package/dist/utilities/find-up.mjs +19 -0
  93. package/dist/utilities/find-workspace-root.cjs +64 -69
  94. package/dist/utilities/find-workspace-root.d.cts +3 -2
  95. package/dist/utilities/{find-workspace-root.d.ts → find-workspace-root.d.mts} +5 -2
  96. package/dist/utilities/find-workspace-root.mjs +73 -0
  97. package/dist/utilities/get-default-config.cjs +69 -91
  98. package/dist/utilities/get-default-config.d.cts +4 -4
  99. package/dist/utilities/{get-default-config.d.ts → get-default-config.d.mts} +6 -4
  100. package/dist/utilities/get-default-config.mjs +74 -0
  101. package/dist/utilities/index.cjs +49 -9
  102. package/dist/utilities/index.d.cts +10 -14
  103. package/dist/utilities/index.d.mts +12 -0
  104. package/dist/utilities/index.mjs +13 -0
  105. package/dist/utilities/process-handler.cjs +32 -47
  106. package/dist/utilities/process-handler.d.cts +4 -4
  107. package/dist/utilities/process-handler.d.mts +9 -0
  108. package/dist/utilities/process-handler.mjs +38 -0
  109. package/dist/utilities/run.cjs +62 -36
  110. package/dist/utilities/run.d.cts +5 -6
  111. package/dist/utilities/{run.d.ts → run.d.mts} +7 -6
  112. package/dist/utilities/run.mjs +64 -0
  113. package/dist/utilities/toml.cjs +27 -32
  114. package/dist/utilities/toml.d.cts +148 -147
  115. package/dist/utilities/toml.d.mts +192 -0
  116. package/dist/utilities/toml.mjs +33 -0
  117. package/package.json +105 -157
  118. package/bin/config.js +0 -108
  119. package/dist/config-file/get-config-file.js +0 -83
  120. package/dist/config-file/index.d.ts +0 -3
  121. package/dist/config-file/index.js +0 -1
  122. package/dist/create-storm-config.js +0 -147
  123. package/dist/env/get-env.js +0 -226
  124. package/dist/env/index.d.ts +0 -4
  125. package/dist/env/index.js +0 -2
  126. package/dist/env/set-env.js +0 -386
  127. package/dist/get-config.js +0 -35
  128. package/dist/index.d.ts +0 -28
  129. package/dist/index.js +0 -7
  130. package/dist/logger/chalk.d.ts +0 -34
  131. package/dist/logger/chalk.js +0 -34
  132. package/dist/logger/console-icons.d.ts +0 -8
  133. package/dist/logger/console-icons.js +0 -17
  134. package/dist/logger/console.js +0 -191
  135. package/dist/logger/create-logger.js +0 -27
  136. package/dist/logger/format-timestamp.js +0 -6
  137. package/dist/logger/get-log-level.js +0 -64
  138. package/dist/logger/index.d.ts +0 -10
  139. package/dist/logger/index.js +0 -7
  140. package/dist/logger/is-unicode-supported.d.ts +0 -3
  141. package/dist/logger/is-unicode-supported.js +0 -12
  142. package/dist/types.d.ts +0 -53
  143. package/dist/types.js +0 -28
  144. package/dist/utilities/apply-workspace-tokens.js +0 -76
  145. package/dist/utilities/colors.js +0 -81
  146. package/dist/utilities/correct-paths.js +0 -231
  147. package/dist/utilities/file-path-utils.js +0 -33
  148. package/dist/utilities/find-up.js +0 -23
  149. package/dist/utilities/find-workspace-root.js +0 -77
  150. package/dist/utilities/get-default-config.js +0 -95
  151. package/dist/utilities/index.d.ts +0 -14
  152. package/dist/utilities/index.js +0 -9
  153. package/dist/utilities/process-handler.d.ts +0 -7
  154. package/dist/utilities/process-handler.js +0 -53
  155. package/dist/utilities/run.js +0 -38
  156. package/dist/utilities/toml.d.ts +0 -189
  157. package/dist/utilities/toml.js +0 -42
@@ -1,231 +0,0 @@
1
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2
- function normalizeWindowsPath(input = "") {
3
- if (!input) {
4
- return input;
5
- }
6
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
7
- }
8
- const _UNC_REGEX = /^[/\\]{2}/;
9
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
10
- const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
11
- const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
12
- const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
13
- const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
14
- const sep = "/";
15
- const correctPaths = function(path) {
16
- if (!path || path.length === 0) {
17
- return ".";
18
- }
19
- path = normalizeWindowsPath(path);
20
- const isUNCPath = path?.match(_UNC_REGEX);
21
- const isPathAbsolute = isAbsolute(path);
22
- const trailingSeparator = path[path.length - 1] === "/";
23
- path = normalizeString(path, !isPathAbsolute);
24
- if (path.length === 0) {
25
- if (isPathAbsolute) {
26
- return "/";
27
- }
28
- return trailingSeparator ? "./" : ".";
29
- }
30
- if (trailingSeparator) {
31
- path += "/";
32
- }
33
- if (_DRIVE_LETTER_RE.test(path)) {
34
- path += "/";
35
- }
36
- if (isUNCPath) {
37
- if (!isPathAbsolute) {
38
- return `//./${path}`;
39
- }
40
- return `//${path}`;
41
- }
42
- return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
43
- };
44
- const joinPaths = function(...segments) {
45
- let path = "";
46
- for (const seg of segments) {
47
- if (!seg) {
48
- continue;
49
- }
50
- if (path.length > 0) {
51
- const pathTrailing = path[path.length - 1] === "/";
52
- const segLeading = seg[0] === "/";
53
- const both = pathTrailing && segLeading;
54
- if (both) {
55
- path += seg.slice(1);
56
- } else {
57
- path += pathTrailing || segLeading ? seg : `/${seg}`;
58
- }
59
- } else {
60
- path += seg;
61
- }
62
- }
63
- return correctPaths(path);
64
- };
65
- function cwd() {
66
- if (typeof process !== "undefined" && typeof process.cwd === "function") {
67
- return process.cwd().replace(/\\/g, "/");
68
- }
69
- return "/";
70
- }
71
- const resolve = function(...arguments_) {
72
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
73
- let resolvedPath = "";
74
- let resolvedAbsolute = false;
75
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
76
- const path = index >= 0 ? arguments_[index] : cwd();
77
- if (!path || path.length === 0) {
78
- continue;
79
- }
80
- resolvedPath = `${path}/${resolvedPath}`;
81
- resolvedAbsolute = isAbsolute(path);
82
- }
83
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
84
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
85
- return `/${resolvedPath}`;
86
- }
87
- return resolvedPath.length > 0 ? resolvedPath : ".";
88
- };
89
- function normalizeString(path, allowAboveRoot) {
90
- let res = "";
91
- let lastSegmentLength = 0;
92
- let lastSlash = -1;
93
- let dots = 0;
94
- let char = null;
95
- for (let index = 0; index <= path.length; ++index) {
96
- if (index < path.length) {
97
- char = path[index];
98
- } else if (char === "/") {
99
- break;
100
- } else {
101
- char = "/";
102
- }
103
- if (char === "/") {
104
- if (lastSlash === index - 1 || dots === 1) {
105
- } else if (dots === 2) {
106
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
107
- if (res.length > 2) {
108
- const lastSlashIndex = res.lastIndexOf("/");
109
- if (lastSlashIndex === -1) {
110
- res = "";
111
- lastSegmentLength = 0;
112
- } else {
113
- res = res.slice(0, lastSlashIndex);
114
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
115
- }
116
- lastSlash = index;
117
- dots = 0;
118
- continue;
119
- } else if (res.length > 0) {
120
- res = "";
121
- lastSegmentLength = 0;
122
- lastSlash = index;
123
- dots = 0;
124
- continue;
125
- }
126
- }
127
- if (allowAboveRoot) {
128
- res += res.length > 0 ? "/.." : "..";
129
- lastSegmentLength = 2;
130
- }
131
- } else {
132
- if (res.length > 0) {
133
- res += `/${path.slice(lastSlash + 1, index)}`;
134
- } else {
135
- res = path.slice(lastSlash + 1, index);
136
- }
137
- lastSegmentLength = index - lastSlash - 1;
138
- }
139
- lastSlash = index;
140
- dots = 0;
141
- } else if (char === "." && dots !== -1) {
142
- ++dots;
143
- } else {
144
- dots = -1;
145
- }
146
- }
147
- return res;
148
- }
149
- const isAbsolute = function(p) {
150
- return _IS_ABSOLUTE_RE.test(p);
151
- };
152
- const toNamespacedPath = function(p) {
153
- return normalizeWindowsPath(p);
154
- };
155
- const extname = function(p) {
156
- if (p === "..") return "";
157
- const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
158
- return match && match[1] || "";
159
- };
160
- const relative = function(from, to) {
161
- const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
162
- const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
163
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
164
- return _to.join("/");
165
- }
166
- const _fromCopy = [..._from];
167
- for (const segment of _fromCopy) {
168
- if (_to[0] !== segment) {
169
- break;
170
- }
171
- _from.shift();
172
- _to.shift();
173
- }
174
- return [..._from.map(() => ".."), ..._to].join("/");
175
- };
176
- const dirname = function(p) {
177
- const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
178
- if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
179
- segments[0] += "/";
180
- }
181
- return segments.join("/") || (isAbsolute(p) ? "/" : ".");
182
- };
183
- const format = function(p) {
184
- const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
185
- const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
186
- Boolean
187
- );
188
- return normalizeWindowsPath(
189
- p.root ? resolve(...segments) : segments.join("/")
190
- );
191
- };
192
- const basename = function(p, extension) {
193
- const segments = normalizeWindowsPath(p).split("/");
194
- let lastSegment = "";
195
- for (let i = segments.length - 1; i >= 0; i--) {
196
- const val = segments[i];
197
- if (val) {
198
- lastSegment = val;
199
- break;
200
- }
201
- }
202
- return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
203
- };
204
- const parse = function(p) {
205
- const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
206
- const base = basename(p);
207
- const extension = extname(base);
208
- return {
209
- root,
210
- dir: dirname(p),
211
- base,
212
- ext: extension,
213
- name: base.slice(0, base.length - extension.length)
214
- };
215
- };
216
- export {
217
- basename,
218
- correctPaths,
219
- dirname,
220
- extname,
221
- format,
222
- isAbsolute,
223
- joinPaths,
224
- normalizeString,
225
- normalizeWindowsPath,
226
- parse,
227
- relative,
228
- resolve,
229
- sep,
230
- toNamespacedPath
231
- };
@@ -1,33 +0,0 @@
1
- import { normalizeWindowsPath } from "./correct-paths";
2
- const removeExtension = (filePath) => {
3
- const result = !filePath || (filePath?.match(/./g) || []).length <= 1 ? "." : filePath.lastIndexOf(".") ? filePath.substring(0, filePath.lastIndexOf(".")) : filePath;
4
- if (result.startsWith("./")) {
5
- return result.substring(2);
6
- }
7
- if (result.startsWith(".") || result.startsWith("/")) {
8
- return result.substring(1);
9
- }
10
- return result;
11
- };
12
- function findFileName(filePath, { requireExtension, withExtension } = {}) {
13
- const result = normalizeWindowsPath(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
14
- if (requireExtension === true && !result.includes(".")) {
15
- return "";
16
- }
17
- if (withExtension === false && result.includes(".")) {
18
- return result.split(".").slice(-1).join(".") || "";
19
- }
20
- return result;
21
- }
22
- function findFilePath(filePath) {
23
- const normalizedPath = normalizeWindowsPath(filePath);
24
- return normalizedPath.replace(
25
- findFileName(normalizedPath, { requireExtension: true }),
26
- ""
27
- );
28
- }
29
- export {
30
- findFileName,
31
- findFilePath,
32
- removeExtension
33
- };
@@ -1,23 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { join } from "node:path";
3
- const MAX_PATH_SEARCH_DEPTH = 30;
4
- let depth = 0;
5
- function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
6
- const _startPath = startPath ?? process.cwd();
7
- if (endDirectoryNames.some(
8
- (endDirName) => existsSync(join(_startPath, endDirName))
9
- )) {
10
- return _startPath;
11
- }
12
- if (endFileNames.some((endFileName) => existsSync(join(_startPath, endFileName)))) {
13
- return _startPath;
14
- }
15
- if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
16
- const parent = join(_startPath, "..");
17
- return findFolderUp(parent, endFileNames, endDirectoryNames);
18
- }
19
- return void 0;
20
- }
21
- export {
22
- findFolderUp
23
- };
@@ -1,77 +0,0 @@
1
- import { correctPaths } from "./correct-paths";
2
- import { findFolderUp } from "./find-up";
3
- const rootFiles = [
4
- "storm-workspace.json",
5
- "storm-workspace.yaml",
6
- "storm-workspace.yml",
7
- "storm-workspace.js",
8
- "storm-workspace.ts",
9
- ".storm-workspace.json",
10
- ".storm-workspace.yaml",
11
- ".storm-workspace.yml",
12
- ".storm-workspace.js",
13
- ".storm-workspace.ts",
14
- "lerna.json",
15
- "nx.json",
16
- "turbo.json",
17
- "npm-workspace.json",
18
- "yarn-workspace.json",
19
- "pnpm-workspace.json",
20
- "npm-workspace.yaml",
21
- "yarn-workspace.yaml",
22
- "pnpm-workspace.yaml",
23
- "npm-workspace.yml",
24
- "yarn-workspace.yml",
25
- "pnpm-workspace.yml",
26
- "npm-lock.json",
27
- "yarn-lock.json",
28
- "pnpm-lock.json",
29
- "npm-lock.yaml",
30
- "yarn-lock.yaml",
31
- "pnpm-lock.yaml",
32
- "npm-lock.yml",
33
- "yarn-lock.yml",
34
- "pnpm-lock.yml",
35
- "bun.lockb",
36
- "bun.lock",
37
- "bunfig.toml"
38
- ];
39
- const rootDirectories = [
40
- ".storm-workspace",
41
- ".nx",
42
- ".git",
43
- ".github",
44
- ".vscode",
45
- ".verdaccio"
46
- ];
47
- function findWorkspaceRootSafe(pathInsideMonorepo) {
48
- if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
49
- return correctPaths(
50
- process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH
51
- );
52
- }
53
- return correctPaths(
54
- findFolderUp(
55
- pathInsideMonorepo ?? process.cwd(),
56
- rootFiles,
57
- rootDirectories
58
- )
59
- );
60
- }
61
- function findWorkspaceRoot(pathInsideMonorepo) {
62
- const result = findWorkspaceRootSafe(pathInsideMonorepo);
63
- if (!result) {
64
- throw new Error(
65
- `Cannot find workspace root upwards from known path. Files search list includes:
66
- ${rootFiles.join(
67
- "\n"
68
- )}
69
- Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
70
- );
71
- }
72
- return result;
73
- }
74
- export {
75
- findWorkspaceRoot,
76
- findWorkspaceRootSafe
77
- };
@@ -1,95 +0,0 @@
1
- import {
2
- STORM_DEFAULT_ERROR_CODES_FILE,
3
- STORM_DEFAULT_LICENSE
4
- } from "@storm-software/config";
5
- import { existsSync } from "node:fs";
6
- import { readFile } from "node:fs/promises";
7
- import { join } from "node:path";
8
- import { joinPaths } from "./correct-paths";
9
- import { findWorkspaceRoot } from "./find-workspace-root";
10
- async function getPackageJsonConfig(root) {
11
- let license = STORM_DEFAULT_LICENSE;
12
- let homepage = void 0;
13
- let support = void 0;
14
- let name = void 0;
15
- let namespace = void 0;
16
- let repository = void 0;
17
- const workspaceRoot = findWorkspaceRoot(root);
18
- if (existsSync(join(workspaceRoot, "package.json"))) {
19
- const file = await readFile(
20
- joinPaths(workspaceRoot, "package.json"),
21
- "utf8"
22
- );
23
- if (file) {
24
- const packageJson = JSON.parse(file);
25
- if (packageJson.name) {
26
- name = packageJson.name;
27
- }
28
- if (packageJson.namespace) {
29
- namespace = packageJson.namespace;
30
- }
31
- if (packageJson.repository) {
32
- if (typeof packageJson.repository === "string") {
33
- repository = packageJson.repository;
34
- } else if (packageJson.repository.url) {
35
- repository = packageJson.repository.url;
36
- }
37
- }
38
- if (packageJson.license) {
39
- license = packageJson.license;
40
- }
41
- if (packageJson.homepage) {
42
- homepage = packageJson.homepage;
43
- }
44
- if (packageJson.bugs) {
45
- if (typeof packageJson.bugs === "string") {
46
- support = packageJson.bugs;
47
- } else if (packageJson.bugs.url) {
48
- support = packageJson.bugs.url;
49
- }
50
- }
51
- }
52
- }
53
- return {
54
- workspaceRoot,
55
- name,
56
- namespace,
57
- repository,
58
- license,
59
- homepage,
60
- support
61
- };
62
- }
63
- function applyDefaultConfig(config) {
64
- if (!config.support && config.contact) {
65
- config.support = config.contact;
66
- }
67
- if (!config.contact && config.support) {
68
- config.contact = config.support;
69
- }
70
- if (config.homepage) {
71
- if (!config.docs) {
72
- config.docs = `${config.homepage}/docs`;
73
- }
74
- if (!config.license) {
75
- config.license = `${config.homepage}/license`;
76
- }
77
- if (!config.support) {
78
- config.support = `${config.homepage}/support`;
79
- }
80
- if (!config.contact) {
81
- config.contact = `${config.homepage}/contact`;
82
- }
83
- if (!config.error?.codesFile || !config?.error?.url) {
84
- config.error ??= { codesFile: STORM_DEFAULT_ERROR_CODES_FILE };
85
- if (config.homepage) {
86
- config.error.url ??= `${config.homepage}/errors`;
87
- }
88
- }
89
- }
90
- return config;
91
- }
92
- export {
93
- applyDefaultConfig,
94
- getPackageJsonConfig
95
- };
@@ -1,14 +0,0 @@
1
- export { applyWorkspaceBaseTokens, applyWorkspaceProjectTokens, applyWorkspaceTokens } from './apply-workspace-tokens.js';
2
- export { DEFAULT_COLOR_CONFIG, getColor, getColors, getGradient } from './colors.js';
3
- export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath } from './correct-paths.js';
4
- export { FindFileNameOptions, findFileName, findFilePath, removeExtension } from './file-path-utils.js';
5
- export { findWorkspaceRoot, findWorkspaceRootSafe } from './find-workspace-root.js';
6
- export { applyDefaultConfig, getPackageJsonConfig } from './get-default-config.js';
7
- export { exitWithError, exitWithSuccess, handleProcess } from './process-handler.js';
8
- export { IOType, LARGE_BUFFER, StdioOptions, run, runAsync } from './run.js';
9
- export { CargoMetadata, CargoToml, Dep, DepKind, Dependency, Docs, Docs2, Features, Metadata, Metadata2, Node, Package, Resolve, Rs, Rs2, Target, Tree, modifyCargoNestedTable, modifyCargoTable, parseCargoToml, parseCargoTomlWithTree, stringifyCargoToml } from './toml.js';
10
- import '../types.js';
11
- import '@storm-software/config';
12
- import '@storm-software/config/types';
13
- import 'node:path';
14
- import 'node:child_process';
@@ -1,9 +0,0 @@
1
- export * from "./apply-workspace-tokens";
2
- export * from "./colors";
3
- export * from "./correct-paths";
4
- export * from "./file-path-utils";
5
- export * from "./find-workspace-root";
6
- export * from "./get-default-config";
7
- export * from "./process-handler";
8
- export * from "./run";
9
- export * from "./toml";
@@ -1,7 +0,0 @@
1
- import { StormWorkspaceConfig } from '@storm-software/config';
2
-
3
- declare const exitWithError: (config?: Partial<StormWorkspaceConfig>) => never;
4
- declare const exitWithSuccess: (config?: Partial<StormWorkspaceConfig>) => never;
5
- declare const handleProcess: (config?: Partial<StormWorkspaceConfig>) => void;
6
-
7
- export { exitWithError, exitWithSuccess, handleProcess };
@@ -1,53 +0,0 @@
1
- import {
2
- writeError,
3
- writeFatal,
4
- writeSuccess,
5
- writeTrace
6
- } from "../logger/console";
7
- const exitWithError = (config) => {
8
- writeFatal("Exiting script with an error status...", config);
9
- process.exit(1);
10
- };
11
- const exitWithSuccess = (config) => {
12
- writeSuccess("Script completed successfully. Exiting...", config);
13
- process.exit(0);
14
- };
15
- const handleProcess = (config) => {
16
- writeTrace(
17
- `Using the following arguments to process the script: ${process.argv.join(", ")}`,
18
- config
19
- );
20
- process.on("unhandledRejection", (error) => {
21
- writeError(
22
- `An Unhandled Rejection occurred while running the program: ${error && typeof error === "object" && "message" in error && error?.message ? error.message : typeof error === "string" ? error : "Unknown error"}
23
- Stacktrace: ${error && typeof error === "object" && "stack" in error && error?.stack ? error.stack : ""}`,
24
- config
25
- );
26
- exitWithError(config);
27
- });
28
- process.on("uncaughtException", (error) => {
29
- writeError(
30
- `An Uncaught Exception occurred while running the program: ${error && typeof error === "object" && "message" in error && error?.message ? error.message : typeof error === "string" ? error : "Unknown error"}
31
- Stacktrace: ${error && typeof error === "object" && "stack" in error && error?.stack ? error.stack : ""}`,
32
- config
33
- );
34
- exitWithError(config);
35
- });
36
- process.on("SIGTERM", (signal) => {
37
- writeError(`The program terminated with signal code: ${signal}`, config);
38
- exitWithError(config);
39
- });
40
- process.on("SIGINT", (signal) => {
41
- writeError(`The program terminated with signal code: ${signal}`, config);
42
- exitWithError(config);
43
- });
44
- process.on("SIGHUP", (signal) => {
45
- writeError(`The program terminated with signal code: ${signal}`, config);
46
- exitWithError(config);
47
- });
48
- };
49
- export {
50
- exitWithError,
51
- exitWithSuccess,
52
- handleProcess
53
- };
@@ -1,38 +0,0 @@
1
- import { exec, execSync } from "node:child_process";
2
- const LARGE_BUFFER = 1024 * 1e6;
3
- const run = (config, command, cwd = config.workspaceRoot ?? process.cwd(), stdio = "inherit", env = process.env) => {
4
- return execSync(command, {
5
- cwd,
6
- env: {
7
- ...process.env,
8
- ...env,
9
- CLICOLOR: "true",
10
- FORCE_COLOR: "true"
11
- },
12
- windowsHide: true,
13
- stdio,
14
- maxBuffer: LARGE_BUFFER,
15
- killSignal: "SIGTERM",
16
- encoding: "utf8"
17
- });
18
- };
19
- const runAsync = (config, command, cwd = config.workspaceRoot ?? process.cwd(), env = process.env) => {
20
- return exec(command, {
21
- cwd,
22
- env: {
23
- ...process.env,
24
- ...env,
25
- CLICOLOR: "true",
26
- FORCE_COLOR: "true"
27
- },
28
- windowsHide: true,
29
- maxBuffer: LARGE_BUFFER,
30
- killSignal: "SIGTERM",
31
- encoding: "utf8"
32
- });
33
- };
34
- export {
35
- LARGE_BUFFER,
36
- run,
37
- runAsync
38
- };