Skip to content

Commit 07cfd71

Browse files
committed
Add generate meta
1 parent 613d1ce commit 07cfd71

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

docs/generate_meta.mjs

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 = /^version:\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 = /^version:\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 = /^version:\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 = /^version:\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+
}

docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"start": "docusaurus start",
88
"build:meta": "node ./generate_meta.mjs",
99
"build:docs": "docusaurus build",
10-
"build": "yarn build:meta && yarn build:docs",
10+
"build": "yarn build:docs",
1111
"swizzle": "docusaurus swizzle",
1212
"deploy": "docusaurus deploy",
1313
"clear": "docusaurus clear",

0 commit comments

Comments
 (0)