@adobe/helix-deploy 11.1.15 → 12.0.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -1
- package/package.json +2 -12
- package/params.json +3 -0
- package/src/ActionBuilder.js +20 -19
- package/src/BaseConfig.js +7 -1
- package/src/bundler/BaseBundler.js +6 -16
- package/src/bundler/WebpackBundler.js +12 -1
- package/src/cli.js +58 -12
- package/src/bundler/EdgeBundler.js +0 -132
- package/src/deploy/CloudflareConfig.js +0 -74
- package/src/deploy/CloudflareDeployer.js +0 -178
- package/src/deploy/ComputeAtEdgeConfig.js +0 -91
- package/src/deploy/ComputeAtEdgeDeployer.js +0 -185
- package/src/gateway/FastlyConfig.js +0 -96
- package/src/gateway/FastlyGateway.js +0 -525
- package/src/template/cloudflare-adapter.js +0 -65
- package/src/template/fastly-adapter.js +0 -128
- package/src/template/polyfills/fetch.js +0 -20
- package/src/template/serviceworker-index.js +0 -26
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import fs from 'fs';
|
|
13
|
-
import FormData from 'form-data';
|
|
14
|
-
import BaseDeployer from './BaseDeployer.js';
|
|
15
|
-
import CloudflareConfig from './CloudflareConfig.js';
|
|
16
|
-
|
|
17
|
-
export default class CloudflareDeployer extends BaseDeployer {
|
|
18
|
-
constructor(baseConfig, config) {
|
|
19
|
-
super(baseConfig);
|
|
20
|
-
Object.assign(this, {
|
|
21
|
-
id: 'cloudflare',
|
|
22
|
-
name: 'Cloudflare',
|
|
23
|
-
_cfg: config,
|
|
24
|
-
noGatewayBackend: true,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
ready() {
|
|
29
|
-
return !!this._cfg.auth && !!this._cfg.accountID && !!this.cfg.edgeBundle;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
validate() {
|
|
33
|
-
if (!this.ready()) {
|
|
34
|
-
throw new Error('Cloudflare target needs email, token, and account ID');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get fullFunctionName() {
|
|
39
|
-
return `${this.cfg.packageName}--${this.cfg.name}`
|
|
40
|
-
.replace(/\./g, '_')
|
|
41
|
-
.replace('@', '_');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async deploy() {
|
|
45
|
-
const body = fs.readFileSync(this.cfg.edgeBundle);
|
|
46
|
-
const settings = await this.getSettings();
|
|
47
|
-
const { id } = await this.createKVNamespace(`${this.cfg.packageName}--secrets`);
|
|
48
|
-
|
|
49
|
-
const metadata = {
|
|
50
|
-
body_part: 'script',
|
|
51
|
-
bindings: [
|
|
52
|
-
...Object.entries(this.cfg.params).map(([key, value]) => ({
|
|
53
|
-
name: key,
|
|
54
|
-
type: 'secret_text',
|
|
55
|
-
text: value,
|
|
56
|
-
})),
|
|
57
|
-
{
|
|
58
|
-
name: 'PACKAGE',
|
|
59
|
-
namespace_id: id,
|
|
60
|
-
type: 'kv_namespace',
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// what https://api.cloudflare.com/#worker-script-upload-worker won't tell you:
|
|
66
|
-
// you can use multipart/formdata to set metadata according to
|
|
67
|
-
// https://community.cloudflare.com/t/bind-kv-and-workers-via-api/221391
|
|
68
|
-
const form = new FormData();
|
|
69
|
-
form.append('script', body, {
|
|
70
|
-
contentType: 'application/javascript',
|
|
71
|
-
});
|
|
72
|
-
form.append('metadata', JSON.stringify(metadata), {
|
|
73
|
-
contentType: 'application/json',
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const res = await this.fetch(`https://api.cloudflare.com/client/v4/accounts/${this._cfg.accountID}/workers/scripts/${this.fullFunctionName}`, {
|
|
77
|
-
method: 'PUT',
|
|
78
|
-
headers: form.getHeaders({
|
|
79
|
-
Authorization: `Bearer ${this._cfg.auth}`,
|
|
80
|
-
}),
|
|
81
|
-
body: form.getBuffer(),
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (!res.ok) {
|
|
85
|
-
const { errors } = await res.json();
|
|
86
|
-
throw new Error(`Unable to upload worker to Cloudflare: ${errors[0].message}`);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
await this.updatePackageParams(id, this.cfg.packageParams);
|
|
90
|
-
|
|
91
|
-
await this.restoreSettings(settings);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async getSettings() {
|
|
95
|
-
const res = await this.fetch(`https://api.cloudflare.com/client/v4/accounts/${this._cfg.accountID}/workers/scripts/${this.fullFunctionName}/script-settings`, {
|
|
96
|
-
method: 'GET',
|
|
97
|
-
headers: {
|
|
98
|
-
Authorization: `Bearer ${this._cfg.auth}`,
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
if (!res.ok) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
const { result } = await res.json();
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async restoreSettings(existing) {
|
|
109
|
-
if (!existing) {
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
const res = await this.fetch(`https://api.cloudflare.com/client/v4/accounts/${this._cfg.accountID}/workers/scripts/${this.fullFunctionName}/script-settings`, {
|
|
113
|
-
method: 'PATCH',
|
|
114
|
-
headers: {
|
|
115
|
-
Authorization: `Bearer ${this._cfg.auth}`,
|
|
116
|
-
'content-type': 'application/json',
|
|
117
|
-
},
|
|
118
|
-
body: JSON.stringify(existing),
|
|
119
|
-
});
|
|
120
|
-
return res.ok;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async updatePackageParams(id, params) {
|
|
124
|
-
const kvlist = Object.entries(params).map(([key, value]) => ({
|
|
125
|
-
key, value,
|
|
126
|
-
}));
|
|
127
|
-
if (!kvlist.length) {
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const res = await this.fetch(`https://api.cloudflare.com/client/v4/accounts/${this._cfg.accountID}/storage/kv/namespaces/${id}/bulk`, {
|
|
132
|
-
method: 'PUT',
|
|
133
|
-
headers: {
|
|
134
|
-
Authorization: `Bearer ${this._cfg.auth}`,
|
|
135
|
-
'content-type': 'application/json',
|
|
136
|
-
},
|
|
137
|
-
body: JSON.stringify(kvlist),
|
|
138
|
-
});
|
|
139
|
-
return res.ok;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async createKVNamespace(name) {
|
|
143
|
-
const postres = await this.fetch(`https://api.cloudflare.com/client/v4/accounts/${this._cfg.accountID}/storage/kv/namespaces`, {
|
|
144
|
-
method: 'POST',
|
|
145
|
-
headers: {
|
|
146
|
-
Authorization: `Bearer ${this._cfg.auth}`,
|
|
147
|
-
'content-type': 'application/json',
|
|
148
|
-
},
|
|
149
|
-
body: {
|
|
150
|
-
title: name,
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
let { result } = await postres.json();
|
|
154
|
-
if (!result) {
|
|
155
|
-
const listres = await this.fetch(`https://api.cloudflare.com/client/v4/accounts/${this._cfg.accountID}/storage/kv/namespaces`, {
|
|
156
|
-
method: 'GET',
|
|
157
|
-
headers: {
|
|
158
|
-
Authorization: `Bearer ${this._cfg.auth}`,
|
|
159
|
-
},
|
|
160
|
-
});
|
|
161
|
-
const { result: results } = await listres.json();
|
|
162
|
-
result = results.find((r) => r.title === name);
|
|
163
|
-
}
|
|
164
|
-
return result;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async test() {
|
|
168
|
-
return this._cfg.testDomain
|
|
169
|
-
? this.testRequest({
|
|
170
|
-
url: `https://${this.fullFunctionName}.${this._cfg.testDomain}.workers.dev`,
|
|
171
|
-
idHeader: 'CF-RAY',
|
|
172
|
-
retry404: 0,
|
|
173
|
-
})
|
|
174
|
-
: undefined;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
CloudflareDeployer.Config = CloudflareConfig;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
export default class ComputeAtEdgeConfig {
|
|
13
|
-
constructor() {
|
|
14
|
-
Object.assign(this, {});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
configure(argv) {
|
|
18
|
-
return this
|
|
19
|
-
.withServiceID(argv.computeServiceId)
|
|
20
|
-
.withAuth(argv.fastlyAuth)
|
|
21
|
-
.withCoralogixToken(argv.coralogixToken)
|
|
22
|
-
.withFastlyGateway(argv.fastlyGateway)
|
|
23
|
-
.withComputeDomain(argv.computeTestDomain)
|
|
24
|
-
.withCoralogixApp(argv.computeCoralogixApp);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
withServiceID(value) {
|
|
28
|
-
this.service = value;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
withAuth(value) {
|
|
33
|
-
this.auth = value;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
withCoralogixToken(value) {
|
|
38
|
-
this.coralogixToken = value;
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
withCoralogixApp(value) {
|
|
43
|
-
this.coralogixApp = value;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
withFastlyGateway(value) {
|
|
48
|
-
this.fastlyGateway = value;
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
withComputeDomain(value) {
|
|
53
|
-
this.testDomain = value;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static yarg(yargs) {
|
|
58
|
-
return yargs
|
|
59
|
-
.group(['compute-service-id', 'compute-domain', 'fastly-auth', 'coralogix-token', 'compute-coralogix-app'], 'Fastly Compute@Edge Options')
|
|
60
|
-
.option('compute-service-id', {
|
|
61
|
-
description: 'the Fastly Service to deploy the action to',
|
|
62
|
-
type: 'string',
|
|
63
|
-
default: '',
|
|
64
|
-
})
|
|
65
|
-
.option('compute-test-domain', {
|
|
66
|
-
description: 'the domain name of the Compute@Edge service (used for testing)',
|
|
67
|
-
type: 'string',
|
|
68
|
-
default: '',
|
|
69
|
-
})
|
|
70
|
-
.option('fastly-auth', {
|
|
71
|
-
description: 'the Fastly token',
|
|
72
|
-
type: 'string',
|
|
73
|
-
default: '',
|
|
74
|
-
})
|
|
75
|
-
.option('coralogix-token', {
|
|
76
|
-
description: 'the Coralogix token (to enable logging)',
|
|
77
|
-
type: 'string',
|
|
78
|
-
default: '',
|
|
79
|
-
})
|
|
80
|
-
.option('fastly-gateway', {
|
|
81
|
-
description: 'the hostname of the Fastly gateway for package params',
|
|
82
|
-
type: 'string',
|
|
83
|
-
default: '',
|
|
84
|
-
})
|
|
85
|
-
.option('compute-coralogix-app', {
|
|
86
|
-
description: 'the Application name',
|
|
87
|
-
type: 'string',
|
|
88
|
-
default: 'fastly-compute',
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import chalk from 'chalk-template';
|
|
13
|
-
import path from 'path';
|
|
14
|
-
import fs from 'fs/promises';
|
|
15
|
-
import * as tar from 'tar';
|
|
16
|
-
import Fastly from '@adobe/fastly-native-promises';
|
|
17
|
-
import { compileApplicationToWasm } from '@fastly/js-compute/src/compileApplicationToWasm.js';
|
|
18
|
-
import { parseInputs } from '@fastly/js-compute/src/parseInputs.js';
|
|
19
|
-
import BaseDeployer from './BaseDeployer.js';
|
|
20
|
-
import ComputeAtEdgeConfig from './ComputeAtEdgeConfig.js';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The class ComputeAtEdgeDeployer deploys to Fastly's Compute(at)Edge (WASM) runtime.
|
|
24
|
-
* It should be seen as a functional equivalent to the CloudflareDeployer
|
|
25
|
-
* and not confused with the FastlyGateway (which only routes requests, but
|
|
26
|
-
* does not handle them.)
|
|
27
|
-
*/
|
|
28
|
-
export default class ComputeAtEdgeDeployer extends BaseDeployer {
|
|
29
|
-
constructor(baseConfig, config) {
|
|
30
|
-
super(baseConfig);
|
|
31
|
-
Object.assign(this, {
|
|
32
|
-
id: 'c@e',
|
|
33
|
-
name: 'Fastly Compute@Edge',
|
|
34
|
-
_cfg: config,
|
|
35
|
-
_fastly: null,
|
|
36
|
-
noGatewayBackend: true,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
ready() {
|
|
41
|
-
return !!this._cfg.service && !!this._cfg.auth && !!this.cfg.edgeBundle;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
validate() {
|
|
45
|
-
if (!this.ready()) {
|
|
46
|
-
throw new Error('Compute@Edge target needs token and service ID');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
init() {
|
|
51
|
-
if (this.ready() && !this._fastly) {
|
|
52
|
-
this._fastly = Fastly(this._cfg.auth, this._cfg.service, 60000);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get log() {
|
|
57
|
-
return this.cfg.log;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* @returns
|
|
63
|
-
*/
|
|
64
|
-
async bundle() {
|
|
65
|
-
const bundleDir = path.dirname(this.cfg.edgeBundle);
|
|
66
|
-
this.log.debug(`--: creating fastly.toml in ${bundleDir}`);
|
|
67
|
-
fs.writeFile(path.resolve(bundleDir, 'fastly.toml'), `
|
|
68
|
-
# This file describes a Fastly Compute@Edge package. To learn more visit:
|
|
69
|
-
# https://developer.fastly.com/reference/fastly-toml/
|
|
70
|
-
|
|
71
|
-
authors = ["Helix Deploy"]
|
|
72
|
-
description = "${this.cfg.packageName} project generated by Helix Deploy"
|
|
73
|
-
language = "javascript"
|
|
74
|
-
manifest_version = 2
|
|
75
|
-
name = "${this.cfg.packageName}"
|
|
76
|
-
service_id = ""
|
|
77
|
-
`);
|
|
78
|
-
|
|
79
|
-
const {
|
|
80
|
-
input,
|
|
81
|
-
output,
|
|
82
|
-
wasmEngine,
|
|
83
|
-
} = await parseInputs([this.cfg.edgeBundle, path.resolve(bundleDir, 'bin', 'main.wasm')]);
|
|
84
|
-
|
|
85
|
-
return new Promise((resolve, reject) => {
|
|
86
|
-
this.log.debug('--: creating WASM bundle of script and interpreter');
|
|
87
|
-
compileApplicationToWasm(input, output, wasmEngine, false, false)
|
|
88
|
-
.then(async () => {
|
|
89
|
-
const file = path.resolve(bundleDir, 'fastly-bundle.tar.gz');
|
|
90
|
-
this.log.debug(chalk`{green ok:} created WASM bundle of script and interpreter in ${bundleDir}/bin/main.wasm`);
|
|
91
|
-
await tar.c({
|
|
92
|
-
gzip: true,
|
|
93
|
-
// sync: true,
|
|
94
|
-
cwd: bundleDir,
|
|
95
|
-
prefix: this.cfg.packageName,
|
|
96
|
-
file,
|
|
97
|
-
}, ['bin/main.wasm', 'fastly.toml']);
|
|
98
|
-
this.log.debug(chalk`{green ok:} created tar file in ${bundleDir}/fastly-bundle.tar.gz`);
|
|
99
|
-
resolve(fs.readFile(file));
|
|
100
|
-
})
|
|
101
|
-
// c8 ignore next 3
|
|
102
|
-
.catch((err) => {
|
|
103
|
-
reject(err);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async deploy() {
|
|
109
|
-
const buf = await this.bundle();
|
|
110
|
-
this.init();
|
|
111
|
-
|
|
112
|
-
await this._fastly.transact(async (version) => {
|
|
113
|
-
this.log.debug('--: uploading package to fastly, service version', version);
|
|
114
|
-
await this._fastly.writePackage(version, buf);
|
|
115
|
-
|
|
116
|
-
this.log.debug('--: creating secrets dictionary');
|
|
117
|
-
await this._fastly.writeDictionary(version, 'secrets', {
|
|
118
|
-
name: 'secrets',
|
|
119
|
-
write_only: 'true',
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const host = this._cfg.fastlyGateway;
|
|
123
|
-
const backend = {
|
|
124
|
-
hostname: host,
|
|
125
|
-
ssl_cert_hostname: host,
|
|
126
|
-
ssl_sni_hostname: host,
|
|
127
|
-
address: host,
|
|
128
|
-
override_host: host,
|
|
129
|
-
name: 'gateway',
|
|
130
|
-
error_threshold: 0,
|
|
131
|
-
first_byte_timeout: 60000,
|
|
132
|
-
weight: 100,
|
|
133
|
-
connect_timeout: 5000,
|
|
134
|
-
port: 443,
|
|
135
|
-
between_bytes_timeout: 10000,
|
|
136
|
-
shield: '', // 'bwi-va-us',
|
|
137
|
-
max_conn: 200,
|
|
138
|
-
use_ssl: true,
|
|
139
|
-
};
|
|
140
|
-
if (host) {
|
|
141
|
-
this.log.debug(`--: updating gateway backend: ${host}`);
|
|
142
|
-
await this._fastly.writeBackend(version, 'gateway', backend);
|
|
143
|
-
}
|
|
144
|
-
}, true);
|
|
145
|
-
|
|
146
|
-
await this._fastly.discard();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
async updatePackage() {
|
|
150
|
-
this.log.info(`--: updating app (gateway) config for https://${this._cfg.fastlyGateway}/${this.cfg.packageName}/...`);
|
|
151
|
-
|
|
152
|
-
this.init();
|
|
153
|
-
|
|
154
|
-
const functionparams = Object
|
|
155
|
-
.entries(this.cfg.params)
|
|
156
|
-
.map(([key, value]) => ({
|
|
157
|
-
item_key: key,
|
|
158
|
-
item_value: value,
|
|
159
|
-
op: 'update',
|
|
160
|
-
}));
|
|
161
|
-
|
|
162
|
-
await this._fastly.bulkUpdateDictItems(undefined, 'secrets', ...functionparams);
|
|
163
|
-
await this._fastly.updateDictItem(undefined, 'secrets', '_token', this.cfg.packageToken);
|
|
164
|
-
await this._fastly.updateDictItem(undefined, 'secrets', '_package', `https://${this._cfg.fastlyGateway}/${this.cfg.packageName}/`);
|
|
165
|
-
|
|
166
|
-
await this._fastly.discard();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
get fullFunctionName() {
|
|
170
|
-
return `${this.cfg.packageName}--${this.cfg.name}`
|
|
171
|
-
.replace(/\./g, '_')
|
|
172
|
-
.replace('@', '_');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
async test() {
|
|
176
|
-
return this._cfg.testDomain
|
|
177
|
-
? this.testRequest({
|
|
178
|
-
url: `https://${this._cfg.testDomain}.edgecompute.app`,
|
|
179
|
-
retry404: 0,
|
|
180
|
-
})
|
|
181
|
-
: undefined;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
ComputeAtEdgeDeployer.Config = ComputeAtEdgeConfig;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
export default class FastlyConfig {
|
|
13
|
-
constructor() {
|
|
14
|
-
Object.assign(this, {
|
|
15
|
-
service: null,
|
|
16
|
-
auth: null,
|
|
17
|
-
checkpath: '',
|
|
18
|
-
checkinterval: 0,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
configure(argv) {
|
|
23
|
-
return this
|
|
24
|
-
.withServiceID(argv.fastlyServiceId)
|
|
25
|
-
.withAuth(argv.fastlyAuth)
|
|
26
|
-
.withCoralogixToken(argv.coralogixToken)
|
|
27
|
-
.withCoralogixApp(argv.coralogixApp)
|
|
28
|
-
.withCheckInterval(argv.checkInterval)
|
|
29
|
-
.withCheckpath(argv.checkpath);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
withAuth(value) {
|
|
33
|
-
this.auth = value;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
withCheckInterval(value) {
|
|
38
|
-
this.checkinterval = value;
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
withServiceID(value) {
|
|
43
|
-
this.service = value;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
withCheckpath(value) {
|
|
48
|
-
this.checkpath = value;
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
withCoralogixToken(value) {
|
|
53
|
-
this.coralogixToken = value;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
withCoralogixApp(value) {
|
|
58
|
-
this.coralogixApp = value;
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static yarg(yargs) {
|
|
63
|
-
return yargs
|
|
64
|
-
.group(['fastly-service-id', 'fastly-auth', 'checkpath', 'coralogix-token', 'coralogix-app'], 'Fastly Gateway Options')
|
|
65
|
-
.option('fastly-service-id', {
|
|
66
|
-
description: 'the Fastly Service to use as a gateway',
|
|
67
|
-
type: 'string',
|
|
68
|
-
default: '',
|
|
69
|
-
})
|
|
70
|
-
.option('fastly-auth', {
|
|
71
|
-
description: 'the Fastly token',
|
|
72
|
-
type: 'string',
|
|
73
|
-
default: '',
|
|
74
|
-
})
|
|
75
|
-
.option('coralogix-token', {
|
|
76
|
-
description: 'the Coralogix token (to enable logging)',
|
|
77
|
-
type: 'string',
|
|
78
|
-
default: '',
|
|
79
|
-
})
|
|
80
|
-
.option('coralogix-app', {
|
|
81
|
-
description: 'the Application name',
|
|
82
|
-
type: 'string',
|
|
83
|
-
default: 'universal-runtime',
|
|
84
|
-
})
|
|
85
|
-
.option('checkpath', {
|
|
86
|
-
description: 'the path to check as part of the Fastly health check',
|
|
87
|
-
type: 'string',
|
|
88
|
-
default: '',
|
|
89
|
-
})
|
|
90
|
-
.option('checkinterval', {
|
|
91
|
-
description: 'the interval in milliseconds that each Fastly POP should perform a health check. Set to 0 to disable health checks entirely.',
|
|
92
|
-
type: 'number',
|
|
93
|
-
default: 6000000,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|