generator-jhipster-yellowbricks 1.2.0 → 1.2.2
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/generators/app/generator.js +18 -15
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { join } from 'node:path';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
4
|
|
|
5
5
|
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';
|
|
6
6
|
import stripJsonComments from 'strip-json-comments';
|
|
@@ -30,31 +30,31 @@ export default class extends BaseApplicationGenerator {
|
|
|
30
30
|
get [BaseApplicationGenerator.COMPOSING]() {
|
|
31
31
|
return this.asComposingTaskGroup({
|
|
32
32
|
async composeBricks() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
console.log('');
|
|
34
|
+
console.log('========================================');
|
|
35
|
+
console.log(' YellowBricks blueprint ');
|
|
36
|
+
console.log('========================================');
|
|
37
|
+
console.log('');
|
|
38
38
|
|
|
39
39
|
let useList = this.blueprintConfig.use ?? [];
|
|
40
40
|
|
|
41
41
|
const jsoncPath = join(this.destinationRoot(), '.yellowbricks.jsonc');
|
|
42
42
|
try {
|
|
43
43
|
const raw = await readFile(jsoncPath, 'utf8');
|
|
44
|
-
|
|
44
|
+
console.log('[yellowbricks] reading config from .yellowbricks.jsonc');
|
|
45
45
|
|
|
46
46
|
let parsed;
|
|
47
47
|
try {
|
|
48
48
|
// strip-json-comments removes // and /* */ but leaves trailing commas — strip those too
|
|
49
49
|
parsed = JSON.parse(stripJsonComments(raw).replace(/,(?=\s*[}\]])/g, ''));
|
|
50
50
|
} catch (e) {
|
|
51
|
-
|
|
51
|
+
console.error(`[yellowbricks] failed to parse .yellowbricks.jsonc: ${e.message}`);
|
|
52
52
|
parsed = {};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
if (Array.isArray(parsed.use)) {
|
|
56
56
|
useList = parsed.use;
|
|
57
|
-
|
|
57
|
+
console.log(`[yellowbricks] found ${useList.length} brick(s) to activate`);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Merge brick configs into .yo-rc.json so child generators can read them
|
|
@@ -69,9 +69,9 @@ export default class extends BaseApplicationGenerator {
|
|
|
69
69
|
this.fs.writeJSON(yorcPath, yorc);
|
|
70
70
|
} catch (e) {
|
|
71
71
|
if (e.code === 'ENOENT') {
|
|
72
|
-
|
|
72
|
+
console.log('[yellowbricks] no .yellowbricks.jsonc found, falling back to .yo-rc.json');
|
|
73
73
|
} else {
|
|
74
|
-
|
|
74
|
+
console.error(`[yellowbricks] error reading .yellowbricks.jsonc: ${e.message}`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -80,14 +80,17 @@ export default class extends BaseApplicationGenerator {
|
|
|
80
80
|
for (const pkgName of requested) {
|
|
81
81
|
const gen = getGen(pkgName);
|
|
82
82
|
if (!KNOWN_BRICKS.has(pkgName)) {
|
|
83
|
-
|
|
83
|
+
console.log(`[yellowbricks] unofficial brick "${pkgName}", trying to run for generator=${gen}`);
|
|
84
84
|
}
|
|
85
85
|
try {
|
|
86
86
|
const resolved = require.resolve(`${pkgName}/generators/${gen}`);
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
const packagePath = dirname(require.resolve(`${pkgName}/package.json`));
|
|
88
|
+
const namespace = `${pkgName}:${gen}`;
|
|
89
|
+
this.env.register(resolved, { namespace, packagePath });
|
|
90
|
+
await this.composeWith(namespace);
|
|
91
|
+
console.log(`[yellowbricks] activated brick: ${pkgName}`);
|
|
89
92
|
} catch {
|
|
90
|
-
|
|
93
|
+
console.error(
|
|
91
94
|
`[yellowbricks] could not load brick "${pkgName}" — check it is installed and has a generators/${gen} entry point`,
|
|
92
95
|
);
|
|
93
96
|
}
|
package/package.json
CHANGED