Skip to content

Commit 896e882

Browse files
committed
Add smoke test for create-polyglot CLI and update package.json
Signed-off-by: kaifcoder <kaifmohd2014@gmail.com>
1 parent a6b3ef2 commit 896e882

File tree

5 files changed

+1747
-21
lines changed

5 files changed

+1747
-21
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,8 @@ dist
139139
vite.config.js.timestamp-*
140140
vite.config.ts.timestamp-*
141141
.vite/
142+
143+
144+
# smoke test files
145+
.smoke-test-*
146+
.tmp-smoke/**

bin/index.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ program
2222
.option("--force", "Overwrite if directory exists and not empty")
2323
.option("--package-manager <pm>", "npm | pnpm | yarn | bun (default: npm)")
2424
.option("--frontend-generator", "Use create-next-app to scaffold the frontend instead of the bundled template")
25+
.option("--yes", "Skip confirmation (assume yes) for non-interactive use")
2526
.action(async (projectNameArg, options) => {
2627
try {
2728
// Collect interactive data if arguments / flags not provided
@@ -92,12 +93,23 @@ program
9293

9394
let answers = {};
9495
if (interactiveQuestions.length) {
95-
answers = await prompts(interactiveQuestions, {
96-
onCancel: () => {
97-
console.log(chalk.red('\n✖ Cancelled.'));
98-
process.exit(1);
96+
if (options.yes) {
97+
// Auto-fill defaults when --yes is used
98+
for (const q of interactiveQuestions) {
99+
if (q.name === 'projectName') answers.projectName = projectNameArg || 'app';
100+
if (q.name === 'services') answers.services = ['node'];
101+
if (q.name === 'preset') answers.preset = '';
102+
if (q.name === 'packageManager') answers.packageManager = 'npm';
103+
if (q.name === 'git') answers.git = false;
99104
}
100-
});
105+
} else {
106+
answers = await prompts(interactiveQuestions, {
107+
onCancel: () => {
108+
console.log(chalk.red('\n✖ Cancelled.'));
109+
process.exit(1);
110+
}
111+
});
112+
}
101113
}
102114

103115
projectName = projectName || answers.projectName;
@@ -230,12 +242,16 @@ program
230242
console.table(services.map(s => ({ type: s.type, name: s.name, port: s.port })));
231243
console.log(`Preset: ${options.preset || 'none'}`);
232244
console.log(`Package Manager: ${options.packageManager}`);
233-
const { proceed } = await prompts({
234-
type: 'confirm',
235-
name: 'proceed',
236-
message: 'Proceed with scaffold?',
237-
initial: true
238-
});
245+
let proceed = true;
246+
if (!options.yes) {
247+
const answer = await prompts({
248+
type: 'confirm',
249+
name: 'proceed',
250+
message: 'Proceed with scaffold?',
251+
initial: true
252+
});
253+
proceed = answer.proceed;
254+
}
239255
if (!proceed) {
240256
console.log(chalk.red('✖ Aborted by user.'));
241257
process.exit(1);

0 commit comments

Comments
 (0)