@mono-labs/project 0.1.284 → 0.1.286
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.
|
@@ -77,7 +77,11 @@ function matchSegment(patternSeg, name) {
|
|
|
77
77
|
return regex.test(name);
|
|
78
78
|
}
|
|
79
79
|
async function expandWorkspacePattern(root, pattern) {
|
|
80
|
-
|
|
80
|
+
// Drop leading './' segments: workspaces are commonly written as './apps/*',
|
|
81
|
+
// and a literal '.' segment would never match a directory name.
|
|
82
|
+
const segs = toPosix(pattern)
|
|
83
|
+
.split('/')
|
|
84
|
+
.filter((s) => s && s !== '.');
|
|
81
85
|
async function expandFrom(dir, segIndex) {
|
|
82
86
|
// Always resolve dir relative to working directory
|
|
83
87
|
const absDir = node_path_1.default.resolve(process.cwd(), dir);
|
|
@@ -89,7 +93,7 @@ async function expandWorkspacePattern(root, pattern) {
|
|
|
89
93
|
results.push(...(await expandFrom(absDir, segIndex + 1)));
|
|
90
94
|
const entries = await node_fs_1.promises.readdir(absDir, { withFileTypes: true }).catch(() => []);
|
|
91
95
|
for (const e of entries) {
|
|
92
|
-
if (e.isDirectory()) {
|
|
96
|
+
if (e.isDirectory() && !SKIP_DIRS.has(e.name)) {
|
|
93
97
|
results.push(...(await expandFrom(node_path_1.default.join(absDir, e.name), segIndex)));
|
|
94
98
|
}
|
|
95
99
|
}
|
|
@@ -115,6 +119,7 @@ async function findWorkspaceRoots(repoRoot, workspacePatterns) {
|
|
|
115
119
|
return [...new Set(roots)];
|
|
116
120
|
}
|
|
117
121
|
// ----------------- package discovery -----------------
|
|
122
|
+
// Matched by exact directory name, so 'out' does not cover 'cdk.out'.
|
|
118
123
|
const SKIP_DIRS = new Set([
|
|
119
124
|
'node_modules',
|
|
120
125
|
'.git',
|
|
@@ -122,34 +127,19 @@ const SKIP_DIRS = new Set([
|
|
|
122
127
|
'dist',
|
|
123
128
|
'build',
|
|
124
129
|
'out',
|
|
130
|
+
'cdk.out',
|
|
125
131
|
'coverage',
|
|
126
132
|
'.turbo',
|
|
127
133
|
]);
|
|
128
|
-
async function findPackageJsonFilesRecursive(startDir) {
|
|
129
|
-
const found = [];
|
|
130
|
-
async function walk(dir) {
|
|
131
|
-
// Always resolve dir relative to working directory
|
|
132
|
-
const absDir = node_path_1.default.resolve(process.cwd(), dir);
|
|
133
|
-
const entries = await node_fs_1.promises.readdir(absDir, { withFileTypes: true }).catch(() => []);
|
|
134
|
-
for (const e of entries) {
|
|
135
|
-
const full = node_path_1.default.join(absDir, e.name);
|
|
136
|
-
if (e.isDirectory()) {
|
|
137
|
-
if (!SKIP_DIRS.has(e.name))
|
|
138
|
-
await walk(full);
|
|
139
|
-
}
|
|
140
|
-
else if (e.isFile() && e.name === 'package.json') {
|
|
141
|
-
found.push(full);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
await walk(startDir);
|
|
146
|
-
return found;
|
|
147
|
-
}
|
|
148
134
|
async function collectPackagesFromWorkspaceRoots(workspaceRoots) {
|
|
149
135
|
const pkgJsonFiles = [];
|
|
136
|
+
// Roots are already fully expanded workspace directories, so each one owns its
|
|
137
|
+
// package.json directly. Walking deeper would pick up build artifacts (cdk.out
|
|
138
|
+
// asset bundles, vendored copies) that are not workspaces.
|
|
150
139
|
for (const root of workspaceRoots) {
|
|
151
|
-
|
|
152
|
-
|
|
140
|
+
const pkgJson = node_path_1.default.join(root, 'package.json');
|
|
141
|
+
if (await exists(pkgJson)) {
|
|
142
|
+
pkgJsonFiles.push(pkgJson);
|
|
153
143
|
}
|
|
154
144
|
}
|
|
155
145
|
const packages = [];
|
|
@@ -284,8 +274,11 @@ async function main() {
|
|
|
284
274
|
const workspacePatterns = normalizeWorkspacePatterns(rootPkg.workspaces);
|
|
285
275
|
const pkgMgr = `${(rootPkg.packageManager || 'yarn').split('@')[0]} mono`;
|
|
286
276
|
const workspaceRoots = await findWorkspaceRoots(REPO_ROOT, workspacePatterns);
|
|
287
|
-
|
|
288
|
-
|
|
277
|
+
// Fallback expands to the package directories themselves, not the containers,
|
|
278
|
+
// so every root is a real workspace owning its own package.json.
|
|
279
|
+
const roots = workspaceRoots.length
|
|
280
|
+
? workspaceRoots
|
|
281
|
+
: await findWorkspaceRoots(REPO_ROOT, ['packages/*', 'apps/*']);
|
|
289
282
|
const packages = await collectPackagesFromWorkspaceRoots(roots);
|
|
290
283
|
const lines = [];
|
|
291
284
|
lines.push(...formatQuickStart(pkgMgr));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mono-labs/project",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.286",
|
|
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.286",
|
|
36
36
|
"dotenv": "^17.2.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
@@ -86,7 +86,11 @@ function matchSegment(patternSeg: string, name: string): boolean {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
async function expandWorkspacePattern(root: string, pattern: string): Promise<string[]> {
|
|
89
|
-
|
|
89
|
+
// Drop leading './' segments: workspaces are commonly written as './apps/*',
|
|
90
|
+
// and a literal '.' segment would never match a directory name.
|
|
91
|
+
const segs = toPosix(pattern)
|
|
92
|
+
.split('/')
|
|
93
|
+
.filter((s) => s && s !== '.')
|
|
90
94
|
|
|
91
95
|
async function expandFrom(dir: string, segIndex: number): Promise<string[]> {
|
|
92
96
|
// Always resolve dir relative to working directory
|
|
@@ -101,7 +105,7 @@ async function expandWorkspacePattern(root: string, pattern: string): Promise<st
|
|
|
101
105
|
|
|
102
106
|
const entries = await fs.readdir(absDir, { withFileTypes: true }).catch(() => [])
|
|
103
107
|
for (const e of entries) {
|
|
104
|
-
if (e.isDirectory()) {
|
|
108
|
+
if (e.isDirectory() && !SKIP_DIRS.has(e.name)) {
|
|
105
109
|
results.push(...(await expandFrom(path.join(absDir, e.name), segIndex)))
|
|
106
110
|
}
|
|
107
111
|
}
|
|
@@ -134,6 +138,7 @@ async function findWorkspaceRoots(
|
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
// ----------------- package discovery -----------------
|
|
141
|
+
// Matched by exact directory name, so 'out' does not cover 'cdk.out'.
|
|
137
142
|
const SKIP_DIRS = new Set([
|
|
138
143
|
'node_modules',
|
|
139
144
|
'.git',
|
|
@@ -141,37 +146,21 @@ const SKIP_DIRS = new Set([
|
|
|
141
146
|
'dist',
|
|
142
147
|
'build',
|
|
143
148
|
'out',
|
|
149
|
+
'cdk.out',
|
|
144
150
|
'coverage',
|
|
145
151
|
'.turbo',
|
|
146
152
|
])
|
|
147
153
|
|
|
148
|
-
async function findPackageJsonFilesRecursive(startDir: string): Promise<string[]> {
|
|
149
|
-
const found: string[] = []
|
|
150
|
-
|
|
151
|
-
async function walk(dir: string): Promise<void> {
|
|
152
|
-
// Always resolve dir relative to working directory
|
|
153
|
-
const absDir = path.resolve(process.cwd(), dir)
|
|
154
|
-
const entries = await fs.readdir(absDir, { withFileTypes: true }).catch(() => [])
|
|
155
|
-
for (const e of entries) {
|
|
156
|
-
const full = path.join(absDir, e.name)
|
|
157
|
-
if (e.isDirectory()) {
|
|
158
|
-
if (!SKIP_DIRS.has(e.name)) await walk(full)
|
|
159
|
-
} else if (e.isFile() && e.name === 'package.json') {
|
|
160
|
-
found.push(full)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
await walk(startDir)
|
|
166
|
-
return found
|
|
167
|
-
}
|
|
168
|
-
|
|
169
154
|
async function collectPackagesFromWorkspaceRoots(workspaceRoots: string[]): Promise<PackageInfo[]> {
|
|
170
155
|
const pkgJsonFiles: string[] = []
|
|
171
156
|
|
|
157
|
+
// Roots are already fully expanded workspace directories, so each one owns its
|
|
158
|
+
// package.json directly. Walking deeper would pick up build artifacts (cdk.out
|
|
159
|
+
// asset bundles, vendored copies) that are not workspaces.
|
|
172
160
|
for (const root of workspaceRoots) {
|
|
173
|
-
|
|
174
|
-
|
|
161
|
+
const pkgJson = path.join(root, 'package.json')
|
|
162
|
+
if (await exists(pkgJson)) {
|
|
163
|
+
pkgJsonFiles.push(pkgJson)
|
|
175
164
|
}
|
|
176
165
|
}
|
|
177
166
|
|
|
@@ -319,8 +308,11 @@ async function main(): Promise<void> {
|
|
|
319
308
|
const pkgMgr = `${(rootPkg.packageManager || 'yarn').split('@')[0]} mono`
|
|
320
309
|
|
|
321
310
|
const workspaceRoots = await findWorkspaceRoots(REPO_ROOT, workspacePatterns)
|
|
322
|
-
|
|
323
|
-
|
|
311
|
+
// Fallback expands to the package directories themselves, not the containers,
|
|
312
|
+
// so every root is a real workspace owning its own package.json.
|
|
313
|
+
const roots = workspaceRoots.length
|
|
314
|
+
? workspaceRoots
|
|
315
|
+
: await findWorkspaceRoots(REPO_ROOT, ['packages/*', 'apps/*'])
|
|
324
316
|
|
|
325
317
|
const packages = await collectPackagesFromWorkspaceRoots(roots)
|
|
326
318
|
|