crypt-express-app 1.3.0 → 1.3.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/dist/index.js +23 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,34 +20,36 @@ function ask(question) {
|
|
|
20
20
|
}
|
|
21
21
|
/* ===================== MAIN ===================== */
|
|
22
22
|
(async function main() {
|
|
23
|
-
let
|
|
23
|
+
let inputName = process.argv[2];
|
|
24
24
|
if (process.argv.length > 3) {
|
|
25
|
-
console.error("❌
|
|
25
|
+
console.error("❌ Only one project name allowed");
|
|
26
26
|
process.exit(1);
|
|
27
27
|
}
|
|
28
|
-
if (!
|
|
29
|
-
|
|
28
|
+
if (!inputName) {
|
|
29
|
+
inputName = await ask("Enter project name: ");
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
if (!
|
|
31
|
+
inputName = inputName.trim();
|
|
32
|
+
if (!inputName) {
|
|
33
33
|
console.error("❌ Project name required");
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
const useCurrentDir = inputName === ".";
|
|
37
|
+
// normalize only if not "."
|
|
38
|
+
const normalizedName = useCurrentDir
|
|
39
|
+
? path.basename(process.cwd())
|
|
40
|
+
: inputName
|
|
41
|
+
.toLowerCase()
|
|
42
|
+
.trim()
|
|
43
|
+
.replace(/\s+/g, "-") // spaces → dash
|
|
44
|
+
.replace(/[^a-z0-9-]/g, ""); // remove invalid chars
|
|
45
|
+
if (!normalizedName) {
|
|
46
|
+
console.error("❌ Invalid project name");
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
43
49
|
const projectDir = useCurrentDir
|
|
44
50
|
? process.cwd()
|
|
45
|
-
: path.join(process.cwd(),
|
|
51
|
+
: path.join(process.cwd(), normalizedName);
|
|
46
52
|
if (!useCurrentDir) {
|
|
47
|
-
if (/\s/.test(projectName)) {
|
|
48
|
-
console.error("❌ Name cannot contain spaces");
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
53
|
if (fs.existsSync(projectDir)) {
|
|
52
54
|
console.error("❌ Directory already exists");
|
|
53
55
|
process.exit(1);
|
|
@@ -62,15 +64,9 @@ function ask(question) {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
rl.close();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.replace(/\s+/g, "-") // space → dash
|
|
69
|
-
.replace(/[^a-z0-9-]/g, "") // remove invalid chars (optional)
|
|
70
|
-
: normalizedName;
|
|
71
|
-
process.env.PROJECT_NAME = finalProjectName;
|
|
72
|
-
console.log(`📦 Creating project: ${process.env.PROJECT_NAME}`);
|
|
73
|
-
generateRootFiles(projectDir, finalProjectName);
|
|
67
|
+
process.env.PROJECT_NAME = normalizedName;
|
|
68
|
+
console.log(`📦 Creating project: ${normalizedName}`);
|
|
69
|
+
generateRootFiles(projectDir, normalizedName);
|
|
74
70
|
generateApp(projectDir);
|
|
75
71
|
generateMiddlewares(projectDir);
|
|
76
72
|
generateLocales(projectDir);
|