Skip to content

Commit e5ff32c

Browse files
committed
增加预设加载功能并优化单体仓库处理逻辑
1 parent ee7c072 commit e5ff32c

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

packages/tools/cli/src/commands/studio.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,30 @@ export async function startStudio(options: { port: number; dir: string, open?: b
118118

119119
// Load Schema
120120
const loader = new ObjectLoader(app.metadata);
121-
loader.load(rootDir);
121+
122+
// Load Presets
123+
if (Array.isArray(config.presets)) {
124+
console.log(chalk.gray(`Loading ${config.presets.length} presets...`));
125+
for (const preset of config.presets) {
126+
try {
127+
loader.loadPackage(preset);
128+
} catch (e: any) {
129+
console.warn(chalk.yellow(`Failed to load preset ${preset}:`), e.message);
130+
}
131+
}
132+
}
133+
134+
// Load Schema from Directory
135+
// In a monorepo root with presets, scanning everything is dangerous.
136+
// We check if we are in a monorepo-like environment.
137+
const isMonorepoRoot = fs.existsSync(path.join(rootDir, 'pnpm-workspace.yaml')) || fs.existsSync(path.join(rootDir, 'pnpm-lock.yaml'));
138+
139+
// If we are in a likely monorepo root AND have presets, skip recursive scan
140+
if (isMonorepoRoot && config.presets && config.presets.length > 0) {
141+
console.log(chalk.yellow('Monorepo root detected with presets. Skipping recursive file scan of root directory to avoid conflicts.'));
142+
} else {
143+
loader.load(rootDir);
144+
}
122145
}
123146

124147
// 2. Load Schema & Init

0 commit comments

Comments
 (0)