@@ -29,9 +29,9 @@ export async function scaffoldMonorepo(projectNameArg, options) {
2929 interactiveQuestions . push ( {
3030 type : 'select' ,
3131 name : 'preset' ,
32- message : 'Preset (optional) :' ,
32+ message : 'Preset:' ,
3333 choices : [
34- { title : 'None' , value : '' } ,
34+ { title : 'None (basic) ' , value : '' } ,
3535 { title : 'Turborepo' , value : 'turborepo' } ,
3636 { title : 'Nx' , value : 'nx' }
3737 ] ,
@@ -310,7 +310,7 @@ export async function scaffoldMonorepo(projectNameArg, options) {
310310 ] , { cwd : dest , stdio : 'inherit' } ) ;
311311 usedGenerator = true ;
312312 } catch ( e ) {
313- console . log ( chalk . yellow ( ' ⚠️ create-next-app failed, falling back to internal template. Error:' ) , e . shortMessage || e . message ) ;
313+ console . log ( chalk . yellow ( ` ⚠️ create-next-app failed: ${ e . message } . Using template.` ) ) ;
314314 }
315315 }
316316 if ( ! usedGenerator ) {
@@ -327,10 +327,10 @@ export async function scaffoldMonorepo(projectNameArg, options) {
327327 await fs . writeFile ( path . join ( dest , 'README.md' ) , `# ${ svcName } service\n\nScaffolded by create-polyglot.` ) ;
328328 }
329329 }
330-
330+
331331 // Initialize logging for the service
332332 initializeServiceLogs ( dest ) ;
333-
333+
334334 console . log ( chalk . green ( `✅ Created ${ svcName } (${ svcType } ) service on port ${ svcPort } ` ) ) ;
335335 }
336336
@@ -341,7 +341,7 @@ export async function scaffoldMonorepo(projectNameArg, options) {
341341 version : '0.1.0' ,
342342 workspaces : [ 'services/*' , 'packages/*' ] ,
343343 scripts : {
344- dev : 'node scripts/dev-basic.cjs ' ,
344+ dev : 'npx create-polyglot dev ' ,
345345 'list:services' : 'node scripts/list-services.mjs' ,
346346 format : 'prettier --write .' ,
347347 lint : 'eslint "services/**/*.{js,jsx,ts,tsx}" --max-warnings 0 || true'
@@ -366,16 +366,6 @@ export async function scaffoldMonorepo(projectNameArg, options) {
366366 // Always ensure scripts dir exists (needed for list-services script)
367367 const scriptsDir = path . join ( projectDir , 'scripts' ) ;
368368 await fs . mkdirp ( scriptsDir ) ;
369- if ( ! options . preset ) {
370- const runnerSrc = path . join ( __dirname , '../../scripts/dev-basic.cjs' ) ;
371- try {
372- if ( await fs . pathExists ( runnerSrc ) ) {
373- await fs . copy ( runnerSrc , path . join ( scriptsDir , 'dev-basic.cjs' ) ) ;
374- }
375- } catch ( e ) {
376- console . log ( chalk . yellow ( '⚠️ Failed to copy dev-basic runner:' , e . message ) ) ;
377- }
378- }
379369 // Create list-services script with runtime status detection
380370 const listScriptPath = path . join ( scriptsDir , 'list-services.mjs' ) ;
381371 await fs . writeFile ( listScriptPath , `#!/usr/bin/env node\nimport fs from 'fs';\nimport path from 'path';\nimport net from 'net';\nimport chalk from 'chalk';\nconst cwd = process.cwd();\nconst cfgPath = path.join(cwd, 'polyglot.json');\nif(!fs.existsSync(cfgPath)){ console.error(chalk.red('polyglot.json not found.')); process.exit(1);}\nconst cfg = JSON.parse(fs.readFileSync(cfgPath,'utf-8'));\n\nfunction strip(str){return str.replace(/\\x1B\\[[0-9;]*m/g,'');}\nfunction pad(str,w){const raw=strip(str);return str+' '.repeat(Math.max(0,w-raw.length));}\nfunction table(items){ if(!items.length){console.log(chalk.yellow('No services.'));return;} const cols=[{k:'name',h:'Name'},{k:'type',h:'Type'},{k:'port',h:'Port'},{k:'status',h:'Status'},{k:'path',h:'Path'}]; const widths=cols.map(c=>Math.max(c.h.length,...items.map(i=>strip(i[c.k]).length))+2); const top='┌'+widths.map(w=>'─'.repeat(w)).join('┬')+'┐'; const sep='├'+widths.map(w=>'─'.repeat(w)).join('┼')+'┤'; const bot='└'+widths.map(w=>'─'.repeat(w)).join('┴')+'┘'; console.log(top); console.log('│'+cols.map((c,i)=>pad(chalk.bold.white(c.h),widths[i])).join('│')+'│'); console.log(sep); for(const it of items){ console.log('│'+cols.map((c,i)=>pad(it[c.k],widths[i])).join('│')+'│'); } console.log(bot); console.log(chalk.gray('Total: '+items.length)); }\n\nasync function check(port){ return new Promise(res=>{ const sock=net.createConnection({port,host:'127.0.0.1'},()=>{sock.destroy();res(true);}); sock.setTimeout(350,()=>{sock.destroy();res(false);}); sock.on('error',()=>{res(false);});}); }\nconst promises = cfg.services.map(async s=>{ const up = await check(s.port); return { ...s, _up: up }; });\nconst results = await Promise.all(promises);\nconst rows = results.map(s=>({ name: chalk.cyan(s.name), type: colorType(s.type)(s.type), port: chalk.green(String(s.port)), status: s._up ? chalk.bgGreen.black(' UP ') : chalk.bgRed.white(' DOWN '), path: chalk.dim(s.path) }));\nfunction colorType(t){ switch(t){case 'node': return chalk.green; case 'python': return chalk.yellow; case 'go': return chalk.cyan; case 'java': return chalk.red; case 'frontend': return chalk.blue; default: return chalk.white;} }\nif(process.argv.includes('--json')) { console.log(JSON.stringify(results.map(r=>({name:r.name,type:r.type,port:r.port,up:r._up,path:r.path})),null,2)); } else { console.log(chalk.magentaBright('\nWorkspace Services (runtime status)')); table(rows); }\n` ) ;
@@ -456,7 +446,7 @@ export async function scaffoldMonorepo(projectNameArg, options) {
456446 await execa ( 'git' , [ 'commit' , '-m' , 'chore: initial scaffold' ] , { cwd : projectDir } ) ;
457447 console . log ( chalk . green ( '✅ Initialized git repository' ) ) ;
458448 } catch ( e ) {
459- console . log ( chalk . yellow ( '⚠️ Git initialization failed (continuing).' ) ) ;
449+ console . log ( chalk . yellow ( '⚠️ Failed to initialize git repository:' , e . message ) ) ;
460450 }
461451 }
462452
@@ -468,7 +458,7 @@ export async function scaffoldMonorepo(projectNameArg, options) {
468458 try {
469459 await execa ( pm , installCmd , { cwd : projectDir , stdio : 'inherit' } ) ;
470460 } catch ( e ) {
471- console . log ( chalk . yellow ( '⚠️ Installing dependencies failed, you can try manually.' ) ) ;
461+ console . log ( chalk . yellow ( '⚠️ Failed to install dependencies:' , e . message ) ) ;
472462 }
473463 }
474464
@@ -487,7 +477,7 @@ export async function scaffoldMonorepo(projectNameArg, options) {
487477 console . log ( chalk . green ( '✅ Added GitHub Actions workflow (.github/workflows/ci.yml)' ) ) ;
488478 }
489479 } catch ( e ) {
490- console . log ( chalk . yellow ( '⚠️ Failed to create GitHub Actions workflow:' ) , e . message ) ;
480+ console . log ( chalk . yellow ( '⚠️ Failed to create GitHub Actions workflow:' , e . message ) ) ;
491481 }
492482 }
493483
@@ -546,10 +536,10 @@ export async function addService(projectDir, { type, name, port }, options = {})
546536 } else {
547537 await fs . writeFile ( path . join ( dest , 'README.md' ) , `# ${ name } (${ type } ) service\n` ) ;
548538 }
549-
539+
550540 // Initialize logging for the service
551541 initializeServiceLogs ( dest ) ;
552-
542+
553543 console . log ( chalk . green ( `✅ Added service '${ name } ' (${ type } ) on port ${ port } ` ) ) ;
554544 cfg . services . push ( { name, type, port, path : `services/${ name } ` } ) ;
555545 await fs . writeJSON ( configPath , cfg , { spaces : 2 } ) ;
0 commit comments