create-oven 0.2.0 → 0.2.2
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/index.js +39 -108
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -103,13 +103,19 @@ async function main() {
|
|
|
103
103
|
|
|
104
104
|
${c.yellow}Options:${c.reset}
|
|
105
105
|
--typescript, --ts Use TypeScript (default: true)
|
|
106
|
+
--no-typescript Don't use TypeScript
|
|
106
107
|
--tailwind Add Tailwind CSS
|
|
108
|
+
--no-tailwind Don't add Tailwind CSS
|
|
107
109
|
--eslint Add ESLint
|
|
110
|
+
--no-eslint Don't add ESLint
|
|
108
111
|
--src-dir Use src/ directory
|
|
112
|
+
--no-src-dir Don't use src/ directory (default)
|
|
109
113
|
--app Use App Router (default: true)
|
|
110
114
|
--import-alias <alias> Set import alias (default: @/*)
|
|
111
115
|
--use-bun Use Bun for installing dependencies
|
|
112
116
|
--use-npm Use npm for installing dependencies
|
|
117
|
+
--no-install Skip installing dependencies
|
|
118
|
+
-y, --yes Use defaults without prompts
|
|
113
119
|
-h, --help Show this help message
|
|
114
120
|
-v, --version Show version
|
|
115
121
|
|
|
@@ -125,14 +131,14 @@ async function main() {
|
|
|
125
131
|
|
|
126
132
|
// Show version
|
|
127
133
|
if (args.includes('--version') || args.includes('-v')) {
|
|
128
|
-
console.log('create-oven v0.2.
|
|
134
|
+
console.log('create-oven v0.2.2');
|
|
129
135
|
process.exit(0);
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
console.log(`
|
|
133
139
|
${c.bold}${c.cyan} ╔═══════════════════════════════════════╗
|
|
134
140
|
║ ║
|
|
135
|
-
║ 🔥 Create Oven App v0.2.
|
|
141
|
+
║ 🔥 Create Oven App v0.2.2 ║
|
|
136
142
|
║ ║
|
|
137
143
|
║ Next.js-style framework for Bun ║
|
|
138
144
|
║ ║
|
|
@@ -160,28 +166,41 @@ ${c.bold}${c.cyan} ╔═══════════════════
|
|
|
160
166
|
|
|
161
167
|
// Parse CLI flags
|
|
162
168
|
const hasFlag = (flag) => args.includes(flag);
|
|
169
|
+
const skipPrompts = hasFlag('--yes') || hasFlag('-y');
|
|
170
|
+
const noInstall = hasFlag('--no-install');
|
|
163
171
|
|
|
164
172
|
// Interactive prompts (like create-next-app)
|
|
165
173
|
console.log();
|
|
166
174
|
|
|
175
|
+
// If --yes flag, use defaults. If specific flag, use that value. Otherwise ask.
|
|
167
176
|
const useTypescript = hasFlag('--typescript') || hasFlag('--ts') ||
|
|
177
|
+
hasFlag('--no-typescript') ? !hasFlag('--no-typescript') :
|
|
178
|
+
skipPrompts ? true :
|
|
168
179
|
await askYesNo(rl, 'Would you like to use TypeScript?', true);
|
|
169
180
|
|
|
170
181
|
const useEslint = hasFlag('--eslint') ||
|
|
182
|
+
hasFlag('--no-eslint') ? !hasFlag('--no-eslint') :
|
|
183
|
+
skipPrompts ? true :
|
|
171
184
|
await askYesNo(rl, 'Would you like to use ESLint?', true);
|
|
172
185
|
|
|
173
186
|
const useTailwind = hasFlag('--tailwind') ||
|
|
187
|
+
hasFlag('--no-tailwind') ? !hasFlag('--no-tailwind') :
|
|
188
|
+
skipPrompts ? true :
|
|
174
189
|
await askYesNo(rl, 'Would you like to use Tailwind CSS?', true);
|
|
175
190
|
|
|
176
191
|
const useSrcDir = hasFlag('--src-dir') ||
|
|
192
|
+
hasFlag('--no-src-dir') ? !hasFlag('--no-src-dir') :
|
|
193
|
+
skipPrompts ? false :
|
|
177
194
|
await askYesNo(rl, 'Would you like to use `src/` directory?', false);
|
|
178
195
|
|
|
179
196
|
const useAppRouter = hasFlag('--app') ||
|
|
197
|
+
hasFlag('--no-app') ? !hasFlag('--no-app') :
|
|
198
|
+
skipPrompts ? true :
|
|
180
199
|
await askYesNo(rl, 'Would you like to use App Router? (recommended)', true);
|
|
181
200
|
|
|
182
201
|
const importAliasArg = args.find((arg, i) => args[i - 1] === '--import-alias');
|
|
183
202
|
const importAlias = importAliasArg ||
|
|
184
|
-
await askText(rl, 'What import alias would you like configured?', '@/*');
|
|
203
|
+
(skipPrompts ? '@/*' : await askText(rl, 'What import alias would you like configured?', '@/*'));
|
|
185
204
|
|
|
186
205
|
rl.close();
|
|
187
206
|
|
|
@@ -197,8 +216,6 @@ ${c.bold}${c.cyan} ╔═══════════════════
|
|
|
197
216
|
// Create directories
|
|
198
217
|
const dirs = [
|
|
199
218
|
appDir,
|
|
200
|
-
path.join(appDir, 'api', 'hello'),
|
|
201
|
-
path.join(appDir, 'about'),
|
|
202
219
|
path.join(projectDir, 'public'),
|
|
203
220
|
];
|
|
204
221
|
|
|
@@ -478,11 +495,8 @@ export default function HomePage({ searchParams }${useTypescript ? ': PageProps'
|
|
|
478
495
|
</p>
|
|
479
496
|
|
|
480
497
|
<div ${useTailwind ? 'class="flex gap-4 flex-wrap justify-center"' : 'style="display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center;"'}>
|
|
481
|
-
<a href="/
|
|
482
|
-
|
|
483
|
-
</a>
|
|
484
|
-
<a href="/api/hello" ${useTailwind ? 'class="px-6 py-3 bg-gray-900 text-white rounded-lg font-medium hover:bg-gray-800 transition"' : 'style="padding: 0.75rem 1.5rem; background: #1a1a1a; color: white; border-radius: 8px; font-weight: 500;"'}>
|
|
485
|
-
API Example
|
|
498
|
+
<a href="https://github.com/oven-ttta/oven-framework" target="_blank" ${useTailwind ? 'class="px-6 py-3 bg-gradient-to-r from-oven-400 to-oven-500 text-white rounded-lg font-medium hover:opacity-90 transition"' : 'style="padding: 0.75rem 1.5rem; background: linear-gradient(135deg, #ff6b35, #f7931e); color: white; border-radius: 8px; font-weight: 500;"'}>
|
|
499
|
+
Documentation →
|
|
486
500
|
</a>
|
|
487
501
|
<a href="https://github.com/oven-ttta/oven-framework" target="_blank" ${useTailwind ? 'class="px-6 py-3 border border-gray-300 rounded-lg font-medium hover:border-gray-400 transition"' : 'style="padding: 0.75rem 1.5rem; border: 1px solid #ddd; border-radius: 8px; font-weight: 500;"'}>
|
|
488
502
|
GitHub ⭐
|
|
@@ -518,87 +532,6 @@ export default function HomePage({ searchParams }${useTypescript ? ': PageProps'
|
|
|
518
532
|
`;
|
|
519
533
|
fs.writeFileSync(path.join(appDir, `page.${ext}x`), homePageContent);
|
|
520
534
|
|
|
521
|
-
// About Page
|
|
522
|
-
const aboutPageContent = `import${useTypescript ? ' type' : ''} { PageProps, Metadata } from '../types';
|
|
523
|
-
|
|
524
|
-
export const metadata${useTypescript ? ': Metadata' : ''} = {
|
|
525
|
-
title: 'About',
|
|
526
|
-
description: 'About ${projectName}',
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
export default function AboutPage({ params }${useTypescript ? ': PageProps' : ''}) {
|
|
530
|
-
return \`
|
|
531
|
-
<main ${useTailwind ? 'class="max-w-4xl mx-auto px-6 py-16"' : 'style="max-width: 900px; margin: 0 auto; padding: 4rem 1.5rem;"'}>
|
|
532
|
-
<a href="/" ${useTailwind ? 'class="text-oven-400 hover:underline mb-8 inline-block"' : 'style="color: #ff6b35; margin-bottom: 2rem; display: inline-block;"'}>
|
|
533
|
-
← Back to Home
|
|
534
|
-
</a>
|
|
535
|
-
|
|
536
|
-
<h1 ${useTailwind ? 'class="text-4xl font-bold mb-6"' : 'style="font-size: 2.5rem; font-weight: bold; margin-bottom: 1.5rem;"'}>
|
|
537
|
-
About ${projectName}
|
|
538
|
-
</h1>
|
|
539
|
-
|
|
540
|
-
<p ${useTailwind ? 'class="text-lg text-gray-600 mb-8 leading-relaxed"' : 'style="font-size: 1.1rem; color: #666; margin-bottom: 2rem; line-height: 1.8;"'}>
|
|
541
|
-
This project was bootstrapped with <strong>create-oven</strong>,
|
|
542
|
-
a Next.js-style framework powered by the Bun runtime.
|
|
543
|
-
</p>
|
|
544
|
-
|
|
545
|
-
<div ${useTailwind ? 'class="bg-oven-50 border-l-4 border-oven-400 p-6 rounded-r-lg mb-8"' : 'style="background: #fff5f2; border-left: 4px solid #ff6b35; padding: 1.5rem; border-radius: 0 8px 8px 0; margin-bottom: 2rem;"'}>
|
|
546
|
-
<h2 ${useTailwind ? 'class="text-xl font-semibold mb-4"' : 'style="font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem;"'}>
|
|
547
|
-
🚀 Why Oven?
|
|
548
|
-
</h2>
|
|
549
|
-
<ul ${useTailwind ? 'class="space-y-2 text-gray-700"' : 'style="list-style: none;"'}>
|
|
550
|
-
<li ${useTailwind ? '' : 'style="margin-bottom: 0.5rem; color: #444;"'}>✓ Built for Bun runtime - 4x faster than Node.js</li>
|
|
551
|
-
<li ${useTailwind ? '' : 'style="margin-bottom: 0.5rem; color: #444;"'}>✓ Next.js-style file-based routing</li>
|
|
552
|
-
<li ${useTailwind ? '' : 'style="margin-bottom: 0.5rem; color: #444;"'}>✓ Zero configuration needed</li>
|
|
553
|
-
<li ${useTailwind ? '' : 'style="margin-bottom: 0.5rem; color: #444;"'}>✓ Full TypeScript support</li>
|
|
554
|
-
${useTailwind ? "<li>✓ Tailwind CSS integration</li>" : ""}
|
|
555
|
-
</ul>
|
|
556
|
-
</div>
|
|
557
|
-
|
|
558
|
-
<h2 ${useTailwind ? 'class="text-2xl font-semibold mb-4"' : 'style="font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem;"'}>
|
|
559
|
-
Learn More
|
|
560
|
-
</h2>
|
|
561
|
-
|
|
562
|
-
<div ${useTailwind ? 'class="flex gap-4 flex-wrap"' : 'style="display: flex; gap: 1rem; flex-wrap: wrap;"'}>
|
|
563
|
-
<a href="https://github.com/oven-ttta/oven-framework" target="_blank"
|
|
564
|
-
${useTailwind ? 'class="px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition"' : 'style="padding: 0.5rem 1rem; background: #1a1a1a; color: white; border-radius: 8px;"'}>
|
|
565
|
-
GitHub
|
|
566
|
-
</a>
|
|
567
|
-
<a href="https://bun.sh/docs" target="_blank"
|
|
568
|
-
${useTailwind ? 'class="px-4 py-2 border border-gray-300 rounded-lg hover:border-gray-400 transition"' : 'style="padding: 0.5rem 1rem; border: 1px solid #ddd; border-radius: 8px;"'}>
|
|
569
|
-
Bun Docs
|
|
570
|
-
</a>
|
|
571
|
-
</div>
|
|
572
|
-
</main>
|
|
573
|
-
\`;
|
|
574
|
-
}
|
|
575
|
-
`;
|
|
576
|
-
fs.writeFileSync(path.join(appDir, 'about', `page.${ext}x`), aboutPageContent);
|
|
577
|
-
|
|
578
|
-
// API Route
|
|
579
|
-
const apiRouteContent = `// API Route: GET /api/hello
|
|
580
|
-
|
|
581
|
-
export async function GET(request${useTypescript ? ': Request' : ''}) {
|
|
582
|
-
return Response.json({
|
|
583
|
-
message: 'Hello from ${projectName}!',
|
|
584
|
-
timestamp: new Date().toISOString(),
|
|
585
|
-
framework: 'Oven 🔥',
|
|
586
|
-
runtime: 'Bun',
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
export async function POST(request${useTypescript ? ': Request' : ''}) {
|
|
591
|
-
const body = await request.json().catch(() => ({}));
|
|
592
|
-
|
|
593
|
-
return Response.json({
|
|
594
|
-
message: 'Data received!',
|
|
595
|
-
data: body,
|
|
596
|
-
timestamp: new Date().toISOString(),
|
|
597
|
-
}, { status: 201 });
|
|
598
|
-
}
|
|
599
|
-
`;
|
|
600
|
-
fs.writeFileSync(path.join(appDir, 'api', 'hello', `route.${ext}`), apiRouteContent);
|
|
601
|
-
|
|
602
535
|
// Server file
|
|
603
536
|
const serverContent = `/**
|
|
604
537
|
* Oven Server - ${projectName}
|
|
@@ -790,11 +723,7 @@ ${projectName}/
|
|
|
790
723
|
│ ├── layout.${ext}x # Root layout
|
|
791
724
|
│ ├── page.${ext}x # Home page (/)
|
|
792
725
|
│ ├── globals.css # Global styles
|
|
793
|
-
│
|
|
794
|
-
│ │ └── page.${ext}x # About page (/about)
|
|
795
|
-
│ └── api/
|
|
796
|
-
│ └── hello/
|
|
797
|
-
│ └── route.${ext} # API route (/api/hello)
|
|
726
|
+
│ └── types.${ext} # TypeScript types
|
|
798
727
|
├── public/ # Static files
|
|
799
728
|
${useTailwind ? '├── tailwind.config.js # Tailwind config\n' : ''}├── oven.config.${ext} # Oven config
|
|
800
729
|
└── package.json
|
|
@@ -826,18 +755,20 @@ vercel --prod
|
|
|
826
755
|
|
|
827
756
|
spin3.stop('Created app files');
|
|
828
757
|
|
|
829
|
-
// Install dependencies
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
758
|
+
// Install dependencies (unless --no-install)
|
|
759
|
+
if (!noInstall) {
|
|
760
|
+
const packageManager = hasFlag('--use-npm') ? 'npm' : 'bun';
|
|
761
|
+
const spin4 = spinner(`Installing dependencies with ${packageManager}...`);
|
|
762
|
+
|
|
763
|
+
try {
|
|
764
|
+
execSync(`${packageManager} install`, {
|
|
765
|
+
cwd: projectDir,
|
|
766
|
+
stdio: 'pipe',
|
|
767
|
+
});
|
|
768
|
+
spin4.stop(`Installed dependencies with ${packageManager}`);
|
|
769
|
+
} catch (e) {
|
|
770
|
+
spin4.fail(`Failed to install dependencies. Run '${packageManager} install' manually.`);
|
|
771
|
+
}
|
|
841
772
|
}
|
|
842
773
|
|
|
843
774
|
// Success message
|