@adobe/helix-deploy 4.15.1 → 5.0.3
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/CHANGELOG.md +33 -0
- package/CONTRIBUTING.md +6 -0
- package/package.json +25 -28
- package/src/ActionBuilder.js +14 -14
- package/src/BaseConfig.js +6 -8
- package/src/DevelopmentServer.js +11 -7
- package/src/bundler/BaseBundler.js +16 -13
- package/src/bundler/EdgeBundler.js +12 -6
- package/src/bundler/RollupBundler.js +18 -13
- package/src/bundler/WebpackBundler.js +15 -8
- package/src/cli.js +17 -28
- package/src/deploy/AWSConfig.js +1 -3
- package/src/deploy/AWSDeployer.js +69 -66
- package/src/deploy/AzureConfig.js +1 -3
- package/src/deploy/AzureDeployer.js +7 -7
- package/src/deploy/BaseDeployer.js +18 -20
- package/src/deploy/CloudflareConfig.js +1 -3
- package/src/deploy/CloudflareDeployer.js +6 -7
- package/src/deploy/ComputeAtEdgeConfig.js +1 -3
- package/src/deploy/ComputeAtEdgeDeployer.js +13 -10
- package/src/deploy/GoogleConfig.js +1 -3
- package/src/deploy/GoogleDeployer.js +11 -12
- package/src/deploy/OpenWhiskConfig.js +1 -3
- package/src/deploy/OpenWhiskDeployer.js +16 -19
- package/src/gateway/FastlyConfig.js +1 -3
- package/src/gateway/FastlyGateway.js +7 -7
- package/src/index.js +1 -1
- package/src/{config/adobeioruntime-node10.js → package.cjs} +2 -13
- package/src/template/node-index.js +4 -3
- package/src/template/serviceworker-index.js +2 -2
- package/src/utils.js +8 -9
|
@@ -10,60 +10,47 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
/* eslint-disable no-await-in-loop,no-restricted-syntax */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
CreateBucketCommand,
|
|
13
|
+
import chalk from 'chalk-template';
|
|
14
|
+
import {
|
|
15
|
+
CreateBucketCommand, DeleteBucketCommand, DeleteObjectCommand, DeleteObjectsCommand,
|
|
17
16
|
ListBucketsCommand,
|
|
18
|
-
ListObjectsV2Command,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
CreateFunctionCommand,
|
|
17
|
+
ListObjectsV2Command, PutObjectCommand,
|
|
18
|
+
S3Client,
|
|
19
|
+
} from '@aws-sdk/client-s3';
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
AddPermissionCommand,
|
|
23
|
+
CreateAliasCommand,
|
|
24
|
+
CreateFunctionCommand, GetAliasCommand,
|
|
27
25
|
GetFunctionCommand,
|
|
26
|
+
LambdaClient, PublishVersionCommand, UpdateAliasCommand, UpdateFunctionCodeCommand,
|
|
28
27
|
UpdateFunctionConfigurationCommand,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
CreateAliasCommand,
|
|
33
|
-
UpdateAliasCommand,
|
|
34
|
-
AddPermissionCommand,
|
|
35
|
-
} = require('@aws-sdk/client-lambda');
|
|
36
|
-
const {
|
|
28
|
+
} from '@aws-sdk/client-lambda';
|
|
29
|
+
|
|
30
|
+
import {
|
|
37
31
|
ApiGatewayV2Client,
|
|
38
|
-
GetApisCommand,
|
|
39
|
-
GetApiCommand,
|
|
40
|
-
GetStagesCommand,
|
|
41
|
-
GetIntegrationsCommand,
|
|
42
32
|
CreateApiCommand,
|
|
33
|
+
CreateIntegrationCommand, CreateRouteCommand,
|
|
43
34
|
CreateStageCommand,
|
|
44
|
-
CreateIntegrationCommand,
|
|
45
35
|
DeleteIntegrationCommand,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const AWSConfig = require('./AWSConfig.js');
|
|
65
|
-
|
|
66
|
-
class AWSDeployer extends BaseDeployer {
|
|
36
|
+
GetApiCommand,
|
|
37
|
+
GetApisCommand,
|
|
38
|
+
GetIntegrationsCommand, GetRoutesCommand,
|
|
39
|
+
GetStagesCommand, UpdateRouteCommand,
|
|
40
|
+
} from '@aws-sdk/client-apigatewayv2';
|
|
41
|
+
|
|
42
|
+
import { PutParameterCommand, SSMClient } from '@aws-sdk/client-ssm';
|
|
43
|
+
|
|
44
|
+
import { PutSecretValueCommand, SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
|
|
45
|
+
|
|
46
|
+
import path from 'path';
|
|
47
|
+
import fse from 'fs-extra';
|
|
48
|
+
import crypto from 'crypto';
|
|
49
|
+
import BaseDeployer from './BaseDeployer.js';
|
|
50
|
+
import ActionBuilder from '../ActionBuilder.js';
|
|
51
|
+
import AWSConfig from './AWSConfig.js';
|
|
52
|
+
|
|
53
|
+
export default class AWSDeployer extends BaseDeployer {
|
|
67
54
|
constructor(baseConfig, config) {
|
|
68
55
|
super(baseConfig);
|
|
69
56
|
|
|
@@ -228,26 +215,41 @@ class AWSDeployer extends BaseDeployer {
|
|
|
228
215
|
|
|
229
216
|
this.log.info(`--: using lambda role "${this._cfg.role}"`);
|
|
230
217
|
|
|
218
|
+
// check if function already exists
|
|
219
|
+
let baseARN;
|
|
231
220
|
try {
|
|
232
|
-
this.log.info(`--:
|
|
233
|
-
await this._lambda.send(new GetFunctionCommand({
|
|
221
|
+
this.log.info(chalk`--: checking existing Lambda function {yellow ${functionName}}`);
|
|
222
|
+
const { Configuration: { FunctionArn } } = await this._lambda.send(new GetFunctionCommand({
|
|
234
223
|
FunctionName: functionName,
|
|
235
224
|
}));
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
FunctionName: functionName,
|
|
239
|
-
...functionConfig.Code,
|
|
240
|
-
}));
|
|
225
|
+
baseARN = FunctionArn;
|
|
226
|
+
this.log.info(chalk`{green ok}: exist {yellow ${FunctionArn}}`);
|
|
241
227
|
} catch (e) {
|
|
242
228
|
if (e.name === 'ResourceNotFoundException') {
|
|
243
|
-
this.log.info(
|
|
229
|
+
this.log.info(chalk`{green ok}: does not exist yet.`);
|
|
230
|
+
this.log.info(chalk`--: creating new Lambda function {yellow ${functionName}}`);
|
|
244
231
|
await this._lambda.send(new CreateFunctionCommand(functionConfig));
|
|
245
232
|
} else {
|
|
246
|
-
this.log.error(`Unable to verify existence of Lambda function ${functionName}`);
|
|
233
|
+
this.log.error(chalk`Unable to verify existence of Lambda function {yellow ${functionName}}`);
|
|
247
234
|
throw e;
|
|
248
235
|
}
|
|
249
236
|
}
|
|
250
237
|
|
|
238
|
+
// update existing function
|
|
239
|
+
if (baseARN) {
|
|
240
|
+
await this.checkFunctionReady(baseARN);
|
|
241
|
+
this.log.info(chalk`--: updating existing Lambda function configuration {yellow ${functionName}}`);
|
|
242
|
+
await this._lambda.send(new UpdateFunctionConfigurationCommand(functionConfig));
|
|
243
|
+
await this.checkFunctionReady(baseARN);
|
|
244
|
+
this.log.info('--: updating Lambda function code...');
|
|
245
|
+
await this._lambda.send(new UpdateFunctionCodeCommand({
|
|
246
|
+
FunctionName: functionName,
|
|
247
|
+
...functionConfig.Code,
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
await this.checkFunctionReady(baseARN);
|
|
251
|
+
|
|
252
|
+
this.log.info('--: publishing new version');
|
|
251
253
|
const versiondata = await this._lambda.send(new PublishVersionCommand({
|
|
252
254
|
FunctionName: functionName,
|
|
253
255
|
}));
|
|
@@ -255,22 +257,23 @@ class AWSDeployer extends BaseDeployer {
|
|
|
255
257
|
this._functionARN = versiondata.FunctionArn;
|
|
256
258
|
// eslint-disable-next-line prefer-destructuring
|
|
257
259
|
this._accountId = this._functionARN.split(':')[4];
|
|
258
|
-
|
|
259
260
|
const versionNum = versiondata.Version;
|
|
261
|
+
this.log.info(chalk`{green ok}: version {yellow ${versionNum}} published.`);
|
|
262
|
+
|
|
260
263
|
try {
|
|
261
264
|
await this._lambda.send(new GetAliasCommand({
|
|
262
265
|
FunctionName: functionName,
|
|
263
266
|
Name: functionVersion,
|
|
264
267
|
}));
|
|
265
268
|
|
|
266
|
-
this.log.info(`--: updating existing alias ${functionName}:${functionVersion} to
|
|
269
|
+
this.log.info(chalk`--: updating existing alias {yellow ${functionName}:${functionVersion}} to version {yellow ${versionNum}}`);
|
|
267
270
|
const updatedata = await this._lambda.send(new UpdateAliasCommand({
|
|
268
271
|
FunctionName: functionName,
|
|
269
272
|
Name: functionVersion,
|
|
270
273
|
FunctionVersion: versionNum,
|
|
271
274
|
}));
|
|
272
|
-
|
|
273
275
|
this._aliasARN = updatedata.AliasArn;
|
|
276
|
+
this.log.info(chalk`{green ok}: alias {yellow ${this._aliasARN}} updated.`);
|
|
274
277
|
} catch (e) {
|
|
275
278
|
if (e.name === 'ResourceNotFoundException') {
|
|
276
279
|
this.log.info(`--: creating new alias ${functionName}:${functionVersion} at v${versionNum}`);
|
|
@@ -280,6 +283,7 @@ class AWSDeployer extends BaseDeployer {
|
|
|
280
283
|
FunctionVersion: versionNum,
|
|
281
284
|
}));
|
|
282
285
|
this._aliasARN = createdata.AliasArn;
|
|
286
|
+
this.log.info(chalk`{green ok}: alias {yellow ${this._aliasARN}} created.`);
|
|
283
287
|
} else {
|
|
284
288
|
this.log.error(`Unable to verify existence of Lambda alias ${functionName}:${functionVersion}`);
|
|
285
289
|
throw e;
|
|
@@ -422,7 +426,7 @@ class AWSDeployer extends BaseDeployer {
|
|
|
422
426
|
// ignore, most likely the permission already exists
|
|
423
427
|
}
|
|
424
428
|
|
|
425
|
-
this.log.info(chalk`{green ok:} function deployed: ${
|
|
429
|
+
this.log.info(chalk`{green ok:} function deployed: {blueBright ${this._functionURL}}`);
|
|
426
430
|
}
|
|
427
431
|
|
|
428
432
|
async test() {
|
|
@@ -530,7 +534,7 @@ class AWSDeployer extends BaseDeployer {
|
|
|
530
534
|
});
|
|
531
535
|
const unused = [];
|
|
532
536
|
if (filter) {
|
|
533
|
-
this.log.info(chalk`Integrations / Routes for {
|
|
537
|
+
this.log.info(chalk`Integrations / Routes for {grey ${filter}}`);
|
|
534
538
|
} else {
|
|
535
539
|
this.log.info('Integrations / Routes');
|
|
536
540
|
}
|
|
@@ -689,17 +693,17 @@ class AWSDeployer extends BaseDeployer {
|
|
|
689
693
|
}
|
|
690
694
|
}
|
|
691
695
|
|
|
692
|
-
async checkFunctionReady() {
|
|
696
|
+
async checkFunctionReady(arn) {
|
|
693
697
|
let tries = 3;
|
|
694
698
|
while (tries > 0) {
|
|
695
699
|
try {
|
|
696
700
|
tries -= 1;
|
|
697
701
|
this.log.info(chalk`--: checking function state ...`);
|
|
698
702
|
const { Configuration } = await this._lambda.send(new GetFunctionCommand({
|
|
699
|
-
FunctionName: this._functionARN,
|
|
703
|
+
FunctionName: arn ?? this._functionARN,
|
|
700
704
|
}));
|
|
701
|
-
if (Configuration.State !== 'Active') {
|
|
702
|
-
this.log.
|
|
705
|
+
if (Configuration.State !== 'Active' || Configuration.LastUpdateStatus === 'InProgress') {
|
|
706
|
+
this.log.info(chalk`{yellow !!:} function is {blue ${Configuration.State}} and last update was {blue ${Configuration.LastUpdateStatus}} (retry...)`);
|
|
703
707
|
} else {
|
|
704
708
|
this.log.info(chalk`{green ok:} function is {blue ${Configuration.State}} and last update was {blue ${Configuration.LastUpdateStatus}}.`);
|
|
705
709
|
return;
|
|
@@ -752,4 +756,3 @@ class AWSDeployer extends BaseDeployer {
|
|
|
752
756
|
}
|
|
753
757
|
|
|
754
758
|
AWSDeployer.Config = AWSConfig;
|
|
755
|
-
module.exports = AWSDeployer;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
class AzureConfig {
|
|
12
|
+
export default class AzureConfig {
|
|
13
13
|
constructor() {
|
|
14
14
|
Object.assign(this, {
|
|
15
15
|
appName: '',
|
|
@@ -36,5 +36,3 @@ class AzureConfig {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
module.exports = AzureConfig;
|
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const fs = require('fs');
|
|
15
|
-
const BaseDeployer = require('./BaseDeployer');
|
|
16
|
-
const AzureConfig = require('./AzureConfig.js');
|
|
12
|
+
import msRestNodeAuth from '@azure/ms-rest-nodeauth';
|
|
13
|
+
import { WebSiteManagementClient } from '@azure/arm-appservice';
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
import fs from 'fs';
|
|
16
|
+
import BaseDeployer from './BaseDeployer.js';
|
|
17
|
+
import AzureConfig from './AzureConfig.js';
|
|
18
|
+
|
|
19
|
+
export default class AzureDeployer extends BaseDeployer {
|
|
19
20
|
constructor(baseConfig, config) {
|
|
20
21
|
super(baseConfig);
|
|
21
22
|
Object.assign(this, {
|
|
@@ -229,4 +230,3 @@ class AzureDeployer extends BaseDeployer {
|
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
AzureDeployer.Config = AzureConfig;
|
|
232
|
-
module.exports = AzureDeployer;
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
import path from 'path';
|
|
13
|
+
import chalk from 'chalk-template';
|
|
14
|
+
import semver from 'semver';
|
|
15
|
+
import { h1, context } from '@adobe/helix-fetch';
|
|
16
16
|
|
|
17
|
-
class BaseDeployer {
|
|
17
|
+
export default class BaseDeployer {
|
|
18
18
|
constructor(cfg) {
|
|
19
19
|
this.isDeployer = true;
|
|
20
20
|
this.cfg = cfg;
|
|
@@ -42,8 +42,8 @@ class BaseDeployer {
|
|
|
42
42
|
getOrCreateFetchContext() {
|
|
43
43
|
if (!this._fetchContext) {
|
|
44
44
|
this._fetchContext = process.env.HELIX_FETCH_FORCE_HTTP1
|
|
45
|
-
?
|
|
46
|
-
:
|
|
45
|
+
? h1()
|
|
46
|
+
: context();
|
|
47
47
|
}
|
|
48
48
|
return this._fetchContext;
|
|
49
49
|
}
|
|
@@ -99,7 +99,7 @@ class BaseDeployer {
|
|
|
99
99
|
while (retry404 >= 0) {
|
|
100
100
|
// eslint-disable-next-line no-param-reassign
|
|
101
101
|
const testUrl = `${url}${this.cfg.testPath || ''}`;
|
|
102
|
-
this.log.info(`--: requesting: ${
|
|
102
|
+
this.log.info(chalk`--: requesting: {blueBright ${testUrl}} ...`);
|
|
103
103
|
// eslint-disable-next-line no-await-in-loop
|
|
104
104
|
const ret = await this.fetch(testUrl, {
|
|
105
105
|
headers,
|
|
@@ -110,21 +110,21 @@ class BaseDeployer {
|
|
|
110
110
|
const body = await ret.text();
|
|
111
111
|
const id = idHeader ? ret.headers.get(idHeader) : 'n/a';
|
|
112
112
|
if (ret.ok) {
|
|
113
|
-
this.log.info(`id: ${
|
|
114
|
-
this.log.info(
|
|
115
|
-
this.log.debug(chalk
|
|
113
|
+
this.log.info(chalk`id: {grey ${id}}`);
|
|
114
|
+
this.log.info(chalk`{green ok:} ${ret.status}`);
|
|
115
|
+
this.log.debug(chalk`{grey ${JSON.stringify(ret.headers.plain(), null, 2)}}`);
|
|
116
116
|
this.log.debug('');
|
|
117
|
-
this.log.debug(chalk
|
|
117
|
+
this.log.debug(chalk`{grey ${body}}`);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
if (ret.status === 302 || ret.status === 301) {
|
|
121
|
-
this.log.info(
|
|
122
|
-
this.log.debug(chalk
|
|
121
|
+
this.log.info(chalk`{green ok:} ${ret.status}`);
|
|
122
|
+
this.log.debug(chalk`{grey Location: ${ret.headers.get('location')}}`);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
this.log.info(`id: ${
|
|
125
|
+
this.log.info(chalk`id: {grey ${id}}`);
|
|
126
126
|
if ((ret.status === 404 || ret.status === 500) && retry404) {
|
|
127
|
-
this.log.info(
|
|
127
|
+
this.log.info(chalk`{yellow warn:} ${ret.status} (retry)`);
|
|
128
128
|
// eslint-disable-next-line no-param-reassign
|
|
129
129
|
retry404 -= 1;
|
|
130
130
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -132,7 +132,7 @@ class BaseDeployer {
|
|
|
132
132
|
setTimeout(resolve, 1500);
|
|
133
133
|
});
|
|
134
134
|
} else {
|
|
135
|
-
// this.log.info(
|
|
135
|
+
// this.log.info(chalk`{red error:} test failed: ${ret.status} ${body}`);
|
|
136
136
|
throw new Error(`test failed: ${ret.status} ${body}`);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -164,7 +164,7 @@ class BaseDeployer {
|
|
|
164
164
|
if (link === 'major' || link === 'minor') {
|
|
165
165
|
if (!s) {
|
|
166
166
|
// eslint-disable-next-line no-underscore-dangle
|
|
167
|
-
this.log.warn(
|
|
167
|
+
this.log.warn(chalk`{yellow warn:} unable to create version sequences. error while parsing version: ${this.cfg.version}`);
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
if (link === 'major') {
|
|
@@ -179,5 +179,3 @@ class BaseDeployer {
|
|
|
179
179
|
return sfx;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
|
|
183
|
-
module.exports = BaseDeployer;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
class CloudflareConfig {
|
|
12
|
+
export default class CloudflareConfig {
|
|
13
13
|
constructor() {
|
|
14
14
|
Object.assign(this, {});
|
|
15
15
|
}
|
|
@@ -67,5 +67,3 @@ class CloudflareConfig {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
module.exports = CloudflareConfig;
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
import path from 'path';
|
|
13
|
+
import fs from 'fs';
|
|
14
|
+
import FormData from 'form-data';
|
|
15
|
+
import BaseDeployer from './BaseDeployer.js';
|
|
16
|
+
import CloudflareConfig from './CloudflareConfig.js';
|
|
17
17
|
|
|
18
|
-
class CloudflareDeployer extends BaseDeployer {
|
|
18
|
+
export default class CloudflareDeployer extends BaseDeployer {
|
|
19
19
|
constructor(baseConfig, config) {
|
|
20
20
|
super(baseConfig);
|
|
21
21
|
Object.assign(this, {
|
|
@@ -142,4 +142,3 @@ class CloudflareDeployer extends BaseDeployer {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
CloudflareDeployer.Config = CloudflareConfig;
|
|
145
|
-
module.exports = CloudflareDeployer;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
class ComputeAtEdgeConfig {
|
|
12
|
+
export default class ComputeAtEdgeConfig {
|
|
13
13
|
constructor() {
|
|
14
14
|
Object.assign(this, {});
|
|
15
15
|
}
|
|
@@ -89,5 +89,3 @@ class ComputeAtEdgeConfig {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
module.exports = ComputeAtEdgeConfig;
|
|
@@ -9,14 +9,18 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
import { fork } from 'child_process';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import fs from 'fs/promises';
|
|
16
|
+
import tar from 'tar';
|
|
17
|
+
import getStream from 'get-stream';
|
|
18
|
+
import Fastly from '@adobe/fastly-native-promises';
|
|
19
|
+
import BaseDeployer from './BaseDeployer.js';
|
|
20
|
+
import ComputeAtEdgeConfig from './ComputeAtEdgeConfig.js';
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
23
|
+
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* The class ComputeAtEdgeDeployer deploys to Fastly's Compute(at)Edge (WASM) runtime.
|
|
@@ -24,7 +28,7 @@ const ComputeAtEdgeConfig = require('./ComputeAtEdgeConfig');
|
|
|
24
28
|
* and not confused with the FastlyGateway (which only routes requests, but
|
|
25
29
|
* does not handle them.)
|
|
26
30
|
*/
|
|
27
|
-
class ComputeAtEdgeDeployer extends BaseDeployer {
|
|
31
|
+
export default class ComputeAtEdgeDeployer extends BaseDeployer {
|
|
28
32
|
constructor(baseConfig, config) {
|
|
29
33
|
super(baseConfig);
|
|
30
34
|
Object.assign(this, {
|
|
@@ -187,4 +191,3 @@ service_id = ""
|
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
ComputeAtEdgeDeployer.Config = ComputeAtEdgeConfig;
|
|
190
|
-
module.exports = ComputeAtEdgeDeployer;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
class GoogleConfig {
|
|
12
|
+
export default class GoogleConfig {
|
|
13
13
|
constructor() {
|
|
14
14
|
Object.assign(this, {
|
|
15
15
|
appName: '',
|
|
@@ -69,5 +69,3 @@ class GoogleConfig {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
module.exports = GoogleConfig;
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class GoogleDeployer extends BaseDeployer {
|
|
12
|
+
import { CloudFunctionsServiceClient } from '@google-cloud/functions';
|
|
13
|
+
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import fs from 'fs';
|
|
16
|
+
import semver from 'semver';
|
|
17
|
+
import chalk from 'chalk-template';
|
|
18
|
+
import BaseDeployer from './BaseDeployer.js';
|
|
19
|
+
import GoogleConfig from './GoogleConfig.js';
|
|
20
|
+
import { filterActions } from '../utils.js';
|
|
21
|
+
|
|
22
|
+
export default class GoogleDeployer extends BaseDeployer {
|
|
23
23
|
constructor(baseConfig, config) {
|
|
24
24
|
super(baseConfig);
|
|
25
25
|
Object.assign(this, {
|
|
@@ -344,4 +344,3 @@ class GoogleDeployer extends BaseDeployer {
|
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
GoogleDeployer.Config = GoogleConfig;
|
|
347
|
-
module.exports = GoogleDeployer;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @field {string} actionName Action as it would be deployed (package + name)
|
|
15
15
|
* @field {boolean} packageShared If package is shared.
|
|
16
16
|
*/
|
|
17
|
-
class OpenWhiskConfig {
|
|
17
|
+
export default class OpenWhiskConfig {
|
|
18
18
|
constructor() {
|
|
19
19
|
Object.assign(this, {
|
|
20
20
|
namespace: '',
|
|
@@ -52,5 +52,3 @@ class OpenWhiskConfig {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
module.exports = OpenWhiskConfig;
|
|
@@ -10,18 +10,16 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
/* eslint-disable no-underscore-dangle */
|
|
13
|
+
import ow from 'openwhisk';
|
|
14
|
+
import os from 'os';
|
|
15
|
+
import fse from 'fs-extra';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import chalk from 'chalk-template';
|
|
18
|
+
import dotenv from 'dotenv';
|
|
19
|
+
import BaseDeployer from './BaseDeployer.js';
|
|
20
|
+
import OpenWhiskConfig from './OpenWhiskConfig.js';
|
|
13
21
|
|
|
14
|
-
|
|
15
|
-
const os = require('os');
|
|
16
|
-
const fse = require('fs-extra');
|
|
17
|
-
const path = require('path');
|
|
18
|
-
const chalk = require('chalk');
|
|
19
|
-
const dotenv = require('dotenv');
|
|
20
|
-
|
|
21
|
-
const BaseDeployer = require('./BaseDeployer');
|
|
22
|
-
const OpenWhiskConfig = require('./OpenWhiskConfig.js');
|
|
23
|
-
|
|
24
|
-
class OpenWhiskDeployer extends BaseDeployer {
|
|
22
|
+
export default class OpenWhiskDeployer extends BaseDeployer {
|
|
25
23
|
constructor(baseConfig, config) {
|
|
26
24
|
super(baseConfig);
|
|
27
25
|
|
|
@@ -88,7 +86,7 @@ class OpenWhiskDeployer extends BaseDeployer {
|
|
|
88
86
|
|
|
89
87
|
getOpenwhiskClient() {
|
|
90
88
|
if (!this._cfg.apiHost || !this._cfg.auth || !this._cfg.namespace) {
|
|
91
|
-
throw Error(chalk`\nMissing OpenWhisk credentials. Make sure you have a {grey .wskprops} in your home directory.\nYou can also set {grey WSK_NAMESPACE}, {
|
|
89
|
+
throw Error(chalk`\nMissing OpenWhisk credentials. Make sure you have a {grey .wskprops} in your home directory.\nYou can also set {grey WSK_NAMESPACE}, {grey WSK_AUTH} and {grey WSK_API_HOST} environment variables.`);
|
|
92
90
|
}
|
|
93
91
|
return ow({
|
|
94
92
|
apihost: this._cfg.apiHost,
|
|
@@ -117,7 +115,7 @@ class OpenWhiskDeployer extends BaseDeployer {
|
|
|
117
115
|
});
|
|
118
116
|
this.log.info(chalk`{green ok:} package created. ${res.namespace}/${res.name}`);
|
|
119
117
|
} else {
|
|
120
|
-
this.log.error(
|
|
118
|
+
this.log.error(chalk`{red error:} ${e.message}`);
|
|
121
119
|
}
|
|
122
120
|
}
|
|
123
121
|
|
|
@@ -187,7 +185,7 @@ class OpenWhiskDeployer extends BaseDeployer {
|
|
|
187
185
|
fn = openwhisk.packages.create.bind(openwhisk.packages);
|
|
188
186
|
verb = 'created';
|
|
189
187
|
} else {
|
|
190
|
-
this.log.error(
|
|
188
|
+
this.log.error(chalk`{red error:} ${e.message}`);
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
191
|
|
|
@@ -203,9 +201,9 @@ class OpenWhiskDeployer extends BaseDeployer {
|
|
|
203
201
|
parameters,
|
|
204
202
|
},
|
|
205
203
|
});
|
|
206
|
-
this.log.info(
|
|
204
|
+
this.log.info(chalk`{green ok:} ${verb} package {whiteBright /${result.namespace}/${result.name}}`);
|
|
207
205
|
} catch (e) {
|
|
208
|
-
this.log.error(
|
|
206
|
+
this.log.error(chalk`{red error: failed processing package: } ${e.stack}`);
|
|
209
207
|
throw Error('abort.');
|
|
210
208
|
}
|
|
211
209
|
}
|
|
@@ -270,10 +268,10 @@ class OpenWhiskDeployer extends BaseDeployer {
|
|
|
270
268
|
try {
|
|
271
269
|
this.log.debug(`creating sequence: ${options.name} -> ${options.action.exec.components[0]}`);
|
|
272
270
|
const result = await openwhisk.actions.update(options);
|
|
273
|
-
this.log.info(
|
|
271
|
+
this.log.info(chalk`{green ok:} created sequence {whiteBright /${result.namespace}/${result.name}} -> {whiteBright ${fqn}}`);
|
|
274
272
|
} catch (e) {
|
|
275
273
|
hasErrors = true;
|
|
276
|
-
this.log.error(
|
|
274
|
+
this.log.error(chalk`{red error:} failed creating sequence: ${e.message}`);
|
|
277
275
|
}
|
|
278
276
|
}));
|
|
279
277
|
if (hasErrors) {
|
|
@@ -283,4 +281,3 @@ class OpenWhiskDeployer extends BaseDeployer {
|
|
|
283
281
|
}
|
|
284
282
|
|
|
285
283
|
OpenWhiskDeployer.Config = OpenWhiskConfig;
|
|
286
|
-
module.exports = OpenWhiskDeployer;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
class FastlyConfig {
|
|
12
|
+
export default class FastlyConfig {
|
|
13
13
|
constructor() {
|
|
14
14
|
Object.assign(this, {
|
|
15
15
|
service: null,
|
|
@@ -94,5 +94,3 @@ class FastlyConfig {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
module.exports = FastlyConfig;
|
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import Fastly from '@adobe/fastly-native-promises';
|
|
13
|
+
import chalk from 'chalk-template';
|
|
14
|
+
import FastlyConfig from './FastlyConfig.js';
|
|
15
|
+
import BaseDeployer from '../deploy/BaseDeployer.js';
|
|
16
|
+
|
|
14
17
|
const {
|
|
15
18
|
toString, vcl, time, req, res, str, concat,
|
|
16
|
-
} =
|
|
17
|
-
const FastlyConfig = require('./FastlyConfig.js');
|
|
18
|
-
const BaseDeployer = require('../deploy/BaseDeployer.js');
|
|
19
|
+
} = Fastly.loghelpers;
|
|
19
20
|
|
|
20
|
-
class FastlyGateway {
|
|
21
|
+
export default class FastlyGateway {
|
|
21
22
|
constructor(baseConfig, config) {
|
|
22
23
|
Object.assign(this, {
|
|
23
24
|
cfg: baseConfig,
|
|
@@ -505,4 +506,3 @@ if (req.url ~ "^/([^/]+)/([^/@_]+)([@_]([^/@_?]+)+)?(.*$)") {
|
|
|
505
506
|
}
|
|
506
507
|
|
|
507
508
|
FastlyGateway.Config = FastlyConfig;
|
|
508
|
-
module.exports = FastlyGateway;
|