@storm-software/config-tools 1.6.1 → 1.7.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 +7 -0
- package/README.md +1 -1
- package/declarations.d.ts +22 -2
- package/index.cjs +74 -1
- package/index.js +72 -1
- package/meta.cjs.json +1 -1
- package/meta.esm.json +1 -1
- package/package.json +1 -1
- package/utilities/find-workspace-root.cjs +75 -2
- package/utilities/find-workspace-root.js +72 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [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
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **config-tools:** Remove unused dependencies ([ef00034](https://github.com/storm-software/storm-ops/commit/ef00034e8a79b81147056ee32a12eaa991a0d4f3))
|
|
7
|
+
|
|
1
8
|
# [1.6.0](https://github.com/storm-software/storm-ops/compare/config-tools-v1.5.14...config-tools-v1.6.0) (2023-12-21)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
16
16
|
|
|
17
17
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.org" target="_blank">stormsoftware.org</a> to stay up to date with this developer</h3><br />
|
|
18
18
|
|
|
19
|
-
[](https://prettier.io/)
|
|
20
20
|
[](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://docusaurus.io/) 
|
|
21
21
|
|
|
22
22
|
<h3 align="center" bold="true">⚠️ <b>Attention</b> ⚠️ This repository, and the apps, libraries, and tools contained within, is still in it's initial development phase. As a result, bugs and issues are expected with it's usage. When the main development phase completes, a proper release will be performed, the packages will be availible through NPM (and other distributions), and this message will be removed. However, in the meantime, please feel free to report any issues you may come across.</h3><br />
|
package/declarations.d.ts
CHANGED
|
@@ -22,7 +22,9 @@ export { StormConfig };
|
|
|
22
22
|
*
|
|
23
23
|
* @param pathInsideMonorepo - The path inside the monorepo
|
|
24
24
|
*/
|
|
25
|
-
declare function findWorkspaceRoot(
|
|
25
|
+
declare function findWorkspaceRoot(
|
|
26
|
+
pathInsideMonorepo?: string
|
|
27
|
+
): Promise<string>;
|
|
26
28
|
export { findWorkspaceRoot };
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -32,9 +34,27 @@ export { findWorkspaceRoot };
|
|
|
32
34
|
*/
|
|
33
35
|
declare function findWorkspaceRootSafe(
|
|
34
36
|
pathInsideMonorepo?: string
|
|
35
|
-
): string | undefined
|
|
37
|
+
): Promise<string | undefined>;
|
|
36
38
|
export { findWorkspaceRootSafe };
|
|
37
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;
|
|
46
|
+
export { findWorkspaceRootSync };
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Find the root of the current monorepo safely (do not throw an error if it cannot be found)
|
|
50
|
+
*
|
|
51
|
+
* @param pathInsideMonorepo - The path inside the monorepo
|
|
52
|
+
*/
|
|
53
|
+
declare function findWorkspaceRootSafeSync(
|
|
54
|
+
pathInsideMonorepo?: string
|
|
55
|
+
): string | undefined;
|
|
56
|
+
export { findWorkspaceRootSafeSync };
|
|
57
|
+
|
|
38
58
|
/**
|
|
39
59
|
* Type-check to determine if `obj` is a `StormError` object
|
|
40
60
|
*
|
package/index.cjs
CHANGED
|
@@ -40,6 +40,8 @@ __export(src_exports, {
|
|
|
40
40
|
createStormConfig: () => createStormConfig,
|
|
41
41
|
findWorkspaceRoot: () => findWorkspaceRoot,
|
|
42
42
|
findWorkspaceRootSafe: () => findWorkspaceRootSafe,
|
|
43
|
+
findWorkspaceRootSafeSync: () => findWorkspaceRootSafeSync,
|
|
44
|
+
findWorkspaceRootSync: () => findWorkspaceRootSync,
|
|
43
45
|
getConfigEnv: () => getConfigEnv,
|
|
44
46
|
getConfigFile: () => getConfigFile,
|
|
45
47
|
getDefaultConfig: () => getDefaultConfig,
|
|
@@ -116,6 +118,51 @@ var findUpStop = Symbol("findUpStop");
|
|
|
116
118
|
function toPath(urlOrPath) {
|
|
117
119
|
return urlOrPath instanceof URL ? (0, import_url.fileURLToPath)(urlOrPath) : urlOrPath;
|
|
118
120
|
}
|
|
121
|
+
async function findUpMultiple(names, options = { limit: Number.POSITIVE_INFINITY, type: "file" }) {
|
|
122
|
+
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
123
|
+
const { root } = path.parse(directory);
|
|
124
|
+
const stopAt = path.resolve(directory, toPath(options.stopAt ?? root));
|
|
125
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
126
|
+
if (typeof names === "function") {
|
|
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
|
+
}
|
|
119
166
|
function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
120
167
|
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
121
168
|
const { root } = path.parse(directory);
|
|
@@ -152,6 +199,10 @@ function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
|
152
199
|
};
|
|
153
200
|
return (names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name)).flat();
|
|
154
201
|
}
|
|
202
|
+
async function findUp(names, options = { limit: 1, type: "file" }) {
|
|
203
|
+
const matches = await findUpMultiple(names, options);
|
|
204
|
+
return matches[0];
|
|
205
|
+
}
|
|
155
206
|
function findUpSync(names, options = { limit: 1, type: "file" }) {
|
|
156
207
|
const matches = findUpMultipleSync(names, options);
|
|
157
208
|
return matches[0];
|
|
@@ -183,6 +234,13 @@ var rootFiles = [
|
|
|
183
234
|
"bun.lockb"
|
|
184
235
|
];
|
|
185
236
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
237
|
+
return process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.env.NX_WORKSPACE_ROOT_PATH ? process.env.NX_WORKSPACE_ROOT_PATH : findUp(rootFiles, {
|
|
238
|
+
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
239
|
+
type: "file",
|
|
240
|
+
limit: 1
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function findWorkspaceRootSafeSync(pathInsideMonorepo) {
|
|
186
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, {
|
|
187
245
|
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
188
246
|
type: "file",
|
|
@@ -202,6 +260,19 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
|
202
260
|
}
|
|
203
261
|
return result;
|
|
204
262
|
}
|
|
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
|
+
}
|
|
205
276
|
|
|
206
277
|
// packages/config-tools/src/utilities/get-default-config.ts
|
|
207
278
|
var import_fs = require("fs");
|
|
@@ -295,7 +366,7 @@ var getDefaultConfig = (config = {}, root) => {
|
|
|
295
366
|
let repository = "https://github.com/storm-software/storm-stack";
|
|
296
367
|
let license = DefaultStormConfig.license;
|
|
297
368
|
let homepage = DefaultStormConfig.homepage;
|
|
298
|
-
const workspaceRoot =
|
|
369
|
+
const workspaceRoot = findWorkspaceRootSync(root);
|
|
299
370
|
if ((0, import_fs.existsSync)((0, import_path.join)(workspaceRoot, "package.json"))) {
|
|
300
371
|
const file = (0, import_fs.readFileSync)((0, import_path.join)(workspaceRoot, "package.json"), {
|
|
301
372
|
encoding: "utf-8"
|
|
@@ -552,6 +623,8 @@ var setConfigEnv = (config) => {
|
|
|
552
623
|
createStormConfig,
|
|
553
624
|
findWorkspaceRoot,
|
|
554
625
|
findWorkspaceRootSafe,
|
|
626
|
+
findWorkspaceRootSafeSync,
|
|
627
|
+
findWorkspaceRootSync,
|
|
555
628
|
getConfigEnv,
|
|
556
629
|
getConfigFile,
|
|
557
630
|
getDefaultConfig,
|
package/index.js
CHANGED
|
@@ -63,6 +63,51 @@ var findUpStop = Symbol("findUpStop");
|
|
|
63
63
|
function toPath(urlOrPath) {
|
|
64
64
|
return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
65
65
|
}
|
|
66
|
+
async function findUpMultiple(names, options = { limit: Number.POSITIVE_INFINITY, type: "file" }) {
|
|
67
|
+
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
68
|
+
const { root } = path.parse(directory);
|
|
69
|
+
const stopAt = path.resolve(directory, toPath(options.stopAt ?? root));
|
|
70
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
71
|
+
if (typeof names === "function") {
|
|
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
|
+
}
|
|
66
111
|
function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
67
112
|
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
68
113
|
const { root } = path.parse(directory);
|
|
@@ -99,6 +144,10 @@ function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
|
99
144
|
};
|
|
100
145
|
return (names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name)).flat();
|
|
101
146
|
}
|
|
147
|
+
async function findUp(names, options = { limit: 1, type: "file" }) {
|
|
148
|
+
const matches = await findUpMultiple(names, options);
|
|
149
|
+
return matches[0];
|
|
150
|
+
}
|
|
102
151
|
function findUpSync(names, options = { limit: 1, type: "file" }) {
|
|
103
152
|
const matches = findUpMultipleSync(names, options);
|
|
104
153
|
return matches[0];
|
|
@@ -130,6 +179,13 @@ var rootFiles = [
|
|
|
130
179
|
"bun.lockb"
|
|
131
180
|
];
|
|
132
181
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
182
|
+
return process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.env.NX_WORKSPACE_ROOT_PATH ? process.env.NX_WORKSPACE_ROOT_PATH : findUp(rootFiles, {
|
|
183
|
+
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
184
|
+
type: "file",
|
|
185
|
+
limit: 1
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function findWorkspaceRootSafeSync(pathInsideMonorepo) {
|
|
133
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, {
|
|
134
190
|
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
135
191
|
type: "file",
|
|
@@ -149,6 +205,19 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
|
149
205
|
}
|
|
150
206
|
return result;
|
|
151
207
|
}
|
|
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
|
+
}
|
|
152
221
|
|
|
153
222
|
// packages/config-tools/src/utilities/get-default-config.ts
|
|
154
223
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -242,7 +311,7 @@ var getDefaultConfig = (config = {}, root) => {
|
|
|
242
311
|
let repository = "https://github.com/storm-software/storm-stack";
|
|
243
312
|
let license = DefaultStormConfig.license;
|
|
244
313
|
let homepage = DefaultStormConfig.homepage;
|
|
245
|
-
const workspaceRoot =
|
|
314
|
+
const workspaceRoot = findWorkspaceRootSync(root);
|
|
246
315
|
if (existsSync(join(workspaceRoot, "package.json"))) {
|
|
247
316
|
const file = readFileSync(join(workspaceRoot, "package.json"), {
|
|
248
317
|
encoding: "utf-8"
|
|
@@ -498,6 +567,8 @@ export {
|
|
|
498
567
|
createStormConfig,
|
|
499
568
|
findWorkspaceRoot,
|
|
500
569
|
findWorkspaceRootSafe,
|
|
570
|
+
findWorkspaceRootSafeSync,
|
|
571
|
+
findWorkspaceRootSync,
|
|
501
572
|
getConfigEnv,
|
|
502
573
|
getConfigFile,
|
|
503
574
|
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":4526,"imports":[{"path":"locate-path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"url","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-workspace-root.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":4526,"imports":[{"path":"locate-path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"url","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytes":2551,"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":5736,"imports":[{"path":"zod","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/get-default-config.ts":{"bytes":2608,"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":"locate-path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"url","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":1015},"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":3645},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytesInOutput":1853},"packages/config-tools/src/utilities/index.ts":{"bytesInOutput":0},"packages/config-tools/src/utilities/get-default-config.ts":{"bytesInOutput":2039},"packages/config-tools/src/schema.ts":{"bytesInOutput":4454},"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":26087},"dist/packages/config-tools/utilities/find-workspace-root.cjs":{"imports":[{"path":"locate-path","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"url","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":2210},"packages/config-tools/src/utilities/find-up.ts":{"bytesInOutput":3645}},"bytes":7604}}}
|
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":4526,"imports":[{"path":"locate-path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"url","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-workspace-root.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":4526,"imports":[{"path":"locate-path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"url","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytes":2551,"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":5736,"imports":[{"path":"zod","kind":"import-statement","external":true}],"format":"esm"},"packages/config-tools/src/utilities/get-default-config.ts":{"bytes":2608,"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":"locate-path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"url","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","findWorkspaceRootSafeSync","findWorkspaceRootSync","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":3488},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytesInOutput":1853},"packages/config-tools/src/utilities/index.ts":{"bytesInOutput":0},"packages/config-tools/src/utilities/get-default-config.ts":{"bytesInOutput":1985},"packages/config-tools/src/schema.ts":{"bytesInOutput":4444},"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":23320},"dist/packages/config-tools/utilities/find-workspace-root.js":{"imports":[{"path":"locate-path","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"url","kind":"import-statement","external":true}],"exports":["findWorkspaceRoot","findWorkspaceRootSafe","findWorkspaceRootSafeSync","findWorkspaceRootSync"],"entryPoint":"packages/config-tools/src/utilities/find-workspace-root.ts","inputs":{"packages/config-tools/src/utilities/find-up.ts":{"bytesInOutput":3488},"packages/config-tools/src/utilities/find-workspace-root.ts":{"bytesInOutput":1853}},"bytes":5565}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/config-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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": {
|
|
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var find_workspace_root_exports = {};
|
|
31
31
|
__export(find_workspace_root_exports, {
|
|
32
32
|
findWorkspaceRoot: () => findWorkspaceRoot,
|
|
33
|
-
findWorkspaceRootSafe: () => findWorkspaceRootSafe
|
|
33
|
+
findWorkspaceRootSafe: () => findWorkspaceRootSafe,
|
|
34
|
+
findWorkspaceRootSafeSync: () => findWorkspaceRootSafeSync,
|
|
35
|
+
findWorkspaceRootSync: () => findWorkspaceRootSync
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(find_workspace_root_exports);
|
|
36
38
|
|
|
@@ -42,6 +44,51 @@ var findUpStop = Symbol("findUpStop");
|
|
|
42
44
|
function toPath(urlOrPath) {
|
|
43
45
|
return urlOrPath instanceof URL ? (0, import_url.fileURLToPath)(urlOrPath) : urlOrPath;
|
|
44
46
|
}
|
|
47
|
+
async function findUpMultiple(names, options = { limit: Number.POSITIVE_INFINITY, type: "file" }) {
|
|
48
|
+
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
49
|
+
const { root } = path.parse(directory);
|
|
50
|
+
const stopAt = path.resolve(directory, toPath(options.stopAt ?? root));
|
|
51
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
52
|
+
if (typeof names === "function") {
|
|
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
|
+
}
|
|
45
92
|
function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
46
93
|
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
47
94
|
const { root } = path.parse(directory);
|
|
@@ -78,6 +125,10 @@ function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
|
78
125
|
};
|
|
79
126
|
return (names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name)).flat();
|
|
80
127
|
}
|
|
128
|
+
async function findUp(names, options = { limit: 1, type: "file" }) {
|
|
129
|
+
const matches = await findUpMultiple(names, options);
|
|
130
|
+
return matches[0];
|
|
131
|
+
}
|
|
81
132
|
function findUpSync(names, options = { limit: 1, type: "file" }) {
|
|
82
133
|
const matches = findUpMultipleSync(names, options);
|
|
83
134
|
return matches[0];
|
|
@@ -109,6 +160,13 @@ var rootFiles = [
|
|
|
109
160
|
"bun.lockb"
|
|
110
161
|
];
|
|
111
162
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
163
|
+
return process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.env.NX_WORKSPACE_ROOT_PATH ? process.env.NX_WORKSPACE_ROOT_PATH : findUp(rootFiles, {
|
|
164
|
+
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
165
|
+
type: "file",
|
|
166
|
+
limit: 1
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function findWorkspaceRootSafeSync(pathInsideMonorepo) {
|
|
112
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, {
|
|
113
171
|
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
114
172
|
type: "file",
|
|
@@ -128,8 +186,23 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
|
128
186
|
}
|
|
129
187
|
return result;
|
|
130
188
|
}
|
|
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
|
+
}
|
|
131
202
|
// Annotate the CommonJS export names for ESM import in node:
|
|
132
203
|
0 && (module.exports = {
|
|
133
204
|
findWorkspaceRoot,
|
|
134
|
-
findWorkspaceRootSafe
|
|
205
|
+
findWorkspaceRootSafe,
|
|
206
|
+
findWorkspaceRootSafeSync,
|
|
207
|
+
findWorkspaceRootSync
|
|
135
208
|
});
|
|
@@ -6,6 +6,51 @@ var findUpStop = Symbol("findUpStop");
|
|
|
6
6
|
function toPath(urlOrPath) {
|
|
7
7
|
return urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
8
8
|
}
|
|
9
|
+
async function findUpMultiple(names, options = { limit: Number.POSITIVE_INFINITY, type: "file" }) {
|
|
10
|
+
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
11
|
+
const { root } = path.parse(directory);
|
|
12
|
+
const stopAt = path.resolve(directory, toPath(options.stopAt ?? root));
|
|
13
|
+
const limit = options.limit ?? Number.POSITIVE_INFINITY;
|
|
14
|
+
if (typeof names === "function") {
|
|
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
|
+
}
|
|
9
54
|
function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
10
55
|
let directory = path.resolve(toPath(options.cwd) ?? "");
|
|
11
56
|
const { root } = path.parse(directory);
|
|
@@ -42,6 +87,10 @@ function findUpMultipleSync(names, options = { limit: 1, type: "file" }) {
|
|
|
42
87
|
};
|
|
43
88
|
return (names && Array.isArray(names) ? names : [names]).map((name) => runNameMatcher(name)).flat();
|
|
44
89
|
}
|
|
90
|
+
async function findUp(names, options = { limit: 1, type: "file" }) {
|
|
91
|
+
const matches = await findUpMultiple(names, options);
|
|
92
|
+
return matches[0];
|
|
93
|
+
}
|
|
45
94
|
function findUpSync(names, options = { limit: 1, type: "file" }) {
|
|
46
95
|
const matches = findUpMultipleSync(names, options);
|
|
47
96
|
return matches[0];
|
|
@@ -73,6 +122,13 @@ var rootFiles = [
|
|
|
73
122
|
"bun.lockb"
|
|
74
123
|
];
|
|
75
124
|
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
125
|
+
return process.env.STORM_WORKSPACE_ROOT ? process.env.STORM_WORKSPACE_ROOT : process.env.NX_WORKSPACE_ROOT_PATH ? process.env.NX_WORKSPACE_ROOT_PATH : findUp(rootFiles, {
|
|
126
|
+
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
127
|
+
type: "file",
|
|
128
|
+
limit: 1
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function findWorkspaceRootSafeSync(pathInsideMonorepo) {
|
|
76
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, {
|
|
77
133
|
cwd: pathInsideMonorepo ?? process.cwd(),
|
|
78
134
|
type: "file",
|
|
@@ -92,7 +148,22 @@ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
|
92
148
|
}
|
|
93
149
|
return result;
|
|
94
150
|
}
|
|
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
|
+
}
|
|
95
164
|
export {
|
|
96
165
|
findWorkspaceRoot,
|
|
97
|
-
findWorkspaceRootSafe
|
|
166
|
+
findWorkspaceRootSafe,
|
|
167
|
+
findWorkspaceRootSafeSync,
|
|
168
|
+
findWorkspaceRootSync
|
|
98
169
|
};
|