ota-manager 1.0.4 → 1.0.7
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.
- package/README.md +143 -56
- package/lib/ota-deploy.js +315 -284
- package/lib/ota-main.js +216 -214
- package/package.json +43 -43
package/README.md
CHANGED
|
@@ -1,56 +1,143 @@
|
|
|
1
|
-
# ota-manager
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
##
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
# 📦 ota-manager
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<h3>Enterprise-Grade Over-The-Air (OTA) Update Manager for Astro, Capacitor, and Static Web Apps</h3>
|
|
5
|
+
<p>Seamlessly deploy live updates to mobile WebViews and web apps without going through App Store or Play Store reviews.</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## ✨ Why `ota-manager`?
|
|
11
|
+
|
|
12
|
+
Modern mobile hybrid apps (built with Astro, Vite, or Capacitor) require a robust, foolproof update pipeline. `ota-manager` provides an end-to-end automated deployment system with built-in safeguards against common deployment pitfalls like broken asset paths, zip bombs, and token leaks.
|
|
13
|
+
|
|
14
|
+
### 🌟 Key Features
|
|
15
|
+
|
|
16
|
+
* 🚀 **Universal & Project-Agnostic**: Dynamically detects `process.cwd()` to integrate flawlessly into any Astro, Vite, Next.js, or static web project.
|
|
17
|
+
* 🔄 **Flexible CLI Shorthands**: Supports both `npx ota-manager` and `npx ota-updates`. Features lightning-fast shorthands like `npx ota-manager -d training` and `-d live`.
|
|
18
|
+
* 🔀 **Multi-Provider & Multi-Channel Routing**: Built-in support for GitHub and GitLab strategies. Configure independent target repositories and branches for `training` vs `live` environments.
|
|
19
|
+
* 🛡️ **Size Guardian Protocol**: Pre-flight audit of your `dist/` directory and generated ZIP archive to prevent Zip Bombs (>50MB threshold protection).
|
|
20
|
+
* 💥 **Tsar Bomba Path Cleanse (`flatten-dist.cjs`)**: Post-build normalization of absolute asset paths (`/assets/`) to relative paths (`./assets/`) to guarantee flawless Capacitor WebView navigation.
|
|
21
|
+
* 🙈 **API Route Protection**: Automatically isolates and hides `/src/pages/api` during static export/build to prevent build failures, then restores them seamlessly.
|
|
22
|
+
* 🔐 **Security Auditor (`ota-security.js`)**: Automated inspection of Personal Access Tokens (PAT) to prevent token leaks or overly broad repository access.
|
|
23
|
+
* 📡 **E2E Connection Simulation**: Built-in `test` command to simulate push and read capabilities against your Git provider before executing actual deployments.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 📦 Installation
|
|
28
|
+
|
|
29
|
+
Install `ota-manager` as a development dependency in your project:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install ota-manager --save-dev
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 Quick Start Guide
|
|
38
|
+
|
|
39
|
+
### 1. Initialize Infrastructure
|
|
40
|
+
Register your Git provider (GitHub or GitLab) to initialize `ota-config.json` and `.env` credentials:
|
|
41
|
+
```bash
|
|
42
|
+
npx ota-manager register github
|
|
43
|
+
# or: npx ota-manager register gitlab
|
|
44
|
+
```
|
|
45
|
+
*Follow the interactive prompts to enter your repository URL and Access Tokens.*
|
|
46
|
+
|
|
47
|
+
### 2. Verify Connection & Security
|
|
48
|
+
Run an end-to-end simulation to ensure your tokens and repository permissions are perfectly configured:
|
|
49
|
+
```bash
|
|
50
|
+
npx ota-manager test
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Check Version Gap
|
|
54
|
+
Compare your local `.env` app version against the remote release manifest:
|
|
55
|
+
```bash
|
|
56
|
+
npx ota-manager status
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 4. Deploy Update
|
|
60
|
+
Deploy your build to the `training` or `live` channel with automated pre-flight checks, path cleansing, and size auditing:
|
|
61
|
+
```bash
|
|
62
|
+
# Deploy to Training Channel
|
|
63
|
+
npx ota-manager deploy training
|
|
64
|
+
# Shorthand alias:
|
|
65
|
+
npx ota-manager -d training
|
|
66
|
+
|
|
67
|
+
# Deploy to Live (Production) Channel
|
|
68
|
+
npx ota-manager deploy live
|
|
69
|
+
# Shorthand alias:
|
|
70
|
+
npx ota-manager -d live
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## ⚙️ Advanced Configuration
|
|
76
|
+
|
|
77
|
+
`ota-manager` stores its active strategy in `ota-config.json` and sensitive tokens in your `.env` file.
|
|
78
|
+
|
|
79
|
+
### Flexible Channel Routing (`ota-config.json`)
|
|
80
|
+
You can configure different branches or even different repositories for your `training` and `live` channels:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"strategy": "github",
|
|
85
|
+
"github": {
|
|
86
|
+
"repo": "https://github.com/your-org/your-ota-repo",
|
|
87
|
+
"branch": "main",
|
|
88
|
+
"channels": {
|
|
89
|
+
"training": {
|
|
90
|
+
"branch": "main"
|
|
91
|
+
},
|
|
92
|
+
"live": {
|
|
93
|
+
"branch": "ota-live"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Environment Variables (`.env`)
|
|
101
|
+
The manager automatically updates your versioning and OTA target URLs during deployment:
|
|
102
|
+
```env
|
|
103
|
+
GITHUB_DEV_PAT="ghp_your_developer_token_here"
|
|
104
|
+
PUBLIC_APP_VERSION_ANDROID=1.0.4
|
|
105
|
+
PUBLIC_APP_VERSION_IOS=1.0.4
|
|
106
|
+
PUBLIC_OTA_UPDATE_URL=https://raw.githubusercontent.com/your-org/your-ota-repo/main/manifest.json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 🛡️ Built-in Safeguards Architecture
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
┌──────────────────────────────────────────────────────────┐
|
|
115
|
+
│ npx ota-manager -d live │
|
|
116
|
+
└─────────────────────────────┬────────────────────────────┘
|
|
117
|
+
▼
|
|
118
|
+
┌──────────────────────────────────────────────────────────┐
|
|
119
|
+
│ 1. Pre-Flight Check: ota-version & verify-dist │
|
|
120
|
+
└─────────────────────────────┬────────────────────────────┘
|
|
121
|
+
▼
|
|
122
|
+
┌──────────────────────────────────────────────────────────┐
|
|
123
|
+
│ 2. API Route Protection: Hides /src/pages/api │
|
|
124
|
+
└─────────────────────────────┬────────────────────────────┘
|
|
125
|
+
▼
|
|
126
|
+
┌──────────────────────────────────────────────────────────┐
|
|
127
|
+
│ 3. Build & Tsar Bomba Cleanse: Normalizes /assets/ paths │
|
|
128
|
+
└─────────────────────────────┬────────────────────────────┘
|
|
129
|
+
▼
|
|
130
|
+
┌──────────────────────────────────────────────────────────┐
|
|
131
|
+
│ 4. Size Guardian Audit: Validates dist/ & ZIP < 50MB │
|
|
132
|
+
└─────────────────────────────┬────────────────────────────┘
|
|
133
|
+
▼
|
|
134
|
+
┌──────────────────────────────────────────────────────────┐
|
|
135
|
+
│ 5. Remote Push & Manifest Update (GitHub / GitLab) │
|
|
136
|
+
└──────────────────────────────────────────────────────────┘
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 📄 License
|
|
142
|
+
|
|
143
|
+
MIT © [First Ryan](https://github.com/firstryan)
|