@buoy-design/cli 0.3.36 → 0.3.37
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/commands/check.js.sync-conflict-20260313-114446-6PCZ3ZU.map +1 -0
- package/dist/commands/dock.js.sync-conflict-20260313-172700-6PCZ3ZU.map +1 -0
- package/dist/commands/show.d.ts.map +1 -1
- package/dist/commands/show.js +131 -12
- package/dist/commands/show.js.map +1 -1
- package/dist/config/loader.d.ts.sync-conflict-20260313-145931-6PCZ3ZU.map +1 -0
- package/dist/config/schema.sync-conflict-20260313-173553-6PCZ3ZU.d.ts +1812 -0
- package/dist/config/schema.sync-conflict-20260313-173553-6PCZ3ZU.d.ts.map +1 -0
- package/dist/config/schema.sync-conflict-20260313-173553-6PCZ3ZU.js +214 -0
- package/dist/config/schema.sync-conflict-20260313-173553-6PCZ3ZU.js.map +1 -0
- package/dist/detect/frameworks.sync-conflict-20260313-150557-6PCZ3ZU.js +252 -0
- package/dist/detect/monorepo-patterns.sync-conflict-20260311-182757-6PCZ3ZU.js +209 -0
- package/dist/hooks/index.sync-conflict-20260311-082258-6PCZ3ZU.js +616 -0
- package/dist/output/reporters.js.sync-conflict-20260313-164629-6PCZ3ZU.map +1 -0
- package/dist/services/drift-analysis.d.ts +2 -0
- package/dist/services/drift-analysis.d.ts.map +1 -1
- package/dist/services/drift-analysis.js +1 -0
- package/dist/services/drift-analysis.js.map +1 -1
- package/dist/services/drift-analysis.js.sync-conflict-20260313-152307-6PCZ3ZU.map +1 -0
- package/dist/services/remote-check.d.ts +4 -0
- package/dist/services/remote-check.d.ts.map +1 -1
- package/dist/services/remote-check.js +15 -1
- package/dist/services/remote-check.js.map +1 -1
- package/dist/services/skill-export.js.sync-conflict-20260313-155735-6PCZ3ZU.map +1 -0
- package/dist/services/skill-export.sync-conflict-20260313-161246-6PCZ3ZU.js +737 -0
- package/package.json +3 -3
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monorepo pattern detection and expansion
|
|
3
|
+
*
|
|
4
|
+
* Handles automatic pattern expansion for popular monorepo structures:
|
|
5
|
+
* - pnpm workspaces (pnpm-workspace.yaml)
|
|
6
|
+
* - yarn/npm workspaces (package.json workspaces)
|
|
7
|
+
* - Lerna (lerna.json)
|
|
8
|
+
* - Nx workspaces (nx.json with apps/libs structure)
|
|
9
|
+
* - Turborepo (turbo.json)
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync } from 'fs';
|
|
12
|
+
import { resolve } from 'path';
|
|
13
|
+
import { parse as parseYaml } from 'yaml';
|
|
14
|
+
// Note: These patterns are used in project-detector.ts for scanning monorepo directories
|
|
15
|
+
// The actual patterns are defined inline there for better maintainability
|
|
16
|
+
/**
|
|
17
|
+
* Detect monorepo configuration from project root
|
|
18
|
+
*/
|
|
19
|
+
export function detectMonorepoConfig(projectRoot) {
|
|
20
|
+
// Check for pnpm workspaces
|
|
21
|
+
const pnpmWorkspacePath = resolve(projectRoot, 'pnpm-workspace.yaml');
|
|
22
|
+
if (existsSync(pnpmWorkspacePath)) {
|
|
23
|
+
const patterns = parsePnpmWorkspaces(pnpmWorkspacePath);
|
|
24
|
+
return { type: 'pnpm', workspacePatterns: patterns };
|
|
25
|
+
}
|
|
26
|
+
// Check for lerna.json
|
|
27
|
+
const lernaPath = resolve(projectRoot, 'lerna.json');
|
|
28
|
+
if (existsSync(lernaPath)) {
|
|
29
|
+
const patterns = parseLernaConfig(lernaPath);
|
|
30
|
+
return { type: 'lerna', workspacePatterns: patterns };
|
|
31
|
+
}
|
|
32
|
+
// Check for nx.json
|
|
33
|
+
const nxPath = resolve(projectRoot, 'nx.json');
|
|
34
|
+
if (existsSync(nxPath)) {
|
|
35
|
+
// Nx typically uses apps/ and libs/ structure
|
|
36
|
+
return { type: 'nx', workspacePatterns: ['apps/*', 'libs/*', 'packages/*'] };
|
|
37
|
+
}
|
|
38
|
+
// Check for turbo.json
|
|
39
|
+
const turboPath = resolve(projectRoot, 'turbo.json');
|
|
40
|
+
if (existsSync(turboPath)) {
|
|
41
|
+
// Turborepo uses package.json workspaces or pnpm-workspace.yaml
|
|
42
|
+
// Fall through to check package.json
|
|
43
|
+
}
|
|
44
|
+
// Check for package.json workspaces (yarn/npm)
|
|
45
|
+
const pkgPath = resolve(projectRoot, 'package.json');
|
|
46
|
+
if (existsSync(pkgPath)) {
|
|
47
|
+
try {
|
|
48
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
49
|
+
const workspaces = pkg.workspaces;
|
|
50
|
+
if (workspaces) {
|
|
51
|
+
// Handle both array and object format
|
|
52
|
+
const patterns = Array.isArray(workspaces)
|
|
53
|
+
? workspaces
|
|
54
|
+
: (workspaces.packages || []);
|
|
55
|
+
if (patterns.length > 0) {
|
|
56
|
+
// Determine if it's turborepo with npm/yarn workspaces
|
|
57
|
+
const type = existsSync(turboPath) ? 'turborepo' :
|
|
58
|
+
existsSync(resolve(projectRoot, 'yarn.lock')) ? 'yarn' : 'npm';
|
|
59
|
+
return { type, workspacePatterns: patterns };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Invalid JSON, continue
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { type: null, workspacePatterns: [] };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parse pnpm-workspace.yaml to get workspace patterns
|
|
71
|
+
*/
|
|
72
|
+
function parsePnpmWorkspaces(filePath) {
|
|
73
|
+
try {
|
|
74
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
75
|
+
const config = parseYaml(content);
|
|
76
|
+
return config?.packages || [];
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Default pnpm patterns
|
|
80
|
+
return ['packages/*'];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Parse lerna.json to get workspace patterns
|
|
85
|
+
*/
|
|
86
|
+
function parseLernaConfig(filePath) {
|
|
87
|
+
try {
|
|
88
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
89
|
+
const config = JSON.parse(content);
|
|
90
|
+
return config?.packages || ['packages/*'];
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return ['packages/*'];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Expand file patterns for monorepo structures
|
|
98
|
+
*
|
|
99
|
+
* Given base patterns like ['src/**\/*.tsx'], this function expands them
|
|
100
|
+
* to include monorepo package locations like ['packages/*\/src/**\/*.tsx']
|
|
101
|
+
*
|
|
102
|
+
* @param basePatterns - Original file patterns (e.g., ['src/**\/*.tsx'])
|
|
103
|
+
* @param monorepoConfig - Detected monorepo configuration
|
|
104
|
+
* @returns Expanded patterns for the monorepo structure
|
|
105
|
+
*/
|
|
106
|
+
export function expandPatternsForMonorepo(basePatterns, monorepoConfig) {
|
|
107
|
+
if (!monorepoConfig.type || monorepoConfig.workspacePatterns.length === 0) {
|
|
108
|
+
return {
|
|
109
|
+
basePatterns,
|
|
110
|
+
monorepoPatterns: [],
|
|
111
|
+
allPatterns: basePatterns,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const monorepoPatterns = [];
|
|
115
|
+
for (const workspacePattern of monorepoConfig.workspacePatterns) {
|
|
116
|
+
// Convert workspace patterns like 'packages/*' to component patterns
|
|
117
|
+
// Remove trailing /* if present for cleaner paths
|
|
118
|
+
const baseWorkspace = workspacePattern.replace(/\/\*+$/, '');
|
|
119
|
+
for (const basePattern of basePatterns) {
|
|
120
|
+
// Handle patterns that start with 'src/'
|
|
121
|
+
if (basePattern.startsWith('src/')) {
|
|
122
|
+
// packages/* + src/**/*.tsx -> packages/*/src/**/*.tsx
|
|
123
|
+
monorepoPatterns.push(`${baseWorkspace}/*/${basePattern}`);
|
|
124
|
+
// Also check for scoped packages: packages/@scope/*/src/**/*.tsx
|
|
125
|
+
if (baseWorkspace === 'packages') {
|
|
126
|
+
monorepoPatterns.push(`packages/@*/*/${basePattern}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// For patterns not starting with src/, add them under workspace packages
|
|
131
|
+
// **/*.tsx -> packages/*/src/**/*.tsx
|
|
132
|
+
monorepoPatterns.push(`${baseWorkspace}/*/src/${basePattern}`);
|
|
133
|
+
if (baseWorkspace === 'packages') {
|
|
134
|
+
monorepoPatterns.push(`packages/@*/*/src/${basePattern}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Add standard monorepo paths that might not be in workspace config
|
|
140
|
+
// but are commonly used (e.g., apps/ for Nx)
|
|
141
|
+
const additionalPatterns = [];
|
|
142
|
+
if (monorepoConfig.type === 'nx' || monorepoConfig.type === 'turborepo') {
|
|
143
|
+
for (const basePattern of basePatterns) {
|
|
144
|
+
if (basePattern.startsWith('src/')) {
|
|
145
|
+
additionalPatterns.push(`apps/*/${basePattern}`);
|
|
146
|
+
additionalPatterns.push(`libs/*/${basePattern}`);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
additionalPatterns.push(`apps/*/src/${basePattern}`);
|
|
150
|
+
additionalPatterns.push(`libs/*/src/${basePattern}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// Combine and deduplicate
|
|
155
|
+
const allMonorepoPatterns = Array.from(new Set([...monorepoPatterns, ...additionalPatterns]));
|
|
156
|
+
return {
|
|
157
|
+
basePatterns,
|
|
158
|
+
monorepoPatterns: allMonorepoPatterns,
|
|
159
|
+
allPatterns: Array.from(new Set([...basePatterns, ...allMonorepoPatterns])),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get default include patterns for a framework, expanded for monorepo if detected
|
|
164
|
+
*
|
|
165
|
+
* @param framework - Framework name (react, vue, svelte, angular)
|
|
166
|
+
* @param projectRoot - Project root directory
|
|
167
|
+
* @returns Include patterns appropriate for the project structure
|
|
168
|
+
*/
|
|
169
|
+
export function getIncludePatternsForFramework(framework, projectRoot) {
|
|
170
|
+
// Base patterns by framework
|
|
171
|
+
const basePatterns = {
|
|
172
|
+
react: ['src/**/*.tsx', 'src/**/*.jsx'],
|
|
173
|
+
vue: ['src/**/*.vue'],
|
|
174
|
+
svelte: ['src/**/*.svelte'],
|
|
175
|
+
angular: ['src/**/*.component.ts'],
|
|
176
|
+
webcomponent: ['src/**/*.ts'],
|
|
177
|
+
};
|
|
178
|
+
const patterns = basePatterns[framework] || ['src/**/*.tsx'];
|
|
179
|
+
const monorepoConfig = detectMonorepoConfig(projectRoot);
|
|
180
|
+
if (!monorepoConfig.type) {
|
|
181
|
+
return patterns;
|
|
182
|
+
}
|
|
183
|
+
const expanded = expandPatternsForMonorepo(patterns, monorepoConfig);
|
|
184
|
+
return expanded.allPatterns;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Check if a project is a monorepo
|
|
188
|
+
*/
|
|
189
|
+
export function isMonorepo(projectRoot) {
|
|
190
|
+
const config = detectMonorepoConfig(projectRoot);
|
|
191
|
+
return config.type !== null;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Get human-readable monorepo type description
|
|
195
|
+
*/
|
|
196
|
+
export function getMonorepoDescription(config) {
|
|
197
|
+
if (!config.type)
|
|
198
|
+
return 'Single package';
|
|
199
|
+
const descriptions = {
|
|
200
|
+
pnpm: 'pnpm workspace',
|
|
201
|
+
yarn: 'Yarn workspace',
|
|
202
|
+
npm: 'npm workspace',
|
|
203
|
+
lerna: 'Lerna monorepo',
|
|
204
|
+
nx: 'Nx workspace',
|
|
205
|
+
turborepo: 'Turborepo',
|
|
206
|
+
};
|
|
207
|
+
return descriptions[config.type] || 'Monorepo';
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=monorepo-patterns.js.map
|