@hahnpro/flow-cli 2.16.2 → 2.16.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.
Files changed (2) hide show
  1. package/lib/cli.mjs +43 -48
  2. package/package.json +19 -19
package/lib/cli.mjs CHANGED
@@ -9,7 +9,7 @@ import { Command } from 'commander';
9
9
  import copyfiles from 'copyfiles';
10
10
  import { execa } from 'execa';
11
11
  import FormData from 'form-data';
12
- import glob from 'glob';
12
+ import { glob } from 'glob';
13
13
  import HttpsProxyAgent from 'https-proxy-agent';
14
14
  import fs from 'node:fs';
15
15
  import { createRequire } from 'node:module';
@@ -313,25 +313,24 @@ program
313
313
  cwd: project.location,
314
314
  ignore: ['node_modules/**/*', '**/package*.json', '**/tsconfig*.json'],
315
315
  };
316
- glob('**/*.*', globOptions, async (error, files) => {
317
- const filtered = files.filter((file) => !file.endsWith('.spec.ts'));
318
- const tsJsonMap = filtered.reduce((accumulator, current, index, array) => {
319
- if (current.endsWith('.ts')) {
320
- // get json file for current function
321
- const json = array.find((v) => v === `${current.split('.')[0]}.json`);
322
- if (json) {
323
- accumulator.push({
324
- ts: path.join(globOptions.cwd, current),
325
- json: path.join(globOptions.cwd, json),
326
- });
327
- }
316
+ const files = await glob('**/*.*', globOptions);
317
+ const filtered = files.filter((file) => !file.endsWith('.spec.ts'));
318
+ const tsJsonMap = filtered.reduce((accumulator, current, index, array) => {
319
+ if (current.endsWith('.ts')) {
320
+ // get json file for current function
321
+ const json = array.find((v) => v === `${current.split('.')[0]}.json`);
322
+ if (json) {
323
+ accumulator.push({
324
+ ts: path.join(globOptions.cwd, current),
325
+ json: path.join(globOptions.cwd, json),
326
+ });
328
327
  }
329
- return accumulator;
330
- }, []);
331
- for (let entry of tsJsonMap) {
332
- await generateSchemasForFile(entry.ts, entry.json);
333
328
  }
334
- });
329
+ return accumulator;
330
+ }, []);
331
+ for (let entry of tsJsonMap) {
332
+ await generateSchemasForFile(entry.ts, entry.json);
333
+ }
335
334
  } catch (error) {
336
335
  if (error) logger.log(error);
337
336
  process.exit(1);
@@ -585,41 +584,37 @@ async function publishFunctions(project, update, baseUrl = BASE_URL) {
585
584
  cwd: project.location,
586
585
  ignore: ['node_modules/**/*', '**/package*.json', '**/tsconfig*.json'],
587
586
  };
588
- glob('**/*.json', globOptions, async (error, files) => {
589
- if (error) {
590
- return reject(error);
591
- }
592
- const headers = { Authorization: `Bearer ${apiToken}` };
587
+ const files = await glob('**/*.json', globOptions).catch((error) => reject(error));
588
+ const headers = { Authorization: `Bearer ${apiToken}` };
593
589
 
594
- for (const file of files) {
595
- try {
596
- const data = await fs.promises.readFile(path.join(globOptions.cwd, file));
597
- const json = JSON.parse(data.toString());
598
- if (json.fqn && json.category) {
599
- if (update) {
600
- try {
601
- await axios.put(`${baseUrl}/api/flow/functions/${json.fqn}`, json, { headers });
602
- logger.ok(`Flow Function "${json.fqn}" has been updated`);
603
- } catch (error) {
604
- logger.error(`Flow Function "${json.fqn}" could not be updated`);
605
- handleApiError(error);
606
- }
607
- } else {
608
- try {
609
- await axios.post(`${baseUrl}/api/flow/functions`, json, { headers });
610
- logger.ok(`Flow Function "${json.fqn}" has been created`);
611
- } catch (error) {
612
- logger.error(`Flow Function "${json.fqn}" could not be created`);
613
- handleApiError(error);
614
- }
590
+ for (const file of files || []) {
591
+ try {
592
+ const data = await fs.promises.readFile(path.join(globOptions.cwd, file));
593
+ const json = JSON.parse(data.toString());
594
+ if (json.fqn && json.category) {
595
+ if (update) {
596
+ try {
597
+ await axios.put(`${baseUrl}/api/flow/functions/${json.fqn}`, json, { headers });
598
+ logger.ok(`Flow Function "${json.fqn}" has been updated`);
599
+ } catch (error) {
600
+ logger.error(`Flow Function "${json.fqn}" could not be updated`);
601
+ handleApiError(error);
602
+ }
603
+ } else {
604
+ try {
605
+ await axios.post(`${baseUrl}/api/flow/functions`, json, { headers });
606
+ logger.ok(`Flow Function "${json.fqn}" has been created`);
607
+ } catch (error) {
608
+ logger.error(`Flow Function "${json.fqn}" could not be created`);
609
+ handleApiError(error);
615
610
  }
616
611
  }
617
- } catch (error) {
618
- logger.error(error);
619
612
  }
613
+ } catch (error) {
614
+ logger.error(error);
620
615
  }
621
- return resolve();
622
- });
616
+ }
617
+ return resolve();
623
618
  });
624
619
  }
625
620
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/flow-cli",
3
- "version": "2.16.2",
3
+ "version": "2.16.4",
4
4
  "description": "CLI for managing Flow Modules",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,38 +27,38 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "archiver": "^5.3.1",
30
- "axios": "~1.2.2",
30
+ "axios": "~1.4.0",
31
31
  "chalk": "^5.2.0",
32
32
  "class-transformer": "0.5.1",
33
33
  "class-validator": "~0.14.0",
34
- "class-validator-jsonschema": "^4.0.0",
35
- "commander": "^9.5.0",
34
+ "class-validator-jsonschema": "^5.0.0",
35
+ "commander": "^10.0.1",
36
36
  "copyfiles": "^2.4.1",
37
37
  "dotenv": "^16.0.3",
38
- "ejs": "^3.1.8",
39
- "execa": "^6.1.0",
38
+ "ejs": "^3.1.9",
39
+ "execa": "^7.1.1",
40
40
  "express": "^4.18.2",
41
41
  "form-data": "^4.0.0",
42
42
  "get-port": "^6.1.2",
43
- "glob": "^8.0.3",
44
- "https-proxy-agent": "^5.0.1",
43
+ "glob": "^10.2.6",
44
+ "https-proxy-agent": "^7.0.0",
45
45
  "nconf": "^0.12.0",
46
- "open": "^8.4.0",
47
- "openid-client": "^5.3.1",
48
- "ora": "^6.1.2",
46
+ "open": "^9.1.0",
47
+ "openid-client": "^5.4.2",
48
+ "ora": "^6.3.1",
49
49
  "reflect-metadata": "^0.1.13",
50
50
  "ts-node": "^10.9.1"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/express": "^4.17.15",
54
- "@types/jest": "^29.2.5",
53
+ "@types/express": "^4.17.17",
54
+ "@types/jest": "^29.5.1",
55
55
  "@types/nconf": "^0.10.3",
56
- "@types/node": "^18.11.18",
57
- "eslint": "^8.31.0",
58
- "eslint-plugin-unicorn": "^45.0.2",
59
- "jest": "^29.3.1",
60
- "prettier": "^2.8.2",
61
- "typescript": "^4.9.4"
56
+ "@types/node": "^18.16.16",
57
+ "eslint": "^8.41.0",
58
+ "eslint-plugin-unicorn": "^47.0.0",
59
+ "jest": "^29.5.0",
60
+ "prettier": "^2.8.8",
61
+ "typescript": "^5.0.4"
62
62
  },
63
63
  "engines": {
64
64
  "node": "^14.13.1 || >=16.0.0"