@adobe/helix-deploy 11.1.14 → 12.0.0-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [11.1.15](https://github.com/adobe/helix-deploy/compare/v11.1.14...v11.1.15) (2024-06-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency isomorphic-git to v1.26.1 ([#718](https://github.com/adobe/helix-deploy/issues/718)) ([60e07b5](https://github.com/adobe/helix-deploy/commit/60e07b5c3a6ae7ec0a126c7ebae9bae6893c3f88))
7
+
1
8
  ## [11.1.14](https://github.com/adobe/helix-deploy/compare/v11.1.13...v11.1.14) (2024-06-22)
2
9
 
3
10
 
package/index.js CHANGED
@@ -10,6 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  export { default as ActionBuilder } from './src/ActionBuilder.js';
13
- export { default as Bundler } from './src/bundler/WebpackBundler.js';
13
+ export { default as WebpackBundler } from './src/bundler/WebpackBundler.js';
14
14
  export { default as BaseConfig } from './src/BaseConfig.js';
15
+ export { default as BaseDeployer } from './src/deploy/BaseDeployer.js';
15
16
  export { default as CLI } from './src/cli.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-deploy",
3
- "version": "11.1.14",
3
+ "version": "12.0.0-pre.1",
4
4
  "description": "Library and Commandline Tools to build and deploy OpenWhisk Actions",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/adobe/helix-deploy#readme",
@@ -37,7 +37,6 @@
37
37
  "@adobe/helix-universal": ">=4.1.1"
38
38
  },
39
39
  "dependencies": {
40
- "@adobe/fastly-native-promises": "3.0.10",
41
40
  "@adobe/fetch": "4.1.8",
42
41
  "@adobe/helix-shared-process-queue": "3.0.4",
43
42
  "@aws-sdk/client-apigatewayv2": "3.600.0",
@@ -46,25 +45,16 @@
46
45
  "@aws-sdk/client-secrets-manager": "3.600.0",
47
46
  "@aws-sdk/client-ssm": "3.600.0",
48
47
  "@aws-sdk/client-sts": "3.600.0",
49
- "@fastly/js-compute": "3.16.0",
50
48
  "@google-cloud/functions": "3.4.0",
51
49
  "@google-cloud/secret-manager": "5.6.0",
52
50
  "@google-cloud/storage": "7.11.2",
53
- "@rollup/plugin-alias": "5.1.0",
54
- "@rollup/plugin-commonjs": "26.0.1",
55
- "@rollup/plugin-json": "6.1.0",
56
- "@rollup/plugin-node-resolve": "15.2.3",
57
- "@rollup/plugin-terser": "0.4.4",
58
51
  "archiver": "7.0.1",
59
52
  "chalk-template": "1.1.0",
60
- "constants-browserify": "1.0.0",
61
53
  "dotenv": "16.4.5",
62
- "form-data": "4.0.0",
63
54
  "fs-extra": "11.2.0",
64
- "isomorphic-git": "1.25.10",
55
+ "isomorphic-git": "1.26.1",
65
56
  "openwhisk": "3.21.8",
66
57
  "semver": "7.6.2",
67
- "tar": "7.4.0",
68
58
  "webpack": "5.92.1",
69
59
  "yargs": "17.7.2"
70
60
  },
@@ -86,7 +76,7 @@
86
76
  "yauzl": "3.1.3"
87
77
  },
88
78
  "engines": {
89
- "node": ">=12.0"
79
+ "node": ">=18.0"
90
80
  },
91
81
  "lint-staged": {
92
82
  "*.js": "eslint"
package/params.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "Parameters": []
3
+ }
@@ -16,19 +16,8 @@ import fs from 'fs';
16
16
  import fse from 'fs-extra';
17
17
  import chalk from 'chalk-template';
18
18
  import git from 'isomorphic-git';
19
- import WebpackBundler from './bundler/WebpackBundler.js';
20
- import EdgeBundler from './bundler/EdgeBundler.js';
21
19
  import pkgJson from './package.cjs';
22
20
 
