cordova-react-vite 3.0.0 → 3.0.1

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 +25 -30
  2. package/package.json +7 -10
package/execute.js CHANGED
@@ -2,42 +2,37 @@
2
2
  const { execSync } = require("child_process");
3
3
  const fs = require("fs");
4
4
  const path = require("path");
5
- const inquirer = require("inquirer");
6
5
 
7
6
  function run(cmd, cwd = process.cwd()) {
8
7
  console.log(`▶ ${cmd}`);
9
8
  execSync(cmd, { stdio: "inherit", cwd, shell: true });
10
9
  }
11
10
 
12
- async function main() {
13
- // گرفتن آرگومان‌ها
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() {
14
25
  const args = process.argv.slice(2);
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;
26
+ if (args.length < 2) {
27
+ console.error("❌ دستور اشتباه!\nمثال: cordova-react-vite Boxit Tracker boxitsoft.ir");
28
+ process.exit(1);
37
29
  }
38
30
 
39
- const displayName = rootName;
40
- const npmName = rootName;
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);
41
36
  const cordovaName = displayName;
42
37
 
43
38
  const rootPath = path.join(process.cwd(), npmName);
@@ -46,6 +41,7 @@ async function main() {
46
41
  console.log(`🚀 ایجاد پروژه ${displayName}`);
47
42
  console.log(`📦 npm name: ${npmName}`);
48
43
  console.log(`📱 cordova id: ${cordovaId}`);
44
+ console.log(`📱 cordova name: ${cordovaName}`);
49
45
 
50
46
  // ---- React Vite ----
51
47
  console.log("📦 ایجاد پروژه React (Vite)...");
@@ -85,9 +81,8 @@ async function main() {
85
81
  "build": "npm run react:build && npm run sync:build && npm run cordova:build && npm run move:apk",
86
82
  "start": "cd react && npm run dev"
87
83
  },
88
- dependencies: {
89
- "rimraf": "^5.0.0",
90
- "inquirer": "^9.2.0"
84
+ devDependencies: {
85
+ rimraf: "^5.0.0"
91
86
  }
92
87
  };
93
88
 
package/package.json CHANGED
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "name": "cordova-react-vite",
3
- "version": "3.0.0",
4
- "description": "Create React + Vite + Cordova project with Android build",
3
+ "version": "3.0.1",
4
+ "description": "CLI to create a full React + Vite + Cordova project with Android platform",
5
+ "main": "execute.js",
5
6
  "bin": {
6
7
  "cordova-react-vite": "execute.js"
7
8
  },
8
- "scripts": {
9
- "start": "node execute.js"
10
- },
11
- "author": "Your Name",
9
+ "keywords": ["cordova", "react", "vite", "android", "cli"],
10
+ "author": "mohammad shadrif feiz",
12
11
  "license": "ISC",
13
- "dependencies": {
14
- "inquirer": "^9.2.0",
15
- "rimraf": "^5.0.0"
16
- }
12
+ "dependencies": {},
13
+ "devDependencies": {}
17
14
  }