@adobe/aem-cli 16.5.1 → 16.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [16.5.3](https://github.com/adobe/helix-cli/compare/v16.5.2...v16.5.3) (2024-06-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * support importing pages with authentication in importer ([aac442d](https://github.com/adobe/helix-cli/commit/aac442d4759a783695b21d41fbc0613177ca8d2d))
7
+
8
+ ## [16.5.2](https://github.com/adobe/helix-cli/compare/v16.5.1...v16.5.2) (2024-06-17)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update command name in message from 'hlx' to 'aem' ([#2384](https://github.com/adobe/helix-cli/issues/2384)) ([30d3ce0](https://github.com/adobe/helix-cli/commit/30d3ce06a810ec95bb3e5ae0bc216775b1160ed6))
14
+
1
15
  ## [16.5.1](https://github.com/adobe/helix-cli/compare/v16.5.0...v16.5.1) (2024-06-15)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aem-cli",
3
- "version": "16.5.1",
3
+ "version": "16.5.3",
4
4
  "description": "AEM CLI",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/import.cmd.js CHANGED
@@ -40,6 +40,11 @@ export default class ImportCommand extends AbstractServerCommand {
40
40
  return this;
41
41
  }
42
42
 
43
+ withHeadersFile(value) {
44
+ this._headersFile = value;
45
+ return this;
46
+ }
47
+
43
48
  async setupImporterUI() {
44
49
  const importerFolder = path.join(this.directory, this._importerSubPath);
45
50
  await fse.ensureDir(importerFolder);
@@ -86,7 +91,8 @@ export default class ImportCommand extends AbstractServerCommand {
86
91
  .withCwd(this.directory)
87
92
  .withLogger(this._logger)
88
93
  .withKill(this._kill)
89
- .withAllowInsecure(this._allowInsecure);
94
+ .withAllowInsecure(this._allowInsecure)
95
+ .withHeadersFile(this._headersFile);
90
96
  this.log.info(chalk`{yellow ___ ________ ___ __}`);
91
97
  this.log.info(chalk`{yellow / | / ____/ |/ / (_)___ ___ ____ ____ _____/ /____ _____}`);
92
98
  this.log.info(chalk`{yellow / /| | / __/ / /|_/ / / / __ \`__ \\/ __ \\/ __ \\/ ___/ __/ _ \\/ ___/}`);
package/src/import.js CHANGED
@@ -74,12 +74,18 @@ export default function up() {
74
74
  type: 'string',
75
75
  default: undefined,
76
76
  })
77
+ .option('headers-file', {
78
+ alias: 'headersFile',
79
+ describe: 'Location of a custom .json file containing headers to be used with all proxy requests',
80
+ type: 'string',
81
+ default: undefined,
82
+ })
77
83
  .group(['port', 'addr', 'stop-other', 'tls-cert', 'tls-key'], 'Server options')
78
84
  .option('cache', {
79
85
  describe: 'Path to local folder to cache the responses',
80
86
  type: 'string',
81
87
  })
82
- .group(['open', 'no-open', 'cache', 'ui-repo', 'skip-ui'], 'AEM Importer Options')
88
+ .group(['open', 'no-open', 'cache', 'ui-repo', 'skip-ui', 'headers-file'], 'AEM Importer Options')
83
89
  .option('allow-insecure', {
84
90
  alias: 'allowInsecure',
85
91
  describe: 'Whether to allow insecure requests to the server',
@@ -111,6 +117,7 @@ export default function up() {
111
117
  .withCache(argv.cache)
112
118
  .withSkipUI(argv.skipUI)
113
119
  .withUIRepo(argv.uiRepo)
120
+ .withHeadersFile(argv.headersFile)
114
121
  .run();
115
122
  },
116
123
  };
@@ -9,6 +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
+ import fs from 'fs-extra';
12
13
  import { HelixImportServer } from './HelixImportServer.js';
13
14
  import { BaseProject } from './BaseProject.js';
14
15
 
@@ -28,9 +29,28 @@ export class HelixImportProject extends BaseProject {
28
29
  return this._allowInsecure;
29
30
  }
30
31
 
32
+ withHeadersFile(value) {
33
+ this._headersFile = value;
34
+ return this;
35
+ }
36
+
37
+ get headersFile() {
38
+ return this._headersFile;
39
+ }
40
+
41
+ get cliHeaders() {
42
+ return this._cliHeaders;
43
+ }
44
+
31
45
  async start() {
32
46
  this.log.debug('Launching AEM import server for importing content...');
33
47
  await super.start();
48
+ try {
49
+ this._cliHeaders = (this._headersFile) ? await fs.readJSON(this._headersFile) : {};
50
+ } catch (error) {
51
+ this.log.error(`Failed to read headers file: ${error.message}`);
52
+ await this.doStop();
53
+ }
34
54
  return this;
35
55
  }
36
56
 
@@ -63,6 +63,11 @@ export class HelixImportServer extends BaseServer {
63
63
  return url.toString();
64
64
  }
65
65
 
66
+ async _updateHeaders(headers) {
67
+ // merge the headers defined with the CLI with those from the request
68
+ Object.assign(headers, await this._project.cliHeaders);
69
+ }
70
+
66
71
  async _doProxyRequest(ctx, url, host, req, res) {
67
72
  ctx.log.debug(`Proxy ${req.method} request to ${url}`);
68
73
 
@@ -100,6 +105,7 @@ export class HelixImportServer extends BaseServer {
100
105
  delete headers.connection;
101
106
  delete headers.host;
102
107
  delete headers.referer;
108
+ await this._updateHeaders(headers);
103
109
 
104
110
  const ret = await getFetch(ctx.config.allowInsecure)(url, {
105
111
  method: req.method,
package/src/up.cmd.js CHANGED
@@ -59,7 +59,7 @@ export default class UpCommand extends AbstractServerCommand {
59
59
  }
60
60
  } catch (e) {
61
61
  if (e.code === 'ENOENT') {
62
- throw Error('hlx up needs local git repository.');
62
+ throw Error('aem up needs local git repository.');
63
63
  }
64
64
  throw e;
65
65
  }