@bill742/create-nextstarter 1.0.0 → 1.1.1
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 +1 -1
- package/package.json +5 -1
- package/src/index.js +15 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# create-nextstarter
|
|
2
2
|
|
|
3
|
-
Scaffold a new [NextStarter](https://github.com/bill742/nextstarter)
|
|
3
|
+
Scaffold a new Next.js project based on the [NextStarter](https://github.com/bill742/nextstarter) boilerplate with a single command.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -84,15 +84,26 @@ async function createNextStarter(projectName) {
|
|
|
84
84
|
}
|
|
85
85
|
console.log(" \u2713 Cleaning up");
|
|
86
86
|
|
|
87
|
-
// Step 3:
|
|
87
|
+
// Step 3: Prompt for site name
|
|
88
|
+
const siteName = (await prompt("? Site name? (e.g. My App) ")).trim() || projectName;
|
|
89
|
+
|
|
90
|
+
// Step 4: Copy .env.example → .env and apply site name
|
|
88
91
|
const envExample = path.join(targetDir, ".env.example");
|
|
89
92
|
const envTarget = path.join(targetDir, ".env");
|
|
90
93
|
if (fs.existsSync(envExample)) {
|
|
91
94
|
fs.copyFileSync(envExample, envTarget);
|
|
92
95
|
}
|
|
96
|
+
if (fs.existsSync(envTarget)) {
|
|
97
|
+
let envContent = fs.readFileSync(envTarget, "utf8");
|
|
98
|
+
envContent = envContent.replace(
|
|
99
|
+
/^(NEXT_PUBLIC_SITE_NAME=).*$/m,
|
|
100
|
+
`$1${siteName}`,
|
|
101
|
+
);
|
|
102
|
+
fs.writeFileSync(envTarget, envContent);
|
|
103
|
+
}
|
|
93
104
|
console.log(" \u2713 Setting up .env");
|
|
94
105
|
|
|
95
|
-
// Step
|
|
106
|
+
// Step 5: Rewrite package.json
|
|
96
107
|
const pkgPath = path.join(targetDir, "package.json");
|
|
97
108
|
if (fs.existsSync(pkgPath)) {
|
|
98
109
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
@@ -102,7 +113,7 @@ async function createNextStarter(projectName) {
|
|
|
102
113
|
}
|
|
103
114
|
console.log(" \u2713 Updating package.json");
|
|
104
115
|
|
|
105
|
-
// Step
|
|
116
|
+
// Step 6: Prompt to install dependencies
|
|
106
117
|
const answer = await prompt("\n? Install dependencies now? (Y/n) ");
|
|
107
118
|
const shouldInstall = answer.trim().toLowerCase() !== "n";
|
|
108
119
|
|
|
@@ -116,7 +127,7 @@ async function createNextStarter(projectName) {
|
|
|
116
127
|
}
|
|
117
128
|
}
|
|
118
129
|
|
|
119
|
-
// Step
|
|
130
|
+
// Step 7: Print next steps
|
|
120
131
|
console.log("\nDone! Your project is ready.\n");
|
|
121
132
|
console.log(` cd ${projectName}`);
|
|
122
133
|
if (!shouldInstall) {
|