mstate-cli 0.1.2 → 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.
@@ -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();
@@ -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:
@@ -51,4 +52,4 @@ switch (action) {
51
52
  utils_1.customLog.error(`${action ? 'Invalid' : 'Missing'} script: ${action !== null && action !== void 0 ? action : ''}`);
52
53
  console.log(`use 'mstate ${enum_1.CmdAction.HELP_FLAG}, ${enum_1.CmdAction.HELP}' for getting allowed action`);
53
54
  }
54
- console.log('\n');
55
+ console.log('');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mstate-cli",
3
- "version": "0.1.2",
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();
package/src/index.ts CHANGED
@@ -36,6 +36,7 @@ switch (action as CmdAction) {
36
36
  workflowHandler.updateWorkflowToDB().then(() => {
37
37
  actionHandler.saveToDB();
38
38
  environmentHandler.saveToDB();
39
+ workflowHandler.resetCache();
39
40
  });
40
41
  break;
41
42
  case CmdAction.HELP:
@@ -71,4 +72,4 @@ switch (action as CmdAction) {
71
72
  );
72
73
  }
73
74
 
74
- console.log('\n');
75
+ console.log('');
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "outDir": "./dist",
4
+ "rootDir": "src",
4
5
  "target": "es2016",
5
6
  "module": "commonjs",
6
7
  "esModuleInterop": true,
package/dist/package.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "name": "mstate-cli",
3
- "version": "0.1.2",
4
- "main": "index.js",
5
- "bin": {
6
- "mstate": "./dist/index.js"
7
- },
8
- "scripts": {
9
- "build": "tsc",
10
- "start": "npm run build && node dist/index.js"
11
- },
12
- "keywords": [
13
- "mstate",
14
- "workflow"
15
- ],
16
- "author": "",
17
- "license": "ISC",
18
- "description": "A CLI tool for maintaining mstate workflows config",
19
- "devDependencies": {
20
- "@types/node": "^22.9.0",
21
- "typescript": "^5.6.3"
22
- }
23
- }
File without changes
File without changes
File without changes