quick-scaffolds-cli 1.2.4 → 1.2.6
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/.npmignore +2 -0
- package/README.md +10 -15
- package/bin/cli.js +25 -27
- package/package.json +4 -2
package/.npmignore
ADDED
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ A lightweight interactive CLI for scaffolding starter web projects quickly.
|
|
|
6
6
|
|
|
7
7
|
quick-scaffolds-cli generates a ready-to-use project from templates with a simple prompt flow.
|
|
8
8
|
|
|
9
|
-
Current release: v1.2.
|
|
9
|
+
Current release: v1.2.6
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ Install once and use the command anywhere:
|
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install -g quick-scaffolds-cli
|
|
19
|
-
ct-pro
|
|
19
|
+
ct-pro
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
### Use with npx
|
|
@@ -24,16 +24,16 @@ ct-pro my-awesome-app
|
|
|
24
24
|
Run without installing globally:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
npx quick-scaffolds-cli
|
|
27
|
+
npx quick-scaffolds-cli
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
|
-
Run the CLI
|
|
32
|
+
Run the CLI and answer the prompts:
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
ct-pro
|
|
36
|
-
?
|
|
35
|
+
ct-pro
|
|
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
38
|
Static HTML/CSS/JS
|
|
39
39
|
React starter
|
|
@@ -41,19 +41,13 @@ ct-pro my-awesome-app
|
|
|
41
41
|
|
|
42
42
|
Prompt details:
|
|
43
43
|
|
|
44
|
-
1.
|
|
45
|
-
-
|
|
46
|
-
-
|
|
44
|
+
1. Project name:
|
|
45
|
+
- Enter a new folder name (default: `my-new-project`)
|
|
46
|
+
- Enter `.` to scaffold in the current directory
|
|
47
47
|
2. Project type:
|
|
48
48
|
- Static HTML/CSS/JS
|
|
49
49
|
- React starter
|
|
50
50
|
|
|
51
|
-
If you choose not to keep the provided name, the CLI asks:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
? What is your project name? my-updated-app
|
|
55
|
-
```
|
|
56
|
-
|
|
57
51
|
## Templates
|
|
58
52
|
|
|
59
53
|
### 1. Static HTML/CSS/JS
|
|
@@ -105,6 +99,7 @@ The generated app includes a counter button and last-click timestamp in `App.jsx
|
|
|
105
99
|
- Interactive CLI powered by @inquirer/prompts
|
|
106
100
|
- Fast project scaffolding from local templates
|
|
107
101
|
- Two starter options: static web or React + Vite
|
|
102
|
+
- Supports scaffolding in the current directory using `.`
|
|
108
103
|
- Automatic dependency installation for React template
|
|
109
104
|
- Simple command interface via ct-pro
|
|
110
105
|
|
package/bin/cli.js
CHANGED
|
@@ -3,30 +3,20 @@ 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
|
|
6
|
+
import { input, select } from '@inquirer/prompts';
|
|
7
7
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
|
|
11
11
|
async function main() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
name = await input(
|
|
21
|
-
{
|
|
22
|
-
name: 'projectName',
|
|
23
|
-
message: 'What is your project name?',
|
|
24
|
-
type: 'input',
|
|
25
|
-
default: 'my-new-project'
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
12
|
+
const name = await input(
|
|
13
|
+
{
|
|
14
|
+
name: 'projectName',
|
|
15
|
+
message: 'What is your project name will be ? (Type "." to use the current directory)',
|
|
16
|
+
type: 'input',
|
|
17
|
+
default: 'my-new-project'
|
|
18
|
+
}
|
|
19
|
+
);
|
|
30
20
|
const projectType = await select({
|
|
31
21
|
message: 'What do you want to build?',
|
|
32
22
|
type: "list",
|
|
@@ -47,12 +37,15 @@ async function main() {
|
|
|
47
37
|
}
|
|
48
38
|
try {
|
|
49
39
|
const projectName = name;
|
|
50
|
-
const targetPath = path.join(process.cwd(), projectName);
|
|
40
|
+
const targetPath = projectName === '.' ? process.cwd() : path.join(process.cwd(), projectName);
|
|
51
41
|
|
|
52
42
|
const templatePath = path.join(__dirname, '../templates', templateFolder);
|
|
53
|
-
|
|
43
|
+
if (projectName !== '.') {
|
|
44
|
+
await fs.mkdir(targetPath, { recursive: true });
|
|
45
|
+
}
|
|
54
46
|
await fs.cp(templatePath, targetPath, { recursive: true });
|
|
55
|
-
|
|
47
|
+
const displayName = projectName === '.' ? path.basename(process.cwd()) : projectName;
|
|
48
|
+
console.log(`\nSuccessfully scaffolded the HTMl project - ${displayName}\n`)
|
|
56
49
|
|
|
57
50
|
} catch (err) {
|
|
58
51
|
console.error(`Error - ${err.message}`)
|
|
@@ -61,9 +54,14 @@ async function main() {
|
|
|
61
54
|
|
|
62
55
|
async function reactApp(projectName, templateFolder) {
|
|
63
56
|
try {
|
|
64
|
-
const
|
|
57
|
+
const isCurrentDirectory = projectName === '.';
|
|
58
|
+
const targetPath = isCurrentDirectory ? process.cwd() : path.join(process.cwd(), projectName);
|
|
59
|
+
const displayName = isCurrentDirectory ? path.basename(process.cwd()) : projectName;
|
|
60
|
+
|
|
65
61
|
const templatePath = path.join(__dirname, '../templates', templateFolder);
|
|
66
|
-
|
|
62
|
+
if (!isCurrentDirectory) {
|
|
63
|
+
await fs.mkdir(targetPath, { recursive: true });
|
|
64
|
+
}
|
|
67
65
|
await fs.cp(templatePath, targetPath, { recursive: true })
|
|
68
66
|
|
|
69
67
|
const filesToUpdate = [
|
|
@@ -73,15 +71,15 @@ async function reactApp(projectName, templateFolder) {
|
|
|
73
71
|
for (const filePath of filesToUpdate) {
|
|
74
72
|
try {
|
|
75
73
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
76
|
-
const updateContent = content.replaceAll('{{PROJECT_NAME}}',
|
|
74
|
+
const updateContent = content.replaceAll('{{PROJECT_NAME}}', displayName);
|
|
77
75
|
await fs.writeFile(filePath, updateContent);
|
|
78
|
-
} catch (err) {
|
|
76
|
+
} catch (err) {await fs.mkdir(targetPath, { recursive: true });
|
|
79
77
|
console.error(err);
|
|
80
78
|
console.error(`File path ${path.basename(filePath)} not found`);
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
console.log(`Successfully scaffolded the React starter project - ${
|
|
82
|
+
console.log(`Successfully scaffolded the React starter project - ${displayName}\n`)
|
|
85
83
|
console.log('📦 Installing dependencies... This may take a minute.\n');
|
|
86
84
|
try {
|
|
87
85
|
execSync('npm install', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quick-scaffolds-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ct-pro": "bin/cli.js"
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"files": [
|
|
10
10
|
"bin",
|
|
11
|
-
"templates"
|
|
11
|
+
"templates",
|
|
12
|
+
"README.md",
|
|
13
|
+
".npmignore"
|
|
12
14
|
],
|
|
13
15
|
"dependencies": {
|
|
14
16
|
"@inquirer/prompts": "^8.3.2"
|