23
- const Bundlers = {
24
- node: {
25
- webpack: WebpackBundler,
26
- },
27
- edge: {
28
- webpack: EdgeBundler,
29
- },
30
- };
31
-
32
21
  /**
33
22
  * Returns the `origin` remote url or `''` if none is defined.
34
23
  *
@@ -126,7 +115,8 @@ export default class ActionBuilder {
126
115
  Object.assign(this, {
127
116
  cfg: {},
128
117
  _deployers: {},
129
- _gateways: { },
118
+ _gateways: {},
119
+ _bundlers: {},
130
120
  });
131
121
  }
132
122
 
@@ -143,6 +133,19 @@ export default class ActionBuilder {
143
133
  if (plg.isGateway) {
144
134
  this._gateways[plg.id] = plg;
145
135
  }
136
+ if (plg.isBundler) {
137
+ let arch = this._bundlers[plg.arch];
138
+ if (!arch) {
139
+ arch = [];
140
+ this._bundlers[plg.arch] = arch;
141
+ }
142
+ let bnds = arch[plg.type];
143
+ if (!bnds) {
144
+ bnds = [];
145
+ arch[plg.type] = bnds;
146
+ }
147
+ bnds.push(plg);
148
+ }
146
149
  });
147
150
  return this;
148
151
  }
@@ -274,20 +277,18 @@ export default class ActionBuilder {
274
277
  if (this.validated) {
275
278
  return;
276
279
  }
277
- // disable edge build
278
-
279
280
  const { cfg } = this;
280
281
  this.bundlers = [];
281
282
  cfg.archs.forEach((arch) => {
282
- const bnds = Bundlers[arch];
283
+ const bnds = this._bundlers[arch];
283
284
  if (!bnds) {
284
- throw Error(`Invalid arch '${arch}' specified. Valid options are: ${Object.keys(Bundlers)}`);
285
+ throw Error(`Invalid arch '${arch}' specified. Valid options are: ${Object.keys(this._bundlers)}`);
285
286
  }
286
- const BundlerClass = bnds[cfg.bundler];
287
- if (!BundlerClass) {
287
+ const bundler = bnds[cfg.bundler];
288
+ if (!bundler) {
288
289
  throw Error(`Invalid bundler '${cfg.bundler}' for '${arch}'. Valid options are: ${Object.keys(bnds)}`);
289
290
  }
290
- this.bundlers.push(new BundlerClass().withConfig(cfg));
291
+ this.bundlers.push(...bundler);
291
292
  });
292
293
  for (const bundler of this.bundlers) {
293
294
  await bundler.init();
package/src/BaseConfig.js CHANGED
@@ -597,7 +597,7 @@ export default class BaseConfig {
597
597
  default: '.',
598
598
  })
599
599
 
600
- .group(['help', 'build', 'deploy', 'test', 'test-bundle', 'update-package', 'version-link', 'delete'], 'Operation Options')
600
+ .group(['help', 'build', 'deploy', 'test', 'test-bundle', 'update-package', 'version-link', 'delete', 'plugin'], 'Operation Options')
601
601
  .option('build', {
602
602
  description: 'Build the deployment package',
603
603
  type: 'boolean',
@@ -632,6 +632,12 @@ export default class BaseConfig {
632
632
  type: 'boolean',
633
633
  default: false,
634
634
  })
635
+ .option('plugin', {
636
+ description: 'Specify bundler or deploy plugins.',
637
+ type: 'string',
638
+ array: true,
639
+ default: [],
640
+ })
635
641
 
636
642
  .group(['minify', 'static', 'entryFile', 'externals', 'edge-externals', 'serverless-externals', 'modules', 'adapterFile', 'esm', 'bundler'], 'Build Options')
637
643
  .option('minify', {
@@ -37,17 +37,15 @@ export default class BaseBundler {
37
37
  }, str);
38
38
  }
39
39
 
40
- constructor() {
40
+ constructor(cfg) {
41
41
  Object.assign(this, {
42
- cfg: {},
42
+ isBundler: true,
43
+ cfg,
44
+ arch: '',
45
+ type: '',
43
46
  });
44
47
  }
45
48
 
46
- withConfig(cfg) {
47
- this.cfg = cfg;
48
- return this;
49
- }
50
-
51
49
  // eslint-disable-next-line class-methods-use-this,no-empty-function
52
50
  async init() {
53
51
  }
@@ -155,7 +153,7 @@ export default class BaseBundler {
155
153
 
156
154
  async updateArchive(archive, packageJson) {
157
155
  const { cfg } = this;
158
- if (cfg.archs.includes('node')) {
156
+ if (this.arch === 'node') {
159
157
  archive.file(cfg.bundle, { name: 'index.js' });
160
158
  }
161
159
 
@@ -178,14 +176,6 @@ export default class BaseBundler {
178
176
 
179
177
  archive.append(JSON.stringify(packageJson, null, ' '), { name: 'package.json' });
180
178
 
181
- // edge function stuff
182
- archive.append([
183
- 'account_id = "fakefakefake"',
184
- `name = "${this.cfg.packageName}/${this.cfg.name}"`,
185
- 'type = "javascript"',
186
- 'workers_dev = true',
187
- ].join('\n'), { name: 'wrangler.toml' });
188
-
189
179
  // this allows to use a cjs loader for the esm modules. but it still doesn't work on AWS
190
180
  if (cfg.esm) {
191
181
  archive.directory('esm-adapter');
@@ -23,6 +23,12 @@ const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
23
23
  * Webpack based bundler
24
24
  */
