@forthtilliath/expo-release-updates 0.3.0 → 0.4.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.
- package/LICENSE +21 -21
- package/README.md +145 -132
- package/dist/compareVersions.d.ts +1 -6
- package/dist/compareVersions.d.ts.map +1 -1
- package/dist/compareVersions.js +5 -17
- package/dist/downloadAndInstallApk.d.ts +12 -1
- package/dist/downloadAndInstallApk.d.ts.map +1 -1
- package/dist/downloadAndInstallApk.js +11 -1
- package/dist/githubReleases.d.ts +6 -0
- package/dist/githubReleases.d.ts.map +1 -1
- package/dist/githubReleases.js +8 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/isUpdateAvailable.d.ts +13 -0
- package/dist/isUpdateAvailable.d.ts.map +1 -0
- package/dist/isUpdateAvailable.js +15 -0
- package/dist/parseChangelogNotes.d.ts +2 -15
- package/dist/parseChangelogNotes.d.ts.map +1 -1
- package/dist/parseChangelogNotes.js +1 -43
- package/package.json +8 -5
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Forthtilliath
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Forthtilliath
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,132 +1,145 @@
|
|
|
1
|
-
# @forthtilliath/expo-release-updates
|
|
2
|
-
|
|
3
|
-
Self-update a sideloaded Android Expo app from its GitHub Releases: check the latest release, show a release history, download and trigger the install of a new APK. No backend needed — just a GitHub repo that publishes an `.apk` asset on each release.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @forthtilliath/expo-release-updates expo-file-system expo-intent-launcher
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Or, from within this monorepo, as a workspace dependency:
|
|
12
|
-
|
|
13
|
-
```json
|
|
14
|
-
{
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@forthtilliath/expo-release-updates": "workspace:*"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
`expo-file-system` and `expo-intent-launcher` are peer dependencies — install them in the consuming app if not already present.
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
Each function is its own module — import the file you need directly, or use
|
|
26
|
-
the barrel to pull everything from a single import:
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
import { compareVersions } from "@forthtilliath/expo-release-updates/compareVersions";
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
import {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
compareVersions("1.2.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### `
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
1
|
+
# @forthtilliath/expo-release-updates
|
|
2
|
+
|
|
3
|
+
Self-update a sideloaded Android Expo app from its GitHub Releases: check the latest release, show a release history, download and trigger the install of a new APK. No backend needed — just a GitHub repo that publishes an `.apk` asset on each release.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @forthtilliath/expo-release-updates expo-file-system expo-intent-launcher
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or, from within this monorepo, as a workspace dependency:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@forthtilliath/expo-release-updates": "workspace:*"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`expo-file-system` and `expo-intent-launcher` are peer dependencies — install them in the consuming app if not already present.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Each function is its own module — import the file you need directly, or use
|
|
26
|
+
the barrel to pull everything from a single import:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { compareVersions } from "@forthtilliath/expo-release-updates/compareVersions";
|
|
30
|
+
import { isUpdateAvailable } from "@forthtilliath/expo-release-updates/isUpdateAvailable";
|
|
31
|
+
import {
|
|
32
|
+
fetchLatestRelease,
|
|
33
|
+
fetchReleaseHistory,
|
|
34
|
+
} from "@forthtilliath/expo-release-updates/githubReleases";
|
|
35
|
+
import { downloadAndInstallApk } from "@forthtilliath/expo-release-updates/downloadAndInstallApk";
|
|
36
|
+
import { parseChangelogNotes } from "@forthtilliath/expo-release-updates/parseChangelogNotes";
|
|
37
|
+
|
|
38
|
+
// Or, everything at once:
|
|
39
|
+
import {
|
|
40
|
+
compareVersions,
|
|
41
|
+
isUpdateAvailable,
|
|
42
|
+
fetchLatestRelease,
|
|
43
|
+
fetchReleaseHistory,
|
|
44
|
+
downloadAndInstallApk,
|
|
45
|
+
parseChangelogNotes,
|
|
46
|
+
} from "@forthtilliath/expo-release-updates";
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Avoid the barrel under Jest (or any other CommonJS `require` consumer).**
|
|
50
|
+
`export * from` re-exports are evaluated eagerly on `require()` — unlike
|
|
51
|
+
Metro's ESM bundling, there's no tree-shaking to skip the unused ones.
|
|
52
|
+
Requiring the barrel from _any_ file, even one that only wants
|
|
53
|
+
`compareVersions`, pulls in `downloadAndInstallApk`'s module graph too,
|
|
54
|
+
including native-module imports (`expo-file-system`, `expo-intent-launcher`)
|
|
55
|
+
that don't exist in a Jest environment — this throws at require time, not
|
|
56
|
+
just at runtime for unused code. Deep imports only ever load the one module
|
|
57
|
+
you asked for, so they don't have this problem in any environment.
|
|
58
|
+
|
|
59
|
+
### `compareVersions(a, b)`
|
|
60
|
+
|
|
61
|
+
Compares two `"x.y.z"` version strings, segment by segment. Returns `-1` if `a < b`, `0` if equal, `1` if `a > b`.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
compareVersions("1.2.0", "1.10.0"); // -1 (numeric, not lexicographic)
|
|
65
|
+
compareVersions("2.0.0", "1.9.9"); // 1
|
|
66
|
+
compareVersions("1.2.3", "1.2.3"); // 0
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### `isUpdateAvailable(currentVersion, latestVersion)`
|
|
70
|
+
|
|
71
|
+
Named wrapper around `compareVersions` for the common "should I show the update prompt?" check — reads as intent instead of a bare `compareVersions(a, b) > 0` repeated at every call site.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
if (release && isUpdateAvailable(currentVersion, release.version)) {
|
|
75
|
+
// an update is available
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### `fetchLatestRelease({ owner, repo, token? })`
|
|
80
|
+
|
|
81
|
+
Fetches the latest GitHub release and its `.apk` asset. Returns `null` if the latest release has no `.apk` attached; throws if the GitHub API request fails. Pass `token` (a GitHub personal access token or `GITHUB_TOKEN`) for private repos, or to raise the API rate limit from 60 to 5000 requests/hour on public ones.
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const release = await fetchLatestRelease({ owner: "acme", repo: "app" });
|
|
85
|
+
if (release && isUpdateAvailable(currentVersion, release.version)) {
|
|
86
|
+
// an update is available: release.version, release.notes, release.apkUrl
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `fetchReleaseHistory({ owner, repo, limit?, token? })`
|
|
91
|
+
|
|
92
|
+
Fetches the most recent releases (version, notes, publish date), most recent first. `limit` defaults to `10` — useful for a "release history" / "what's new" screen.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const history = await fetchReleaseHistory({
|
|
96
|
+
owner: "acme",
|
|
97
|
+
repo: "app",
|
|
98
|
+
limit: 5,
|
|
99
|
+
});
|
|
100
|
+
// [{ version: "1.11.0", notes: "### Added\n- ...", publishedAt: "2026-07-30T..." }, ...]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `downloadAndInstallApk({ apkUrl, fileName, onProgress?, expectedMd5? })`
|
|
104
|
+
|
|
105
|
+
Downloads an APK to the app's cache directory and triggers the Android install-package intent. **Android only** — there is no iOS equivalent (sideloading isn't possible there). Pass `expectedMd5` to verify the downloaded file's integrity before installing — a mismatch deletes the file and throws instead. GitHub Releases has no built-in signature check the way an app store does, so this is the standard safeguard against a corrupted or tampered download; publish the checksum alongside the release (e.g. in the release notes or a `.md5` asset).
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
await downloadAndInstallApk({
|
|
109
|
+
apkUrl: release.apkUrl,
|
|
110
|
+
fileName: "myapp-update.apk",
|
|
111
|
+
onProgress: (fraction) => setProgress(fraction),
|
|
112
|
+
expectedMd5: release.apkMd5,
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### `parseChangelogNotes(notes)`
|
|
117
|
+
|
|
118
|
+
Parses a small subset of Markdown (`### heading`, `- item`, `**bold**`) commonly found in GitHub release notes into a list of typed blocks (`heading` / `item` / `text`, each with `bold`-aware segments), ready for a UI layer to render without a full Markdown dependency. Pair it with `@forthtilliath/react-native-kit`'s `ChangelogNotes` component to render the result directly.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
parseChangelogNotes("### Added\n- **Auto-backup**: saves every 5 minutes.");
|
|
122
|
+
// [
|
|
123
|
+
// { type: "heading", text: "Added" },
|
|
124
|
+
// {
|
|
125
|
+
// type: "item",
|
|
126
|
+
// segments: [
|
|
127
|
+
// { text: "Auto-backup", bold: true },
|
|
128
|
+
// { text: ": saves every 5 minutes.", bold: false },
|
|
129
|
+
// ],
|
|
130
|
+
// },
|
|
131
|
+
// ]
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Scripts
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pnpm run dev # tsc --watch -> dist/
|
|
138
|
+
pnpm run build # tsc -> dist/
|
|
139
|
+
pnpm run check-types # tsc --noEmit
|
|
140
|
+
pnpm run lint # eslint
|
|
141
|
+
pnpm run test # vitest run
|
|
142
|
+
pnpm run test:watch # vitest
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Built to `dist/` (see the `exports` field in `package.json`), so run `pnpm run build` (or `dev`) after source changes for consumers to see them.
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Compares two "x.y.z" version strings, segment by segment.
|
|
3
|
-
*
|
|
4
|
-
* @returns -1 if `a` < `b`, 0 if they're equal, 1 if `a` > `b`.
|
|
5
|
-
*/
|
|
6
|
-
export declare function compareVersions(a: string, b: string): number;
|
|
1
|
+
export { compareVersions } from "@forthtilliath/ts-kit/version/compareVersions";
|
|
7
2
|
//# sourceMappingURL=compareVersions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareVersions.d.ts","sourceRoot":"","sources":["../src/compareVersions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compareVersions.d.ts","sourceRoot":"","sources":["../src/compareVersions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC"}
|
package/dist/compareVersions.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function compareVersions(a, b) {
|
|
7
|
-
const partsA = a.split(".").map(Number);
|
|
8
|
-
const partsB = b.split(".").map(Number);
|
|
9
|
-
const length = Math.max(partsA.length, partsB.length);
|
|
10
|
-
for (let i = 0; i < length; i++) {
|
|
11
|
-
const numA = partsA[i] ?? 0;
|
|
12
|
-
const numB = partsB[i] ?? 0;
|
|
13
|
-
if (numA !== numB)
|
|
14
|
-
return numA > numB ? 1 : -1;
|
|
15
|
-
}
|
|
16
|
-
return 0;
|
|
17
|
-
}
|
|
1
|
+
// Framework-agnostic — actually implemented (and tested/documented) in
|
|
2
|
+
// ts-kit, re-exported here so this package's deep-import path
|
|
3
|
+
// (`@forthtilliath/expo-release-updates/compareVersions`) and root barrel
|
|
4
|
+
// export keep working.
|
|
5
|
+
export { compareVersions } from "@forthtilliath/ts-kit/version/compareVersions";
|
|
@@ -3,11 +3,22 @@ export interface DownloadAndInstallApkOptions {
|
|
|
3
3
|
/** Temp filename in the cache directory, e.g. "myapp-update.apk". */
|
|
4
4
|
fileName: string;
|
|
5
5
|
onProgress?: (fraction: number) => void;
|
|
6
|
+
/**
|
|
7
|
+
* MD5 checksum the downloaded file is expected to match (case-insensitive),
|
|
8
|
+
* e.g. one published alongside the release. When set, a mismatch deletes
|
|
9
|
+
* the file and rejects instead of installing it — standard integrity check
|
|
10
|
+
* before running a sideloaded binary, since GitHub Releases has no
|
|
11
|
+
* built-in signature verification the way an app store does.
|
|
12
|
+
*/
|
|
13
|
+
expectedMd5?: string;
|
|
6
14
|
}
|
|
7
15
|
/**
|
|
8
16
|
* Downloads an APK to the cache directory and triggers the Android
|
|
9
17
|
* install-package intent. Android only — there is no equivalent flow on iOS,
|
|
10
18
|
* which doesn't allow installing a downloaded package outside the App Store.
|
|
19
|
+
*
|
|
20
|
+
* @throws if the download fails, or if `expectedMd5` is set and doesn't
|
|
21
|
+
* match the downloaded file.
|
|
11
22
|
*/
|
|
12
|
-
export declare function downloadAndInstallApk({ apkUrl, fileName, onProgress, }: DownloadAndInstallApkOptions): Promise<void>;
|
|
23
|
+
export declare function downloadAndInstallApk({ apkUrl, fileName, onProgress, expectedMd5, }: DownloadAndInstallApkOptions): Promise<void>;
|
|
13
24
|
//# sourceMappingURL=downloadAndInstallApk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloadAndInstallApk.d.ts","sourceRoot":"","sources":["../src/downloadAndInstallApk.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"downloadAndInstallApk.d.ts","sourceRoot":"","sources":["../src/downloadAndInstallApk.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,MAAM,EACN,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B9C"}
|
|
@@ -4,8 +4,11 @@ import * as IntentLauncher from "expo-intent-launcher";
|
|
|
4
4
|
* Downloads an APK to the cache directory and triggers the Android
|
|
5
5
|
* install-package intent. Android only — there is no equivalent flow on iOS,
|
|
6
6
|
* which doesn't allow installing a downloaded package outside the App Store.
|
|
7
|
+
*
|
|
8
|
+
* @throws if the download fails, or if `expectedMd5` is set and doesn't
|
|
9
|
+
* match the downloaded file.
|
|
7
10
|
*/
|
|
8
|
-
export async function downloadAndInstallApk({ apkUrl, fileName, onProgress, }) {
|
|
11
|
+
export async function downloadAndInstallApk({ apkUrl, fileName, onProgress, expectedMd5, }) {
|
|
9
12
|
const destination = new File(Paths.cache, fileName);
|
|
10
13
|
if (destination.exists)
|
|
11
14
|
destination.delete();
|
|
@@ -18,6 +21,13 @@ export async function downloadAndInstallApk({ apkUrl, fileName, onProgress, }) {
|
|
|
18
21
|
const file = await task.downloadAsync();
|
|
19
22
|
if (!file)
|
|
20
23
|
throw new Error("The download failed.");
|
|
24
|
+
if (expectedMd5) {
|
|
25
|
+
const actualMd5 = file.info({ md5: true }).md5;
|
|
26
|
+
if (actualMd5?.toLowerCase() !== expectedMd5.toLowerCase()) {
|
|
27
|
+
file.delete();
|
|
28
|
+
throw new Error(`APK checksum mismatch: expected ${expectedMd5}, got ${actualMd5 ?? "none"}.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
21
31
|
await IntentLauncher.startActivityAsync("android.intent.action.VIEW", {
|
|
22
32
|
data: file.contentUri,
|
|
23
33
|
flags: 1,
|
package/dist/githubReleases.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export interface GithubRepoRef {
|
|
2
2
|
owner: string;
|
|
3
3
|
repo: string;
|
|
4
|
+
/**
|
|
5
|
+
* A GitHub personal access token (or `GITHUB_TOKEN` in CI), sent as a
|
|
6
|
+
* `Bearer` token. Required for private repos; also raises the API rate
|
|
7
|
+
* limit from 60 to 5000 requests/hour for public ones.
|
|
8
|
+
*/
|
|
9
|
+
token?: string;
|
|
4
10
|
}
|
|
5
11
|
export interface LatestRelease {
|
|
6
12
|
version: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubReleases.d.ts","sourceRoot":"","sources":["../src/githubReleases.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"githubReleases.d.ts","sourceRoot":"","sources":["../src/githubReleases.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAyBD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAkB/B;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,aAAa,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACtC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAehC"}
|
package/dist/githubReleases.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
function releasesUrl({ owner, repo }) {
|
|
2
2
|
return `https://api.github.com/repos/${owner}/${repo}/releases`;
|
|
3
3
|
}
|
|
4
|
+
function githubHeaders({ token }) {
|
|
5
|
+
return {
|
|
6
|
+
Accept: "application/vnd.github+json",
|
|
7
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
11
|
* Fetches the latest GitHub release for a repo, along with its `.apk` asset.
|
|
6
12
|
*
|
|
@@ -9,7 +15,7 @@ function releasesUrl({ owner, repo }) {
|
|
|
9
15
|
*/
|
|
10
16
|
export async function fetchLatestRelease(ref) {
|
|
11
17
|
const response = await fetch(`${releasesUrl(ref)}/latest`, {
|
|
12
|
-
headers:
|
|
18
|
+
headers: githubHeaders(ref),
|
|
13
19
|
});
|
|
14
20
|
if (!response.ok)
|
|
15
21
|
throw new Error(`GitHub responded with ${String(response.status)}`);
|
|
@@ -29,9 +35,7 @@ export async function fetchLatestRelease(ref) {
|
|
|
29
35
|
*/
|
|
30
36
|
export async function fetchReleaseHistory(ref) {
|
|
31
37
|
const { limit = 10 } = ref;
|
|
32
|
-
const response = await fetch(`${releasesUrl(ref)}?per_page=${String(limit)}`, {
|
|
33
|
-
headers: { Accept: "application/vnd.github+json" },
|
|
34
|
-
});
|
|
38
|
+
const response = await fetch(`${releasesUrl(ref)}?per_page=${String(limit)}`, { headers: githubHeaders(ref) });
|
|
35
39
|
if (!response.ok)
|
|
36
40
|
throw new Error(`GitHub responded with ${String(response.status)}`);
|
|
37
41
|
const data = (await response.json());
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `latestVersion` is strictly newer than `currentVersion`.
|
|
3
|
+
*
|
|
4
|
+
* Thin, named wrapper around `compareVersions` for the common "should I show
|
|
5
|
+
* the update prompt?" check, so call sites read as intent rather than a bare
|
|
6
|
+
* `compareVersions(a, b) > 0` comparison repeated at every call site.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* isUpdateAvailable("1.2.0", "1.10.0"); // true
|
|
10
|
+
* isUpdateAvailable("1.2.0", "1.2.0"); // false
|
|
11
|
+
*/
|
|
12
|
+
export declare function isUpdateAvailable(currentVersion: string, latestVersion: string): boolean;
|
|
13
|
+
//# sourceMappingURL=isUpdateAvailable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isUpdateAvailable.d.ts","sourceRoot":"","sources":["../src/isUpdateAvailable.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,GACpB,OAAO,CAET"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { compareVersions } from "./compareVersions.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether `latestVersion` is strictly newer than `currentVersion`.
|
|
4
|
+
*
|
|
5
|
+
* Thin, named wrapper around `compareVersions` for the common "should I show
|
|
6
|
+
* the update prompt?" check, so call sites read as intent rather than a bare
|
|
7
|
+
* `compareVersions(a, b) > 0` comparison repeated at every call site.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* isUpdateAvailable("1.2.0", "1.10.0"); // true
|
|
11
|
+
* isUpdateAvailable("1.2.0", "1.2.0"); // false
|
|
12
|
+
*/
|
|
13
|
+
export function isUpdateAvailable(currentVersion, latestVersion) {
|
|
14
|
+
return compareVersions(latestVersion, currentVersion) > 0;
|
|
15
|
+
}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
bold: boolean;
|
|
4
|
-
}
|
|
5
|
-
export type ChangelogBlock = {
|
|
6
|
-
type: "heading";
|
|
7
|
-
text: string;
|
|
8
|
-
} | {
|
|
9
|
-
type: "item";
|
|
10
|
-
segments: ChangelogSegment[];
|
|
11
|
-
} | {
|
|
12
|
-
type: "text";
|
|
13
|
-
segments: ChangelogSegment[];
|
|
14
|
-
};
|
|
15
|
-
export declare function parseChangelogNotes(notes: string): ChangelogBlock[];
|
|
1
|
+
export type { ChangelogBlock, ChangelogSegment, } from "@forthtilliath/ts-kit/markdown/parseChangelogNotes";
|
|
2
|
+
export { parseChangelogNotes } from "@forthtilliath/ts-kit/markdown/parseChangelogNotes";
|
|
16
3
|
//# sourceMappingURL=parseChangelogNotes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseChangelogNotes.d.ts","sourceRoot":"","sources":["../src/parseChangelogNotes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseChangelogNotes.d.ts","sourceRoot":"","sources":["../src/parseChangelogNotes.ts"],"names":[],"mappings":"AAIA,YAAY,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,oDAAoD,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC"}
|
|
@@ -1,43 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// ("### Heading", "- item", "**bold**"). Rendered as-is in a plain <Text>,
|
|
3
|
-
// the raw syntax shows up unstyled — this parser turns it into a small set
|
|
4
|
-
// of typed blocks a UI layer can render (heading / bullet item / plain
|
|
5
|
-
// text), without pulling in a full Markdown dependency for this narrow use
|
|
6
|
-
// case.
|
|
7
|
-
function parseInlineSegments(text) {
|
|
8
|
-
const segments = [];
|
|
9
|
-
const boldPattern = /\*\*(.+?)\*\*/g;
|
|
10
|
-
let lastIndex = 0;
|
|
11
|
-
let match;
|
|
12
|
-
while ((match = boldPattern.exec(text)) !== null) {
|
|
13
|
-
if (match.index > lastIndex) {
|
|
14
|
-
segments.push({ text: text.slice(lastIndex, match.index), bold: false });
|
|
15
|
-
}
|
|
16
|
-
// The capture group is mandatory in the pattern, so it always matches —
|
|
17
|
-
// the `?? ""` fallback is only here to satisfy `noUncheckedIndexedAccess`.
|
|
18
|
-
segments.push({ text: match[1] ?? "", bold: true });
|
|
19
|
-
lastIndex = boldPattern.lastIndex;
|
|
20
|
-
}
|
|
21
|
-
if (lastIndex < text.length) {
|
|
22
|
-
segments.push({ text: text.slice(lastIndex), bold: false });
|
|
23
|
-
}
|
|
24
|
-
return segments;
|
|
25
|
-
}
|
|
26
|
-
export function parseChangelogNotes(notes) {
|
|
27
|
-
return notes
|
|
28
|
-
.split("\n")
|
|
29
|
-
.map((line) => line.trim())
|
|
30
|
-
.filter((line) => line.length > 0)
|
|
31
|
-
.map((line) => {
|
|
32
|
-
if (line.startsWith("### ")) {
|
|
33
|
-
return { type: "heading", text: line.slice(4).trim() };
|
|
34
|
-
}
|
|
35
|
-
if (line.startsWith("- ")) {
|
|
36
|
-
return {
|
|
37
|
-
type: "item",
|
|
38
|
-
segments: parseInlineSegments(line.slice(2).trim()),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return { type: "text", segments: parseInlineSegments(line) };
|
|
42
|
-
});
|
|
43
|
-
}
|
|
1
|
+
export { parseChangelogNotes } from "@forthtilliath/ts-kit/markdown/parseChangelogNotes";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forthtilliath/expo-release-updates",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -24,13 +24,16 @@
|
|
|
24
24
|
"expo-file-system": ">=54.0.0",
|
|
25
25
|
"expo-intent-launcher": ">=12.0.0"
|
|
26
26
|
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@forthtilliath/ts-kit": "0.5.0"
|
|
29
|
+
},
|
|
27
30
|
"devDependencies": {
|
|
28
|
-
"eslint": "
|
|
29
|
-
"expo-file-system": "~57.0.
|
|
31
|
+
"eslint": "10.7.0",
|
|
32
|
+
"expo-file-system": "~57.0.2",
|
|
30
33
|
"expo-intent-launcher": "~57.0.1",
|
|
31
|
-
"typescript": "
|
|
34
|
+
"typescript": "^5.9.3",
|
|
32
35
|
"vitest": "^4.1.10",
|
|
33
|
-
"@forthtilliath/eslint-config": "0.
|
|
36
|
+
"@forthtilliath/eslint-config": "0.4.2",
|
|
34
37
|
"@forthtilliath/typescript-config": "0.0.0"
|
|
35
38
|
},
|
|
36
39
|
"scripts": {
|