@finesoft/create-app 0.1.17 → 0.1.19

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.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { run } from "../dist/index.mjs";
4
+
5
+ await run(process.argv.slice(2));
package/dist/index.mjs CHANGED
@@ -2,6 +2,7 @@ import * as prompts from "@clack/prompts";
2
2
  import { bold, cyan, green, red } from "kolorist";
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
+ import { fileURLToPath } from "node:url";
5
6
  //#region src/index.ts
6
7
  const FRAMEWORKS = [
7
8
  {
@@ -41,18 +42,35 @@ const FRAMEWORKS = [
41
42
  }]
42
43
  }
43
44
  ];
44
- async function main() {
45
+ const CURRENT_DIR = path.dirname(fileURLToPath(import.meta.url));
46
+ function validateProjectName(value) {
47
+ if (!value) return "Project name is required";
48
+ if (/[^\w\-.]/.test(value)) return "Invalid project name";
49
+ }
50
+ function getProjectNameFromArgs(argv) {
51
+ return argv.find((arg) => !arg.startsWith("-"));
52
+ }
53
+ function resolveTemplateDir(templateName) {
54
+ return path.resolve(CURRENT_DIR, "..", "templates", templateName);
55
+ }
56
+ async function run(argv = process.argv.slice(2)) {
45
57
  prompts.intro(bold("Create Finesoft App"));
58
+ const cliProjectName = getProjectNameFromArgs(argv);
59
+ const projectNameError = cliProjectName ? validateProjectName(cliProjectName) : void 0;
60
+ if (projectNameError) {
61
+ prompts.log.error(projectNameError);
62
+ process.exit(1);
63
+ }
46
64
  const project = await prompts.group({
47
- name: () => prompts.text({
48
- message: "Project name",
49
- placeholder: "my-finesoft-app",
50
- defaultValue: "my-finesoft-app",
51
- validate: (value) => {
52
- if (!value) return "Project name is required";
53
- if (/[^\w\-.]/.test(value)) return "Invalid project name";
54
- }
55
- }),
65
+ name: () => {
66
+ if (cliProjectName) return Promise.resolve(cliProjectName);
67
+ return prompts.text({
68
+ message: "Project name",
69
+ placeholder: "my-finesoft-app",
70
+ defaultValue: "my-finesoft-app",
71
+ validate: validateProjectName
72
+ });
73
+ },
56
74
  framework: () => prompts.select({
57
75
  message: "Framework",
58
76
  options: FRAMEWORKS.map((f) => ({
@@ -76,7 +94,7 @@ async function main() {
76
94
  } });
77
95
  const targetDir = path.resolve(process.cwd(), project.name);
78
96
  const templateName = project.variant;
79
- const templateDir = path.resolve(new URL(".", import.meta.url).pathname, "..", "templates", templateName);
97
+ const templateDir = resolveTemplateDir(templateName);
80
98
  if (!fs.existsSync(templateDir)) {
81
99
  prompts.log.error(`Template "${templateName}" not found at ${templateDir}`);
82
100
  process.exit(1);
@@ -123,9 +141,13 @@ function copyDir(src, dest) {
123
141
  else fs.copyFileSync(srcPath, destPath);
124
142
  }
125
143
  }
126
- main().catch((err) => {
144
+ function isDirectExecution() {
145
+ if (!process.argv[1]) return false;
146
+ return path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
147
+ }
148
+ if (isDirectExecution()) run().catch((err) => {
127
149
  console.error(err);
128
150
  process.exit(1);
129
151
  });
130
152
  //#endregion
131
- export {};
153
+ export { getProjectNameFromArgs, resolveTemplateDir, run, validateProjectName };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@finesoft/create-app",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "Scaffold a new Finesoft Front project",
5
5
  "license": "MIT",
6
6
  "bin": {
7
- "create-finesoft-app": "dist/index.mjs"
7
+ "create-finesoft-app": "bin/create-finesoft-app.js"
8
8
  },
9
9
  "files": [
10
+ "bin",
10
11
  "dist",
11
12
  "templates"
12
13
  ],
@@ -8,7 +8,7 @@
8
8
  "preview": "vp preview"
9
9
  },
10
10
  "dependencies": {
11
- "@finesoft/front": "^0.1.66",
11
+ "@finesoft/front": "^0.1.68",
12
12
  "react": "^19.0.0",
13
13
  "react-dom": "^19.0.0"
14
14
  },
@@ -8,7 +8,7 @@
8
8
  "preview": "vp preview"
9
9
  },
10
10
  "dependencies": {
11
- "@finesoft/front": "^0.1.66",
11
+ "@finesoft/front": "^0.1.68",
12
12
  "react": "^19.0.0",
13
13
  "react-dom": "^19.0.0"
14
14
  },
@@ -8,7 +8,7 @@
8
8
  "preview": "vp preview"
9
9
  },
10
10
  "dependencies": {
11
- "@finesoft/front": "^0.1.66",
11
+ "@finesoft/front": "^0.1.68",
12
12
  "svelte": "^5.0.0"
13
13
  },
14
14
  "devDependencies": {
@@ -8,7 +8,7 @@
8
8
  "preview": "vp preview"
9
9
  },
10
10
  "dependencies": {
11
- "@finesoft/front": "^0.1.66",
11
+ "@finesoft/front": "^0.1.68",
12
12
  "svelte": "^5.0.0"
13
13
  },
14
14
  "devDependencies": {
@@ -8,7 +8,7 @@
8
8
  "preview": "vp preview"
9
9
  },
10
10
  "dependencies": {
11
- "@finesoft/front": "^0.1.66",
11
+ "@finesoft/front": "^0.1.68",
12
12
  "vue": "^3.5.0"
13
13
  },
14
14
  "devDependencies": {
@@ -8,7 +8,7 @@
8
8
  "preview": "vp preview"
9
9
  },
10
10
  "dependencies": {
11
- "@finesoft/front": "^0.1.66",
11
+ "@finesoft/front": "^0.1.68",
12
12
  "vue": "^3.5.0"
13
13
  },
14
14
  "devDependencies": {