cordova-react-vite 1.0.0 → 3.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 +30 -25
  2. package/package.json +9 -6
package/execute.js CHANGED
@@ -2,37 +2,42 @@
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() {
12
+ async function main() {
13
+ // گرفتن آرگومان‌ها
25
14
  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);
15
+ let rootName = args[0];
16
+ let cordovaId = args[1];
17
+
18
+ // اگر آرگومان نبود، interactive کنیم
19
+ if (!rootName || !cordovaId) {
20
+ const answers = await inquirer.prompt([
21
+ {
22
+ type: "input",
23
+ name: "cordovaId",
24
+ message: "نام Package ID برای Cordova (مثال: com.example.name) چیه؟",
25
+ validate: input => input ? true : "نمیشه خالی باشه!"
26
+ },
27
+ {
28
+ type: "input",
29
+ name: "rootName",
30
+ message: "نام فولدر اصلی و package.json (kebab-case) چیه؟",
31
+ validate: input => input ? true : "نمیشه خالی باشه!"
32
+ }
33
+ ]);
34
+
35
+ rootName = answers.rootName;
36
+ cordovaId = answers.cordovaId;
29
37
  }
30
38
 
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);
39
+ const displayName = rootName;
40
+ const npmName = rootName;
36
41
  const cordovaName = displayName;
37
42
 
38
43
  const rootPath = path.join(process.cwd(), npmName);
@@ -41,7 +46,6 @@ function main() {
41
46
  console.log(`🚀 ایجاد پروژه ${displayName}`);
42
47
  console.log(`📦 npm name: ${npmName}`);
43
48
  console.log(`📱 cordova id: ${cordovaId}`);
44
- console.log(`📱 cordova name: ${cordovaName}`);
45
49
 
46
50
  // ---- React Vite ----
47
51
  console.log("📦 ایجاد پروژه React (Vite)...");
@@ -81,8 +85,9 @@ function main() {
81
85
  "build": "npm run react:build && npm run sync:build && npm run cordova:build && npm run move:apk",
82
86
  "start": "cd react && npm run dev"
83
87
  },
84
- devDependencies: {
85
- rimraf: "^5.0.0"
88
+ dependencies: {
89
+ "rimraf": "^5.0.0",
90
+ "inquirer": "^9.2.0"
86
91
  }
87
92
  };
88
93
 
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "cordova-react-vite",
3
- "version": "1.0.0",
4
- "description": "CLI to create a full React + Vite + Cordova project with Android platform",
5
- "main": "execute.js",
3
+ "version": "3.0.0",
4
+ "description": "Create React + Vite + Cordova project with Android build",
6
5
  "bin": {
7
6
  "cordova-react-vite": "execute.js"
8
7
  },
9
- "keywords": ["cordova", "react", "vite", "android", "cli"],
8
+ "scripts": {
9
+ "start": "node execute.js"
10
+ },
10
11
  "author": "Your Name",
11
12
  "license": "ISC",
12
- "dependencies": {},
13
- "devDependencies": {}
13
+ "dependencies": {
14
+ "inquirer": "^9.2.0",
15
+ "rimraf": "^5.0.0"
16
+ }
14
17
  }