generator-jhipster-yellowbricks-spring-boot-contextpath 1.0.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/README.md +75 -0
- package/cli/cli-customizations.cjs +2 -0
- package/cli/cli.cjs +38 -0
- package/generators/spring-boot/command.js +13 -0
- package/generators/spring-boot/generator.js +159 -0
- package/generators/spring-boot/index.js +2 -0
- package/generators/spring-boot/templates/template-file-spring-boot.ejs +0 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# generator-jhipster-yellowbricks-spring-boot-contextpath
|
|
2
|
+
|
|
3
|
+
A [JHipster](https://www.jhipster.tech/) blueprint that sets `server.servlet.context-path` in `application.yml` to a configurable context path.
|
|
4
|
+
|
|
5
|
+
[![NPM version][npm-image]][npm-url]
|
|
6
|
+
[![Generator][github-generator-image]][github-generator-url]
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## JHipster source
|
|
10
|
+
|
|
11
|
+
- Generator: [`generators/spring-boot`](https://github.com/jhipster/generator-jhipster/tree/main/generators/spring-boot)
|
|
12
|
+
- Template: [`application.yml.ejs`](https://github.com/jhipster/generator-jhipster/blob/main/generators/spring-boot/templates/src/main/resources/config/application.yml.ejs)
|
|
13
|
+
|
|
14
|
+
## What it does
|
|
15
|
+
|
|
16
|
+
Patches `src/main/resources/config/application.yml` during generation to insert `context-path` as the first key in `server.servlet`:
|
|
17
|
+
|
|
18
|
+
```diff
|
|
19
|
+
server:
|
|
20
|
+
servlet:
|
|
21
|
+
+ context-path: /jh/
|
|
22
|
+
session:
|
|
23
|
+
cookie:
|
|
24
|
+
http-only: true
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The value is configurable — any context path can be used.
|
|
28
|
+
|
|
29
|
+
## Prerequisites
|
|
30
|
+
|
|
31
|
+
- Node.js `^22.18.0 || >=24.11.0`
|
|
32
|
+
- JHipster 9
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g generator-jhipster-yellowbricks-spring-boot-contextpath
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
Create a `.yo-rc.json` in your project directory with the desired context path:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"generator-jhipster-yellowbricks-spring-boot-contextpath": {
|
|
47
|
+
"contextPath": "/jh/"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Then run JHipster with this blueprint:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Standard generator
|
|
56
|
+
jhipster --blueprints yellowbricks-spring-boot-contextpath
|
|
57
|
+
|
|
58
|
+
# With JDL
|
|
59
|
+
jhipster import-jdl your-app.jdl --blueprints yellowbricks-spring-boot-contextpath
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Replace `/jh/` with your actual context path. The trailing slash is required.
|
|
63
|
+
|
|
64
|
+
## Pre-release
|
|
65
|
+
|
|
66
|
+
To use the latest unreleased version directly from GitHub:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install -g idNoRD/generator-jhipster-yellowbricks-spring-boot-contextpath#main
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
[npm-image]: https://img.shields.io/npm/v/generator-jhipster-yellowbricks-spring-boot-contextpath.svg
|
|
73
|
+
[npm-url]: https://npmjs.org/package/generator-jhipster-yellowbricks-spring-boot-contextpath
|
|
74
|
+
[github-generator-image]: https://github.com/idNoRD/generator-jhipster-yellowbricks-spring-boot-contextpath/actions/workflows/generator.yml/badge.svg
|
|
75
|
+
[github-generator-url]: https://github.com/idNoRD/generator-jhipster-yellowbricks-spring-boot-contextpath/actions/workflows/generator.yml
|
package/cli/cli.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { basename, dirname, join } = require('path');
|
|
4
|
+
|
|
5
|
+
const { bin, version } = require('../package.json');
|
|
6
|
+
|
|
7
|
+
// Get package name to use as namespace.
|
|
8
|
+
// Allows blueprints to be aliased.
|
|
9
|
+
const packagePath = dirname(__dirname);
|
|
10
|
+
const packageFolderName = basename(packagePath);
|
|
11
|
+
const devBlueprintPath = join(packagePath, '.blueprint');
|
|
12
|
+
const blueprint = packageFolderName.startsWith('jhipster-') ? `generator-${packageFolderName}` : packageFolderName;
|
|
13
|
+
|
|
14
|
+
(async () => {
|
|
15
|
+
const { runJHipster, done, logger } = await import('generator-jhipster/cli');
|
|
16
|
+
const executableName = Object.keys(bin)[0];
|
|
17
|
+
|
|
18
|
+
runJHipster({
|
|
19
|
+
executableName,
|
|
20
|
+
executableVersion: version,
|
|
21
|
+
defaultCommand: 'app',
|
|
22
|
+
devBlueprintPath,
|
|
23
|
+
blueprints: {
|
|
24
|
+
[blueprint]: version,
|
|
25
|
+
},
|
|
26
|
+
printBlueprintLogo: () => {
|
|
27
|
+
console.log('===================== JHipster Yellowbricks Spring Boot Contextpath =====================');
|
|
28
|
+
console.log('');
|
|
29
|
+
},
|
|
30
|
+
lookups: [{ packagePaths: [packagePath] }],
|
|
31
|
+
...require('./cli-customizations.cjs'),
|
|
32
|
+
}).catch(done);
|
|
33
|
+
|
|
34
|
+
process.on('unhandledRejection', up => {
|
|
35
|
+
logger.error('Unhandled promise rejection at:');
|
|
36
|
+
logger.fatal(up);
|
|
37
|
+
});
|
|
38
|
+
})();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { asCommand } from 'generator-jhipster';
|
|
2
|
+
|
|
3
|
+
export default asCommand({
|
|
4
|
+
configs: {
|
|
5
|
+
contextPath: {
|
|
6
|
+
description: 'Context path to set as server.servlet.context-path in application.yml (e.g. /jh/)',
|
|
7
|
+
cli: {
|
|
8
|
+
type: String,
|
|
9
|
+
},
|
|
10
|
+
scope: 'blueprint',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';
|
|
2
|
+
|
|
3
|
+
export default class extends BaseApplicationGenerator {
|
|
4
|
+
constructor(args, opts, features) {
|
|
5
|
+
super(args, opts, {
|
|
6
|
+
...features,
|
|
7
|
+
|
|
8
|
+
sbsBlueprint: true,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get [BaseApplicationGenerator.INITIALIZING]() {
|
|
13
|
+
return this.asInitializingTaskGroup({
|
|
14
|
+
async initializingTemplateTask() {},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get [BaseApplicationGenerator.PROMPTING]() {
|
|
19
|
+
return this.asPromptingTaskGroup({
|
|
20
|
+
async promptingTemplateTask() {},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get [BaseApplicationGenerator.CONFIGURING]() {
|
|
25
|
+
return this.asConfiguringTaskGroup({
|
|
26
|
+
async configuringTemplateTask() {},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get [BaseApplicationGenerator.COMPOSING]() {
|
|
31
|
+
return this.asComposingTaskGroup({
|
|
32
|
+
async composingTemplateTask() {},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get [BaseApplicationGenerator.COMPOSING_COMPONENT]() {
|
|
37
|
+
return this.asComposingComponentTaskGroup({
|
|
38
|
+
async composingComponentTemplateTask() {},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get [BaseApplicationGenerator.LOADING]() {
|
|
43
|
+
return this.asLoadingTaskGroup({
|
|
44
|
+
async loadingTemplateTask() {},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get [BaseApplicationGenerator.PREPARING]() {
|
|
49
|
+
return this.asPreparingTaskGroup({
|
|
50
|
+
async preparingTemplateTask() {},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get [BaseApplicationGenerator.POST_PREPARING]() {
|
|
55
|
+
return this.asPostPreparingTaskGroup({
|
|
56
|
+
async postPreparingTemplateTask() {},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get [BaseApplicationGenerator.DEFAULT]() {
|
|
61
|
+
return this.asDefaultTaskGroup({
|
|
62
|
+
async defaultTemplateTask() {},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get [BaseApplicationGenerator.WRITING]() {
|
|
67
|
+
return this.asWritingTaskGroup({
|
|
68
|
+
async writingTemplateTask({ application }) {
|
|
69
|
+
await this.writeFiles({
|
|
70
|
+
sections: {
|
|
71
|
+
files: [{ templates: ['template-file-spring-boot'] }],
|
|
72
|
+
},
|
|
73
|
+
context: application,
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get [BaseApplicationGenerator.MULTISTEP_TRANSFORM]() {
|
|
80
|
+
return this.asMultistepTransformTaskGroup({
|
|
81
|
+
async multistepTransformTemplateTask() {},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get [BaseApplicationGenerator.POST_WRITING]() {
|
|
86
|
+
return this.asPostWritingTaskGroup({
|
|
87
|
+
async addContextPath() {
|
|
88
|
+
const contextPath = this.blueprintConfig.contextPath;
|
|
89
|
+
if (!contextPath) {
|
|
90
|
+
this.log.warn(
|
|
91
|
+
'[context-path blueprint] contextPath not configured — add {"generator-jhipster-yellowbricks-spring-boot-contextpath":{"contextPath":"/jh/"}} to .yo-rc.json',
|
|
92
|
+
);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.editFile('src/main/resources/config/application.yml', { ignoreNonExisting: true }, content => {
|
|
97
|
+
// Drift detection: verify expected surrounding structure
|
|
98
|
+
if (!/^server:$/m.test(content)) {
|
|
99
|
+
this.log.warn('[context-path blueprint] application.yml: server section not found — manual intervention needed');
|
|
100
|
+
return content;
|
|
101
|
+
}
|
|
102
|
+
if (!/ {2}servlet:/.test(content)) {
|
|
103
|
+
this.log.warn('[context-path blueprint] application.yml: server.servlet section not found — manual intervention needed');
|
|
104
|
+
return content;
|
|
105
|
+
}
|
|
106
|
+
if (!/^\s+session:$/m.test(content)) {
|
|
107
|
+
this.log.warn(
|
|
108
|
+
'[context-path blueprint] application.yml: server.servlet.session section not found — manual intervention needed',
|
|
109
|
+
);
|
|
110
|
+
return content;
|
|
111
|
+
}
|
|
112
|
+
// End drift detection
|
|
113
|
+
|
|
114
|
+
// Capture existing context-path value if present
|
|
115
|
+
const previousMatch = content.match(/^ {4}context-path: (.+)$/m);
|
|
116
|
+
const previousContextPath = previousMatch ? previousMatch[1].trim() : null;
|
|
117
|
+
|
|
118
|
+
// Remove existing context-path line, then insert as first key under servlet:
|
|
119
|
+
let updated = content.replace(/^ {4}context-path: .+\n/m, '');
|
|
120
|
+
updated = updated.replace(/^( {2}servlet:\n)/m, `$1 context-path: ${contextPath}\n`);
|
|
121
|
+
|
|
122
|
+
if (previousContextPath && previousContextPath !== contextPath) {
|
|
123
|
+
this.log.info(
|
|
124
|
+
`[context-path blueprint] application.yml: context-path renamed from "${previousContextPath}" to "${contextPath}"`,
|
|
125
|
+
);
|
|
126
|
+
} else {
|
|
127
|
+
this.log.info(`[context-path blueprint] application.yml: context-path "${contextPath}" added successfully`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return updated;
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
get [BaseApplicationGenerator.TRANSFORM]() {
|
|
137
|
+
return this.asTransformTaskGroup({
|
|
138
|
+
async transformTemplateTask() {},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get [BaseApplicationGenerator.INSTALL]() {
|
|
143
|
+
return this.asInstallTaskGroup({
|
|
144
|
+
async installTemplateTask() {},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get [BaseApplicationGenerator.POST_INSTALL]() {
|
|
149
|
+
return this.asPostInstallTaskGroup({
|
|
150
|
+
async postInstallTemplateTask() {},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
get [BaseApplicationGenerator.END]() {
|
|
155
|
+
return this.asEndTaskGroup({
|
|
156
|
+
async endTemplateTask() {},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "generator-jhipster-yellowbricks-spring-boot-contextpath",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "JHipster blueprint to configure Spring Boot application context-path",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"yeoman-generator",
|
|
7
|
+
"jhipster-blueprint",
|
|
8
|
+
"jhipster-9",
|
|
9
|
+
"generator-jhipster-yellowbricks"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/idNoRD/generator-jhipster-yellowbricks-spring-boot-contextpath.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "idNoRD",
|
|
17
|
+
"bin": {
|
|
18
|
+
"jhipster-yellowbricks-spring-boot-contextpath": "cli/cli.cjs"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"cli",
|
|
22
|
+
"generators",
|
|
23
|
+
"!**/__*",
|
|
24
|
+
"!**/*.snap",
|
|
25
|
+
"!**/*.spec.?(c|m)js"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"ejslint": "ejslint generators/**/*.ejs",
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"lint-fix": "npm run ejslint && npm run lint -- --fix",
|
|
31
|
+
"prepare": "husky",
|
|
32
|
+
"prettier-check": "prettier --check \"{,**/}*.{md,json,yml,html,cjs,mjs,js,cts,mts,ts,tsx,css,scss,vue,java}\"",
|
|
33
|
+
"prettier-format": "prettier --write \"{,**/}*.{md,json,yml,html,cjs,mjs,js,cts,mts,ts,tsx,css,scss,vue,java}\"",
|
|
34
|
+
"pretest": "npm run prettier-check && npm run lint",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"update-snapshot": "vitest run --update",
|
|
37
|
+
"vitest": "vitest"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"generator-jhipster": "9.0.0-beta.3"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
44
|
+
"@semantic-release/exec": "^7.1.0",
|
|
45
|
+
"@semantic-release/git": "^10.0.1",
|
|
46
|
+
"@semantic-release/github": "^12.0.6",
|
|
47
|
+
"@semantic-release/npm": "^13.1.4",
|
|
48
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
49
|
+
"ejs-lint": "2.0.1",
|
|
50
|
+
"eslint": "9.39.2",
|
|
51
|
+
"eslint-config-prettier": "10.1.8",
|
|
52
|
+
"eslint-plugin-prettier": "5.5.5",
|
|
53
|
+
"globals": "17.3.0",
|
|
54
|
+
"husky": "9.1.7",
|
|
55
|
+
"jiti": "2.6.1",
|
|
56
|
+
"lint-staged": "16.2.7",
|
|
57
|
+
"prettier": "3.8.1",
|
|
58
|
+
"prettier-plugin-packagejson": "3.0.0",
|
|
59
|
+
"semantic-release": "^25.0.3",
|
|
60
|
+
"vitest": "4.0.18",
|
|
61
|
+
"yeoman-test": ">=10"
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"generator-jhipster": "9.0.0-beta.3",
|
|
65
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
66
|
+
}
|
|
67
|
+
}
|