@abgov/nx-oc 5.1.0 → 5.2.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 +2 -1
- package/src/adsp/adsp-utils.d.ts +8 -0
- package/src/adsp/adsp-utils.js +102 -0
- package/src/adsp/adsp-utils.js.map +1 -0
- package/src/adsp/adsp.d.ts +10 -0
- package/src/adsp/environments.d.ts +7 -0
- package/src/adsp/environments.js +18 -0
- package/src/adsp/environments.js.map +1 -0
- package/src/adsp/index.d.ts +3 -0
- package/src/adsp/index.js +6 -0
- package/src/adsp/index.js.map +1 -0
- package/src/generators/deployment/deployment.js +38 -31
- package/src/generators/deployment/deployment.js.map +1 -1
- package/src/generators/deployment/deployment.spec.ts +26 -62
- package/src/generators/deployment/schema.d.ts +8 -4
- package/src/generators/deployment/schema.json +35 -5
- package/src/index.d.ts +1 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/nx-oc",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"description": "Government of Alberta - Nx plugin for OpenShift.",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"executors": "./executors.json",
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@nrwl/devkit": "^15.0.0",
|
|
16
|
+
"express": "4.18.1",
|
|
16
17
|
"jest-mock": "28.1.3"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tree } from '@nrwl/devkit';
|
|
2
|
+
import { AdspConfiguration, AdspOptions } from './adsp';
|
|
3
|
+
import { EnvironmentName } from './environments';
|
|
4
|
+
export declare function hasDependency(host: Tree, dependency: string): boolean;
|
|
5
|
+
export declare function getAdspConfiguration(_host: Tree, options: {
|
|
6
|
+
env: EnvironmentName;
|
|
7
|
+
}): Promise<AdspConfiguration>;
|
|
8
|
+
export declare function isAdspOptions(options: unknown): options is AdspOptions;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAdspOptions = exports.getAdspConfiguration = exports.hasDependency = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
const axios_1 = require("axios");
|
|
7
|
+
const enquirer_1 = require("enquirer");
|
|
8
|
+
const express = require("express");
|
|
9
|
+
const open = require("open");
|
|
10
|
+
const simple_oauth2_1 = require("simple-oauth2");
|
|
11
|
+
const environments_1 = require("./environments");
|
|
12
|
+
function hasDependency(host, dependency) {
|
|
13
|
+
const { dependencies, devDependencies } = (0, devkit_1.readJson)(host, 'package.json');
|
|
14
|
+
return !!(dependencies === null || dependencies === void 0 ? void 0 : dependencies[dependency]) || !!(devDependencies === null || devDependencies === void 0 ? void 0 : devDependencies[dependency]);
|
|
15
|
+
}
|
|
16
|
+
exports.hasDependency = hasDependency;
|
|
17
|
+
function realmLogin(accessServiceUrl, realm) {
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const client = new simple_oauth2_1.AuthorizationCode({
|
|
20
|
+
client: {
|
|
21
|
+
id: 'nx-adsp-cli',
|
|
22
|
+
secret: '',
|
|
23
|
+
},
|
|
24
|
+
auth: {
|
|
25
|
+
tokenHost: accessServiceUrl,
|
|
26
|
+
tokenPath: `/auth/realms/${realm}/protocol/openid-connect/token`,
|
|
27
|
+
authorizePath: `/auth/realms/${realm}/protocol/openid-connect/auth`,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const redirect_uri = 'http://localhost:3000/callback';
|
|
31
|
+
const authorizationUri = client.authorizeURL({
|
|
32
|
+
redirect_uri,
|
|
33
|
+
scope: 'email',
|
|
34
|
+
});
|
|
35
|
+
const app = express();
|
|
36
|
+
const tokenPromise = new Promise((resolve, reject) => {
|
|
37
|
+
app.get('/callback', function (req, res) {
|
|
38
|
+
const { code, error } = req.query;
|
|
39
|
+
if (error) {
|
|
40
|
+
res.send('Login failed.');
|
|
41
|
+
reject(new Error(`Error encountered during login. ${error}`));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
res.send('Successfully signed in. You can close this browser tab or window.');
|
|
45
|
+
resolve(client.getToken({
|
|
46
|
+
code: code,
|
|
47
|
+
redirect_uri,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
const server = app.listen(3000);
|
|
53
|
+
open(authorizationUri);
|
|
54
|
+
const { token } = yield Promise.race([
|
|
55
|
+
tokenPromise,
|
|
56
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Timed out waiting for login.')), 120000)),
|
|
57
|
+
]).finally(() => server.close());
|
|
58
|
+
return token['access_token'];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function getAdspConfiguration(_host, options) {
|
|
62
|
+
var _a;
|
|
63
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const { env } = options;
|
|
65
|
+
const environment = environments_1.environments[env || 'prod'];
|
|
66
|
+
if (isAdspOptions(options)) {
|
|
67
|
+
// If Adsp configuration is already been resolved, then no need to retrieve gain.
|
|
68
|
+
return options.adsp;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const { data: entries } = yield axios_1.default.get(new URL('/directory/v2/namespaces/platform/entries', environment.directoryServiceUrl).href, { decompress: true, responseEncoding: 'utf8', responseType: 'json' });
|
|
72
|
+
const urls = entries.reduce((values, item) => (Object.assign(Object.assign({}, values), { [item.urn]: item.url })), {});
|
|
73
|
+
const token = yield realmLogin(environment.accessServiceUrl, 'core');
|
|
74
|
+
const tenantServiceUrl = urls['urn:ads:platform:tenant-service:v2'];
|
|
75
|
+
const { data: tenants } = yield axios_1.default.get(new URL('v2/tenants', tenantServiceUrl).href, {
|
|
76
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
77
|
+
});
|
|
78
|
+
const choices = tenants.results
|
|
79
|
+
.map((r) => r.name)
|
|
80
|
+
.sort((a, b) => a.localeCompare(b));
|
|
81
|
+
const result = yield (0, enquirer_1.prompt)({
|
|
82
|
+
type: 'autocomplete',
|
|
83
|
+
name: 'tenant',
|
|
84
|
+
message: 'Which tenant is the application or service for?',
|
|
85
|
+
choices,
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
tenant: (0, devkit_1.names)(result.tenant).fileName,
|
|
89
|
+
tenantRealm: ((_a = tenants.results.find((r) => r.name === result.tenant)) === null || _a === void 0 ? void 0 : _a.realm) || '',
|
|
90
|
+
accessServiceUrl: environment.accessServiceUrl,
|
|
91
|
+
directoryServiceUrl: environment.directoryServiceUrl,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.getAdspConfiguration = getAdspConfiguration;
|
|
97
|
+
function isAdspOptions(options) {
|
|
98
|
+
var _a;
|
|
99
|
+
return !!((_a = options === null || options === void 0 ? void 0 : options.adsp) === null || _a === void 0 ? void 0 : _a.tenantRealm);
|
|
100
|
+
}
|
|
101
|
+
exports.isAdspOptions = isAdspOptions;
|
|
102
|
+
//# sourceMappingURL=adsp-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adsp-utils.js","sourceRoot":"","sources":["../../../../../packages/nx-oc/src/adsp/adsp-utils.ts"],"names":[],"mappings":";;;;AAAA,yCAAqD;AACrD,iCAA0B;AAC1B,uCAAkC;AAClC,mCAAmC;AACnC,6BAA6B;AAC7B,iDAA+D;AAE/D,iDAA+D;AAO/D,SAAgB,aAAa,CAAC,IAAU,EAAE,UAAkB;IAC1D,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,GAAY,IAAA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AAgB;;IAC5C,OAAO,CAAC,CAAC,CAAA,MAAC,OAAuB,aAAvB,OAAO,uBAAP,OAAO,CAAkB,IAAI,0CAAE,WAAW,CAAA,CAAC;AACvD,CAAC;AAFD,sCAEC"}
|
|
@@ -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-oc/src/adsp/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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/nx-oc/src/adsp/index.ts"],"names":[],"mappings":";;;AACA,uDAA6B;AAC7B,yDAA+B"}
|
|
@@ -6,40 +6,47 @@ const path = require("path");
|
|
|
6
6
|
const yaml = require("yaml");
|
|
7
7
|
const pipeline_envs_1 = require("../../pipeline-envs");
|
|
8
8
|
const git_utils_1 = require("../../utils/git-utils");
|
|
9
|
+
const adsp_1 = require("../../adsp");
|
|
9
10
|
const infraManifestFile = '.openshift/environments.yml';
|
|
10
11
|
function normalizeOptions(host, options) {
|
|
11
12
|
var _a, _b, _c, _d;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
const projectName = (0, devkit_1.names)(options.project).fileName;
|
|
15
|
+
const result = host.read(infraManifestFile).toString();
|
|
16
|
+
const { items } = yaml.parse(result);
|
|
17
|
+
const ocInfraProject = ((_b = (_a = items[0]) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.namespace) || '';
|
|
18
|
+
const SA_PREFIX = 'system:serviceaccounts:';
|
|
19
|
+
const ocEnvProjects = (_d = (_c = items[0]) === null || _c === void 0 ? void 0 : _c.subjects) === null || _d === void 0 ? void 0 : _d.filter((s) => s.kind === 'Group' && s.name.startsWith(SA_PREFIX)).map((s) => s.name.replace(SA_PREFIX, ''));
|
|
20
|
+
// TODO: Find a better way to determine this.
|
|
21
|
+
const config = (0, devkit_1.readProjectConfiguration)(host, projectName);
|
|
22
|
+
let appType = options.appType;
|
|
23
|
+
if (!appType) {
|
|
24
|
+
switch (config.targets.build.executor) {
|
|
25
|
+
case '@nrwl/web:webpack':
|
|
26
|
+
case '@angular-devkit/build-angular:browser':
|
|
27
|
+
appType = 'frontend';
|
|
28
|
+
break;
|
|
29
|
+
case '@nrwl/node:build':
|
|
30
|
+
appType = 'node';
|
|
31
|
+
break;
|
|
32
|
+
case '@nx-dotnet/core:build':
|
|
33
|
+
appType = 'dotnet';
|
|
34
|
+
break;
|
|
35
|
+
case '@nrwl/webpack:webpack': {
|
|
36
|
+
// More recent version of NX switched to use a generic webpack executor for builds.
|
|
37
|
+
appType =
|
|
38
|
+
config.targets.build.options.target === 'node' ? 'node' : 'frontend';
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
const adsp = options.adsp || (yield (0, adsp_1.getAdspConfiguration)(host, options));
|
|
44
|
+
return Object.assign(Object.assign({}, options), { appType,
|
|
45
|
+
adsp,
|
|
46
|
+
projectName,
|
|
47
|
+
ocInfraProject,
|
|
48
|
+
ocEnvProjects });
|
|
49
|
+
});
|
|
43
50
|
}
|
|
44
51
|
function addFiles(host, options) {
|
|
45
52
|
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), options.adsp), { sourceRepositoryUrl: (0, git_utils_1.getGitRemoteUrl)(), tmpl: '' });
|
|
@@ -56,7 +63,7 @@ function default_1(host, options) {
|
|
|
56
63
|
console.log(`Cannot generate deployment; run 'nx g @abgov/nx-oc:workspace' first.`);
|
|
57
64
|
return;
|
|
58
65
|
}
|
|
59
|
-
const normalizedOptions = normalizeOptions(host, options);
|
|
66
|
+
const normalizedOptions = yield normalizeOptions(host, options);
|
|
60
67
|
if (!normalizedOptions.appType) {
|
|
61
68
|
console.log('Cannot generate deployment for unknown project type.');
|
|
62
69
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../../../../../../packages/nx-oc/src/generators/deployment/deployment.ts"],"names":[],"mappings":";;;AAAA,yCAOsB;AACtB,6BAA6B;AAC7B,6BAA6B;AAC7B,uDAA2D;AAC3D,qDAAwD;
|
|
1
|
+
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../../../../../../packages/nx-oc/src/generators/deployment/deployment.ts"],"names":[],"mappings":";;;AAAA,yCAOsB;AACtB,6BAA6B;AAC7B,6BAA6B;AAC7B,uDAA2D;AAC3D,qDAAwD;AAExD,qCAAkD;AAElD,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AAExD,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;;QAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;QAEpD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,CAAC;QACvD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,cAAc,GAAG,CAAA,MAAA,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,QAAQ,0CAAE,SAAS,KAAI,EAAE,CAAC;QAE3D,MAAM,SAAS,GAAG,yBAAyB,CAAC;QAC5C,MAAM,aAAa,GAAG,MAAA,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,QAAQ,0CACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EACjE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;QAE7C,6CAA6C;QAC7C,MAAM,MAAM,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC3D,IAAI,OAAO,GAAoB,OAAO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QAC/D,IAAI,MAAM,CAAC,WAAW,KAAK,aAAa,EAAE;YACxC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;YACvD,OAAO;SACR;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;YACnC,OAAO,CAAC,GAAG,CACT,sEAAsE,CACvE,CAAC;YACF,OAAO;SACR;QAED,MAAM,iBAAiB,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE;YAC9B,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;YACpE,OAAO;SACR;QAED,MAAM,CAAC,OAAO,mCACT,MAAM,CAAC,OAAO,KACjB,YAAY,EAAE;gBACZ,QAAQ,EAAE,oBAAoB;gBAC9B,OAAO,EAAE;oBACP,SAAS,EAAE,iBAAiB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;;wBAAC,OAAA,CAAC;4BAC9D,OAAO;4BACP,GAAG,EAAE,MAAA,4BAAI,CAAC,CAAC,CAAC,0CAAE,WAAW,EAAE;yBAC5B,CAAC,CAAA;qBAAA,CAAC;iBACJ;aACF,GACF,CAAC;QAEF,IAAA,mCAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAE1D,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAClC,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AArCD,4BAqCC"}
|
|
@@ -3,15 +3,33 @@ import {
|
|
|
3
3
|
readProjectConfiguration,
|
|
4
4
|
} from '@nrwl/devkit';
|
|
5
5
|
import { createTreeWithEmptyV1Workspace } from '@nrwl/devkit/testing';
|
|
6
|
+
|
|
7
|
+
import * as utils from '../../adsp';
|
|
8
|
+
import { environments } from '../../adsp';
|
|
6
9
|
import pipeline from '../pipeline/pipeline';
|
|
7
10
|
import { Schema } from './schema';
|
|
8
11
|
import generator from './deployment';
|
|
12
|
+
|
|
13
|
+
jest.mock('../../adsp');
|
|
14
|
+
const utilsMock = utils as jest.Mocked<typeof utils>;
|
|
15
|
+
utilsMock.getAdspConfiguration.mockResolvedValue({
|
|
16
|
+
tenant: 'test',
|
|
17
|
+
tenantRealm: 'test',
|
|
18
|
+
accessServiceUrl: environments.test.accessServiceUrl,
|
|
19
|
+
directoryServiceUrl: environments.test.directoryServiceUrl,
|
|
20
|
+
});
|
|
21
|
+
|
|
9
22
|
describe('Deployment Generator', () => {
|
|
10
|
-
const options: Schema
|
|
23
|
+
const options: Schema = {
|
|
11
24
|
project: 'test',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
env: 'development',
|
|
26
|
+
appType: 'frontend',
|
|
27
|
+
adsp: {
|
|
28
|
+
tenant: 'test',
|
|
29
|
+
tenantRealm: 'test',
|
|
30
|
+
accessServiceUrl: 'https://access-uat.alberta.ca',
|
|
31
|
+
directoryServiceUrl: 'https://directory',
|
|
32
|
+
},
|
|
15
33
|
};
|
|
16
34
|
|
|
17
35
|
it('can run', async () => {
|
|
@@ -45,33 +63,6 @@ describe('Deployment Generator', () => {
|
|
|
45
63
|
);
|
|
46
64
|
});
|
|
47
65
|
|
|
48
|
-
it('can generate deployment for react from nx pre 13.8', async () => {
|
|
49
|
-
const host = createTreeWithEmptyV1Workspace();
|
|
50
|
-
await pipeline(host, {
|
|
51
|
-
pipeline: 'test',
|
|
52
|
-
type: 'jenkins',
|
|
53
|
-
infra: 'test-infra',
|
|
54
|
-
envs: 'test-dev',
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
addProjectConfiguration(host, 'test', {
|
|
58
|
-
root: 'apps/test',
|
|
59
|
-
projectType: 'application',
|
|
60
|
-
targets: {
|
|
61
|
-
build: {
|
|
62
|
-
executor: '@nrwl/web:webpack',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
await generator(host, options);
|
|
68
|
-
expect(host.exists('.openshift/test/test.yml')).toBeTruthy();
|
|
69
|
-
expect(host.exists('.openshift/test/Dockerfile')).toBeTruthy();
|
|
70
|
-
|
|
71
|
-
const dockerfile = host.read('.openshift/test/Dockerfile').toString();
|
|
72
|
-
expect(dockerfile).toContain('nginx');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
66
|
it('can generate deployment for react', async () => {
|
|
76
67
|
const host = createTreeWithEmptyV1Workspace();
|
|
77
68
|
await pipeline(host, {
|
|
@@ -88,7 +79,7 @@ describe('Deployment Generator', () => {
|
|
|
88
79
|
build: {
|
|
89
80
|
executor: '@nrwl/webpack:webpack',
|
|
90
81
|
options: {
|
|
91
|
-
compiler: 'babel'
|
|
82
|
+
compiler: 'babel',
|
|
92
83
|
},
|
|
93
84
|
},
|
|
94
85
|
},
|
|
@@ -129,33 +120,6 @@ describe('Deployment Generator', () => {
|
|
|
129
120
|
expect(dockerfile).toContain('nginx');
|
|
130
121
|
});
|
|
131
122
|
|
|
132
|
-
it('can generate deployment for node from nx pre 13.8', async () => {
|
|
133
|
-
const host = createTreeWithEmptyV1Workspace();
|
|
134
|
-
await pipeline(host, {
|
|
135
|
-
pipeline: 'test',
|
|
136
|
-
type: 'jenkins',
|
|
137
|
-
infra: 'test-infra',
|
|
138
|
-
envs: 'test-dev',
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
addProjectConfiguration(host, 'test', {
|
|
142
|
-
root: 'apps/test',
|
|
143
|
-
projectType: 'application',
|
|
144
|
-
targets: {
|
|
145
|
-
build: {
|
|
146
|
-
executor: '@nrwl/node:build',
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
await generator(host, options);
|
|
152
|
-
expect(host.exists('.openshift/test/test.yml')).toBeTruthy();
|
|
153
|
-
expect(host.exists('.openshift/test/Dockerfile')).toBeTruthy();
|
|
154
|
-
|
|
155
|
-
const dockerfile = host.read('.openshift/test/Dockerfile').toString();
|
|
156
|
-
expect(dockerfile).toContain('node');
|
|
157
|
-
});
|
|
158
|
-
|
|
159
123
|
it('can generate deployment for node', async () => {
|
|
160
124
|
const host = createTreeWithEmptyV1Workspace();
|
|
161
125
|
await pipeline(host, {
|
|
@@ -179,7 +143,7 @@ describe('Deployment Generator', () => {
|
|
|
179
143
|
},
|
|
180
144
|
});
|
|
181
145
|
|
|
182
|
-
await generator(host, options);
|
|
146
|
+
await generator(host, { ...options, appType: 'node' });
|
|
183
147
|
expect(host.exists('.openshift/test/test.yml')).toBeTruthy();
|
|
184
148
|
expect(host.exists('.openshift/test/Dockerfile')).toBeTruthy();
|
|
185
149
|
|
|
@@ -206,7 +170,7 @@ describe('Deployment Generator', () => {
|
|
|
206
170
|
},
|
|
207
171
|
});
|
|
208
172
|
|
|
209
|
-
await generator(host, options);
|
|
173
|
+
await generator(host, { ...options, appType: 'dotnet' });
|
|
210
174
|
expect(host.exists('.openshift/test/test.yml')).toBeTruthy();
|
|
211
175
|
expect(host.exists('.openshift/test/Dockerfile')).toBeTruthy();
|
|
212
176
|
|
|
@@ -233,7 +197,7 @@ describe('Deployment Generator', () => {
|
|
|
233
197
|
},
|
|
234
198
|
});
|
|
235
199
|
|
|
236
|
-
await generator(host, options);
|
|
200
|
+
await generator(host, { ...options, appType: null });
|
|
237
201
|
expect(host.exists('.openshift/test/test.yml')).toBeFalsy();
|
|
238
202
|
expect(host.exists('.openshift/test/Dockerfile')).toBeFalsy();
|
|
239
203
|
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { AdspConfiguration } from '../../adsp';
|
|
2
|
+
|
|
3
|
+
export type ApplicationType = 'node' | 'dotnet' | 'frontend';
|
|
4
|
+
|
|
1
5
|
export interface Schema {
|
|
2
6
|
project: string;
|
|
3
|
-
|
|
7
|
+
appType?: ApplicationType;
|
|
8
|
+
env: EnvironmentName;
|
|
9
|
+
adsp?: AdspConfiguration;
|
|
4
10
|
}
|
|
5
11
|
|
|
6
|
-
export type ApplicationType = 'node' | 'dotnet' | 'frontend';
|
|
7
|
-
|
|
8
12
|
export interface NormalizedSchema extends Schema {
|
|
9
13
|
projectName: string;
|
|
10
14
|
appType: ApplicationType;
|
|
11
15
|
ocInfraProject: string;
|
|
12
16
|
ocEnvProjects: string[];
|
|
13
|
-
adsp
|
|
17
|
+
adsp: AdspConfiguration;
|
|
14
18
|
}
|
|
@@ -14,16 +14,46 @@
|
|
|
14
14
|
},
|
|
15
15
|
"x-prompt": "Which project to add deployment for?"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
17
|
+
"appType": {
|
|
18
18
|
"type": "string",
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "Type of application.",
|
|
20
20
|
"$default": {
|
|
21
21
|
"$source": "argv",
|
|
22
22
|
"index": 1
|
|
23
23
|
},
|
|
24
24
|
"alias": "t",
|
|
25
|
-
"x-prompt":
|
|
25
|
+
"x-prompt": {
|
|
26
|
+
"message": "What type of application is the project?",
|
|
27
|
+
"type": "list",
|
|
28
|
+
"items": [
|
|
29
|
+
"frontend",
|
|
30
|
+
"dotnet",
|
|
31
|
+
"node"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"env": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Environment to target.",
|
|
38
|
+
"$default": {
|
|
39
|
+
"$source": "argv",
|
|
40
|
+
"index": 2
|
|
41
|
+
},
|
|
42
|
+
"alias": "e",
|
|
43
|
+
"x-prompt": {
|
|
44
|
+
"message": "Which ADSP environment do you want to target?",
|
|
45
|
+
"type": "list",
|
|
46
|
+
"items": [
|
|
47
|
+
"dev",
|
|
48
|
+
"test",
|
|
49
|
+
"prod"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
26
52
|
}
|
|
27
53
|
},
|
|
28
|
-
"required": [
|
|
29
|
-
|
|
54
|
+
"required": [
|
|
55
|
+
"project",
|
|
56
|
+
"appType",
|
|
57
|
+
"env"
|
|
58
|
+
]
|
|
59
|
+
}
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deploymentGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
var deployment_1 = require("./generators/deployment/deployment");
|
|
5
6
|
Object.defineProperty(exports, "deploymentGenerator", { enumerable: true, get: function () { return deployment_1.default; } });
|
|
7
|
+
tslib_1.__exportStar(require("./adsp"), exports);
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nx-oc/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nx-oc/src/index.ts"],"names":[],"mappings":";;;;AAAA,iEAAoF;AAA3E,iHAAA,OAAO,OAAuB;AACvC,iDAAuB"}
|