create-next-mui 0.1.1 → 0.1.2

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/package.json +1 -1
  2. package/src/index.js +31 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-next-mui",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "spin up your nextjs project with mui setup",
5
5
  "keywords": [
6
6
  "nextjs",
package/src/index.js CHANGED
@@ -10,8 +10,18 @@ import { fileURLToPath } from "node:url";
10
10
  const __filename = fileURLToPath(import.meta.url);
11
11
  const __dirname = path.dirname(__filename);
12
12
 
13
- const initialProjectName = process.argv[2];
14
- const hasInitialProjectName = typeof initialProjectName === "string";
13
+ const args = process.argv.slice(2);
14
+ const positionalArgs = args.filter(
15
+ (arg) => !["--yes", "-y", "--js"].includes(arg),
16
+ );
17
+
18
+ const PROJECT_NAME = positionalArgs[0];
19
+ const hasInitialProjectName = PROJECT_NAME !== undefined;
20
+
21
+ const hasYesFlag = args.includes("--yes") || args.includes("-y");
22
+ const hasJsFlag = args.includes("--js");
23
+
24
+ const DEFAULT_LANGUAGE = hasJsFlag ? "js" : "ts";
15
25
 
16
26
  function validateProjectName(value) {
17
27
  if (value.length === 0) return "Project name is required!";
@@ -60,7 +70,7 @@ async function main() {
60
70
  p.intro(color.bgBlue(color.white(" create-next-mui ")));
61
71
 
62
72
  const projectNameError = hasInitialProjectName
63
- ? validateProjectName(initialProjectName)
73
+ ? validateProjectName(PROJECT_NAME)
64
74
  : undefined;
65
75
 
66
76
  if (projectNameError) {
@@ -72,28 +82,30 @@ async function main() {
72
82
  {
73
83
  name: () =>
74
84
  hasInitialProjectName
75
- ? Promise.resolve(initialProjectName)
85
+ ? Promise.resolve(PROJECT_NAME)
76
86
  : p.text({
77
87
  message: "What is your project name?",
78
88
  placeholder: "my-next-mui-app (or '.' for current directory)",
79
89
  validate: validateProjectName,
80
90
  }),
81
91
  language: () =>
82
- p.select({
83
- message: "Choose your language flavor:",
84
- options: [
85
- {
86
- value: "ts",
87
- label: "TypeScript (Recommended)",
88
- hint: "Strict typings, clean architecture",
89
- },
90
- {
91
- value: "js",
92
- label: "JavaScript",
93
- hint: "Vanilla JS configuration",
94
- },
95
- ],
96
- }),
92
+ hasYesFlag
93
+ ? Promise.resolve(DEFAULT_LANGUAGE)
94
+ : p.select({
95
+ message: "Choose your language flavor:",
96
+ options: [
97
+ {
98
+ value: "ts",
99
+ label: "TypeScript (Recommended)",
100
+ hint: "Strict typings, clean architecture",
101
+ },
102
+ {
103
+ value: "js",
104
+ label: "JavaScript",
105
+ hint: "Vanilla JS configuration",
106
+ },
107
+ ],
108
+ }),
97
109
  },
98
110
  {
99
111
  onCancel: () => {