dsh-go 手机版 GitHub 自动上传插件(胶囊 + 面板 + 回合脚注)
由 dsh-go 自动上传 · 2026/11/17 12:09:15
This commit is contained in:
commit
7c02807cb6
12 files changed
+1302
No files matched your search
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env node
|
||||
// 交互式写入 GitHub 令牌:在终端里运行,粘贴令牌后回车。令牌只写本机文件,权限 600。
|
||||
import { mkdirSync, writeFileSync, chmodSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
|
||||
const home = process.env.DSH_HOME || join(process.env.HOME || '/root', '.dsh')
|
||||
const file = join(home, 'dsh-go', 'github-token')
|
||||
|
||||
process.stdout.write('把 GitHub 令牌粘贴到这里,然后按回车(只保存在本机):\n')
|
||||
let raw = ''
|
||||
process.stdin.setEncoding('utf8')
|
||||
process.stdin.on('data', (chunk) => { raw += chunk })
|
||||
process.stdin.on('end', () => {
|
||||
const token = raw.split('\n')[0].trim()
|
||||
if (!/^[A-Za-z0-9_]{20,255}$/.test(token)) {
|
||||
console.error('这看起来不像 GitHub 令牌(应该是一串 40 位左右的字母数字,可能以 ghp_ 开头),没有写入。')
|
||||
process.exitCode = 1
|
||||
return
|
||||
}
|
||||
mkdirSync(dirname(file), { recursive: true, mode: 0o700 })
|
||||
writeFileSync(file, `${token}\n`, { mode: 0o600 })
|
||||
chmodSync(file, 0o600)
|
||||
console.log(`已保存到 ${file}(权限 600,不会上传、不会进仓库)。`)
|
||||
console.log('回到 dsh-go 的「GitHub 上传」面板,点一下项目就能上传了。')
|
||||
})
|
||||
Reference in new issue
Block a user