mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/mihomo-party-org/clash-party.git
synced 2026-09-20 08:03:39 +08:00
25 lines
737 B
JavaScript
25 lines
737 B
JavaScript
// Usage: node scripts/plugin/gen-cpx.mjs <loginUrl> <providerName> [site] [out.cpx]
|
|
import { writeFileSync } from 'fs'
|
|
|
|
const [loginUrl, name, site, out = 'plugin.cpx'] = process.argv.slice(2)
|
|
if (!loginUrl || !name) {
|
|
console.error(
|
|
'Usage: node gen-cpx.mjs <loginUrl https authorize> <providerName> [site] [out.cpx]'
|
|
)
|
|
process.exit(1)
|
|
}
|
|
const u = new URL(loginUrl)
|
|
if (u.protocol !== 'https:' || u.search || u.hash) {
|
|
console.error('loginUrl must be https with no query/fragment')
|
|
process.exit(1)
|
|
}
|
|
const descriptor = {
|
|
magic: 'CPXF',
|
|
v: 2,
|
|
spec: 'cpx-plugin/2',
|
|
loginUrl,
|
|
provider: { name, ...(site ? { site } : {}) }
|
|
}
|
|
writeFileSync(out, JSON.stringify(descriptor, null, 2) + '\n')
|
|
console.log('wrote', out)
|