@adobe/aem-cli 16.2.14 → 16.3.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [16.3.0](https://github.com/adobe/helix-cli/compare/v16.2.14...v16.3.0) (2024-03-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * always proxy from main branch by default ([#2333](https://github.com/adobe/helix-cli/issues/2333)) ([e0b9be2](https://github.com/adobe/helix-cli/commit/e0b9be2f3d21f429c3b1b206145d50debacbac3c)), closes [#2331](https://github.com/adobe/helix-cli/issues/2331) [#2328](https://github.com/adobe/helix-cli/issues/2328)
7
+
1
8
  ## [16.2.14](https://github.com/adobe/helix-cli/compare/v16.2.13...v16.2.14) (2024-03-14)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aem-cli",
3
- "version": "16.2.14",
3
+ "version": "16.3.0",
4
4
  "description": "AEM CLI",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/up.cmd.js CHANGED
@@ -74,22 +74,16 @@ export default class UpCommand extends AbstractServerCommand {
74
74
  this.log.info('');
75
75
 
76
76
  const ref = await GitUtils.getBranch(this.directory);
77
- const gitUrl = await GitUtils.getOriginURL(this.directory, { ref });
78
- let explicitURL = true;
77
+ this._gitUrl = await GitUtils.getOriginURL(this.directory, { ref });
79
78
  if (!this._url) {
80
- explicitURL = false;
81
- // check if remote already has the `ref`
82
- await this.verifyUrl(gitUrl, ref);
79
+ await this.verifyUrl(this._gitUrl, ref);
83
80
  }
84
81
  this._project.withProxyUrl(this._url);
85
82
  await this.initSeverOptions();
86
83
 
87
84
  try {
88
85
  await this._project.init();
89
-
90
- if (!explicitURL) {
91
- this.watchGit();
92
- }
86
+ this.watchGit();
93
87
  } catch (e) {
94
88
  throw Error(`Unable to start AEM: ${e.message}`);
95
89
  }
@@ -99,7 +93,7 @@ export default class UpCommand extends AbstractServerCommand {
99
93
  });
100
94
  }
101
95
 
102
- async verifyUrl(gitUrl, inref) {
96
+ async verifyUrl(gitUrl, ref) {
103
97
  // check if the site is on helix5
104
98
  // https://admin.hlx.page/sidekick/adobe/www-aem-live/main/config.json
105
99
  // {
@@ -116,7 +110,7 @@ export default class UpCommand extends AbstractServerCommand {
116
110
  // "project": "Helix Website (AEM Live)",
117
111
  // "testProperty": "header";
118
112
  // }
119
- const configUrl = `https://admin.hlx.page/sidekick/${gitUrl.owner}/${gitUrl.repo}/${inref}/config.json`;
113
+ const configUrl = `https://admin.hlx.page/sidekick/${gitUrl.owner}/${gitUrl.repo}/main/config.json`;
120
114
  const configResp = await getFetch()(configUrl);
121
115
  let previewHostBase = 'hlx.page';
122
116
  if (configResp.ok) {
@@ -128,34 +122,17 @@ export default class UpCommand extends AbstractServerCommand {
128
122
  }
129
123
  }
130
124
 
131
- let ref = inref;
132
-
133
- // replace `/` by `-` in ref.
134
- ref = ref.replace(/\//g, '-');
135
- this._url = `https://${ref}--${gitUrl.repo}--${gitUrl.owner}.${previewHostBase}`;
125
+ const dnsName = `${ref.replace(/\//g, '-')}--${gitUrl.repo}--${gitUrl.owner}`;
136
126
  // check length limit
137
- if (this._url.split('.')
138
- .map((part) => part.replace(/^https:\/\//, ''))
139
- .some((part) => part.length > 63)) {
140
- this.log.error(chalk`URL {yellow ${this._url}} exceeds the 63 character limit for DNS labels.`);
127
+ if (dnsName.length > 63) {
128
+ this.log.error(chalk`URL {yellow https://${dnsName}.${previewHostBase}} exceeds the 63 character limit for DNS labels.`);
141
129
  this.log.error(chalk`Please use a shorter branch name or a shorter repository name.`);
142
130
  await this.stop();
143
131
  throw Error('branch name too long');
144
132
  }
145
133
 
146
- const fstabUrl = `${this._url}/fstab.yaml`;
147
- const resp = await getFetch()(fstabUrl);
148
- await resp.buffer();
149
- if (!resp.ok) {
150
- if (resp.status === 401) {
151
- this.log.warn(chalk`Unable to verify {yellow ${ref}} branch via {blue ${fstabUrl}} for authenticated sites.`);
152
- } else if (ref === 'main') {
153
- this.log.warn(chalk`Unable to verify {yellow main} branch via {blue ${fstabUrl}} (${resp.status}). Maybe not pushed yet?`);
154
- } else {
155
- this.log.warn(chalk`Unable to verify {yellow ${ref}} branch on {blue ${fstabUrl}} (${resp.status}). Fallback to {yellow main} branch.`);
156
- this._url = `https://main--${gitUrl.repo}--${gitUrl.owner}.${previewHostBase}`;
157
- }
158
- }
134
+ // always proxy to main
135
+ this._url = `https://main--${gitUrl.repo}--${gitUrl.owner}.${previewHostBase}`;
159
136
  }
160
137
 
161
138
  /**
@@ -183,14 +160,17 @@ export default class UpCommand extends AbstractServerCommand {
183
160
  }
184
161
  try {
185
162
  // restart if any of the files is not ignored
186
- this.log.info('git HEAD or remotes changed, reconfiguring server...');
187
163
  const ref = await GitUtils.getBranch(this.directory);
188
164
  const gitUrl = await GitUtils.getOriginURL(this.directory, { ref });
189
- await this.verifyUrl(gitUrl, ref);
190
- this._project.withProxyUrl(this._url);
191
- await this._project.initHeadHtml();
192
- this.log.info(`Updated proxy to ${this._url}`);
193
- this.emit('changed', this);
165
+ if (gitUrl.toString() !== this._gitUrl.toString()) {
166
+ this.log.info('git HEAD or remotes changed, reconfiguring server...');
167
+ this._gitUrl = gitUrl;
168
+ await this.verifyUrl(gitUrl, ref);
169
+ this._project.withProxyUrl(this._url);
170
+ await this._project.initHeadHtml();
171
+ this.log.info(`Updated proxy to ${this._url}`);
172
+ this.emit('changed', this);
173
+ }
194
174
  } catch {
195
175
  // ignore
196
176
  }