@adobe/aem-cli 16.3.9 → 16.3.11

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,17 @@
1
+ ## [16.3.11](https://github.com/adobe/helix-cli/compare/v16.3.10...v16.3.11) (2024-05-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * support allow-unauthorized in aem up ([#2352](https://github.com/adobe/helix-cli/issues/2352)) ([e5cdac0](https://github.com/adobe/helix-cli/commit/e5cdac053e76df305925ec415e3b767176f0d8b1))
7
+
8
+ ## [16.3.10](https://github.com/adobe/helix-cli/compare/v16.3.9...v16.3.10) (2024-04-27)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency @adobe/helix-shared-config to v10.4.3 ([a69f5ff](https://github.com/adobe/helix-cli/commit/a69f5ffd8247c9a285aa28e35a819643ba30c6a7))
14
+
1
15
  ## [16.3.9](https://github.com/adobe/helix-cli/compare/v16.3.8...v16.3.9) (2024-04-17)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aem-cli",
3
- "version": "16.3.9",
3
+ "version": "16.3.11",
4
4
  "description": "AEM CLI",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  "dependencies": {
41
41
  "@adobe/fetch": "4.1.2",
42
42
  "@adobe/helix-log": "6.0.3",
43
- "@adobe/helix-shared-config": "10.4.2",
43
+ "@adobe/helix-shared-config": "10.4.3",
44
44
  "@adobe/helix-shared-git": "3.0.8",
45
45
  "@adobe/helix-shared-indexer": "2.0.23",
46
46
  "camelcase": "8.0.0",
@@ -82,14 +82,14 @@
82
82
  "@semantic-release/git": "10.0.1",
83
83
  "c8": "9.1.0",
84
84
  "eslint": "8.57.0",
85
- "esmock": "2.6.4",
85
+ "esmock": "2.6.5",
86
86
  "husky": "9.0.11",
87
87
  "junit-report-builder": "3.2.1",
88
88
  "lint-staged": "15.2.2",
89
89
  "mocha": "10.4.0",
90
90
  "mocha-multi-reporters": "1.5.1",
91
91
  "nock": "13.5.4",
92
- "semantic-release": "22.0.12",
92
+ "semantic-release": "23.0.8",
93
93
  "semantic-release-discord-bot": "^1.1.0",
94
94
  "sinon": "17.0.1"
95
95
  },
@@ -84,7 +84,7 @@ export class AbstractServerCommand extends AbstractCommand {
84
84
  this.emit('stopped', this);
85
85
  }
86
86
 
