forked from cloudflare/wildebeest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-one-click-deploy-button.mjs
49 lines (47 loc) · 1.31 KB
/
generate-one-click-deploy-button.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const PROJECT_URL = 'https://github.com/cloudflare/wildebeest'
const ONE_CLICK_BASE_URL = 'https://deploy.workers.cloudflare.com'
const FIELDS = [
{
name: 'Zone ID',
secret: 'CF_ZONE_ID',
descr: 'Get your Zone ID from the Cloudflare Dashboard',
},
{
name: 'Domain',
secret: 'CF_DEPLOY_DOMAIN',
descr: 'Domain on which your instance will be running',
},
{
name: 'Instance title',
secret: 'INSTANCE_TITLE',
descr: 'Title of your instance',
},
{
name: 'Administrator Email',
secret: 'ADMIN_EMAIL',
descr: 'An Email address that can be messaged regarding inquiries or issues',
},
{
name: 'Instance description',
secret: 'INSTANCE_DESCR',
descr: 'A short, plain-text description of your instance',
},
]
const API_TOKEN_TEMPLATE = JSON.stringify([
{ key: 'd1', type: 'edit' },
{ key: 'page', type: 'edit' },
{ key: 'images', type: 'edit' },
{ key: 'access', type: 'edit' },
{ key: 'workers_kv_storage', type: 'edit' },
{ key: 'access_acct', type: 'read' },
{ key: 'dns', type: 'edit' },
{ key: 'workers_scripts', type: 'edit' },
])
const fields = FIELDS.map((x) => JSON.stringify(x))
.map((v) => `fields=${v}`)
.join('&')
const url = new URL(
`/?url=${PROJECT_URL}&authed=true&${fields}&apiTokenTmpl=${API_TOKEN_TEMPLATE}&apiTokenName=Wildebeest`,
ONE_CLICK_BASE_URL
)
console.log(url.href)