@hahnpro/flow-cli 2.14.0 → 2.14.2
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/auth.mjs +9 -2
- package/lib/cli.mjs +2 -15
- package/lib/utils.mjs +11 -0
- package/package.json +12 -12
package/lib/auth.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import getPort from 'get-port';
|
|
4
|
+
import HttpsProxyAgent from 'https-proxy-agent';
|
|
4
5
|
import nconf from 'nconf';
|
|
5
6
|
import open from 'open';
|
|
6
|
-
import openidClient from 'openid-client';
|
|
7
|
+
import openidClient, { custom } from 'openid-client';
|
|
7
8
|
import { dirname, join } from 'node:path';
|
|
8
9
|
import { fileURLToPath } from 'node:url';
|
|
9
10
|
|
|
@@ -21,6 +22,12 @@ const viewsPath = join(__dirname, 'views');
|
|
|
21
22
|
let server = null;
|
|
22
23
|
nconf.file({ file: join(__dirname, 'config') });
|
|
23
24
|
|
|
25
|
+
if (process.env.https_proxy || process.env.http_proxy) {
|
|
26
|
+
custom.setHttpOptionsDefaults({
|
|
27
|
+
agent: HttpsProxyAgent(process.env.https_proxy || process.env.http_proxy),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
export async function getAccessToken(baseUrl = BASE_URL, realm = REALM) {
|
|
25
32
|
checkEnvironment([
|
|
26
33
|
['BASE_URL', baseUrl],
|
|
@@ -38,8 +45,8 @@ export async function getAccessToken(baseUrl = BASE_URL, realm = REALM) {
|
|
|
38
45
|
const kcIssuer = await openidClient.Issuer.discover(`${baseUrl}/auth/realms/${realm}/`);
|
|
39
46
|
const client = new kcIssuer.Client({ client_id: CLIENT_ID, client_secret: CLIENT_SECRET });
|
|
40
47
|
const tokenSet = await client.grant({ grant_type: 'client_credentials' });
|
|
48
|
+
|
|
41
49
|
nconf.set(baseUrl.replace(/:/g, ''), tokenSet);
|
|
42
|
-
server.close();
|
|
43
50
|
nconf.save((error) => {
|
|
44
51
|
if (error) {
|
|
45
52
|
logger.error(error);
|
package/lib/cli.mjs
CHANGED
|
@@ -17,18 +17,16 @@ import path from 'node:path';
|
|
|
17
17
|
import ora from 'ora';
|
|
18
18
|
|
|
19
19
|
import { getAccessToken, login, logout } from './auth.mjs';
|
|
20
|
-
import { handleConvertedOutput, logger, prepareTsFile } from './utils.mjs';
|
|
20
|
+
import { handleApiError, handleConvertedOutput, logger, prepareTsFile } from './utils.mjs';
|
|
21
21
|
|
|
22
22
|
const require = createRequire(import.meta.url);
|
|
23
23
|
const BASE_URL = process.env.BASE_URL || process.env.PLATFORM_URL;
|
|
24
24
|
const BUILD_DIR = process.env.BUILD_DIR || 'dist';
|
|
25
25
|
|
|
26
|
-
let axios;
|
|
26
|
+
let axios = Axios;
|
|
27
27
|
if (process.env.https_proxy || process.env.http_proxy) {
|
|
28
28
|
const httpsAgent = HttpsProxyAgent(process.env.https_proxy || process.env.http_proxy);
|
|
29
29
|
axios = Axios.create({ httpsAgent, proxy: false });
|
|
30
|
-
} else {
|
|
31
|
-
axios = Axios;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
let apiToken;
|
|
@@ -610,17 +608,6 @@ async function publishFunctions(project, update, baseUrl = BASE_URL) {
|
|
|
610
608
|
});
|
|
611
609
|
}
|
|
612
610
|
|
|
613
|
-
function handleApiError(error) {
|
|
614
|
-
if (error.isAxiosError && error.response) {
|
|
615
|
-
logger.error(`${error.response.status} ${error.response.statusText}`);
|
|
616
|
-
if (error.response.data) {
|
|
617
|
-
logger.error(JSON.stringify(error.response.data));
|
|
618
|
-
}
|
|
619
|
-
} else {
|
|
620
|
-
logger.error(error);
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
611
|
function zipDirectory(source, out) {
|
|
625
612
|
const archive = archiver('zip', { zlib: { level: 8 } });
|
|
626
613
|
const stream = fs.createWriteStream(out);
|
package/lib/utils.mjs
CHANGED
|
@@ -192,6 +192,17 @@ export const logger = {
|
|
|
192
192
|
/* eslint-enable no-console */
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
+
export function handleApiError(error) {
|
|
196
|
+
if (error.isAxiosError && error.response) {
|
|
197
|
+
logger.error(`${error.response.status} ${error.response.statusText}`);
|
|
198
|
+
if (error.response.data) {
|
|
199
|
+
logger.error(JSON.stringify(error.response.data));
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
logger.error(error);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
195
206
|
function blockDefinitionIncludes(block, value) {
|
|
196
207
|
return block.trim().split('\n', 1)[0].includes(value);
|
|
197
208
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/flow-cli",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.2",
|
|
4
4
|
"description": "CLI for managing Flow Modules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,25 +26,25 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"archiver": "^5.3.
|
|
29
|
+
"archiver": "^5.3.1",
|
|
30
30
|
"axios": "^0.26.1",
|
|
31
31
|
"chalk": "^5.0.1",
|
|
32
32
|
"class-transformer": "0.5.1",
|
|
33
33
|
"class-validator": "~0.13.2",
|
|
34
34
|
"class-validator-jsonschema": "^3.1.0",
|
|
35
|
-
"commander": "^9.
|
|
35
|
+
"commander": "^9.2.0",
|
|
36
36
|
"copyfiles": "^2.4.1",
|
|
37
37
|
"dotenv": "^16.0.0",
|
|
38
|
-
"ejs": "^3.1.
|
|
38
|
+
"ejs": "^3.1.7",
|
|
39
39
|
"execa": "^6.1.0",
|
|
40
40
|
"express": "^4.17.3",
|
|
41
41
|
"form-data": "^4.0.0",
|
|
42
42
|
"get-port": "^6.1.2",
|
|
43
|
-
"glob": "^
|
|
44
|
-
"https-proxy-agent": "^5.0.
|
|
45
|
-
"nconf": "^0.
|
|
43
|
+
"glob": "^8.0.1",
|
|
44
|
+
"https-proxy-agent": "^5.0.1",
|
|
45
|
+
"nconf": "^0.12.0",
|
|
46
46
|
"open": "^8.4.0",
|
|
47
|
-
"openid-client": "^5.1.
|
|
47
|
+
"openid-client": "^5.1.5",
|
|
48
48
|
"ora": "^6.1.0",
|
|
49
49
|
"reflect-metadata": "^0.1.13",
|
|
50
50
|
"ts-node": "^10.7.0"
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@types/express": "^4.17.13",
|
|
54
54
|
"@types/jest": "^27.4.1",
|
|
55
55
|
"@types/nconf": "^0.10.2",
|
|
56
|
-
"@types/node": "^16.11.
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-plugin-unicorn": "^
|
|
56
|
+
"@types/node": "^16.11.27",
|
|
57
|
+
"eslint": "^8.13.0",
|
|
58
|
+
"eslint-plugin-unicorn": "^42.0.0",
|
|
59
59
|
"jest": "^27.5.1",
|
|
60
|
-
"prettier": "^2.6.
|
|
60
|
+
"prettier": "^2.6.2",
|
|
61
61
|
"typescript": "^4.6.3"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|