@@ -7,13 +7,16 @@ import { getEnv } from './env.js';
7
7
const serviceId = argv [ 2 ] ;
8
8
const serviceName = argv [ 3 ] ;
9
9
10
+ const env = getEnv ( serviceName ) ;
11
+ Object . assign ( process . env , env ) ;
12
+
10
13
const {
11
14
DICTIONARY_NAME ,
12
15
CONFIG_STORE_NAME ,
13
16
KV_STORE_NAME ,
14
17
SECRET_STORE_NAME ,
15
18
ACL_NAME ,
16
- } = getEnv ( serviceName ) ;
19
+ } = env ;
17
20
18
21
function existingListId ( stores , existingName ) {
19
22
const existing = stores . find (
@@ -49,11 +52,10 @@ async function setupConfigStores() {
49
52
if ( ! STORE_ID ) {
50
53
console . log ( `Creating new config store ${ DICTIONARY_NAME } ` ) ;
51
54
STORE_ID = JSON . parse (
52
- await zx `fastly config-store create --quiet --name=${ DICTIONARY_NAME } --json --token $FASTLY_API_TOKEN` ,
55
+ await zx `fastly config-store create --quiet --name="$ DICTIONARY_NAME" --json --token $FASTLY_API_TOKEN` ,
53
56
) . id ;
54
57
} else {
55
58
console . log ( `Using existing config store ${ DICTIONARY_NAME } ` ) ;
56
- STORE_ID = STORE_ID ;
57
59
}
58
60
await zx `echo -n 'https://twitter.com/fastly' | fastly config-store-entry update --upsert --key twitter --store-id=${ STORE_ID } --stdin --token $FASTLY_API_TOKEN` ;
59
61
try {
@@ -66,11 +68,10 @@ async function setupConfigStores() {
66
68
if ( ! STORE_ID ) {
67
69
console . log ( `Creating new config store ${ CONFIG_STORE_NAME } ` ) ;
68
70
STORE_ID = JSON . parse (
69
- await zx `fastly config-store create --quiet --name=${ CONFIG_STORE_NAME } --json --token $FASTLY_API_TOKEN` ,
71
+ await zx `fastly config-store create --quiet --name="$ CONFIG_STORE_NAME" --json --token $FASTLY_API_TOKEN` ,
70
72
) . id ;
71
73
} else {
72
74
console . log ( `Using existing config store ${ CONFIG_STORE_NAME } ` ) ;
73
- STORE_ID = STORE_ID ;
74
75
}
75
76
await zx `echo -n 'https://twitter.com/fastly' | fastly config-store-entry update --upsert --key twitter --store-id=${ STORE_ID } --stdin --token $FASTLY_API_TOKEN` ;
76
77
try {
@@ -89,11 +90,10 @@ async function setupKVStore() {
89
90
if ( ! STORE_ID ) {
90
91
console . log ( `Creating new KV store ${ KV_STORE_NAME } ` ) ;
91
92
STORE_ID = JSON . parse (
92
- await zx `fastly kv-store create --quiet --name=${ KV_STORE_NAME } --json --token $FASTLY_API_TOKEN` ,
93
+ await zx `fastly kv-store create --quiet --name="$ KV_STORE_NAME" --json --token $FASTLY_API_TOKEN` ,
93
94
) . StoreID ;
94
95
} else {
95
96
console . log ( `Using existing KV store ${ KV_STORE_NAME } ` ) ;
96
- STORE_ID = STORE_ID ;
97
97
}
98
98
try {
99
99
await zx `fastly resource-link create --service-id ${ serviceId } --version latest --resource-id ${ STORE_ID } --token $FASTLY_API_TOKEN --autoclone` ;
@@ -110,7 +110,7 @@ async function setupSecretStore() {
110
110
if ( ! STORE_ID ) {
111
111
console . log ( `Creating new secret store ${ SECRET_STORE_NAME } ` ) ;
112
112
STORE_ID = JSON . parse (
113
- await zx `fastly secret-store create --quiet --name=${ SECRET_STORE_NAME } --json --token $FASTLY_API_TOKEN` ,
113
+ await zx `fastly secret-store create --quiet --name="$ SECRET_STORE_NAME" --json --token $FASTLY_API_TOKEN` ,
114
114
) . id ;
115
115
} else {
116
116
console . log ( `Using existing secret store ${ SECRET_STORE_NAME } ` ) ;
@@ -136,7 +136,7 @@ async function setupAcl() {
136
136
if ( ! ACL_ID ) {
137
137
console . log ( `Creating ACL ${ ACL_NAME } ` ) ;
138
138
ACL_ID = JSON . parse (
139
- await zx `fastly compute acl create --name=${ ACL_NAME } --token $FASTLY_API_TOKEN --json` ,
139
+ await zx `fastly compute acl create --name="$ ACL_NAME" --token $FASTLY_API_TOKEN --json` ,
140
140
) . id ;
141
141
await zx `fastly compute acl update --acl-id=${ ACL_ID } --operation=create --prefix=100.100.0.0/16 --action=BLOCK --token $FASTLY_API_TOKEN` ;
142
142
await zx `fastly compute acl update --acl-id=${ ACL_ID } --operation=create --prefix=2a03:4b80::/32 --action=ALLOW --token $FASTLY_API_TOKEN` ;
@@ -150,9 +150,11 @@ async function setupAcl() {
150
150
}
151
151
}
152
152
153
+ zx . verbose = true ;
153
154
await setupConfigStores ( ) ;
154
155
await setupKVStore ( ) ;
155
156
await setupSecretStore ( ) ;
156
157
await setupAcl ( ) ;
158
+ zx . verbose = false ;
157
159
158
160
await zx `fastly service-version activate --service-id ${ serviceId } --version latest --token $FASTLY_API_TOKEN` ;
0 commit comments