cordova-react-vite 1.0.0 → 2.0.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/execute.js +21 -25
  2. package/package.json +1 -1
package/execute.js CHANGED
@@ -2,37 +2,32 @@
2
2
  const { execSync } = require("child_process");
3
3
  const fs = require("fs");
4
4
  const path = require("path");
5
+ const inquirer = require("inquirer");
5
6
 
6
7
  function run(cmd, cwd = process.cwd()) {
7
8
  console.log(`▶ ${cmd}`);
8
9
  execSync(cmd, { stdio: "inherit", cwd, shell: true });
9
10
  }
10
11
 
11
- function toKebab(str) {
12
- return str.toLowerCase().replace(/\s+/g, "-");
13
- }
14
-
15
- function toCamel(str) {
16
- return str.replace(/\s+/g, "").toLowerCase();
17
- }
18
-
19
- function reverseDomain(domain, appName) {
20
- const parts = domain.split(".").reverse();
21
- return [...parts, toCamel(appName)].join(".");
22
- }
23
-
24
- function main() {
25
- const args = process.argv.slice(2);
26
- if (args.length < 2) {
27
- console.error("❌ دستور اشتباه!\nمثال: cordova-react-vite Boxit Tracker boxitsoft.ir");
28
- process.exit(1);
29
- }
12
+ async function main() {
13
+ const answers = await inquirer.prompt([
14
+ {
15
+ type: "input",
16
+ name: "cordovaId",
17
+ message: "نام Package ID برای Cordova (مثال: com.example.name) چیه؟",
18
+ validate: input => input ? true : "نمیشه خالی باشه!"
19
+ },
20
+ {
21
+ type: "input",
22
+ name: "rootName",
23
+ message: "نام فولدر اصلی و package.json (kebab-case) چیه؟",
24
+ validate: input => input ? true : "نمیشه خالی باشه!"
25
+ }
26
+ ]);
30
27
 
31
- const domain = args[args.length - 1];
32
- const appNameParts = args.slice(0, -1);
33
- const displayName = appNameParts.join(" ");
34
- const npmName = toKebab(displayName);
35
- const cordovaId = reverseDomain(domain, displayName);
28
+ const { cordovaId, rootName } = answers;
29
+ const displayName = rootName; // برای نمایش در Cordova
30
+ const npmName = rootName; // از کاربر گرفته شده، هیچ تبدیل خودکاری انجام نمی‌شود
36
31
  const cordovaName = displayName;
37
32
 
38
33
  const rootPath = path.join(process.cwd(), npmName);
@@ -82,7 +77,8 @@ function main() {
82
77
  "start": "cd react && npm run dev"
83
78
  },
84
79
  devDependencies: {
85
- rimraf: "^5.0.0"
80
+ rimraf: "^5.0.0",
81
+ inquirer: "^9.2.0"
86
82
  }
87
83
  };
88
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-react-vite",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "CLI to create a full React + Vite + Cordova project with Android platform",
5
5
  "main": "execute.js",
6
6
  "bin": {