@abgov/nx-adsp 5.0.0 → 5.1.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/package.json +4 -2
- package/src/generators/angular-app/angular-app.js +26 -24
- package/src/generators/angular-app/angular-app.js.map +1 -1
- package/src/generators/angular-app/angular-app.spec.ts +2 -1
- package/src/generators/angular-app/schema.d.ts +6 -4
- package/src/generators/angular-app/schema.json +36 -8
- package/src/generators/dotnet-service/dotnet-service.js +9 -10
- package/src/generators/dotnet-service/dotnet-service.js.map +1 -1
- package/src/generators/dotnet-service/dotnet-service.spec.ts +2 -1
- package/src/generators/dotnet-service/schema.d.ts +2 -3
- package/src/generators/dotnet-service/schema.json +26 -9
- package/src/generators/express-service/express-service.js +11 -9
- package/src/generators/express-service/express-service.js.map +1 -1
- package/src/generators/express-service/express-service.spec.ts +1 -1
- package/src/generators/express-service/schema.d.ts +3 -2
- package/src/generators/express-service/schema.json +18 -6
- package/src/generators/mern/mern.js +15 -13
- package/src/generators/mern/mern.js.map +1 -1
- package/src/generators/mern/mern.spec.ts +1 -1
- package/src/generators/mern/schema.d.ts +4 -3
- package/src/generators/mern/schema.json +18 -6
- package/src/generators/react-app/react-app.js +30 -30
- package/src/generators/react-app/react-app.js.map +1 -1
- package/src/generators/react-app/react-app.spec.ts +2 -1
- package/src/generators/react-app/schema.d.ts +5 -3
- package/src/generators/react-app/schema.json +36 -8
- package/src/generators/react-dotnet/react-dotnet.js +2 -2
- package/src/generators/react-dotnet/react-dotnet.js.map +1 -1
- package/src/generators/react-dotnet/react-dotnet.spec.ts +2 -1
- package/src/generators/react-dotnet/schema.d.ts +4 -1
- package/src/generators/react-dotnet/schema.json +28 -6
- package/src/utils/adsp-utils.d.ts +5 -4
- package/src/utils/adsp-utils.js +63 -9
- package/src/utils/adsp-utils.js.map +1 -1
- package/src/utils/environments.d.ts +7 -0
- package/src/utils/environments.js +18 -0
- package/src/utils/environments.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/nx-adsp",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"description": "Government of Alberta - Nx plugin for ADSP apps.",
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@angular-devkit/core": "^15.0.0",
|
|
20
20
|
"@angular-devkit/schematics": "^15.0.0",
|
|
21
|
-
"
|
|
21
|
+
"axios": "1.1.3",
|
|
22
|
+
"express": "4.18.1",
|
|
23
|
+
"open": "^8.4.0"
|
|
22
24
|
},
|
|
23
25
|
"generators": "./generators.json",
|
|
24
26
|
"types": "./src/index.d.ts"
|
|
@@ -5,22 +5,24 @@ const devkit_1 = require("@nrwl/devkit");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const adsp_utils_1 = require("../../utils/adsp-utils");
|
|
7
7
|
function normalizeOptions(host, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
10
|
+
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectName}`;
|
|
11
|
+
const projectOrg = (0, devkit_1.getWorkspaceLayout)(host).npmScope;
|
|
12
|
+
const openshiftDirectory = `.openshift/${projectName}`;
|
|
13
|
+
const adsp = yield (0, adsp_utils_1.getAdspConfiguration)(host, options);
|
|
14
|
+
const nginxProxies = Array.isArray(options.proxy)
|
|
15
|
+
? [...options.proxy]
|
|
16
|
+
: options.proxy
|
|
17
|
+
? [options.proxy]
|
|
18
|
+
: [];
|
|
19
|
+
return Object.assign(Object.assign({}, options), { projectName,
|
|
20
|
+
projectRoot,
|
|
21
|
+
openshiftDirectory,
|
|
22
|
+
projectOrg,
|
|
23
|
+
adsp,
|
|
24
|
+
nginxProxies });
|
|
25
|
+
});
|
|
24
26
|
}
|
|
25
27
|
function addFiles(host, options) {
|
|
26
28
|
const templateOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, options), options.adsp), (0, devkit_1.names)(options.name)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot), tmpl: '' });
|
|
@@ -35,12 +37,12 @@ function addFiles(host, options) {
|
|
|
35
37
|
target: `${upstreamUrl.protocol}//localhost${upstreamUrl.port ? ':' + upstreamUrl.port : ''}`,
|
|
36
38
|
secure: upstreamUrl.protocol === 'https:',
|
|
37
39
|
changeOrigin: false,
|
|
38
|
-
pathRewrite: {}
|
|
40
|
+
pathRewrite: {},
|
|
39
41
|
};
|
|
40
42
|
// If there is a path on the upstream url, then add a rewrite.
|
|
41
43
|
if (upstreamUrl.pathname.length > 1) {
|
|
42
44
|
proxy.pathRewrite = {
|
|
43
|
-
[`^${nginxProxy.location}`]: upstreamUrl.pathname
|
|
45
|
+
[`^${nginxProxy.location}`]: upstreamUrl.pathname,
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
return Object.assign(Object.assign({}, proxyConf), { [nginxProxy.location]: proxy });
|
|
@@ -55,13 +57,13 @@ function removeFiles(host, options) {
|
|
|
55
57
|
}
|
|
56
58
|
function default_1(host, options) {
|
|
57
59
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
const normalizedOptions = normalizeOptions(host, options);
|
|
60
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
59
61
|
const { applicationGenerator: initAngular } = yield Promise.resolve().then(() => require('@nrwl/angular/generators'));
|
|
60
62
|
yield initAngular(host, { name: options.name });
|
|
61
63
|
(0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
62
64
|
'@abgov/angular-components': '^1.7.1',
|
|
63
65
|
'@abgov/core-css': '^1.0.0',
|
|
64
|
-
'@angular/cdk':
|
|
66
|
+
'@angular/cdk': '^11.2.0',
|
|
65
67
|
'@angular/localize': '^11.2.0',
|
|
66
68
|
'html-webpack-plugin': '~4.5.2',
|
|
67
69
|
'oidc-client': '~1.11.5',
|
|
@@ -74,10 +76,10 @@ function default_1(host, options) {
|
|
|
74
76
|
config.targets.build.options = Object.assign(Object.assign({}, config.targets.build.options), { assets: [
|
|
75
77
|
...config.targets.build.options.assets,
|
|
76
78
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
79
|
+
glob: 'nginx.conf',
|
|
80
|
+
input: `${layout.appsDir}/${options.name}`,
|
|
81
|
+
output: './',
|
|
82
|
+
},
|
|
81
83
|
] });
|
|
82
84
|
if (addedProxy) {
|
|
83
85
|
// Add the webpack dev server proxy if there is proxy configuration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/angular-app/angular-app.ts"],"names":[],"mappings":";;;AAAA,yCAYsB;AACtB,6BAA6B;AAC7B,uDAA6E;AAG7E,
|
|
1
|
+
{"version":3,"file":"angular-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/angular-app/angular-app.ts"],"names":[],"mappings":";;;AAAA,yCAYsB;AACtB,6BAA6B;AAC7B,uDAA6E;AAG7E,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,MAAM,UAAU,GAAG,IAAA,2BAAkB,EAAC,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G,2CAAa,GAAG,cAAc,EAAE,EAAC,CAAC;YAClE,MAAM,mBAAmB,CAAC,IAAI,kCACzB,OAAO,KACV,OAAO,EAAE,iBAAiB,CAAC,WAAW,IACtC,CAAC;SACJ;QAED,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AAhED,4BAgEC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { EnvironmentName } from '../../utils/environments';
|
|
2
|
+
|
|
1
3
|
export interface AngularAppGeneratorSchema {
|
|
2
4
|
name: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
env: EnvironmentName;
|
|
6
|
+
realm: string;
|
|
7
|
+
proxy?: NginxProxyConfiguration | NginxProxyConfiguration[];
|
|
5
8
|
}
|
|
6
9
|
|
|
7
|
-
|
|
8
10
|
export interface NormalizedSchema extends AngularAppGeneratorSchema {
|
|
9
11
|
projectName: string;
|
|
10
12
|
projectRoot: string;
|
|
11
13
|
projectOrg: string;
|
|
12
14
|
openshiftDirectory: string;
|
|
13
|
-
adsp: AdspConfiguration
|
|
15
|
+
adsp: AdspConfiguration;
|
|
14
16
|
nginxProxies: NginxProxyConfiguration[];
|
|
15
17
|
}
|
|
@@ -14,15 +14,33 @@
|
|
|
14
14
|
},
|
|
15
15
|
"x-prompt": "What name would you like to use?"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
17
|
+
"env": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "Environment to target.",
|
|
20
20
|
"$default": {
|
|
21
21
|
"$source": "argv",
|
|
22
22
|
"index": 1
|
|
23
23
|
},
|
|
24
|
-
"alias": "
|
|
25
|
-
"x-prompt":
|
|
24
|
+
"alias": "e",
|
|
25
|
+
"x-prompt": {
|
|
26
|
+
"message": "Which ADSP environment do you want to target?",
|
|
27
|
+
"type": "list",
|
|
28
|
+
"items": [
|
|
29
|
+
"dev",
|
|
30
|
+
"test",
|
|
31
|
+
"prod"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"realm": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Realm of the ADSP tenant.",
|
|
38
|
+
"$default": {
|
|
39
|
+
"$source": "argv",
|
|
40
|
+
"index": 2
|
|
41
|
+
},
|
|
42
|
+
"alias": "r",
|
|
43
|
+
"x-prompt": "What is the realm of your ADSP tenant?"
|
|
26
44
|
},
|
|
27
45
|
"proxy": {
|
|
28
46
|
"oneOf": [
|
|
@@ -38,7 +56,10 @@
|
|
|
38
56
|
"type": "string"
|
|
39
57
|
}
|
|
40
58
|
},
|
|
41
|
-
"required": [
|
|
59
|
+
"required": [
|
|
60
|
+
"location",
|
|
61
|
+
"proxyPass"
|
|
62
|
+
]
|
|
42
63
|
}
|
|
43
64
|
},
|
|
44
65
|
{
|
|
@@ -51,10 +72,17 @@
|
|
|
51
72
|
"type": "string"
|
|
52
73
|
}
|
|
53
74
|
},
|
|
54
|
-
"required": [
|
|
75
|
+
"required": [
|
|
76
|
+
"location",
|
|
77
|
+
"proxyPass"
|
|
78
|
+
]
|
|
55
79
|
}
|
|
56
80
|
]
|
|
57
81
|
}
|
|
58
82
|
},
|
|
59
|
-
"required": [
|
|
60
|
-
|
|
83
|
+
"required": [
|
|
84
|
+
"name",
|
|
85
|
+
"env",
|
|
86
|
+
"realm"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
-
const camelcase_1 = require("camelcase");
|
|
6
5
|
const path = require("path");
|
|
7
6
|
const adsp_utils_1 = require("../../utils/adsp-utils");
|
|
8
7
|
function normalizeOptions(host, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
10
|
+
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectName}`;
|
|
11
|
+
const adsp = yield (0, adsp_utils_1.getAdspConfiguration)(host, options);
|
|
12
|
+
return Object.assign(Object.assign({}, options), { projectName,
|
|
13
|
+
projectRoot,
|
|
14
|
+
adsp });
|
|
15
|
+
});
|
|
17
16
|
}
|
|
18
17
|
function addFiles(host, options) {
|
|
19
18
|
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), options.adsp), { tmpl: '' });
|
|
@@ -24,7 +23,7 @@ function default_1(host, options) {
|
|
|
24
23
|
if (!(0, adsp_utils_1.hasDependency)(host, '@nx-dotnet/core')) {
|
|
25
24
|
throw new Error('nx-dotnet/core is required to generate dotnet service');
|
|
26
25
|
}
|
|
27
|
-
const normalizedOptions = normalizeOptions(host, options);
|
|
26
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
28
27
|
const { default: appGenerator } = yield Promise.resolve().then(() => require(`${'@nx-dotnet/core/src/generators/app/generator'}`));
|
|
29
28
|
const { default: refGenerator } = yield Promise.resolve().then(() => require(`${'@nx-dotnet/core/src/generators/nuget-reference/generator'}`));
|
|
30
29
|
yield appGenerator(host, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotnet-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/dotnet-service/dotnet-service.ts"],"names":[],"mappings":";;;AAAA,yCAMsB;AACtB,
|
|
1
|
+
{"version":3,"file":"dotnet-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/dotnet-service/dotnet-service.ts"],"names":[],"mappings":";;;AAAA,yCAMsB;AACtB,6BAA6B;AAC7B,uDAA6E;AAG7E,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;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B,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,MAAM,YAAY,CAAC,IAAI,EAAE;YACvB,OAAO,EAAE,iBAAiB,CAAC,WAAW;YACtC,WAAW,EAAE,UAAU;YACvB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QAEH,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAElC,IAAI,IAAA,0BAAa,EAAC,IAAI,EAAE,cAAc,CAAC,EAAE;YACvC,MAAM,EAAE,mBAAmB,EAAE,GAAG,2CAAa,GAAG,cAAc,EAAE,EAAC,CAAC;YAClE,MAAM,mBAAmB,CAAC,IAAI,kCACzB,OAAO,KACV,OAAO,EAAE,iBAAiB,CAAC,WAAW,IACtC,CAAC;SACJ;QAED,OAAO,GAAS,EAAE;YAChB,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAA,CAAC;IACJ,CAAC;CAAA;AA5CD,4BA4CC"}
|
|
@@ -14,7 +14,8 @@ const refGeneratorMock = refGenerator as jest.Mocked<typeof refGenerator>;
|
|
|
14
14
|
describe('Dotnet Service Generator', () => {
|
|
15
15
|
const options: Schema = {
|
|
16
16
|
name: 'test',
|
|
17
|
-
|
|
17
|
+
env: 'dev',
|
|
18
|
+
realm: 'test',
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
it('can run', async () => {
|
|
@@ -2,13 +2,12 @@ import { AdspConfiguration } from '../../utils/adsp';
|
|
|
2
2
|
|
|
3
3
|
export interface Schema {
|
|
4
4
|
name: string;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
env: EnvironmentName;
|
|
6
|
+
realm: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface NormalizedSchema extends Schema {
|
|
10
10
|
projectName: string;
|
|
11
11
|
projectRoot: string;
|
|
12
12
|
adsp: AdspConfiguration;
|
|
13
|
-
namespace: string;
|
|
14
13
|
}
|
|
@@ -14,21 +14,38 @@
|
|
|
14
14
|
},
|
|
15
15
|
"x-prompt": "What name would you like to use?"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
17
|
+
"env": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "Environment to target.",
|
|
20
20
|
"$default": {
|
|
21
21
|
"$source": "argv",
|
|
22
22
|
"index": 1
|
|
23
23
|
},
|
|
24
|
-
"alias": "
|
|
25
|
-
"x-prompt":
|
|
24
|
+
"alias": "e",
|
|
25
|
+
"x-prompt": {
|
|
26
|
+
"message": "Which ADSP environment do you want to target?",
|
|
27
|
+
"type": "list",
|
|
28
|
+
"items": [
|
|
29
|
+
"dev",
|
|
30
|
+
"test",
|
|
31
|
+
"prod"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
26
34
|
},
|
|
27
|
-
"
|
|
35
|
+
"realm": {
|
|
28
36
|
"type": "string",
|
|
29
|
-
"description": "
|
|
30
|
-
"
|
|
37
|
+
"description": "Realm of the ADSP tenant.",
|
|
38
|
+
"$default": {
|
|
39
|
+
"$source": "argv",
|
|
40
|
+
"index": 2
|
|
41
|
+
},
|
|
42
|
+
"alias": "r",
|
|
43
|
+
"x-prompt": "What is the realm of your ADSP tenant?"
|
|
31
44
|
}
|
|
32
45
|
},
|
|
33
|
-
"required": [
|
|
34
|
-
|
|
46
|
+
"required": [
|
|
47
|
+
"name",
|
|
48
|
+
"env",
|
|
49
|
+
"realm"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -7,12 +7,14 @@ const linter_1 = require("@nrwl/linter");
|
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const adsp_utils_1 = require("../../utils/adsp-utils");
|
|
9
9
|
function normalizeOptions(host, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
12
|
+
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectName}`;
|
|
13
|
+
const adsp = yield (0, adsp_utils_1.getAdspConfiguration)(host, options);
|
|
14
|
+
return Object.assign(Object.assign({}, options), { projectName,
|
|
15
|
+
projectRoot,
|
|
16
|
+
adsp });
|
|
17
|
+
});
|
|
16
18
|
}
|
|
17
19
|
function addFiles(host, options) {
|
|
18
20
|
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), options.adsp), { tmpl: '' });
|
|
@@ -20,13 +22,13 @@ function addFiles(host, options) {
|
|
|
20
22
|
}
|
|
21
23
|
function default_1(host, options) {
|
|
22
24
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const normalizedOptions = normalizeOptions(host, options);
|
|
25
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
24
26
|
const { applicationGenerator: initExpress } = yield Promise.resolve().then(() => require('@nrwl/express'));
|
|
25
27
|
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 }));
|
|
26
28
|
(0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
27
29
|
'@abgov/adsp-service-sdk': '^1.18.0',
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
dotenv: '^16.0.0',
|
|
31
|
+
passport: '^0.6.0',
|
|
30
32
|
'passport-anonymous': '^1.0.1',
|
|
31
33
|
}, {
|
|
32
34
|
'@types/passport': '^1.0.9',
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"express-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/express-service/express-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AS;YACpC,MAAM,EAAE,SAAS;YACjB,QAAQ,EAAE,QAAQ;YAClB,oBAAoB,EAAE,QAAQ;SAC/B,EACD;YACE,iBAAiB,EAAE,QAAQ;YAC3B,2BAA2B,EAAE,QAAQ;SACtC,CACF,CAAC;QAEF,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAClC,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,CAAC,IAAI,kCACzB,OAAO,KACV,OAAO,EAAE,iBAAiB,CAAC,WAAW,IACtC,CAAC;SACJ;QAED,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AA1CD,4BA0CC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { AdspConfiguration } from '../../utils/adsp';
|
|
2
|
+
import { EnvironmentName } from '../../utils/environments';
|
|
2
3
|
|
|
3
4
|
export interface Schema {
|
|
4
5
|
name: string;
|
|
5
|
-
|
|
6
|
+
env: EnvironmentName;
|
|
6
7
|
realm: string;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export interface NormalizedSchema extends Schema {
|
|
10
11
|
projectName: string;
|
|
11
12
|
projectRoot: string;
|
|
12
|
-
adsp: AdspConfiguration
|
|
13
|
+
adsp: AdspConfiguration;
|
|
13
14
|
}
|
|
@@ -14,15 +14,23 @@
|
|
|
14
14
|
},
|
|
15
15
|
"x-prompt": "What name would you like to use?"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
17
|
+
"env": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "Environment to target.",
|
|
20
20
|
"$default": {
|
|
21
21
|
"$source": "argv",
|
|
22
22
|
"index": 1
|
|
23
23
|
},
|
|
24
|
-
"alias": "
|
|
25
|
-
"x-prompt":
|
|
24
|
+
"alias": "e",
|
|
25
|
+
"x-prompt": {
|
|
26
|
+
"message": "Which ADSP environment do you want to target?",
|
|
27
|
+
"type": "list",
|
|
28
|
+
"items": [
|
|
29
|
+
"dev",
|
|
30
|
+
"test",
|
|
31
|
+
"prod"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
26
34
|
},
|
|
27
35
|
"realm": {
|
|
28
36
|
"type": "string",
|
|
@@ -35,5 +43,9 @@
|
|
|
35
43
|
"x-prompt": "What is the realm of your ADSP tenant?"
|
|
36
44
|
}
|
|
37
45
|
},
|
|
38
|
-
"required": [
|
|
39
|
-
|
|
46
|
+
"required": [
|
|
47
|
+
"name",
|
|
48
|
+
"env",
|
|
49
|
+
"realm"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -7,17 +7,19 @@ const adsp_utils_1 = require("../../utils/adsp-utils");
|
|
|
7
7
|
const express_service_1 = require("../express-service/express-service");
|
|
8
8
|
const react_app_1 = require("../react-app/react-app");
|
|
9
9
|
function normalizeOptions(host, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const name = (0, devkit_1.names)(options.name).fileName;
|
|
12
|
+
const projectDirectory = name;
|
|
13
|
+
const projectName = projectDirectory.replace(new RegExp('/', 'g'), '-');
|
|
14
|
+
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectDirectory}`;
|
|
15
|
+
const openshiftDirectory = `${path.dirname((0, devkit_1.getWorkspacePath)(host))}/.openshift/${projectDirectory}`;
|
|
16
|
+
const adsp = yield (0, adsp_utils_1.getAdspConfiguration)(host, options);
|
|
17
|
+
return Object.assign(Object.assign({}, options), { projectName,
|
|
18
|
+
projectRoot,
|
|
19
|
+
projectDirectory,
|
|
20
|
+
openshiftDirectory,
|
|
21
|
+
adsp });
|
|
22
|
+
});
|
|
21
23
|
}
|
|
22
24
|
function addFiles(host, options) {
|
|
23
25
|
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.name)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot), template: '' });
|
|
@@ -26,11 +28,11 @@ function addFiles(host, options) {
|
|
|
26
28
|
}
|
|
27
29
|
function default_1(host, options) {
|
|
28
30
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const normalizedOptions = normalizeOptions(host, options);
|
|
31
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
30
32
|
yield (0, express_service_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-service` }));
|
|
31
33
|
yield (0, react_app_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-app`, proxy: {
|
|
32
34
|
location: '/api/',
|
|
33
|
-
proxyPass: `http://${options.name}-service:3333/${options.name}-service
|
|
35
|
+
proxyPass: `http://${options.name}-service:3333/${options.name}-service/`,
|
|
34
36
|
} }));
|
|
35
37
|
// Currently no files specific to MERN generator.
|
|
36
38
|
// addFiles(host, normalizedOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mern.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/mern/mern.ts"],"names":[],"mappings":";;;AAAA,yCASsB;AACtB,6BAA6B;AAC7B,uDAA8D;AAC9D,wEAAoE;AACpE,sDAAkD;AAGlD,
|
|
1
|
+
{"version":3,"file":"mern.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/mern/mern.ts"],"names":[],"mappings":";;;AAAA,yCASsB;AACtB,6BAA6B;AAC7B,uDAA8D;AAC9D,wEAAoE;AACpE,sDAAkD;AAGlD,SAAe,gBAAgB,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,iBAAiB,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEhE,MAAM,IAAA,yBAAkB,EAAC,IAAI,kCACxB,OAAO,KACV,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,UAAU,IAC/B,CAAC;QAEH,MAAM,IAAA,mBAAY,EAAC,IAAI,kCAClB,OAAO,KACV,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,MAAM,EAC3B,KAAK,EAAE;gBACL,QAAQ,EAAE,OAAO;gBACjB,SAAS,EAAE,UAAU,OAAO,CAAC,IAAI,iBAAiB,OAAO,CAAC,IAAI,WAAW;aAC1E,IACD,CAAC;QAEH,iDAAiD;QACjD,qCAAqC;QACrC,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AAxBD,4BAwBC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { AdspConfiguration } from
|
|
1
|
+
import { AdspConfiguration } from '../../utils/adsp';
|
|
2
|
+
import { EnvironmentName } from '../../utils/environments';
|
|
2
3
|
|
|
3
4
|
export interface Schema {
|
|
4
5
|
name: string;
|
|
5
|
-
|
|
6
|
+
env: EnvironmentName;
|
|
6
7
|
realm: string;
|
|
7
8
|
}
|
|
8
9
|
|
|
@@ -11,5 +12,5 @@ export interface NormalizedSchema extends Schema {
|
|
|
11
12
|
projectRoot: string;
|
|
12
13
|
projectDirectory: string;
|
|
13
14
|
openshiftDirectory: string;
|
|
14
|
-
adsp: AdspConfiguration
|
|
15
|
+
adsp: AdspConfiguration;
|
|
15
16
|
}
|
|
@@ -14,15 +14,23 @@
|
|
|
14
14
|
},
|
|
15
15
|
"x-prompt": "What name would you like to use?"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
17
|
+
"env": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "Environment to target.",
|
|
20
20
|
"$default": {
|
|
21
21
|
"$source": "argv",
|
|
22
22
|
"index": 1
|
|
23
23
|
},
|
|
24
|
-
"alias": "
|
|
25
|
-
"x-prompt":
|
|
24
|
+
"alias": "e",
|
|
25
|
+
"x-prompt": {
|
|
26
|
+
"message": "Which ADSP environment do you want to target?",
|
|
27
|
+
"type": "list",
|
|
28
|
+
"items": [
|
|
29
|
+
"dev",
|
|
30
|
+
"test",
|
|
31
|
+
"prod"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
26
34
|
},
|
|
27
35
|
"realm": {
|
|
28
36
|
"type": "string",
|
|
@@ -35,5 +43,9 @@
|
|
|
35
43
|
"x-prompt": "What is the realm of your ADSP tenant?"
|
|
36
44
|
}
|
|
37
45
|
},
|
|
38
|
-
"required": [
|
|
39
|
-
|
|
46
|
+
"required": [
|
|
47
|
+
"name",
|
|
48
|
+
"env",
|
|
49
|
+
"realm"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -1,26 +1,27 @@
|
|
|
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");
|
|
5
4
|
const devkit_1 = require("@nrwl/devkit");
|
|
6
5
|
const linter_1 = require("@nrwl/linter");
|
|
7
6
|
const path = require("path");
|
|
8
7
|
const adsp_utils_1 = require("../../utils/adsp-utils");
|
|
9
8
|
function normalizeOptions(host, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
11
|
+
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectName}`;
|
|
12
|
+
const openshiftDirectory = `.openshift/${projectName}`;
|
|
13
|
+
const adsp = yield (0, adsp_utils_1.getAdspConfiguration)(host, options);
|
|
14
|
+
const nginxProxies = Array.isArray(options.proxy)
|
|
15
|
+
? [...options.proxy]
|
|
16
|
+
: options.proxy
|
|
17
|
+
? [options.proxy]
|
|
18
|
+
: [];
|
|
19
|
+
return Object.assign(Object.assign({}, options), { projectName,
|
|
20
|
+
projectRoot,
|
|
21
|
+
openshiftDirectory,
|
|
22
|
+
adsp,
|
|
23
|
+
nginxProxies });
|
|
24
|
+
});
|
|
24
25
|
}
|
|
25
26
|
function addFiles(host, options) {
|
|
26
27
|
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), options.adsp), { tmpl: '' });
|
|
@@ -35,12 +36,12 @@ function addFiles(host, options) {
|
|
|
35
36
|
target: `${upstreamUrl.protocol}//localhost${upstreamUrl.port ? ':' + upstreamUrl.port : ''}`,
|
|
36
37
|
secure: upstreamUrl.protocol === 'https:',
|
|
37
38
|
changeOrigin: false,
|
|
38
|
-
pathRewrite: {}
|
|
39
|
+
pathRewrite: {},
|
|
39
40
|
};
|
|
40
41
|
// If there is a path on the upstream url, then add a rewrite.
|
|
41
42
|
if (upstreamUrl.pathname.length > 1) {
|
|
42
43
|
proxy.pathRewrite = {
|
|
43
|
-
[`^${nginxProxy.location}`]: upstreamUrl.pathname
|
|
44
|
+
[`^${nginxProxy.location}`]: upstreamUrl.pathname,
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
return Object.assign(Object.assign({}, proxyConf), { [nginxProxy.location]: proxy });
|
|
@@ -55,7 +56,7 @@ function removeFiles(host, options) {
|
|
|
55
56
|
}
|
|
56
57
|
function default_1(host, options) {
|
|
57
58
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
const normalizedOptions = normalizeOptions(host, options);
|
|
59
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
59
60
|
const { applicationGenerator: initReact } = yield Promise.resolve().then(() => require('@nrwl/react'));
|
|
60
61
|
const { reduxGenerator: initRedux } = yield Promise.resolve().then(() => require('@nrwl/react'));
|
|
61
62
|
// Setting strict to false because of: https://github.com/nrwl/nx/issues/8180
|
|
@@ -64,22 +65,21 @@ function default_1(host, options) {
|
|
|
64
65
|
style: 'styled-components',
|
|
65
66
|
skipFormat: true,
|
|
66
67
|
linter: linter_1.Linter.EsLint,
|
|
67
|
-
unitTestRunner:
|
|
68
|
-
e2eTestRunner:
|
|
68
|
+
unitTestRunner: 'jest',
|
|
69
|
+
e2eTestRunner: 'cypress',
|
|
69
70
|
babelJest: false,
|
|
70
71
|
strict: false,
|
|
71
72
|
});
|
|
72
73
|
yield initRedux(host, { name: 'intake', project: options.name });
|
|
73
74
|
(0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
74
|
-
'@abgov/
|
|
75
|
-
'@
|
|
76
|
-
'@types/
|
|
77
|
-
|
|
78
|
-
'html-webpack-plugin': '~4.5.2',
|
|
75
|
+
'@abgov/react-components': '^4.1.0',
|
|
76
|
+
'@types/react-router-dom': '~5.3.3',
|
|
77
|
+
'@types/redux-mock-store': '~1.0.2',
|
|
78
|
+
'html-webpack-plugin': '~5.5.0',
|
|
79
79
|
'oidc-client': '~1.11.5',
|
|
80
80
|
'redux-oidc': '~4.0.0-beta1',
|
|
81
81
|
'react-router-dom': '~5.2.0',
|
|
82
|
-
'redux-mock-store': '~1.5.4'
|
|
82
|
+
'redux-mock-store': '~1.5.4',
|
|
83
83
|
});
|
|
84
84
|
const addedProxy = addFiles(host, normalizedOptions);
|
|
85
85
|
removeFiles(host, normalizedOptions);
|
|
@@ -88,10 +88,10 @@ function default_1(host, options) {
|
|
|
88
88
|
config.targets.build.options = Object.assign(Object.assign({}, config.targets.build.options), { assets: [
|
|
89
89
|
...config.targets.build.options.assets,
|
|
90
90
|
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
91
|
+
glob: 'nginx.conf',
|
|
92
|
+
input: `${layout.appsDir}/${options.name}`,
|
|
93
|
+
output: './',
|
|
94
|
+
},
|
|
95
95
|
], webpackConfig: `${normalizedOptions.projectRoot}/webpack.conf.js` });
|
|
96
96
|
if (addedProxy) {
|
|
97
97
|
// Add the webpack dev server proxy if there is proxy configuration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-app/react-app.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"react-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-app/react-app.ts"],"names":[],"mappings":";;;AAAA,yCAWsB;AACtB,yCAAsC;AACtC,6BAA6B;AAC7B,uDAA6E;AAG7E,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;QAEf,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,MAAM,kBAAkB,GAAG,cAAc,WAAW,EAAE,CAAC;QAEvD,MAAM,IAAI,GAAG,MAAM,IAAA,iCAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEvD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;YAC/C,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;YACpB,CAAC,CAAC,OAAO,CAAC,KAAK;gBACf,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;gBACjB,CAAC,CAAC,EAAE,CAAC;QAEP,uCACK,OAAO,KACV,WAAW;YACX,WAAW;YACX,kBAAkB;YAClB,IAAI;YACJ,YAAY,IACZ;IACJ,CAAC;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AG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AA7ED,4BA6EC"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { AdspConfiguration } from '../../utils/adsp';
|
|
2
|
+
import { EnvironmentName } from '../../utils/environments';
|
|
2
3
|
import { NginxProxyConfiguration } from '../../utils/nginx';
|
|
3
4
|
|
|
4
5
|
export interface Schema {
|
|
5
6
|
name: string;
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
env: EnvironmentName;
|
|
8
|
+
realm: string;
|
|
9
|
+
proxy?: NginxProxyConfiguration | NginxProxyConfiguration[];
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export interface NormalizedSchema extends Schema {
|
|
11
13
|
projectName: string;
|
|
12
14
|
projectRoot: string;
|
|
13
15
|
openshiftDirectory: string;
|
|
14
|
-
adsp: AdspConfiguration
|
|
16
|
+
adsp: AdspConfiguration;
|
|
15
17
|
nginxProxies: NginxProxyConfiguration[];
|
|
16
18
|
}
|
|
@@ -14,15 +14,33 @@
|
|
|
14
14
|
},
|
|
15
15
|
"x-prompt": "What name would you like to use?"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
17
|
+
"env": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "Environment to target.",
|
|
20
20
|
"$default": {
|
|
21
21
|
"$source": "argv",
|
|
22
22
|
"index": 1
|
|
23
23
|
},
|
|
24
|
-
"alias": "
|
|
25
|
-
"x-prompt":
|
|
24
|
+
"alias": "e",
|
|
25
|
+
"x-prompt": {
|
|
26
|
+
"message": "Which ADSP environment do you want to target?",
|
|
27
|
+
"type": "list",
|
|
28
|
+
"items": [
|
|
29
|
+
"dev",
|
|
30
|
+
"test",
|
|
31
|
+
"prod"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"realm": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Realm of the ADSP tenant.",
|
|
38
|
+
"$default": {
|
|
39
|
+
"$source": "argv",
|
|
40
|
+
"index": 2
|
|
41
|
+
},
|
|
42
|
+
"alias": "r",
|
|
43
|
+
"x-prompt": "What is the realm of your ADSP tenant?"
|
|
26
44
|
},
|
|
27
45
|
"proxy": {
|
|
28
46
|
"oneOf": [
|
|
@@ -38,7 +56,10 @@
|
|
|
38
56
|
"type": "string"
|
|
39
57
|
}
|
|
40
58
|
},
|
|
41
|
-
"required": [
|
|
59
|
+
"required": [
|
|
60
|
+
"location",
|
|
61
|
+
"proxyPass"
|
|
62
|
+
]
|
|
42
63
|
}
|
|
43
64
|
},
|
|
44
65
|
{
|
|
@@ -51,10 +72,17 @@
|
|
|
51
72
|
"type": "string"
|
|
52
73
|
}
|
|
53
74
|
},
|
|
54
|
-
"required": [
|
|
75
|
+
"required": [
|
|
76
|
+
"location",
|
|
77
|
+
"proxyPass"
|
|
78
|
+
]
|
|
55
79
|
}
|
|
56
80
|
]
|
|
57
81
|
}
|
|
58
82
|
},
|
|
59
|
-
"required": [
|
|
60
|
-
|
|
83
|
+
"required": [
|
|
84
|
+
"name",
|
|
85
|
+
"env",
|
|
86
|
+
"realm"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
@@ -6,10 +6,10 @@ 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
8
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
yield (0, dotnet_service_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-service
|
|
9
|
+
yield (0, dotnet_service_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-service` }));
|
|
10
10
|
yield (0, react_app_1.default)(host, Object.assign(Object.assign({}, options), { name: `${options.name}-app`, proxy: {
|
|
11
11
|
location: '/api/',
|
|
12
|
-
proxyPass: `http://${options.name}-service:5000/${options.name}-service
|
|
12
|
+
proxyPass: `http://${options.name}-service:5000/${options.name}-service/`,
|
|
13
13
|
} }));
|
|
14
14
|
return () => {
|
|
15
15
|
(0, devkit_1.installPackagesTask)(host);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-dotnet.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-dotnet/react-dotnet.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"react-dotnet.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-dotnet/react-dotnet.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AACzD,qEAAiE;AACjE,sDAAkD;AAGlD,mBAA+B,IAAU,EAAE,OAAe;;QACxD,MAAM,IAAA,wBAAiB,EAAC,IAAI,kCACvB,OAAO,KACV,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,UAAU,IAC/B,CAAC;QAEH,MAAM,IAAA,mBAAY,EAAC,IAAI,kCAClB,OAAO,KACV,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,MAAM,EAC3B,KAAK,EAAE;gBACL,QAAQ,EAAE,OAAO;gBACjB,SAAS,EAAE,UAAU,OAAO,CAAC,IAAI,iBAAiB,OAAO,CAAC,IAAI,WAAW;aAC1E,IACD,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AAlBD,4BAkBC"}
|
|
@@ -14,16 +14,38 @@
|
|
|
14
14
|
},
|
|
15
15
|
"x-prompt": "What name would you like to use?"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
17
|
+
"env": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "Environment to target.",
|
|
20
20
|
"$default": {
|
|
21
21
|
"$source": "argv",
|
|
22
22
|
"index": 1
|
|
23
23
|
},
|
|
24
|
-
"alias": "
|
|
25
|
-
"x-prompt":
|
|
24
|
+
"alias": "e",
|
|
25
|
+
"x-prompt": {
|
|
26
|
+
"message": "Which ADSP environment do you want to target?",
|
|
27
|
+
"type": "list",
|
|
28
|
+
"items": [
|
|
29
|
+
"dev",
|
|
30
|
+
"test",
|
|
31
|
+
"prod"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"realm": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Realm of the ADSP tenant.",
|
|
38
|
+
"$default": {
|
|
39
|
+
"$source": "argv",
|
|
40
|
+
"index": 2
|
|
41
|
+
},
|
|
42
|
+
"alias": "r",
|
|
43
|
+
"x-prompt": "What is the realm of your ADSP tenant?"
|
|
26
44
|
}
|
|
27
45
|
},
|
|
28
|
-
"required": [
|
|
29
|
-
|
|
46
|
+
"required": [
|
|
47
|
+
"name",
|
|
48
|
+
"env",
|
|
49
|
+
"realm"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Tree } from '@nrwl/devkit';
|
|
2
2
|
import { AdspConfiguration } from './adsp';
|
|
3
|
+
import { EnvironmentName } from './environments';
|
|
3
4
|
export declare function hasDependency(host: Tree, dependency: string): boolean;
|
|
4
|
-
export declare function getAdspConfiguration(
|
|
5
|
-
|
|
6
|
-
realm
|
|
7
|
-
}): AdspConfiguration
|
|
5
|
+
export declare function getAdspConfiguration(_host: Tree, { env, realm }: {
|
|
6
|
+
env?: EnvironmentName;
|
|
7
|
+
realm: string;
|
|
8
|
+
}, login?: boolean): Promise<AdspConfiguration>;
|
package/src/utils/adsp-utils.js
CHANGED
|
@@ -1,20 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAdspConfiguration = exports.hasDependency = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
const axios_1 = require("axios");
|
|
7
|
+
const express = require("express");
|
|
8
|
+
const open = require("open");
|
|
9
|
+
const simple_oauth2_1 = require("simple-oauth2");
|
|
10
|
+
const environments_1 = require("./environments");
|
|
5
11
|
function hasDependency(host, dependency) {
|
|
6
12
|
const { dependencies, devDependencies } = (0, devkit_1.readJson)(host, 'package.json');
|
|
7
|
-
return !!dependencies[dependency] ||
|
|
8
|
-
!!devDependencies[dependency];
|
|
13
|
+
return !!dependencies[dependency] || !!devDependencies[dependency];
|
|
9
14
|
}
|
|
10
15
|
exports.hasDependency = hasDependency;
|
|
11
|
-
function
|
|
12
|
-
return {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
function tenantLogin(accessServiceUrl, realm) {
|
|
17
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const client = new simple_oauth2_1.AuthorizationCode({
|
|
19
|
+
client: {
|
|
20
|
+
id: 'nx-adsp-cli',
|
|
21
|
+
secret: '',
|
|
22
|
+
},
|
|
23
|
+
auth: {
|
|
24
|
+
tokenHost: accessServiceUrl,
|
|
25
|
+
tokenPath: `/auth/realms/${realm}/protocol/openid-connect/token`,
|
|
26
|
+
authorizePath: `/auth/realms/${realm}/protocol/openid-connect/auth`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const redirect_uri = 'http://localhost:3000/callback';
|
|
30
|
+
const authorizationUri = client.authorizeURL({
|
|
31
|
+
redirect_uri,
|
|
32
|
+
scope: 'profile email',
|
|
33
|
+
});
|
|
34
|
+
const app = express();
|
|
35
|
+
const tokenPromise = new Promise((resolve) => {
|
|
36
|
+
app.get('/callback', function (req, res) {
|
|
37
|
+
res.send('Successfully signed in. You can close the browser.');
|
|
38
|
+
resolve(client.getToken({
|
|
39
|
+
code: req.query.code,
|
|
40
|
+
redirect_uri,
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
const server = app.listen(3000);
|
|
45
|
+
open(authorizationUri);
|
|
46
|
+
const { token } = yield Promise.race([
|
|
47
|
+
tokenPromise,
|
|
48
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Timed out waiting for login.')), 120000)),
|
|
49
|
+
]).finally(() => server.close());
|
|
50
|
+
return token.access_token;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function getAdspConfiguration(_host, { env, realm }, login = false) {
|
|
54
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
let tenant = '';
|
|
56
|
+
const environment = environments_1.environments[env || 'prod'];
|
|
57
|
+
if (login) {
|
|
58
|
+
const { data: entries } = yield axios_1.default.get(new URL('/directory/v2/namespaces/platform/entries', environment.directoryServiceUrl).href, { decompress: true, responseEncoding: 'utf8', responseType: 'json' });
|
|
59
|
+
const urls = entries.reduce((values, item) => (Object.assign(Object.assign({}, values), { [item.urn]: item.url })), {});
|
|
60
|
+
const token = yield tenantLogin(environment.accessServiceUrl, realm);
|
|
61
|
+
const tenantServiceUrl = urls['urn:ads:platform:tenant-service:v2'];
|
|
62
|
+
const { data: tenants } = yield axios_1.default.get(new URL('v2/tenants', tenantServiceUrl).href, { headers: { Authorization: `Bearer ${token}` } });
|
|
63
|
+
tenant = tenants.results[0].name;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
tenant,
|
|
67
|
+
tenantRealm: realm,
|
|
68
|
+
accessServiceUrl: environment.accessServiceUrl,
|
|
69
|
+
directoryServiceUrl: environment.directoryServiceUrl,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
18
72
|
}
|
|
19
73
|
exports.getAdspConfiguration = getAdspConfiguration;
|
|
20
74
|
//# sourceMappingURL=adsp-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adsp-utils.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/adsp-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adsp-utils.js","sourceRoot":"","sources":["../../../../../packages/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AC,gBAAgB,EAAE,KAAK,CAAC,CAAC;YAErE,MAAM,gBAAgB,GAAG,IAAI,CAAC,oCAAoC,CAAC,CAAC;YACpE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,eAAK,CAAC,GAAG,CACvC,IAAI,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAC5C,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,EAAE,CAClD,CAAC;YAEF,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;SAClC;QAED,OAAO;YACL,MAAM;YACN,WAAW,EAAE,KAAK;YAClB,gBAAgB,EAAE,WAAW,CAAC,gBAAgB;YAC9C,mBAAmB,EAAE,WAAW,CAAC,mBAAmB;SACrD,CAAC;IACJ,CAAC;CAAA;AAvCD,oDAuCC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.environments = void 0;
|
|
4
|
+
exports.environments = {
|
|
5
|
+
dev: {
|
|
6
|
+
accessServiceUrl: 'https://access.adsp-dev.gov.ab.ca',
|
|
7
|
+
directoryServiceUrl: 'https://directory-service.adsp-dev.gov.ab.ca',
|
|
8
|
+
},
|
|
9
|
+
test: {
|
|
10
|
+
accessServiceUrl: 'https://access-uat.alberta.ca',
|
|
11
|
+
directoryServiceUrl: 'https://directory-service.adsp-uat.alberta.ca',
|
|
12
|
+
},
|
|
13
|
+
prod: {
|
|
14
|
+
accessServiceUrl: 'https://access.alberta.ca',
|
|
15
|
+
directoryServiceUrl: 'https://directory-service.adsp.alberta.ca',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=environments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../../../packages/nx-adsp/src/utils/environments.ts"],"names":[],"mappings":";;;AAMa,QAAA,YAAY,GAAyC;IAChE,GAAG,EAAE;QACH,gBAAgB,EAAE,mCAAmC;QACrD,mBAAmB,EAAE,8CAA8C;KACpE;IACD,IAAI,EAAE;QACJ,gBAAgB,EAAE,+BAA+B;QACjD,mBAAmB,EAAE,+CAA+C;KACrE;IACD,IAAI,EAAE;QACJ,gBAAgB,EAAE,2BAA2B;QAC7C,mBAAmB,EAAE,2CAA2C;KACjE;CACF,CAAC"}
|