Skip to content
/ core Public

Commit 25fdde6

Browse files
committed
fix: update scripe
1 parent 2153077 commit 25fdde6

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

apps/core/get-latest-admin-version.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,43 @@
1+
import { execSync } from 'node:child_process'
12
import { writeFile } from 'node:fs/promises'
23
import { createRequire } from 'node:module'
34
import { resolve } from 'node:path'
45
import { fileURLToPath } from 'node:url'
6+
57
import axios from 'axios'
68

9+
function githubToken() {
10+
if (process.env.GH_TOKEN) return process.env.GH_TOKEN
11+
if (process.env.GITHUB_TOKEN) return process.env.GITHUB_TOKEN
12+
try {
13+
return execSync('gh auth token', {
14+
encoding: 'utf8',
15+
stdio: ['ignore', 'pipe', 'ignore'],
16+
}).trim()
17+
} catch {
18+
return undefined
19+
}
20+
}
21+
722
const require = createRequire(import.meta.url)
823
const __dirname = fileURLToPath(new URL('.', import.meta.url))
924

1025
const {
1126
dashboard: { repo },
1227
} = require('./package.json')
28+
1329
const Package = require('./package.json')
30+
1431
const endpoint = `https://api.github.com/repos/${repo}/releases/latest`
1532

1633
const latestVersion = async () => {
34+
const token = githubToken()
1735
const res = await axios
1836
.get(endpoint, {
1937
headers: {
2038
'User-Agent':
2139
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
22-
Authorization: process.env.GH_TOKEN
23-
? `Bearer ${process.env.GH_TOKEN}`
24-
: undefined,
40+
...(token ? { Authorization: `Bearer ${token}` } : {}),
2541
},
2642
})
2743
.catch((error) => {
@@ -40,7 +56,7 @@ async function main() {
4056
JSON.stringify(Package, null, 2),
4157
)
4258

43-
console.log('Updated version to', version)
59+
console.info('Updated version to', version)
4460
}
4561

4662
main()

apps/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@
180180
"vite-tsconfig-paths": "6.1.1",
181181
"vitest": "4.1.0"
182182
}
183-
}
183+
}

0 commit comments

Comments
 (0)