create-next-rkk 1.0.0
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 +85 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +236 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# create-next-rkk
|
|
2
|
+
|
|
3
|
+
The easiest way to create a new Next.js app with [rkk-next](https://github.com/ROHIT8759/rkk-next) pre-configured!
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-next-rkk@latest my-app
|
|
9
|
+
cd my-app
|
|
10
|
+
npm run dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
That's it! Your Next.js app with rkk-next is ready.
|
|
14
|
+
|
|
15
|
+
## 📋 What You Get
|
|
16
|
+
|
|
17
|
+
✅ **Next.js** latest version
|
|
18
|
+
✅ **rkk-next** pre-installed and configured
|
|
19
|
+
✅ **SEO** setup with MetaManager
|
|
20
|
+
✅ **TypeScript** support (optional)
|
|
21
|
+
✅ **Pages Router** or **App Router** (your choice)
|
|
22
|
+
✅ **Best practices** included
|
|
23
|
+
|
|
24
|
+
## 🎯 Usage
|
|
25
|
+
|
|
26
|
+
### Interactive Mode
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx create-next-rkk@latest
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
You'll be prompted for:
|
|
33
|
+
- Project name
|
|
34
|
+
- Router type (Pages or App)
|
|
35
|
+
- TypeScript (yes/no)
|
|
36
|
+
- Install dependencies (yes/no)
|
|
37
|
+
|
|
38
|
+
### With Project Name
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx create-next-rkk@latest my-awesome-app
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Non-Interactive Mode
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx create-next-rkk@latest my-app --router app --typescript --install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 📦 What's Included
|
|
51
|
+
|
|
52
|
+
### Pages Router Setup
|
|
53
|
+
- `_app.tsx` with Web Vitals reporting
|
|
54
|
+
- `index.tsx` with MetaManager and SmartLink
|
|
55
|
+
- Pre-configured examples
|
|
56
|
+
|
|
57
|
+
### App Router Setup
|
|
58
|
+
- `layout.tsx` with generateAppMetadata
|
|
59
|
+
- `page.tsx` with JSON-LD
|
|
60
|
+
- Modern App Router patterns
|
|
61
|
+
|
|
62
|
+
## 🔧 Post-Installation
|
|
63
|
+
|
|
64
|
+
After creating your app:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
cd your-app-name
|
|
68
|
+
npm run dev
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Visit `http://localhost:3000` to see your app!
|
|
72
|
+
|
|
73
|
+
## 📚 Learn More
|
|
74
|
+
|
|
75
|
+
- [rkk-next Documentation](https://github.com/ROHIT8759/rkk-next)
|
|
76
|
+
- [rkk-next Quick Start](https://github.com/ROHIT8759/rkk-next/blob/main/QUICKSTART.md)
|
|
77
|
+
- [Next.js Documentation](https://nextjs.org/docs)
|
|
78
|
+
|
|
79
|
+
## 🐛 Issues
|
|
80
|
+
|
|
81
|
+
Report issues at: https://github.com/ROHIT8759/rkk-next/issues
|
|
82
|
+
|
|
83
|
+
## 📄 License
|
|
84
|
+
|
|
85
|
+
MIT © Rohit Kumar Kundu
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const commander_1 = require("commander");
|
|
41
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
42
|
+
const child_process_1 = require("child_process");
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
46
|
+
const ora_1 = __importDefault(require("ora"));
|
|
47
|
+
const program = new commander_1.Command();
|
|
48
|
+
program
|
|
49
|
+
.name('create-next-rkk')
|
|
50
|
+
.description('Create a new Next.js app with rkk-next pre-configured')
|
|
51
|
+
.version('1.0.0')
|
|
52
|
+
.argument('[project-name]', 'name of your project')
|
|
53
|
+
.action(async (projectName) => {
|
|
54
|
+
console.log(chalk_1.default.bold.cyan('\n🚀 Create RKK Next.js App\n'));
|
|
55
|
+
const answers = await inquirer_1.default.prompt([
|
|
56
|
+
{
|
|
57
|
+
type: 'input',
|
|
58
|
+
name: 'projectName',
|
|
59
|
+
message: 'What is your project name?',
|
|
60
|
+
default: projectName || 'my-rkk-app',
|
|
61
|
+
when: !projectName,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: 'list',
|
|
65
|
+
name: 'router',
|
|
66
|
+
message: 'Which Next.js router do you want to use?',
|
|
67
|
+
choices: [
|
|
68
|
+
{ name: 'App Router (Recommended)', value: 'app' },
|
|
69
|
+
{ name: 'Pages Router', value: 'pages' },
|
|
70
|
+
],
|
|
71
|
+
default: 'app',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'confirm',
|
|
75
|
+
name: 'typescript',
|
|
76
|
+
message: 'Use TypeScript?',
|
|
77
|
+
default: true,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: 'confirm',
|
|
81
|
+
name: 'installDeps',
|
|
82
|
+
message: 'Install dependencies now?',
|
|
83
|
+
default: true,
|
|
84
|
+
},
|
|
85
|
+
]);
|
|
86
|
+
const targetDir = projectName || answers.projectName;
|
|
87
|
+
// Step 1: Create Next.js app
|
|
88
|
+
const spinner = (0, ora_1.default)('Creating Next.js application...').start();
|
|
89
|
+
try {
|
|
90
|
+
const nextFlags = [
|
|
91
|
+
'--use-npm',
|
|
92
|
+
answers.typescript ? '--typescript' : '--javascript',
|
|
93
|
+
answers.router === 'app' ? '--app' : '',
|
|
94
|
+
'--no-tailwind',
|
|
95
|
+
'--eslint',
|
|
96
|
+
'--src-dir',
|
|
97
|
+
].filter(Boolean).join(' ');
|
|
98
|
+
(0, child_process_1.execSync)(`npx create-next-app@latest ${targetDir} ${nextFlags} --yes`, { stdio: 'pipe' });
|
|
99
|
+
spinner.succeed('Next.js application created!');
|
|
100
|
+
// Step 2: Install rkk-next
|
|
101
|
+
if (answers.installDeps) {
|
|
102
|
+
spinner.start('Installing rkk-next...');
|
|
103
|
+
process.chdir(targetDir);
|
|
104
|
+
(0, child_process_1.execSync)('npm install rkk-next', { stdio: 'pipe' });
|
|
105
|
+
spinner.succeed('rkk-next installed!');
|
|
106
|
+
}
|
|
107
|
+
// Step 3: Setup template files
|
|
108
|
+
spinner.start('Setting up rkk-next configuration...');
|
|
109
|
+
setupTemplateFiles(targetDir, answers.router, answers.typescript);
|
|
110
|
+
spinner.succeed('Configuration complete!');
|
|
111
|
+
// Success message
|
|
112
|
+
console.log(chalk_1.default.green.bold('\n✨ Success! Created ' + targetDir));
|
|
113
|
+
console.log(chalk_1.default.cyan('\n📁 Inside your project directory:\n'));
|
|
114
|
+
console.log(chalk_1.default.white(' cd ' + targetDir));
|
|
115
|
+
if (!answers.installDeps) {
|
|
116
|
+
console.log(chalk_1.default.white(' npm install'));
|
|
117
|
+
}
|
|
118
|
+
console.log(chalk_1.default.white(' npm run dev'));
|
|
119
|
+
console.log(chalk_1.default.cyan('\n📚 Documentation:'));
|
|
120
|
+
console.log(chalk_1.default.white(' https://github.com/ROHIT8759/rkk-next\n'));
|
|
121
|
+
console.log(chalk_1.default.yellow('Happy coding! 🎉\n'));
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
spinner.fail('Failed to create application');
|
|
125
|
+
console.error(chalk_1.default.red('\nError:'), error.message);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
function setupTemplateFiles(projectDir, router, typescript) {
|
|
130
|
+
const ext = typescript ? 'tsx' : 'jsx';
|
|
131
|
+
const srcDir = path.join(projectDir, 'src');
|
|
132
|
+
if (router === 'pages') {
|
|
133
|
+
// Setup Pages Router
|
|
134
|
+
const pagesDir = path.join(srcDir, 'pages');
|
|
135
|
+
// _app file
|
|
136
|
+
const appContent = `import type { AppProps } from 'next/app';
|
|
137
|
+
import { reportWebVitals } from 'rkk-next';
|
|
138
|
+
import '../styles/globals.css';
|
|
139
|
+
|
|
140
|
+
export default function App({ Component, pageProps }: AppProps) {
|
|
141
|
+
return <Component {...pageProps} />;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export { reportWebVitals };
|
|
145
|
+
`;
|
|
146
|
+
// index.tsx with rkk-next
|
|
147
|
+
const indexContent = `import { MetaManager, SmartLink, OptimizedImage } from 'rkk-next';
|
|
148
|
+
|
|
149
|
+
export default function Home() {
|
|
150
|
+
return (
|
|
151
|
+
<>
|
|
152
|
+
<MetaManager
|
|
153
|
+
title="Home | My App"
|
|
154
|
+
description="Built with rkk-next and Next.js"
|
|
155
|
+
keywords="nextjs, seo, performance"
|
|
156
|
+
/>
|
|
157
|
+
|
|
158
|
+
<main style={{ padding: '2rem', maxWidth: '1200px', margin: '0 auto' }}>
|
|
159
|
+
<h1>Welcome to Your RKK Next.js App!</h1>
|
|
160
|
+
<p>This app is pre-configured with rkk-next for SEO, performance, and routing optimization.</p>
|
|
161
|
+
|
|
162
|
+
<SmartLink href="/about">
|
|
163
|
+
Learn More →
|
|
164
|
+
</SmartLink>
|
|
165
|
+
</main>
|
|
166
|
+
</>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
`;
|
|
170
|
+
fs.writeFileSync(path.join(pagesDir, `_app.${ext}`), appContent);
|
|
171
|
+
fs.writeFileSync(path.join(pagesDir, `index.${ext}`), indexContent);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// Setup App Router
|
|
175
|
+
const appDir = path.join(srcDir, 'app');
|
|
176
|
+
// layout.tsx
|
|
177
|
+
const layoutContent = `import { generateAppMetadata } from 'rkk-next';
|
|
178
|
+
import './globals.css';
|
|
179
|
+
|
|
180
|
+
export const metadata = generateAppMetadata({
|
|
181
|
+
title: 'My RKK App',
|
|
182
|
+
description: 'Built with rkk-next and Next.js',
|
|
183
|
+
image: '/og-image.png',
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
export default function RootLayout({
|
|
187
|
+
children,
|
|
188
|
+
}: {
|
|
189
|
+
children: React.ReactNode;
|
|
190
|
+
}) {
|
|
191
|
+
return (
|
|
192
|
+
<html lang="en">
|
|
193
|
+
<body>{children}</body>
|
|
194
|
+
</html>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
// page.tsx
|
|
199
|
+
const pageContent = `import { JsonLd, OptimizedImage } from 'rkk-next';
|
|
200
|
+
import Link from 'next/link';
|
|
201
|
+
|
|
202
|
+
export default function HomePage() {
|
|
203
|
+
return (
|
|
204
|
+
<>
|
|
205
|
+
<JsonLd
|
|
206
|
+
type="WebSite"
|
|
207
|
+
data={{
|
|
208
|
+
name: "My RKK App",
|
|
209
|
+
url: "https://myapp.com",
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
|
|
213
|
+
<main style={{ padding: '2rem', maxWidth: '1200px', margin: '0 auto' }}>
|
|
214
|
+
<h1>Welcome to Your RKK Next.js App!</h1>
|
|
215
|
+
<p>This app is pre-configured with rkk-next for SEO, performance, and routing optimization.</p>
|
|
216
|
+
|
|
217
|
+
<Link href="/about">Learn More →</Link>
|
|
218
|
+
</main>
|
|
219
|
+
</>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
fs.writeFileSync(path.join(appDir, `layout.${ext}`), layoutContent);
|
|
224
|
+
fs.writeFileSync(path.join(appDir, `page.${ext}`), pageContent);
|
|
225
|
+
}
|
|
226
|
+
// Create next.config.js with rkk-next
|
|
227
|
+
const configContent = `/** @type {import('next').NextConfig} */
|
|
228
|
+
const nextConfig = {
|
|
229
|
+
reactStrictMode: true,
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
module.exports = nextConfig;
|
|
233
|
+
`;
|
|
234
|
+
fs.writeFileSync(path.join(projectDir, 'next.config.js'), configContent);
|
|
235
|
+
}
|
|
236
|
+
program.parse(process.argv);
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-next-rkk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI tool to create Next.js apps with rkk-next pre-configured",
|
|
5
|
+
"author": "Rohit Kumar Kundu",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"create-next-rkk": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"templates"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/ROHIT8759/rkk-next.git",
|
|
18
|
+
"directory": "cli"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/ROHIT8759/rkk-next/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/ROHIT8759/rkk-next#readme",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"dev": "tsc --watch",
|
|
27
|
+
"prepublishOnly": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"chalk": "^4.1.2",
|
|
31
|
+
"commander": "^11.1.0",
|
|
32
|
+
"inquirer": "^8.2.6",
|
|
33
|
+
"ora": "^5.4.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/inquirer": "^9.0.7",
|
|
37
|
+
"@types/node": "^20.10.0",
|
|
38
|
+
"typescript": "^5.3.3"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"nextjs",
|
|
42
|
+
"cli",
|
|
43
|
+
"create-app",
|
|
44
|
+
"rkk-next",
|
|
45
|
+
"scaffold",
|
|
46
|
+
"generator",
|
|
47
|
+
"boilerplate"
|
|
48
|
+
],
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=16.0.0"
|
|
51
|
+
}
|
|
52
|
+
}
|