create-revo 1.2.6 → 2.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.
Files changed (38) hide show
  1. package/cli.js +215 -42
  2. package/package.json +8 -3
  3. package/template-nextjs/README.md +36 -0
  4. package/template-nextjs/eslint.config.mjs +25 -0
  5. package/template-nextjs/next.config.ts +7 -0
  6. package/template-nextjs/package-lock.json +6182 -0
  7. package/template-nextjs/package.json +28 -0
  8. package/template-nextjs/postcss.config.mjs +5 -0
  9. package/template-nextjs/public/revo.png +0 -0
  10. package/template-nextjs/src/app/favicon.ico +0 -0
  11. package/template-nextjs/src/app/globals.css +21 -0
  12. package/template-nextjs/src/app/layout.tsx +34 -0
  13. package/template-nextjs/src/app/page.tsx +24 -0
  14. package/template-nextjs/tsconfig.json +27 -0
  15. package/template-reactjs/README.md +28 -0
  16. package/{template → template-reactjs}/index.html +6 -6
  17. package/template-reactjs/public/favicon.ico +0 -0
  18. package/template-reactjs/src/App.tsx +23 -0
  19. package/template-reactjs/src/assets/revo.png +0 -0
  20. package/template-reactjs/src/components/dltme +0 -0
  21. package/template/README.md +0 -1
  22. package/template/public/revo.svg +0 -7
  23. package/template/src/App.tsx +0 -20
  24. package/template/src/assets/revo.svg +0 -19
  25. package/template/src/assets/revo2.svg +0 -7
  26. /package/{template/src → template-nextjs/src/app}/components/dltme +0 -0
  27. /package/{template → template-reactjs}/eslint.config.js +0 -0
  28. /package/{template → template-reactjs}/package-lock.json +0 -0
  29. /package/{template → template-reactjs}/package.json +0 -0
  30. /package/{template → template-reactjs}/postcss.config.js +0 -0
  31. /package/{template → template-reactjs}/src/index.css +0 -0
  32. /package/{template → template-reactjs}/src/main.tsx +0 -0
  33. /package/{template → template-reactjs}/src/vite-env.d.ts +0 -0
  34. /package/{template → template-reactjs}/tailwind.config.js +0 -0
  35. /package/{template → template-reactjs}/tsconfig.app.json +0 -0
  36. /package/{template → template-reactjs}/tsconfig.json +0 -0
  37. /package/{template → template-reactjs}/tsconfig.node.json +0 -0
  38. /package/{template → template-reactjs}/vite.config.ts +0 -0
package/cli.js CHANGED
@@ -3,18 +3,58 @@
3
3
  import fs from "fs";
4
4
  import path from "path";
5
5
  import { fileURLToPath } from "url";
6
+ import readline from "readline";
6
7
 
7
8
  const __filename = fileURLToPath(import.meta.url);
8
9
  const __dirname = path.dirname(__filename);
9
10
 
10
11
  const projectName = process.argv[2];
11
12
 
