@storm-software/config-tools 1.7.0 → 1.8.0
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/declarations.d.ts +2 -22
- package/index.cjs +26 -129
- package/index.js +26 -127
- package/meta.cjs.json +1 -1
- package/meta.esm.json +1 -1
- package/package.json +1 -1
- package/utilities/find-workspace-root.cjs +19 -135
- package/utilities/find-workspace-root.js +18 -122
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.7.1](https://github.com/storm-software/storm-ops/compare/config-tools-v1.7.0...config-tools-v1.7.1) (2023-12-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **config-tools:** Resolved issues with returned values in `findWorkspaceRoot` functions ([c790e15](https://github.com/storm-software/storm-ops/commit/c790e151ec130b4a72d17b965092c402c685d824))
|
|
7
|
+
|
|
8
|
+
# [1.7.0](https://github.com/storm-software/storm-ops/compare/config-tools-v1.6.1...config-tools-v1.7.0) (2023-12-21)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **config-tools:** Added the `findWorkspaceRootSync` and `findWorkspaceRootSafeSync` functions ([59e0ee4](https://github.com/storm-software/storm-ops/commit/59e0ee4779a15752fb035d235b929bb3e8ecc974))
|
|
14
|
+
|
|
1
15
|
## [1.6.1](https://github.com/storm-software/storm-ops/compare/config-tools-v1.6.0...config-tools-v1.6.1) (2023-12-21)
|
|
2
16
|
|
|
3
17
|
|
package/declarations.d.ts
CHANGED
|
@@ -22,27 +22,7 @@ export { StormConfig };
|
|
|
22
22
|
*
|
|
23
23
|
* @param pathInsideMonorepo - The path inside the monorepo
|
|
24
24
|
*/
|
|
25
|
-
declare function findWorkspaceRoot(
|
|
26
|
-
pathInsideMonorepo?: string
|
|
27
|
-
): Promise<string>;
|
|
28
|
-
export { findWorkspaceRoot };
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Find the root of the current monorepo safely (do not throw an error if it cannot be found)
|
|
32
|
-
*
|
|
33
|
-
* @param pathInsideMonorepo - The path inside the monorepo
|
|
34
|
-
*/
|
|
35
|
-
declare function findWorkspaceRootSafe(
|
|
36
|
-
pathInsideMonorepo?: string
|
|
37
|
-
): Promise<string | undefined>;
|
|
38
|
-
export { findWorkspaceRootSafe };
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Find the root of the current monorepo
|
|
42
|
-
*
|
|
43
|
-
* @param pathInsideMonorepo - The path inside the monorepo
|
|
44
|
-
*/
|
|
45
|
-
declare function findWorkspaceRootSync(pathInsideMonorepo?: string): string;
|
|
25
|
+
declare function findWorkspaceRoot(pathInsideMonorepo?: string): string;
|
|
46
26
|
export { findWorkspaceRootSync };
|
|
47
27
|
|
|
48
28
|
/**
|
|
@@ -50,7 +30,7 @@ export { findWorkspaceRootSync };
|
|
|
50
30
|
*
|
|
51
31
|
* @param pathInsideMonorepo - The path inside the monorepo
|
|
52
32
|
*/
|
|
53
|
-
declare function
|
|
33
|
+
declare function findWorkspaceRootSafe(
|
|
54
34
|
pathInsideMonorepo?: string
|
|
55
35
|
): string | undefined;
|
|
56
36
|
export { findWorkspaceRootSafeSync };
|
package/index.cjs
CHANGED
|
@@ -40,8 +40,6 @@ __export(src_exports, {
|
|
|
40
40
|
createStormConfig: () => createStormConfig,
|
|
41
41
|
findWorkspaceRoot: () => findWorkspaceRoot,
|
|
42
42
|
findWorkspaceRootSafe: () => findWorkspaceRootSafe,
|
|
43
|
-
findWorkspaceRootSafeSync: () => findWorkspaceRootSafeSync,
|
|
44
|
-
findWorkspaceRootSync: () => findWorkspaceRootSync,
|
|
45
43
|
getConfigEnv: () => getConfigEnv,
|
|
46
44
|
getConfigFile: () => getConfigFile,
|
|
47
45
|
getDefaultConfig: () => getDefaultConfig,
|
|
@@ -111,101 +109,20 @@ var LogLevelLabel = {
|
|
|
111
109
|
};
|
|
112
110
|
|
|
113
111
|
// packages/config-tools/src/utilities/find-up.ts
|
|
114
|
-
var
|
|
115
|
-
var
|
|
116
|
-
var
|
|
117
|
-
var
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const foundPath = names(options.cwd);
|
|
128
|
-
return (0, import_locate_path.locatePathSync)([foundPath], { ...options, cwd: directory });
|
|
129
|
-
}
|
|
130
|
-
const runNameMatcher = async (name) => {
|
|
131
|
-
const paths = [name].flat();
|
|
132
|
-
const runMatcher = async (locateOptions) => {
|
|
133
|
-
if (typeof name !== "function") {
|
|
134
|
-
return (0, import_locate_path.locatePath)(paths, locateOptions);
|
|
135
|
-
}
|
|
136
|
-
const foundPath = await name(locateOptions.cwd);
|
|
137
|
-
if (typeof foundPath === "string") {
|
|
138
|
-
return (0, import_locate_path.locatePath)([foundPath], locateOptions);
|
|
139
|
-
}
|
|
140
|
-
return foundPath;
|
|
141
|
-
};
|
|
142
|
-
const matches = [];
|
|
143
|
-
while (true) {
|
|
144
|
-
console.debug(
|
|
145
|
-
`Searching for workspace root files in ${directory}
|
|
146
|
-
Options: ${JSON.stringify(
|
|
147
|
-
options
|
|
148
|
-
)}`
|
|
149
|
-
);
|
|
150
|
-
const foundPath = await runMatcher({ ...options, cwd: directory });
|
|
151
|
-
console.debug(`Found path specified at ${foundPath}`);
|
|
152
|
-
if (foundPath) {
|
|
153
|
-
matches.push(path.resolve(directory, foundPath));
|
|
154
|
-
}
|
|
155
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
directory = path.dirname(directory);
|
|
159
|
-
}
|
|
160
|
-
return matches;
|
|
161
|
-
};
|
|
162
|
-
return (await Promise.allSettled(
|
|
163
|
-
(names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name))
|
|
164
|
-
)).flat();
|
|
165
|
-
}
|
|
166
|
-
function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
167
|
-
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
168
|
-
const { root } = path.parse(directory);
|
|
169
|
-
const stopAt = path.resolve(directory, toPath(options.stopAt) ?? root);
|
|
170
|
-
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
171
|
-
if (typeof names === "function") {
|
|
172
|
-
const foundPath = names(options.cwd);
|
|
173
|
-
return (0, import_locate_path.locatePathSync)([foundPath], options);
|
|
112
|
+
var import_fs = require("fs");
|
|
113
|
+
var import_path = require("path");
|
|
114
|
+
var MAX_PATH_SEARCH_DEPTH = 30;
|
|
115
|
+
var depth = 0;
|
|
116
|
+
function findFolderUp(startPath, endFileNames) {
|
|
117
|
+
startPath = startPath ?? process.cwd();
|
|
118
|
+
if (endFileNames.some((endFileName) => (0, import_fs.existsSync)((0, import_path.join)(startPath, endFileName)))) {
|
|
119
|
+
return startPath;
|
|
120
|
+
} else if (startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
121
|
+
const parent = (0, import_path.join)(startPath, "..");
|
|
122
|
+
return findFolderUp(parent, endFileNames);
|
|
123
|
+
} else {
|
|
124
|
+
return void 0;
|
|
174
125
|
}
|
|
175
|
-
const runNameMatcher = (name) => {
|
|
176
|
-
const paths = [name].flat();
|
|
177
|
-
const runMatcher = (locateOptions) => {
|
|
178
|
-
if (typeof name !== "function") {
|
|
179
|
-
return (0, import_locate_path.locatePathSync)(paths, locateOptions);
|
|
180
|
-
}
|
|
181
|
-
const foundPath = name(locateOptions.cwd);
|
|
182
|
-
if (typeof foundPath === "string") {
|
|
183
|
-
return (0, import_locate_path.locatePathSync)([foundPath], locateOptions);
|
|
184
|
-
}
|
|
185
|
-
return foundPath;
|
|
186
|
-
};
|
|
187
|
-
const matches = [];
|
|
188
|
-
while (true) {
|
|
189
|
-
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
190
|
-
if (foundPath) {
|
|
191
|
-
matches.push(path.resolve(directory, foundPath));
|
|
192
|
-
}
|
|
193
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
directory = path.dirname(directory);
|
|
197
|
-
}
|
|
198
|
-
return matches;
|
|
199
|
-
};
|
|
200
|
-
return (names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name)).flat();
|
|
201
|
-
}
|
|
202
|
-
async function findUp(names, options = { limit: 1, type: "file" }) {
|
|
203
|
-
const matches = await findUpMultiple(names, options);
|
|
204
|
-
return matches[0];
|
|
205
|
-
}
|
|
206
|
-
function findUpSync(names, options = { limit: 1, type: "file" }) {
|
|
207
|
-
const matches = findUpMultipleSync(names, options);
|
|
208
|
-
return matches[0];
|
|
209
126
|
}
|
|
210
127
|
|
|
211
128
|
// packages/config-tools/src/utilities/find-workspace-root.ts
|
|
@@ -234,18 +151,10 @@ var rootFiles = [
|
|
|
234
151
|
"bun.lockb"
|
|
235
152
|
];
|
|
236
153
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
function findWorkspaceRootSafeSync(pathInsideMonorepo) {
|
|
244
|
-
return process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.env.NX_WORKSPACE_ROOT_PATH ? process.env.NX_WORKSPACE_ROOT_PATH : findUpSync(rootFiles, {
|
|
245
|
-
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
246
|
-
type: "file",
|
|
247
|
-
limit: 1
|
|
248
|
-
});
|
|
154
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
155
|
+
return process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH;
|
|
156
|
+
}
|
|
157
|
+
return findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles);
|
|
249
158
|
}
|
|
250
159
|
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
251
160
|
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
@@ -260,23 +169,10 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
|
260
169
|
}
|
|
261
170
|
return result;
|
|
262
171
|
}
|
|
263
|
-
function findWorkspaceRootSync(pathInsideMonorepo) {
|
|
264
|
-
const result = findWorkspaceRootSafeSync(pathInsideMonorepo);
|
|
265
|
-
if (!result) {
|
|
266
|
-
throw new Error(
|
|
267
|
-
`Cannot find workspace root upwards from known path. Files search list includes:
|
|
268
|
-
${rootFiles.join(
|
|
269
|
-
"\n"
|
|
270
|
-
)}
|
|
271
|
-
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
return result;
|
|
275
|
-
}
|
|
276
172
|
|
|
277
173
|
// packages/config-tools/src/utilities/get-default-config.ts
|
|
278
|
-
var
|
|
279
|
-
var
|
|
174
|
+
var import_fs2 = require("fs");
|
|
175
|
+
var import_path2 = require("path");
|
|
280
176
|
|
|
281
177
|
// packages/config-tools/src/schema.ts
|
|
282
178
|
var z = __toESM(require("zod"), 1);
|
|
@@ -315,6 +211,7 @@ var StormConfigSchema = z.object({
|
|
|
315
211
|
runtimeVersion: z.string().trim().regex(
|
|
316
212
|
/^(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-]+)*))?$/
|
|
317
213
|
).default("1.0.0").describe("The global version of the Storm runtime"),
|
|
214
|
+
packageManager: z.enum(["npm", "yarn", "pnpm", "bun"]).default("npm").describe("The package manager used by the repository"),
|
|
318
215
|
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
319
216
|
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
320
217
|
logLevel: z.enum(["silent", "fatal", "error", "warn", "info", "debug", "trace"]).optional().describe(
|
|
@@ -342,6 +239,7 @@ var DefaultColorConfig = {
|
|
|
342
239
|
fatal: "#7d1a1a"
|
|
343
240
|
};
|
|
344
241
|
var DefaultStormConfig = {
|
|
242
|
+
name: "storm-workspace",
|
|
345
243
|
namespace: "storm-software",
|
|
346
244
|
license: "Apache License 2.0",
|
|
347
245
|
homepage: "https://stormsoftware.org",
|
|
@@ -349,6 +247,7 @@ var DefaultStormConfig = {
|
|
|
349
247
|
owner: "@storm-software/development",
|
|
350
248
|
worker: "stormie-bot",
|
|
351
249
|
runtimeDirectory: "node_modules/.storm",
|
|
250
|
+
packageManager: "npm",
|
|
352
251
|
timezone: "America/New_York",
|
|
353
252
|
locale: "en-US",
|
|
354
253
|
env: "production",
|
|
@@ -363,12 +262,12 @@ var DefaultStormConfig = {
|
|
|
363
262
|
var getDefaultConfig = (config = {}, root) => {
|
|
364
263
|
let name = "storm-workspace";
|
|
365
264
|
let namespace = "storm-software";
|
|
366
|
-
let repository = "https://github.com/storm-software/storm-
|
|
265
|
+
let repository = "https://github.com/storm-software/storm-ops";
|
|
367
266
|
let license = DefaultStormConfig.license;
|
|
368
267
|
let homepage = DefaultStormConfig.homepage;
|
|
369
|
-
const workspaceRoot =
|
|
370
|
-
if ((0,
|
|
371
|
-
const file = (0,
|
|
268
|
+
const workspaceRoot = findWorkspaceRoot(root);
|
|
269
|
+
if ((0, import_fs2.existsSync)((0, import_path2.join)(workspaceRoot, "package.json"))) {
|
|
270
|
+
const file = (0, import_fs2.readFileSync)((0, import_path2.join)(workspaceRoot, "package.json"), {
|
|
372
271
|
encoding: "utf-8"
|
|
373
272
|
});
|
|
374
273
|
if (file) {
|
|
@@ -623,8 +522,6 @@ var setConfigEnv = (config) => {
|
|
|
623
522
|
createStormConfig,
|
|
624
523
|
findWorkspaceRoot,
|
|
625
524
|
findWorkspaceRootSafe,
|
|
626
|
-
findWorkspaceRootSafeSync,
|
|
627
|
-
findWorkspaceRootSync,
|
|
628
525
|
getConfigEnv,
|
|
629
526
|
getConfigFile,
|
|
630
527
|
getDefaultConfig,
|
package/index.js
CHANGED
|
@@ -56,101 +56,20 @@ var LogLevelLabel = {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
// packages/config-tools/src/utilities/find-up.ts
|
|
59
|
-
import {
|
|
60
|
-
import
|
|
61
|
-
|
|
62
|
-
var
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const foundPath = names(options.cwd);
|
|
73
|
-
return locatePathSync([foundPath], { ...options, cwd: directory });
|
|
74
|
-
}
|
|
75
|
-
const runNameMatcher = async (name) => {
|
|
76
|
-
const paths = [name].flat();
|
|
77
|
-
const runMatcher = async (locateOptions) => {
|
|
78
|
-
if (typeof name !== "function") {
|
|
79
|
-
return locatePath(paths, locateOptions);
|
|
80
|
-
}
|
|
81
|
-
const foundPath = await name(locateOptions.cwd);
|
|
82
|
-
if (typeof foundPath === "string") {
|
|
83
|
-
return locatePath([foundPath], locateOptions);
|
|
84
|
-
}
|
|
85
|
-
return foundPath;
|
|
86
|
-
};
|
|
87
|
-
const matches = [];
|
|
88
|
-
while (true) {
|
|
89
|
-
console.debug(
|
|
90
|
-
`Searching for workspace root files in ${directory}
|
|
91
|
-
Options: ${JSON.stringify(
|
|
92
|
-
options
|
|
93
|
-
)}`
|
|
94
|
-
);
|
|
95
|
-
const foundPath = await runMatcher({ ...options, cwd: directory });
|
|
96
|
-
console.debug(`Found path specified at ${foundPath}`);
|
|
97
|
-
if (foundPath) {
|
|
98
|
-
matches.push(path.resolve(directory, foundPath));
|
|
99
|
-
}
|
|
100
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
directory = path.dirname(directory);
|
|
104
|
-
}
|
|
105
|
-
return matches;
|
|
106
|
-
};
|
|
107
|
-
return (await Promise.allSettled(
|
|
108
|
-
(names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name))
|
|
109
|
-
)).flat();
|
|
110
|
-
}
|
|
111
|
-
function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
112
|
-
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
113
|
-
const { root } = path.parse(directory);
|
|
114
|
-
const stopAt = path.resolve(directory, toPath(options.stopAt) ?? root);
|
|
115
|
-
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
116
|
-
if (typeof names === "function") {
|
|
117
|
-
const foundPath = names(options.cwd);
|
|
118
|
-
return locatePathSync([foundPath], options);
|
|
59
|
+
import { existsSync } from "fs";
|
|
60
|
+
import { join } from "path";
|
|
61
|
+
var MAX_PATH_SEARCH_DEPTH = 30;
|
|
62
|
+
var depth = 0;
|
|
63
|
+
function findFolderUp(startPath, endFileNames) {
|
|
64
|
+
startPath = startPath ?? process.cwd();
|
|
65
|
+
if (endFileNames.some((endFileName) => existsSync(join(startPath, endFileName)))) {
|
|
66
|
+
return startPath;
|
|
67
|
+
} else if (startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
68
|
+
const parent = join(startPath, "..");
|
|
69
|
+
return findFolderUp(parent, endFileNames);
|
|
70
|
+
} else {
|
|
71
|
+
return void 0;
|
|
119
72
|
}
|
|
120
|
-
const runNameMatcher = (name) => {
|
|
121
|
-
const paths = [name].flat();
|
|
122
|
-
const runMatcher = (locateOptions) => {
|
|
123
|
-
if (typeof name !== "function") {
|
|
124
|
-
return locatePathSync(paths, locateOptions);
|
|
125
|
-
}
|
|
126
|
-
const foundPath = name(locateOptions.cwd);
|
|
127
|
-
if (typeof foundPath === "string") {
|
|
128
|
-
return locatePathSync([foundPath], locateOptions);
|
|
129
|
-
}
|
|
130
|
-
return foundPath;
|
|
131
|
-
};
|
|
132
|
-
const matches = [];
|
|
133
|
-
while (true) {
|
|
134
|
-
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
135
|
-
if (foundPath) {
|
|
136
|
-
matches.push(path.resolve(directory, foundPath));
|
|
137
|
-
}
|
|
138
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
directory = path.dirname(directory);
|
|
142
|
-
}
|
|
143
|
-
return matches;
|
|
144
|
-
};
|
|
145
|
-
return (names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name)).flat();
|
|
146
|
-
}
|
|
147
|
-
async function findUp(names, options = { limit: 1, type: "file" }) {
|
|
148
|
-
const matches = await findUpMultiple(names, options);
|
|
149
|
-
return matches[0];
|
|
150
|
-
}
|
|
151
|
-
function findUpSync(names, options = { limit: 1, type: "file" }) {
|
|
152
|
-
const matches = findUpMultipleSync(names, options);
|
|
153
|
-
return matches[0];
|
|
154
73
|
}
|
|
155
74
|
|
|
156
75
|
// packages/config-tools/src/utilities/find-workspace-root.ts
|
|
@@ -179,18 +98,10 @@ var rootFiles = [
|
|
|
179
98
|
"bun.lockb"
|
|
180
99
|
];
|
|
181
100
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
function findWorkspaceRootSafeSync(pathInsideMonorepo) {
|
|
189
|
-
return process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.env.NX_WORKSPACE_ROOT_PATH ? process.env.NX_WORKSPACE_ROOT_PATH : findUpSync(rootFiles, {
|
|
190
|
-
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
191
|
-
type: "file",
|
|
192
|
-
limit: 1
|
|
193
|
-
});
|
|
101
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
102
|
+
return process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH;
|
|
103
|
+
}
|
|
104
|
+
return findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles);
|
|
194
105
|
}
|
|
195
106
|
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
196
107
|
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
@@ -205,23 +116,10 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
|
205
116
|
}
|
|
206
117
|
return result;
|
|
207
118
|
}
|
|
208
|
-
function findWorkspaceRootSync(pathInsideMonorepo) {
|
|
209
|
-
const result = findWorkspaceRootSafeSync(pathInsideMonorepo);
|
|
210
|
-
if (!result) {
|
|
211
|
-
throw new Error(
|
|
212
|
-
`Cannot find workspace root upwards from known path. Files search list includes:
|
|
213
|
-
${rootFiles.join(
|
|
214
|
-
"\n"
|
|
215
|
-
)}
|
|
216
|
-
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
221
119
|
|
|
222
120
|
// packages/config-tools/src/utilities/get-default-config.ts
|
|
223
|
-
import { existsSync, readFileSync } from "fs";
|
|
224
|
-
import { join } from "path";
|
|
121
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
122
|
+
import { join as join2 } from "path";
|
|
225
123
|
|
|
226
124
|
// packages/config-tools/src/schema.ts
|
|
227
125
|
import * as z from "zod";
|
|
@@ -260,6 +158,7 @@ var StormConfigSchema = z.object({
|
|
|
260
158
|
runtimeVersion: z.string().trim().regex(
|
|
261
159
|
/^(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-]+)*))?$/
|
|
262
160
|
).default("1.0.0").describe("The global version of the Storm runtime"),
|
|
161
|
+
packageManager: z.enum(["npm", "yarn", "pnpm", "bun"]).default("npm").describe("The package manager used by the repository"),
|
|
263
162
|
timezone: z.string().trim().default("America/New_York").describe("The default timezone of the workspace"),
|
|
264
163
|
locale: z.string().trim().default("en-US").describe("The default locale of the workspace"),
|
|
265
164
|
logLevel: z.enum(["silent", "fatal", "error", "warn", "info", "debug", "trace"]).optional().describe(
|
|
@@ -287,6 +186,7 @@ var DefaultColorConfig = {
|
|
|
287
186
|
fatal: "#7d1a1a"
|
|
288
187
|
};
|
|
289
188
|
var DefaultStormConfig = {
|
|
189
|
+
name: "storm-workspace",
|
|
290
190
|
namespace: "storm-software",
|
|
291
191
|
license: "Apache License 2.0",
|
|
292
192
|
homepage: "https://stormsoftware.org",
|
|
@@ -294,6 +194,7 @@ var DefaultStormConfig = {
|
|
|
294
194
|
owner: "@storm-software/development",
|
|
295
195
|
worker: "stormie-bot",
|
|
296
196
|
runtimeDirectory: "node_modules/.storm",
|
|
197
|
+
packageManager: "npm",
|
|
297
198
|
timezone: "America/New_York",
|
|
298
199
|
locale: "en-US",
|
|
299
200
|
env: "production",
|
|
@@ -308,12 +209,12 @@ var DefaultStormConfig = {
|
|
|
308
209
|
var getDefaultConfig = (config = {}, root) => {
|
|
309
210
|
let name = "storm-workspace";
|
|
310
211
|
let namespace = "storm-software";
|
|
311
|
-
let repository = "https://github.com/storm-software/storm-
|
|
212
|
+
let repository = "https://github.com/storm-software/storm-ops";
|
|
312
213
|
let license = DefaultStormConfig.license;
|
|
313
214
|
let homepage = DefaultStormConfig.homepage;
|
|
314
|
-
const workspaceRoot =
|
|
315
|
-
if (
|
|
316
|
-
const file = readFileSync(
|
|
215
|
+
const workspaceRoot = findWorkspaceRoot(root);
|
|
216
|
+
if (existsSync2(join2(workspaceRoot, "package.json"))) {
|
|
217
|
+
const file = readFileSync(join2(workspaceRoot, "package.json"), {
|
|
317
218
|
encoding: "utf-8"
|
|
318
219
|
});
|
|
319
220
|
if (file) {
|
|
@@ -567,8 +468,6 @@ export {
|
|
|
567
468
|
createStormConfig,
|
|
568
469
|
findWorkspaceRoot,
|
|
569
470
|
findWorkspaceRootSafe,
|
|
570
|
-
findWorkspaceRootSafeSync,
|
|
571
|
-
findWorkspaceRootSync,
|
|
572
471
|
getConfigEnv,
|
|
573
472
|
getConfigFile,
|
|
574
473
|
getDefaultConfig,
|
package/meta.cjs.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/config-tools/src/config-file/get-config-file.ts":{"bytes":1987,"imports":[{"path":"cosmiconfig","kind":"import-statement","external":true},{"path":"../types","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/config-file/index.ts":{"bytes":35,"imports":[{"path":"packages/config-tools/src/config-file/get-config-file.ts","kind":"import-statement","original":"./get-config-file"}],"format":"esm"},"packages/config-tools/src/types.ts":{"bytes":1405,"imports":[{"path":"zod","kind":"import-statement","external":true},{"path":"./schema","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-up.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/config-tools/src/config-file/get-config-file.ts":{"bytes":1987,"imports":[{"path":"cosmiconfig","kind":"import-statement","external":true},{"path":"../types","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/config-file/index.ts":{"bytes":35,"imports":[{"path":"packages/config-tools/src/config-file/get-config-file.ts","kind":"import-statement","original":"./get-config-file"}],"format":"esm"},"packages/config-tools/src/types.ts":{"bytes":1405,"imports":[{"path":"zod","kind":"import-statement","external":true},{"path":"./schema","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-up.ts":{"bytes":648,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytes":1755,"imports":[{"path":"packages/config-tools/src/utilities/find-up.ts","kind":"import-statement","original":"./find-up"}],"format":"esm"},"packages/config-tools/src/schema.ts":{"bytes":5887,"imports":[{"path":"zod","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/get-default-config.ts":{"bytes":2636,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"packages/config-tools/src/schema.ts","kind":"import-statement","original":"../schema"},{"path":"../types","kind":"import-statement","external":true},{"path":"packages/config-tools/src/utilities/find-workspace-root.ts","kind":"import-statement","original":"./find-workspace-root"}],"format":"esm"},"packages/config-tools/src/utilities/get-log-level.ts":{"bytes":1409,"imports":[{"path":"packages/config-tools/src/types.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/config-tools/src/utilities/index.ts":{"bytes":110,"imports":[{"path":"packages/config-tools/src/utilities/find-workspace-root.ts","kind":"import-statement","original":"./find-workspace-root"},{"path":"packages/config-tools/src/utilities/get-default-config.ts","kind":"import-statement","original":"./get-default-config"},{"path":"packages/config-tools/src/utilities/get-log-level.ts","kind":"import-statement","original":"./get-log-level"}],"format":"esm"},"packages/config-tools/src/env/get-env.ts":{"bytes":4137,"imports":[{"path":"packages/config-tools/src/types.ts","kind":"import-statement","original":"../types"},{"path":"packages/config-tools/src/utilities/index.ts","kind":"import-statement","original":"../utilities"}],"format":"esm"},"packages/config-tools/src/create-storm-config.ts":{"bytes":2905,"imports":[{"path":"zod","kind":"import-statement","external":true},{"path":"packages/config-tools/src/env/get-env.ts","kind":"import-statement","original":"./env/get-env"},{"path":"packages/config-tools/src/schema.ts","kind":"import-statement","original":"./schema"},{"path":"./types","kind":"import-statement","external":true},{"path":"packages/config-tools/src/utilities/get-default-config.ts","kind":"import-statement","original":"./utilities/get-default-config"}],"format":"esm"},"packages/config-tools/src/env/set-env.ts":{"bytes":4309,"imports":[{"path":"packages/config-tools/src/types.ts","kind":"import-statement","original":"../types"},{"path":"packages/config-tools/src/utilities/get-log-level.ts","kind":"import-statement","original":"../utilities/get-log-level"}],"format":"esm"},"packages/config-tools/src/env/index.ts":{"bytes":54,"imports":[{"path":"packages/config-tools/src/env/get-env.ts","kind":"import-statement","original":"./get-env"},{"path":"packages/config-tools/src/env/set-env.ts","kind":"import-statement","original":"./set-env"}],"format":"esm"},"packages/config-tools/src/index.ts":{"bytes":399,"imports":[{"path":"packages/config-tools/src/config-file/index.ts","kind":"import-statement","original":"./config-file"},{"path":"packages/config-tools/src/create-storm-config.ts","kind":"import-statement","original":"./create-storm-config"},{"path":"packages/config-tools/src/env/index.ts","kind":"import-statement","original":"./env"},{"path":"packages/config-tools/src/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/config-tools/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/config-tools/src/utilities/index.ts","kind":"import-statement","original":"./utilities"}],"format":"esm"}},"outputs":{"dist/packages/config-tools/index.cjs":{"imports":[{"path":"cosmiconfig","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"zod","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/config-tools/src/index.ts","inputs":{"packages/config-tools/src/index.ts":{"bytesInOutput":899},"packages/config-tools/src/config-file/get-config-file.ts":{"bytesInOutput":1594},"packages/config-tools/src/config-file/index.ts":{"bytesInOutput":0},"packages/config-tools/src/types.ts":{"bytesInOutput":256},"packages/config-tools/src/utilities/find-up.ts":{"bytesInOutput":555},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytesInOutput":1137},"packages/config-tools/src/utilities/index.ts":{"bytesInOutput":0},"packages/config-tools/src/utilities/get-default-config.ts":{"bytesInOutput":2091},"packages/config-tools/src/schema.ts":{"bytesInOutput":4582},"packages/config-tools/src/utilities/get-log-level.ts":{"bytesInOutput":1029},"packages/config-tools/src/env/get-env.ts":{"bytesInOutput":3060},"packages/config-tools/src/create-storm-config.ts":{"bytesInOutput":1106},"packages/config-tools/src/env/index.ts":{"bytesInOutput":0},"packages/config-tools/src/env/set-env.ts":{"bytesInOutput":3528}},"bytes":22291},"dist/packages/config-tools/utilities/find-workspace-root.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/config-tools/src/utilities/find-workspace-root.ts","inputs":{"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytesInOutput":1378},"packages/config-tools/src/utilities/find-up.ts":{"bytesInOutput":555}},"bytes":3031}}}
|
package/meta.esm.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/config-tools/src/config-file/get-config-file.ts":{"bytes":1987,"imports":[{"path":"cosmiconfig","kind":"import-statement","external":true},{"path":"../types","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/config-file/index.ts":{"bytes":35,"imports":[{"path":"packages/config-tools/src/config-file/get-config-file.ts","kind":"import-statement","original":"./get-config-file"}],"format":"esm"},"packages/config-tools/src/types.ts":{"bytes":1405,"imports":[{"path":"zod","kind":"import-statement","external":true},{"path":"./schema","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-up.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/config-tools/src/config-file/get-config-file.ts":{"bytes":1987,"imports":[{"path":"cosmiconfig","kind":"import-statement","external":true},{"path":"../types","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/config-file/index.ts":{"bytes":35,"imports":[{"path":"packages/config-tools/src/config-file/get-config-file.ts","kind":"import-statement","original":"./get-config-file"}],"format":"esm"},"packages/config-tools/src/types.ts":{"bytes":1405,"imports":[{"path":"zod","kind":"import-statement","external":true},{"path":"./schema","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-up.ts":{"bytes":648,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytes":1755,"imports":[{"path":"packages/config-tools/src/utilities/find-up.ts","kind":"import-statement","original":"./find-up"}],"format":"esm"},"packages/config-tools/src/schema.ts":{"bytes":5887,"imports":[{"path":"zod","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/get-default-config.ts":{"bytes":2636,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"packages/config-tools/src/schema.ts","kind":"import-statement","original":"../schema"},{"path":"../types","kind":"import-statement","external":true},{"path":"packages/config-tools/src/utilities/find-workspace-root.ts","kind":"import-statement","original":"./find-workspace-root"}],"format":"esm"},"packages/config-tools/src/utilities/get-log-level.ts":{"bytes":1409,"imports":[{"path":"packages/config-tools/src/types.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/config-tools/src/utilities/index.ts":{"bytes":110,"imports":[{"path":"packages/config-tools/src/utilities/find-workspace-root.ts","kind":"import-statement","original":"./find-workspace-root"},{"path":"packages/config-tools/src/utilities/get-default-config.ts","kind":"import-statement","original":"./get-default-config"},{"path":"packages/config-tools/src/utilities/get-log-level.ts","kind":"import-statement","original":"./get-log-level"}],"format":"esm"},"packages/config-tools/src/env/get-env.ts":{"bytes":4137,"imports":[{"path":"packages/config-tools/src/types.ts","kind":"import-statement","original":"../types"},{"path":"packages/config-tools/src/utilities/index.ts","kind":"import-statement","original":"../utilities"}],"format":"esm"},"packages/config-tools/src/create-storm-config.ts":{"bytes":2905,"imports":[{"path":"zod","kind":"import-statement","external":true},{"path":"packages/config-tools/src/env/get-env.ts","kind":"import-statement","original":"./env/get-env"},{"path":"packages/config-tools/src/schema.ts","kind":"import-statement","original":"./schema"},{"path":"./types","kind":"import-statement","external":true},{"path":"packages/config-tools/src/utilities/get-default-config.ts","kind":"import-statement","original":"./utilities/get-default-config"}],"format":"esm"},"packages/config-tools/src/env/set-env.ts":{"bytes":4309,"imports":[{"path":"packages/config-tools/src/types.ts","kind":"import-statement","original":"../types"},{"path":"packages/config-tools/src/utilities/get-log-level.ts","kind":"import-statement","original":"../utilities/get-log-level"}],"format":"esm"},"packages/config-tools/src/env/index.ts":{"bytes":54,"imports":[{"path":"packages/config-tools/src/env/get-env.ts","kind":"import-statement","original":"./get-env"},{"path":"packages/config-tools/src/env/set-env.ts","kind":"import-statement","original":"./set-env"}],"format":"esm"},"packages/config-tools/src/index.ts":{"bytes":399,"imports":[{"path":"packages/config-tools/src/config-file/index.ts","kind":"import-statement","original":"./config-file"},{"path":"packages/config-tools/src/create-storm-config.ts","kind":"import-statement","original":"./create-storm-config"},{"path":"packages/config-tools/src/env/index.ts","kind":"import-statement","original":"./env"},{"path":"packages/config-tools/src/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/config-tools/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/config-tools/src/utilities/index.ts","kind":"import-statement","original":"./utilities"}],"format":"esm"}},"outputs":{"dist/packages/config-tools/index.js":{"imports":[{"path":"cosmiconfig","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"zod","kind":"import-statement","external":true}],"exports":["ColorConfigSchema","DefaultColorConfig","DefaultStormConfig","LogLevel","LogLevelLabel","StormConfigSchema","createConfig","createConfigExtension","createStormConfig","findWorkspaceRoot","findWorkspaceRootSafe","getConfigEnv","getConfigFile","getDefaultConfig","getExtensionEnv","getLogLevel","getLogLevelLabel","setConfigEnv","setExtensionEnv"],"entryPoint":"packages/config-tools/src/index.ts","inputs":{"packages/config-tools/src/config-file/get-config-file.ts":{"bytesInOutput":1564},"packages/config-tools/src/config-file/index.ts":{"bytesInOutput":0},"packages/config-tools/src/index.ts":{"bytesInOutput":0},"packages/config-tools/src/types.ts":{"bytesInOutput":256},"packages/config-tools/src/utilities/find-up.ts":{"bytesInOutput":502},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytesInOutput":1137},"packages/config-tools/src/utilities/index.ts":{"bytesInOutput":0},"packages/config-tools/src/utilities/get-default-config.ts":{"bytesInOutput":2058},"packages/config-tools/src/schema.ts":{"bytesInOutput":4572},"packages/config-tools/src/utilities/get-log-level.ts":{"bytesInOutput":1029},"packages/config-tools/src/env/get-env.ts":{"bytesInOutput":3060},"packages/config-tools/src/create-storm-config.ts":{"bytesInOutput":1106},"packages/config-tools/src/env/index.ts":{"bytesInOutput":0},"packages/config-tools/src/env/set-env.ts":{"bytesInOutput":3528}},"bytes":19765},"dist/packages/config-tools/utilities/find-workspace-root.js":{"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true}],"exports":["findWorkspaceRoot","findWorkspaceRootSafe"],"entryPoint":"packages/config-tools/src/utilities/find-workspace-root.ts","inputs":{"packages/config-tools/src/utilities/find-up.ts":{"bytesInOutput":502},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytesInOutput":1137}},"bytes":1809}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/config-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "⚡The Storm-Ops monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.",
|
|
6
6
|
"repository": {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,122 +14,31 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// packages/config-tools/src/utilities/find-workspace-root.ts
|
|
30
20
|
var find_workspace_root_exports = {};
|
|
31
21
|
__export(find_workspace_root_exports, {
|
|
32
22
|
findWorkspaceRoot: () => findWorkspaceRoot,
|
|
33
|
-
findWorkspaceRootSafe: () => findWorkspaceRootSafe
|
|
34
|
-
findWorkspaceRootSafeSync: () => findWorkspaceRootSafeSync,
|
|
35
|
-
findWorkspaceRootSync: () => findWorkspaceRootSync
|
|
23
|
+
findWorkspaceRootSafe: () => findWorkspaceRootSafe
|
|
36
24
|
});
|
|
37
25
|
module.exports = __toCommonJS(find_workspace_root_exports);
|
|
38
26
|
|
|
39
27
|
// packages/config-tools/src/utilities/find-up.ts
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const foundPath = names(options.cwd);
|
|
54
|
-
return (0, import_locate_path.locatePathSync)([foundPath], { ...options, cwd: directory });
|
|
55
|
-
}
|
|
56
|
-
const runNameMatcher = async (name) => {
|
|
57
|
-
const paths = [name].flat();
|
|
58
|
-
const runMatcher = async (locateOptions) => {
|
|
59
|
-
if (typeof name !== "function") {
|
|
60
|
-
return (0, import_locate_path.locatePath)(paths, locateOptions);
|
|
61
|
-
}
|
|
62
|
-
const foundPath = await name(locateOptions.cwd);
|
|
63
|
-
if (typeof foundPath === "string") {
|
|
64
|
-
return (0, import_locate_path.locatePath)([foundPath], locateOptions);
|
|
65
|
-
}
|
|
66
|
-
return foundPath;
|
|
67
|
-
};
|
|
68
|
-
const matches = [];
|
|
69
|
-
while (true) {
|
|
70
|
-
console.debug(
|
|
71
|
-
`Searching for workspace root files in ${directory}
|
|
72
|
-
Options: ${JSON.stringify(
|
|
73
|
-
options
|
|
74
|
-
)}`
|
|
75
|
-
);
|
|
76
|
-
const foundPath = await runMatcher({ ...options, cwd: directory });
|
|
77
|
-
console.debug(`Found path specified at ${foundPath}`);
|
|
78
|
-
if (foundPath) {
|
|
79
|
-
matches.push(path.resolve(directory, foundPath));
|
|
80
|
-
}
|
|
81
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
directory = path.dirname(directory);
|
|
85
|
-
}
|
|
86
|
-
return matches;
|
|
87
|
-
};
|
|
88
|
-
return (await Promise.allSettled(
|
|
89
|
-
(names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name))
|
|
90
|
-
)).flat();
|
|
91
|
-
}
|
|
92
|
-
function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
93
|
-
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
94
|
-
const { root } = path.parse(directory);
|
|
95
|
-
const stopAt = path.resolve(directory, toPath(options.stopAt) ?? root);
|
|
96
|
-
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
97
|
-
if (typeof names === "function") {
|
|
98
|
-
const foundPath = names(options.cwd);
|
|
99
|
-
return (0, import_locate_path.locatePathSync)([foundPath], options);
|
|
28
|
+
var import_fs = require("fs");
|
|
29
|
+
var import_path = require("path");
|
|
30
|
+
var MAX_PATH_SEARCH_DEPTH = 30;
|
|
31
|
+
var depth = 0;
|
|
32
|
+
function findFolderUp(startPath, endFileNames) {
|
|
33
|
+
startPath = startPath ?? process.cwd();
|
|
34
|
+
if (endFileNames.some((endFileName) => (0, import_fs.existsSync)((0, import_path.join)(startPath, endFileName)))) {
|
|
35
|
+
return startPath;
|
|
36
|
+
} else if (startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
37
|
+
const parent = (0, import_path.join)(startPath, "..");
|
|
38
|
+
return findFolderUp(parent, endFileNames);
|
|
39
|
+
} else {
|
|
40
|
+
return void 0;
|
|
100
41
|
}
|
|
101
|
-
const runNameMatcher = (name) => {
|
|
102
|
-
const paths = [name].flat();
|
|
103
|
-
const runMatcher = (locateOptions) => {
|
|
104
|
-
if (typeof name !== "function") {
|
|
105
|
-
return (0, import_locate_path.locatePathSync)(paths, locateOptions);
|
|
106
|
-
}
|
|
107
|
-
const foundPath = name(locateOptions.cwd);
|
|
108
|
-
if (typeof foundPath === "string") {
|
|
109
|
-
return (0, import_locate_path.locatePathSync)([foundPath], locateOptions);
|
|
110
|
-
}
|
|
111
|
-
return foundPath;
|
|
112
|
-
};
|
|
113
|
-
const matches = [];
|
|
114
|
-
while (true) {
|
|
115
|
-
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
116
|
-
if (foundPath) {
|
|
117
|
-
matches.push(path.resolve(directory, foundPath));
|
|
118
|
-
}
|
|
119
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
directory = path.dirname(directory);
|
|
123
|
-
}
|
|
124
|
-
return matches;
|
|
125
|
-
};
|
|
126
|
-
return (names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name)).flat();
|
|
127
|
-
}
|
|
128
|
-
async function findUp(names, options = { limit: 1, type: "file" }) {
|
|
129
|
-
const matches = await findUpMultiple(names, options);
|
|
130
|
-
return matches[0];
|
|
131
|
-
}
|
|
132
|
-
function findUpSync(names, options = { limit: 1, type: "file" }) {
|
|
133
|
-
const matches = findUpMultipleSync(names, options);
|
|
134
|
-
return matches[0];
|
|
135
42
|
}
|
|
136
43
|
|
|
137
44
|
// packages/config-tools/src/utilities/find-workspace-root.ts
|
|
@@ -160,18 +67,10 @@ var rootFiles = [
|
|
|
160
67
|
"bun.lockb"
|
|
161
68
|
];
|
|
162
69
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
function findWorkspaceRootSafeSync(pathInsideMonorepo) {
|
|
170
|
-
return process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.env.NX_WORKSPACE_ROOT_PATH ? process.env.NX_WORKSPACE_ROOT_PATH : findUpSync(rootFiles, {
|
|
171
|
-
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
172
|
-
type: "file",
|
|
173
|
-
limit: 1
|
|
174
|
-
});
|
|
70
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
71
|
+
return process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH;
|
|
72
|
+
}
|
|
73
|
+
return findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles);
|
|
175
74
|
}
|
|
176
75
|
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
177
76
|
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
@@ -186,23 +85,8 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
|
186
85
|
}
|
|
187
86
|
return result;
|
|
188
87
|
}
|
|
189
|
-
function findWorkspaceRootSync(pathInsideMonorepo) {
|
|
190
|
-
const result = findWorkspaceRootSafeSync(pathInsideMonorepo);
|
|
191
|
-
if (!result) {
|
|
192
|
-
throw new Error(
|
|
193
|
-
`Cannot find workspace root upwards from known path. Files search list includes:
|
|
194
|
-
${rootFiles.join(
|
|
195
|
-
"\n"
|
|
196
|
-
)}
|
|
197
|
-
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
return result;
|
|
201
|
-
}
|
|
202
88
|
// Annotate the CommonJS export names for ESM import in node:
|
|
203
89
|
0 && (module.exports = {
|
|
204
90
|
findWorkspaceRoot,
|
|
205
|
-
findWorkspaceRootSafe
|
|
206
|
-
findWorkspaceRootSafeSync,
|
|
207
|
-
findWorkspaceRootSync
|
|
91
|
+
findWorkspaceRootSafe
|
|
208
92
|
});
|
|
@@ -1,99 +1,18 @@
|
|
|
1
1
|
// packages/config-tools/src/utilities/find-up.ts
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const foundPath = names(options.cwd);
|
|
16
|
-
return locatePathSync([foundPath], { ...options, cwd: directory });
|
|
17
|
-
}
|
|
18
|
-
const runNameMatcher = async (name) => {
|
|
19
|
-
const paths = [name].flat();
|
|
20
|
-
const runMatcher = async (locateOptions) => {
|
|
21
|
-
if (typeof name !== "function") {
|
|
22
|
-
return locatePath(paths, locateOptions);
|
|
23
|
-
}
|
|
24
|
-
const foundPath = await name(locateOptions.cwd);
|
|
25
|
-
if (typeof foundPath === "string") {
|
|
26
|
-
return locatePath([foundPath], locateOptions);
|
|
27
|
-
}
|
|
28
|
-
return foundPath;
|
|
29
|
-
};
|
|
30
|
-
const matches = [];
|
|
31
|
-
while (true) {
|
|
32
|
-
console.debug(
|
|
33
|
-
`Searching for workspace root files in ${directory}
|
|
34
|
-
Options: ${JSON.stringify(
|
|
35
|
-
options
|
|
36
|
-
)}`
|
|
37
|
-
);
|
|
38
|
-
const foundPath = await runMatcher({ ...options, cwd: directory });
|
|
39
|
-
console.debug(`Found path specified at ${foundPath}`);
|
|
40
|
-
if (foundPath) {
|
|
41
|
-
matches.push(path.resolve(directory, foundPath));
|
|
42
|
-
}
|
|
43
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
directory = path.dirname(directory);
|
|
47
|
-
}
|
|
48
|
-
return matches;
|
|
49
|
-
};
|
|
50
|
-
return (await Promise.allSettled(
|
|
51
|
-
(names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name))
|
|
52
|
-
)).flat();
|
|
53
|
-
}
|
|
54
|
-
function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
55
|
-
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
56
|
-
const { root } = path.parse(directory);
|
|
57
|
-
const stopAt = path.resolve(directory, toPath(options.stopAt) ?? root);
|
|
58
|
-
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
59
|
-
if (typeof names === "function") {
|
|
60
|
-
const foundPath = names(options.cwd);
|
|
61
|
-
return locatePathSync([foundPath], options);
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
var MAX_PATH_SEARCH_DEPTH = 30;
|
|
5
|
+
var depth = 0;
|
|
6
|
+
function findFolderUp(startPath, endFileNames) {
|
|
7
|
+
startPath = startPath ?? process.cwd();
|
|
8
|
+
if (endFileNames.some((endFileName) => existsSync(join(startPath, endFileName)))) {
|
|
9
|
+
return startPath;
|
|
10
|
+
} else if (startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
11
|
+
const parent = join(startPath, "..");
|
|
12
|
+
return findFolderUp(parent, endFileNames);
|
|
13
|
+
} else {
|
|
14
|
+
return void 0;
|
|
62
15
|
}
|
|
63
|
-
const runNameMatcher = (name) => {
|
|
64
|
-
const paths = [name].flat();
|
|
65
|
-
const runMatcher = (locateOptions) => {
|
|
66
|
-
if (typeof name !== "function") {
|
|
67
|
-
return locatePathSync(paths, locateOptions);
|
|
68
|
-
}
|
|
69
|
-
const foundPath = name(locateOptions.cwd);
|
|
70
|
-
if (typeof foundPath === "string") {
|
|
71
|
-
return locatePathSync([foundPath], locateOptions);
|
|
72
|
-
}
|
|
73
|
-
return foundPath;
|
|
74
|
-
};
|
|
75
|
-
const matches = [];
|
|
76
|
-
while (true) {
|
|
77
|
-
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
78
|
-
if (foundPath) {
|
|
79
|
-
matches.push(path.resolve(directory, foundPath));
|
|
80
|
-
}
|
|
81
|
-
if (directory === stopAt || matches.length >= limit) {
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
directory = path.dirname(directory);
|
|
85
|
-
}
|
|
86
|
-
return matches;
|
|
87
|
-
};
|
|
88
|
-
return (names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name)).flat();
|
|
89
|
-
}
|
|
90
|
-
async function findUp(names, options = { limit: 1, type: "file" }) {
|
|
91
|
-
const matches = await findUpMultiple(names, options);
|
|
92
|
-
return matches[0];
|
|
93
|
-
}
|
|
94
|
-
function findUpSync(names, options = { limit: 1, type: "file" }) {
|
|
95
|
-
const matches = findUpMultipleSync(names, options);
|
|
96
|
-
return matches[0];
|
|
97
16
|
}
|
|
98
17
|
|
|
99
18
|
// packages/config-tools/src/utilities/find-workspace-root.ts
|
|
@@ -122,18 +41,10 @@ var rootFiles = [
|
|
|
122
41
|
"bun.lockb"
|
|
123
42
|
];
|
|
124
43
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function findWorkspaceRootSafeSync(pathInsideMonorepo) {
|
|
132
|
-
return process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.env.NX_WORKSPACE_ROOT_PATH ? process.env.NX_WORKSPACE_ROOT_PATH : findUpSync(rootFiles, {
|
|
133
|
-
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
134
|
-
type: "file",
|
|
135
|
-
limit: 1
|
|
136
|
-
});
|
|
44
|
+
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
45
|
+
return process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH;
|
|
46
|
+
}
|
|
47
|
+
return findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles);
|
|
137
48
|
}
|
|
138
49
|
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
139
50
|
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
@@ -148,22 +59,7 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
|
148
59
|
}
|
|
149
60
|
return result;
|
|
150
61
|
}
|
|
151
|
-
function findWorkspaceRootSync(pathInsideMonorepo) {
|
|
152
|
-
const result = findWorkspaceRootSafeSync(pathInsideMonorepo);
|
|
153
|
-
if (!result) {
|
|
154
|
-
throw new Error(
|
|
155
|
-
`Cannot find workspace root upwards from known path. Files search list includes:
|
|
156
|
-
${rootFiles.join(
|
|
157
|
-
"\n"
|
|
158
|
-
)}
|
|
159
|
-
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
return result;
|
|
163
|
-
}
|
|
164
62
|
export {
|
|
165
63
|
findWorkspaceRoot,
|
|
166
|
-
findWorkspaceRootSafe
|
|
167
|
-
findWorkspaceRootSafeSync,
|
|
168
|
-
findWorkspaceRootSync
|
|
64
|
+
findWorkspaceRootSafe
|
|
169
65
|
};
|