25
25
  export default class WebpackBundler extends BaseBundler {
26
+ constructor(cfg) {
27
+ super(cfg);
28
+ this.arch = 'node';
29
+ this.type = 'webpack';
30
+ }
31
+
26
32
  async init() {
27
33
  if (this.cfg.esm) {
28
34
  throw new Error('Webpack bundler does not support ESM builds.');
@@ -105,7 +111,7 @@ export default class WebpackBundler extends BaseBundler {
105
111
  }
106
112
 
107
113
  if (cfg.progressHandler) {
108
- opts.plugins.push(new webpack.ProgressPlugin(cfg.progressHandler));
114
+ this.initProgressHandler(opts, cfg);
109
115
  }
110
116
 
111
117
  const customizePath = path.join(cfg.cwd, 'hlx.webpack.customize.js');
@@ -119,6 +125,11 @@ export default class WebpackBundler extends BaseBundler {
119
125
  return opts;
120
126
  }
121
127
 
128
+ // eslint-disable-next-line class-methods-use-this
129
+ initProgressHandler(opts, cfg) {
130
+ opts.plugins.push(new webpack.ProgressPlugin(cfg.progressHandler));
131
+ }
132
+
122
133
  async createWebpackBundle(arch) {
123
134
  const { cfg } = this;
124
135
  if (!cfg.depFile) {
package/src/cli.js CHANGED
@@ -18,24 +18,55 @@ import BaseConfig from './BaseConfig.js';
18
18
  import OpenWhiskDeployer from './deploy/OpenWhiskDeployer.js';
19
19
  import AWSDeployer from './deploy/AWSDeployer.js';
20
20
  import GoogleDeployer from './deploy/GoogleDeployer.js';
21
- import CloudflareDeployer from './deploy/CloudflareDeployer.js';
22
- import ComputeAtEdgeDeployer from './deploy/ComputeAtEdgeDeployer.js';
23
- import FastlyGateway from './gateway/FastlyGateway.js';
24
21
  import ActionBuilder from './ActionBuilder.js';
22
+ import WebpackBundler from './bundler/WebpackBundler.js';
25
23
 
26
24
  const PLUGINS = [
27
25
  OpenWhiskDeployer,
28
26
  AWSDeployer,
29
27
  GoogleDeployer,
30
- CloudflareDeployer,
31
- ComputeAtEdgeDeployer,
32
- FastlyGateway,
28
+ WebpackBundler,
33
29
  ];
34
30
 
35
31
  envConfig();
36
32
 
33
+ async function loadPlugin(name) {
34
+ const names = [
35
+ name,
36
+ `helix-deploy-${name}`,
37
+ `@adobe/helix-deploy-${name}`,
38
+ ];
39
+
40
+ let module;
41
+ let moduleName;
42
+ for (const n of names) {
43
+ try {
44
+ // eslint-disable-next-line no-await-in-loop
45
+ module = await import(n);
46
+ moduleName = n;
47
+ break;
48
+ } catch (e) {
49
+ if (e.code !== 'MODULE_NOT_FOUND') {
50
+ throw e;
51
+ }
52
+ }
53
+ }
54
+ if (!module) {
55
+ throw new Error(`Plugin not found: ${name}`);
56
+ }
57
+ const { plugins } = module;
58
+ if (!plugins) {
59
+ throw new Error(`Plugin ${module.name} does not export a plugins' array.`);
60
+ }
61
+ console.log('Loaded plugin:', moduleName);
62
+ for (const clazz of plugins) {
63
+ console.log('- ', clazz.name);
64
+ }
65
+ return plugins;
66
+ }
67
+
37
68
  export default class CLI {
38
- constructor() {
69
+ buildArgs(plugins) {
39
70
  this._yargs = yargs()
40
71
  .pkgConf('wsk')
41
72
  .env('HLX')
@@ -61,14 +92,27 @@ export default class CLI {
61
92
  });
62
93
  });
63
94
  BaseConfig.yarg(this._yargs);
64
- PLUGINS.forEach((PluginClass) => PluginClass.Config.yarg(this._yargs));
95
+ plugins.forEach((PluginClass) => PluginClass.Config?.yarg(this._yargs));
65
96
  this._yargs
66
97
  .wrap(Math.min(120, this._yargs.terminalWidth()))
67
98
  .help();
68
99
  }
69
100
 
70
- prepare(args) {
71
- const argv = this._yargs.parse(args);
101
+ async prepare(args) {
102
+ const pluginClasses = [...PLUGINS];
103
+ this.buildArgs(pluginClasses);
104
+ let argv = this._yargs.parse(args);
105
+
106
+ // if args specify plugins, load them and parse again
107
+ if (argv.plugin.length) {
108
+ for (const pluginName of argv.plugin) {
109
+ // eslint-disable-next-line no-await-in-loop
110
+ const plugins = await loadPlugin(pluginName);
111
+ pluginClasses.push(...plugins);
112
+ }
113
+ this.buildArgs(pluginClasses);
114
+ argv = this._yargs.parse(args);
115
+ }
72
116
 
73
117
  // apply '!important' args (override env).
74
118
  Object.entries(argv).forEach(([key, value]) => {
@@ -83,8 +127,10 @@ export default class CLI {
83
127
  }
84
128
 
85
129
  const config = new BaseConfig().configure(argv);
86
- const plugins = PLUGINS.map((PluginClass) => {
87
- const pluginConfig = new PluginClass.Config().configure(argv);
130
+ const plugins = pluginClasses.map((PluginClass) => {
131
+ const pluginConfig = PluginClass.Config
132
+ ? new PluginClass.Config().configure(argv)
133
+ : null;
88
134
  return new PluginClass(config, pluginConfig);
89
135
  });
90
136
 
@@ -1,132 +0,0 @@
1
- /*
2
- * Copyright 2021 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
- import { fileURLToPath } from 'url';
13
- import path from 'path';
14
- import webpack from 'webpack';
15
- import WebpackBundler from './WebpackBundler.js';
16
-
17
- // eslint-disable-next-line no-underscore-dangle
18
- const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
19
-
20
- /**
21
- * Creates the action bundle
22
- */
23
- export default class EdgeBundler extends WebpackBundler {
24
- async getWebpackConfig() {
25
- const { cfg } = this;
26
- const opts = {
27
- target: 'webworker',
28
- mode: 'development',
29
- // the universal adapter is the entry point
30
- entry: cfg.adapterFile || path.resolve(__dirname, '..', 'template', 'serviceworker-index.js'),
31
- output: {
32
- path: cfg.cwd,
33
- filename: path.relative(cfg.cwd, cfg.edgeBundle),
34
- library: 'main',
35
- libraryTarget: 'umd',
36
- globalObject: 'globalThis',
37
- },
38
- devtool: false,
39
- externals: [
40
- ...cfg.externals, // user defined externals for all platforms
41
- ...cfg.edgeExternals, // user defined externals for edge compute
42
- // the following are imported by the universal adapter and are assumed to be available
43
- './params.json',
44
- 'aws-sdk',
45
- '@google-cloud/secret-manager',
46
- '@google-cloud/storage',
47
- 'fastly:env',
48
- ].reduce((obj, ext) => {
49
- // this makes webpack to ignore the module and just leave it as normal require.
50
- // eslint-disable-next-line no-param-reassign
51
- obj[ext] = `commonjs2 ${ext}`;
52
- return obj;
53
- }, {}),
54
- module: {
55
- rules: [{
56
- test: /\.js$/,
57
- type: 'javascript/auto',
58
- }, {
59
- test: /\.mjs$/,
60
- type: 'javascript/esm',
61
- }],
62
- },
63
- resolve: {
64
- mainFields: ['main', 'module'],
65
- extensions: ['.wasm', '.js', '.mjs', '.json'],
66
- alias: {
67
- // the main.js is imported in the universal adapter and is _the_ action entry point
68
- './main.js': cfg.file,
69
- // 'psl': path.resolve(__dirname, '../node_modules/psl/dist/psl.js'), // inlined data
70
- '@adobe/fetch': path.resolve(__dirname, '../template/polyfills/fetch.js'),
71
- '@adobe/helix-fetch': path.resolve(__dirname, '../template/polyfills/fetch.js'),
72
- },
73
- /* fallback: {
74
- assert: require.resolve('assert'),
75
- buffer: require.resolve('buffer'),
76
- console: require.resolve('console-browserify'),
77
- constants: require.resolve('constants-browserify'),
78
- crypto: require.resolve('crypto-browserify'),
79
- domain: require.resolve('domain-browser'),
80
- events: path.resolve(__dirname, '../node_modules/events/events.js'),
81
- http: require.resolve('stream-http'),
82
- https: require.resolve('https-browserify'),
83
- os: require.resolve('os-browserify/browser'),
84
- path: require.resolve('path-browserify'),
85
- punycode: require.resolve('punycode'),
86
- process: require.resolve('process/browser'),
87
- querystring: require.resolve('querystring-es3'),
88
- stream: require.resolve('stream-browserify'),
89
- string_decoder: require.resolve('string_decoder'),
90
- sys: require.resolve('util'),
91
- timers: require.resolve('timers-browserify'),
92
- tty: require.resolve('tty-browserify'),
93
- url: require.resolve('url'),
94
- util: require.resolve('util'),
95
- vm: require.resolve('vm-browserify'),
96
- zlib: require.resolve('browserify-zlib'),
97
- }, */
98
- },
99
- node: {
100
- __dirname: true,
101
- __filename: false,
102
- },
103
- plugins: [],
104
- };
105
- if (cfg.minify) {
106
- opts.optimization = {
107
- minimize: cfg.minify,
108
- };
109
- }
110
- if (cfg.modulePaths && cfg.modulePaths.length > 0) {
111
- opts.resolve.modules = cfg.modulePaths;
112
- }
113
-
114
- if (cfg.progressHandler) {
115
- opts.plugins.push(new webpack.ProgressPlugin(cfg.progressHandler));
116
- }
117
- return opts;
118
- }
119
-
120
- async createBundle() {
121
- const { cfg } = this;
122
- if (!cfg.edgeBundle) {
123
- throw Error('edge bundle path is undefined');
124
- }
125
- return this.createWebpackBundle('edge');
126
- }
127
-
128
- // eslint-disable-next-line class-methods-use-this
129
- validateBundle() {
130
- // TODO: validate edge bundle, skipped since we're on node
131
- }
132
- }
@@ -1,74 +0,0 @@
1
- /*
2
- * Copyright 2021 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
- export default class CloudflareConfig {
13
- constructor() {
14
- Object.assign(this, {});
15
- }
16
-
17
- configure(argv) {
18
- return this
19
- .withEmail(argv.cloudflareEmail)
20
- .withAuth(argv.cloudflareAuth)
21
- .withTestDomain(argv.cloudflareTestDomain)
22
- .withAccountID(argv.cloudflareAccountId);
23
- }
24
-
25
- withAccountID(value) {
26
- this.accountID = value;
27
- return this;
28
- }
29
-
30
- withEmail(value) {
31
- this.email = value;
32
- return this;
33
- }
34
-
35
- withTestDomain(value) {
36
- this.testDomain = value;
37
- return this;
38
- }
39
-
40
- withAuth(value) {
41
- this.auth = value;
42
- return this;
43
- }
44
-
45
- static yarg(yargs) {
46
- return yargs
47
- .group([
48
- 'cloudflare-account-id',
49
- 'cloudflare-auth',
50
- 'cloudflare-email',
51
- 'cloudflare-test-domain',
52
- ], 'Cloudflare Workers Deployment Options')
53
- .option('cloudflare-account-id', {
54
- description: 'the Cloudflare account ID to deploy to',
55
- type: 'string',
56
- default: '',
57
- })
58
- .option('cloudflare-email', {
59
- description: 'the Cloudflare email address belonging to the authentication token',
60
- type: 'string',
61
- default: '',
62
- })
63
- .option('cloudflare-test-domain', {
64
- description: 'the *.workers.dev subdomain to use for testing deployed scripts',
65
- type: 'string',
66
- default: '',
67
- })
68
- .option('cloudflare-auth', {
69
- description: 'the Cloudflare API token from https://dash.cloudflare.com/profile/api-tokens',
70
- type: 'string',
71
- default: '',
72
- });
73
- }
74
- }