mstate-cli 0.1.3 → 0.1.4
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/handlers/workflow.handler.js +31 -0
- package/dist/index.js +1 -0
- package/package.json +4 -1
- package/src/handlers/workflow.handler.ts +34 -0
- package/src/index.ts +1 -0
@@ -179,5 +179,36 @@ class WorkflowHandler {
|
|
179
179
|
}
|
180
180
|
});
|
181
181
|
}
|
182
|
+
resetCache() {
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
184
|
+
const args = process.argv;
|
185
|
+
const dirPath = (0, utils_1.getValueFromArgs)(args, Key.WORKFLOW);
|
186
|
+
const workflowName = dirPath.replace(/\//g, '__');
|
187
|
+
const secretKey = (0, utils_1.getValueFromArgs)(args, Key.SECRET_KEY);
|
188
|
+
if (!secretKey) {
|
189
|
+
utils_1.customLog.error(`Parameter secret is required`);
|
190
|
+
return;
|
191
|
+
}
|
192
|
+
if (!workflowName) {
|
193
|
+
utils_1.customLog.error(`Parameter workflow is required`);
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
const url = `${constant_1.MSTATE_URL}/cache/reset/${workflowName}`;
|
197
|
+
const responseJSON = yield fetch(url, {
|
198
|
+
method: 'DELETE',
|
199
|
+
headers: {
|
200
|
+
'Content-Type': 'application/json',
|
201
|
+
'secret-key': secretKey,
|
202
|
+
},
|
203
|
+
});
|
204
|
+
const response = yield responseJSON.json();
|
205
|
+
if (response === null || response === void 0 ? void 0 : response.errors) {
|
206
|
+
utils_1.customLog.error('Invalid Parameters: ', response === null || response === void 0 ? void 0 : response.errors);
|
207
|
+
}
|
208
|
+
else {
|
209
|
+
utils_1.customLog.success(`Workflow updated successfully`);
|
210
|
+
}
|
211
|
+
});
|
212
|
+
}
|
182
213
|
}
|
183
214
|
exports.workflowHandler = new WorkflowHandler();
|
package/dist/index.js
CHANGED
@@ -34,6 +34,7 @@ switch (action) {
|
|
34
34
|
workflow_handler_1.workflowHandler.updateWorkflowToDB().then(() => {
|
35
35
|
action_handler_1.actionHandler.saveToDB();
|
36
36
|
environment_handler_1.environmentHandler.saveToDB();
|
37
|
+
workflow_handler_1.workflowHandler.resetCache();
|
37
38
|
});
|
38
39
|
break;
|
39
40
|
case enum_1.CmdAction.HELP:
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mstate-cli",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.4",
|
4
4
|
"main": "index.js",
|
5
5
|
"bin": {
|
6
6
|
"mstate": "./dist/index.js"
|
@@ -19,5 +19,8 @@
|
|
19
19
|
"devDependencies": {
|
20
20
|
"@types/node": "^22.9.0",
|
21
21
|
"typescript": "^5.6.3"
|
22
|
+
},
|
23
|
+
"dependencies": {
|
24
|
+
"mstate-cli": "^0.0.9"
|
22
25
|
}
|
23
26
|
}
|
@@ -158,6 +158,40 @@ class WorkflowHandler {
|
|
158
158
|
customLog.error('Error in cloning workflow', error.message);
|
159
159
|
}
|
160
160
|
}
|
161
|
+
|
162
|
+
async resetCache() {
|
163
|
+
const args = process.argv;
|
164
|
+
|
165
|
+
const dirPath = getValueFromArgs(args, Key.WORKFLOW);
|
166
|
+
const workflowName = dirPath.replace(/\//g, '__');
|
167
|
+
const secretKey = getValueFromArgs(args, Key.SECRET_KEY);
|
168
|
+
|
169
|
+
if (!secretKey) {
|
170
|
+
customLog.error(`Parameter secret is required`);
|
171
|
+
return;
|
172
|
+
}
|
173
|
+
|
174
|
+
if (!workflowName) {
|
175
|
+
customLog.error(`Parameter workflow is required`);
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
|
179
|
+
const url = `${MSTATE_URL}/cache/reset/${workflowName}`;
|
180
|
+
const responseJSON = await fetch(url, {
|
181
|
+
method: 'DELETE',
|
182
|
+
headers: {
|
183
|
+
'Content-Type': 'application/json',
|
184
|
+
'secret-key': secretKey,
|
185
|
+
},
|
186
|
+
});
|
187
|
+
|
188
|
+
const response = await responseJSON.json();
|
189
|
+
if (response?.errors) {
|
190
|
+
customLog.error('Invalid Parameters: ', response?.errors);
|
191
|
+
} else {
|
192
|
+
customLog.success(`Workflow updated successfully`);
|
193
|
+
}
|
194
|
+
}
|
161
195
|
}
|
162
196
|
|
163
197
|
export const workflowHandler = new WorkflowHandler();
|