@abgov/nx-adsp 12.4.0 → 12.5.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 +6 -0
- package/package.json +1 -1
- package/src/generators/angular-app/angular-app.js +22 -7
- package/src/generators/angular-app/angular-app.js.map +1 -1
- package/src/generators/angular-app/files/nginx.conf__tmpl__ +14 -7
- package/src/generators/angular-app/files/src/app/app.component.css__tmpl__ +10 -54
- package/src/generators/angular-app/files/src/app/app.component.html__tmpl__ +18 -49
- package/src/generators/angular-app/files/src/app/app.component.spec.ts__tmpl__ +22 -27
- package/src/generators/angular-app/files/src/app/app.component.ts__tmpl__ +60 -20
- package/src/generators/angular-app/files/src/app/app.config.ts__tmpl__ +27 -0
- package/src/generators/angular-app/files/src/app/app.routes.ts__tmpl__ +10 -31
- package/src/generators/angular-app/files/src/app/home/home.component.html__tmpl__ +1 -3
- package/src/generators/angular-app/files/src/app/home/home.component.ts__tmpl__ +9 -23
- package/src/generators/angular-app/files/src/app/protected/protected.component.html__tmpl__ +2 -2
- package/src/generators/angular-app/files/src/app/protected/protected.component.spec.ts__tmpl__ +27 -43
- package/src/generators/angular-app/files/src/app/protected/protected.component.ts__tmpl__ +15 -15
- package/src/generators/angular-app/files/src/app/services/auth-guard.service.ts__tmpl__ +12 -21
- package/src/generators/angular-app/files/src/environments/environment.ts__tmpl__ +2 -11
- package/src/generators/angular-app/files/src/index.html__tmpl__ +3 -9
- package/src/generators/angular-app/files/src/main.ts__tmpl__ +8 -12
- package/src/generators/angular-app/files/src/silent-check-sso.html__tmpl__ +5 -0
- package/src/generators/angular-app/files/src/styles.css__tmpl__ +2 -2
- package/src/generators/mean/mean.d.ts +3 -0
- package/src/generators/mean/mean.js +30 -0
- package/src/generators/mean/mean.js.map +1 -0
- package/src/generators/mean/mean.spec.ts +38 -0
- package/src/generators/mean/schema.d.ts +11 -0
- package/src/generators/mean/schema.json +26 -0
- package/src/generators/mern/mern.js +5 -21
- package/src/generators/mern/mern.js.map +1 -1
- package/src/generators/mern/schema.d.ts +0 -4
- package/src/generators/react-app/files/nginx.conf__tmpl__ +18 -7
- package/src/generators/react-app/react-app.js +6 -0
- package/src/generators/react-app/react-app.js.map +1 -1
- package/src/generators/angular-app/files/src/app/app.module.ts__tmpl__ +0 -47
- package/src/generators/angular-app/files/src/app/auth-callback/auth-callback.component.css__tmpl__ +0 -13
- package/src/generators/angular-app/files/src/app/auth-callback/auth-callback.component.html__tmpl__ +0 -12
- package/src/generators/angular-app/files/src/app/auth-callback/auth-callback.component.spec.ts__tmpl__ +0 -33
- package/src/generators/angular-app/files/src/app/auth-callback/auth-callback.component.ts__tmpl__ +0 -48
- package/src/generators/angular-app/files/src/app/auth.interceptor.ts__tmpl__ +0 -24
- package/src/generators/angular-app/files/src/app/logout/logout.component.html__tmpl__ +0 -1
- package/src/generators/angular-app/files/src/app/logout/logout.component.ts__tmpl__ +0 -9
- package/src/generators/angular-app/files/src/app/services/auth.service.ts__tmpl__ +0 -57
- package/src/generators/angular-app/files/src/app/tenant.service.ts__tmpl__ +0 -19
- package/src/generators/angular-app/files/src/environments/config.ts__tmpl__ +0 -21
- /package/src/generators/angular-app/files/{src → public}/assets/banner.jpg +0 -0
- /package/src/generators/angular-app/files/{src → public}/assets/github-1.svg +0 -0
- /package/src/generators/angular-app/files/{src → public}/favicon.ico +0 -0
package/src/generators/angular-app/files/src/app/protected/protected.component.spec.ts__tmpl__
CHANGED
|
@@ -1,52 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
3
|
+
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
|
4
|
+
import { Keycloak } from 'keycloak-angular';
|
|
2
5
|
import { ProtectedComponent } from './protected.component';
|
|
3
|
-
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
|
4
|
-
import TenantService from '../tenant.service';
|
|
5
|
-
import {
|
|
6
|
-
BrowserDynamicTestingModule,
|
|
7
|
-
platformBrowserDynamicTesting
|
|
8
|
-
} from "@angular/platform-browser-dynamic/testing";
|
|
9
6
|
|
|
10
7
|
describe('ProtectedComponent', () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const keycloakMock = {
|
|
9
|
+
authenticated: true,
|
|
10
|
+
tokenParsed: { name: 'Test User' },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let httpTesting: HttpTestingController;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
await TestBed.configureTestingModule({
|
|
17
|
+
imports: [ProtectedComponent],
|
|
18
|
+
providers: [
|
|
19
|
+
provideHttpClient(),
|
|
20
|
+
provideHttpClientTesting(),
|
|
21
|
+
{ provide: Keycloak, useValue: keycloakMock },
|
|
22
|
+
],
|
|
23
|
+
}).compileComponents();
|
|
24
|
+
|
|
25
|
+
httpTesting = TestBed.inject(HttpTestingController);
|
|
18
26
|
});
|
|
19
|
-
beforeEach(
|
|
20
|
-
waitForAsync(() => {
|
|
21
|
-
TestBed.configureTestingModule({
|
|
22
|
-
declarations: [ProtectedComponent],
|
|
23
|
-
providers: [ProtectedComponent, TenantService],
|
|
24
|
-
imports: [HttpClientTestingModule],
|
|
25
|
-
}).compileComponents();
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
);
|
|
28
|
+
afterEach(() => httpTesting.verify());
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
fixture = TestBed.createComponent(ProtectedComponent);
|
|
30
|
+
it('should create', () => {
|
|
31
|
+
const fixture = TestBed.createComponent(ProtectedComponent);
|
|
33
32
|
fixture.detectChanges();
|
|
33
|
+
httpTesting.expectOne('/api/v1/private').flush({ message: 'Hello' });
|
|
34
|
+
expect(fixture.componentInstance).toBeTruthy();
|
|
34
35
|
});
|
|
35
|
-
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
httpTestingController.verify();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should create', (inject([TenantService, HttpTestingController],
|
|
41
|
-
() => {
|
|
42
|
-
const mockTenant = { status: 200, statusText: 'OK'}
|
|
43
|
-
const data = { name: 'Child Services' }
|
|
44
|
-
const req = httpTestingController.expectOne(
|
|
45
|
-
'http://localhost:3333/api/tenant/v1/realm/123'
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
expect(req.request.method).toEqual('GET');
|
|
49
|
-
|
|
50
|
-
req.flush(data, mockTenant);
|
|
51
|
-
})));
|
|
52
36
|
});
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Component, OnInit } from '@angular/core';
|
|
2
|
-
import
|
|
1
|
+
import { Component, inject, OnInit, signal } from '@angular/core';
|
|
2
|
+
import { HttpClient } from '@angular/common/http';
|
|
3
|
+
import Keycloak from 'keycloak-js';
|
|
3
4
|
|
|
4
5
|
@Component({
|
|
5
|
-
selector: '
|
|
6
|
+
selector: '<%= projectName %>-protected',
|
|
7
|
+
standalone: true,
|
|
6
8
|
templateUrl: './protected.component.html',
|
|
7
|
-
|
|
9
|
+
styleUrl: './protected.component.css',
|
|
8
10
|
})
|
|
9
11
|
export class ProtectedComponent implements OnInit {
|
|
10
|
-
|
|
12
|
+
private http = inject(HttpClient);
|
|
13
|
+
private keycloak = inject(Keycloak);
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
privateMessage = signal('Not retrieved');
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
(data: any) => {
|
|
17
|
-
this.tenant = data.tenant;
|
|
18
|
-
},
|
|
19
|
-
(err) => console.error(err),
|
|
20
|
-
() => console.log('done loading tenant')
|
|
21
|
-
);
|
|
17
|
+
get userName(): string {
|
|
18
|
+
return (this.keycloak.tokenParsed?.['name'] as string) ?? '';
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
ngOnInit() {
|
|
25
|
-
this.
|
|
22
|
+
this.http.get<{ message: string }>('/api/v1/private').subscribe({
|
|
23
|
+
next: (data) => this.privateMessage.set(data.message),
|
|
24
|
+
error: () => this.privateMessage.set('Error loading data'),
|
|
25
|
+
});
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (this.authService.isLoggedIn()) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
console.log('start authentication...');
|
|
18
|
-
this.authService.startAuthentication();
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
// Auth guard is configured in app.routes.ts using keycloak-angular's createAuthGuard.
|
|
2
|
+
// Add this file if you need a reusable, injectable guard:
|
|
3
|
+
//
|
|
4
|
+
// import { Injectable } from '@angular/core';
|
|
5
|
+
// import { Router } from '@angular/router';
|
|
6
|
+
// import { createAuthGuard } from 'keycloak-angular';
|
|
7
|
+
//
|
|
8
|
+
// export const authGuard = createAuthGuard(async ({ keycloak }) => {
|
|
9
|
+
// if (keycloak.authenticated) return true;
|
|
10
|
+
// await keycloak.login({ redirectUri: window.location.href });
|
|
11
|
+
// return false;
|
|
12
|
+
// });
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
// This file can be replaced during build by using the `fileReplacements` array.
|
|
2
|
-
// When building for production, this file is replaced with `environment.prod.ts`.
|
|
3
|
-
|
|
4
1
|
export const environment = {
|
|
5
2
|
production: false,
|
|
6
3
|
access: {
|
|
7
|
-
url: '<%= accessServiceUrl
|
|
4
|
+
url: '<%= accessServiceUrl %>/auth',
|
|
8
5
|
realm: '<%= tenantRealm %>',
|
|
9
|
-
client_id: 'urn:ads:<%= tenant %>:<%= projectName %>'
|
|
6
|
+
client_id: 'urn:ads:<%= tenant %>:<%= projectName %>',
|
|
10
7
|
},
|
|
11
|
-
tenantApi: {
|
|
12
|
-
host: "http://localhost:3333",
|
|
13
|
-
endpoints: {
|
|
14
|
-
tenantNameByRealm: "/api/tenant/v1/realm",
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
8
|
};
|
|
@@ -6,16 +6,10 @@
|
|
|
6
6
|
<base href="/" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
8
|
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
|
9
|
-
<script
|
|
10
|
-
|
|
11
|
-
src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"
|
|
12
|
-
></script>
|
|
13
|
-
<script
|
|
14
|
-
nomodule
|
|
15
|
-
src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"
|
|
16
|
-
></script>
|
|
9
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/ionicons@latest/dist/ionicons/ionicons.esm.js"></script>
|
|
10
|
+
<script nomodule src="https://cdn.jsdelivr.net/npm/ionicons@latest/dist/ionicons/ionicons.js"></script>
|
|
17
11
|
</head>
|
|
18
12
|
<body>
|
|
19
|
-
<<%= projectName %>-
|
|
13
|
+
<<%= projectName %>-root></<%= projectName %>-root>
|
|
20
14
|
</body>
|
|
21
15
|
</html>
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import 'zone.js';
|
|
2
|
+
import '@abgov/web-components';
|
|
3
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
4
|
+
import { AppComponent } from './app/app.component';
|
|
5
|
+
import { appConfig } from './app/app.config';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (environment.production) {
|
|
8
|
-
enableProdMode();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
platformBrowserDynamic()
|
|
12
|
-
.bootstrapModule(AppModule)
|
|
13
|
-
.catch((err) => console.error(err));
|
|
7
|
+
bootstrapApplication(AppComponent, appConfig).catch((err) =>
|
|
8
|
+
console.error(err)
|
|
9
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
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 angular_app_1 = require("../angular-app/angular-app");
|
|
8
|
+
const express_service_1 = require("../express-service/express-service");
|
|
9
|
+
function normalizeOptions(host, options) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const adsp = yield (0, nx_oc_1.getAdspConfiguration)(host, options);
|
|
12
|
+
return Object.assign(Object.assign({}, options), { adsp });
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function default_1(host, options) {
|
|
16
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
18
|
+
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
19
|
+
yield (0, express_service_1.default)(host, Object.assign(Object.assign({}, normalizedOptions), { name: `${projectName}-service` }));
|
|
20
|
+
yield (0, angular_app_1.default)(host, Object.assign(Object.assign({}, normalizedOptions), { name: `${projectName}-app`, proxy: {
|
|
21
|
+
location: '/api/',
|
|
22
|
+
proxyPass: `http://${projectName}-service:3333/${projectName}-service/`,
|
|
23
|
+
} }));
|
|
24
|
+
yield (0, devkit_1.formatFiles)(host);
|
|
25
|
+
return () => {
|
|
26
|
+
(0, devkit_1.installPackagesTask)(host);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=mean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mean.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/mean/mean.ts"],"names":[],"mappings":";;AAcA,4BAuBC;;AArCD,uCAA2E;AAC3E,wCAAoD;AACpD,4DAAwD;AACxD,wEAAoE;AAGpE,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;QAEf,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,uCAAY,OAAO,KAAE,IAAI,IAAG;IAC9B,CAAC;CAAA;AAED,mBAA+B,IAAU,EAAE,OAAe;;QACxD,MAAM,iBAAiB,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QAEjD,MAAM,IAAA,yBAAkB,EAAC,IAAI,kCACxB,iBAAiB,KACpB,IAAI,EAAE,GAAG,WAAW,UAAU,IAC9B,CAAC;QAEH,MAAM,IAAA,qBAAc,EAAC,IAAI,kCACpB,iBAAiB,KACpB,IAAI,EAAE,GAAG,WAAW,MAAM,EAC1B,KAAK,EAAE;gBACL,QAAQ,EAAE,OAAO;gBACjB,SAAS,EAAE,UAAU,WAAW,iBAAiB,WAAW,WAAW;aACxE,IACD,CAAC;QAEH,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,38 @@
|
|
|
1
|
+
import { readProjectConfiguration } from '@nx/devkit';
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
+
import * as utils from '@abgov/nx-oc';
|
|
4
|
+
import { environments } from '@abgov/nx-oc';
|
|
5
|
+
import { Schema } from './schema';
|
|
6
|
+
import generator from './mean';
|
|
7
|
+
|
|
8
|
+
jest.mock('@abgov/nx-oc');
|
|
9
|
+
const utilsMock = utils as jest.Mocked<typeof utils>;
|
|
10
|
+
utilsMock.getAdspConfiguration.mockResolvedValue({
|
|
11
|
+
tenant: 'test',
|
|
12
|
+
tenantRealm: 'test',
|
|
13
|
+
accessServiceUrl: environments.test.accessServiceUrl,
|
|
14
|
+
directoryServiceUrl: environments.test.directoryServiceUrl,
|
|
15
|
+
});
|
|
16
|
+
utilsMock.deploymentGenerator.mockResolvedValue(undefined);
|
|
17
|
+
|
|
18
|
+
describe('MEAN Generator', () => {
|
|
19
|
+
const options: Schema = {
|
|
20
|
+
name: 'test',
|
|
21
|
+
env: 'dev',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
it('can run', async () => {
|
|
25
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
26
|
+
await generator(host, options);
|
|
27
|
+
|
|
28
|
+
const appConfig = readProjectConfiguration(host, 'test-app');
|
|
29
|
+
expect(appConfig.root).toBe('apps/test-app');
|
|
30
|
+
|
|
31
|
+
const serviceConfig = readProjectConfiguration(host, 'test-service');
|
|
32
|
+
expect(serviceConfig.root).toBe('apps/test-service');
|
|
33
|
+
|
|
34
|
+
expect(host.exists('apps/test-app/nginx.conf')).toBeTruthy();
|
|
35
|
+
const nginxConf = host.read('apps/test-app/nginx.conf').toString();
|
|
36
|
+
expect(nginxConf).toContain('http://test-service:3333/');
|
|
37
|
+
}, 30000);
|
|
38
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "mean",
|
|
5
|
+
"title": "MEAN fullstack generator",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Name of the project.",
|
|
11
|
+
"$default": { "$source": "argv", "index": 0 },
|
|
12
|
+
"x-prompt": "What name would you like to use for the project?"
|
|
13
|
+
},
|
|
14
|
+
"env": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "ADSP environment to initialize the project for.",
|
|
17
|
+
"enum": ["dev", "test", "prod"],
|
|
18
|
+
"default": "prod"
|
|
19
|
+
},
|
|
20
|
+
"accessToken": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Access token for ADSP tenant configuration (skips interactive login)."
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["name"]
|
|
26
|
+
}
|
|
@@ -3,40 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const path = require("path");
|
|
7
6
|
const nx_oc_1 = require("@abgov/nx-oc");
|
|
8
7
|
const express_service_1 = require("../express-service/express-service");
|
|
9
8
|
const react_app_1 = require("../react-app/react-app");
|
|
10
9
|
function normalizeOptions(host, options) {
|
|
11
10
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
const name = (0, devkit_1.names)(options.name).fileName;
|
|
13
|
-
const projectDirectory = name;
|
|
14
|
-
const projectName = projectDirectory.replace(new RegExp('/', 'g'), '-');
|
|
15
|
-
const projectRoot = `${(0, devkit_1.getWorkspaceLayout)(host).appsDir}/${projectDirectory}`;
|
|
16
|
-
const openshiftDirectory = `.openshift/${projectDirectory}`;
|
|
17
11
|
const adsp = yield (0, nx_oc_1.getAdspConfiguration)(host, options);
|
|
18
|
-
return Object.assign(Object.assign({}, options), {
|
|
19
|
-
projectRoot,
|
|
20
|
-
projectDirectory,
|
|
21
|
-
openshiftDirectory,
|
|
22
|
-
adsp });
|
|
12
|
+
return Object.assign(Object.assign({}, options), { adsp });
|
|
23
13
|
});
|
|
24
14
|
}
|
|
25
|
-
function addFiles(host, options) {
|
|
26
|
-
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), (0, devkit_1.names)(options.name)), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot), template: '' });
|
|
27
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
28
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'openshift'), `${options.openshiftDirectory}`, templateOptions);
|
|
29
|
-
}
|
|
30
15
|
function default_1(host, options) {
|
|
31
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
32
17
|
const normalizedOptions = yield normalizeOptions(host, options);
|
|
33
|
-
|
|
34
|
-
yield (0,
|
|
18
|
+
const projectName = (0, devkit_1.names)(options.name).fileName;
|
|
19
|
+
yield (0, express_service_1.default)(host, Object.assign(Object.assign({}, normalizedOptions), { name: `${projectName}-service` }));
|
|
20
|
+
yield (0, react_app_1.default)(host, Object.assign(Object.assign({}, normalizedOptions), { name: `${projectName}-app`, proxy: {
|
|
35
21
|
location: '/api/',
|
|
36
|
-
proxyPass: `http://${
|
|
22
|
+
proxyPass: `http://${projectName}-service:3333/${projectName}-service/`,
|
|
37
23
|
} }));
|
|
38
|
-
// Currently no files specific to MERN generator.
|
|
39
|
-
// addFiles(host, normalizedOptions);
|
|
40
24
|
yield (0, devkit_1.formatFiles)(host);
|
|
41
25
|
return () => {
|
|
42
26
|
(0, devkit_1.installPackagesTask)(host);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mern.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/mern/mern.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mern.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/mern/mern.ts"],"names":[],"mappings":";;AAcA,4BAuBC;;AArCD,uCAA2E;AAC3E,wCAAoD;AACpD,wEAAoE;AACpE,sDAAkD;AAGlD,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;QAEf,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvD,uCAAY,OAAO,KAAE,IAAI,IAAG;IAC9B,CAAC;CAAA;AAED,mBAA+B,IAAU,EAAE,OAAe;;QACxD,MAAM,iBAAiB,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QAEjD,MAAM,IAAA,yBAAkB,EAAC,IAAI,kCACxB,iBAAiB,KACpB,IAAI,EAAE,GAAG,WAAW,UAAU,IAC9B,CAAC;QAEH,MAAM,IAAA,mBAAY,EAAC,IAAI,kCAClB,iBAAiB,KACpB,IAAI,EAAE,GAAG,WAAW,MAAM,EAC1B,KAAK,EAAE;gBACL,QAAQ,EAAE,OAAO;gBACjB,SAAS,EAAE,UAAU,WAAW,iBAAiB,WAAW,WAAW;aACxE,IACD,CAAC;QAEH,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
events {
|
|
2
|
-
worker_connections
|
|
2
|
+
worker_connections 1024;
|
|
3
3
|
}
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
http {
|
|
5
6
|
sendfile on;
|
|
6
7
|
include mime.types;
|
|
7
8
|
default_type application/octet-stream;
|
|
8
9
|
|
|
10
|
+
gzip on;
|
|
11
|
+
gzip_types text/plain text/css application/javascript application/json image/svg+xml font/woff2;
|
|
12
|
+
gzip_min_length 1000;
|
|
13
|
+
|
|
9
14
|
server {
|
|
10
|
-
|
|
11
15
|
listen 8080;
|
|
12
16
|
root /opt/app-root/src;
|
|
13
17
|
index index.html;
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
20
|
+
add_header X-Content-Type-Options "nosniff" always;
|
|
21
|
+
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
22
|
+
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
23
|
+
|
|
24
|
+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
17
25
|
expires 30d;
|
|
18
26
|
add_header Cache-Control "public, no-transform";
|
|
19
|
-
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
location = /silent-check-sso.html {
|
|
30
|
+
add_header Cache-Control "no-store";
|
|
31
|
+
}
|
|
20
32
|
|
|
21
33
|
location / {
|
|
22
|
-
gzip on;
|
|
23
34
|
try_files $uri /index.html;
|
|
24
35
|
}
|
|
25
36
|
<% nginxProxies.forEach(function(nginxProxy){ %>
|
|
@@ -58,6 +58,7 @@ function removeFiles(host, options) {
|
|
|
58
58
|
}
|
|
59
59
|
function default_1(host, options) {
|
|
60
60
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
var _a, _b;
|
|
61
62
|
const normalizedOptions = yield normalizeOptions(host, options);
|
|
62
63
|
const { applicationGenerator: initReact } = yield Promise.resolve().then(() => require('@nx/react'));
|
|
63
64
|
// Setting strict to false because of: https://github.com/nrwl/nx/issues/8180
|
|
@@ -87,6 +88,11 @@ function default_1(host, options) {
|
|
|
87
88
|
removeFiles(host, normalizedOptions);
|
|
88
89
|
const layout = (0, devkit_1.getWorkspaceLayout)(host);
|
|
89
90
|
const config = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
91
|
+
// Remove the generated fileReplacements for production — we use a single
|
|
92
|
+
// environment.ts with runtime env vars rather than a build-time swap.
|
|
93
|
+
if ((_b = (_a = config.targets.build.configurations) === null || _a === void 0 ? void 0 : _a.production) === null || _b === void 0 ? void 0 : _b.fileReplacements) {
|
|
94
|
+
delete config.targets.build.configurations.production.fileReplacements;
|
|
95
|
+
}
|
|
90
96
|
config.targets.build.options = Object.assign(Object.assign({}, config.targets.build.options), { assets: [
|
|
91
97
|
...config.targets.build.options.assets,
|
|
92
98
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-app/react-app.ts"],"names":[],"mappings":";;AAmGA,
|
|
1
|
+
{"version":3,"file":"react-app.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/react-app/react-app.ts"],"names":[],"mappings":";;AAmGA,4BAgFC;;AAnLD,wCAAyE;AACzE,uCAWoB;AACpB,uCAAoC;AACpC,6BAA6B;AAG7B,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,4BAAoB,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;CAAA;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,OAAyB;IACrD,MAAM,eAAe,iDAChB,OAAO,GACP,OAAO,CAAC,IAAI,K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,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { NgModule, APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
2
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
3
|
-
import "@abgov/web-components";
|
|
4
|
-
import { AngularComponentsModule } from '@abgov/angular-components';
|
|
5
|
-
|
|
6
|
-
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
|
|
7
|
-
import { AuthInterceptor } from './auth.interceptor';
|
|
8
|
-
import { FormsModule } from '@angular/forms';
|
|
9
|
-
import { AppRoutingModule } from './app.routes';
|
|
10
|
-
import { ProtectedComponent } from './protected/protected.component';
|
|
11
|
-
import { AuthCallbackComponent } from './auth-callback/auth-callback.component';
|
|
12
|
-
import { AuthGuardService } from './services/auth-guard.service';
|
|
13
|
-
import { AuthService } from './services/auth.service';
|
|
14
|
-
import { AppComponent } from './app.component';
|
|
15
|
-
import { Config } from '../environments/config';
|
|
16
|
-
|
|
17
|
-
@NgModule({
|
|
18
|
-
imports: [
|
|
19
|
-
AngularComponentsModule,
|
|
20
|
-
BrowserModule,
|
|
21
|
-
HttpClientModule,
|
|
22
|
-
FormsModule,
|
|
23
|
-
AppRoutingModule,
|
|
24
|
-
],
|
|
25
|
-
providers: [
|
|
26
|
-
AuthGuardService,
|
|
27
|
-
AuthService,
|
|
28
|
-
Config,
|
|
29
|
-
{
|
|
30
|
-
provide: APP_INITIALIZER,
|
|
31
|
-
useFactory: initializeApp,
|
|
32
|
-
deps: [Config],
|
|
33
|
-
multi: true,
|
|
34
|
-
},
|
|
35
|
-
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
|
|
36
|
-
],
|
|
37
|
-
declarations: [AppComponent, AuthCallbackComponent, ProtectedComponent],
|
|
38
|
-
bootstrap: [AppComponent],
|
|
39
|
-
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
40
|
-
})
|
|
41
|
-
export class AppModule {}
|
|
42
|
-
|
|
43
|
-
export function initializeApp(config: Config) {
|
|
44
|
-
return (): Promise<any> => {
|
|
45
|
-
return config.Init();
|
|
46
|
-
};
|
|
47
|
-
}
|
package/src/generators/angular-app/files/src/app/auth-callback/auth-callback.component.html__tmpl__
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<h3>Redirected to auth-callback route!</h3>
|
|
2
|
-
<p>Now you are logged in and allowed to access the "protected" route...</p>
|
|
3
|
-
<div class="info">
|
|
4
|
-
<div>
|
|
5
|
-
<div>Token Type:</div>
|
|
6
|
-
<div class="token">{{ tokenType }}</div>
|
|
7
|
-
</div>
|
|
8
|
-
<div>
|
|
9
|
-
<div>Token:</div>
|
|
10
|
-
<div class="token">{{ accessToken }}</div>
|
|
11
|
-
</div>
|
|
12
|
-
</div>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { AuthCallbackComponent } from './auth-callback.component';
|
|
3
|
-
import {
|
|
4
|
-
BrowserDynamicTestingModule,
|
|
5
|
-
platformBrowserDynamicTesting
|
|
6
|
-
} from "@angular/platform-browser-dynamic/testing";
|
|
7
|
-
|
|
8
|
-
describe('AuthCallbackComponent', () => {
|
|
9
|
-
let component: AuthCallbackComponent;
|
|
10
|
-
let fixture: ComponentFixture<AuthCallbackComponent>;
|
|
11
|
-
let envData = {"production":false,"access":{"url":"https://testurl.com","realm":"123","client_id":"urn:ads:platform:tenant-admin-app"},"tenantApi":{"host":"http://localhost:3333","endpoints":{"tenantNameByRealm":"/api/tenant/v1/realm"}}}
|
|
12
|
-
|
|
13
|
-
localStorage.setItem('envData', JSON.stringify(envData));
|
|
14
|
-
|
|
15
|
-
beforeEach((() => {
|
|
16
|
-
TestBed.initTestEnvironment(
|
|
17
|
-
BrowserDynamicTestingModule,
|
|
18
|
-
platformBrowserDynamicTesting()
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
TestBed.configureTestingModule({
|
|
22
|
-
declarations: [AuthCallbackComponent],
|
|
23
|
-
}).compileComponents();
|
|
24
|
-
|
|
25
|
-
fixture = TestBed.createComponent(AuthCallbackComponent);
|
|
26
|
-
component = fixture.componentInstance;
|
|
27
|
-
fixture.detectChanges();
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
it('should create', () => {
|
|
31
|
-
expect(component).toBeTruthy();
|
|
32
|
-
});
|
|
33
|
-
});
|