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.
Files changed (2) hide show
  1. package/bin/cli.js +70 -37
  2. 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 or prompt
32
+ // Get project name from command line
28
33
  let projectName = process.argv[2];
29
34
 
30
- const answers = await inquirer.prompt([
31
- {
32
- type: "input",
33
- name: "appName",
34
- message: "What is your app name?",
35
- default: projectName || "my-express-mongo-app",
36
- validate(input) {
37
- if (!input.trim()) return "App name cannot be empty";
38
- if (!/^[a-z0-9-_]+$/i.test(input))
39
- return "App name can only contain letters, numbers, hyphens and underscores";
40
- return true;
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
- type: "list",
45
- name: "gitProvider",
46
- message: "Which Git provider do you want to use?",
47
- choices: [
48
- { name: "GitHub", value: "github" },
49
- { name: "GitLab", value: "gitlab" },
50
- { name: "None", value: "none" },
51
- ],
52
- default: "github",
53
- },
54
- {
55
- type: "confirm",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-express-mongo-ts",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Create Express + MongoDB applications with TypeScript, authentication, and best practices out of the box",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {