@mono-labs/project 0.1.267 → 0.1.270
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/dist/loadFromRoot.d.ts +1 -5
- package/dist/loadFromRoot.d.ts.map +1 -1
- package/dist/loadFromRoot.js +6 -20
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/index.js +10 -30
- package/package.json +2 -2
- package/src/loadFromRoot.ts +4 -21
- package/src/project/index.ts +10 -31
package/dist/loadFromRoot.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { findProjectRoot } from '@mono-labs/shared';
|
|
1
2
|
export interface MonoWorkspaceConfig {
|
|
2
3
|
packageMaps: Record<string, string>;
|
|
3
4
|
}
|
|
@@ -11,11 +12,6 @@ export interface MonoConfig {
|
|
|
11
12
|
config: MonoProjectConfig;
|
|
12
13
|
files: MonoFiles;
|
|
13
14
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Walk up from cwd until we find a directory containing package.json.
|
|
16
|
-
* This is treated as the project root.
|
|
17
|
-
*/
|
|
18
|
-
export declare function findProjectRoot(startDir?: string): string;
|
|
19
15
|
export declare function getRootDirectory(): string;
|
|
20
16
|
export declare function getRootJson(): Record<string, unknown>;
|
|
21
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadFromRoot.d.ts","sourceRoot":"","sources":["../src/loadFromRoot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadFromRoot.d.ts","sourceRoot":"","sources":["../src/loadFromRoot.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMpD,MAAM,WAAW,mBAAmB;IACnC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhD,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,SAAS,CAAC;CACjB;AAMD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASrD;AAYD;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CASpD;AAED,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAQvC;AAID;;;GAGG;AACH,wBAAgB,aAAa,IAAI,UAAU,CA4C1C;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
package/dist/loadFromRoot.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.findProjectRoot =
|
|
6
|
+
exports.findProjectRoot = void 0;
|
|
7
7
|
exports.getRootDirectory = getRootDirectory;
|
|
8
8
|
exports.getRootJson = getRootJson;
|
|
9
9
|
exports.resolveMonoDirectory = resolveMonoDirectory;
|
|
@@ -12,29 +12,15 @@ exports.getMonoConfig = getMonoConfig;
|
|
|
12
12
|
exports.clearMonoConfigCache = clearMonoConfigCache;
|
|
13
13
|
const fs_1 = __importDefault(require("fs"));
|
|
14
14
|
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const shared_1 = require("@mono-labs/shared");
|
|
16
|
+
// Re-export so existing consumers aren't broken
|
|
17
|
+
var shared_2 = require("@mono-labs/shared");
|
|
18
|
+
Object.defineProperty(exports, "findProjectRoot", { enumerable: true, get: function () { return shared_2.findProjectRoot; } });
|
|
15
19
|
/* ------------------------------------------------------------------
|
|
16
20
|
* Helpers
|
|
17
21
|
* ------------------------------------------------------------------ */
|
|
18
|
-
/**
|
|
19
|
-
* Walk up from cwd until we find a directory containing package.json.
|
|
20
|
-
* This is treated as the project root.
|
|
21
|
-
*/
|
|
22
|
-
function findProjectRoot(startDir = process.cwd()) {
|
|
23
|
-
let current = startDir;
|
|
24
|
-
while (true) {
|
|
25
|
-
const pkg = path_1.default.join(current, 'package.json');
|
|
26
|
-
if (fs_1.default.existsSync(pkg))
|
|
27
|
-
return current;
|
|
28
|
-
const parent = path_1.default.dirname(current);
|
|
29
|
-
if (parent === current)
|
|
30
|
-
break;
|
|
31
|
-
current = parent;
|
|
32
|
-
}
|
|
33
|
-
// Fallback: use cwd
|
|
34
|
-
return startDir;
|
|
35
|
-
}
|
|
36
22
|
function getRootDirectory() {
|
|
37
|
-
return findProjectRoot();
|
|
23
|
+
return (0, shared_1.findProjectRoot)();
|
|
38
24
|
}
|
|
39
25
|
function getRootJson() {
|
|
40
26
|
const root = getRootDirectory();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAQA,KAAK,qBAAqB,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,eAAe,EAAE,OAAO,CAAA;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,mBAAmB,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAUD,KAAK,aAAa,GAAG;IACnB,GAAG,EAAE,gBAAgB,CAAA;IACrB,UAAU,EAAE,mBAAmB,CAAA;CAChC,CAAA;AAED;;;GAGG;AACH,KAAK,aAAa,CAAC,KAAK,SAAS,MAAM,EAAE,OAAO,GAAG,OAAO,IAAI,KAAK,SAAS,MAAM,aAAa,GAC3F,aAAa,CAAC,KAAK,CAAC,GACpB,OAAO,CAAA;AA0DX,wBAAgB,aAAa,CAAC,OAAO,GAAG,OAAO,EAAE,KAAK,SAAS,MAAM,GAAG,KAAK,EAC3E,UAAU,GAAE,KAAsB,EAClC,QAAQ,GAAE,MAAsB,GAC/B;IAAE,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,qBAAqB,CAAA;CAAE,CA6CxE;AAED,eAAO,MAAM,iBAAiB,sBAAgB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/project/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.filterEnvByConfig = exports.filterEnvByPrefixes = exports.loadMergedEnv
|
|
|
7
7
|
exports.loadAppConfig = loadAppConfig;
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const shared_1 = require("@mono-labs/shared");
|
|
10
11
|
const requiredSystemDefaults = {
|
|
11
12
|
ec2User: 'ec2-user',
|
|
12
13
|
regions: ['us-east-1'],
|
|
@@ -25,36 +26,15 @@ function isLambdaRuntime() {
|
|
|
25
26
|
* ────────────────────────────────────────────────────────── */
|
|
26
27
|
function detectWorkspaceAndConfigPath(startDir, configFileName) {
|
|
27
28
|
const cwd = node_path_1.default.resolve(startDir);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// ignore
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const markers = ['pnpm-workspace.yaml', 'lerna.json', 'turbo.json', 'nx.json', '.git'];
|
|
41
|
-
return markers.some((m) => node_fs_1.default.existsSync(node_path_1.default.join(dir, m)));
|
|
42
|
-
};
|
|
43
|
-
let dir = cwd;
|
|
44
|
-
while (true) {
|
|
45
|
-
if (isWorkspaceRootDir(dir)) {
|
|
46
|
-
return {
|
|
47
|
-
cwd,
|
|
48
|
-
workspaceRoot: dir,
|
|
49
|
-
isWorkspaceRoot: dir === cwd,
|
|
50
|
-
configDir: dir,
|
|
51
|
-
configPath: node_path_1.default.join(dir, configFileName),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const parent = node_path_1.default.dirname(dir);
|
|
55
|
-
if (parent === dir)
|
|
56
|
-
break;
|
|
57
|
-
dir = parent;
|
|
29
|
+
const result = (0, shared_1.findWorkspaceRoot)(cwd);
|
|
30
|
+
if (result.isWorkspace || result.root !== cwd) {
|
|
31
|
+
return {
|
|
32
|
+
cwd,
|
|
33
|
+
workspaceRoot: result.root,
|
|
34
|
+
isWorkspaceRoot: result.root === cwd,
|
|
35
|
+
configDir: result.root,
|
|
36
|
+
configPath: node_path_1.default.join(result.root, configFileName),
|
|
37
|
+
};
|
|
58
38
|
}
|
|
59
39
|
return {
|
|
60
40
|
cwd,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mono-labs/project",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.270",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "Project configuration utilities for mono-labs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@mono-labs/shared": "0.1.
|
|
35
|
+
"@mono-labs/shared": "0.1.270",
|
|
36
36
|
"dotenv": "^17.2.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
package/src/loadFromRoot.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { findProjectRoot } from '@mono-labs/shared';
|
|
4
|
+
|
|
5
|
+
// Re-export so existing consumers aren't broken
|
|
6
|
+
export { findProjectRoot } from '@mono-labs/shared';
|
|
3
7
|
|
|
4
8
|
/* ------------------------------------------------------------------
|
|
5
9
|
* Types
|
|
@@ -26,27 +30,6 @@ export interface MonoConfig {
|
|
|
26
30
|
* Helpers
|
|
27
31
|
* ------------------------------------------------------------------ */
|
|
28
32
|
|
|
29
|
-
/**
|
|
30
|
-
* Walk up from cwd until we find a directory containing package.json.
|
|
31
|
-
* This is treated as the project root.
|
|
32
|
-
*/
|
|
33
|
-
export function findProjectRoot(startDir: string = process.cwd()): string {
|
|
34
|
-
let current = startDir;
|
|
35
|
-
|
|
36
|
-
while (true) {
|
|
37
|
-
const pkg = path.join(current, 'package.json');
|
|
38
|
-
if (fs.existsSync(pkg)) return current;
|
|
39
|
-
|
|
40
|
-
const parent = path.dirname(current);
|
|
41
|
-
if (parent === current) break;
|
|
42
|
-
|
|
43
|
-
current = parent;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Fallback: use cwd
|
|
47
|
-
return startDir;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
33
|
export function getRootDirectory(): string {
|
|
51
34
|
return findProjectRoot();
|
|
52
35
|
}
|
package/src/project/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
+
import { findWorkspaceRoot } from '@mono-labs/shared'
|
|
3
4
|
|
|
4
5
|
/* ──────────────────────────────────────────────────────────
|
|
5
6
|
* Types
|
|
@@ -72,38 +73,16 @@ function detectWorkspaceAndConfigPath(
|
|
|
72
73
|
configFileName: string
|
|
73
74
|
): WorkspaceDetectResult {
|
|
74
75
|
const cwd = path.resolve(startDir)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const markers = ['pnpm-workspace.yaml', 'lerna.json', 'turbo.json', 'nx.json', '.git']
|
|
88
|
-
|
|
89
|
-
return markers.some((m) => fs.existsSync(path.join(dir, m)))
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
let dir = cwd
|
|
93
|
-
while (true) {
|
|
94
|
-
if (isWorkspaceRootDir(dir)) {
|
|
95
|
-
return {
|
|
96
|
-
cwd,
|
|
97
|
-
workspaceRoot: dir,
|
|
98
|
-
isWorkspaceRoot: dir === cwd,
|
|
99
|
-
configDir: dir,
|
|
100
|
-
configPath: path.join(dir, configFileName),
|
|
101
|
-
}
|
|
76
|
+
const result = findWorkspaceRoot(cwd)
|
|
77
|
+
|
|
78
|
+
if (result.isWorkspace || result.root !== cwd) {
|
|
79
|
+
return {
|
|
80
|
+
cwd,
|
|
81
|
+
workspaceRoot: result.root,
|
|
82
|
+
isWorkspaceRoot: result.root === cwd,
|
|
83
|
+
configDir: result.root,
|
|
84
|
+
configPath: path.join(result.root, configFileName),
|
|
102
85
|
}
|
|
103
|
-
|
|
104
|
-
const parent = path.dirname(dir)
|
|
105
|
-
if (parent === dir) break
|
|
106
|
-
dir = parent
|
|
107
86
|
}
|
|
108
87
|
|
|
109
88
|
return {
|