@adobe/helix-deploy 4.15.0 → 5.0.2
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 +36 -50
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## [5.0.2](https://github.com/adobe/helix-deploy/compare/v5.0.1...v5.0.2) (2021-12-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update external fixes ([b898a1d](https://github.com/adobe/helix-deploy/commit/b898a1da4e06a20cb616cf524458a98608124e6c))
|
|
7
|
+
|
|
8
|
+
## [5.0.1](https://github.com/adobe/helix-deploy/compare/v5.0.0...v5.0.1) (2021-12-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update external fixes ([eca546c](https://github.com/adobe/helix-deploy/commit/eca546ce271ba6c6d37fcf1572f5d1d0f5c068b2))
|
|
14
|
+
|
|
15
|
+
# [5.0.0](https://github.com/adobe/helix-deploy/compare/v4.15.1...v5.0.0) (2021-12-02)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* convert to ESM ([2946721](https://github.com/adobe/helix-deploy/commit/294672121135f32495cc48e58f636553b3473489))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### BREAKING CHANGES
|
|
24
|
+
|
|
25
|
+
* exported APIs only available through ESM
|
|
26
|
+
|
|
27
|
+
## [4.15.1](https://github.com/adobe/helix-deploy/compare/v4.15.0...v4.15.1) (2021-11-20)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **deps:** update external fixes ([21e2af6](https://github.com/adobe/helix-deploy/commit/21e2af69186b80607747d390aa4f98507b02e070))
|
|
33
|
+
|
|
1
34
|
# [4.15.0](https://github.com/adobe/helix-deploy/compare/v4.14.1...v4.15.0) (2021-11-20)
|
|
2
35
|
|
|
3
36
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -72,3 +72,9 @@ The project's committers will release to the [Adobe organization on npmjs.org](h
|
|
|
72
72
|
Please contact the [Adobe Open Source Advisory Board](https://git.corp.adobe.com/OpenSourceAdvisoryBoard/discuss/issues) to get access to the npmjs organization.
|
|
73
73
|
|
|
74
74
|
The release process is fully automated using `semantic-release`, increasing the version numbers, etc. based on the contents of the commit messages found.
|
|
75
|
+
|
|
76
|
+
# Managing Secrets
|
|
77
|
+
|
|
78
|
+
## Azure
|
|
79
|
+
|
|
80
|
+
The Azure deployment is using an application secret that is expiring on a regular basis. To update the secret, refer to the [Azure Active Directory Documentation on configuring access policies on resources](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#option-2-create-a-new-application-secret)
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-deploy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Library and Commandline Tools to build and deploy OpenWhisk Actions",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://github.com/adobe/helix-deploy#readme",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "https://github.com/adobe/helix-deploy.git"
|
|
@@ -15,15 +16,17 @@
|
|
|
15
16
|
"serverless"
|
|
16
17
|
],
|
|
17
18
|
"main": "index.js",
|
|
19
|
+
"type": "module",
|
|
18
20
|
"bin": {
|
|
19
21
|
"hedy": "src/index.js"
|
|
20
22
|
},
|
|
21
23
|
"scripts": {
|
|
22
24
|
"lint": "eslint .",
|
|
23
|
-
"test": "
|
|
24
|
-
"test-ci": "npm run lint &&
|
|
25
|
-
"integration-ci": "
|
|
26
|
-
"semantic-release": "semantic-release"
|
|
25
|
+
"test": "c8 mocha -i -g Integration",
|
|
26
|
+
"test-ci": "npm run lint && c8 mocha -i -g Integration && codecov",
|
|
27
|
+
"integration-ci": "c8 mocha -g Integration && codecov",
|
|
28
|
+
"semantic-release": "semantic-release",
|
|
29
|
+
"prepare": "husky install"
|
|
27
30
|
},
|
|
28
31
|
"mocha": {
|
|
29
32
|
"reporter": "mocha-multi-reporters",
|
|
@@ -36,38 +39,38 @@
|
|
|
36
39
|
"dependencies": {
|
|
37
40
|
"@adobe/fastly-native-promises": "2.0.0",
|
|
38
41
|
"@adobe/helix-fetch": "3.0.0",
|
|
39
|
-
"@aws-sdk/client-apigatewayv2": "3.
|
|
40
|
-
"@aws-sdk/client-lambda": "3.
|
|
41
|
-
"@aws-sdk/client-s3": "3.
|
|
42
|
-
"@aws-sdk/client-secrets-manager": "3.
|
|
43
|
-
"@aws-sdk/client-ssm": "3.
|
|
42
|
+
"@aws-sdk/client-apigatewayv2": "3.43.0",
|
|
43
|
+
"@aws-sdk/client-lambda": "3.43.0",
|
|
44
|
+
"@aws-sdk/client-s3": "3.44.0",
|
|
45
|
+
"@aws-sdk/client-secrets-manager": "3.43.0",
|
|
46
|
+
"@aws-sdk/client-ssm": "3.44.0",
|
|
44
47
|
"@azure/arm-appservice": "9.0.0",
|
|
45
48
|
"@azure/ms-rest-nodeauth": "3.1.0",
|
|
46
49
|
"@fastly/js-compute": "0.2.1",
|
|
47
50
|
"@google-cloud/functions": "1.2.0",
|
|
48
51
|
"@google-cloud/secret-manager": "3.10.1",
|
|
49
|
-
"@google-cloud/storage": "5.16.
|
|
52
|
+
"@google-cloud/storage": "5.16.1",
|
|
50
53
|
"@rollup/plugin-alias": "3.1.8",
|
|
51
54
|
"@rollup/plugin-commonjs": "21.0.1",
|
|
52
55
|
"@rollup/plugin-json": "4.1.0",
|
|
53
56
|
"@rollup/plugin-node-resolve": "13.0.6",
|
|
54
57
|
"archiver": "5.3.0",
|
|
55
|
-
"chalk": "
|
|
58
|
+
"chalk-template": "0.2.0",
|
|
56
59
|
"constants-browserify": "1.0.0",
|
|
57
60
|
"dotenv": "10.0.0",
|
|
58
61
|
"express": "4.17.1",
|
|
59
62
|
"form-data": "4.0.0",
|
|
60
63
|
"fs-extra": "10.0.0",
|
|
61
64
|
"get-stream": "6.0.1",
|
|
62
|
-
"isomorphic-git": "1.10.
|
|
65
|
+
"isomorphic-git": "1.10.2",
|
|
63
66
|
"openwhisk": "3.21.5",
|
|
64
67
|
"proxyquire": "2.1.3",
|
|
65
|
-
"rollup": "2.
|
|
68
|
+
"rollup": "2.61.1",
|
|
66
69
|
"rollup-plugin-terser": "7.0.2",
|
|
67
70
|
"semver": "7.3.5",
|
|
68
71
|
"tar": "6.1.11",
|
|
69
|
-
"webpack": "5.
|
|
70
|
-
"yargs": "17.
|
|
72
|
+
"webpack": "5.65.0",
|
|
73
|
+
"yargs": "17.3.0"
|
|
71
74
|
},
|
|
72
75
|
"devDependencies": {
|
|
73
76
|
"@adobe/eslint-config-helix": "1.3.1",
|
|
@@ -76,20 +79,20 @@
|
|
|
76
79
|
"@adobe/helix-universal-logger": "2.0.0",
|
|
77
80
|
"@semantic-release/changelog": "6.0.1",
|
|
78
81
|
"@semantic-release/git": "10.0.1",
|
|
82
|
+
"c8": "7.10.0",
|
|
79
83
|
"chai": "4.3.4",
|
|
80
84
|
"chai-http": "4.3.0",
|
|
81
85
|
"codecov": "3.8.3",
|
|
82
|
-
"eslint": "8.
|
|
86
|
+
"eslint": "8.4.1",
|
|
83
87
|
"eslint-plugin-header": "3.1.1",
|
|
84
88
|
"eslint-plugin-import": "2.25.3",
|
|
85
|
-
"
|
|
86
|
-
"lint-staged": "12.
|
|
89
|
+
"husky": "7.0.4",
|
|
90
|
+
"lint-staged": "12.1.2",
|
|
87
91
|
"mocha": "9.1.3",
|
|
88
92
|
"mocha-junit-reporter": "2.0.2",
|
|
89
93
|
"mocha-multi-reporters": "1.5.1",
|
|
90
94
|
"nock": "13.2.1",
|
|
91
|
-
"
|
|
92
|
-
"semantic-release": "18.0.0",
|
|
95
|
+
"semantic-release": "18.0.1",
|
|
93
96
|
"sinon": "12.0.1",
|
|
94
97
|
"yauzl": "2.10.0"
|
|
95
98
|
},
|
|
@@ -98,11 +101,5 @@
|
|
|
98
101
|
},
|
|
99
102
|
"lint-staged": {
|
|
100
103
|
"*.js": "eslint"
|
|
101
|
-
}
|
|
102
|
-
"config": {
|
|
103
|
-
"ghooks": {
|
|
104
|
-
"pre-commit": "npx lint-staged"
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"homepage": "https://github.com/adobe/helix-deploy#readme"
|
|
104
|
+
}
|
|
108
105
|
}
|
package/src/ActionBuilder.js
CHANGED
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
*/
|
|
12
12
|
/* eslint-disable no-await-in-loop */
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import fs from 'fs';
|
|
16
|
+
import fse from 'fs-extra';
|
|
17
|
+
import chalk from 'chalk-template';
|
|
18
|
+
import git from 'isomorphic-git';
|
|
19
|
+
import WebpackBundler from './bundler/WebpackBundler.js';
|
|
20
|
+
import EdgeBundler from './bundler/EdgeBundler.js';
|
|
21
|
+
import RollupBundler from './bundler/RollupBundler.js';
|
|
22
|
+
import pkgJson from './package.cjs';
|
|
23
23
|
|
|
24
24
|
const Bundlers = {
|
|
25
25
|
node: {
|
|
@@ -62,7 +62,7 @@ async function getCurrentRevision(dir) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
export default class ActionBuilder {
|
|
66
66
|
/**
|
|
67
67
|
* Iterates the given params and resolves potential file references.
|
|
68
68
|
* @param {object} params the params
|
|
@@ -310,7 +310,7 @@ module.exports = class ActionBuilder {
|
|
|
310
310
|
// eslint-disable-next-line no-await-in-loop
|
|
311
311
|
await dep[fnName](...args);
|
|
312
312
|
} catch (e) {
|
|
313
|
-
cfg.log.error(
|
|
313
|
+
cfg.log.error(chalk`{red error:} ${dep.name} - ${e.message}`);
|
|
314
314
|
errors.push(e);
|
|
315
315
|
}
|
|
316
316
|
}
|
|
@@ -338,7 +338,7 @@ module.exports = class ActionBuilder {
|
|
|
338
338
|
async updateLinks() {
|
|
339
339
|
const { cfg } = this;
|
|
340
340
|
if (cfg.baseName === cfg.name) {
|
|
341
|
-
cfg.log.warn(
|
|
341
|
+
cfg.log.warn(chalk`{yellow warn:} unable to create version links. unsupported action name format. should be: "name@version"`);
|
|
342
342
|
return false;
|
|
343
343
|
}
|
|
344
344
|
return this.execute('updateLinks', 'updating links on ');
|
|
@@ -372,7 +372,7 @@ module.exports = class ActionBuilder {
|
|
|
372
372
|
|
|
373
373
|
async _run() {
|
|
374
374
|
const { cfg } = this;
|
|
375
|
-
cfg.log.info(chalk`{grey universal-action-builder v${version}}`);
|
|
375
|
+
cfg.log.info(chalk`{grey universal-action-builder v${pkgJson.version}}`);
|
|
376
376
|
await this.validate();
|
|
377
377
|
await this.validateAdditionalTasks();
|
|
378
378
|
await this.validateBundlers();
|
|
@@ -466,4 +466,4 @@ module.exports = class ActionBuilder {
|
|
|
466
466
|
await this.runAdditionalTasks();
|
|
467
467
|
return '';
|
|
468
468
|
}
|
|
469
|
-
}
|
|
469
|
+
}
|
package/src/BaseConfig.js
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
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 crypto from 'crypto';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import fse from 'fs-extra';
|
|
15
|
+
import chalk from 'chalk-template';
|
|
16
|
+
import dotenv from 'dotenv';
|
|
17
17
|
|
|
18
18
|
// eslint-disable-next-line no-template-curly-in-string
|
|
19
19
|
const DEFAULT_ACTION_FORMAT = '/${packageName}/${baseName}/${version}';
|
|
@@ -41,7 +41,7 @@ function coerceDate(value) {
|
|
|
41
41
|
* @field baseName Name of the function w/o the version. eg `my-action`
|
|
42
42
|
* @field packageName Name of the function package. eg `my-package`
|
|
43
43
|
*/
|
|
44
|
-
class BaseConfig {
|
|
44
|
+
export default class BaseConfig {
|
|
45
45
|
constructor() {
|
|
46
46
|
Object.assign(this, {
|
|
47
47
|
cwd: process.cwd(),
|
|
@@ -806,5 +806,3 @@ class BaseConfig {
|
|
|
806
806
|
});
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
|
-
|
|
810
|
-
module.exports = BaseConfig;
|
package/src/DevelopmentServer.js
CHANGED
|
@@ -9,12 +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
|
-
|
|
14
|
-
|
|
12
|
+
import { createRequire } from 'module';
|
|
13
|
+
import fse from 'fs-extra';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import express from 'express';
|
|
16
|
+
import ActionBuilder from './ActionBuilder.js';
|
|
17
|
+
import BaseConfig from './BaseConfig.js';
|
|
18
|
+
|
|
19
|
+
// load proxyquire specially since it doesn't support ESM yet.
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
15
21
|
const proxyquire = require('proxyquire').noCallThru();
|
|
16
|
-
const ActionBuilder = require('./ActionBuilder');
|
|
17
|
-
const BaseConfig = require('./BaseConfig.js');
|
|
18
22
|
|
|
19
23
|
function rawBody() {
|
|
20
24
|
return (req, res, next) => {
|
|
@@ -61,7 +65,7 @@ function addRequestHeader(name, value) {
|
|
|
61
65
|
*
|
|
62
66
|
* @type {DevelopmentServer}
|
|
63
67
|
*/
|
|
64
|
-
|
|
68
|
+
export default class DevelopmentServer {
|
|
65
69
|
/**
|
|
66
70
|
* Creates a new development server using the given universal function.
|
|
67
71
|
* @param {UniversalFunction} main - The universal function
|
|
@@ -169,4 +173,4 @@ module.exports = class DevelopmentServer {
|
|
|
169
173
|
});
|
|
170
174
|
});
|
|
171
175
|
}
|
|
172
|
-
}
|
|
176
|
+
}
|
|
@@ -9,19 +9,22 @@
|
|
|
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 path from 'path';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import fse from 'fs-extra';
|
|
15
|
+
import chalk from 'chalk-template';
|
|
16
|
+
import archiver from 'archiver';
|
|
17
|
+
import semver from 'semver';
|
|
18
|
+
import { validateBundle } from '../utils.js';
|
|
19
|
+
import pkgJson from '../package.cjs';
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
22
|
+
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* Base for all bundlers
|
|
23
26
|
*/
|
|
24
|
-
|
|
27
|
+
export default class BaseBundler {
|
|
25
28
|
/**
|
|
26
29
|
* Simple string substitute. Replaces all `${key}` occurrences from the given object.
|
|
27
30
|
* @param {string} str string to substitute
|
|
@@ -62,7 +65,7 @@ module.exports = class BaseBundler {
|
|
|
62
65
|
cfg.log.error(chalk`{red error:}`, result.error);
|
|
63
66
|
throw Error(`Validation failed: ${result.error}`);
|
|
64
67
|
}
|
|
65
|
-
cfg.log.info(chalk`{green ok:} bundle can be loaded and has a {
|
|
68
|
+
cfg.log.info(chalk`{green ok:} bundle can be loaded and has a {grey main()} function.`);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
async createArchive() {
|
|
@@ -112,8 +115,8 @@ module.exports = class BaseBundler {
|
|
|
112
115
|
// google cloud installs these dependencies at deploy time
|
|
113
116
|
// all other environments ignore them – this allows us to
|
|
114
117
|
// avoid bundling something that only google needs
|
|
115
|
-
'@google-cloud/secret-manager': dependencies['@google-cloud/secret-manager'],
|
|
116
|
-
'@google-cloud/storage': dependencies['@google-cloud/storage'],
|
|
118
|
+
'@google-cloud/secret-manager': pkgJson.dependencies['@google-cloud/secret-manager'],
|
|
119
|
+
'@google-cloud/storage': pkgJson.dependencies['@google-cloud/storage'],
|
|
117
120
|
},
|
|
118
121
|
};
|
|
119
122
|
archive.pipe(output);
|
|
@@ -186,4 +189,4 @@ module.exports = class BaseBundler {
|
|
|
186
189
|
archive.file(path.resolve(__dirname, '..', 'template', 'aws-esm-adapter.js'), { name: 'esm-adapter/index.js' });
|
|
187
190
|
}
|
|
188
191
|
}
|
|
189
|
-
}
|
|
192
|
+
}
|
|
@@ -9,15 +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
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import webpack from 'webpack';
|
|
15
|
+
import WebpackBundler from './WebpackBundler.js';
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const WebpackBundler = require('./WebpackBundler.js');
|
|
17
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
18
|
+
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
|
|
16
19
|
|
|
17
20
|
/**
|
|
18
21
|
* Creates the action bundle
|
|
19
22
|
*/
|
|
20
|
-
|
|
23
|
+
export default class EdgeBundler extends WebpackBundler {
|
|
21
24
|
async getWebpackConfig() {
|
|
22
25
|
const { cfg } = this;
|
|
23
26
|
const opts = {
|
|
@@ -48,8 +51,11 @@ module.exports = class EdgeBundler extends WebpackBundler {
|
|
|
48
51
|
}, {}),
|
|
49
52
|
module: {
|
|
50
53
|
rules: [{
|
|
51
|
-
test: /\.
|
|
54
|
+
test: /\.js$/,
|
|
52
55
|
type: 'javascript/auto',
|
|
56
|
+
}, {
|
|
57
|
+
test: /\.mjs$/,
|
|
58
|
+
type: 'javascript/esm',
|
|
53
59
|
}],
|
|
54
60
|
},
|
|
55
61
|
resolve: {
|
|
@@ -115,4 +121,4 @@ module.exports = class EdgeBundler extends WebpackBundler {
|
|
|
115
121
|
}
|
|
116
122
|
return this.createWebpackBundle('edge');
|
|
117
123
|
}
|
|
118
|
-
}
|
|
124
|
+
}
|
|
@@ -10,21 +10,26 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import fse from 'fs-extra';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
import { rollup } from 'rollup';
|
|
17
|
+
import chalk from 'chalk-template';
|
|
18
|
+
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
19
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
20
|
+
import alias from '@rollup/plugin-alias';
|
|
21
|
+
import pluginJson from '@rollup/plugin-json';
|
|
22
|
+
import { terser } from 'rollup-plugin-terser';
|
|
23
|
+
|
|
24
|
+
import BaseBundler from './BaseBundler.js';
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
27
|
+
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
30
|
* Creates the action bundle using rollup
|
|
26
31
|
*/
|
|
27
|
-
|
|
32
|
+
export default class Bundler extends BaseBundler {
|
|
28
33
|
async getRollupConfig() {
|
|
29
34
|
const { cfg } = this;
|
|
30
35
|
/**
|
|
@@ -92,7 +97,7 @@ module.exports = class Bundler extends BaseBundler {
|
|
|
92
97
|
|
|
93
98
|
cfg.log.info(`--: creating ${cfg.esm ? 'esm ' : ''}${cfg.minify ? 'minified ' : ''}bundle using rollup...`);
|
|
94
99
|
const config = await this.getRollupConfig();
|
|
95
|
-
const bundle = await rollup
|
|
100
|
+
const bundle = await rollup(config);
|
|
96
101
|
|
|
97
102
|
const { output } = await bundle.generate(config.output);
|
|
98
103
|
await this.resolveDependencyInfos(output);
|
|
@@ -162,4 +167,4 @@ module.exports = class Bundler extends BaseBundler {
|
|
|
162
167
|
.sort((d0, d1) => d0.name.localeCompare(d1.name));
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
|
-
}
|
|
170
|
+
}
|
|
@@ -9,17 +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
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import fse from 'fs-extra';
|
|
15
|
+
import webpack from 'webpack';
|
|
16
|
+
import chalk from 'chalk-template';
|
|
17
|
+
import BaseBundler from './BaseBundler.js';
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const webpack = require('webpack');
|
|
16
|
-
const chalk = require('chalk');
|
|
17
|
-
const BaseBundler = require('./BaseBundler.js');
|
|
19
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
20
|
+
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
* Webpack based bundler
|
|
21
24
|
*/
|
|
22
|
-
|
|
25
|
+
export default class WebpackBundler extends BaseBundler {
|
|
23
26
|
async init() {
|
|
24
27
|
if (this.cfg.esm) {
|
|
25
28
|
throw new Error('Webpack bundler does not support ESM builds.');
|
|
@@ -33,6 +36,7 @@ module.exports = class WebpackBundler extends BaseBundler {
|
|
|
33
36
|
mode: 'development',
|
|
34
37
|
// the universal adapter is the entry point
|
|
35
38
|
entry: cfg.adapterFile || path.resolve(__dirname, '..', 'template', 'node-index.js'),
|
|
39
|
+
context: cfg.cwd,
|
|
36
40
|
output: {
|
|
37
41
|
path: cfg.cwd,
|
|
38
42
|
filename: path.relative(cfg.cwd, cfg.bundle),
|
|
@@ -56,8 +60,11 @@ module.exports = class WebpackBundler extends BaseBundler {
|
|
|
56
60
|
}, {}),
|
|
57
61
|
module: {
|
|
58
62
|
rules: [{
|
|
59
|
-
test: /\.
|
|
63
|
+
test: /\.js$/,
|
|
60
64
|
type: 'javascript/auto',
|
|
65
|
+
}, {
|
|
66
|
+
test: /\.mjs$/,
|
|
67
|
+
type: 'javascript/esm',
|
|
61
68
|
}],
|
|
62
69
|
},
|
|
63
70
|
resolve: {
|
|
@@ -197,4 +204,4 @@ module.exports = class WebpackBundler extends BaseBundler {
|
|
|
197
204
|
.sort((d0, d1) => d0.name.localeCompare(d1.name));
|
|
198
205
|
});
|
|
199
206
|
}
|
|
200
|
-
}
|
|
207
|
+
}
|
package/src/cli.js
CHANGED
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/* eslint-disable no-console */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
import yargs from 'yargs';
|
|
15
|
+
import chalk from 'chalk-template';
|
|
16
|
+
import { config as envConfig } from 'dotenv';
|
|
17
|
+
import BaseConfig from './BaseConfig.js';
|
|
18
|
+
import OpenWhiskDeployer from './deploy/OpenWhiskDeployer.js';
|
|
19
|
+
import AWSDeployer from './deploy/AWSDeployer.js';
|
|
20
|
+
import AzureDeployer from './deploy/AzureDeployer.js';
|
|
21
|
+
import GoogleDeployer from './deploy/GoogleDeployer.js';
|
|
22
|
+
import CloudflareDeployer from './deploy/CloudflareDeployer.js';
|
|
23
|
+
import ComputeAtEdgeDeployer from './deploy/ComputeAtEdgeDeployer.js';
|
|
24
|
+
import FastlyGateway from './gateway/FastlyGateway.js';
|
|
25
|
+
import ActionBuilder from './ActionBuilder.js';
|
|
26
26
|
|
|
27
27
|
const PLUGINS = [
|
|
28
28
|
OpenWhiskDeployer,
|
|
@@ -34,11 +34,9 @@ const PLUGINS = [
|
|
|
34
34
|
FastlyGateway,
|
|
35
35
|
];
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
require('dotenv').config();
|
|
37
|
+
envConfig();
|
|
40
38
|
|
|
41
|
-
class CLI {
|
|
39
|
+
export default class CLI {
|
|
42
40
|
constructor() {
|
|
43
41
|
this._yargs = yargs()
|
|
44
42
|
.pkgConf('wsk')
|
|
@@ -48,18 +46,11 @@ class CLI {
|
|
|
48
46
|
this._yargs.help();
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
// eslint-disable-next-line class-methods-use-this
|
|
52
|
-
createBuilder() {
|
|
53
|
-
// eslint-disable-next-line global-require
|
|
54
|
-
const ActionBuilder = require('./ActionBuilder.js');
|
|
55
|
-
return new ActionBuilder();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
49
|
prepare(args) {
|
|
59
50
|
const argv = this._yargs.parse(args);
|
|
60
51
|
|
|
61
52
|
if (argv.externals.length === 0) {
|
|
62
|
-
argv.externals =
|
|
53
|
+
argv.externals = [/^openwhisk(\/.*)?$/];
|
|
63
54
|
}
|
|
64
55
|
|
|
65
56
|
const config = new BaseConfig().configure(argv);
|
|
@@ -68,7 +59,7 @@ class CLI {
|
|
|
68
59
|
return new PluginClass(config, pluginConfig);
|
|
69
60
|
});
|
|
70
61
|
|
|
71
|
-
return
|
|
62
|
+
return new ActionBuilder()
|
|
72
63
|
.withConfig(config)
|
|
73
64
|
.withPlugins(plugins);
|
|
74
65
|
}
|
|
@@ -80,10 +71,8 @@ class CLI {
|
|
|
80
71
|
console.log(JSON.stringify(res, null, 2));
|
|
81
72
|
}
|
|
82
73
|
} catch (err) {
|
|
83
|
-
console.log(
|
|
74
|
+
console.log(chalk`{red error:} ${err.message}`);
|
|
84
75
|
process.exitCode = 1;
|
|
85
76
|
}
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
|
-
|
|
89
|
-
module.exports = CLI;
|
package/src/deploy/AWSConfig.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// eslint-disable-next-line no-template-curly-in-string
|
|
14
14
|
const DEFAULT_LAMBDA_FORMAT = '${packageName}--${baseName}';
|
|
15
15
|
|
|
16
|
-
class AWSConfig {
|
|
16
|
+
export default class AWSConfig {
|
|
17
17
|
constructor() {
|
|
18
18
|
Object.assign(this, {
|
|
19
19
|
region: '',
|
|
@@ -125,5 +125,3 @@ class AWSConfig {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
module.exports = AWSConfig;
|
|
@@ -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
|
|
|
@@ -422,7 +409,7 @@ class AWSDeployer extends BaseDeployer {
|
|
|
422
409
|
// ignore, most likely the permission already exists
|
|
423
410
|
}
|
|
424
411
|
|
|
425
|
-
this.log.info(chalk`{green ok:} function deployed: ${
|
|
412
|
+
this.log.info(chalk`{green ok:} function deployed: {blueBright ${this._functionURL}}`);
|
|
426
413
|
}
|
|
427
414
|
|
|
428
415
|
async test() {
|
|
@@ -530,7 +517,7 @@ class AWSDeployer extends BaseDeployer {
|
|
|
530
517
|
});
|
|
531
518
|
const unused = [];
|
|
532
519
|
if (filter) {
|
|
533
|
-
this.log.info(chalk`Integrations / Routes for {
|
|
520
|
+
this.log.info(chalk`Integrations / Routes for {grey ${filter}}`);
|
|
534
521
|
} else {
|
|
535
522
|
this.log.info('Integrations / Routes');
|
|
536
523
|
}
|
|
@@ -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
|
-
|
|
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;
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
3
3
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -9,15 +9,4 @@
|
|
|
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
|
-
module.exports = {
|
|
14
|
-
// modules that are provided by the runtime container
|
|
15
|
-
externals: [
|
|
16
|
-
// 'express',
|
|
17
|
-
// 'body-parser',
|
|
18
|
-
// 'cls-hooked',
|
|
19
|
-
// 'request',
|
|
20
|
-
// 'request-promise',
|
|
21
|
-
/^openwhisk(\/.*)?$/,
|
|
22
|
-
],
|
|
23
|
-
};
|
|
12
|
+
module.exports = require('../package.json');
|
|
@@ -9,9 +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
|
-
|
|
13
|
-
global.__rootdir = __dirname;
|
|
14
|
-
|
|
12
|
+
const { dirname } = require('path');
|
|
15
13
|
const {
|
|
16
14
|
openwhisk,
|
|
17
15
|
aws,
|
|
@@ -19,6 +17,9 @@ const {
|
|
|
19
17
|
azure,
|
|
20
18
|
} = require('@adobe/helix-universal').adapter;
|
|
21
19
|
|
|
20
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
21
|
+
global.__rootdir = dirname(__filename); // __dirname is transformed by webpack, __filename isn't
|
|
22
|
+
|
|
22
23
|
module.exports = Object.assign(azure, {
|
|
23
24
|
main: openwhisk,
|
|
24
25
|
lambda: aws,
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
/* eslint-env serviceworker */
|
|
13
|
-
const fastly = require('./fastly-adapter');
|
|
14
|
-
const cloudflare = require('./cloudflare-adapter');
|
|
13
|
+
const fastly = require('./fastly-adapter.js');
|
|
14
|
+
const cloudflare = require('./cloudflare-adapter.js');
|
|
15
15
|
|
|
16
16
|
/* eslint-disable no-restricted-globals */
|
|
17
17
|
if (typeof addEventListener === 'function') {
|
package/src/utils.js
CHANGED
|
@@ -9,8 +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
|
-
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
13
|
+
import { fork } from 'child_process';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
17
|
+
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* @typedef {object} VersionCoordinates
|
|
@@ -54,7 +58,7 @@ const path = require('path');
|
|
|
54
58
|
* @param {VersionSpec} versionspec - which version is current
|
|
55
59
|
* @returns {NamedAction[]} - a list of actions that can safely be deleted
|
|
56
60
|
*/
|
|
57
|
-
function filterActions(fns, now, {
|
|
61
|
+
export function filterActions(fns, now, {
|
|
58
62
|
ciAge, patchAge, minorAge, majorAge, ciNum, patchNum, minorNum, majorNum,
|
|
59
63
|
} = {}, { patchVersion, minorVersion, majorVersion } = {}) {
|
|
60
64
|
// sort by updated date
|
|
@@ -151,7 +155,7 @@ function filterActions(fns, now, {
|
|
|
151
155
|
...cleanmajorbyage, ...cleanmajorbycount];
|
|
152
156
|
}
|
|
153
157
|
|
|
154
|
-
async function validateBundle(bundlePath, invoke = false) {
|
|
158
|
+
export async function validateBundle(bundlePath, invoke = false) {
|
|
155
159
|
try {
|
|
156
160
|
const opts = {
|
|
157
161
|
invoke,
|
|
@@ -175,8 +179,3 @@ async function validateBundle(bundlePath, invoke = false) {
|
|
|
175
179
|
};
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
|
-
|
|
179
|
-
module.exports = {
|
|
180
|
-
filterActions,
|
|
181
|
-
validateBundle,
|
|
182
|
-
};
|