create-lumen 1.1.1 → 1.1.3

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/README.md CHANGED
@@ -18,8 +18,12 @@ Non-interactive Quick Setup (TypeScript + Tailwind + Feature-based + Router + ES
18
18
 
19
19
  ```bash
20
20
  npm create lumen my-app -y
21
+ # or
22
+ npm create lumen -y my-app
21
23
  ```
22
24
 
25
+ The CLI ignores flag arguments when resolving the project name, so `-y` can appear before or after the app name without being mistaken for the folder name.
26
+
23
27
  Run the scaffolder locally (development / testing the generator):
24
28
 
25
29
  ```bash
package/bin/cli.js CHANGED
@@ -1,15 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { readFile } from "node:fs/promises";
3
4
  import chalk from "chalk";
4
5
  import "../register.js";
5
6
 
7
+ const { version } = JSON.parse(
8
+ await readFile(new URL("../package.json", import.meta.url), "utf8")
9
+ );
10
+
6
11
  const args = process.argv.slice(2);
7
12
  const quickSetup = args.includes("-y");
8
13
  const projectName = args.find((a) => !a.startsWith("-"));
9
14
 
10
15
  console.log(
11
16
  chalk.bold.cyan("\n ✦ LUMEN") +
12
- chalk.gray(" v1.1.0") +
17
+ chalk.gray(` v${version}`) +
13
18
  chalk.gray(
14
19
  "\n Scaffold a React + Vite project with architecture choice\n"
15
20
  )
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "create-lumen",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Scaffold a React + Vite project with architecture choice: feature-based or component-based.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "create-lumen": "bin/cli.js"
8
8
  },
9
9
  "files": [
10
- "bin/",
11
- "register.js",
12
- "src/",
13
- "templates/",
14
- "README.md",
15
- "LICENSE"
16
- ],
10
+ "bin/",
11
+ "register.js",
12
+ "src/",
13
+ "templates/",
14
+ "README.md",
15
+ "LICENSE"
16
+ ],
17
17
  "scripts": {
18
18
  "test": "node --import ./register.js --test \"tests/unit/*.test.mjs\" \"tests/smoke/*.test.mjs\""
19
19
  },
package/src/main.js CHANGED
@@ -21,16 +21,30 @@ const __dirname = path.dirname(__filename);
21
21
  const TEMPLATES_DIR = path.join(__dirname, "../templates");
22
22
  const CURRENT_DIR = process.cwd();
23
23
 
24
+ export function resolveProjectName({ quickSetup = false, projectName: nameArg, cwd = CURRENT_DIR } = {}) {
25
+ const cliArgs = (process.argv.slice(2) ?? []).filter((arg) => arg && !arg.startsWith("-"));
26
+ const cliArg = nameArg || cliArgs[0] || null;
27
+
28
+ if (cliArg && cliArg.trim()) {
29
+ return cliArg.trim();
30
+ }
31
+
32
+ if (quickSetup) {
33
+ const defaultName = path.basename(cwd).trim() || "my-app";
34
+ return defaultName === "." ? "my-app" : defaultName;
35
+ }
36
+
37
+ return null;
38
+ }
39
+
24
40
  export async function main(options = {}) {
25
41
  const { quickSetup = false, projectName: nameArg } = options;
26
42
  const pkg = getPkgManager();
27
43
 
28
44
  // 1. Project name
29
- const cliArg = nameArg || process.argv[2];
30
- let projectName;
45
+ let projectName = resolveProjectName({ quickSetup, projectName: nameArg, cwd: CURRENT_DIR });
31
46
 
32
- if (cliArg && cliArg.trim()) {
33
- projectName = cliArg.trim();
47
+ if (projectName) {
34
48
  log.step(chalk.gray(`Project name: ${chalk.bold(projectName)}`));
35
49
  } else {
36
50
  projectName = await text({