cordova-react-vite 3.0.1 → 3.0.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.
Files changed (2) hide show
  1. package/execute.js +40 -19
  2. package/package.json +1 -1
package/execute.js CHANGED
@@ -24,7 +24,7 @@ function reverseDomain(domain, appName) {
24
24
  function main() {
25
25
  const args = process.argv.slice(2);
26
26
  if (args.length < 2) {
27
- console.error("❌ دستور اشتباه!\nمثال: cordova-react-vite Boxit Tracker boxitsoft.ir");
27
+ console.error("❌ wrong statement example: cordova-react-vite Boxit Tracker boxitsoft.ir");
28
28
  process.exit(1);
29
29
  }
30
30
 
@@ -38,37 +38,63 @@ function main() {
38
38
  const rootPath = path.join(process.cwd(), npmName);
39
39
  if (!fs.existsSync(rootPath)) fs.mkdirSync(rootPath);
40
40
 
41
- console.log(`🚀 ایجاد پروژه ${displayName}`);
41
+ console.log(`🚀 create project ${displayName}`);
42
42
  console.log(`📦 npm name: ${npmName}`);
43
43
  console.log(`📱 cordova id: ${cordovaId}`);
44
44
  console.log(`📱 cordova name: ${cordovaName}`);
45
45
 
46
46
  // ---- React Vite ----
47
- console.log("📦 ایجاد پروژه React (Vite)...");
47
+ console.log("📦 create project React (Vite)...");
48
48
  run(`npm create vite@latest react -- --template react`, rootPath);
49
49
  run(`npm install`, path.join(rootPath, "react"));
50
-
51
- // اضافه کردن <script src="cordova.js"> به index.html
50
+ // install aio-cordova
51
+ console.log("📦 install aio-cordova in React...");
52
+ run(`npm install aio-cordova`, path.join(rootPath, "react"));
53
+ // add <script src="cordova.js"> to index.html
52
54
  const indexHtmlPath = path.join(rootPath, "react", "index.html");
53
55
  if (fs.existsSync(indexHtmlPath)) {
54
56
  let html = fs.readFileSync(indexHtmlPath, "utf8");
55
57
  if (!html.includes('cordova.js')) {
56
58
  html = html.replace("</body>", " <script src=\"cordova.js\"></script>\n</body>");
57
59
  fs.writeFileSync(indexHtmlPath, html, "utf8");
58
- console.log("✔ <script src=\"cordova.js\"> به index.html اضافه شد");
60
+ console.log("✔ <script src=\"cordova.js\"> added to index.html");
59
61
  }
60
62
  }
63
+ // ---- overwrite App.tsx ----
64
+ const appTsxPath = path.join(rootPath, "react", "src", "App.tsx");
65
+ const appTsxContent = `import { FC } from "react";
66
+ import { AIOCordovaComponent, AIOCordova } from "aio-cordova";
67
+
68
+ const App: FC = () => {
69
+ return (
70
+ <AIOCordovaComponent
71
+ startWindows={() => <WindowsApp />}
72
+ startAndroid={(aioCordova) => <AndroidApp aioCordova={aioCordova} />}
73
+ />
74
+ )
75
+ }
76
+ export default App;
61
77
 
78
+ const WindowsApp: FC = () => {
79
+ return null;
80
+ }
81
+ const AndroidApp: FC = (inst: AIOCordova) => {
82
+ return null;
83
+ }
84
+ `;
85
+
86
+ fs.writeFileSync(appTsxPath, appTsxContent, "utf8");
87
+ console.log("✔ src/App.tsx changed");
62
88
  // ---- Cordova ----
63
- console.log("📱 ایجاد پروژه Cordova...");
89
+ console.log("creating cordova project");
64
90
  run(`npx cordova create cordova ${cordovaId} "${cordovaName}"`, rootPath);
65
91
 
66
92
  // ---- Android platform ----
67
- console.log("📱 اضافه کردن Android platform...");
93
+ console.log("add android platform");
68
94
  run(`npx cordova platform add android`, path.join(rootPath, "cordova"));
69
95
 
70
- // ---- package.json روت ----
71
- console.log("🛠 ایجاد package.json روت...");
96
+ // ---- package.json root ----
97
+ console.log("create root package.json");
72
98
  const rootPkg = {
73
99
  name: npmName,
74
100
  version: "1.0.0",
@@ -90,14 +116,9 @@ function main() {
90
116
  path.join(rootPath, "package.json"),
91
117
  JSON.stringify(rootPkg, null, 2)
92
118
  );
93
-
94
- console.log(" پروژه آماده شد!");
95
- console.log(`📂 ساختار پروژه:
96
- ${npmName}/
97
- ├─ react/ ← پروژه React Vite
98
- ├─ cordova/ ← پروژه Cordova (${cordovaId}, Android platform اضافه شد)
99
- └─ package.json ← مدیریت مشترک build
100
- `);
119
+ // ---- install root package.json dependencies ----
120
+ console.log("📦 install root package.json dependencies...");
121
+ run(`npm install`, rootPath);
122
+ console.log("✅ project is ready!");
101
123
  }
102
-
103
124
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-react-vite",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "CLI to create a full React + Vite + Cordova project with Android platform",
5
5
  "main": "execute.js",
6
6
  "bin": {