@adobe/helix-deploy 4.14.0 → 5.0.0

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.
@@ -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
- const chalk = require('chalk');
14
- const {
15
- S3Client,
16
- CreateBucketCommand,
13
+ import chalk from 'chalk';
14
+ import {
15
+ CreateBucketCommand, DeleteBucketCommand, DeleteObjectCommand, DeleteObjectsCommand,
17
16
  ListBucketsCommand,
18
- ListObjectsV2Command,
19
- PutObjectCommand,
20
- DeleteBucketCommand,
21
- DeleteObjectCommand,
22
- DeleteObjectsCommand,
23
- } = require('@aws-sdk/client-s3');
24
- const {
25
- LambdaClient,
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
- UpdateFunctionCodeCommand,
30
- GetAliasCommand,
31
- PublishVersionCommand,
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
- CreateRouteCommand,
47
- GetRoutesCommand,
48
- UpdateRouteCommand,
49
- } = require('@aws-sdk/client-apigatewayv2');
50
- const {
51
- SSMClient,
52
- PutParameterCommand,
53
- } = require('@aws-sdk/client-ssm');
54
- const {
55
- SecretsManagerClient,
56
- PutSecretValueCommand,
57
- } = require('@aws-sdk/client-secrets-manager');
58
-
59
- const path = require('path');
60
- const fse = require('fs-extra');
61
- const crypto = require('crypto');
62
- const BaseDeployer = require('./BaseDeployer');
63
- const ActionBuilder = require('../ActionBuilder.js');
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
 
@@ -752,4 +739,3 @@ class AWSDeployer extends BaseDeployer {
752
739
  }
753
740
 
754
741
  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
- const msRestNodeAuth = require('@azure/ms-rest-nodeauth');
13
- const { WebSiteManagementClient } = require('@azure/arm-appservice');
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
- class AzureDeployer extends BaseDeployer {
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
- const path = require('path');
13
- const chalk = require('chalk');
14
- const semver = require('semver');
15
- const fetchAPI = require('@adobe/helix-fetch');
12
+ import path from 'path';
13
+ import chalk from 'chalk';
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
- ? fetchAPI.h1()
46
- : fetchAPI.context();
45
+ ? h1()
46
+ : context();
47
47
  }
48
48
  return this._fetchContext;
49
49
  }
@@ -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,19 +9,20 @@
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
- const path = require('path');
13
- const fs = require('fs');
14
- const FormData = require('form-data');
15
- const BaseDeployer = require('./BaseDeployer');
16
- const CloudflareConfig = require('./CloudflareConfig');
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, {
22
22
  id: 'cloudflare',
23
23
  name: 'Cloudflare',
24
24
  _cfg: config,
25
+ noGatewayBackend: true,
25
26
  });
26
27
  }
27
28
 
@@ -141,4 +142,3 @@ class CloudflareDeployer extends BaseDeployer {
141
142
  }
142
143
 
143
144
  CloudflareDeployer.Config = CloudflareConfig;
144
- 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
- const { fork } = require('child_process');
13
- const path = require('path');
14
- const fs = require('fs/promises');
15
- const tar = require('tar');
16
- const getStream = require('get-stream');
17
- const Fastly = require('@adobe/fastly-native-promises');
18
- const BaseDeployer = require('./BaseDeployer');
19
- const ComputeAtEdgeConfig = require('./ComputeAtEdgeConfig');
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, {
@@ -32,6 +36,7 @@ class ComputeAtEdgeDeployer extends BaseDeployer {
32
36
  name: 'Fastly Compute@Edge',
33
37
  _cfg: config,
34
38
  _fastly: null,
39
+ noGatewayBackend: true,
35
40
  });
36
41
  }
37
42
 
@@ -186,4 +191,3 @@ service_id = ""
186
191
  }
187
192
 
188
193
  ComputeAtEdgeDeployer.Config = ComputeAtEdgeConfig;
189
- 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,16 +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
- const { CloudFunctionsServiceClient } = require('@google-cloud/functions');
13
- const { SecretManagerServiceClient } = require('@google-cloud/secret-manager');
14
- const path = require('path');
15
- const fs = require('fs');
16
- const semver = require('semver');
17
- const BaseDeployer = require('./BaseDeployer');
18
- const GoogleConfig = require('./GoogleConfig.js');
19
- const { filterActions } = require('../utils.js');
20
-
21
- 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';
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 {
22
23
  constructor(baseConfig, config) {
23
24
  super(baseConfig);
24
25
  Object.assign(this, {
@@ -59,7 +60,7 @@ class GoogleDeployer extends BaseDeployer {
59
60
  projectId: this._cfg.projectID,
60
61
  });
61
62
  } catch (e) {
62
- this.log.error(`Unable to authenticate with Google: ${e.message}`);
63
+ this.log.error(chalk`{red error:} Unable to authenticate with Google: ${e.message}`);
63
64
  throw e;
64
65
  }
65
66
  }
@@ -82,9 +83,9 @@ class GoogleDeployer extends BaseDeployer {
82
83
  },
83
84
  secretId,
84
85
  });
