-
Notifications
You must be signed in to change notification settings - Fork 4
/
deploy.mjs
33 lines (26 loc) · 1.06 KB
/
deploy.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* © Copyright IBM Corp. 2022, 2023
* SPDX-License-Identifier: Apache-2.0
*/
import { AiopsBundleApiClient, UploadBundleTask, loginWithApiKey } from 'cp4waiops-ui-bundle-tools';
import fs from 'fs/promises';
const targetData = await fs.readFile('./target.json');
const targetDataJSON = JSON.parse(targetData);
// if (targetDataJSON.insecure) { // currently no support for cert checking, api validation only
process.removeAllListeners('warning');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
// }
const { authToken } = await loginWithApiKey(targetDataJSON.url, targetDataJSON.username, targetDataJSON.apiKey);
console.log('Logged into cluster and ready to upload 📡');
const bundleClient = AiopsBundleApiClient({
url: targetDataJSON.url,
token: authToken
});
const uploadBundleTask = UploadBundleTask(bundleClient);
console.log('Initiating bundle upload 🚀')
try {
await uploadBundleTask.uploadBundleFromDirectory(targetDataJSON.tenantId, targetDataJSON.bundleName, 'dist' );
console.log('Bundle uploaded successfully! 🎉')
} catch(e) {
console.error(e)
}