1
+ import fetch from 'node-fetch' ;
2
+ import fs from 'fs' ;
3
+
4
+ // Fetch version value fromy yaml file https://raw.githubusercontent.com/LinwoodDev/Qeck/nightly/app/pubspec.yaml
5
+ const nightlyUrl = 'https://raw.githubusercontent.com/LinwoodDev/Qeck/nightly/app/pubspec.yaml' ;
6
+ const nightlyVersion = await fetch ( nightlyUrl ) . then ( res => res . text ( ) ) . then ( text => {
7
+ const regex = / ^ v e r s i o n : \s ( .+ ) \+ ( .+ ) $ / gm;
8
+ const match = regex . exec ( text ) ;
9
+ return match [ 1 ] ;
10
+ }
11
+ ) ;
12
+
13
+ // stable
14
+ const stableUrl = 'https://raw.githubusercontent.com/LinwoodDev/Qeck/stable/app/pubspec.yaml' ;
15
+ const stableVersion = await fetch ( stableUrl ) . then ( res => res . text ( ) ) . then ( text => {
16
+ const regex = / ^ v e r s i o n : \s ( .+ ) \+ ( .+ ) $ / gm;
17
+ const match = regex . exec ( text ) ;
18
+ return match [ 1 ] ;
19
+ }
20
+ ) ;
21
+
22
+ // develop
23
+ const developUrl = 'https://raw.githubusercontent.com/LinwoodDev/Qeck/develop/app/pubspec.yaml' ;
24
+ const developVersion = await fetch ( developUrl ) . then ( res => res . text ( ) ) . then ( text => {
25
+ const regex = / ^ v e r s i o n : \s ( .+ ) \+ ( .+ ) $ / gm;
26
+ const match = regex . exec ( text ) ;
27
+ return match [ 1 ] ;
28
+ }
29
+ ) ;
30
+
31
+ // main
32
+ const mainUrl = 'https://raw.githubusercontent.com/LinwoodDev/Qeck/main/app/pubspec.yaml' ;
33
+ const mainVersion = await fetch ( mainUrl ) . then ( res => res . text ( ) ) . then ( text => {
34
+ const regex = / ^ v e r s i o n : \s ( .+ ) \+ ( .+ ) $ / gm;
35
+ const match = regex . exec ( text ) ;
36
+ return match [ 1 ] ;
37
+ }
38
+ ) ;
39
+
40
+ // Write nightly and stable version to meta.json
41
+ const meta = {
42
+ version : {
43
+ nightly : nightlyVersion ,
44
+ stable : stableVersion ,
45
+ develop : developVersion ,
46
+ main : mainVersion ,
47
+ }
48
+ } ;
49
+
50
+ // Write to static/meta.json
51
+ const metaPath = 'static/meta.json' ;
52
+ // Create meta.json if it doesn't exist
53
+ if ( ! fs . existsSync ( metaPath ) ) {
54
+ fs . writeFileSync ( metaPath , JSON . stringify ( meta ) ) ;
55
+ }
0 commit comments