87
- async initSeverOptions() {
87
+ async initServerOptions() {
88
88
  if (this._cache) {
89
89
  await fse.ensureDir(this._cache);
90
90
  this._project.withCacheDirectory(this._cache);
@@ -45,11 +45,11 @@ const httpProxyHandler = {
45
45
  };
46
46
 
47
47
  // create global context that is used by all commands and can be reset for CLI to terminate
48
- export function getFetch(allowUnauthorized) {
49
- const cacheName = allowUnauthorized ? 'insecure' : 'default';
48
+ export function getFetch(allowInsecure) {
49
+ const cacheName = allowInsecure ? 'insecure' : 'default';
50
50
  let cache = CONTEXT_CACHE[cacheName];
51
51
  if (!cache) {
52
- const context = keepAlive({ rejectUnauthorized: !allowUnauthorized });
52
+ const context = keepAlive({ rejectUnauthorized: !allowInsecure });
53
53
  cache = {
54
54
  context,
55
55
  fetch: new Proxy(context.fetch, httpProxyHandler),
package/src/import.cmd.js CHANGED
@@ -22,6 +22,12 @@ export default class ImportCommand extends AbstractServerCommand {
22
22
  constructor(logger) {
23
23
  super(logger);
24
24
  this._importerSubPath = 'tools/importer';
25
+ this._allowInsecure = true;
26
+ }
27
+
28
+ withAllowInsecure(value) {
29
+ this._allowInsecure = value;
30
+ return this;
25
31
  }
26
32
 
27
33
  withSkipUI(value) {
@@ -79,7 +85,8 @@ export default class ImportCommand extends AbstractServerCommand {
79
85
  this._project = new HelixImportProject()
80
86
  .withCwd(this.directory)
81
87
  .withLogger(this._logger)
82
- .withKill(this._kill);
88
+ .withKill(this._kill)
89
+ .withAllowInsecure(this._allowInsecure);
83
90
  this.log.info(chalk`{yellow ___ ________ ___ __}`);
84
91
  this.log.info(chalk`{yellow / | / ____/ |/ / (_)___ ___ ____ ____ _____/ /____ _____}`);
85
92
  this.log.info(chalk`{yellow / /| | / __/ / /|_/ / / / __ \`__ \\/ __ \\/ __ \\/ ___/ __/ _ \\/ ___/}`);
@@ -88,7 +95,7 @@ export default class ImportCommand extends AbstractServerCommand {
88
95
  this.log.info(chalk`{yellow /_/ v${pkgJson.version}}`);
89
96
  this.log.info('');
90
97
 
91
- await this.initSeverOptions();
98
+ await this.initServerOptions();
92
99
 
93
100
  if (!this._skipUI) {
94
101
  await this.setupImporterUI();
package/src/import.js CHANGED
@@ -80,6 +80,12 @@ export default function up() {
80
80
  type: 'string',
81
81
  })
82
82
  .group(['open', 'no-open', 'cache', 'ui-repo', 'skip-ui'], 'AEM Importer Options')
83
+ .option('allow-insecure', {
84
+ alias: 'allowInsecure',
85
+ describe: 'Whether to allow insecure requests to the server',
86
+ type: 'boolean',
87
+ default: true,
88
+ })
83
89
 
84
90
  .help();
85
91
  },
@@ -100,6 +106,7 @@ export default function up() {
100
106
  // this prevents the window to be opened during integration tests
101
107
  .withOpen(path.basename(argv.$0) === 'aem' ? argv.open : false)
102
108
  .withTLS(argv.tlsKey, argv.tlsCert)
109
+ .withAllowInsecure(argv.allowInsecure)
103
110
  .withKill(argv.stopOther)
104
111
  .withCache(argv.cache)
105
112
  .withSkipUI(argv.skipUI)
@@ -116,7 +116,7 @@ export class BaseServer extends EventEmitter {
116
116
  let retries = 1;
117
117
  if (this._project.kill && await utils.checkPortInUse(this._port, this._addr)) {
118
118
  try {
119
- const res = await getFetch()(`${this._scheme}://${this._addr}:${this._port}/.kill`);
119
+ const res = await getFetch(true)(`${this._scheme}://${this._addr}:${this._port}/.kill`);
120
120
  await res.text();
121
121
  } catch (e) {
122
122
  // ignore errors, in case the other server closes connection
@@ -75,7 +75,9 @@ export default class HeadHtmlSupport {
75
75
  .parse(html);
76
76
  }
77
77
 
78
- constructor({ proxyUrl, directory, log }) {
78
+ constructor({
79
+ proxyUrl, directory, allowInsecure, log,
80
+ }) {
79
81
  this.remoteHtml = '';
80
82
  this.remoteDom = null;
81
83
  this.remoteStatus = 0;
@@ -85,6 +87,7 @@ export default class HeadHtmlSupport {
85
87
  this.url = new URL(proxyUrl);
86
88
  this.url.pathname = '/head.html';
87
89
  this.filePath = resolve(directory, 'head.html');
90
+ this.allowInsecure = allowInsecure;
88
91
  this.log = log;
89
92
  }
90
93
 
@@ -94,7 +97,7 @@ export default class HeadHtmlSupport {
94
97
  if (this.cookie) {
95
98
  headers.cookie = this.cookie;
96
99
  }
97
- const resp = await getFetch()(this.url, {
100
+ const resp = await getFetch(this.allowInsecure)(this.url, {
98
101
  cache: 'no-store',
99
102
  headers,
100
103
  });
@@ -15,6 +15,17 @@ import { BaseProject } from './BaseProject.js';
15
15
  export class HelixImportProject extends BaseProject {
16
16
  constructor() {
17
17
  super(HelixImportServer);
18
+
19
+ this._allowInsecure = true;
20
+ }
21
+
22
+ withAllowInsecure(value) {
23
+ this._allowInsecure = value;
24
+ return this;
25
+ }
26
+
27
+ get allowInsecure() {
28
+ return this._allowInsecure;
18
29
  }
19
30
 
20
31
  async start() {
@@ -101,7 +101,7 @@ export class HelixImportServer extends BaseServer {
101
101
  delete headers.host;
102
102
  delete headers.referer;
103
103
 
104
- const ret = await getFetch(true)(url, {
104
+ const ret = await getFetch(ctx.config.allowInsecure)(url, {
105
105
  method: req.method,
106
106
  headers,
107
107
  cache: 'no-store',
@@ -23,6 +23,7 @@ export class HelixProject extends BaseProject {
23
23
  this._headHtml = null;
24
24
  this._indexer = null;
25
25
  this._printIndex = false;
26
+ this._allowInsecure = false;
26
27
  this._file404html = null;
27
28
  }
28
29
 
@@ -41,10 +42,19 @@ export class HelixProject extends BaseProject {
41
42
  return this;
42
43
  }
43
44
 
45
+ withAllowInsecure(value) {
46
+ this._allowInsecure = value;
47
+ return this;
48
+ }
49
+
44
50
  get proxyUrl() {
45
51
  return this._proxyUrl;
46
52
  }
47
53
 
54
+ get allowInsecure() {
55
+ return this._allowInsecure;
56
+ }
57
+
48
58
  get indexer() {
49
59
  return this._indexer;
50
60
  }
@@ -77,6 +87,7 @@ export class HelixProject extends BaseProject {
77
87
  directory: this.directory,
78
88
  log: this.log,
79
89
  proxyUrl: this.proxyUrl,
90
+ allowInsecure: this.allowInsecure,
80
91
  });
81
92
 
82
93
  // register local head in live-reload
@@ -58,7 +58,7 @@ const utils = {
58
58
  if (auth) {
59
59
  headers.authorization = `Bearer ${auth}`;
60
60
  }
61
- const res = await getFetch()(uri, {
61
+ const res = await getFetch(ctx.config.allowInsecure)(uri, {
62
62
  cache: 'no-store',
63
63
  headers,
64
64
  });
@@ -258,7 +258,7 @@ window.LiveReloadOptions = {
258
258
  delete headers.connection;
259
259
  delete headers['proxy-connection'];
260
260
  delete headers.host;
261
- const ret = await getFetch()(url, {
261
+ const ret = await getFetch(ctx.config.allowInsecure)(url, {
262
262
  method: req.method,
263
263
  headers,
264
264
  cache: 'no-store',
package/src/up.cmd.js CHANGED
@@ -35,6 +35,11 @@ export default class UpCommand extends AbstractServerCommand {
35
35
  return this;
36
36
  }
37
37
 
38
+ withAllowInsecure(value) {
39
+ this._allowInsecure = value;
40
+ return this;
41
+ }
42
+
38
43
  async doStop() {
39
44
  await super.doStop();
40
45
  if (this._watcher) {
@@ -65,7 +70,8 @@ export default class UpCommand extends AbstractServerCommand {
65
70
  .withLiveReload(this._liveReload)
66
71
  .withLogger(this._logger)
67
72
  .withKill(this._kill)
68
- .withPrintIndex(this._printIndex);
73
+ .withPrintIndex(this._printIndex)
74
+ .withAllowInsecure(this._allowInsecure);
69
75
  this.log.info(chalk`{yellow ___ ________ ___ __ __ v${pkgJson.version}}`);
70
76
  this.log.info(chalk`{yellow / | / ____/ |/ / _____(_)___ ___ __ __/ /___ _/ /_____ _____}`);
71
77
  this.log.info(chalk`{yellow / /| | / __/ / /|_/ / / ___/ / __ \`__ \\/ / / / / __ \`/ __/ __ \\/ ___/}`);
@@ -79,7 +85,7 @@ export default class UpCommand extends AbstractServerCommand {
79
85
  await this.verifyUrl(this._gitUrl, ref);
80
86
  }
81
87
  this._project.withProxyUrl(this._url);
82
- await this.initSeverOptions();
88
+ await this.initServerOptions();
83
89
 
84
90
  try {
85
91
  await this._project.init();
@@ -111,7 +117,7 @@ export default class UpCommand extends AbstractServerCommand {
111
117
  // "testProperty": "header";
112
118
  // }
113
119
  const configUrl = `https://admin.hlx.page/sidekick/${gitUrl.owner}/${gitUrl.repo}/main/config.json`;
114
- const configResp = await getFetch()(configUrl);
120
+ const configResp = await getFetch(this._allowInsecure)(configUrl);
115
121
  let previewHostBase = 'hlx.page';
116
122
  if (configResp.ok) {
117
123
  // this is best effort for now
package/src/up.js CHANGED
@@ -92,6 +92,12 @@ export default function up() {
92
92
  type: 'string',
93
93
  })
94
94
  .group(['url', 'livereload', 'no-livereload', 'open', 'no-open', 'print-index', 'cache'], 'AEM Options')
95
+ .option('allow-insecure', {
96
+ alias: 'allowInsecure',
97
+ describe: 'Whether to allow insecure requests to the server',
98
+ type: 'boolean',
99
+ default: false,
100
+ })
95
101
 
96
102
  .help();
97
103
  },
@@ -112,6 +118,7 @@ export default function up() {
112
118
  .withLiveReload(argv.livereload)
113
119
  .withUrl(argv.url)
114
120
  .withPrintIndex(argv.printIndex)
121
+ .withAllowInsecure(argv.allowInsecure)
115
122
  .withKill(argv.stopOther)
116
123
  .withCache(argv.alphaCache)
117
124
  .run();