create-next-mui 0.0.4 → 0.0.5
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/package.json +1 -1
- package/src/index.js +39 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -19,11 +19,14 @@ async function main() {
|
|
|
19
19
|
name: () =>
|
|
20
20
|
p.text({
|
|
21
21
|
message: "What is your project name?",
|
|
22
|
-
placeholder: "my-next-mui-app",
|
|
22
|
+
placeholder: "my-next-mui-app (or '.' for current directory)",
|
|
23
23
|
validate(value) {
|
|
24
24
|
if (value.length === 0) return "Project name is required!";
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
|
|
26
|
+
// ✅ Allow exactly "." otherwise apply your safe character regex
|
|
27
|
+
if (value !== "." && value.match(/[^a-zA-Z0-9-_]/g)) {
|
|
28
|
+
return "Keep it URL safe or use '.' for the current folder";
|
|
29
|
+
}
|
|
27
30
|
},
|
|
28
31
|
}),
|
|
29
32
|
language: () =>
|
|
@@ -59,6 +62,24 @@ async function main() {
|
|
|
59
62
|
// Define destination paths (where the user is running the command)
|
|
60
63
|
const targetProjectDir = path.resolve(process.cwd(), project.name);
|
|
61
64
|
|
|
65
|
+
// If targeting current directory, make sure it's clean
|
|
66
|
+
if (project.name === ".") {
|
|
67
|
+
try {
|
|
68
|
+
const existingFiles = await fs.readdir(targetProjectDir);
|
|
69
|
+
if (existingFiles.length > 0) {
|
|
70
|
+
p.log.error(
|
|
71
|
+
color.red(
|
|
72
|
+
"The current directory is not empty! Please clear it or specify a project name.",
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
// If the directory reading fails completely, we exit safely
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
62
83
|
const s = p.spinner();
|
|
63
84
|
s.start("Unboxing your Next.js + MUI foundation locally...");
|
|
64
85
|
|
|
@@ -66,7 +87,15 @@ async function main() {
|
|
|
66
87
|
// Native high-speed recursive copy
|
|
67
88
|
await fs.cp(sourceTemplateDir, targetProjectDir, {
|
|
68
89
|
recursive: true,
|
|
69
|
-
filter: (src) =>
|
|
90
|
+
filter: (src) => {
|
|
91
|
+
const targetName = path.basename(src);
|
|
92
|
+
return (
|
|
93
|
+
targetName !== "node_modules" &&
|
|
94
|
+
targetName !== ".next" &&
|
|
95
|
+
targetName !== "out" &&
|
|
96
|
+
targetName !== "build"
|
|
97
|
+
);
|
|
98
|
+
},
|
|
70
99
|
});
|
|
71
100
|
|
|
72
101
|
s.stop(color.green("Workspace scaffolded successfully!"));
|
|
@@ -77,8 +106,13 @@ async function main() {
|
|
|
77
106
|
}
|
|
78
107
|
|
|
79
108
|
// Clear instructions for the developer
|
|
109
|
+
const isCurrentDir = project.name === ".";
|
|
110
|
+
const cdInstruction = isCurrentDir
|
|
111
|
+
? ""
|
|
112
|
+
: `${color.cyan(`cd ${project.name}`)}\n`;
|
|
113
|
+
|
|
80
114
|
p.note(
|
|
81
|
-
`${
|
|
115
|
+
`${cdInstruction}${color.cyan("npm install")}\n${color.cyan("npm run dev")}`,
|
|
82
116
|
"Next Steps to Get Started:",
|
|
83
117
|
);
|
|
84
118
|
|