zcatalyst-cli 1.25.0 → 1.25.1
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/lib/internal/api.js +6 -3
- package/lib/progress.js +8 -1
- package/package.json +2 -2
- package/scripts/send-notification.js +0 -107
package/lib/internal/api.js
CHANGED
|
@@ -122,9 +122,12 @@ class API {
|
|
|
122
122
|
}
|
|
123
123
|
_logUploadProgress({ chunk, error } = {}) {
|
|
124
124
|
if (this.uploadProgress) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
if (chunk) {
|
|
126
|
+
this.uploadProgress.tick(chunk.length);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
error ? this.uploadProgress.error(error) : this.uploadProgress.error();
|
|
130
|
+
}
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
_logDownloadProgress({ chunk, error } = {}) {
|
package/lib/progress.js
CHANGED
|
@@ -41,7 +41,14 @@ class Progress {
|
|
|
41
41
|
}
|
|
42
42
|
error(err) {
|
|
43
43
|
const msg = this.failure ? this.failure(err) : typeof err === 'string' ? err : err === null || err === void 0 ? void 0 : err.message;
|
|
44
|
-
|
|
44
|
+
if (msg) {
|
|
45
|
+
if (this.throbber.pick(this.title)) {
|
|
46
|
+
this.throbber.fail(this.title, { text: msg });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.throbber.remove(this.title);
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
tick(count = 1) {
|
|
47
54
|
let prependedHeader = '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcatalyst-cli",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.1",
|
|
4
4
|
"description": "Command Line Tool for CATALYST",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -112,6 +112,6 @@
|
|
|
112
112
|
"files": [
|
|
113
113
|
"lib/**/*",
|
|
114
114
|
"templates/**/*",
|
|
115
|
-
"scripts
|
|
115
|
+
"scripts/postInstall.js"
|
|
116
116
|
]
|
|
117
117
|
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
-
|
|
4
|
-
const PACKAGE_JSON = require('../package.json');
|
|
5
|
-
const HTTPS = require('https');
|
|
6
|
-
const VERSION = PACKAGE_JSON.version;
|
|
7
|
-
const NPM_REGISTRY_LINK = process.env.NPM_REGISTRY_LINK;
|
|
8
|
-
const RELEASE_NOTES_LINK = process.env.RELEASE_NOTES_LINK;
|
|
9
|
-
const API_KEY = process.env.API_KEY;
|
|
10
|
-
const MERGE_REQUEST_ID = process.env.CI_MERGE_REQUEST_IID;
|
|
11
|
-
|
|
12
|
-
const INSTALL_COMMAND = `npm install -g zcatalyst-cli@${VERSION}`;
|
|
13
|
-
const CHANNEL_NAMES = (process.env.CHANNEL_NAMES || '').split(',');
|
|
14
|
-
|
|
15
|
-
const notify = async () => {
|
|
16
|
-
let text = `Hey Team, we've released a new version of [ZCatalyst-CLI](${NPM_REGISTRY_LINK}) :fireworks: \n\n *Version:* \`v${VERSION}\``;
|
|
17
|
-
|
|
18
|
-
if (MERGE_REQUEST_ID) {
|
|
19
|
-
text =
|
|
20
|
-
text +
|
|
21
|
-
`\n* [Pipeline status](https://git.csez.zohocorpin.com/BaaS/ZCatalyst-CLI/-/merge_requests/${MERGE_REQUEST_ID}/pipelines)`;
|
|
22
|
-
}
|
|
23
|
-
const message = {
|
|
24
|
-
text,
|
|
25
|
-
bot: {
|
|
26
|
-
name: 'Dx Tools Update',
|
|
27
|
-
image: 'https://www.zoho.com/sites/zweb/images/producticon/catalyst.svg'
|
|
28
|
-
},
|
|
29
|
-
card: {
|
|
30
|
-
title: 'Announcement',
|
|
31
|
-
thumbnail: 'https://public-catlab-development.zohostratus.in/megaphone.gif',
|
|
32
|
-
theme: 'modern-inline'
|
|
33
|
-
},
|
|
34
|
-
slides: [
|
|
35
|
-
{
|
|
36
|
-
type: 'text',
|
|
37
|
-
title: 'Installation Command',
|
|
38
|
-
data: '```' + INSTALL_COMMAND + '```'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
type: 'text',
|
|
42
|
-
title: 'Release Notes',
|
|
43
|
-
data: `${RELEASE_NOTES_LINK}`
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
if (!CHANNEL_NAMES || !Array.isArray(CHANNEL_NAMES) || CHANNEL_NAMES.length === 0) {
|
|
49
|
-
console.error('Invalid channels: ' + process.env.CHANNEL_NAMES);
|
|
50
|
-
process.exit(1);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
await Promise.all(
|
|
54
|
-
CHANNEL_NAMES.map((channel) => {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
try {
|
|
57
|
-
const reqOpts = {
|
|
58
|
-
hostname: 'cliq.zoho.com',
|
|
59
|
-
path: `/company/64396901/api/v2/channelsbyname/${channel}/message?zapikey=${API_KEY}`,
|
|
60
|
-
qs: {},
|
|
61
|
-
method: 'POST',
|
|
62
|
-
headers: {
|
|
63
|
-
'content-type': 'application/json'
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const req = HTTPS.request(reqOpts, async (res) => {
|
|
67
|
-
if (res.statusCode === 204) {
|
|
68
|
-
console.log('Notification successful: ' + channel);
|
|
69
|
-
return resolve();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const data = [];
|
|
73
|
-
res.on('data', (chunk) => {
|
|
74
|
-
data.push(chunk);
|
|
75
|
-
});
|
|
76
|
-
res.on('end', () => {
|
|
77
|
-
const resStr = Buffer.concat(data).toString();
|
|
78
|
-
reject(
|
|
79
|
-
new Error(
|
|
80
|
-
`API ERROR ::: ${req.method} ::: https://${req.host}${req.path} ::: ${res.statusCode} ::: ${resStr}`
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
req.on('error', reject);
|
|
86
|
-
req.write(JSON.stringify(message));
|
|
87
|
-
req.end();
|
|
88
|
-
} catch (er) {
|
|
89
|
-
if (er instanceof Error) {
|
|
90
|
-
return reject(er);
|
|
91
|
-
}
|
|
92
|
-
const error = new Error();
|
|
93
|
-
error.cause = er;
|
|
94
|
-
return reject(error);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
})
|
|
98
|
-
).catch((er) => {
|
|
99
|
-
console.error('Error sending notifications: ', er);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
console.log('All Notifications sent successfully');
|
|
104
|
-
process.exit(0);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
notify();
|