create-express-mongo-ts 1.3.0 ā 1.4.0
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/bin/cli.js +70 -37
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -21,49 +21,82 @@ const styles = {
|
|
|
21
21
|
heading: (msg) => chalk.bold(msg),
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
// Check if running in interactive mode
|
|
25
|
+
function isInteractive() {
|
|
26
|
+
return process.stdin.isTTY && process.stdout.isTTY;
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
async function createExpressMongo() {
|
|
25
30
|
console.log(chalk.cyan.bold("\nš Create Express MongoDB TypeScript App\n"));
|
|
26
31
|
|
|
27
|
-
// Get project name from command line
|
|
32
|
+
// Get project name from command line
|
|
28
33
|
let projectName = process.argv[2];
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
let answers;
|
|
36
|
+
|
|
37
|
+
// If not interactive or project name provided, use defaults
|
|
38
|
+
if (!isInteractive()) {
|
|
39
|
+
if (!projectName) {
|
|
40
|
+
console.log(styles.error("ā Please provide a project name:"));
|
|
41
|
+
console.log(
|
|
42
|
+
` ${styles.command("npx create-express-mongo-ts")} ${chalk.green(
|
|
43
|
+
"<project-name>"
|
|
44
|
+
)}`
|
|
45
|
+
);
|
|
46
|
+
console.log(`\nExample:`);
|
|
47
|
+
console.log(` ${styles.command("npx create-express-mongo-ts my-app")}`);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log(
|
|
52
|
+
styles.warning("Running in non-interactive mode with defaults...\n")
|
|
53
|
+
);
|
|
54
|
+
answers = {
|
|
55
|
+
appName: projectName,
|
|
56
|
+
gitProvider: "github",
|
|
57
|
+
initGit: true,
|
|
58
|
+
installDeps: true,
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
// Interactive mode - use inquirer prompts
|
|
62
|
+
answers = await inquirer.prompt([
|
|
63
|
+
{
|
|
64
|
+
type: "input",
|
|
65
|
+
name: "appName",
|
|
66
|
+
message: "What is your app name?",
|
|
67
|
+
default: projectName || "my-express-mongo-app",
|
|
68
|
+
validate(input) {
|
|
69
|
+
if (!input.trim()) return "App name cannot be empty";
|
|
70
|
+
if (!/^[a-z0-9-_]+$/i.test(input))
|
|
71
|
+
return "App name can only contain letters, numbers, hyphens and underscores";
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: "list",
|
|
77
|
+
name: "gitProvider",
|
|
78
|
+
message: "Which Git provider do you want to use?",
|
|
79
|
+
choices: [
|
|
80
|
+
{ name: "GitHub", value: "github" },
|
|
81
|
+
{ name: "GitLab", value: "gitlab" },
|
|
82
|
+
{ name: "None", value: "none" },
|
|
83
|
+
],
|
|
84
|
+
default: "github",
|
|
41
85
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
name: "initGit",
|
|
57
|
-
message: "Initialize a git repository?",
|
|
58
|
-
default: true,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
type: "confirm",
|
|
62
|
-
name: "installDeps",
|
|
63
|
-
message: "Install dependencies automatically?",
|
|
64
|
-
default: true,
|
|
65
|
-
},
|
|
66
|
-
]);
|
|
86
|
+
{
|
|
87
|
+
type: "confirm",
|
|
88
|
+
name: "initGit",
|
|
89
|
+
message: "Initialize a git repository?",
|
|
90
|
+
default: true,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: "confirm",
|
|
94
|
+
name: "installDeps",
|
|
95
|
+
message: "Install dependencies automatically?",
|
|
96
|
+
default: true,
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
67
100
|
|
|
68
101
|
createApp(answers);
|
|
69
102
|
}
|
package/package.json
CHANGED