12
- if (!projectName) {
13
- console.error("Please provide a project name: npx create-revo [project-name]");
14
- process.exit(1);
13
+ function askProjectName() {
14
+ return new Promise((resolve) => {
15
+ const rl = readline.createInterface({
16
+ input: process.stdin,
17
+ output: process.stdout
18
+ });
19
+
20
+ rl.question('Enter project name: ', (answer) => {
21
+ rl.close();
22
+ resolve(answer.trim());
23
+ });
24
+ });
15
25
  }
16
26
 
17
- const targetDir = path.join(process.cwd(), projectName);
27
+ function askTemplateChoice() {
28
+ return new Promise((resolve) => {
29
+ const rl = readline.createInterface({
30
+ input: process.stdin,
31
+ output: process.stdout
32
+ });
33
+
34
+ console.log('\nChoose your template:');
35
+ console.log('1. React.js + Typescript + TailwindCSS + Vite');
36
+ console.log('2. Next.js + Typescript + TailwindCSS');
37
+
38
+ const askQuestion = () => {
39
+ rl.question('Enter your choice (1 or 2): ', (answer) => {
40
+ const choice = answer.trim().toLowerCase();
41
+
42
+ if (choice === '1' || choice === 'react' || choice === 'reactjs') {
43
+ rl.close();
44
+ resolve('reactjs');
45
+ } else if (choice === '2' || choice === 'next' || choice === 'nextjs') {
46
+ rl.close();
47
+ resolve('nextjs');
48
+ } else {
49
+ console.log('Invalid choice. Please enter 1 or 2.');
50
+ askQuestion();
51
+ }
52
+ });
53
+ };
54
+
55
+ askQuestion();
56
+ });
57
+ }
18
58
 
19
59
  function replacePlaceholders(content, placeholderValues) {
20
60
  Object.keys(placeholderValues).forEach((key) => {
@@ -24,24 +64,92 @@ function replacePlaceholders(content, placeholderValues) {
24
64
  return content;
25
65
  }
26
66
 
27
- function copyTemplateFiles() {
28
- const templateDir = path.join(__dirname, "template");
67
+ function copyTemplateFiles(templateType, projectName, targetDir) {
68
+ const templateDir = path.join(__dirname, `template-${templateType}`);
69
+
70
+ // Check if template directory exists
71
+ if (!fs.existsSync(templateDir)) {
72
+ console.error(`Template directory 'template-${templateType}' not found!`);
73
+ process.exit(1);
74
+ }
29
75
 
30
76
  fs.mkdirSync(targetDir, { recursive: true });
31
77
 
32
78
  copyRecursive(templateDir, targetDir);
33
79
 
34
80
  replacePlaceholdersInDirectory(targetDir, { projectName });
81
+
82
+ // Create .gitignore file
83
+ createGitignoreFile(targetDir);
84
+ }
85
+
86
+ function createGitignoreFile(projectDir) {
87
+ const gitignoreContent = `# dependencies
88
+ /node_modules
89
+ /.pnp
90
+ .pnp.*
91
+ .yarn/*
92
+ !.yarn/patches
93
+ !.yarn/plugins
94
+ !.yarn/releases
95
+ !.yarn/versions
96
+
97
+ # testing
98
+ /coverage
99
+
100
+ # next.js
101
+ /.next/
102
+ /out/
103
+
104
+ # production
105
+ /build
106
+
107
+ # misc
108
+ .DS_Store
109
+ *.pem
110
+
111
+ # debug
112
+ npm-debug.log*
113
+ yarn-debug.log*
114
+ yarn-error.log*
115
+ .pnpm-debug.log*
116
+
117
+ # env files (can opt-in for committing if needed)
118
+ .env*
119
+
120
+ # vercel
121
+ .vercel
122
+
123
+ # typescript
124
+ *.tsbuildinfo
125
+ next-env.d.ts
126
+ `;
127
+
128
+ try {
129
+ const gitignorePath = path.join(projectDir, '.gitignore');
130
+ fs.writeFileSync(gitignorePath, gitignoreContent);
131
+ } catch (error) {
132
+ //
133
+ }
35
134
  }
36
135
 
37
136
  function copyRecursive(source, target) {
38
- if (fs.statSync(source).isDirectory()) {
39
- fs.mkdirSync(target, { recursive: true });
40
- fs.readdirSync(source).forEach((file) => {
41
- copyRecursive(path.join(source, file), path.join(target, file));
42
- });
43
- } else {
44
- fs.copyFileSync(source, target);
137
+ try {
138
+ if (fs.statSync(source).isDirectory()) {
139
+ fs.mkdirSync(target, { recursive: true });
140
+ const files = fs.readdirSync(source);
141
+
142
+ for (const file of files) {
143
+ const sourcePath = path.join(source, file);
144
+ const targetPath = path.join(target, file);
145
+ copyRecursive(sourcePath, targetPath);
146
+ }
147
+ } else {
148
+ fs.copyFileSync(source, target);
149
+ }
150
+ } catch (error) {
151
+ console.error(`Error copying ${source} to ${target}:`, error.message);
152
+ throw error;
45
153
  }
46
154
  }
47
155
 
@@ -53,40 +161,105 @@ function sanitizeProjectName(name) {
53
161
  }
54
162
 
55
163
  function replacePlaceholdersInDirectory(directory, placeholderValues) {
164
+ try {
165
+ const sanitizedProjectName = sanitizeProjectName(placeholderValues.projectName);
166
+ const files = fs.readdirSync(directory);
56
167
 
57
- const sanitizedProjectName = sanitizeProjectName(placeholderValues.projectName);
168
+ for (const file of files) {
169
+ const filePath = path.join(directory, file);
170
+
171
+ if (fs.statSync(filePath).isDirectory()) {
172
+ replacePlaceholdersInDirectory(filePath, placeholderValues);
173
+ } else {
174
+ let content = fs.readFileSync(filePath, "utf8");
58
175
 
59
- fs.readdirSync(directory).forEach((file) => {
60
- const filePath = path.join(directory, file);
61
- if (fs.statSync(filePath).isDirectory()) {
62
- replacePlaceholdersInDirectory(filePath, placeholderValues);
63
- } else {
64
- let content = fs.readFileSync(filePath, "utf8");
176
+ if (file === "package.json" || file === "package-lock.json") {
177
+ try {
178
+ const jsonContent = JSON.parse(content);
179
+ jsonContent.name = sanitizedProjectName;
180
+
181
+ // Update all dependencies to latest versions
182
+ if (jsonContent.dependencies) {
183
+ Object.keys(jsonContent.dependencies).forEach(dep => {
184
+ jsonContent.dependencies[dep] = "latest";
185
+ });
186
+ }
187
+ if (jsonContent.devDependencies) {
188
+ Object.keys(jsonContent.devDependencies).forEach(dep => {
189
+ jsonContent.devDependencies[dep] = "latest";
190
+ });
191
+ }
192
+
193
+ content = JSON.stringify(jsonContent, null, 2);
194
+ } catch (jsonError) {
195
+ console.warn(`Warning: Could not parse JSON in ${filePath}:`, jsonError.message);
196
+ // Fallback to string replacement
197
+ content = content.replace(/\{\{projectName\}\}/g, sanitizedProjectName);
198
+ }
199
+ } else if (file === "index.html" || file.endsWith(".html")) {
200
+ // Replace project name in HTML title and meta tags
201
+ content = content.replace(/\{\{projectName\}\}/g, placeholderValues.projectName);
202
+ // Also replace common placeholders like "Revo" with project name
203
+ content = content.replace(/Revo/g, placeholderValues.projectName);
204
+ } else if (file.endsWith(".tsx") || file.endsWith(".ts") || file.endsWith(".jsx") || file.endsWith(".js")) {
205
+ // Replace project name in React/Next.js files
206
+ content = content.replace(/\{\{projectName\}\}/g, placeholderValues.projectName);
207
+ // Replace common placeholders
208
+ content = content.replace(/Create Next App/g, placeholderValues.projectName);
209
+ content = content.replace(/Generated by create next app/g, `Generated by ${placeholderValues.projectName}`);
210
+ } else {
211
+ // Use the optimized replacePlaceholders function for other files
212
+ content = replacePlaceholders(content, placeholderValues);
213
+ }
65
214
 
66
- if (file === "package.json" || file === "package-lock.json") {
67
- const jsonContent = JSON.parse(content);
68
- jsonContent.name = sanitizedProjectName;
69
- content = JSON.stringify(jsonContent, null, 2);
70
- } else {
71
- Object.keys(placeholderValues).forEach((key) => {
72
- const placeholder = `{{${key}}}`;
73
- content = content.replace(new RegExp(placeholder, "g"), placeholderValues[key]);
74
- });
215
+ fs.writeFileSync(filePath, content);
75
216
  }
76
-
77
- fs.writeFileSync(filePath, content);
78
217
  }
79
- });
218
+ } catch (error) {
219
+ console.error(`Error processing directory ${directory}:`, error.message);
220
+ throw error;
221
+ }
80
222
  }
81
223
 
82
- try {
83
- console.log("Setting up project...");
84
- copyTemplateFiles();
85
- console.log(`Project created at ${targetDir}`);
86
- process.chdir(targetDir);
87
- console.log("Project setup complete!");
88
- console.log("Run npm install and you are set.");
89
- } catch (error) {
90
- console.error("Error creating project:", error);
91
- process.exit(1);
224
+ async function main() {
225
+ try {
226
+ let finalProjectName = projectName;
227
+
228
+ // If no project name provided, ask for it
229
+ if (!finalProjectName) {
230
+ finalProjectName = await askProjectName();
231
+ }
232
+
233
+ // Validate project name
234
+ if (!/^[a-zA-Z0-9-_~]+$/.test(finalProjectName)) {
235
+ console.error("Project name can only contain letters, numbers, hyphens, underscores, and tildes");
236
+ process.exit(1);
237
+ }
238
+
239
+ const finalTargetDir = path.join(process.cwd(), finalProjectName);
240
+
241
+ // Check if target directory already exists
242
+ if (fs.existsSync(finalTargetDir)) {
243
+ console.error(`Directory '${finalProjectName}' already exists! Please choose a different name.`);
244
+ process.exit(1);
245
+ }
246
+
247
+ // Ask user to choose template
248
+ const templateType = await askTemplateChoice();
249
+
250
+ copyTemplateFiles(templateType, finalProjectName, finalTargetDir);
251
+
252
+ console.log(`Project created successfully at ${finalTargetDir}`);
253
+ process.chdir(finalTargetDir);
254
+
255
+ console.log("\nProject setup complete!");
256
+ console.log("\nNext steps:");
257
+ console.log("1. Run: npm install");
258
+ console.log("2. Run: npm run dev");
259
+ } catch (error) {
260
+ console.error("Error creating project:", error.message);
261
+ process.exit(1);
262
+ }
92
263
  }
264
+
265
+ main();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-revo",
3
- "version": "1.2.6",
4
- "description": "React Project Setup Tool built on Vite",
3
+ "version": "2.0.0",
4
+ "description": "Project setup tool for ReactJS and NextJS",
5
5
  "main": "cli.js",
6
6
  "bin": {
7
7
  "create-revo": "./cli.js"
@@ -12,9 +12,14 @@
12
12
  "keywords": [
13
13
  "build",
14
14
  "tool",
15
- "bread",
16
15
  "react",
16
+ "nextjs",
17
+ "next.js",
18
+ "typescript",
19
+ "tailwind",
20
+ "vite",
17
21
  "project",
22
+ "template",
18
23
  "maybetarun"
19
24
  ],
20
25
  "author": "Tarun Gupta",
@@ -0,0 +1,36 @@
1
+ This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-revo`](https://www.npmjs.com/package/create-revo) for {{projectName}}.
2
+
3
+ ## Getting Started
4
+
5
+ First, run the development server:
6
+
7
+ ```bash
8
+ npm run dev
9
+ # or
10
+ yarn dev
11
+ # or
12
+ pnpm dev
13
+ # or
14
+ bun dev
15
+ ```
16
+
17
+ Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18
+
19
+ You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20
+
21
+ This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22
+
23
+ ## Learn More
24
+
25
+ To learn more about Next.js, take a look at the following resources:
26
+
27
+ - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28
+ - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29
+
30
+ You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31
+
32
+ ## Deploy on Vercel
33
+
34
+ The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35
+
36
+ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
@@ -0,0 +1,25 @@
1
+ import { dirname } from "path";
2
+ import { fileURLToPath } from "url";
3
+ import { FlatCompat } from "@eslint/eslintrc";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = dirname(__filename);
7
+
8
+ const compat = new FlatCompat({
9
+ baseDirectory: __dirname,
10
+ });
11
+
12
+ const eslintConfig = [
13
+ ...compat.extends("next/core-web-vitals", "next/typescript"),
14
+ {
15
+ ignores: [
16
+ "node_modules/**",
17
+ ".next/**",
18
+ "out/**",
19
+ "build/**",
20
+ "next-env.d.ts",
21
+ ],
22
+ },
23
+ ];
24
+
25
+ export default eslintConfig;
@@ -0,0 +1,7 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {
4
+ /* config options here */
5
+ };
6
+
7
+ export default nextConfig;