@hahnpro/flow-cli 2.16.3 → 2.16.5

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 +49 -52
  2. package/package.json +20 -20
package/lib/cli.mjs CHANGED
@@ -9,8 +9,8 @@ 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';
13
- import HttpsProxyAgent from 'https-proxy-agent';
12
+ import { glob } from 'glob';
13
+ import { HttpsProxyAgent } from 'https-proxy-agent';
14
14
  import fs from 'node:fs';
15
15
  import { createRequire } from 'node:module';
16
16
  import path from 'node:path';
@@ -20,6 +20,8 @@ import { fileURLToPath } from 'node:url';
20
20
  import { getAccessToken, login, logout } from './auth.mjs';
21
21
  import { handleApiError, handleConvertedOutput, logger, prepareTsFile } from './utils.mjs';
22
22
 
23
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
+ // @ts-ignore
23
25
  const require = createRequire(import.meta.url);
24
26
  const BASE_URL = process.env.BASE_URL || process.env.PLATFORM_URL;
25
27
  const BUILD_DIR = process.env.BUILD_DIR || 'dist';
@@ -27,16 +29,16 @@ const BUILD_DIR = process.env.BUILD_DIR || 'dist';
27
29
  const __filename = fileURLToPath(import.meta.url);
28
30
  const __dirname = path.dirname(__filename);
29
31
 
30
- let axios = Axios;
32
+ let axios = Axios.create();
31
33
  if (process.env.https_proxy || process.env.http_proxy) {
32
- const httpsAgent = HttpsProxyAgent(process.env.https_proxy || process.env.http_proxy);
34
+ const httpsAgent = new HttpsProxyAgent(process.env.https_proxy || process.env.http_proxy);
33
35
  axios = Axios.create({ httpsAgent, proxy: false });
34
36
  }
35
37
 
36
38
  let apiToken;
37
39
  let projectsRoot = 'modules';
38
40
 
39
- const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')));
41
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString());
40
42
 
41
43
  const CMD = {
42
44
  AUDIT: 'audit',
@@ -313,25 +315,24 @@ program
313
315
  cwd: project.location,
314
316
  ignore: ['node_modules/**/*', '**/package*.json', '**/tsconfig*.json'],
315
317
  };
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
- }
318
+ const files = await glob('**/*.*', globOptions);
319
+ const filtered = files.filter((file) => !file.endsWith('.spec.ts'));
320
+ const tsJsonMap = filtered.reduce((accumulator, current, index, array) => {
321
+ if (current.endsWith('.ts')) {
322
+ // get json file for current function
323
+ const json = array.find((v) => v === `${current.split('.')[0]}.json`);
324
+ if (json) {
325
+ accumulator.push({
326
+ ts: path.join(globOptions.cwd, current),
327
+ json: path.join(globOptions.cwd, json),
328
+ });
328
329
  }
329
- return accumulator;
330
- }, []);
331
- for (let entry of tsJsonMap) {
332
- await generateSchemasForFile(entry.ts, entry.json);
333
330
  }
334
- });
331
+ return accumulator;
332
+ }, []);
333
+ for (let entry of tsJsonMap) {
334
+ await generateSchemasForFile(entry.ts, entry.json);
335
+ }
335
336
  } catch (error) {
336
337
  if (error) logger.log(error);
337
338
  process.exit(1);
@@ -585,41 +586,37 @@ async function publishFunctions(project, update, baseUrl = BASE_URL) {
585
586
  cwd: project.location,
586
587
  ignore: ['node_modules/**/*', '**/package*.json', '**/tsconfig*.json'],
587
588
  };
588
- glob('**/*.json', globOptions, async (error, files) => {
589
- if (error) {
590
- return reject(error);
591
- }
592
- const headers = { Authorization: `Bearer ${apiToken}` };
589
+ const files = await glob('**/*.json', globOptions).catch((error) => reject(error));
590
+ const headers = { Authorization: `Bearer ${apiToken}` };
593
591
 
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
- }
592
+ for (const file of files || []) {
593
+ try {
594
+ const data = await fs.promises.readFile(path.join(globOptions.cwd, file));
595
+ const json = JSON.parse(data.toString());
596
+ if (json.fqn && json.category) {
597
+ if (update) {
598
+ try {
599
+ await axios.put(`${baseUrl}/api/flow/functions/${json.fqn}`, json, { headers });
600
+ logger.ok(`Flow Function "${json.fqn}" has been updated`);
601
+ } catch (error) {
602
+ logger.error(`Flow Function "${json.fqn}" could not be updated`);
603
+ handleApiError(error);
604
+ }
605
+ } else {
606
+ try {
607
+ await axios.post(`${baseUrl}/api/flow/functions`, json, { headers });
608
+ logger.ok(`Flow Function "${json.fqn}" has been created`);
609
+ } catch (error) {
610
+ logger.error(`Flow Function "${json.fqn}" could not be created`);
611
+ handleApiError(error);
615
612
  }
616
613
  }
617
- } catch (error) {
618
- logger.error(error);
619
614
  }
615
+ } catch (error) {
616
+ logger.error(error);
620
617
  }
621
- return resolve();
622
- });
618
+ }
619
+ return resolve();
623
620
  });
624
621
  }
625
622
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hahnpro/flow-cli",
3
- "version": "2.16.3",
3
+ "version": "2.16.5",
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.3.3",
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": "^10.0.0",
34
+ "class-validator-jsonschema": "^5.0.0",
35
+ "commander": "^11.0.0",
36
36
  "copyfiles": "^2.4.1",
37
- "dotenv": "^16.0.3",
38
- "ejs": "^3.1.8",
39
- "execa": "^7.0.0",
37
+ "dotenv": "^16.3.1",
38
+ "ejs": "^3.1.9",
39
+ "execa": "^7.1.1",
40
40
  "express": "^4.18.2",
41
41
  "form-data": "^4.0.0",
42
- "get-port": "^6.1.2",
43
- "glob": "^8.1.0",
44
- "https-proxy-agent": "^5.0.1",
42
+ "get-port": "^7.0.0",
43
+ "glob": "^10.2.7",
44
+ "https-proxy-agent": "^7.0.0",
45
45
  "nconf": "^0.12.0",
46
- "open": "^8.4.1",
47
- "openid-client": "^5.4.0",
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
53
  "@types/express": "^4.17.17",
54
- "@types/jest": "^29.4.0",
54
+ "@types/jest": "^29.5.2",
55
55
  "@types/nconf": "^0.10.3",
56
- "@types/node": "^18.13.0",
57
- "eslint": "^8.34.0",
58
- "eslint-plugin-unicorn": "^45.0.2",
59
- "jest": "^29.4.3",
60
- "prettier": "^2.8.4",
61
- "typescript": "^4.9.5"
56
+ "@types/node": "^18.16.18",
57
+ "eslint": "^8.43.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"