create-lumen 1.1.0 → 1.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.
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,6 +1,6 @@
1
1
  {
2
2
  "name": "create-lumen",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Scaffold a React + Vite project with architecture choice: feature-based or component-based.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "files": [
10
10
  "bin/",
11
+ "register.js",
11
12
  "src/",
12
13
  "templates/",
13
14
  "README.md",
package/register.js ADDED
@@ -0,0 +1,18 @@
1
+ import { registerHooks } from "node:module";
2
+ import path from "node:path";
3
+ import { fileURLToPath, pathToFileURL } from "node:url";
4
+
5
+ const SRC_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "src");
6
+
7
+ if (!globalThis.__lumenAliasRegistered) {
8
+ globalThis.__lumenAliasRegistered = true;
9
+ registerHooks({
10
+ resolve(specifier, context, nextResolve) {
11
+ if (specifier.startsWith("@/")) {
12
+ const resolvedPath = path.resolve(SRC_DIR, specifier.slice(2));
13
+ return nextResolve(pathToFileURL(resolvedPath).href, context);
14
+ }
15
+ return nextResolve(specifier, context);
16
+ },
17
+ });
18
+ }
package/src/main.js CHANGED
@@ -21,16 +21,28 @@ 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 cliArg = nameArg || process.argv[2];
26
+ if (cliArg && cliArg.trim()) {
27
+ return cliArg.trim();
28
+ }
29
+
30
+ if (quickSetup) {
31
+ const defaultName = path.basename(cwd).trim() || "my-app";
32
+ return defaultName === "." ? "my-app" : defaultName;
33
+ }
34
+
35
+ return null;
36
+ }
37
+
24
38
  export async function main(options = {}) {
25
39
  const { quickSetup = false, projectName: nameArg } = options;
26
40
  const pkg = getPkgManager();
27
41
 
28
42
  // 1. Project name
29
- const cliArg = nameArg || process.argv[2];
30
- let projectName;
43
+ let projectName = resolveProjectName({ quickSetup, projectName: nameArg, cwd: CURRENT_DIR });
31
44
 
32
- if (cliArg && cliArg.trim()) {
33
- projectName = cliArg.trim();
45
+ if (projectName) {
34
46
  log.step(chalk.gray(`Project name: ${chalk.bold(projectName)}`));
35
47
  } else {
36
48
  projectName = await text({