quick-scaffolds-cli 1.2.6 → 1.3.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 +84 -39
- package/bin/cli.js +56 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# quick-scaffolds-cli
|
|
2
2
|
|
|
3
|
-
A lightweight interactive CLI for scaffolding starter web projects
|
|
3
|
+
A lightweight, interactive CLI for scaffolding starter web projects in seconds.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
quick-scaffolds-cli
|
|
7
|
+
quick-scaffolds-cli is a command-line tool that generates ready-to-use web project starters with zero configuration. Answer a few simple prompts and get a fully structured project—choose between static HTML/CSS/JS or a modern React + Vite setup.
|
|
8
8
|
|
|
9
|
-
Current release
|
|
9
|
+
**Current release:** v1.3.0 | **License:** MIT
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
@@ -35,26 +35,26 @@ Run the CLI and answer the prompts:
|
|
|
35
35
|
ct-pro
|
|
36
36
|
? What is your project name will be ? (Type "." to use the current directory) my-awesome-app
|
|
37
37
|
? What do you want to build?
|
|
38
|
-
Static HTML/CSS/JS
|
|
39
|
-
|
|
38
|
+
❯ Static HTML/CSS/JS
|
|
39
|
+
React starter
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
Prompt
|
|
42
|
+
### Prompt Details
|
|
43
43
|
|
|
44
|
-
1. Project
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
**1. Project Name**
|
|
45
|
+
- Enter a new folder name to create a new directory (default: `my-new-project`)
|
|
46
|
+
- Enter `.` to scaffold directly in the current directory
|
|
47
|
+
|
|
48
|
+
**2. Project Type**
|
|
49
|
+
- **Static HTML/CSS/JS:** A simple, lightweight static site starter—perfect for learning or quick prototypes
|
|
50
|
+
- **React starter:** A modern React app with Vite, ESM modules, and optional React Router setup for navigation
|
|
50
51
|
|
|
51
52
|
## Templates
|
|
52
53
|
|
|
53
54
|
### 1. Static HTML/CSS/JS
|
|
55
|
+
A simple, minimal starter template for static web projects.
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
Generated structure:
|
|
57
|
+
**Generated structure:**
|
|
58
58
|
|
|
59
59
|
```text
|
|
60
60
|
my-awesome-app/
|
|
@@ -65,17 +65,26 @@ my-awesome-app/
|
|
|
65
65
|
└── app.js
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
**Next steps:**
|
|
69
|
+
```bash
|
|
70
|
+
cd my-awesome-app
|
|
71
|
+
# Open index.html in your browser
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### 2. React Starter (Vite + Modern ESM)
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
A modern React starter with Vite, automatic dependency installation, and optional React Router setup.
|
|
71
79
|
|
|
72
|
-
Generated structure
|
|
80
|
+
**Generated structure:**
|
|
73
81
|
|
|
74
82
|
```text
|
|
75
83
|
my-awesome-app/
|
|
76
84
|
├── .gitignore
|
|
77
85
|
├── index.html
|
|
78
86
|
├── package.json
|
|
87
|
+
├── vite.config.js
|
|
79
88
|
├── public/
|
|
80
89
|
│ └── index.css
|
|
81
90
|
└── src/
|
|
@@ -85,44 +94,80 @@ my-awesome-app/
|
|
|
85
94
|
└── main.jsx
|
|
86
95
|
```
|
|
87
96
|
|
|
88
|
-
|
|
97
|
+
**Interactive setup:**
|
|
98
|
+
- 📦 Automatically installs npm dependencies after scaffolding
|
|
99
|
+
- 🛣️ Prompts to install **React Router** for navigation (optional)
|
|
100
|
+
✨ **Interactive CLI** — User-friendly prompts powered by [@inquirer/prompts](https://www.npmjs.com/package/@inquirer/prompts)
|
|
89
101
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
⚡ **Zero Configuration** — Choose a template and get a working project instantly
|
|
103
|
+
|
|
104
|
+
🎨 **Two Templates:**
|
|
105
|
+
- Static HTML/CSS/JS for simple projects
|
|
106
|
+
- React + Vite with modern ESM module support
|
|
107
|
+
|
|
108
|
+
🛣️ **React Router Setup** — Optional routing configuration for multi-page React apps
|
|
109
|
+
|
|
110
|
+
📦 **Automatic Dependencies** — npm install runs automatically for React projects
|
|
111
|
+
|
|
112
|
+
🎯 **Current Directory Support** — Use `.` to scaffold in your existing folder
|
|
113
|
+
|
|
114
|
+
🚀 **Simple Command Interface** — Just run `ct-pro` from anywhere
|
|
93
115
|
```
|
|
94
116
|
|
|
117
|
+
The generated app includes a counter button in `App.jsx` so you can immediately see React state updates in action
|
|
95
118
|
The generated app includes a counter button and last-click timestamp in `App.jsx` so you can quickly confirm rendering and state updates.
|
|
96
119
|
|
|
97
120
|
## Features
|
|
98
121
|
|
|
99
|
-
|
|
100
|
-
- Fast project scaffolding from local templates
|
|
101
|
-
- Two starter options: static web or React + Vite
|
|
102
|
-
- Supports scaffolding in the current directory using `.`
|
|
103
|
-
- Automatic dependency installation for React template
|
|
104
|
-
- Simple command interface via ct-pro
|
|
122
|
+
### React Project is Blank
|
|
105
123
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
- If the React page is blank, run the dev server inside your generated project folder:
|
|
124
|
+
Ensure you're running the development server:
|
|
109
125
|
|
|
110
126
|
```bash
|
|
111
127
|
cd my-awesome-app
|
|
112
128
|
npm run dev
|
|
113
129
|
```
|
|
114
130
|
|
|
115
|
-
|
|
116
|
-
- `index.html` loads `./src/main.jsx`
|
|
117
|
-
- `main.jsx` renders `App.jsx`
|
|
131
|
+
Then open http://localhost:5173 in your browser.
|
|
118
132
|
|
|
119
|
-
|
|
133
|
+
### React Entry Point
|
|
120
134
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
The React app boots in this order:
|
|
136
|
+
1. `index.html` loads your app into the root div
|
|
137
|
+
2. `src/main.jsx` renders the React app
|
|
138
|
+
3. `App.jsx` is the root React component
|
|
124
139
|
|
|
125
|
-
|
|
140
|
+
### Dependencies Installation Failed
|
|
141
|
+
The quick-scaffolds-cli repository is organized as follows:
|
|
142
|
+
|
|
143
|
+
```text
|
|
144
|
+
quick-scaffolds-cli/
|
|
145
|
+
├── LICENSE
|
|
146
|
+
├── README.md
|
|
147
|
+
├── package.json
|
|
148
|
+
├── bin/
|
|
149
|
+
│ └── cli.js # Main CLI entry point
|
|
150
|
+
├── templates/
|
|
151
|
+
│ ├── html-template/ # Static web starter
|
|
152
|
+
│ │ ├── index.html
|
|
153
|
+
│ │ ├── css/
|
|
154
|
+
│ │ │ └── style.css
|
|
155
|
+
│ │ └── js/
|
|
156
|
+
│ │ └── app.js
|
|
157
|
+
│ └── react-template/ # React + Vite starter
|
|
158
|
+
│ ├── .gitignore
|
|
159
|
+
│ ├── index.html
|
|
160
|
+
│ ├── package.json
|
|
161
|
+
│ ├── vite.config.js
|
|
162
|
+
│ ├── public/
|
|
163
|
+
│ │ └── index.css
|
|
164
|
+
│ └── src/
|
|
165
|
+
│ ├── App.css
|
|
166
|
+
│ ├── App.jsx
|
|
167
|
+
│ ├── index.css
|
|
168
|
+
│ ├── main.jsx
|
|
169
|
+
│ └── pages/ # (created if React Router is selected)
|
|
170
|
+
│ └── Home.jsx
|
|
126
171
|
|
|
127
172
|
```text
|
|
128
173
|
quick-scaffolds-cli/
|
package/bin/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { execSync } from 'node:child_process';
|
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { input, select } from '@inquirer/prompts';
|
|
6
|
+
import { input, select, confirm } from '@inquirer/prompts';
|
|
7
7
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
@@ -73,7 +73,8 @@ async function reactApp(projectName, templateFolder) {
|
|
|
73
73
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
74
74
|
const updateContent = content.replaceAll('{{PROJECT_NAME}}', displayName);
|
|
75
75
|
await fs.writeFile(filePath, updateContent);
|
|
76
|
-
} catch (err) {
|
|
76
|
+
} catch (err) {
|
|
77
|
+
await fs.mkdir(targetPath, { recursive: true });
|
|
77
78
|
console.error(err);
|
|
78
79
|
console.error(`File path ${path.basename(filePath)} not found`);
|
|
79
80
|
}
|
|
@@ -87,6 +88,59 @@ async function reactApp(projectName, templateFolder) {
|
|
|
87
88
|
stdio: 'inherit'
|
|
88
89
|
});
|
|
89
90
|
console.log('✅ Dependencies installed successfully!\n');
|
|
91
|
+
|
|
92
|
+
const addRouterQuestion = await confirm({
|
|
93
|
+
message: 'Whould you like to setup React Router for navigation ?',
|
|
94
|
+
default: true
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
if (addRouterQuestion) {
|
|
98
|
+
console.log('Adding React Router...📦')
|
|
99
|
+
execSync('npm install react-router-dom', {
|
|
100
|
+
cwd: targetPath,
|
|
101
|
+
stdio: 'inherit'
|
|
102
|
+
});
|
|
103
|
+
const routerAppCode = `
|
|
104
|
+
|
|
105
|
+
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
|
|
106
|
+
import Home from './pages/Home';
|
|
107
|
+
import React from 'react';
|
|
108
|
+
|
|
109
|
+
function App() {
|
|
110
|
+
return (
|
|
111
|
+
<Router>
|
|
112
|
+
<Routes>
|
|
113
|
+
<Route path="/" element={<Home />} />
|
|
114
|
+
</Routes>
|
|
115
|
+
</Router>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export default App;
|
|
120
|
+
|
|
121
|
+
`;
|
|
122
|
+
const appJsxPath = path.join(targetPath, 'src', 'App.jsx');
|
|
123
|
+
await fs.writeFile(appJsxPath, routerAppCode);
|
|
124
|
+
const pageDirPath = path.join(targetPath, 'src', 'pages');
|
|
125
|
+
await fs.mkdir(pageDirPath, { recursive: true});
|
|
126
|
+
const homeComponentCode =`
|
|
127
|
+
|
|
128
|
+
import React from 'react';
|
|
129
|
+
|
|
130
|
+
export default function Home() {
|
|
131
|
+
return (
|
|
132
|
+
<div>
|
|
133
|
+
<h1>Welcome Home</h1>
|
|
134
|
+
<p>Your React Router is up and running!</p>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
const homeComponentPath = path.join(pageDirPath, 'Home.jsx');
|
|
140
|
+
await fs.writeFile(homeComponentPath, homeComponentCode);
|
|
141
|
+
console.log('✅ Successfully added React Router');
|
|
142
|
+
|
|
143
|
+
}
|
|
90
144
|
} catch (err) {
|
|
91
145
|
console.error(err);
|
|
92
146
|
console.log('⚠️ Could not install dependencies automatically.\n');
|