@axinom/mosaic-cli 0.19.0-rc.5 → 0.19.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/dist/commands/hosting/index.js +4 -67
- package/dist/commands/hosting/index.js.map +1 -1
- package/dist/commands/hosting/manifest/manifest-commands.d.ts +2 -0
- package/dist/commands/hosting/manifest/manifest-commands.js +65 -0
- package/dist/commands/hosting/manifest/manifest-commands.js.map +1 -0
- package/dist/commands/hosting/manifest/upload-manifest-options.d.ts +12 -0
- package/dist/commands/hosting/manifest/upload-manifest-options.js +3 -0
- package/dist/commands/hosting/manifest/upload-manifest-options.js.map +1 -0
- package/dist/commands/hosting/manifest/upload-manifest.d.ts +10 -0
- package/dist/commands/hosting/manifest/upload-manifest.js +144 -0
- package/dist/commands/hosting/manifest/upload-manifest.js.map +1 -0
- package/dist/commands/hosting/pilet/pilet-commands.d.ts +2 -0
- package/dist/commands/hosting/pilet/pilet-commands.js +70 -0
- package/dist/commands/hosting/pilet/pilet-commands.js.map +1 -0
- package/dist/commands/hosting/pilet/register-pilet-options.js.map +1 -0
- package/dist/commands/hosting/{register-pilet.js → pilet/register-pilet.js} +6 -6
- package/dist/commands/hosting/pilet/register-pilet.js.map +1 -0
- package/package.json +5 -4
- package/src/commands/hosting/index.ts +7 -73
- package/src/commands/hosting/manifest/manifest-commands.ts +68 -0
- package/src/commands/hosting/manifest/upload-manifest-options.ts +12 -0
- package/src/commands/hosting/manifest/upload-manifest.ts +179 -0
- package/src/commands/hosting/pilet/pilet-commands.ts +74 -0
- package/src/commands/hosting/{register-pilet.ts → pilet/register-pilet.ts} +6 -6
- package/dist/commands/hosting/register-pilet-options.js.map +0 -1
- package/dist/commands/hosting/register-pilet.js.map +0 -1
- /package/dist/commands/hosting/{register-pilet-options.d.ts → pilet/register-pilet-options.d.ts} +0 -0
- /package/dist/commands/hosting/{register-pilet-options.js → pilet/register-pilet-options.js} +0 -0
- /package/dist/commands/hosting/{register-pilet.d.ts → pilet/register-pilet.d.ts} +0 -0
- /package/src/commands/hosting/{register-pilet-options.ts → pilet/register-pilet-options.ts} +0 -0
|
@@ -1,80 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hosting = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const manifest_commands_1 = require("./manifest/manifest-commands");
|
|
5
|
+
const pilet_commands_1 = require("./pilet/pilet-commands");
|
|
6
6
|
exports.hosting = {
|
|
7
7
|
command: 'hosting',
|
|
8
8
|
describe: 'Commands related to Mosaic Hosting.',
|
|
9
9
|
builder: (yargs) => yargs
|
|
10
|
-
.command('pilet', 'Pilet related actions', piletCommands)
|
|
10
|
+
.command('pilet', 'Pilet related actions', pilet_commands_1.piletCommands)
|
|
11
|
+
.command('manifest', 'Deployment Manifest related actions', manifest_commands_1.manifestCommands)
|
|
11
12
|
.demandCommand(),
|
|
12
13
|
handler: (_args) => {
|
|
13
14
|
console.log('Please pick a sub command related to hosting.');
|
|
14
15
|
},
|
|
15
16
|
};
|
|
16
|
-
const piletCommands = {
|
|
17
|
-
builder: (yargs) => yargs
|
|
18
|
-
.command('register', 'Register a pilet in Mosaic Micro-Frontend Service.', piletRegister)
|
|
19
|
-
.demandCommand(),
|
|
20
|
-
handler: () => {
|
|
21
|
-
console.log('Please pick an action related to hosting pilet command.');
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
const piletRegister = {
|
|
25
|
-
builder: (yargs) => {
|
|
26
|
-
return yargs
|
|
27
|
-
.option('serviceId', {
|
|
28
|
-
describe: 'Service ID the pilet should be registered to',
|
|
29
|
-
alias: 'i',
|
|
30
|
-
string: true,
|
|
31
|
-
})
|
|
32
|
-
.option('mosaicHostingClientId', {
|
|
33
|
-
describe: 'Client ID to authenticate',
|
|
34
|
-
alias: 'c',
|
|
35
|
-
string: true,
|
|
36
|
-
})
|
|
37
|
-
.option('mosaicHostingClientSecret', {
|
|
38
|
-
describe: 'Client Secret to authenticate',
|
|
39
|
-
alias: 's',
|
|
40
|
-
string: true,
|
|
41
|
-
})
|
|
42
|
-
.option('tenantId', {
|
|
43
|
-
describe: 'Tenant ID',
|
|
44
|
-
alias: 't',
|
|
45
|
-
string: true,
|
|
46
|
-
})
|
|
47
|
-
.option('environmentId', {
|
|
48
|
-
describe: 'Environment ID',
|
|
49
|
-
alias: 'e',
|
|
50
|
-
string: true,
|
|
51
|
-
})
|
|
52
|
-
.option('piletArtifactPath', {
|
|
53
|
-
describe: 'Pilet Artifact Path',
|
|
54
|
-
alias: 'p',
|
|
55
|
-
string: true,
|
|
56
|
-
})
|
|
57
|
-
.option('idServiceAuthBaseURL', {
|
|
58
|
-
describe: 'ID Service Authentication Endpoint Base URL',
|
|
59
|
-
alias: 'a',
|
|
60
|
-
string: true,
|
|
61
|
-
})
|
|
62
|
-
.option('microFrontendServiceBaseURL', {
|
|
63
|
-
describe: 'Micro Frontend Service Base URL',
|
|
64
|
-
alias: 'm',
|
|
65
|
-
string: true,
|
|
66
|
-
})
|
|
67
|
-
.option('overrideRegistration', {
|
|
68
|
-
describe: 'Override registration',
|
|
69
|
-
alias: 'm',
|
|
70
|
-
default: false,
|
|
71
|
-
boolean: true,
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
handler: (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
-
// Validate arguments and read any arguments that are coming from environment variables.
|
|
76
|
-
const validatedArgs = (0, register_pilet_1.validateArgs)(args);
|
|
77
|
-
yield (0, register_pilet_1.registerPilet)(validatedArgs);
|
|
78
|
-
}),
|
|
79
|
-
};
|
|
80
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/hosting/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/hosting/index.ts"],"names":[],"mappings":";;;AACA,oEAAgE;AAChE,2DAAuD;AAE1C,QAAA,OAAO,GAAoC;IACtD,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,qCAAqC;IAC/C,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,OAAO,CAAC,OAAO,EAAE,uBAAuB,EAAE,8BAAa,CAAC;SACxD,OAAO,CACN,UAAU,EACV,qCAAqC,EACrC,oCAAgB,CACjB;SACA,aAAa,EAAE;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACjB,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;IAC/D,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.manifestCommands = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const upload_manifest_1 = require("./upload-manifest");
|
|
6
|
+
exports.manifestCommands = {
|
|
7
|
+
builder: (yargs) => yargs
|
|
8
|
+
.command('upload', 'Upload a Deployment Manifest against a Service ID to the Hosting Service.', manifestUpload)
|
|
9
|
+
.demandCommand(),
|
|
10
|
+
handler: () => {
|
|
11
|
+
console.log('Please pick an action related to hosting manifest command.');
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
const manifestUpload = {
|
|
15
|
+
builder: (yargs) => {
|
|
16
|
+
return yargs
|
|
17
|
+
.option('name', {
|
|
18
|
+
describe: 'Name of the Deployment Manifest',
|
|
19
|
+
alias: 'n',
|
|
20
|
+
string: true,
|
|
21
|
+
demandOption: true,
|
|
22
|
+
})
|
|
23
|
+
.option('serviceId', {
|
|
24
|
+
describe: 'Service ID the Deployment Manifest should be registered to',
|
|
25
|
+
alias: 'i',
|
|
26
|
+
string: true,
|
|
27
|
+
})
|
|
28
|
+
.option('mosaicHostingClientId', {
|
|
29
|
+
describe: 'Service Account Client ID to authenticate',
|
|
30
|
+
alias: 'c',
|
|
31
|
+
string: true,
|
|
32
|
+
})
|
|
33
|
+
.option('mosaicHostingClientSecret', {
|
|
34
|
+
describe: 'Service Account Client Secret to authenticate',
|
|
35
|
+
alias: 's',
|
|
36
|
+
string: true,
|
|
37
|
+
})
|
|
38
|
+
.option('deploymentManifestPath', {
|
|
39
|
+
describe: 'Deployment Manifest Path',
|
|
40
|
+
alias: 'p',
|
|
41
|
+
string: true,
|
|
42
|
+
default: './mosaic-hosting-deployment-manifest.yaml',
|
|
43
|
+
})
|
|
44
|
+
.option('idServiceAuthBaseURL', {
|
|
45
|
+
describe: 'ID Service Authentication Endpoint Base URL',
|
|
46
|
+
alias: 'a',
|
|
47
|
+
string: true,
|
|
48
|
+
})
|
|
49
|
+
.option('hostingServiceBaseURL', {
|
|
50
|
+
describe: 'Hosting Service Base URL',
|
|
51
|
+
alias: 'h',
|
|
52
|
+
string: true,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
handler: (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
const [validatedArgs, errorMessages] = (0, upload_manifest_1.validateArgs)(args);
|
|
57
|
+
if (errorMessages.length > 0) {
|
|
58
|
+
console.log(errorMessages);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
yield (0, upload_manifest_1.uploadDeploymentManifest)(validatedArgs);
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=manifest-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-commands.js","sourceRoot":"","sources":["../../../../src/commands/hosting/manifest/manifest-commands.ts"],"names":[],"mappings":";;;;AACA,uDAA2E;AAG9D,QAAA,gBAAgB,GAAoC;IAC/D,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,OAAO,CACN,QAAQ,EACR,2EAA2E,EAC3E,cAAc,CACf;SACA,aAAa,EAAE;IACpB,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,CAAC,EAAE;YAC5B,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;SAC5B;aAAM;YACL,MAAM,IAAA,0CAAwB,EAAC,aAAa,CAAC,CAAC;SAC/C;IACH,CAAC,CAAA;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for Upload Deployment Manifest
|
|
3
|
+
*/
|
|
4
|
+
export interface GetUploadManifestOptions {
|
|
5
|
+
name: string;
|
|
6
|
+
serviceId?: string;
|
|
7
|
+
mosaicHostingClientId?: string;
|
|
8
|
+
mosaicHostingClientSecret?: string;
|
|
9
|
+
deploymentManifestPath?: string;
|
|
10
|
+
idServiceAuthBaseURL?: string;
|
|
11
|
+
hostingServiceBaseURL?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-manifest-options.js","sourceRoot":"","sources":["../../../../src/commands/hosting/manifest/upload-manifest-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GetUploadManifestOptions } from './upload-manifest-options';
|
|
2
|
+
export declare const uploadDeploymentManifest: (args: Required<GetUploadManifestOptions>) => Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Method that validates the arguments.
|
|
5
|
+
* We're using this to allow both input arguments and environment variables.
|
|
6
|
+
*
|
|
7
|
+
* @param args
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const validateArgs: (args: GetUploadManifestOptions) => [Required<GetUploadManifestOptions>, string[]];
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateArgs = exports.uploadDeploymentManifest = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const mosaic_id_link_be_1 = require("@axinom/mosaic-id-link-be");
|
|
6
|
+
const mosaic_service_common_1 = require("@axinom/mosaic-service-common");
|
|
7
|
+
const axios_1 = require("axios");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const yaml = require("js-yaml");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const getAxiosInstance = (hostingServiceBaseUrl, serviceAccountToken) => {
|
|
12
|
+
return axios_1.default.create({
|
|
13
|
+
baseURL: new URL(hostingServiceBaseUrl).toString(),
|
|
14
|
+
headers: {
|
|
15
|
+
Authorization: `Bearer ${serviceAccountToken}`,
|
|
16
|
+
'content-type': 'application/json',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const uploadDeploymentManifest = (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b, _c, _d, _e;
|
|
22
|
+
const serviceAccountToken = yield (0, mosaic_id_link_be_1.getServiceAccountToken)(args.idServiceAuthBaseURL, args.mosaicHostingClientId, args.mosaicHostingClientSecret);
|
|
23
|
+
let manifestToUpload;
|
|
24
|
+
try {
|
|
25
|
+
manifestToUpload = findManifestToUpload(args.deploymentManifestPath);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.log(`Error occurred while trying to read the Deployment Manifest at ${args.deploymentManifestPath}.`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const axiosInstance = getAxiosInstance(args.hostingServiceBaseURL, serviceAccountToken.accessToken);
|
|
32
|
+
const data = JSON.stringify({
|
|
33
|
+
query: `mutation CreateServiceDeploymentManifest($serviceId: String!, $name: String, $configMap: DeploymentConfigMap!) {
|
|
34
|
+
createServiceDeploymentManifest(
|
|
35
|
+
input: {configMap: $configMap, name: $name, serviceId: $serviceId}
|
|
36
|
+
) {
|
|
37
|
+
serviceDeploymentManifest {
|
|
38
|
+
id
|
|
39
|
+
name
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}`,
|
|
43
|
+
variables: {
|
|
44
|
+
serviceId: args.serviceId,
|
|
45
|
+
name: args.name === '' ? undefined : args.name,
|
|
46
|
+
configMap: manifestToUpload,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
const response = yield axiosInstance.post('graphql', data);
|
|
51
|
+
if (response.data.errors !== undefined && response.data.errors.length > 0) {
|
|
52
|
+
console.log('Upload of Deployment Manifest failed.');
|
|
53
|
+
console.log(response.data.errors[0].message);
|
|
54
|
+
console.log();
|
|
55
|
+
if (((_b = (_a = response.data.errors[0].details) === null || _a === void 0 ? void 0 : _a.validateErrors) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
56
|
+
console.log('Schema Validation Errors:');
|
|
57
|
+
for (const detail of response.data.errors[0].details.validateErrors) {
|
|
58
|
+
console.log(detail);
|
|
59
|
+
}
|
|
60
|
+
console.log();
|
|
61
|
+
}
|
|
62
|
+
if (((_d = (_c = response.data.errors[0].details) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.length) > 0) {
|
|
63
|
+
console.log('Deployment Manifest Syntax Validation Errors:');
|
|
64
|
+
const validationErrors = [];
|
|
65
|
+
for (const detail of response.data.errors[0].details.validationErrors) {
|
|
66
|
+
validationErrors.push(detail);
|
|
67
|
+
}
|
|
68
|
+
console.log(validationErrors);
|
|
69
|
+
console.log();
|
|
70
|
+
}
|
|
71
|
+
console.log(`The Deployment Manifest Schema can be found at ${args.hostingServiceBaseURL}/.well-known.`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log('Upload of Deployment Manifest successful.');
|
|
75
|
+
console.log((_e = response.data.data) === null || _e === void 0 ? void 0 : _e.createServiceDeploymentManifest.serviceDeploymentManifest);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.log('Error while uploading the Deployment Manifest.');
|
|
80
|
+
console.log(JSON.stringify(error.message));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
exports.uploadDeploymentManifest = uploadDeploymentManifest;
|
|
84
|
+
/**
|
|
85
|
+
* Method that validates the arguments.
|
|
86
|
+
* We're using this to allow both input arguments and environment variables.
|
|
87
|
+
*
|
|
88
|
+
* @param args
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
const validateArgs = (args) => {
|
|
92
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
93
|
+
const errorMessages = [];
|
|
94
|
+
const idServiceAuthBaseURL = (_b = (_a = args.idServiceAuthBaseURL) !== null && _a !== void 0 ? _a : process.env.ID_SERVICE_AUTH_BASE_URL) !== null && _b !== void 0 ? _b : '';
|
|
95
|
+
const mosaicHostingClientId = (_d = (_c = args.mosaicHostingClientId) !== null && _c !== void 0 ? _c : process.env.MOSAIC_HOSTING_CLIENT_ID) !== null && _d !== void 0 ? _d : '';
|
|
96
|
+
const mosaicHostingClientSecret = (_f = (_e = args.mosaicHostingClientSecret) !== null && _e !== void 0 ? _e : process.env.MOSAIC_HOSTING_CLIENT_SECRET) !== null && _f !== void 0 ? _f : '';
|
|
97
|
+
const serviceId = (_h = (_g = args.serviceId) !== null && _g !== void 0 ? _g : process.env.SERVICE_ID) !== null && _h !== void 0 ? _h : '';
|
|
98
|
+
const hostingServiceBaseURL = (_k = (_j = args.hostingServiceBaseURL) !== null && _j !== void 0 ? _j : process.env.HOSTING_SERVICE_BASE_URL) !== null && _k !== void 0 ? _k : '';
|
|
99
|
+
if ((0, mosaic_service_common_1.isNullOrWhitespace)(idServiceAuthBaseURL)) {
|
|
100
|
+
errorMessages.push('[idServiceAuthBaseURL] is required.');
|
|
101
|
+
}
|
|
102
|
+
if ((0, mosaic_service_common_1.isNullOrWhitespace)(mosaicHostingClientId)) {
|
|
103
|
+
errorMessages.push('[clientId] is required.');
|
|
104
|
+
}
|
|
105
|
+
if ((0, mosaic_service_common_1.isNullOrWhitespace)(mosaicHostingClientSecret)) {
|
|
106
|
+
errorMessages.push('[clientSecret] is required.');
|
|
107
|
+
}
|
|
108
|
+
if ((0, mosaic_service_common_1.isNullOrWhitespace)(serviceId)) {
|
|
109
|
+
errorMessages.push('[serviceId] is required.');
|
|
110
|
+
}
|
|
111
|
+
if ((0, mosaic_service_common_1.isNullOrWhitespace)(hostingServiceBaseURL)) {
|
|
112
|
+
errorMessages.push('[hostingServiceBaseURL] is required.');
|
|
113
|
+
}
|
|
114
|
+
return [
|
|
115
|
+
{
|
|
116
|
+
name: args.name,
|
|
117
|
+
idServiceAuthBaseURL,
|
|
118
|
+
mosaicHostingClientId,
|
|
119
|
+
mosaicHostingClientSecret,
|
|
120
|
+
serviceId,
|
|
121
|
+
deploymentManifestPath: (_l = args.deploymentManifestPath) !== null && _l !== void 0 ? _l : './mosaic-hosting-deployment-manifest.yaml',
|
|
122
|
+
hostingServiceBaseURL,
|
|
123
|
+
},
|
|
124
|
+
errorMessages,
|
|
125
|
+
];
|
|
126
|
+
};
|
|
127
|
+
exports.validateArgs = validateArgs;
|
|
128
|
+
const findManifestToUpload = (deploymentManifestPath) => {
|
|
129
|
+
if (!(0, fs_1.existsSync)(deploymentManifestPath)) {
|
|
130
|
+
throw new Error(`No directory found at ${deploymentManifestPath}`);
|
|
131
|
+
}
|
|
132
|
+
const stat = (0, fs_1.lstatSync)(deploymentManifestPath);
|
|
133
|
+
let manifestFile;
|
|
134
|
+
if (stat.isDirectory()) {
|
|
135
|
+
manifestFile = path.join(deploymentManifestPath, 'mosaic-hosting-deployment-manifest.yaml');
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
manifestFile = deploymentManifestPath;
|
|
139
|
+
}
|
|
140
|
+
const doc = yaml.load((0, fs_1.readFileSync)(manifestFile, 'utf8'));
|
|
141
|
+
console.log(`Deployment Manifest found at ${manifestFile}.`);
|
|
142
|
+
return doc;
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=upload-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-manifest.js","sourceRoot":"","sources":["../../../../src/commands/hosting/manifest/upload-manifest.ts"],"names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vC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,iBAAY,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,gCAAgC,YAAY,GAAG,CAAC,CAAC;IAE7D,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.piletCommands = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const register_pilet_1 = require("./register-pilet");
|
|
6
|
+
exports.piletCommands = {
|
|
7
|
+
builder: (yargs) => yargs
|
|
8
|
+
.command('register', 'Register a pilet in Mosaic Micro Frontend Service.', piletRegister)
|
|
9
|
+
.demandCommand(),
|
|
10
|
+
handler: () => {
|
|
11
|
+
console.log('Please pick an action related to hosting pilet command.');
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
const piletRegister = {
|
|
15
|
+
builder: (yargs) => {
|
|
16
|
+
return yargs
|
|
17
|
+
.option('serviceId', {
|
|
18
|
+
describe: 'Service ID the pilet should be registered to',
|
|
19
|
+
alias: 'i',
|
|
20
|
+
string: true,
|
|
21
|
+
})
|
|
22
|
+
.option('mosaicHostingClientId', {
|
|
23
|
+
describe: 'Client ID to authenticate',
|
|
24
|
+
alias: 'c',
|
|
25
|
+
string: true,
|
|
26
|
+
})
|
|
27
|
+
.option('mosaicHostingClientSecret', {
|
|
28
|
+
describe: 'Client Secret to authenticate',
|
|
29
|
+
alias: 's',
|
|
30
|
+
string: true,
|
|
31
|
+
})
|
|
32
|
+
.option('tenantId', {
|
|
33
|
+
describe: 'Tenant ID',
|
|
34
|
+
alias: 't',
|
|
35
|
+
string: true,
|
|
36
|
+
})
|
|
37
|
+
.option('environmentId', {
|
|
38
|
+
describe: 'Environment ID',
|
|
39
|
+
alias: 'e',
|
|
40
|
+
string: true,
|
|
41
|
+
})
|
|
42
|
+
.option('piletArtifactPath', {
|
|
43
|
+
describe: 'Pilet Artifact Path',
|
|
44
|
+
alias: 'p',
|
|
45
|
+
string: true,
|
|
46
|
+
})
|
|
47
|
+
.option('idServiceAuthBaseURL', {
|
|
48
|
+
describe: 'ID Service Authentication Endpoint Base URL',
|
|
49
|
+
alias: 'a',
|
|
50
|
+
string: true,
|
|
51
|
+
})
|
|
52
|
+
.option('microFrontendServiceBaseURL', {
|
|
53
|
+
describe: 'Micro Frontend Service Base URL',
|
|
54
|
+
alias: 'm',
|
|
55
|
+
string: true,
|
|
56
|
+
})
|
|
57
|
+
.option('overrideRegistration', {
|
|
58
|
+
describe: 'Override registration',
|
|
59
|
+
alias: 'm',
|
|
60
|
+
default: false,
|
|
61
|
+
boolean: true,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
handler: (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
// Validate arguments and read any arguments that are coming from environment variables.
|
|
66
|
+
const validatedArgs = (0, register_pilet_1.validateArgs)(args);
|
|
67
|
+
yield (0, register_pilet_1.registerPilet)(validatedArgs);
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=pilet-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pilet-commands.js","sourceRoot":"","sources":["../../../../src/commands/hosting/pilet/pilet-commands.ts"],"names":[],"mappings":";;;;AACA,qDAA+D;AAGlD,QAAA,aAAa,GAAoC;IAC5D,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,OAAO,CACN,UAAU,EACV,oDAAoD,EACpD,aAAa,CACd;SACA,aAAa,EAAE;IACpB,OAAO,EAAE,GAAG,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;IACzE,CAAC;CACF,CAAC;AAEF,MAAM,aAAa,GAAoD;IACrE,OAAO,EAAE,CAAC,KAAK,EAAE,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zC,MAAM,IAAA,8BAAa,EAAC,aAAa,CAAC,CAAC;IACrC,CAAC,CAAA;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-pilet-options.js","sourceRoot":"","sources":["../../../../src/commands/hosting/pilet/register-pilet-options.ts"],"names":[],"mappings":""}
|
|
@@ -48,8 +48,8 @@ exports.registerPilet = registerPilet;
|
|
|
48
48
|
const validateArgs = (args) => {
|
|
49
49
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
50
50
|
const idServiceAuthBaseURL = (_a = args.idServiceAuthBaseURL) !== null && _a !== void 0 ? _a : process.env.ID_SERVICE_AUTH_BASE_URL;
|
|
51
|
-
const
|
|
52
|
-
const
|
|
51
|
+
const mosaicHostingClientId = (_b = args.mosaicHostingClientId) !== null && _b !== void 0 ? _b : process.env.MOSAIC_HOSTING_CLIENT_ID;
|
|
52
|
+
const mosaicHostingClientSecret = (_c = args.mosaicHostingClientSecret) !== null && _c !== void 0 ? _c : process.env.MOSAIC_HOSTING_CLIENT_SECRET;
|
|
53
53
|
const tenantId = (_d = args.tenantId) !== null && _d !== void 0 ? _d : process.env.TENANT_ID;
|
|
54
54
|
const environmentId = (_e = args.environmentId) !== null && _e !== void 0 ? _e : process.env.ENVIRONMENT_ID;
|
|
55
55
|
const serviceId = (_f = args.serviceId) !== null && _f !== void 0 ? _f : process.env.SERVICE_ID;
|
|
@@ -58,10 +58,10 @@ const validateArgs = (args) => {
|
|
|
58
58
|
if ((0, mosaic_service_common_1.isNullOrWhitespace)(idServiceAuthBaseURL)) {
|
|
59
59
|
throw new Error('idServiceAuthBaseURL is required.');
|
|
60
60
|
}
|
|
61
|
-
if ((0, mosaic_service_common_1.isNullOrWhitespace)(
|
|
61
|
+
if ((0, mosaic_service_common_1.isNullOrWhitespace)(mosaicHostingClientId)) {
|
|
62
62
|
throw new Error('clientId is required.');
|
|
63
63
|
}
|
|
64
|
-
if ((0, mosaic_service_common_1.isNullOrWhitespace)(
|
|
64
|
+
if ((0, mosaic_service_common_1.isNullOrWhitespace)(mosaicHostingClientSecret)) {
|
|
65
65
|
throw new Error('clientSecret is required.');
|
|
66
66
|
}
|
|
67
67
|
if ((0, mosaic_service_common_1.isNullOrWhitespace)(tenantId)) {
|
|
@@ -81,8 +81,8 @@ const validateArgs = (args) => {
|
|
|
81
81
|
}
|
|
82
82
|
return {
|
|
83
83
|
idServiceAuthBaseURL,
|
|
84
|
-
mosaicHostingClientId
|
|
85
|
-
mosaicHostingClientSecret
|
|
84
|
+
mosaicHostingClientId,
|
|
85
|
+
mosaicHostingClientSecret,
|
|
86
86
|
tenantId,
|
|
87
87
|
environmentId,
|
|
88
88
|
serviceId,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-pilet.js","sourceRoot":"","sources":["../../../../src/commands/hosting/pilet/register-pilet.ts"],"names":[],"mappings":";;;;AAAA,iEAAmE;AACnE,yEAAmE;AACnE,iCAA0C;AAC1C,sCAAsC;AACtC,2BAA0E;AAC1E,6BAA6B;AAGtB,MAAM,aAAa,GAAG,CAC3B,IAAuC,EACxB,EAAE;;IACjB,MAAM,mBAAmB,GAAG,MAAM,IAAA,0CAAsB,EACtD,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,yBAAyB,CAC/B,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;IAE5B,MAAM,MAAM,GAAG;QACb,aAAa,EAAE,QAAQ;QACvB,OAAO,kBACL,aAAa,EAAE,UAAU,mBAAmB,CAAC,WAAW,EAAE,IACvD,IAAI,CAAC,UAAU,EAAE,CACrB;KACF,CAAC;IAEF,IAAI;QACF,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACxE,IAAI,iBAAiB,EAAE;YACrB,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAA,qBAAgB,EAAC,iBAAi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ANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-cli",
|
|
3
|
-
"version": "0.19.0
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "The Axinom Mosaic CLI",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@asyncapi/diff": "^0.4.1",
|
|
34
34
|
"@asyncapi/modelina": "^1.8.4",
|
|
35
35
|
"@asyncapi/parser": "^2.0.2",
|
|
36
|
-
"@axinom/mosaic-id-link-be": "^0.13.3
|
|
37
|
-
"@axinom/mosaic-service-common": "^0.34.0
|
|
36
|
+
"@axinom/mosaic-id-link-be": "^0.13.3",
|
|
37
|
+
"@axinom/mosaic-service-common": "^0.34.0",
|
|
38
38
|
"@graphql-inspector/core": "^3.1.2",
|
|
39
39
|
"@stoplight/spectral": "^5.9.1",
|
|
40
40
|
"axios": "^0.19.2",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"glob": "^7.1.6",
|
|
49
49
|
"graphile-utils": "^4.13.0",
|
|
50
50
|
"graphql": "^15.4.0",
|
|
51
|
+
"js-yaml": "^4.1.0",
|
|
51
52
|
"json-schema": "^0.4.0",
|
|
52
53
|
"json-schema-diff": "^0.17.1",
|
|
53
54
|
"json-schema-ref-parser": "^9.0.7",
|
|
@@ -67,5 +68,5 @@
|
|
|
67
68
|
"publishConfig": {
|
|
68
69
|
"access": "public"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "4e4a3aa0d5a0efa7dc2da0e52fa5610d2a771498"
|
|
71
72
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandModule } from 'yargs';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { manifestCommands } from './manifest/manifest-commands';
|
|
3
|
+
import { piletCommands } from './pilet/pilet-commands';
|
|
4
4
|
|
|
5
5
|
export const hosting: CommandModule<unknown, unknown> = {
|
|
6
6
|
command: 'hosting',
|
|
@@ -8,79 +8,13 @@ export const hosting: CommandModule<unknown, unknown> = {
|
|
|
8
8
|
builder: (yargs) =>
|
|
9
9
|
yargs
|
|
10
10
|
.command('pilet', 'Pilet related actions', piletCommands)
|
|
11
|
-
.demandCommand(),
|
|
12
|
-
handler: (_args) => {
|
|
13
|
-
console.log('Please pick a sub command related to hosting.');
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const piletCommands: CommandModule<unknown, unknown> = {
|
|
18
|
-
builder: (yargs) =>
|
|
19
|
-
yargs
|
|
20
11
|
.command(
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
|
|
12
|
+
'manifest',
|
|
13
|
+
'Deployment Manifest related actions',
|
|
14
|
+
manifestCommands,
|
|
24
15
|
)
|
|
25
16
|
.demandCommand(),
|
|
26
|
-
handler: () => {
|
|
27
|
-
console.log('Please pick
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const piletRegister: CommandModule<unknown, GetRegisterPiletOptions> = {
|
|
32
|
-
builder: (yargs) => {
|
|
33
|
-
return yargs
|
|
34
|
-
.option('serviceId', {
|
|
35
|
-
describe: 'Service ID the pilet should be registered to',
|
|
36
|
-
alias: 'i',
|
|
37
|
-
string: true,
|
|
38
|
-
})
|
|
39
|
-
.option('mosaicHostingClientId', {
|
|
40
|
-
describe: 'Client ID to authenticate',
|
|
41
|
-
alias: 'c',
|
|
42
|
-
string: true,
|
|
43
|
-
})
|
|
44
|
-
.option('mosaicHostingClientSecret', {
|
|
45
|
-
describe: 'Client Secret to authenticate',
|
|
46
|
-
alias: 's',
|
|
47
|
-
string: true,
|
|
48
|
-
})
|
|
49
|
-
.option('tenantId', {
|
|
50
|
-
describe: 'Tenant ID',
|
|
51
|
-
alias: 't',
|
|
52
|
-
string: true,
|
|
53
|
-
})
|
|
54
|
-
.option('environmentId', {
|
|
55
|
-
describe: 'Environment ID',
|
|
56
|
-
alias: 'e',
|
|
57
|
-
string: true,
|
|
58
|
-
})
|
|
59
|
-
.option('piletArtifactPath', {
|
|
60
|
-
describe: 'Pilet Artifact Path',
|
|
61
|
-
alias: 'p',
|
|
62
|
-
string: true,
|
|
63
|
-
})
|
|
64
|
-
.option('idServiceAuthBaseURL', {
|
|
65
|
-
describe: 'ID Service Authentication Endpoint Base URL',
|
|
66
|
-
alias: 'a',
|
|
67
|
-
string: true,
|
|
68
|
-
})
|
|
69
|
-
.option('microFrontendServiceBaseURL', {
|
|
70
|
-
describe: 'Micro Frontend Service Base URL',
|
|
71
|
-
alias: 'm',
|
|
72
|
-
string: true,
|
|
73
|
-
})
|
|
74
|
-
.option('overrideRegistration', {
|
|
75
|
-
describe: 'Override registration',
|
|
76
|
-
alias: 'm',
|
|
77
|
-
default: false,
|
|
78
|
-
boolean: true,
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
handler: async (args) => {
|
|
82
|
-
// Validate arguments and read any arguments that are coming from environment variables.
|
|
83
|
-
const validatedArgs = validateArgs(args);
|
|
84
|
-
await registerPilet(validatedArgs);
|
|
17
|
+
handler: (_args) => {
|
|
18
|
+
console.log('Please pick a sub command related to hosting.');
|
|
85
19
|
},
|
|
86
20
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CommandModule } from 'yargs';
|
|
2
|
+
import { uploadDeploymentManifest, validateArgs } from './upload-manifest';
|
|
3
|
+
import { GetUploadManifestOptions } from './upload-manifest-options';
|
|
4
|
+
|
|
5
|
+
export const manifestCommands: CommandModule<unknown, unknown> = {
|
|
6
|
+
builder: (yargs) =>
|
|
7
|
+
yargs
|
|
8
|
+
.command(
|
|
9
|
+
'upload',
|
|
10
|
+
'Upload a Deployment Manifest against a Service ID to the Hosting Service.',
|
|
11
|
+
manifestUpload,
|
|
12
|
+
)
|
|
13
|
+
.demandCommand(),
|
|
14
|
+
handler: () => {
|
|
15
|
+
console.log('Please pick an action related to hosting manifest command.');
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const manifestUpload: CommandModule<unknown, GetUploadManifestOptions> = {
|
|
20
|
+
builder: (yargs) => {
|
|
21
|
+
return yargs
|
|
22
|
+
.option('name', {
|
|
23
|
+
describe: 'Name of the Deployment Manifest',
|
|
24
|
+
alias: 'n',
|
|
25
|
+
string: true,
|
|
26
|
+
demandOption: true,
|
|
27
|
+
})
|
|
28
|
+
.option('serviceId', {
|
|
29
|
+
describe: 'Service ID the Deployment Manifest should be registered to',
|
|
30
|
+
alias: 'i',
|
|
31
|
+
string: true,
|
|
32
|
+
})
|
|
33
|
+
.option('mosaicHostingClientId', {
|
|
34
|
+
describe: 'Service Account Client ID to authenticate',
|
|
35
|
+
alias: 'c',
|
|
36
|
+
string: true,
|
|
37
|
+
})
|
|
38
|
+
.option('mosaicHostingClientSecret', {
|
|
39
|
+
describe: 'Service Account Client Secret to authenticate',
|
|
40
|
+
alias: 's',
|
|
41
|
+
string: true,
|
|
42
|
+
})
|
|
43
|
+
.option('deploymentManifestPath', {
|
|
44
|
+
describe: 'Deployment Manifest Path',
|
|
45
|
+
alias: 'p',
|
|
46
|
+
string: true,
|
|
47
|
+
default: './mosaic-hosting-deployment-manifest.yaml',
|
|
48
|
+
})
|
|
49
|
+
.option('idServiceAuthBaseURL', {
|
|
50
|
+
describe: 'ID Service Authentication Endpoint Base URL',
|
|
51
|
+
alias: 'a',
|
|
52
|
+
string: true,
|
|
53
|
+
})
|
|
54
|
+
.option('hostingServiceBaseURL', {
|
|
55
|
+
describe: 'Hosting Service Base URL',
|
|
56
|
+
alias: 'h',
|
|
57
|
+
string: true,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
handler: async (args) => {
|
|
61
|
+
const [validatedArgs, errorMessages] = validateArgs(args);
|
|
62
|
+
if (errorMessages.length > 0) {
|
|
63
|
+
console.log(errorMessages);
|
|
64
|
+
} else {
|
|
65
|
+
await uploadDeploymentManifest(validatedArgs);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for Upload Deployment Manifest
|
|
3
|
+
*/
|
|
4
|
+
export interface GetUploadManifestOptions {
|
|
5
|
+
name: string;
|
|
6
|
+
serviceId?: string;
|
|
7
|
+
mosaicHostingClientId?: string;
|
|
8
|
+
mosaicHostingClientSecret?: string;
|
|
9
|
+
deploymentManifestPath?: string;
|
|
10
|
+
idServiceAuthBaseURL?: string;
|
|
11
|
+
hostingServiceBaseURL?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { getServiceAccountToken } from '@axinom/mosaic-id-link-be';
|
|
2
|
+
import { isNullOrWhitespace } from '@axinom/mosaic-service-common';
|
|
3
|
+
import axios, { AxiosError, AxiosInstance } from 'axios';
|
|
4
|
+
import { existsSync, lstatSync, readFileSync } from 'fs';
|
|
5
|
+
import * as yaml from 'js-yaml';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { GetUploadManifestOptions } from './upload-manifest-options';
|
|
8
|
+
|
|
9
|
+
const getAxiosInstance = (
|
|
10
|
+
hostingServiceBaseUrl: string,
|
|
11
|
+
serviceAccountToken: string,
|
|
12
|
+
): AxiosInstance => {
|
|
13
|
+
return axios.create({
|
|
14
|
+
baseURL: new URL(hostingServiceBaseUrl).toString(),
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${serviceAccountToken}`,
|
|
17
|
+
'content-type': 'application/json',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const uploadDeploymentManifest = async (
|
|
23
|
+
args: Required<GetUploadManifestOptions>,
|
|
24
|
+
): Promise<void> => {
|
|
25
|
+
const serviceAccountToken = await getServiceAccountToken(
|
|
26
|
+
args.idServiceAuthBaseURL,
|
|
27
|
+
args.mosaicHostingClientId,
|
|
28
|
+
args.mosaicHostingClientSecret,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
let manifestToUpload;
|
|
32
|
+
try {
|
|
33
|
+
manifestToUpload = findManifestToUpload(args.deploymentManifestPath);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.log(
|
|
36
|
+
`Error occurred while trying to read the Deployment Manifest at ${args.deploymentManifestPath}.`,
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const axiosInstance: AxiosInstance = getAxiosInstance(
|
|
42
|
+
args.hostingServiceBaseURL,
|
|
43
|
+
serviceAccountToken.accessToken,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const data = JSON.stringify({
|
|
47
|
+
query: `mutation CreateServiceDeploymentManifest($serviceId: String!, $name: String, $configMap: DeploymentConfigMap!) {
|
|
48
|
+
createServiceDeploymentManifest(
|
|
49
|
+
input: {configMap: $configMap, name: $name, serviceId: $serviceId}
|
|
50
|
+
) {
|
|
51
|
+
serviceDeploymentManifest {
|
|
52
|
+
id
|
|
53
|
+
name
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}`,
|
|
57
|
+
variables: {
|
|
58
|
+
serviceId: args.serviceId,
|
|
59
|
+
name: args.name === '' ? undefined : args.name,
|
|
60
|
+
configMap: manifestToUpload,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const response = await axiosInstance.post('graphql', data);
|
|
66
|
+
if (response.data.errors !== undefined && response.data.errors.length > 0) {
|
|
67
|
+
console.log('Upload of Deployment Manifest failed.');
|
|
68
|
+
console.log(response.data.errors[0].message);
|
|
69
|
+
console.log();
|
|
70
|
+
if (response.data.errors[0].details?.validateErrors?.length > 0) {
|
|
71
|
+
console.log('Schema Validation Errors:');
|
|
72
|
+
for (const detail of response.data.errors[0].details.validateErrors) {
|
|
73
|
+
console.log(detail);
|
|
74
|
+
}
|
|
75
|
+
console.log();
|
|
76
|
+
}
|
|
77
|
+
if (response.data.errors[0].details?.validationErrors?.length > 0) {
|
|
78
|
+
console.log('Deployment Manifest Syntax Validation Errors:');
|
|
79
|
+
const validationErrors: string[] = [];
|
|
80
|
+
for (const detail of response.data.errors[0].details.validationErrors) {
|
|
81
|
+
validationErrors.push(detail);
|
|
82
|
+
}
|
|
83
|
+
console.log(validationErrors);
|
|
84
|
+
console.log();
|
|
85
|
+
}
|
|
86
|
+
console.log(
|
|
87
|
+
`The Deployment Manifest Schema can be found at ${args.hostingServiceBaseURL}/.well-known.`,
|
|
88
|
+
);
|
|
89
|
+
} else {
|
|
90
|
+
console.log('Upload of Deployment Manifest successful.');
|
|
91
|
+
console.log(
|
|
92
|
+
response.data.data?.createServiceDeploymentManifest
|
|
93
|
+
.serviceDeploymentManifest,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.log('Error while uploading the Deployment Manifest.');
|
|
98
|
+
console.log(JSON.stringify((error as AxiosError).message));
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Method that validates the arguments.
|
|
104
|
+
* We're using this to allow both input arguments and environment variables.
|
|
105
|
+
*
|
|
106
|
+
* @param args
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
export const validateArgs = (
|
|
110
|
+
args: GetUploadManifestOptions,
|
|
111
|
+
): [Required<GetUploadManifestOptions>, string[]] => {
|
|
112
|
+
const errorMessages: string[] = [];
|
|
113
|
+
|
|
114
|
+
const idServiceAuthBaseURL =
|
|
115
|
+
args.idServiceAuthBaseURL ?? process.env.ID_SERVICE_AUTH_BASE_URL ?? '';
|
|
116
|
+
const mosaicHostingClientId =
|
|
117
|
+
args.mosaicHostingClientId ?? process.env.MOSAIC_HOSTING_CLIENT_ID ?? '';
|
|
118
|
+
const mosaicHostingClientSecret =
|
|
119
|
+
args.mosaicHostingClientSecret ??
|
|
120
|
+
process.env.MOSAIC_HOSTING_CLIENT_SECRET ??
|
|
121
|
+
'';
|
|
122
|
+
const serviceId = args.serviceId ?? process.env.SERVICE_ID ?? '';
|
|
123
|
+
const hostingServiceBaseURL =
|
|
124
|
+
args.hostingServiceBaseURL ?? process.env.HOSTING_SERVICE_BASE_URL ?? '';
|
|
125
|
+
|
|
126
|
+
if (isNullOrWhitespace(idServiceAuthBaseURL)) {
|
|
127
|
+
errorMessages.push('[idServiceAuthBaseURL] is required.');
|
|
128
|
+
}
|
|
129
|
+
if (isNullOrWhitespace(mosaicHostingClientId)) {
|
|
130
|
+
errorMessages.push('[clientId] is required.');
|
|
131
|
+
}
|
|
132
|
+
if (isNullOrWhitespace(mosaicHostingClientSecret)) {
|
|
133
|
+
errorMessages.push('[clientSecret] is required.');
|
|
134
|
+
}
|
|
135
|
+
if (isNullOrWhitespace(serviceId)) {
|
|
136
|
+
errorMessages.push('[serviceId] is required.');
|
|
137
|
+
}
|
|
138
|
+
if (isNullOrWhitespace(hostingServiceBaseURL)) {
|
|
139
|
+
errorMessages.push('[hostingServiceBaseURL] is required.');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return [
|
|
143
|
+
{
|
|
144
|
+
name: args.name,
|
|
145
|
+
idServiceAuthBaseURL,
|
|
146
|
+
mosaicHostingClientId,
|
|
147
|
+
mosaicHostingClientSecret,
|
|
148
|
+
serviceId,
|
|
149
|
+
deploymentManifestPath:
|
|
150
|
+
args.deploymentManifestPath ??
|
|
151
|
+
'./mosaic-hosting-deployment-manifest.yaml',
|
|
152
|
+
hostingServiceBaseURL,
|
|
153
|
+
},
|
|
154
|
+
errorMessages,
|
|
155
|
+
];
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const findManifestToUpload = (deploymentManifestPath: string): unknown => {
|
|
159
|
+
if (!existsSync(deploymentManifestPath)) {
|
|
160
|
+
throw new Error(`No directory found at ${deploymentManifestPath}`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const stat = lstatSync(deploymentManifestPath);
|
|
164
|
+
|
|
165
|
+
let manifestFile: string;
|
|
166
|
+
if (stat.isDirectory()) {
|
|
167
|
+
manifestFile = path.join(
|
|
168
|
+
deploymentManifestPath,
|
|
169
|
+
'mosaic-hosting-deployment-manifest.yaml',
|
|
170
|
+
);
|
|
171
|
+
} else {
|
|
172
|
+
manifestFile = deploymentManifestPath;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const doc = yaml.load(readFileSync(manifestFile, 'utf8'));
|
|
176
|
+
console.log(`Deployment Manifest found at ${manifestFile}.`);
|
|
177
|
+
|
|
178
|
+
return doc;
|
|
179
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CommandModule } from 'yargs';
|
|
2
|
+
import { registerPilet, validateArgs } from './register-pilet';
|
|
3
|
+
import { GetRegisterPiletOptions } from './register-pilet-options';
|
|
4
|
+
|
|
5
|
+
export const piletCommands: CommandModule<unknown, unknown> = {
|
|
6
|
+
builder: (yargs) =>
|
|
7
|
+
yargs
|
|
8
|
+
.command(
|
|
9
|
+
'register',
|
|
10
|
+
'Register a pilet in Mosaic Micro Frontend Service.',
|
|
11
|
+
piletRegister,
|
|
12
|
+
)
|
|
13
|
+
.demandCommand(),
|
|
14
|
+
handler: () => {
|
|
15
|
+
console.log('Please pick an action related to hosting pilet command.');
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const piletRegister: CommandModule<unknown, GetRegisterPiletOptions> = {
|
|
20
|
+
builder: (yargs) => {
|
|
21
|
+
return yargs
|
|
22
|
+
.option('serviceId', {
|
|
23
|
+
describe: 'Service ID the pilet should be registered to',
|
|
24
|
+
alias: 'i',
|
|
25
|
+
string: true,
|
|
26
|
+
})
|
|
27
|
+
.option('mosaicHostingClientId', {
|
|
28
|
+
describe: 'Client ID to authenticate',
|
|
29
|
+
alias: 'c',
|
|
30
|
+
string: true,
|
|
31
|
+
})
|
|
32
|
+
.option('mosaicHostingClientSecret', {
|
|
33
|
+
describe: 'Client Secret to authenticate',
|
|
34
|
+
alias: 's',
|
|
35
|
+
string: true,
|
|
36
|
+
})
|
|
37
|
+
.option('tenantId', {
|
|
38
|
+
describe: 'Tenant ID',
|
|
39
|
+
alias: 't',
|
|
40
|
+
string: true,
|
|
41
|
+
})
|
|
42
|
+
.option('environmentId', {
|
|
43
|
+
describe: 'Environment ID',
|
|
44
|
+
alias: 'e',
|
|
45
|
+
string: true,
|
|
46
|
+
})
|
|
47
|
+
.option('piletArtifactPath', {
|
|
48
|
+
describe: 'Pilet Artifact Path',
|
|
49
|
+
alias: 'p',
|
|
50
|
+
string: true,
|
|
51
|
+
})
|
|
52
|
+
.option('idServiceAuthBaseURL', {
|
|
53
|
+
describe: 'ID Service Authentication Endpoint Base URL',
|
|
54
|
+
alias: 'a',
|
|
55
|
+
string: true,
|
|
56
|
+
})
|
|
57
|
+
.option('microFrontendServiceBaseURL', {
|
|
58
|
+
describe: 'Micro Frontend Service Base URL',
|
|
59
|
+
alias: 'm',
|
|
60
|
+
string: true,
|
|
61
|
+
})
|
|
62
|
+
.option('overrideRegistration', {
|
|
63
|
+
describe: 'Override registration',
|
|
64
|
+
alias: 'm',
|
|
65
|
+
default: false,
|
|
66
|
+
boolean: true,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
handler: async (args) => {
|
|
70
|
+
// Validate arguments and read any arguments that are coming from environment variables.
|
|
71
|
+
const validatedArgs = validateArgs(args);
|
|
72
|
+
await registerPilet(validatedArgs);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -67,9 +67,9 @@ export const validateArgs = (
|
|
|
67
67
|
): Required<GetRegisterPiletOptions> => {
|
|
68
68
|
const idServiceAuthBaseURL =
|
|
69
69
|
args.idServiceAuthBaseURL ?? process.env.ID_SERVICE_AUTH_BASE_URL;
|
|
70
|
-
const
|
|
70
|
+
const mosaicHostingClientId =
|
|
71
71
|
args.mosaicHostingClientId ?? process.env.MOSAIC_HOSTING_CLIENT_ID;
|
|
72
|
-
const
|
|
72
|
+
const mosaicHostingClientSecret =
|
|
73
73
|
args.mosaicHostingClientSecret ?? process.env.MOSAIC_HOSTING_CLIENT_SECRET;
|
|
74
74
|
const tenantId = args.tenantId ?? process.env.TENANT_ID;
|
|
75
75
|
const environmentId = args.environmentId ?? process.env.ENVIRONMENT_ID;
|
|
@@ -82,10 +82,10 @@ export const validateArgs = (
|
|
|
82
82
|
if (isNullOrWhitespace(idServiceAuthBaseURL)) {
|
|
83
83
|
throw new Error('idServiceAuthBaseURL is required.');
|
|
84
84
|
}
|
|
85
|
-
if (isNullOrWhitespace(
|
|
85
|
+
if (isNullOrWhitespace(mosaicHostingClientId)) {
|
|
86
86
|
throw new Error('clientId is required.');
|
|
87
87
|
}
|
|
88
|
-
if (isNullOrWhitespace(
|
|
88
|
+
if (isNullOrWhitespace(mosaicHostingClientSecret)) {
|
|
89
89
|
throw new Error('clientSecret is required.');
|
|
90
90
|
}
|
|
91
91
|
if (isNullOrWhitespace(tenantId)) {
|
|
@@ -106,8 +106,8 @@ export const validateArgs = (
|
|
|
106
106
|
|
|
107
107
|
return {
|
|
108
108
|
idServiceAuthBaseURL,
|
|
109
|
-
mosaicHostingClientId
|
|
110
|
-
mosaicHostingClientSecret
|
|
109
|
+
mosaicHostingClientId,
|
|
110
|
+
mosaicHostingClientSecret,
|
|
111
111
|
tenantId,
|
|
112
112
|
environmentId,
|
|
113
113
|
serviceId,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register-pilet-options.js","sourceRoot":"","sources":["../../../src/commands/hosting/register-pilet-options.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"register-pilet.js","sourceRoot":"","sources":["../../../src/commands/hosting/register-pilet.ts"],"names":[],"mappings":";;;;AAAA,iEAAmE;AACnE,yEAAmE;AACnE,iCAA0C;AAC1C,sCAAsC;AACtC,2BAA0E;AAC1E,6BAA6B;AAGtB,MAAM,aAAa,GAAG,CAC3B,IAAuC,EAC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,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,IAAA,cAAS,EAAC,QAAQ,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACpD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACzB;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CACb,gDAAgD,SAAS,8CAA8C,CACxG,CAAC;KACH;IACD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,GAAG,CAAC,CAAC;KAC1D;IAED,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC"}
|
/package/dist/commands/hosting/{register-pilet-options.d.ts → pilet/register-pilet-options.d.ts}
RENAMED
|
File without changes
|
/package/dist/commands/hosting/{register-pilet-options.js → pilet/register-pilet-options.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|