generator-jhipster-yellowbricks-angular-contextpath 1.1.2 → 1.1.4

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/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # generator-jhipster-yellowbricks-angular-contextpath
2
2
 
3
- A [JHipster](https://www.jhipster.tech/) blueprint that sets the Angular `baseHref` in `angular.json` to a configurable context path.
3
+ One of [![Yellow Bricks Badge](https://img.shields.io/badge/YELLOWBRICKS--yellow?style=for-the-badge&labelColor=black)](https://github.com/idNoRD/generator-jhipster-yellowbricks) - a [JHipster](https://www.jhipster.tech/) blueprint that sets the Angular `baseHref` in `angular.json` and prefixes the proxy routes in `proxy.config.mjs` to a configurable context path.
4
4
 
5
5
  [![NPM version][npm-image]][npm-url]
6
6
  [![Generator][github-generator-image]][github-generator-url]
7
7
  ![GitHub Maintained](https://img.shields.io/maintenance/yes/2026)
8
8
 
9
+ ## JHipster source
10
+
11
+ - Generator: [`generators/angular`](https://github.com/jhipster/generator-jhipster/tree/main/generators/angular)
12
+ - Templates: [`angular.json.ejs`](https://github.com/jhipster/generator-jhipster/blob/main/generators/angular/templates/angular.json.ejs), [`proxy.config.mjs.ejs`](https://github.com/jhipster/generator-jhipster/blob/main/generators/angular/templates/proxy.config.mjs.ejs)
13
+
9
14
  ## What it does
10
15
 
11
16
  Patches `angular.json` during generation to insert `baseHref` as the first key in `build.options`:
@@ -19,6 +24,13 @@ Patches `angular.json` during generation to insert `baseHref` as the first key i
19
24
  ...
20
25
  ```
21
26
 
27
+ Patches `proxy.config.mjs` to prefix the proxy route pattern with the context path so that dev-server requests are forwarded correctly:
28
+
29
+ ```diff
30
+ - '^/(api|management|v3/api-docs...)': {
31
+ + '^/jh/(api|management|v3/api-docs...)': {
32
+ ```
33
+
22
34
  The value is configurable — any context path can be used.
23
35
 
24
36
  ## Prerequisites
@@ -88,11 +88,30 @@ export default class extends BaseApplicationGenerator {
88
88
  const contextPath = this.blueprintConfig.contextPath;
89
89
  if (!contextPath) {
90
90
  this.log.warn(
91
- '[base-href blueprint] contextPath not configured — add {"generator-jhipster-yellowbricks-angular-contextpath":{"contextPath":"/jh/"}} to .yo-rc.json',
91
+ '[yellowbricks-angular-contextpath] contextPath not configured — add {"generator-jhipster-yellowbricks-angular-contextpath":{"contextPath":"/jh/"}} to .yo-rc.json',
92
92
  );
93
93
  return;
94
94
  }
95
95
 
96
+ this.editFile('proxy.config.mjs', { ignoreNonExisting: true }, content => {
97
+ const updatedPattern = `'^${contextPath}(`;
98
+
99
+ if (content.includes(updatedPattern)) {
100
+ return content;
101
+ }
102
+
103
+ const originalPattern = `'^/(`;
104
+ if (!content.includes(originalPattern)) {
105
+ this.log.warn(
106
+ `[yellowbricks-angular-contextpath] proxy.config.mjs: expected pattern ${originalPattern} not found — manual intervention needed`,
107
+ );
108
+ return content;
109
+ }
110
+
111
+ this.log.info(`[yellowbricks-angular-contextpath] proxy.config.mjs: proxy path prefix set to "${contextPath}"`);
112
+ return content.replace(originalPattern, updatedPattern);
113
+ });
114
+
96
115
  this.editFile('angular.json', { ignoreNonExisting: true }, content => {
97
116
  const json = JSON.parse(content);
98
117
  const projectName = Object.keys(json.projects ?? {})[0];
@@ -102,25 +121,33 @@ export default class extends BaseApplicationGenerator {
102
121
  const expectedBuilder = '@angular-builders/custom-esbuild:application';
103
122
 
104
123
  if (!build) {
105
- this.log.warn('[base-href blueprint] angular.json: architect.build section not found — manual intervention needed');
124
+ this.log.warn(
125
+ '[yellowbricks-angular-contextpath] angular.json: architect.build section not found — manual intervention needed',
126
+ );
106
127
  return content;
107
128
  }
108
129
  if (build.builder !== expectedBuilder) {
109
130
  this.log.warn(
110
- `[base-href blueprint] angular.json: expected builder "${expectedBuilder}" but found "${build.builder ?? 'undefined'}" — manual intervention needed`,
131
+ `[yellowbricks-angular-contextpath] angular.json: expected builder "${expectedBuilder}" but found "${build.builder ?? 'undefined'}" — manual intervention needed`,
111
132
  );
112
133
  return content;
113
134
  }
114
135
  if (!build.options) {
115
- this.log.warn('[base-href blueprint] angular.json: architect.build.options not found — manual intervention needed');
136
+ this.log.warn(
137
+ '[yellowbricks-angular-contextpath] angular.json: architect.build.options not found — manual intervention needed',
138
+ );
116
139
  return content;
117
140
  }
118
141
  if (!Array.isArray(build.options.plugins)) {
119
- this.log.warn('[base-href blueprint] angular.json: build.options.plugins array not found — manual intervention needed');
142
+ this.log.warn(
143
+ '[yellowbricks-angular-contextpath] angular.json: build.options.plugins array not found — manual intervention needed',
144
+ );
120
145
  return content;
121
146
  }
122
147
  if (!build.options.outputPath) {
123
- this.log.warn('[base-href blueprint] angular.json: build.options.outputPath not found — manual intervention needed');
148
+ this.log.warn(
149
+ '[yellowbricks-angular-contextpath] angular.json: build.options.outputPath not found — manual intervention needed',
150
+ );
124
151
  return content;
125
152
  }
126
153
  // --- end drift detection ---
@@ -132,9 +159,11 @@ export default class extends BaseApplicationGenerator {
132
159
  build.options = { baseHref: contextPath, ...remainingOptions };
133
160
 
134
161
  if (previousBaseHref && previousBaseHref !== contextPath) {
135
- this.log.info(`[base-href blueprint] angular.json: baseHref renamed from "${previousBaseHref}" to "${contextPath}"`);
162
+ this.log.info(
163
+ `[yellowbricks-angular-contextpath] angular.json: baseHref renamed from "${previousBaseHref}" to "${contextPath}"`,
164
+ );
136
165
  } else {
137
- this.log.info(`[base-href blueprint] angular.json: baseHref "${contextPath}" added successfully`);
166
+ this.log.info(`[yellowbricks-angular-contextpath] angular.json: baseHref "${contextPath}" added successfully`);
138
167
  }
139
168
 
140
169
  return `${JSON.stringify(json, null, 2)}\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-jhipster-yellowbricks-angular-contextpath",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "JHipster blueprint to configure Angular application baseHref via a custom context path",
5
5
  "keywords": [
6
6
  "yeoman-generator",
@@ -14,6 +14,7 @@
14
14
  },
15
15
  "license": "MIT",
16
16
  "author": "idNoRD",
17
+ "type": "module",
17
18
  "bin": {
18
19
  "jhipster-yellowbricks-angular-contextpath": "cli/cli.cjs"
19
20
  },