@kb-labs/devkit 1.0.0 → 1.2.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/.github/workflow-templates/deploy.yml +28 -0
- package/.github/workflow-templates/docker-build.yml +25 -0
- package/.github/workflows/deploy-reusable.yml +110 -0
- package/.github/workflows/docker-build-reusable.yml +110 -0
- package/README.md +186 -34
- package/bin/devkit-architecture.mjs +14 -32
- package/bin/devkit-build-order.mjs +2 -30
- package/bin/devkit-check-build-readiness.mjs +14 -24
- package/bin/devkit-check-commands.mjs +9 -25
- package/bin/devkit-check-deprecated.mjs +24 -39
- package/bin/devkit-check-duplicates.mjs +3 -34
- package/bin/devkit-check-exports.mjs +3 -34
- package/bin/devkit-check-imports.mjs +3 -34
- package/bin/devkit-check-paths.mjs +9 -32
- package/bin/devkit-check-structure.mjs +3 -34
- package/bin/devkit-check-types.mjs +8 -31
- package/bin/devkit-fix-deps.mjs +3 -33
- package/bin/devkit-health.mjs +13 -35
- package/bin/devkit-stats.mjs +3 -31
- package/bin/devkit-types-audit.mjs +13 -34
- package/bin/devkit-types-order.mjs +8 -29
- package/bin/devkit-validate-naming.mjs +9 -35
- package/bin/devkit-visualize.mjs +3 -34
- package/bin/lib/find-packages.mjs +77 -0
- package/eslint/node.js +3 -1
- package/eslint/plugin.js +51 -0
- package/eslint/react.js +2 -1
- package/package.json +29 -24
- package/sync/index.mjs +27 -3
- package/tsconfig/dist/tsconfig.tools.tsbuildinfo +1 -1
- package/tsconfig/node.json +2 -1
- package/tsup/bin.js +5 -0
- package/tsup/dual.js +5 -0
- package/tsup/node.js +41 -3
- package/tsup/react-lib.js +6 -1
- package/tsup/sdk.js +5 -0
|
@@ -17,6 +17,9 @@ import { execSync, spawn } from 'node:child_process';
|
|
|
17
17
|
import fs from 'node:fs';
|
|
18
18
|
import path from 'node:path';
|
|
19
19
|
|
|
20
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
21
|
+
import { findPackages } from './lib/find-packages.mjs';
|
|
22
|
+
|
|
20
23
|
// ANSI colors
|
|
21
24
|
const colors = {
|
|
22
25
|
reset: '\x1b[0m',
|
|
@@ -49,31 +52,12 @@ const options = {
|
|
|
49
52
|
* Find all plugin manifests in monorepo
|
|
50
53
|
*/
|
|
51
54
|
function findPluginManifests(rootDir) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
59
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
60
|
-
|
|
61
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
62
|
-
|
|
63
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
64
|
-
|
|
65
|
-
for (const pkgDir of packageDirs) {
|
|
66
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
67
|
-
|
|
68
|
-
const manifestPath = path.join(packagesDir, pkgDir.name, 'manifest.json');
|
|
69
|
-
|
|
70
|
-
if (fs.existsSync(manifestPath)) {
|
|
71
|
-
manifests.push(manifestPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return manifests;
|
|
55
|
+
return findPackages(rootDir)
|
|
56
|
+
.map((pkgPath) => {
|
|
57
|
+
const manifestPath = path.join(path.dirname(pkgPath), 'manifest.json');
|
|
58
|
+
return fs.existsSync(manifestPath) ? manifestPath : null;
|
|
59
|
+
})
|
|
60
|
+
.filter(Boolean);
|
|
77
61
|
}
|
|
78
62
|
|
|
79
63
|
/**
|
|
@@ -27,6 +27,9 @@ import fs from 'node:fs';
|
|
|
27
27
|
import path from 'node:path';
|
|
28
28
|
import { fileURLToPath } from 'node:url';
|
|
29
29
|
|
|
30
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
31
|
+
import { findPackages as _findPackagePaths } from './lib/find-packages.mjs';
|
|
32
|
+
|
|
30
33
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
31
34
|
|
|
32
35
|
// ANSI colors
|
|
@@ -85,48 +88,30 @@ Options:
|
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
/**
|
|
88
|
-
* Find all kb-labs-* packages
|
|
91
|
+
* Find all kb-labs-* packages with src directories
|
|
89
92
|
*/
|
|
90
93
|
function findPackages(rootDir, filterPackage) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
110
|
-
const srcDir = path.join(packagesDir, pkgDir.name, 'src');
|
|
111
|
-
|
|
112
|
-
if (fs.existsSync(packageJsonPath) && fs.existsSync(srcDir)) {
|
|
113
|
-
try {
|
|
114
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
115
|
-
packages.push({
|
|
116
|
-
name: packageJson.name,
|
|
117
|
-
shortName: pkgDir.name,
|
|
118
|
-
repo: entry.name,
|
|
119
|
-
path: path.join(packagesDir, pkgDir.name),
|
|
120
|
-
srcPath: srcDir,
|
|
121
|
-
});
|
|
122
|
-
} catch {
|
|
123
|
-
// Skip invalid package.json
|
|
124
|
-
}
|
|
94
|
+
return _findPackagePaths(rootDir, filterPackage)
|
|
95
|
+
.map((pkgPath) => {
|
|
96
|
+
const dir = path.dirname(pkgPath);
|
|
97
|
+
const srcDir = path.join(dir, 'src');
|
|
98
|
+
if (!fs.existsSync(srcDir)) return null;
|
|
99
|
+
try {
|
|
100
|
+
const packageJson = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
101
|
+
const parts = pkgPath.split(path.sep);
|
|
102
|
+
const repo = parts.find((p) => p.startsWith('kb-labs-')) || 'unknown';
|
|
103
|
+
return {
|
|
104
|
+
name: packageJson.name,
|
|
105
|
+
shortName: path.basename(dir),
|
|
106
|
+
repo,
|
|
107
|
+
path: dir,
|
|
108
|
+
srcPath: srcDir,
|
|
109
|
+
};
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
125
112
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return packages;
|
|
113
|
+
})
|
|
114
|
+
.filter(Boolean);
|
|
130
115
|
}
|
|
131
116
|
|
|
132
117
|
/**
|
|
@@ -19,6 +19,9 @@ import fs from 'node:fs';
|
|
|
19
19
|
import path from 'node:path';
|
|
20
20
|
import { fileURLToPath } from 'node:url';
|
|
21
21
|
|
|
22
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
23
|
+
import { findPackages } from './lib/find-packages.mjs';
|
|
24
|
+
|
|
22
25
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
23
26
|
|
|
24
27
|
// ANSI colors
|
|
@@ -45,40 +48,6 @@ const options = {
|
|
|
45
48
|
verbose: args.includes('--verbose') || args.includes('-v'),
|
|
46
49
|
};
|
|
47
50
|
|
|
48
|
-
/**
|
|
49
|
-
* Find all packages in monorepo
|
|
50
|
-
*/
|
|
51
|
-
function findPackages(rootDir, filterPackage) {
|
|
52
|
-
const packages = [];
|
|
53
|
-
const entries = fs.readdirSync(rootDir, { withFileTypes: true });
|
|
54
|
-
|
|
55
|
-
for (const entry of entries) {
|
|
56
|
-
if (!entry.isDirectory() || !entry.name.startsWith('kb-labs-')) {continue;}
|
|
57
|
-
|
|
58
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
59
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
60
|
-
|
|
61
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
62
|
-
|
|
63
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
64
|
-
|
|
65
|
-
for (const pkgDir of packageDirs) {
|
|
66
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
67
|
-
|
|
68
|
-
// Filter by package name if specified
|
|
69
|
-
if (filterPackage && pkgDir.name !== filterPackage) {continue;}
|
|
70
|
-
|
|
71
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
72
|
-
|
|
73
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
74
|
-
packages.push(packageJsonPath);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return packages;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
51
|
/**
|
|
83
52
|
* Collect all dependencies from all packages
|
|
84
53
|
*/
|
|
@@ -19,6 +19,9 @@ import fs from 'node:fs';
|
|
|
19
19
|
import path from 'node:path';
|
|
20
20
|
import { fileURLToPath } from 'node:url';
|
|
21
21
|
|
|
22
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
23
|
+
import { findPackages } from './lib/find-packages.mjs';
|
|
24
|
+
|
|
22
25
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
23
26
|
|
|
24
27
|
// ANSI colors
|
|
@@ -382,40 +385,6 @@ function checkPackage(packageJsonPath, allPackages) {
|
|
|
382
385
|
};
|
|
383
386
|
}
|
|
384
387
|
|
|
385
|
-
/**
|
|
386
|
-
* Find all packages in monorepo
|
|
387
|
-
*/
|
|
388
|
-
function findPackages(rootDir, filterPackage) {
|
|
389
|
-
const packages = [];
|
|
390
|
-
const entries = fs.readdirSync(rootDir, { withFileTypes: true });
|
|
391
|
-
|
|
392
|
-
for (const entry of entries) {
|
|
393
|
-
if (!entry.isDirectory() || !entry.name.startsWith('kb-labs-')) {continue;}
|
|
394
|
-
|
|
395
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
396
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
397
|
-
|
|
398
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
399
|
-
|
|
400
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
401
|
-
|
|
402
|
-
for (const pkgDir of packageDirs) {
|
|
403
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
404
|
-
|
|
405
|
-
// Filter by package name if specified
|
|
406
|
-
if (filterPackage && pkgDir.name !== filterPackage) {continue;}
|
|
407
|
-
|
|
408
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
409
|
-
|
|
410
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
411
|
-
packages.push(packageJsonPath);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return packages;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
388
|
/**
|
|
420
389
|
* Main function
|
|
421
390
|
*/
|
|
@@ -19,6 +19,9 @@ import fs from 'node:fs';
|
|
|
19
19
|
import path from 'node:path';
|
|
20
20
|
import { fileURLToPath } from 'node:url';
|
|
21
21
|
|
|
22
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
23
|
+
import { findPackages } from './lib/find-packages.mjs';
|
|
24
|
+
|
|
22
25
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
23
26
|
|
|
24
27
|
/**
|
|
@@ -356,40 +359,6 @@ function checkPackage(packageJsonPath) {
|
|
|
356
359
|
};
|
|
357
360
|
}
|
|
358
361
|
|
|
359
|
-
/**
|
|
360
|
-
* Find all packages in monorepo
|
|
361
|
-
*/
|
|
362
|
-
function findPackages(rootDir, filterPackage) {
|
|
363
|
-
const packages = [];
|
|
364
|
-
const entries = fs.readdirSync(rootDir, { withFileTypes: true });
|
|
365
|
-
|
|
366
|
-
for (const entry of entries) {
|
|
367
|
-
if (!entry.isDirectory() || !entry.name.startsWith('kb-labs-')) {continue;}
|
|
368
|
-
|
|
369
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
370
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
371
|
-
|
|
372
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
373
|
-
|
|
374
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
375
|
-
|
|
376
|
-
for (const pkgDir of packageDirs) {
|
|
377
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
378
|
-
|
|
379
|
-
// Filter by package name if specified
|
|
380
|
-
if (filterPackage && pkgDir.name !== filterPackage) {continue;}
|
|
381
|
-
|
|
382
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
383
|
-
|
|
384
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
385
|
-
packages.push(packageJsonPath);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
return packages;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
362
|
/**
|
|
394
363
|
* Detect circular dependencies between packages
|
|
395
364
|
*/
|
|
@@ -21,6 +21,9 @@ import fs from 'node:fs';
|
|
|
21
21
|
import path from 'node:path';
|
|
22
22
|
import { fileURLToPath } from 'node:url';
|
|
23
23
|
|
|
24
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
25
|
+
import { findPackages as _findPackagePaths } from './lib/find-packages.mjs';
|
|
26
|
+
|
|
24
27
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
25
28
|
|
|
26
29
|
// ANSI colors
|
|
@@ -52,40 +55,14 @@ const options = {
|
|
|
52
55
|
};
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
|
-
* Find all packages in monorepo
|
|
58
|
+
* Find all packages in monorepo (returns objects with path, dir, repo)
|
|
56
59
|
*/
|
|
57
60
|
function findPackages(rootDir, filterPackage) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
65
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
66
|
-
|
|
67
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
68
|
-
|
|
69
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
70
|
-
|
|
71
|
-
for (const pkgDir of packageDirs) {
|
|
72
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
73
|
-
|
|
74
|
-
if (filterPackage && pkgDir.name !== filterPackage) {continue;}
|
|
75
|
-
|
|
76
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
77
|
-
|
|
78
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
79
|
-
packages.push({
|
|
80
|
-
path: packageJsonPath,
|
|
81
|
-
dir: path.join(packagesDir, pkgDir.name),
|
|
82
|
-
repo: entry.name,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return packages;
|
|
61
|
+
return _findPackagePaths(rootDir, filterPackage).map((pkgPath) => {
|
|
62
|
+
const parts = pkgPath.split(path.sep);
|
|
63
|
+
const repo = parts.find((p) => p.startsWith('kb-labs-')) || 'unknown';
|
|
64
|
+
return { path: pkgPath, dir: path.dirname(pkgPath), repo };
|
|
65
|
+
});
|
|
89
66
|
}
|
|
90
67
|
|
|
91
68
|
/**
|
|
@@ -20,6 +20,9 @@ import fs from 'node:fs';
|
|
|
20
20
|
import path from 'node:path';
|
|
21
21
|
import { fileURLToPath } from 'node:url';
|
|
22
22
|
|
|
23
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
24
|
+
import { findPackages } from './lib/find-packages.mjs';
|
|
25
|
+
|
|
23
26
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
24
27
|
|
|
25
28
|
// ANSI colors
|
|
@@ -272,40 +275,6 @@ function checkPackage(packageJsonPath) {
|
|
|
272
275
|
};
|
|
273
276
|
}
|
|
274
277
|
|
|
275
|
-
/**
|
|
276
|
-
* Find all packages in monorepo
|
|
277
|
-
*/
|
|
278
|
-
function findPackages(rootDir, filterPackage) {
|
|
279
|
-
const packages = [];
|
|
280
|
-
const entries = fs.readdirSync(rootDir, { withFileTypes: true });
|
|
281
|
-
|
|
282
|
-
for (const entry of entries) {
|
|
283
|
-
if (!entry.isDirectory() || !entry.name.startsWith('kb-labs-')) {continue;}
|
|
284
|
-
|
|
285
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
286
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
287
|
-
|
|
288
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
289
|
-
|
|
290
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
291
|
-
|
|
292
|
-
for (const pkgDir of packageDirs) {
|
|
293
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
294
|
-
|
|
295
|
-
// Filter by package name if specified
|
|
296
|
-
if (filterPackage && pkgDir.name !== filterPackage) {continue;}
|
|
297
|
-
|
|
298
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
299
|
-
|
|
300
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
301
|
-
packages.push(packageJsonPath);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
return packages;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
278
|
/**
|
|
310
279
|
* Main function
|
|
311
280
|
*/
|
|
@@ -18,6 +18,9 @@ import fs from 'node:fs';
|
|
|
18
18
|
import path from 'node:path';
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
20
|
|
|
21
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
22
|
+
import { findPackages as _findPackagePaths } from './lib/find-packages.mjs';
|
|
23
|
+
|
|
21
24
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
22
25
|
|
|
23
26
|
// ANSI colors
|
|
@@ -50,39 +53,13 @@ const options = {
|
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
/**
|
|
53
|
-
* Find all packages
|
|
56
|
+
* Find all packages (returns objects with path, dir)
|
|
54
57
|
*/
|
|
55
58
|
function findPackages(rootDir, filterPackage) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!entry.isDirectory() || !entry.name.startsWith('kb-labs-')) {continue;}
|
|
61
|
-
|
|
62
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
63
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
64
|
-
|
|
65
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
66
|
-
|
|
67
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
68
|
-
|
|
69
|
-
for (const pkgDir of packageDirs) {
|
|
70
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
71
|
-
|
|
72
|
-
if (filterPackage && pkgDir.name !== filterPackage) {continue;}
|
|
73
|
-
|
|
74
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
75
|
-
|
|
76
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
77
|
-
packages.push({
|
|
78
|
-
path: packageJsonPath,
|
|
79
|
-
dir: path.join(packagesDir, pkgDir.name),
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return packages;
|
|
59
|
+
return _findPackagePaths(rootDir, filterPackage).map((pkgPath) => ({
|
|
60
|
+
path: pkgPath,
|
|
61
|
+
dir: path.dirname(pkgPath),
|
|
62
|
+
}));
|
|
86
63
|
}
|
|
87
64
|
|
|
88
65
|
/**
|
package/bin/devkit-fix-deps.mjs
CHANGED
|
@@ -24,6 +24,9 @@ import path from 'node:path';
|
|
|
24
24
|
import { fileURLToPath } from 'node:url';
|
|
25
25
|
import { execSync } from 'node:child_process';
|
|
26
26
|
|
|
27
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
28
|
+
import { findPackages } from './lib/find-packages.mjs';
|
|
29
|
+
|
|
27
30
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
28
31
|
|
|
29
32
|
// ANSI colors
|
|
@@ -66,39 +69,6 @@ if (options.all) {
|
|
|
66
69
|
options.alignVersions = true;
|
|
67
70
|
}
|
|
68
71
|
|
|
69
|
-
/**
|
|
70
|
-
* Find all packages in monorepo
|
|
71
|
-
*/
|
|
72
|
-
function findPackages(rootDir, filterPackage) {
|
|
73
|
-
const packages = [];
|
|
74
|
-
const entries = fs.readdirSync(rootDir, { withFileTypes: true });
|
|
75
|
-
|
|
76
|
-
for (const entry of entries) {
|
|
77
|
-
if (!entry.isDirectory() || !entry.name.startsWith('kb-labs-')) {continue;}
|
|
78
|
-
|
|
79
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
80
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
81
|
-
|
|
82
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
83
|
-
|
|
84
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
85
|
-
|
|
86
|
-
for (const pkgDir of packageDirs) {
|
|
87
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
88
|
-
|
|
89
|
-
if (filterPackage && pkgDir.name !== filterPackage) {continue;}
|
|
90
|
-
|
|
91
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
92
|
-
|
|
93
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
94
|
-
packages.push(packageJsonPath);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return packages;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
72
|
/**
|
|
103
73
|
* Extract imports from source files
|
|
104
74
|
*/
|
package/bin/devkit-health.mjs
CHANGED
|
@@ -28,6 +28,9 @@ import path from 'node:path';
|
|
|
28
28
|
import { fileURLToPath } from 'node:url';
|
|
29
29
|
import { execSync } from 'node:child_process';
|
|
30
30
|
|
|
31
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
32
|
+
import { findPackages as _findPackagePaths } from './lib/find-packages.mjs';
|
|
33
|
+
|
|
31
34
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
32
35
|
|
|
33
36
|
// ANSI colors
|
|
@@ -66,42 +69,17 @@ const rootDir = findMonorepoRoot();
|
|
|
66
69
|
* Find all packages in monorepo
|
|
67
70
|
*/
|
|
68
71
|
function findAllPackages() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
? execSync(`find ${rootDir} -type d -path "*/${pattern}" 2>/dev/null || true`, { encoding: 'utf-8' })
|
|
78
|
-
.split('\n')
|
|
79
|
-
.filter(Boolean)
|
|
80
|
-
: [path.join(rootDir, pattern)];
|
|
81
|
-
|
|
82
|
-
for (const dir of dirs) {
|
|
83
|
-
if (!fs.existsSync(dir)) {continue;}
|
|
84
|
-
|
|
85
|
-
const subDirs = fs.readdirSync(dir, { withFileTypes: true })
|
|
86
|
-
.filter((d) => d.isDirectory())
|
|
87
|
-
.map((d) => path.join(dir, d.name));
|
|
88
|
-
|
|
89
|
-
for (const subDir of subDirs) {
|
|
90
|
-
const pkgPath = path.join(subDir, 'package.json');
|
|
91
|
-
if (fs.existsSync(pkgPath)) {
|
|
92
|
-
try {
|
|
93
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
94
|
-
if (packageFilter && !pkg.name.includes(packageFilter)) {continue;}
|
|
95
|
-
packages.push({ name: pkg.name, path: subDir, pkg });
|
|
96
|
-
} catch (err) {
|
|
97
|
-
// Skip invalid package.json
|
|
98
|
-
}
|
|
99
|
-
}
|
|
72
|
+
return _findPackagePaths(rootDir)
|
|
73
|
+
.map((pkgJsonPath) => {
|
|
74
|
+
try {
|
|
75
|
+
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
|
76
|
+
if (packageFilter && !pkg.name.includes(packageFilter)) return null;
|
|
77
|
+
return { name: pkg.name, path: path.dirname(pkgJsonPath), pkg };
|
|
78
|
+
} catch (err) {
|
|
79
|
+
return null;
|
|
100
80
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return packages;
|
|
81
|
+
})
|
|
82
|
+
.filter(Boolean);
|
|
105
83
|
}
|
|
106
84
|
|
|
107
85
|
/**
|
package/bin/devkit-stats.mjs
CHANGED
|
@@ -17,6 +17,9 @@ import fs from 'node:fs';
|
|
|
17
17
|
import path from 'node:path';
|
|
18
18
|
import { fileURLToPath } from 'node:url';
|
|
19
19
|
|
|
20
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
21
|
+
import { findPackages } from './lib/find-packages.mjs';
|
|
22
|
+
|
|
20
23
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
21
24
|
|
|
22
25
|
// ANSI colors
|
|
@@ -46,37 +49,6 @@ const options = {
|
|
|
46
49
|
health: args.includes('--health'),
|
|
47
50
|
};
|
|
48
51
|
|
|
49
|
-
/**
|
|
50
|
-
* Find all packages
|
|
51
|
-
*/
|
|
52
|
-
function findPackages(rootDir) {
|
|
53
|
-
const packages = [];
|
|
54
|
-
const entries = fs.readdirSync(rootDir, { withFileTypes: true });
|
|
55
|
-
|
|
56
|
-
for (const entry of entries) {
|
|
57
|
-
if (!entry.isDirectory() || !entry.name.startsWith('kb-labs-')) {continue;}
|
|
58
|
-
|
|
59
|
-
const repoPath = path.join(rootDir, entry.name);
|
|
60
|
-
const packagesDir = path.join(repoPath, 'packages');
|
|
61
|
-
|
|
62
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
63
|
-
|
|
64
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
65
|
-
|
|
66
|
-
for (const pkgDir of packageDirs) {
|
|
67
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
68
|
-
|
|
69
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
70
|
-
|
|
71
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
72
|
-
packages.push(packageJsonPath);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return packages;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
52
|
/**
|
|
81
53
|
* Calculate package size
|
|
82
54
|
*/
|
|
@@ -25,6 +25,9 @@ import fs from 'node:fs';
|
|
|
25
25
|
import path from 'node:path';
|
|
26
26
|
import { fileURLToPath } from 'node:url';
|
|
27
27
|
|
|
28
|
+
// Shared package discovery — supports both flat and categorized layouts
|
|
29
|
+
import { findPackages as _findPackagePaths } from './lib/find-packages.mjs';
|
|
30
|
+
|
|
28
31
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
29
32
|
|
|
30
33
|
// ANSI colors
|
|
@@ -57,42 +60,18 @@ const options = {
|
|
|
57
60
|
};
|
|
58
61
|
|
|
59
62
|
/**
|
|
60
|
-
* Find all packages
|
|
63
|
+
* Find all packages with TypeScript configs
|
|
61
64
|
*/
|
|
62
65
|
function findPackages(rootDir) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!fs.existsSync(packagesDir)) {continue;}
|
|
73
|
-
|
|
74
|
-
const packageDirs = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
75
|
-
|
|
76
|
-
for (const pkgDir of packageDirs) {
|
|
77
|
-
if (!pkgDir.isDirectory()) {continue;}
|
|
78
|
-
|
|
79
|
-
const packageJsonPath = path.join(packagesDir, pkgDir.name, 'package.json');
|
|
80
|
-
const tsconfigPath = path.join(packagesDir, pkgDir.name, 'tsconfig.json');
|
|
81
|
-
|
|
82
|
-
if (fs.existsSync(packageJsonPath) && fs.existsSync(tsconfigPath)) {
|
|
83
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
84
|
-
|
|
85
|
-
packages.push({
|
|
86
|
-
name: packageJson.name,
|
|
87
|
-
path: packageJsonPath,
|
|
88
|
-
dir: path.join(packagesDir, pkgDir.name),
|
|
89
|
-
tsconfigPath,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return packages;
|
|
66
|
+
return _findPackagePaths(rootDir)
|
|
67
|
+
.map((pkgPath) => {
|
|
68
|
+
const dir = path.dirname(pkgPath);
|
|
69
|
+
const tsconfigPath = path.join(dir, 'tsconfig.json');
|
|
70
|
+
if (!fs.existsSync(tsconfigPath)) return null;
|
|
71
|
+
const packageJson = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
72
|
+
return { name: packageJson.name, path: pkgPath, dir, tsconfigPath };
|
|
73
|
+
})
|
|
74
|
+
.filter(Boolean);
|
|
96
75
|
}
|
|
97
76
|
|
|
98
77
|
/**
|