create-sb-react 1.0.3 → 1.0.7
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/index.js +24 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -49,17 +49,22 @@ const template =
|
|
|
49
49
|
? "react-ts"
|
|
50
50
|
: "react";
|
|
51
51
|
|
|
52
|
+
const useCurrentDir = !answers.projectName.trim();
|
|
53
|
+
const projectTarget = useCurrentDir ? "." : answers.projectName;
|
|
54
|
+
|
|
52
55
|
console.log("📦 Creating Vite project...");
|
|
53
56
|
|
|
54
57
|
execSync(
|
|
55
|
-
`npx create-vite@latest ${
|
|
58
|
+
`npx create-vite@latest ${projectTarget} --template ${template}`,
|
|
56
59
|
{
|
|
57
60
|
stdio: ["pipe", "inherit", "inherit"],
|
|
58
61
|
input: "n\n"
|
|
59
62
|
}
|
|
60
63
|
);
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
if (!useCurrentDir) {
|
|
66
|
+
process.chdir(answers.projectName);
|
|
67
|
+
}
|
|
63
68
|
|
|
64
69
|
console.log("📦 Installing common packages...");
|
|
65
70
|
|
|
@@ -86,9 +91,19 @@ fs.writeJsonSync(".prettierrc", {
|
|
|
86
91
|
trailingComma: "es5"
|
|
87
92
|
}, { spaces: 2 });
|
|
88
93
|
|
|
94
|
+
fs.writeFileSync(
|
|
95
|
+
".prettierignore",
|
|
96
|
+
"node_modules\ndist\nbuild\n.husky\ncspell.json\n"
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
fs.writeFileSync(
|
|
100
|
+
".gitignore",
|
|
101
|
+
"# Logs\nlogs\n*.log\nnpm-debug.log*\n\n# Dependencies\nnode_modules\n\n# Build output\ndist\nbuild\n\n# Local env files\n.env\n.env.local\n.env.*.local\n\n# Editor\n.vscode\n.idea\n\n# OS\n.DS_Store\nThumbs.db\n"
|
|
102
|
+
);
|
|
103
|
+
|
|
89
104
|
const packageJson = fs.readJsonSync("package.json");
|
|
90
|
-
packageJson.scripts["spell-check"] = "cspell \"src/**/*.{js,jsx,ts,tsx,scss}\"";
|
|
91
|
-
packageJson.scripts["format"] = "prettier --write src/**/*.{js,jsx,ts,tsx,scss,css}";
|
|
105
|
+
packageJson.scripts["spell-check"] = "cspell --no-must-find-files \"src/**/*.{js,jsx,ts,tsx,scss}\"";
|
|
106
|
+
packageJson.scripts["format"] = "prettier --write --no-error-on-unmatched-pattern src/**/*.{js,jsx,ts,tsx,scss,css}";
|
|
92
107
|
fs.writeJsonSync("package.json", packageJson, { spaces: 2 });
|
|
93
108
|
|
|
94
109
|
fs.writeJsonSync("cspell.json", {
|
|
@@ -264,7 +279,7 @@ import ReactDOM from "react-dom/client";
|
|
|
264
279
|
import App from "./App";
|
|
265
280
|
import "./index.css";
|
|
266
281
|
|
|
267
|
-
ReactDOM.createRoot(document.getElementById("root")).render(
|
|
282
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
268
283
|
<React.StrictMode>
|
|
269
284
|
<App />
|
|
270
285
|
</React.StrictMode>
|
|
@@ -279,7 +294,7 @@ import React from "react";
|
|
|
279
294
|
import ReactDOM from "react-dom/client";
|
|
280
295
|
import App from "./App";
|
|
281
296
|
|
|
282
|
-
ReactDOM.createRoot(document.getElementById("root")).render(
|
|
297
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
283
298
|
<React.StrictMode>
|
|
284
299
|
<App />
|
|
285
300
|
</React.StrictMode>
|
|
@@ -291,6 +306,8 @@ ReactDOM.createRoot(document.getElementById("root")).render(
|
|
|
291
306
|
console.log("");
|
|
292
307
|
console.log("✅ Project setup completed successfully!");
|
|
293
308
|
console.log("");
|
|
294
|
-
|
|
309
|
+
if (!useCurrentDir) {
|
|
310
|
+
console.log(`👉 cd ${answers.projectName}`);
|
|
311
|
+
}
|
|
295
312
|
console.log("👉 npm run dev");
|
|
296
313
|
|