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.
Files changed (4) hide show
  1. package/README.md +143 -56
  2. package/lib/ota-deploy.js +315 -284
  3. package/lib/ota-main.js +216 -214
  4. package/package.json +43 -43
package/README.md CHANGED
@@ -1,56 +1,143 @@
1
- # ota-manager
2
-
3
- Enterprise-grade Over-The-Air (OTA) update manager for Astro and static web projects.
4
-
5
- ## Features
6
-
7
- - 🚀 **Multi-Provider Support**: Switch between GitHub and GitLab seamlessly.
8
- - 🏗️ **Multi-Channel Deployment**: Manage 'training' and 'live' environments independently.
9
- - 🔒 **Secure PAT Management**: Separate Read-only tokens (for APK) and Developer tokens (for deployment).
10
- - 🛡️ **Pre-deployment Health Check**: Automatic version gap checking and token verification.
11
- - 📦 **Smart ZIP Archiving**: POSIX-compliant compression for Android compatibility.
12
-
13
- ## Installation
14
-
15
- ```bash
16
- npm install ota-manager --save-dev
17
- ```
18
-
19
- ## Quick Start
20
-
21
- ### 1. Initialize Configuration
22
- ```bash
23
- npx ota-updates register gitlab
24
- ```
25
- Follow the interactive prompts to set up your repository URL and Access Tokens.
26
-
27
- ### 2. Check Status
28
- ```bash
29
- npx ota-updates status
30
- ```
31
-
32
- ### 3. Deploy Update
33
- ```bash
34
- npx ota-updates training
35
- ```
36
-
37
- ## Configuration
38
-
39
- The manager stores metadata in `ota-config.json` and sensitive tokens in your `.env` file.
40
-
41
- ```json
42
- // ota-config.json
43
- {
44
- "strategy": "gitlab",
45
- "configs": {
46
- "gitlab": {
47
- "repo": "https://gitlab.com/your-user/your-ota-repo",
48
- "branch": "main"
49
- }
50
- }
51
- }
52
- ```
53
-
54
- ## License
55
-
56
- MIT © First Ryan
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)