File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 "scripts" : {
1010 "dev" : " vite" ,
1111 "build" : " vite build" ,
12+ "check" : " node scripts/check-app-update-json.mjs && npm run build" ,
1213 "preview" : " vite preview"
1314 },
1415 "dependencies" : {
Original file line number Diff line number Diff line change 1+ {
2+ "appId": "com.strawcoding.strawmoneybook",
3+ "latestVersion": "1.3.59",
4+ "version": "1.3.59",
5+ "playUrl": "https://play.google.com/store/apps/details?id=com.strawcoding.strawmoneybook",
6+ "source": "official_site_static",
7+ "message": ""
8+ }
Original file line number Diff line number Diff line change 1+ {
2+ "latestVersion" : " 1.3.59" ,
3+ "playUrl" : " https://play.google.com/store/apps/details?id=com.strawcoding.strawmoneybook" ,
4+ "message" : " "
5+ }
Original file line number Diff line number Diff line change 1+ import { existsSync , readFileSync } from 'node:fs'
2+ import { resolve } from 'node:path'
3+
4+ const root = process . cwd ( )
5+ const manifestPath = resolve ( root , 'public/app-update.json' )
6+ const playApiPath = resolve ( root , 'public/api/app-update/play' )
7+
8+ function readJson ( path ) {
9+ return JSON . parse ( readFileSync ( path , 'utf8' ) )
10+ }
11+
12+ if ( ! existsSync ( manifestPath ) ) {
13+ throw new Error ( 'missing public/app-update.json' )
14+ }
15+ if ( ! existsSync ( playApiPath ) ) {
16+ throw new Error ( 'missing public/api/app-update/play' )
17+ }
18+
19+ const manifest = readJson ( manifestPath )
20+ const playApi = readJson ( playApiPath )
21+ const latestVersion = String ( manifest . latestVersion ?? '' ) . trim ( )
22+
23+ if ( ! latestVersion ) {
24+ throw new Error ( 'public/app-update.json missing latestVersion' )
25+ }
26+ if ( String ( playApi . latestVersion ?? '' ) . trim ( ) !== latestVersion ) {
27+ throw new Error ( 'Play API latestVersion must match manifest latestVersion' )
28+ }
29+ if ( String ( playApi . version ?? '' ) . trim ( ) !== latestVersion ) {
30+ throw new Error ( 'Play API version must match manifest latestVersion' )
31+ }
32+
33+ console . log ( `[check-app-update-json] latestVersion=${ latestVersion } ` )
You can’t perform that action at this time.
0 commit comments