@abgov/nx-adsp 12.16.0 → 12.17.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/generators.json +17 -0
- package/package.json +5 -1
- package/src/generators/angular-app/angular-app.js +15 -8
- package/src/generators/angular-app/angular-app.js.map +1 -1
- package/src/generators/angular-app/files/src/app/app.component.ts__tmpl__ +2 -2
- package/src/generators/angular-app/schema.json +5 -0
- package/src/generators/mevn/mevn.d.ts +3 -0
- package/src/generators/mevn/mevn.js +70 -0
- package/src/generators/mevn/mevn.js.map +1 -0
- package/src/generators/mevn/mevn.spec.ts +47 -0
- package/src/generators/mevn/schema.d.ts +14 -0
- package/src/generators/mevn/schema.json +60 -0
- package/src/generators/pevn/pevn.d.ts +3 -0
- package/src/generators/pevn/pevn.js +70 -0
- package/src/generators/pevn/pevn.js.map +1 -0
- package/src/generators/pevn/pevn.spec.ts +47 -0
- package/src/generators/pevn/schema.d.ts +14 -0
- package/src/generators/pevn/schema.json +60 -0
- package/src/generators/react-app/schema.json +5 -0
- package/src/generators/vue-app/files/AGENTS.md__tmpl__ +97 -0
- package/src/generators/vue-app/files/nginx.conf__tmpl__ +45 -0
- package/src/generators/vue-app/files/src/App.vue__tmpl__ +39 -0
- package/src/generators/vue-app/files/src/assets/banner.jpg +0 -0
- package/src/generators/vue-app/files/src/environments/environment.ts__tmpl__ +11 -0
- package/src/generators/vue-app/files/src/index.html__tmpl__ +22 -0
- package/src/generators/vue-app/files/src/main.ts__tmpl__ +28 -0
- package/src/generators/vue-app/files/src/router/index.ts__tmpl__ +29 -0
- package/src/generators/vue-app/files/src/silent-check-sso.html__tmpl__ +5 -0
- package/src/generators/vue-app/files/src/views/HomeView.vue__tmpl__ +49 -0
- package/src/generators/vue-app/files/src/views/ProtectedView.vue__tmpl__ +14 -0
- package/src/generators/vue-app/files/vite.config.ts__tmpl__ +50 -0
- package/src/generators/vue-app/schema.d.ts +22 -0
- package/src/generators/vue-app/schema.json +85 -0
- package/src/generators/vue-app/vue-app.d.ts +3 -0
- package/src/generators/vue-app/vue-app.js +140 -0
- package/src/generators/vue-app/vue-app.js.map +1 -0
- package/src/generators/vue-app/vue-app.spec.ts +93 -0
- package/src/utils/agent.d.ts +1 -1
- package/src/utils/agent.js +5 -3
- package/src/utils/agent.js.map +1 -1
package/generators.json
CHANGED
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"schema": "./src/generators/angular-app/schema.json",
|
|
45
45
|
"description": "Generator that creates a Angular based frontend application."
|
|
46
46
|
},
|
|
47
|
+
"vue-app": {
|
|
48
|
+
"factory": "./src/generators/vue-app/vue-app",
|
|
49
|
+
"schema": "./src/generators/vue-app/schema.json",
|
|
50
|
+
"description": "Generator that creates a Vue 3 frontend application using GoA web components."
|
|
51
|
+
},
|
|
47
52
|
"mean": {
|
|
48
53
|
"factory": "./src/generators/mean/mean",
|
|
49
54
|
"schema": "./src/generators/mean/schema.json",
|
|
@@ -61,6 +66,18 @@
|
|
|
61
66
|
"schema": "./src/generators/pean/schema.json",
|
|
62
67
|
"description": "Generator that creates a PEAN fullstack solution.",
|
|
63
68
|
"hidden": true
|
|
69
|
+
},
|
|
70
|
+
"pevn": {
|
|
71
|
+
"factory": "./src/generators/pevn/pevn",
|
|
72
|
+
"schema": "./src/generators/pevn/schema.json",
|
|
73
|
+
"description": "Generator that creates a PEVN fullstack solution.",
|
|
74
|
+
"hidden": true
|
|
75
|
+
},
|
|
76
|
+
"mevn": {
|
|
77
|
+
"factory": "./src/generators/mevn/mevn",
|
|
78
|
+
"schema": "./src/generators/mevn/schema.json",
|
|
79
|
+
"description": "Generator that creates a MEVN fullstack solution.",
|
|
80
|
+
"hidden": true
|
|
64
81
|
}
|
|
65
82
|
}
|
|
66
83
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/nx-adsp",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.17.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"description": "Government of Alberta - Nx plugin for ADSP apps.",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"@nx/eslint": "^22.0.0",
|
|
18
18
|
"@nx/express": "^22.0.0",
|
|
19
19
|
"@nx/react": "^22.0.0",
|
|
20
|
+
"@nx/vue": "^22.0.0",
|
|
20
21
|
"tslib": "^2.0.0"
|
|
21
22
|
},
|
|
22
23
|
"peerDependenciesMeta": {
|
|
@@ -25,6 +26,9 @@
|
|
|
25
26
|
},
|
|
26
27
|
"@nx/angular": {
|
|
27
28
|
"optional": true
|
|
29
|
+
},
|
|
30
|
+
"@nx/vue": {
|
|
31
|
+
"optional": true
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
@@ -56,7 +56,7 @@ function addFiles(host, options) {
|
|
|
56
56
|
}
|
|
57
57
|
function default_1(host, options) {
|
|
58
58
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
59
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
60
60
|
const normalizedOptions = yield normalizeOptions(host, options);
|
|
61
61
|
const { applicationGenerator: initAngular } = yield Promise.resolve().then(() => require('@nx/angular/generators'));
|
|
62
62
|
yield initAngular(host, {
|
|
@@ -89,6 +89,13 @@ function default_1(host, options) {
|
|
|
89
89
|
if ((_b = (_a = config.targets.build.configurations) === null || _a === void 0 ? void 0 : _a.production) === null || _b === void 0 ? void 0 : _b.fileReplacements) {
|
|
90
90
|
delete config.targets.build.configurations.production.fileReplacements;
|
|
91
91
|
}
|
|
92
|
+
// keycloak-js pushes the initial bundle above Angular's default 1 MB error budget.
|
|
93
|
+
if ((_c = config.targets.build.configurations) === null || _c === void 0 ? void 0 : _c.production) {
|
|
94
|
+
config.targets.build.configurations.production.budgets = [
|
|
95
|
+
{ type: 'initial', maximumWarning: '2mb', maximumError: '4mb' },
|
|
96
|
+
{ type: 'anyComponentStyle', maximumWarning: '6kb', maximumError: '10kb' },
|
|
97
|
+
];
|
|
98
|
+
}
|
|
92
99
|
config.targets.build.options = Object.assign(Object.assign({}, config.targets.build.options), { polyfills: ['zone.js'], assets: [
|
|
93
100
|
...config.targets.build.options.assets,
|
|
94
101
|
`${normalizedOptions.projectRoot}/src/silent-check-sso.html`,
|
|
@@ -106,7 +113,7 @@ function default_1(host, options) {
|
|
|
106
113
|
(0, quality_1.addSemgrepTarget)(host, options.name);
|
|
107
114
|
yield (0, devkit_1.formatFiles)(host);
|
|
108
115
|
if (normalizedOptions.adsp) {
|
|
109
|
-
const accessToken = (
|
|
116
|
+
const accessToken = (_d = normalizedOptions.adsp.accessToken) !== null && _d !== void 0 ? _d : options.accessToken;
|
|
110
117
|
const clientId = `urn:ads:${normalizedOptions.adsp.tenant}:${normalizedOptions.projectName}`;
|
|
111
118
|
yield (0, keycloak_admin_1.ensurePublicClient)(normalizedOptions.adsp.accessServiceUrl, normalizedOptions.adsp.tenantRealm, clientId, accessToken);
|
|
112
119
|
if (options.serviceClientId) {
|
|
@@ -115,12 +122,12 @@ function default_1(host, options) {
|
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
if (normalizedOptions.adsp && !options.skipAgent) {
|
|
118
|
-
const accessToken = (
|
|
119
|
-
const appComponentTs = (
|
|
120
|
-
const appComponentHtml = (
|
|
121
|
-
const appConfigTs = (
|
|
122
|
-
const appRoutesTs = (
|
|
123
|
-
const environmentTs = (
|
|
125
|
+
const accessToken = (_e = normalizedOptions.adsp.accessToken) !== null && _e !== void 0 ? _e : options.accessToken;
|
|
126
|
+
const appComponentTs = (_g = (_f = host.read(`${normalizedOptions.projectRoot}/src/app/app.component.ts`)) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : '';
|
|
127
|
+
const appComponentHtml = (_j = (_h = host.read(`${normalizedOptions.projectRoot}/src/app/app.component.html`)) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : '';
|
|
128
|
+
const appConfigTs = (_l = (_k = host.read(`${normalizedOptions.projectRoot}/src/app/app.config.ts`)) === null || _k === void 0 ? void 0 : _k.toString()) !== null && _l !== void 0 ? _l : '';
|
|
129
|
+
const appRoutesTs = (_o = (_m = host.read(`${normalizedOptions.projectRoot}/src/app/app.routes.ts`)) === null || _m === void 0 ? void 0 : _m.toString()) !== null && _o !== void 0 ? _o : '';
|
|
130
|
+
const environmentTs = (_q = (_p = host.read(`${normalizedOptions.projectRoot}/src/environments/environment.ts`)) === null || _p === void 0 ? void 0 : _p.toString()) !== null && _q !== void 0 ? _q : '';
|
|
124
131
|
yield (0, agent_1.confirmAfterAgentInterrupt)(yield (0, agent_1.consultAgent)(normalizedOptions.adsp.directoryServiceUrl, accessToken, {
|
|
125
132
|
projectName: normalizedOptions.projectName,
|
|
126
133
|
projectType: 'angular-app',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/angular-app/angular-app.ts"],"names":[],"mappings":";;AAkGA,
|
|
1
|
+
{"version":3,"file":"angular-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/angular-app/angular-app.ts"],"names":[],"mappings":";;AAkGA,4BAmJC;;AArPD,wCAAyE;AACzE,6CAA6E;AAC7E,+DAA6G;AAC7G,+DAA4D;AAC5D,iDAAiG;AACjG,uCAYoB;AACpB,6BAA6B;AAG7B,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAkC;;QAElC,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;QACzE,MA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AAA,kCAA0B,EAAC,MAAM,IAAA,oBAAY,EACjD,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,EAC1C,WAAW,EACX;gBACE,WAAW,EAAE,iBAAiB,CAAC,WAAW;gBAC1C,WAAW,EAAE,aAAa;gBAC1B,MAAM,EAAE,iBAAiB,CAAC,IAAI,CAAC,MAAM;gBACrC,aAAa,EAAE,+BAAc;gBAC7B,aAAa,EAAE;oBACb,0BAA0B,EAAE,cAAc;oBAC1C,4BAA4B,EAAE,gBAAgB;oBAC9C,uBAAuB,EAAE,WAAW;oBACpC,uBAAuB,EAAE,WAAW;oBACpC,iCAAiC,EAAE,aAAa;iBACjD;aACF,EACD,IAAI,EACJ,iBAAiB,CAAC,WAAW,CAC9B,CAAC,CAAC;QACL,CAAC;QAED,MAAM,IAAA,2BAAmB,EAAC,IAAI,kCACzB,iBAAiB,KACpB,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,iBAAiB,CAAC,WAAW,IACtC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
GoabMicrositeHeader,
|
|
10
10
|
} from '@abgov/angular-components';
|
|
11
11
|
import Keycloak from 'keycloak-js';
|
|
12
|
-
import { getAccessToken } from './user.slice';
|
|
13
12
|
|
|
14
13
|
@Component({
|
|
15
14
|
selector: '<%= projectName %>-root',
|
|
@@ -39,7 +38,8 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
39
38
|
error: () => (this.publicResource = 'Error loading data'),
|
|
40
39
|
});
|
|
41
40
|
if (this.isLoggedIn) {
|
|
42
|
-
|
|
41
|
+
this.keycloak.updateToken(30).then(() => {
|
|
42
|
+
const token = this.keycloak.token ?? '';
|
|
43
43
|
this.http.get<{ message: string }>('/api/v1/private', {
|
|
44
44
|
headers: { Authorization: `Bearer ${token}` },
|
|
45
45
|
}).subscribe({
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const nx_oc_1 = require("@abgov/nx-oc");
|
|
7
|
+
const express_service_1 = require("../express-service/express-service");
|
|
8
|
+
const vue_app_1 = require("../vue-app/vue-app");
|
|
9
|
+
const agent_1 = require("../../utils/agent");
|
|
10
|
+
const keycloak_admin_1 = require("../../utils/keycloak-admin");
|
|
11
|
+
const plugin_version_1 = require("../../utils/plugin-version");
|
|
12
|
+
function normalizeOptions(host, options) {
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
var _a;
|
|
15
|
+
const adsp = yield (0, nx_oc_1.getAdspConfiguration)(host, options);
|
|
16
|
+
return Object.assign(Object.assign({}, options), { accessToken: (_a = adsp.accessToken) !== null && _a !== void 0 ? _a : options.accessToken, adsp });
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function default_1(host, options) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
22
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
23
|
+
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
24
|
+
const serviceName = `${projectName}-service`;
|
|
25
|
+
const appName = `${projectName}-app`;
|
|
26
|
+
const appsDir = (0, devkit_1.getWorkspaceLayout)(host).appsDir;
|
|
27
|
+
const serviceRoot = `${appsDir}/${serviceName}`;
|
|
28
|
+
const appRoot = `${appsDir}/${appName}`;
|
|
29
|
+
yield (0, express_service_1.default)(host, Object.assign(Object.assign({}, normalizedOptions), { name: serviceName, skipAgent: true, database: 'mongo' }));
|
|
30
|
+
yield (0, vue_app_1.default)(host, Object.assign(Object.assign({}, normalizedOptions), { name: appName, proxy: {
|
|
31
|
+
location: '/api/',
|
|
32
|
+
proxyPass: `http://${serviceName}:3333/${serviceName}/`,
|
|
33
|
+
}, skipAgent: true }));
|
|
34
|
+
if (normalizedOptions.adsp) {
|
|
35
|
+
const accessToken = (_a = normalizedOptions.adsp.accessToken) !== null && _a !== void 0 ? _a : normalizedOptions.accessToken;
|
|
36
|
+
const serviceClientId = `urn:ads:${normalizedOptions.adsp.tenant}:${serviceName}`;
|
|
37
|
+
const appClientId = `urn:ads:${normalizedOptions.adsp.tenant}:${appName}`;
|
|
38
|
+
yield (0, keycloak_admin_1.ensureAudienceMapper)(normalizedOptions.adsp.accessServiceUrl, normalizedOptions.adsp.tenantRealm, appClientId, serviceClientId, accessToken);
|
|
39
|
+
yield (0, keycloak_admin_1.ensureClientRoleScope)(normalizedOptions.adsp.accessServiceUrl, normalizedOptions.adsp.tenantRealm, appClientId, serviceClientId, 'example-role', accessToken);
|
|
40
|
+
}
|
|
41
|
+
if (normalizedOptions.adsp && !normalizedOptions.skipAgent) {
|
|
42
|
+
const accessToken = (_b = normalizedOptions.adsp.accessToken) !== null && _b !== void 0 ? _b : (yield (0, nx_oc_1.realmLogin)(normalizedOptions.adsp.accessServiceUrl, normalizedOptions.adsp.tenantRealm).catch((err) => {
|
|
43
|
+
var _a;
|
|
44
|
+
process.stdout.write(`\n[nx-adsp] Agent sign-in failed (${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : err}) — skipping agent interaction.\n`);
|
|
45
|
+
return undefined;
|
|
46
|
+
}));
|
|
47
|
+
yield (0, agent_1.confirmAfterAgentInterrupt)(yield (0, agent_1.consultAgent)(normalizedOptions.adsp.directoryServiceUrl, accessToken, {
|
|
48
|
+
projectName,
|
|
49
|
+
projectType: 'mevn',
|
|
50
|
+
tenant: normalizedOptions.adsp.tenant,
|
|
51
|
+
pluginVersion: plugin_version_1.PLUGIN_VERSION,
|
|
52
|
+
existingFiles: {
|
|
53
|
+
'service/src/main.ts': (_d = (_c = host.read(`${serviceRoot}/src/main.ts`)) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : '',
|
|
54
|
+
'service/src/environment.ts': (_f = (_e = host.read(`${serviceRoot}/src/environment.ts`)) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : '',
|
|
55
|
+
'service/src/database.ts': (_h = (_g = host.read(`${serviceRoot}/src/database.ts`)) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : '',
|
|
56
|
+
'service/src/events.ts': (_k = (_j = host.read(`${serviceRoot}/src/events.ts`)) === null || _j === void 0 ? void 0 : _j.toString()) !== null && _k !== void 0 ? _k : '',
|
|
57
|
+
'app/src/App.vue': (_m = (_l = host.read(`${appRoot}/src/App.vue`)) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : '',
|
|
58
|
+
'app/src/main.ts': (_p = (_o = host.read(`${appRoot}/src/main.ts`)) === null || _o === void 0 ? void 0 : _o.toString()) !== null && _p !== void 0 ? _p : '',
|
|
59
|
+
'app/src/router/index.ts': (_r = (_q = host.read(`${appRoot}/src/router/index.ts`)) === null || _q === void 0 ? void 0 : _q.toString()) !== null && _r !== void 0 ? _r : '',
|
|
60
|
+
'app/src/environments/environment.ts': (_t = (_s = host.read(`${appRoot}/src/environments/environment.ts`)) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : '',
|
|
61
|
+
},
|
|
62
|
+
}, host, serviceRoot, { additionalRoots: { 'app': appRoot } }));
|
|
63
|
+
}
|
|
64
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
65
|
+
return () => {
|
|
66
|
+
(0, devkit_1.installPackagesTask)(host);
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=mevn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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AE,EAAE,CACxC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readProjectConfiguration } from '@nx/devkit';
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
+
|
|
4
|
+
import * as utils from '@abgov/nx-oc';
|
|
5
|
+
import { environments } from '@abgov/nx-oc';
|
|
6
|
+
import { Schema } from './schema';
|
|
7
|
+
import generator from './mevn';
|
|
8
|
+
|
|
9
|
+
jest.mock('@nx/devkit', () => ({ ...jest.requireActual('@nx/devkit'), formatFiles: jest.fn().mockResolvedValue(undefined) }));
|
|
10
|
+
jest.mock('@abgov/nx-oc');
|
|
11
|
+
jest.mock('../../utils/agent', () => ({
|
|
12
|
+
consultAgent: jest.fn().mockResolvedValue(null),
|
|
13
|
+
confirmAfterAgentInterrupt: jest.fn().mockResolvedValue(undefined),
|
|
14
|
+
}));
|
|
15
|
+
const utilsMock = utils as jest.Mocked<typeof utils>;
|
|
16
|
+
utilsMock.getAdspConfiguration.mockResolvedValue({
|
|
17
|
+
tenant: 'test',
|
|
18
|
+
tenantRealm: 'test',
|
|
19
|
+
accessServiceUrl: environments.test.accessServiceUrl,
|
|
20
|
+
directoryServiceUrl: environments.test.directoryServiceUrl,
|
|
21
|
+
});
|
|
22
|
+
utilsMock.realmLogin.mockResolvedValue('test-token');
|
|
23
|
+
|
|
24
|
+
describe('MEVN Generator', () => {
|
|
25
|
+
const options: Schema = {
|
|
26
|
+
name: 'test',
|
|
27
|
+
env: 'dev',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
it('can run', async () => {
|
|
31
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
32
|
+
await generator(host, options);
|
|
33
|
+
|
|
34
|
+
const appConfig = readProjectConfiguration(host, 'test-app');
|
|
35
|
+
expect(appConfig.root).toBe('apps/test-app');
|
|
36
|
+
|
|
37
|
+
const serviceConfig = readProjectConfiguration(host, 'test-service');
|
|
38
|
+
expect(serviceConfig.root).toBe('apps/test-service');
|
|
39
|
+
|
|
40
|
+
expect(host.exists('apps/test-app/nginx.conf')).toBeTruthy();
|
|
41
|
+
const nginxConf = host.read('apps/test-app/nginx.conf').toString();
|
|
42
|
+
expect(nginxConf).toContain('http://test-service:3333/');
|
|
43
|
+
|
|
44
|
+
expect(host.exists('apps/test-app/src/App.vue')).toBeTruthy();
|
|
45
|
+
expect(host.exists('apps/test-service/prisma/schema.prisma')).toBeFalsy();
|
|
46
|
+
}, 30000);
|
|
47
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AdspConfiguration, EnvironmentName } from '@abgov/nx-oc';
|
|
2
|
+
|
|
3
|
+
export interface Schema {
|
|
4
|
+
name: string;
|
|
5
|
+
env: EnvironmentName;
|
|
6
|
+
accessToken?: string;
|
|
7
|
+
tenant?: string;
|
|
8
|
+
tenantRealm?: string;
|
|
9
|
+
skipAgent?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface NormalizedSchema extends Schema {
|
|
13
|
+
adsp: AdspConfiguration;
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"id": "NxAdspMevn",
|
|
4
|
+
"title": "MEVN Stack ADSP Solution",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Name of the MEVN stack solution.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "What name would you like to use?"
|
|
15
|
+
},
|
|
16
|
+
"env": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Environment to target.",
|
|
19
|
+
"$default": {
|
|
20
|
+
"$source": "argv",
|
|
21
|
+
"index": 1
|
|
22
|
+
},
|
|
23
|
+
"alias": "e",
|
|
24
|
+
"x-prompt": {
|
|
25
|
+
"message": "Which ADSP environment do you want to target?",
|
|
26
|
+
"type": "list",
|
|
27
|
+
"items": [
|
|
28
|
+
"dev",
|
|
29
|
+
"test",
|
|
30
|
+
"prod"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"tenant": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "ADSP tenant name. Enables a single browser login for the full stack — service and frontend agent interactions both use the same tenant-realm token.",
|
|
37
|
+
"alias": "t"
|
|
38
|
+
},
|
|
39
|
+
"tenantRealm": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Keycloak realm UUID. Optional when --tenant is provided — overrides the realm looked up from the tenant service.",
|
|
42
|
+
"alias": "tr"
|
|
43
|
+
},
|
|
44
|
+
"accessToken": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Access token for retrieving configuration from ADSP APIs.",
|
|
47
|
+
"alias": "at"
|
|
48
|
+
},
|
|
49
|
+
"skipAgent": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"description": "Skip the consultAgent interaction and generate base scaffolding only.",
|
|
52
|
+
"default": false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"required": [
|
|
56
|
+
"name",
|
|
57
|
+
"env"
|
|
58
|
+
],
|
|
59
|
+
"additionalProperties": false
|
|
60
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const nx_oc_1 = require("@abgov/nx-oc");
|
|
7
|
+
const express_service_1 = require("../express-service/express-service");
|
|
8
|
+
const vue_app_1 = require("../vue-app/vue-app");
|
|
9
|
+
const agent_1 = require("../../utils/agent");
|
|
10
|
+
const keycloak_admin_1 = require("../../utils/keycloak-admin");
|
|
11
|
+
const plugin_version_1 = require("../../utils/plugin-version");
|
|
12
|
+
function normalizeOptions(host, options) {
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
var _a;
|
|
15
|
+
const adsp = yield (0, nx_oc_1.getAdspConfiguration)(host, options);
|
|
16
|
+
return Object.assign(Object.assign({}, options), { accessToken: (_a = adsp.accessToken) !== null && _a !== void 0 ? _a : options.accessToken, adsp });
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function default_1(host, options) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
22
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
23
|
+
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
24
|
+
const serviceName = `${projectName}-service`;
|
|
25
|
+
const appName = `${projectName}-app`;
|
|
26
|
+
const appsDir = (0, devkit_1.getWorkspaceLayout)(host).appsDir;
|
|
27
|
+
const serviceRoot = `${appsDir}/${serviceName}`;
|
|
28
|
+
const appRoot = `${appsDir}/${appName}`;
|
|
29
|
+
yield (0, express_service_1.default)(host, Object.assign(Object.assign({}, normalizedOptions), { name: serviceName, skipAgent: true, database: 'postgres' }));
|
|
30
|
+
yield (0, vue_app_1.default)(host, Object.assign(Object.assign({}, normalizedOptions), { name: appName, proxy: {
|
|
31
|
+
location: '/api/',
|
|
32
|
+
proxyPass: `http://${serviceName}:3333/${serviceName}/`,
|
|
33
|
+
}, skipAgent: true }));
|
|
34
|
+
if (normalizedOptions.adsp) {
|
|
35
|
+
const accessToken = (_a = normalizedOptions.adsp.accessToken) !== null && _a !== void 0 ? _a : normalizedOptions.accessToken;
|
|
36
|
+
const serviceClientId = `urn:ads:${normalizedOptions.adsp.tenant}:${serviceName}`;
|
|
37
|
+
const appClientId = `urn:ads:${normalizedOptions.adsp.tenant}:${appName}`;
|
|
38
|
+
yield (0, keycloak_admin_1.ensureAudienceMapper)(normalizedOptions.adsp.accessServiceUrl, normalizedOptions.adsp.tenantRealm, appClientId, serviceClientId, accessToken);
|
|
39
|
+
yield (0, keycloak_admin_1.ensureClientRoleScope)(normalizedOptions.adsp.accessServiceUrl, normalizedOptions.adsp.tenantRealm, appClientId, serviceClientId, 'example-role', accessToken);
|
|
40
|
+
}
|
|
41
|
+
if (normalizedOptions.adsp && !normalizedOptions.skipAgent) {
|
|
42
|
+
const accessToken = (_b = normalizedOptions.adsp.accessToken) !== null && _b !== void 0 ? _b : (yield (0, nx_oc_1.realmLogin)(normalizedOptions.adsp.accessServiceUrl, normalizedOptions.adsp.tenantRealm).catch((err) => {
|
|
43
|
+
var _a;
|
|
44
|
+
process.stdout.write(`\n[nx-adsp] Agent sign-in failed (${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : err}) — skipping agent interaction.\n`);
|
|
45
|
+
return undefined;
|
|
46
|
+
}));
|
|
47
|
+
yield (0, agent_1.confirmAfterAgentInterrupt)(yield (0, agent_1.consultAgent)(normalizedOptions.adsp.directoryServiceUrl, accessToken, {
|
|
48
|
+
projectName,
|
|
49
|
+
projectType: 'pevn',
|
|
50
|
+
tenant: normalizedOptions.adsp.tenant,
|
|
51
|
+
pluginVersion: plugin_version_1.PLUGIN_VERSION,
|
|
52
|
+
existingFiles: {
|
|
53
|
+
'service/src/main.ts': (_d = (_c = host.read(`${serviceRoot}/src/main.ts`)) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : '',
|
|
54
|
+
'service/src/environment.ts': (_f = (_e = host.read(`${serviceRoot}/src/environment.ts`)) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : '',
|
|
55
|
+
'service/src/database.ts': (_h = (_g = host.read(`${serviceRoot}/src/database.ts`)) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : '',
|
|
56
|
+
'service/src/events.ts': (_k = (_j = host.read(`${serviceRoot}/src/events.ts`)) === null || _j === void 0 ? void 0 : _j.toString()) !== null && _k !== void 0 ? _k : '',
|
|
57
|
+
'app/src/App.vue': (_m = (_l = host.read(`${appRoot}/src/App.vue`)) === null || _l === void 0 ? void 0 : _l.toString()) !== null && _m !== void 0 ? _m : '',
|
|
58
|
+
'app/src/main.ts': (_p = (_o = host.read(`${appRoot}/src/main.ts`)) === null || _o === void 0 ? void 0 : _o.toString()) !== null && _p !== void 0 ? _p : '',
|
|
59
|
+
'app/src/router/index.ts': (_r = (_q = host.read(`${appRoot}/src/router/index.ts`)) === null || _q === void 0 ? void 0 : _q.toString()) !== null && _r !== void 0 ? _r : '',
|
|
60
|
+
'app/src/environments/environment.ts': (_t = (_s = host.read(`${appRoot}/src/environments/environment.ts`)) === null || _s === void 0 ? void 0 : _s.toString()) !== null && _t !== void 0 ? _t : '',
|
|
61
|
+
},
|
|
62
|
+
}, host, serviceRoot, { additionalRoots: { 'app': appRoot } }));
|
|
63
|
+
}
|
|
64
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
65
|
+
return () => {
|
|
66
|
+
(0, devkit_1.installPackagesTask)(host);
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=pevn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pevn.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/pevn/pevn.ts"],"names":[],"mappings":";;AAiBA,4BAmFC;;AApGD,uCAA+F;AAC/F,wCAAgE;AAChE,wEAAoE;AACpE,gDAA4C;AAE5C,6CAA6E;AAC7E,+DAAyF;AACzF,+DAA4D;AAE5D,SAAe,gBAAgB,C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ectConfiguration } from '@nx/devkit';
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
+
|
|
4
|
+
import * as utils from '@abgov/nx-oc';
|
|
5
|
+
import { environments } from '@abgov/nx-oc';
|
|
6
|
+
import { Schema } from './schema';
|
|
7
|
+
import generator from './pevn';
|
|
8
|
+
|
|
9
|
+
jest.mock('@nx/devkit', () => ({ ...jest.requireActual('@nx/devkit'), formatFiles: jest.fn().mockResolvedValue(undefined) }));
|
|
10
|
+
jest.mock('@abgov/nx-oc');
|
|
11
|
+
jest.mock('../../utils/agent', () => ({
|
|
12
|
+
consultAgent: jest.fn().mockResolvedValue(null),
|
|
13
|
+
confirmAfterAgentInterrupt: jest.fn().mockResolvedValue(undefined),
|
|
14
|
+
}));
|
|
15
|
+
const utilsMock = utils as jest.Mocked<typeof utils>;
|
|
16
|
+
utilsMock.getAdspConfiguration.mockResolvedValue({
|
|
17
|
+
tenant: 'test',
|
|
18
|
+
tenantRealm: 'test',
|
|
19
|
+
accessServiceUrl: environments.test.accessServiceUrl,
|
|
20
|
+
directoryServiceUrl: environments.test.directoryServiceUrl,
|
|
21
|
+
});
|
|
22
|
+
utilsMock.realmLogin.mockResolvedValue('test-token');
|
|
23
|
+
|
|
24
|
+
describe('PEVN Generator', () => {
|
|
25
|
+
const options: Schema = {
|
|
26
|
+
name: 'test',
|
|
27
|
+
env: 'dev',
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
it('can run', async () => {
|
|
31
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
32
|
+
await generator(host, options);
|
|
33
|
+
|
|
34
|
+
const appConfig = readProjectConfiguration(host, 'test-app');
|
|
35
|
+
expect(appConfig.root).toBe('apps/test-app');
|
|
36
|
+
|
|
37
|
+
const serviceConfig = readProjectConfiguration(host, 'test-service');
|
|
38
|
+
expect(serviceConfig.root).toBe('apps/test-service');
|
|
39
|
+
|
|
40
|
+
expect(host.exists('apps/test-app/nginx.conf')).toBeTruthy();
|
|
41
|
+
const nginxConf = host.read('apps/test-app/nginx.conf').toString();
|
|
42
|
+
expect(nginxConf).toContain('http://test-service:3333/');
|
|
43
|
+
|
|
44
|
+
expect(host.exists('apps/test-app/src/App.vue')).toBeTruthy();
|
|
45
|
+
expect(host.exists('apps/test-service/prisma/schema.prisma')).toBeTruthy();
|
|
46
|
+
}, 30000);
|
|
47
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AdspConfiguration, EnvironmentName } from '@abgov/nx-oc';
|
|
2
|
+
|
|
3
|
+
export interface Schema {
|
|
4
|
+
name: string;
|
|
5
|
+
env: EnvironmentName;
|
|
6
|
+
accessToken?: string;
|
|
7
|
+
tenant?: string;
|
|
8
|
+
tenantRealm?: string;
|
|
9
|
+
skipAgent?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface NormalizedSchema extends Schema {
|
|
13
|
+
adsp: AdspConfiguration;
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"id": "NxAdspPevn",
|
|
4
|
+
"title": "PEVN Stack ADSP Solution",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Name of the PEVN stack solution.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "What name would you like to use?"
|
|
15
|
+
},
|
|
16
|
+
"env": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Environment to target.",
|
|
19
|
+
"$default": {
|
|
20
|
+
"$source": "argv",
|
|
21
|
+
"index": 1
|
|
22
|
+
},
|
|
23
|
+
"alias": "e",
|
|
24
|
+
"x-prompt": {
|
|
25
|
+
"message": "Which ADSP environment do you want to target?",
|
|
26
|
+
"type": "list",
|
|
27
|
+
"items": [
|
|
28
|
+
"dev",
|
|
29
|
+
"test",
|
|
30
|
+
"prod"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"tenant": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "ADSP tenant name. Enables a single browser login for the full stack — service and frontend agent interactions both use the same tenant-realm token.",
|
|
37
|
+
"alias": "t"
|
|
38
|
+
},
|
|
39
|
+
"tenantRealm": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Keycloak realm UUID. Optional when --tenant is provided — overrides the realm looked up from the tenant service.",
|
|
42
|
+
"alias": "tr"
|
|
43
|
+
},
|
|
44
|
+
"accessToken": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "Access token for retrieving configuration from ADSP APIs.",
|
|
47
|
+
"alias": "at"
|
|
48
|
+
},
|
|
49
|
+
"skipAgent": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"description": "Skip the consultAgent interaction and generate base scaffolding only.",
|
|
52
|
+
"default": false
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"required": [
|
|
56
|
+
"name",
|
|
57
|
+
"env"
|
|
58
|
+
],
|
|
59
|
+
"additionalProperties": false
|
|
60
|
+
}
|