webspresso 0.0.9 → 0.0.10
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/README.md +23 -1
- package/bin/webspresso.js +125 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,9 +73,31 @@ webspresso new my-app --no-tailwind
|
|
|
73
73
|
- Asks if you want to install in the current directory
|
|
74
74
|
- If current directory is not empty, shows a warning
|
|
75
75
|
- Prompts for project name (defaults to current folder name)
|
|
76
|
+
- After project creation, asks if you want to install dependencies
|
|
77
|
+
- If yes, runs `npm install` and `npm run build:css`
|
|
78
|
+
- Then asks if you want to start the development server
|
|
79
|
+
- If yes, starts `npm run dev` automatically
|
|
80
|
+
|
|
81
|
+
**Auto Installation:**
|
|
82
|
+
```bash
|
|
83
|
+
# With --install flag (semi-interactive)
|
|
84
|
+
webspresso new my-app --install
|
|
85
|
+
# → Automatically runs: npm install && npm run build:css
|
|
86
|
+
# → Then prompts: "Start development server?" [Y/n]
|
|
87
|
+
# → If yes: starts npm run dev (with watch:css if Tailwind enabled)
|
|
88
|
+
|
|
89
|
+
# Without --install flag (fully interactive)
|
|
90
|
+
webspresso new my-app
|
|
91
|
+
# → Prompts: "Install dependencies and build CSS now?" [Y/n]
|
|
92
|
+
# → If yes: runs npm install && npm run build:css
|
|
93
|
+
# → Then: "Start development server?" [Y/n]
|
|
94
|
+
# → If yes: starts npm run dev (with watch:css if Tailwind enabled)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Note:** When dev server starts with Tailwind CSS, it automatically runs `watch:css` in the background to watch for CSS changes.
|
|
76
98
|
|
|
77
99
|
Options:
|
|
78
|
-
- `-i, --install` - Auto run `npm install` and `npm run build:css`
|
|
100
|
+
- `-i, --install` - Auto run `npm install` and `npm run build:css` (non-interactive)
|
|
79
101
|
- `--no-tailwind` - Skip Tailwind CSS setup
|
|
80
102
|
|
|
81
103
|
The project includes:
|
package/bin/webspresso.js
CHANGED
|
@@ -429,8 +429,8 @@ module.exports = {
|
|
|
429
429
|
console.log('✅ Tailwind CSS setup complete!');
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
-
//
|
|
433
|
-
|
|
432
|
+
// Helper function to run installation
|
|
433
|
+
async function runInstallation(projectPath, useTailwind) {
|
|
434
434
|
console.log('\n📦 Installing dependencies...\n');
|
|
435
435
|
const { execSync } = require('child_process');
|
|
436
436
|
try {
|
|
@@ -447,27 +447,137 @@ module.exports = {
|
|
|
447
447
|
});
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
console.log('\n✅
|
|
450
|
+
console.log('\n✅ Installation complete!\n');
|
|
451
|
+
} catch (err) {
|
|
452
|
+
console.error('❌ Installation failed:', err.message);
|
|
453
|
+
process.exit(1);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Helper function to start dev server
|
|
458
|
+
function startDevServer(projectPath, useTailwind) {
|
|
459
|
+
console.log('\n🚀 Starting development server...\n');
|
|
460
|
+
console.log('Press Ctrl+C to stop\n');
|
|
461
|
+
|
|
462
|
+
const { spawn } = require('child_process');
|
|
463
|
+
|
|
464
|
+
if (useTailwind) {
|
|
465
|
+
// Start CSS watch and server together
|
|
466
|
+
const cssWatch = spawn('npm', ['run', 'watch:css'], {
|
|
467
|
+
stdio: 'inherit',
|
|
468
|
+
shell: true,
|
|
469
|
+
cwd: projectPath
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
const server = spawn('node', ['--watch', 'server.js'], {
|
|
473
|
+
stdio: 'inherit',
|
|
474
|
+
shell: true,
|
|
475
|
+
cwd: projectPath,
|
|
476
|
+
env: { ...process.env, PORT: process.env.PORT || '3000', NODE_ENV: 'development' }
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
// Handle exit
|
|
480
|
+
const cleanup = () => {
|
|
481
|
+
cssWatch.kill();
|
|
482
|
+
server.kill();
|
|
483
|
+
process.exit(0);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
process.on('SIGINT', cleanup);
|
|
487
|
+
process.on('SIGTERM', cleanup);
|
|
488
|
+
|
|
489
|
+
cssWatch.on('exit', cleanup);
|
|
490
|
+
server.on('exit', cleanup);
|
|
491
|
+
} else {
|
|
492
|
+
// Just start server
|
|
493
|
+
const server = spawn('node', ['--watch', 'server.js'], {
|
|
494
|
+
stdio: 'inherit',
|
|
495
|
+
shell: true,
|
|
496
|
+
cwd: projectPath,
|
|
497
|
+
env: { ...process.env, PORT: process.env.PORT || '3000', NODE_ENV: 'development' }
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
server.on('exit', (code) => {
|
|
501
|
+
process.exit(code || 0);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
process.on('SIGINT', () => {
|
|
505
|
+
server.kill();
|
|
506
|
+
process.exit(0);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// Auto install if requested or ask interactively
|
|
512
|
+
if (autoInstall) {
|
|
513
|
+
await runInstallation(projectPath, useTailwind);
|
|
514
|
+
|
|
515
|
+
// Ask if user wants to start dev server
|
|
516
|
+
const { shouldStartDev } = await inquirer.prompt([
|
|
517
|
+
{
|
|
518
|
+
type: 'confirm',
|
|
519
|
+
name: 'shouldStartDev',
|
|
520
|
+
message: 'Start development server?',
|
|
521
|
+
default: true
|
|
522
|
+
}
|
|
523
|
+
]);
|
|
524
|
+
|
|
525
|
+
if (shouldStartDev) {
|
|
526
|
+
startDevServer(projectPath, useTailwind);
|
|
527
|
+
} else {
|
|
528
|
+
console.log('✅ Project ready!\n');
|
|
451
529
|
console.log('Start developing:');
|
|
452
530
|
if (!useCurrentDir) {
|
|
453
531
|
console.log(` cd ${projectName}`);
|
|
454
532
|
}
|
|
455
533
|
console.log(' npm run dev\n');
|
|
456
|
-
} catch (err) {
|
|
457
|
-
console.error('❌ Installation failed:', err.message);
|
|
458
|
-
process.exit(1);
|
|
459
534
|
}
|
|
460
535
|
} else {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
536
|
+
// Ask if user wants to install dependencies
|
|
537
|
+
const { shouldInstall } = await inquirer.prompt([
|
|
538
|
+
{
|
|
539
|
+
type: 'confirm',
|
|
540
|
+
name: 'shouldInstall',
|
|
541
|
+
message: 'Install dependencies and build CSS now?',
|
|
542
|
+
default: true
|
|
543
|
+
}
|
|
544
|
+
]);
|
|
545
|
+
|
|
546
|
+
if (shouldInstall) {
|
|
547
|
+
await runInstallation(projectPath, useTailwind);
|
|
548
|
+
|
|
549
|
+
// Ask if user wants to start dev server
|
|
550
|
+
const { shouldStartDev } = await inquirer.prompt([
|
|
551
|
+
{
|
|
552
|
+
type: 'confirm',
|
|
553
|
+
name: 'shouldStartDev',
|
|
554
|
+
message: 'Start development server?',
|
|
555
|
+
default: true
|
|
556
|
+
}
|
|
557
|
+
]);
|
|
558
|
+
|
|
559
|
+
if (shouldStartDev) {
|
|
560
|
+
startDevServer(projectPath, useTailwind);
|
|
561
|
+
} else {
|
|
562
|
+
console.log('\n✅ Project ready!\n');
|
|
563
|
+
console.log('Start developing:');
|
|
564
|
+
if (!useCurrentDir) {
|
|
565
|
+
console.log(` cd ${projectName}`);
|
|
566
|
+
}
|
|
567
|
+
console.log(' npm run dev\n');
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
console.log('\n✅ Project created successfully!\n');
|
|
571
|
+
console.log('Next steps:');
|
|
572
|
+
if (!useCurrentDir) {
|
|
573
|
+
console.log(` cd ${projectName}`);
|
|
574
|
+
}
|
|
575
|
+
console.log(' npm install');
|
|
576
|
+
if (useTailwind) {
|
|
577
|
+
console.log(' npm run build:css');
|
|
578
|
+
}
|
|
579
|
+
console.log(' npm run dev\n');
|
|
469
580
|
}
|
|
470
|
-
console.log(' npm run dev\n');
|
|
471
581
|
}
|
|
472
582
|
});
|
|
473
583
|
|
package/package.json
CHANGED