85
- this.log.info(`Created secret ${secret.name}`);
86
+ this.log.info(`--: Created secret ${secret.name}`);
86
87
  } catch {
87
- this.log.info('Using existing secret');
88
+ this.log.info('--: Using existing secret');
88
89
  [secret] = await this._secretclient.getSecret({
89
90
  name: `${parent}/secrets/${secretId}`,
90
91
  });
@@ -98,7 +99,7 @@ class GoogleDeployer extends BaseDeployer {
98
99
  },
99
100
  });
100
101
 
101
- this.log.info(`Added secret version ${version.name}`);
102
+ this.log.info(chalk`{green ok}: Added secret version ${version.name}`);
102
103
 
103
104
  /*
104
105
  const [retversion] = await this._secretclient.accessSecretVersion({
@@ -191,23 +192,23 @@ class GoogleDeployer extends BaseDeployer {
191
192
  function: func,
192
193
  });
193
194
 
194
- this.log.info('updating existing function');
195
+ this.log.info('--: updating existing function');
195
196
  const [res] = await op.promise();
196
197
  this._function = res;
197
- this.log.info('function deployed');
198
+ this.log.info(chalk`{green ok:} function deployed`);
198
199
  } else {
199
200
  const [op] = await this._client.createFunction({
200
201
  location: `projects/${this._cfg.projectID}/locations/${this._cfg.region}`,
201
202
  function: func,
202
203
  });
203
204
 
204
- this.log.info('creating function, please wait (Google deployments are slow).');
205
+ this.log.info('--: creating function, please wait (Google deployments are slow).');
205
206
  const [res] = await op.promise();
206
207
  this._function = res;
207
- this.log.info('function deployed');
208
+ this.log.info(chalk`{green ok:} function deployed`);
208
209
  }
209
210
 
210
- this.log.info('enabling unauthenticated requests');
211
+ this.log.info('--: enabling unauthenticated requests');
211
212
  await this._client.setIamPolicy({
212
213
  resource: name,
213
214
  policy: {
@@ -222,11 +223,8 @@ class GoogleDeployer extends BaseDeployer {
222
223
  },
223
224
  });
224
225
  } catch (err) {
225
- this.log.error(err);
226
- // eslint-disable-next-line max-len
227
- this.log.error('bad request:', err.metadata.internalRepr.get('google.rpc.badrequest-bin').toString());
228
- // eslint-disable-next-line max-len
229
- this.log.error('details:', err.metadata.internalRepr.get('grpc-status-details-bin').toString());
226
+ this.log.error(chalk`{red error:} bad request: ${err.metadata.internalRepr.get('google.rpc.badrequest-bin').toString()}`);
227
+ this.log.error(chalk`{red error:} details: ${err.metadata.internalRepr.get('grpc-status-details-bin').toString()}`);
230
228
  throw err;
231
229
  }
232
230
 
@@ -239,8 +237,7 @@ class GoogleDeployer extends BaseDeployer {
239
237
  await this.createFunction();
240
238
  } catch (err) {
241
239
  const message = err.metadata ? err.metadata.get('grpc-status-details-bin')[0].toString() : err.message;
242
- this.log.error(`Unable to deploy Google Cloud function: ${message}`, err.metadata);
243
-
240
+ this.log.error(chalk`{red error:} Unable to deploy Google Cloud function: ${message}`, err.metadata);
244
241
  throw err;
245
242
  }
246
243
  }
@@ -299,15 +296,14 @@ class GoogleDeployer extends BaseDeployer {
299
296
  },
300
297
  versionspec,
301
298
  ).map((fn) => {
302
- this.log.info(`Cleaning up outdated function '${fn.fqName}`);
299
+ this.log.info(`--: Cleaning up outdated function '${fn.fqName}`);
303
300
 
304
301
  return this._client.deleteFunction({
305
302
  name: fn.fqName,
306
303
  });
307
304
  }));
308
305
  } catch (e) {
309
- this.log.error('Cleanup failed, proceeding anyway.');
310
- this.log.error(e);
306
+ this.log.error(chalk`{red error:} Cleanup failed, proceeding anyway.`, e);
311
307
  }
312
308
  }
313
309
 
@@ -348,4 +344,3 @@ class GoogleDeployer extends BaseDeployer {
348
344
  }
349
345
 
350
346
  GoogleDeployer.Config = GoogleConfig;
351
- 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';
18
+ import dotenv from 'dotenv';
19
+ import BaseDeployer from './BaseDeployer.js';
20
+ import OpenWhiskConfig from './OpenWhiskConfig.js';
13
21
 
14
- const ow = require('openwhisk');
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
 
@@ -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;