@abgov/nx-adsp 3.1.0 → 3.2.0-beta.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/README.md +1 -1
- package/package.json +10 -12
- package/src/generators/angular-app/angular-app.js +1 -1
- package/src/generators/angular-app/angular-app.spec.ts +42 -52
- package/src/generators/dotnet-service/dotnet-service.js +2 -2
- package/src/generators/dotnet-service/dotnet-service.spec.ts +8 -9
- package/src/generators/express-service/express-service.js +9 -9
- package/src/generators/express-service/express-service.js.map +1 -1
- package/src/generators/express-service/express-service.spec.ts +9 -9
- package/src/generators/express-service/files/src/environments/environment.prod.ts__tmpl__ +9 -0
- package/src/generators/express-service/files/src/environments/environment.ts__tmpl__ +7 -0
- package/src/generators/express-service/files/src/main.ts__tmpl__ +46 -29
- package/src/generators/express-service/schema.d.ts +1 -0
- package/src/generators/express-service/schema.json +10 -0
- package/src/generators/mern/mern.js +1 -1
- package/src/generators/mern/mern.spec.ts +9 -9
- package/src/generators/mern/schema.d.ts +1 -0
- package/src/generators/mern/schema.json +10 -0
- package/src/generators/react-app/react-app.js +4 -3
- package/src/generators/react-app/react-app.js.map +1 -1
- package/src/generators/react-app/react-app.spec.ts +42 -60
- package/src/generators/react-dotnet/react-dotnet.js +1 -1
- package/src/generators/react-dotnet/react-dotnet.spec.ts +9 -10
- package/src/utils/adsp-utils.d.ts +2 -1
- package/src/utils/adsp-utils.js +4 -3
- package/src/utils/adsp-utils.js.map +1 -1
- package/src/utils/adsp.d.ts +1 -0
- package/src/generators/express-service/files/src/access.ts__tmpl__ +0 -44
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# About this project
|
|
2
|
-
This is the Government of Alberta -
|
|
2
|
+
This is the Government of Alberta - Nx plugin for ADSP apps.
|
|
3
3
|
|
|
4
4
|
The plugin includes generators for application, service, and fullstack solution quick starts. If the peer dependency `@abgov/nx-oc` is found, then OpenShift yml files are also included in the quickstarts. Application stack peer dependencies are required for the associated ADSP application type; for example, `@nrwl/angular` is required for the angular-app, and `@abgov/nx-dotnet` is required for dotnet-service.
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/nx-adsp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-beta.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
-
"description": "Government of Alberta -
|
|
6
|
+
"description": "Government of Alberta - Nx plugin for ADSP apps.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/abgov/nx-tools.git",
|
|
10
10
|
"directory": "packages/nx-adsp"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@
|
|
14
|
-
"@
|
|
15
|
-
"@nrwl/express": "^
|
|
16
|
-
"@nrwl/react": "^
|
|
17
|
-
"@nrwl/angular": "^13.4.3"
|
|
13
|
+
"@nrwl/angular": "^14.0.0",
|
|
14
|
+
"@nrwl/devkit": "^14.0.0",
|
|
15
|
+
"@nrwl/express": "^14.0.0",
|
|
16
|
+
"@nrwl/react": "^14.0.0"
|
|
18
17
|
},
|
|
19
18
|
"dependencies": {
|
|
20
|
-
"@angular-devkit/core": "^
|
|
21
|
-
"@angular-devkit/schematics": "^
|
|
22
|
-
"camelcase": "^5.3.1"
|
|
23
|
-
"@nrwl/devkit": "13.8.1"
|
|
19
|
+
"@angular-devkit/core": "^14.0.0",
|
|
20
|
+
"@angular-devkit/schematics": "^14.0.0",
|
|
21
|
+
"camelcase": "^5.3.1"
|
|
24
22
|
},
|
|
25
23
|
"generators": "./generators.json",
|
|
26
|
-
"
|
|
24
|
+
"types": "./src/index.d.ts"
|
|
27
25
|
}
|
|
@@ -54,7 +54,7 @@ function removeFiles(host, options) {
|
|
|
54
54
|
host.delete(`${options.projectRoot}/src/app/star.svg`);
|
|
55
55
|
}
|
|
56
56
|
function default_1(host, options) {
|
|
57
|
-
return
|
|
57
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
58
|
const normalizedOptions = normalizeOptions(host, options);
|
|
59
59
|
const { applicationGenerator: initAngular } = yield Promise.resolve().then(() => require('@nrwl/angular/generators'));
|
|
60
60
|
yield initAngular(host, { name: options.name });
|
|
@@ -6,15 +6,14 @@ import { AngularAppGeneratorSchema } from './schema';
|
|
|
6
6
|
|
|
7
7
|
describe('angular app generator', () => {
|
|
8
8
|
let appTree: Tree;
|
|
9
|
-
const options: AngularAppGeneratorSchema = {
|
|
9
|
+
const options: AngularAppGeneratorSchema = {
|
|
10
|
+
name: 'test',
|
|
11
|
+
tenant: 'testtenant',
|
|
12
|
+
};
|
|
10
13
|
|
|
11
14
|
beforeEach(() => {
|
|
12
|
-
appTree = createTreeWithEmptyWorkspace(
|
|
13
|
-
jest.setTimeout(28000)
|
|
15
|
+
appTree = createTreeWithEmptyWorkspace();
|
|
14
16
|
});
|
|
15
|
-
afterAll(() => {
|
|
16
|
-
jest.clearAllTimers()
|
|
17
|
-
})
|
|
18
17
|
|
|
19
18
|
it('should run successfully', async () => {
|
|
20
19
|
await angularApp(appTree, options);
|
|
@@ -22,48 +21,42 @@ describe('angular app generator', () => {
|
|
|
22
21
|
expect(config).toBeDefined();
|
|
23
22
|
expect(config.root).toBe('apps/test');
|
|
24
23
|
expect(appTree.exists('apps/test/nginx.conf')).toBeTruthy();
|
|
25
|
-
},
|
|
24
|
+
}, 30000);
|
|
26
25
|
|
|
27
|
-
it
|
|
28
|
-
const host = createTreeWithEmptyWorkspace(
|
|
29
|
-
await angularApp(
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
);
|
|
26
|
+
it('can add nginx proxy', async () => {
|
|
27
|
+
const host = createTreeWithEmptyWorkspace();
|
|
28
|
+
await angularApp(host, {
|
|
29
|
+
...options,
|
|
30
|
+
proxy: {
|
|
31
|
+
location: '/test/',
|
|
32
|
+
proxyPass: 'http://test-service:3333/',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
39
35
|
|
|
40
36
|
const config = readProjectConfiguration(host, 'test');
|
|
41
37
|
expect(config.root).toBe('apps/test');
|
|
42
38
|
|
|
43
39
|
expect(host.exists('apps/test/nginx.conf')).toBeTruthy();
|
|
44
|
-
expect(
|
|
45
|
-
|
|
46
|
-
)
|
|
40
|
+
expect(host.read('apps/test/nginx.conf').toString()).toContain(
|
|
41
|
+
'http://test-service:3333/'
|
|
42
|
+
);
|
|
47
43
|
});
|
|
48
44
|
|
|
49
|
-
it
|
|
50
|
-
const host = createTreeWithEmptyWorkspace(
|
|
51
|
-
await angularApp(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
);
|
|
45
|
+
it('can add multiple nginx proxy', async () => {
|
|
46
|
+
const host = createTreeWithEmptyWorkspace();
|
|
47
|
+
await angularApp(host, {
|
|
48
|
+
...options,
|
|
49
|
+
proxy: [
|
|
50
|
+
{
|
|
51
|
+
location: '/test/',
|
|
52
|
+
proxyPass: 'http://test-service:3333/',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
location: '/test2/',
|
|
56
|
+
proxyPass: 'http://test-service2:3333/',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
});
|
|
67
60
|
|
|
68
61
|
const config = readProjectConfiguration(host, 'test');
|
|
69
62
|
expect(config.root).toBe('apps/test');
|
|
@@ -74,18 +67,15 @@ describe('angular app generator', () => {
|
|
|
74
67
|
expect(nginxConf).toContain('http://test-service2:3333/');
|
|
75
68
|
});
|
|
76
69
|
|
|
77
|
-
it
|
|
78
|
-
const host = createTreeWithEmptyWorkspace(
|
|
79
|
-
await angularApp(
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
);
|
|
70
|
+
it('can add webpack dev server proxy', async () => {
|
|
71
|
+
const host = createTreeWithEmptyWorkspace();
|
|
72
|
+
await angularApp(host, {
|
|
73
|
+
...options,
|
|
74
|
+
proxy: {
|
|
75
|
+
location: '/test/',
|
|
76
|
+
proxyPass: 'http://test-service:3333/api/',
|
|
77
|
+
},
|
|
78
|
+
});
|
|
89
79
|
|
|
90
80
|
const config = readProjectConfiguration(host, 'test');
|
|
91
81
|
expect(config.root).toBe('apps/test');
|
|
@@ -18,7 +18,7 @@ function addFiles(host, options) {
|
|
|
18
18
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
19
19
|
}
|
|
20
20
|
function default_1(host, options) {
|
|
21
|
-
return
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
const normalizedOptions = normalizeOptions(host, options);
|
|
23
23
|
(0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
24
24
|
'@abgov/nx-dotnet': '^1.0.0'
|
|
@@ -56,7 +56,7 @@ function default_1(host, options) {
|
|
|
56
56
|
const { deploymentGenerator } = yield Promise.resolve().then(() => require(`${'@abgov/nx-oc'}`));
|
|
57
57
|
yield deploymentGenerator(host, Object.assign(Object.assign({}, options), { project: normalizedOptions.projectName }));
|
|
58
58
|
}
|
|
59
|
-
return () =>
|
|
59
|
+
return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
60
60
|
(0, devkit_1.installPackagesTask)(host);
|
|
61
61
|
});
|
|
62
62
|
});
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { readProjectConfiguration } from '@nrwl/devkit';
|
|
2
|
-
import {
|
|
2
|
+
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
|
|
3
3
|
import { Schema } from './schema';
|
|
4
4
|
import generator from './dotnet-service';
|
|
5
5
|
|
|
6
6
|
describe('Dotnet Service Generator', () => {
|
|
7
|
-
|
|
8
|
-
const options: Schema = {
|
|
7
|
+
const options: Schema = {
|
|
9
8
|
name: 'test',
|
|
10
|
-
tenant: 'test'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
it
|
|
14
|
-
const host =
|
|
9
|
+
tenant: 'test',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
it('can run', async () => {
|
|
13
|
+
const host = createTreeWithEmptyV1Workspace();
|
|
15
14
|
await generator(host, options);
|
|
16
15
|
|
|
17
16
|
const config = readProjectConfiguration(host, 'test');
|
|
@@ -19,4 +18,4 @@ describe('Dotnet Service Generator', () => {
|
|
|
19
18
|
|
|
20
19
|
expect(host.exists('apps/test/test.csproj')).toBeTruthy();
|
|
21
20
|
});
|
|
22
|
-
});
|
|
21
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const test_runners_1 = require("@nrwl/angular/src/utils/test-runners");
|
|
4
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
5
6
|
const linter_1 = require("@nrwl/linter");
|
|
6
7
|
const path = require("path");
|
|
@@ -18,19 +19,18 @@ function addFiles(host, options) {
|
|
|
18
19
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
19
20
|
}
|
|
20
21
|
function default_1(host, options) {
|
|
21
|
-
return
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
const normalizedOptions = normalizeOptions(host, options);
|
|
23
24
|
const { applicationGenerator: initExpress } = yield Promise.resolve().then(() => require('@nrwl/express'));
|
|
24
|
-
yield initExpress(host, Object.assign(Object.assign({}, options), { skipFormat: true, skipPackageJson: false, linter: linter_1.Linter.EsLint, unitTestRunner:
|
|
25
|
+
yield initExpress(host, Object.assign(Object.assign({}, options), { skipFormat: true, skipPackageJson: false, linter: linter_1.Linter.EsLint, unitTestRunner: test_runners_1.UnitTestRunner.Jest, pascalCaseFiles: false, js: false }));
|
|
25
26
|
(0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
|
|
29
|
-
'passport-
|
|
27
|
+
'@abgov/adsp-service-sdk': '^1.18.0',
|
|
28
|
+
'dotenv': '^16.0.0',
|
|
29
|
+
'passport': '^0.6.0',
|
|
30
|
+
'passport-anonymous': '^1.0.1',
|
|
30
31
|
}, {
|
|
31
|
-
'@types/passport': '^1.0.
|
|
32
|
-
|
|
33
|
-
'@types/passport-jwt': '^3.0.5',
|
|
32
|
+
'@types/passport': '^1.0.9',
|
|
33
|
+
'@types/passport-anonymous': '^1.0.3',
|
|
34
34
|
});
|
|
35
35
|
addFiles(host, normalizedOptions);
|
|
36
36
|
yield (0, devkit_1.formatFiles)(host);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-service.ts"],"names":[],"mappings":";;;AAAA,uEAAsE;AACtE,yCAQsB;AACtB,yCAAsC;AACtC,6BAA6B;AAC7B,uDAA6E;AAG7E,SAAS,gBAAgB,CACvB,IAAU,EACV,OAAe;IAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;IAEzE,MAAM,IAAI,GAAG,IAAA,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AAG,cAAc,EAAE,EAAC,CAAC;YAClE,MAAM,mBAAmB,CACvB,IAAI,kCAEC,OAAO,KACV,OAAO,EAAE,iBAAiB,CAAC,WAAW,IAEzC,CAAC;SACH;QAED,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAA;IACH,CAAC;CAAA;AAhDD,4BAgDC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { readProjectConfiguration } from '@nrwl/devkit';
|
|
2
|
-
import {
|
|
2
|
+
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
|
|
3
3
|
import { Schema } from './schema';
|
|
4
4
|
import generator from './express-service';
|
|
5
5
|
|
|
6
6
|
describe('Express Service Generator', () => {
|
|
7
|
-
|
|
8
|
-
const options: Schema = {
|
|
7
|
+
const options: Schema = {
|
|
9
8
|
name: 'test',
|
|
10
|
-
tenant: 'test'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
tenant: 'test',
|
|
10
|
+
realm: 'test',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
it('can run', async () => {
|
|
14
|
+
const host = createTreeWithEmptyV1Workspace();
|
|
15
15
|
await generator(host, options);
|
|
16
16
|
|
|
17
17
|
const config = readProjectConfiguration(host, 'test');
|
|
18
18
|
expect(config.root).toBe('apps/test');
|
|
19
19
|
|
|
20
|
-
expect(host.exists('apps/test/src/
|
|
20
|
+
expect(host.exists('apps/test/src/main.ts')).toBeTruthy();
|
|
21
21
|
});
|
|
22
22
|
});
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import * as dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
1
4
|
export const environment = {
|
|
2
5
|
production: true,
|
|
6
|
+
TENANT_REALM: '<%= tenantRealm %>',
|
|
7
|
+
ACCESS_SERVICE_URL: '<%= accessServiceUrl %>',
|
|
8
|
+
DIRECTORY_SERVICE_URL: '<%= directoryServiceUrl %>',
|
|
9
|
+
CLIENT_ID: 'urn:ads:<%= tenant %>:<%= projectName %>',
|
|
10
|
+
CLIENT_SECRET: '',
|
|
11
|
+
LOG_LEVEL: 'info',
|
|
3
12
|
...process.env,
|
|
4
13
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import * as dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
1
4
|
export const environment = {
|
|
2
5
|
production: false,
|
|
3
6
|
port: '3333',
|
|
4
7
|
TENANT_REALM: '<%= tenantRealm %>',
|
|
5
8
|
ACCESS_SERVICE_URL: '<%= accessServiceUrl %>',
|
|
9
|
+
DIRECTORY_SERVICE_URL: '<%= directoryServiceUrl %>',
|
|
10
|
+
CLIENT_ID: 'urn:ads:<%= tenant %>:<%= projectName %>',
|
|
11
|
+
CLIENT_SECRET: '',
|
|
12
|
+
LOG_LEVEL: 'debug',
|
|
6
13
|
...process.env
|
|
7
14
|
};
|
|
@@ -2,45 +2,62 @@
|
|
|
2
2
|
* This is not a production server yet!
|
|
3
3
|
* This is only a minimal backend to get started.
|
|
4
4
|
*/
|
|
5
|
+
import { AdspId, initializeService } from '@abgov/adsp-service-sdk';
|
|
5
6
|
import * as express from 'express';
|
|
6
7
|
import * as passport from 'passport';
|
|
7
8
|
import { Strategy as AnonymousStrategy } from 'passport-anonymous';
|
|
8
|
-
import { AccessUser, createAccessStrategy } from './access';
|
|
9
9
|
|
|
10
10
|
import { environment } from './environments/environment';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
async function initializeApp(): Promise<express.Application> {
|
|
13
|
+
const app = express();
|
|
14
|
+
app.use(passport.initialize());
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const serviceId = AdspId.parse(environment.CLIENT_ID);
|
|
17
|
+
const { tenantStrategy } = await initializeService(
|
|
18
|
+
{
|
|
19
|
+
displayName: '<%= projectName %>',
|
|
20
|
+
description: 'Put your service description here.',
|
|
21
|
+
realm: environment.TENANT_REALM,
|
|
22
|
+
serviceId,
|
|
23
|
+
clientSecret: environment.CLIENT_SECRET,
|
|
24
|
+
accessServiceUrl: new URL(environment.ACCESS_SERVICE_URL),
|
|
25
|
+
directoryUrl: new URL(environment.DIRECTORY_SERVICE_URL),
|
|
26
|
+
},
|
|
27
|
+
{ logLevel: environment.LOG_LEVEL }
|
|
28
|
+
);
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
'
|
|
21
|
-
|
|
30
|
+
passport.use('tenant', tenantStrategy);
|
|
31
|
+
passport.use('anonymous', new AnonymousStrategy());
|
|
32
|
+
|
|
33
|
+
app.use(passport.authenticate(['tenant', 'anonymous'], { session: false }));
|
|
34
|
+
|
|
35
|
+
app.get('/<%= projectName %>/v1/public', (_req, res) => {
|
|
22
36
|
res.send({ message: `Welcome to public API resource!` });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
app.get(
|
|
40
|
+
'/<%= projectName %>/v1/private',
|
|
41
|
+
(req, res, next) => {
|
|
42
|
+
if (!req.user) {
|
|
43
|
+
res.sendStatus(401);
|
|
44
|
+
} else {
|
|
45
|
+
next();
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
(req, res) => {
|
|
49
|
+
const user = req.user;
|
|
50
|
+
res.send({ message: `Welcome to private API resource! ${user.name}` });
|
|
33
51
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
res.send({ message: `Welcome to private API resource! ${user.name}` });
|
|
38
|
-
}
|
|
39
|
-
);
|
|
52
|
+
);
|
|
53
|
+
return app;
|
|
54
|
+
}
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
initializeApp().then((app) => {
|
|
57
|
+
const port = environment.port || 3333;
|
|
42
58
|
|
|
43
|
-
const server = app.listen(port, () => {
|
|
44
|
-
|
|
59
|
+
const server = app.listen(port, () => {
|
|
60
|
+
console.log(`Listening at http://localhost:${port}/<%= projectName %>/v1`);
|
|
61
|
+
});
|
|
62
|
+
server.on('error', console.error);
|
|
45
63
|
});
|
|
46
|
-
server.on('error', console.error);
|
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"alias": "t",
|
|
25
25
|
"x-prompt": "What is the name of your ADSP tenant?"
|
|
26
|
+
},
|
|
27
|
+
"realm": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "Realm of the ADSP tenant.",
|
|
30
|
+
"$default": {
|
|
31
|
+
"$source": "argv",
|
|
32
|
+
"index": 2
|
|
33
|
+
},
|
|
34
|
+
"alias": "r",
|
|
35
|
+
"x-prompt": "What is the realm of your ADSP tenant?"
|
|
26
36
|
}
|
|
27
37
|
},
|
|
28
38
|
"required": ["name", "tenant"]
|
|
@@ -25,7 +25,7 @@ function addFiles(host, options) {
|
|
|
25
25
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'openshift'), `${options.openshiftDirectory}`, templateOptions);
|
|
26
26
|
}
|
|
27
27
|
function default_1(host, options) {
|
|
28
|
-
return
|
|
28
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
const normalizedOptions = normalizeOptions(host, options);
|
|
30
30
|
yield (0, express_service_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-service` }));
|
|
31
31
|
yield (0, react_app_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-app`, proxy: {
|
|
@@ -4,14 +4,14 @@ import { Schema } from './schema';
|
|
|
4
4
|
import generator from './mern';
|
|
5
5
|
|
|
6
6
|
describe('React App Generator', () => {
|
|
7
|
-
|
|
8
|
-
const options: Schema = {
|
|
7
|
+
const options: Schema = {
|
|
9
8
|
name: 'test',
|
|
10
9
|
tenant: 'test',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
realm: 'test',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
it('can run', async () => {
|
|
14
|
+
const host = createTreeWithEmptyWorkspace();
|
|
15
15
|
await generator(host, options);
|
|
16
16
|
|
|
17
17
|
const appConfig = readProjectConfiguration(host, 'test-app');
|
|
@@ -19,9 +19,9 @@ describe('React App Generator', () => {
|
|
|
19
19
|
|
|
20
20
|
const serviceConfig = readProjectConfiguration(host, 'test-service');
|
|
21
21
|
expect(serviceConfig.root).toBe('apps/test-service');
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
expect(host.exists('apps/test-app/nginx.conf')).toBeTruthy();
|
|
24
24
|
const nginxConf = host.read('apps/test-app/nginx.conf').toString();
|
|
25
25
|
expect(nginxConf).toContain('http://test-service:3333/');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
26
|
+
}, 30000);
|
|
27
|
+
});
|
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"alias": "t",
|
|
25
25
|
"x-prompt": "What is the name of your ADSP tenant?"
|
|
26
|
+
},
|
|
27
|
+
"realm": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "Realm of the ADSP tenant.",
|
|
30
|
+
"$default": {
|
|
31
|
+
"$source": "argv",
|
|
32
|
+
"index": 2
|
|
33
|
+
},
|
|
34
|
+
"alias": "r",
|
|
35
|
+
"x-prompt": "What is the realm of your ADSP tenant?"
|
|
26
36
|
}
|
|
27
37
|
},
|
|
28
38
|
"required": ["name", "tenant"]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const test_runners_1 = require("@nrwl/angular/src/utils/test-runners");
|
|
4
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
5
6
|
const linter_1 = require("@nrwl/linter");
|
|
6
7
|
const path = require("path");
|
|
@@ -53,7 +54,7 @@ function removeFiles(host, options) {
|
|
|
53
54
|
host.delete(`${options.projectRoot}/src/app/star.svg`);
|
|
54
55
|
}
|
|
55
56
|
function default_1(host, options) {
|
|
56
|
-
return
|
|
57
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
57
58
|
const normalizedOptions = normalizeOptions(host, options);
|
|
58
59
|
const { applicationGenerator: initReact } = yield Promise.resolve().then(() => require('@nrwl/react'));
|
|
59
60
|
const { reduxGenerator: initRedux } = yield Promise.resolve().then(() => require('@nrwl/react'));
|
|
@@ -63,8 +64,8 @@ function default_1(host, options) {
|
|
|
63
64
|
style: 'styled-components',
|
|
64
65
|
skipFormat: true,
|
|
65
66
|
linter: linter_1.Linter.EsLint,
|
|
66
|
-
unitTestRunner:
|
|
67
|
-
e2eTestRunner:
|
|
67
|
+
unitTestRunner: test_runners_1.UnitTestRunner.Jest,
|
|
68
|
+
e2eTestRunner: test_runners_1.E2eTestRunner.Cypress,
|
|
68
69
|
babelJest: false,
|
|
69
70
|
strict: false,
|
|
70
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-app/react-app.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"react-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-app/react-app.ts"],"names":[],"mappings":";;;AAAA,uEAAqF;AACrF,yCAWsB;AACtB,yCAAsC;AACtC,6BAA6B;AAC7B,uDAA6E;AAG7E,SAAS,gBAAgB,CACvB,IAAU,EACV,OAAe;IAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;IACzE,MAAM,kBAAkB,GAAG,cAAc,WAAW,EAAE,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AAC,OAAO,KAC/B,WAAW,EAAE,GAAG,iBAAiB,CAAC,WAAW,kBAAkB,GAChE,CAAA;SACF;QAED,IAAA,mCAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEvD,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,IAAI,IAAA,0BAAa,EAAC,IAAI,EAAE,cAAc,CAAC,EAAE;YACvC,MAAM,EAAE,mBAAmB,EAAE,GAAG,2CAAa,GAAG,cAAc,EAAE,EAAC,CAAC;YAClE,MAAM,mBAAmB,CACvB,IAAI,kCAEC,OAAO,KACV,OAAO,EAAE,iBAAiB,CAAC,WAAW,IAEzC,CAAC;SACH;QAED,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAA;IACH,CAAC;CAAA;AAnFD,4BAmFC"}
|
|
@@ -1,73 +1,58 @@
|
|
|
1
1
|
import { readProjectConfiguration } from '@nrwl/devkit';
|
|
2
|
-
import {
|
|
2
|
+
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
|
|
3
3
|
import { Schema } from './schema';
|
|
4
4
|
import generator from './react-app';
|
|
5
5
|
|
|
6
6
|
describe('React App Generator', () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
jest.setTimeout(28000)
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
afterAll(() => {
|
|
12
|
-
jest.clearAllTimers()
|
|
13
|
-
})
|
|
14
|
-
|
|
15
7
|
const options: Schema = {
|
|
16
8
|
name: 'test',
|
|
17
9
|
tenant: 'test',
|
|
18
|
-
}
|
|
10
|
+
};
|
|
19
11
|
|
|
20
|
-
it
|
|
21
|
-
|
|
22
|
-
const host = createTreeWithEmptyWorkspace();
|
|
12
|
+
it('can run', async () => {
|
|
13
|
+
const host = createTreeWithEmptyV1Workspace();
|
|
23
14
|
await generator(host, options);
|
|
24
15
|
|
|
25
16
|
const config = readProjectConfiguration(host, 'test');
|
|
26
17
|
expect(config.root).toBe('apps/test');
|
|
27
18
|
|
|
28
19
|
expect(host.exists('apps/test/nginx.conf')).toBeTruthy();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it
|
|
32
|
-
const host =
|
|
33
|
-
await generator(
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
);
|
|
20
|
+
}, 30000);
|
|
21
|
+
|
|
22
|
+
it('can add nginx proxy', async () => {
|
|
23
|
+
const host = createTreeWithEmptyV1Workspace();
|
|
24
|
+
await generator(host, {
|
|
25
|
+
...options,
|
|
26
|
+
proxy: {
|
|
27
|
+
location: '/test/',
|
|
28
|
+
proxyPass: 'http://test-service:3333/',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
43
31
|
|
|
44
32
|
const config = readProjectConfiguration(host, 'test');
|
|
45
33
|
expect(config.root).toBe('apps/test');
|
|
46
34
|
|
|
47
35
|
expect(host.exists('apps/test/nginx.conf')).toBeTruthy();
|
|
48
|
-
expect(
|
|
49
|
-
|
|
50
|
-
)
|
|
36
|
+
expect(host.read('apps/test/nginx.conf').toString()).toContain(
|
|
37
|
+
'http://test-service:3333/'
|
|
38
|
+
);
|
|
51
39
|
});
|
|
52
40
|
|
|
53
|
-
it
|
|
54
|
-
const host =
|
|
55
|
-
await generator(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
);
|
|
41
|
+
it('can add multiple nginx proxy', async () => {
|
|
42
|
+
const host = createTreeWithEmptyV1Workspace();
|
|
43
|
+
await generator(host, {
|
|
44
|
+
...options,
|
|
45
|
+
proxy: [
|
|
46
|
+
{
|
|
47
|
+
location: '/test/',
|
|
48
|
+
proxyPass: 'http://test-service:3333/',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
location: '/test2/',
|
|
52
|
+
proxyPass: 'http://test-service2:3333/',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
});
|
|
71
56
|
|
|
72
57
|
const config = readProjectConfiguration(host, 'test');
|
|
73
58
|
expect(config.root).toBe('apps/test');
|
|
@@ -78,18 +63,15 @@ describe('React App Generator', () => {
|
|
|
78
63
|
expect(nginxConf).toContain('http://test-service2:3333/');
|
|
79
64
|
});
|
|
80
65
|
|
|
81
|
-
it
|
|
82
|
-
const host =
|
|
83
|
-
await generator(
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
);
|
|
66
|
+
it('can add webpack dev server proxy', async () => {
|
|
67
|
+
const host = createTreeWithEmptyV1Workspace();
|
|
68
|
+
await generator(host, {
|
|
69
|
+
...options,
|
|
70
|
+
proxy: {
|
|
71
|
+
location: '/test/',
|
|
72
|
+
proxyPass: 'http://test-service:3333/api/',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
93
75
|
|
|
94
76
|
const config = readProjectConfiguration(host, 'test');
|
|
95
77
|
expect(config.root).toBe('apps/test');
|
|
@@ -5,7 +5,7 @@ const devkit_1 = require("@nrwl/devkit");
|
|
|
5
5
|
const dotnet_service_1 = require("../dotnet-service/dotnet-service");
|
|
6
6
|
const react_app_1 = require("../react-app/react-app");
|
|
7
7
|
function default_1(host, options) {
|
|
8
|
-
return
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
9
|
yield (0, dotnet_service_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-service`, namespace: options.name }));
|
|
10
10
|
yield (0, react_app_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-app`, proxy: {
|
|
11
11
|
location: '/api/',
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { readProjectConfiguration } from '@nrwl/devkit';
|
|
2
|
-
import {
|
|
2
|
+
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
|
|
3
3
|
import { Schema } from './schema';
|
|
4
4
|
import generator from './react-dotnet';
|
|
5
5
|
|
|
6
6
|
describe('React App Generator', () => {
|
|
7
|
-
|
|
8
|
-
const options: Schema = {
|
|
7
|
+
const options: Schema = {
|
|
9
8
|
name: 'test',
|
|
10
9
|
tenant: 'test',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
it
|
|
14
|
-
const host =
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
it('can run', async () => {
|
|
13
|
+
const host = createTreeWithEmptyV1Workspace();
|
|
15
14
|
await generator(host, options);
|
|
16
15
|
|
|
17
16
|
const appConfig = readProjectConfiguration(host, 'test-app');
|
|
@@ -19,9 +18,9 @@ describe('React App Generator', () => {
|
|
|
19
18
|
|
|
20
19
|
const serviceConfig = readProjectConfiguration(host, 'test-service');
|
|
21
20
|
expect(serviceConfig.root).toBe('apps/test-service');
|
|
22
|
-
|
|
21
|
+
|
|
23
22
|
expect(host.exists('apps/test-app/nginx.conf')).toBeTruthy();
|
|
24
23
|
const nginxConf = host.read('apps/test-app/nginx.conf').toString();
|
|
25
24
|
expect(nginxConf).toContain('http://test-service:5000/');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
25
|
+
}, 30000);
|
|
26
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Tree } from '@nrwl/devkit';
|
|
2
2
|
import { AdspConfiguration } from './adsp';
|
|
3
3
|
export declare function hasDependency(host: Tree, dependency: string): boolean;
|
|
4
|
-
export declare function getAdspConfiguration(host: Tree, { tenant }: {
|
|
4
|
+
export declare function getAdspConfiguration(host: Tree, { tenant, realm }: {
|
|
5
5
|
tenant: string;
|
|
6
|
+
realm?: string;
|
|
6
7
|
}): AdspConfiguration;
|
package/src/utils/adsp-utils.js
CHANGED
|
@@ -8,11 +8,12 @@ function hasDependency(host, dependency) {
|
|
|
8
8
|
!!devDependencies[dependency];
|
|
9
9
|
}
|
|
10
10
|
exports.hasDependency = hasDependency;
|
|
11
|
-
function getAdspConfiguration(host, { tenant }) {
|
|
11
|
+
function getAdspConfiguration(host, { tenant, realm }) {
|
|
12
12
|
return {
|
|
13
13
|
tenant,
|
|
14
|
-
tenantRealm:
|
|
15
|
-
accessServiceUrl: 'https://access.
|
|
14
|
+
tenantRealm: realm,
|
|
15
|
+
accessServiceUrl: 'https://access.alberta.ca',
|
|
16
|
+
directoryServiceUrl: 'https://directory-service.adsp.alberta.ca',
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
exports.getAdspConfiguration = getAdspConfiguration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adsp-utils.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/adsp-utils.ts"],"names":[],"mappings":";;;AAAA,yCAGsB;AAOtB,SAAgB,aAAa,CAAC,IAAU,EAAE,UAAkB;IAC1D,MAAM,EACJ,YAAY,EACZ,eAAe,EAChB,GAAY,IAAA,iBAAQ,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAE5C,OAAO,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC;QAC/B,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AARD,sCAQC;AAED,SAAgB,oBAAoB,CAClC,IAAU,EACV,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"adsp-utils.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/adsp-utils.ts"],"names":[],"mappings":";;;AAAA,yCAGsB;AAOtB,SAAgB,aAAa,CAAC,IAAU,EAAE,UAAkB;IAC1D,MAAM,EACJ,YAAY,EACZ,eAAe,EAChB,GAAY,IAAA,iBAAQ,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAE5C,OAAO,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC;QAC/B,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AARD,sCAQC;AAED,SAAgB,oBAAoB,CAClC,IAAU,EACV,EAAE,MAAM,EAAE,KAAK,EAAsC;IAErD,OAAO;QACL,MAAM;QACN,WAAW,EAAE,KAAK;QAClB,gBAAgB,EAAE,2BAA2B;QAC7C,mBAAmB,EAAE,2CAA2C;KACjE,CAAA;AACH,CAAC;AAVD,oDAUC"}
|
package/src/utils/adsp.d.ts
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as jwksRsa from 'jwks-rsa';
|
|
2
|
-
import { Strategy as JwtStrategy, ExtractJwt } from 'passport-jwt';
|
|
3
|
-
|
|
4
|
-
interface AccessStrategyProps {
|
|
5
|
-
ACCESS_SERVICE_URL: string;
|
|
6
|
-
TENANT_REALM: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface AccessUser {
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
email: string;
|
|
13
|
-
roles: string[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const createAccessStrategy = ({
|
|
17
|
-
ACCESS_SERVICE_URL,
|
|
18
|
-
TENANT_REALM,
|
|
19
|
-
}: AccessStrategyProps) => {
|
|
20
|
-
const strategy = new JwtStrategy(
|
|
21
|
-
{
|
|
22
|
-
jwtFromRequest: ExtractJwt.fromExtractors([
|
|
23
|
-
ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
24
|
-
ExtractJwt.fromUrlQueryParameter('token'),
|
|
25
|
-
]),
|
|
26
|
-
secretOrKeyProvider: jwksRsa.passportJwtSecret({
|
|
27
|
-
jwksUri: `${ACCESS_SERVICE_URL}/auth/realms/${TENANT_REALM}/protocol/openid-connect/certs`,
|
|
28
|
-
cache: true,
|
|
29
|
-
}),
|
|
30
|
-
issuer: `${ACCESS_SERVICE_URL}/auth/realms/${TENANT_REALM}`,
|
|
31
|
-
},
|
|
32
|
-
(payload, done) => {
|
|
33
|
-
const user: AccessUser = {
|
|
34
|
-
id: payload.sub,
|
|
35
|
-
name: payload.name || payload.preferred_username,
|
|
36
|
-
email: payload.email,
|
|
37
|
-
roles: payload.realm_access.roles,
|
|
38
|
-
}
|
|
39
|
-
done(null, user);
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return strategy;
|
|
44
|
-
};
|