@hahnpro/flow-cli 2.14.2-6 → 2.15.0
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 +8 -3
- package/lib/cli.mjs +26 -21
- package/lib/utils.mjs +4 -4
- package/package.json +20 -21
- package/lib/config +0 -12
package/lib/auth.mjs
CHANGED
|
@@ -43,8 +43,12 @@ export async function getAccessToken(baseUrl = BASE_URL, realm = REALM) {
|
|
|
43
43
|
? new Promise(async (resolve, reject) => {
|
|
44
44
|
try {
|
|
45
45
|
const kcIssuer = await openidClient.Issuer.discover(`${baseUrl}/auth/realms/${realm}/`);
|
|
46
|
-
const client = new kcIssuer.Client({
|
|
47
|
-
|
|
46
|
+
const client = new kcIssuer.Client({
|
|
47
|
+
client_id: CLIENT_ID,
|
|
48
|
+
client_secret: CLIENT_SECRET,
|
|
49
|
+
token_endpoint_auth_method: 'client_secret_jwt',
|
|
50
|
+
});
|
|
51
|
+
tokenSet = await client.grant({ grant_type: 'client_credentials' });
|
|
48
52
|
|
|
49
53
|
nconf.set(baseUrl.replace(/:/g, ''), tokenSet);
|
|
50
54
|
nconf.save((error) => {
|
|
@@ -85,6 +89,7 @@ export function login(baseUrl = BASE_URL, realm = REALM) {
|
|
|
85
89
|
const auhtUrl = client.authorizationUrl({ code_challenge, code_challenge_method: 'S256' });
|
|
86
90
|
|
|
87
91
|
const app = express();
|
|
92
|
+
app.disable('x-powered-by');
|
|
88
93
|
app.use(express.static(viewsPath));
|
|
89
94
|
app.set('views', viewsPath);
|
|
90
95
|
|
|
@@ -142,6 +147,6 @@ function checkEnvironment(values) {
|
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
149
|
if (missing) {
|
|
145
|
-
throw new Error('Missing environment
|
|
150
|
+
throw new Error('Missing environment variables');
|
|
146
151
|
}
|
|
147
152
|
}
|
package/lib/cli.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import fs from 'node:fs';
|
|
|
15
15
|
import { createRequire } from 'node:module';
|
|
16
16
|
import path from 'node:path';
|
|
17
17
|
import ora from 'ora';
|
|
18
|
+
import { fileURLToPath } from 'node:url';
|
|
18
19
|
|
|
19
20
|
import { getAccessToken, login, logout } from './auth.mjs';
|
|
20
21
|
import { handleApiError, handleConvertedOutput, logger, prepareTsFile } from './utils.mjs';
|
|
@@ -23,6 +24,9 @@ const require = createRequire(import.meta.url);
|
|
|
23
24
|
const BASE_URL = process.env.BASE_URL || process.env.PLATFORM_URL;
|
|
24
25
|
const BUILD_DIR = process.env.BUILD_DIR || 'dist';
|
|
25
26
|
|
|
27
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
28
|
+
const __dirname = path.dirname(__filename);
|
|
29
|
+
|
|
26
30
|
let axios = Axios;
|
|
27
31
|
if (process.env.https_proxy || process.env.http_proxy) {
|
|
28
32
|
const httpsAgent = HttpsProxyAgent(process.env.https_proxy || process.env.http_proxy);
|
|
@@ -32,6 +36,8 @@ if (process.env.https_proxy || process.env.http_proxy) {
|
|
|
32
36
|
let apiToken;
|
|
33
37
|
let projectsRoot = 'modules';
|
|
34
38
|
|
|
39
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')));
|
|
40
|
+
|
|
35
41
|
const CMD = {
|
|
36
42
|
AUDIT: 'audit',
|
|
37
43
|
BUILD: 'build',
|
|
@@ -46,7 +52,7 @@ const CMD = {
|
|
|
46
52
|
const program = new Command();
|
|
47
53
|
|
|
48
54
|
program
|
|
49
|
-
.version(
|
|
55
|
+
.version(packageJson.version, '-v, --version')
|
|
50
56
|
.usage('[command] [options]')
|
|
51
57
|
.description('Flow Module Management Tool')
|
|
52
58
|
.on('--help', () => {});
|
|
@@ -112,11 +118,7 @@ program
|
|
|
112
118
|
.description('Lint project files')
|
|
113
119
|
.action(async (projectName) => {
|
|
114
120
|
try {
|
|
115
|
-
|
|
116
|
-
if (projectName === 'all') {
|
|
117
|
-
project = { location: '.' };
|
|
118
|
-
}
|
|
119
|
-
project = await findProject(projectName);
|
|
121
|
+
const project = await findProject(projectName);
|
|
120
122
|
await exec(CMD.LINT, project);
|
|
121
123
|
} catch (error) {
|
|
122
124
|
if (error) logger.log(error);
|
|
@@ -124,10 +126,11 @@ program
|
|
|
124
126
|
}
|
|
125
127
|
});
|
|
126
128
|
|
|
129
|
+
// if BASE_URL is not given and --url is not specified this correctly throws an error
|
|
127
130
|
program
|
|
128
131
|
.command('login')
|
|
129
|
-
.
|
|
130
|
-
.
|
|
132
|
+
.requiredOption('--url <url>', 'URL of target platform', process.env.BASE_URL)
|
|
133
|
+
.requiredOption('-r, --realm <realm>', 'Auth realm of target platform', process.env.REALM)
|
|
131
134
|
.description('Authenticate against platform')
|
|
132
135
|
.action(async (options) => {
|
|
133
136
|
try {
|
|
@@ -141,7 +144,7 @@ program
|
|
|
141
144
|
|
|
142
145
|
program
|
|
143
146
|
.command('logout')
|
|
144
|
-
.
|
|
147
|
+
.requiredOption('--url <url>', 'URL of target platform', process.env.BASE_URL)
|
|
145
148
|
.description('Remove authentication data')
|
|
146
149
|
.action(async (options) => {
|
|
147
150
|
try {
|
|
@@ -186,8 +189,8 @@ program
|
|
|
186
189
|
|
|
187
190
|
program
|
|
188
191
|
.command('publish-module [projectName]')
|
|
189
|
-
.
|
|
190
|
-
.
|
|
192
|
+
.requiredOption('--url <url>', 'URL of target platform', process.env.BASE_URL)
|
|
193
|
+
.requiredOption('-r, --realm <realm>', 'Auth realm of target platform', process.env.REALM)
|
|
191
194
|
.option('-f, --functions', 'publish flow functions')
|
|
192
195
|
.option('-u, --update', 'update existing flow functions')
|
|
193
196
|
.option('-s, --skip', 'skip modules that already exists with the current version')
|
|
@@ -240,8 +243,8 @@ program
|
|
|
240
243
|
|
|
241
244
|
program
|
|
242
245
|
.command('publish-functions [projectName]')
|
|
243
|
-
.
|
|
244
|
-
.
|
|
246
|
+
.requiredOption('--url <url>', 'URL of target platform', process.env.BASE_URL)
|
|
247
|
+
.requiredOption('-r, --realm <realm>', 'Auth realm of target platform', process.env.REALM)
|
|
245
248
|
.option('-u, --update', 'update existing flow functions')
|
|
246
249
|
.description('Publishes all Flow Functions inside specified Module to Cloud Platform')
|
|
247
250
|
.action(async (projectName, options) => {
|
|
@@ -530,6 +533,8 @@ async function publishModule(project, baseUrl = BASE_URL) {
|
|
|
530
533
|
...form.getHeaders(),
|
|
531
534
|
Authorization: `Bearer ${apiToken}`,
|
|
532
535
|
},
|
|
536
|
+
maxBodyLength: Number.POSITIVE_INFINITY,
|
|
537
|
+
maxContentLength: Number.POSITIVE_INFINITY,
|
|
533
538
|
});
|
|
534
539
|
|
|
535
540
|
logger.ok(`Module "${project.name}" published!`);
|
|
@@ -623,9 +628,9 @@ function zipDirectory(source, out) {
|
|
|
623
628
|
});
|
|
624
629
|
}
|
|
625
630
|
|
|
626
|
-
function deleteFile(
|
|
631
|
+
function deleteFile(filePath) {
|
|
627
632
|
return new Promise((resolve, reject) => {
|
|
628
|
-
fs.unlink(
|
|
633
|
+
fs.unlink(filePath, (error) => {
|
|
629
634
|
if (error) return reject(error);
|
|
630
635
|
return resolve();
|
|
631
636
|
});
|
|
@@ -732,20 +737,20 @@ function checkIfAll(projectName) {
|
|
|
732
737
|
return false;
|
|
733
738
|
}
|
|
734
739
|
|
|
735
|
-
function readJson(
|
|
740
|
+
function readJson(filePath) {
|
|
736
741
|
return new Promise((resolve, reject) => {
|
|
737
|
-
fs.readFile(
|
|
742
|
+
fs.readFile(filePath, { encoding: 'utf8' }, (error, data) => {
|
|
738
743
|
if (error) return reject(error);
|
|
739
744
|
try {
|
|
740
745
|
return resolve(JSON.parse(data));
|
|
741
|
-
} catch (
|
|
742
|
-
return reject(
|
|
746
|
+
} catch (error_) {
|
|
747
|
+
return reject(error_);
|
|
743
748
|
}
|
|
744
749
|
});
|
|
745
750
|
});
|
|
746
751
|
}
|
|
747
752
|
|
|
748
|
-
function writeJson(
|
|
753
|
+
function writeJson(filePath, data) {
|
|
749
754
|
return new Promise((resolve, reject) => {
|
|
750
755
|
let dataString;
|
|
751
756
|
try {
|
|
@@ -753,7 +758,7 @@ function writeJson(path, data) {
|
|
|
753
758
|
} catch (error) {
|
|
754
759
|
return reject(error);
|
|
755
760
|
}
|
|
756
|
-
fs.writeFile(
|
|
761
|
+
fs.writeFile(filePath, dataString, (error) => {
|
|
757
762
|
if (error) return reject(error);
|
|
758
763
|
return resolve();
|
|
759
764
|
});
|
package/lib/utils.mjs
CHANGED
|
@@ -10,7 +10,7 @@ const defaultLogger = {
|
|
|
10
10
|
/* eslint-enable no-console */
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export function checkTypes(definedTypes, propertiesSchema, jsonPath,
|
|
13
|
+
export function checkTypes(definedTypes, propertiesSchema, jsonPath, logger1 = defaultLogger) {
|
|
14
14
|
const knownTypes = new Set([
|
|
15
15
|
...definedTypes,
|
|
16
16
|
'string',
|
|
@@ -32,7 +32,7 @@ export function checkTypes(definedTypes, propertiesSchema, jsonPath, logger = de
|
|
|
32
32
|
const properties = propertiesSchema.properties || {};
|
|
33
33
|
for (const property of Object.keys(properties)) {
|
|
34
34
|
if (properties[property].type && !knownTypes.has(properties[property].type)) {
|
|
35
|
-
|
|
35
|
+
logger1.error(
|
|
36
36
|
`ERROR: unknown type ${properties[property].type}.
|
|
37
37
|
Please add a schema for this type in ${jsonPath}
|
|
38
38
|
for more info check the documentation`,
|
|
@@ -52,12 +52,12 @@ export async function getTypes(filePath) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export async function handleConvertedOutput(result, jsonPath, json,
|
|
55
|
+
export async function handleConvertedOutput(result, jsonPath, json, logger1 = defaultLogger) {
|
|
56
56
|
let schema;
|
|
57
57
|
try {
|
|
58
58
|
schema = JSON.parse(result);
|
|
59
59
|
} catch {
|
|
60
|
-
|
|
60
|
+
logger1.error(result);
|
|
61
61
|
return json;
|
|
62
62
|
}
|
|
63
63
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/flow-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
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": "
|
|
30
|
+
"axios": "~0.27.2",
|
|
31
31
|
"chalk": "^5.0.1",
|
|
32
32
|
"class-transformer": "0.5.1",
|
|
33
33
|
"class-validator": "~0.13.2",
|
|
34
|
-
"class-validator-jsonschema": "^3.1.
|
|
35
|
-
"commander": "^9.
|
|
34
|
+
"class-validator-jsonschema": "^3.1.1",
|
|
35
|
+
"commander": "^9.4.0",
|
|
36
36
|
"copyfiles": "^2.4.1",
|
|
37
|
-
"dotenv": "^16.0.
|
|
38
|
-
"ejs": "^3.1.
|
|
37
|
+
"dotenv": "^16.0.1",
|
|
38
|
+
"ejs": "^3.1.8",
|
|
39
39
|
"execa": "^6.1.0",
|
|
40
|
-
"express": "^4.
|
|
40
|
+
"express": "^4.18.1",
|
|
41
41
|
"form-data": "^4.0.0",
|
|
42
42
|
"get-port": "^6.1.2",
|
|
43
|
-
"glob": "^8.0.
|
|
43
|
+
"glob": "^8.0.3",
|
|
44
44
|
"https-proxy-agent": "^5.0.1",
|
|
45
45
|
"nconf": "^0.12.0",
|
|
46
46
|
"open": "^8.4.0",
|
|
47
|
-
"openid-client": "^5.1.
|
|
48
|
-
"ora": "^6.1.
|
|
47
|
+
"openid-client": "^5.1.8",
|
|
48
|
+
"ora": "^6.1.2",
|
|
49
49
|
"reflect-metadata": "^0.1.13",
|
|
50
|
-
"ts-node": "^10.
|
|
50
|
+
"ts-node": "^10.9.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/express": "^4.17.13",
|
|
54
|
-
"@types/jest": "^
|
|
55
|
-
"@types/nconf": "^0.10.
|
|
56
|
-
"@types/node": "^16.11.
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-plugin-unicorn": "^
|
|
59
|
-
"jest": "^
|
|
60
|
-
"prettier": "^2.
|
|
61
|
-
"typescript": "^4.
|
|
54
|
+
"@types/jest": "^28.1.6",
|
|
55
|
+
"@types/nconf": "^0.10.3",
|
|
56
|
+
"@types/node": "^16.11.45",
|
|
57
|
+
"eslint": "^8.20.0",
|
|
58
|
+
"eslint-plugin-unicorn": "^43.0.2",
|
|
59
|
+
"jest": "^28.1.3",
|
|
60
|
+
"prettier": "^2.7.1",
|
|
61
|
+
"typescript": "^4.7.4"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": "^14.13.1 || >=16.0.0"
|
|
@@ -83,6 +83,5 @@
|
|
|
83
83
|
"format": "prettier --write .",
|
|
84
84
|
"lint": "eslint '**/*.{js,mjs}'",
|
|
85
85
|
"test": "jest"
|
|
86
|
-
}
|
|
87
|
-
"readme": "# `@hahnpro/flow-cli`\n\nhttps://github.com/hahnprojects/flow\n\n```shell\nflow-cli --help\nflow-cli [command] --help\n```\n\n# Commands\n\n## `build [projectName]`\n\nBuilds specified Project.\n\n## `install [projectName]`\n\nInstalls the dependencies of the specified Project.\n\n## `format`\n\nFormats all typescript files according to prettier configuration.\n\n## `name [projectName]`\n\nInstalls Dependencies and Builds the specified Project.\n\n## `package [projectName]`\n\nBuilds specified Module and packages it as .zip File for manual upload to the platform.\n\n## `publish-module [projectName]`\n\nPublishes specified Module to Cloud Platform.\n\n- `-f`, `--functions` Publish flow functions.\n- `-u`, `--update` Update existing flow functions.\n\n## `publish-functions [projectName]`\n\nPublishes all Flow Functions inside specified Module to Cloud Platform.\n\n- `-u`, `--update` Update existing flow functions.\n\n## `serve [projectName]`\n\nBuilds and serves your Project. Rebuilding on file changes.\n\n## `start [projectName]`\n\nRuns your project.\n\n## `test [projectName]`\n\nRuns tests for your Project.\n\n## `generate-schemas [projectName]`\n\nGenerates Input, Output and Properties-Schemas for the specified project.\n\n- `--verbose` Output more information about what is being done.\n- `-h`, `--hide` Hide warnings if Input/OutputProperties classes can´t be found.\n This command generates the schemas and puts them in the `inputStreams` and `outputStreams`\n fields in the json-files of each Flow-Function. It always assumes the properties defined\n in the `Input/OutPutProperties` classes are meant for the default input/output streams.\n If your Function uses different streams you may have to change stream name manually.\n"
|
|
86
|
+
}
|
|
88
87
|
}
|
package/lib/config
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"https//testing.hahnpro.com": {
|
|
3
|
-
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJZbmFFenVubVYxWkpQZndQbWpxR1ZqUFdWejZFNjRZRkNCZTZ6bVJPa1hVIn0.eyJleHAiOjE2NDg5MjA4MTMsImlhdCI6MTY0ODkxNjk3MywiYXV0aF90aW1lIjoxNjQ4OTE1MTI2LCJqdGkiOiJiNGYyZTU1Ny04NTc0LTRhZjEtYjhkMC1lM2Q0ZjcyZTZhZWQiLCJpc3MiOiJodHRwczovL3Rlc3RpbmcuaGFobnByby5jb20vYXV0aC9yZWFsbXMvdGVzdGluZyIsImF1ZCI6ImZsb3ctc2VydmljZSIsInN1YiI6IjYyMDcyZjc0LTFhOTUtNDY2Ni1iMzA2LWNmNGM5MmM5OThhZSIsInR5cCI6IkJlYXJlciIsImF6cCI6ImZsb3ctY2xpIiwic2Vzc2lvbl9zdGF0ZSI6ImE3NWI4NGU1LTUzMmEtNDE5Ny1iZTk5LTZjZjNkYzZiYmRiMCIsImFjciI6IjAiLCJyZXNvdXJjZV9hY2Nlc3MiOnsiZmxvdy1zZXJ2aWNlIjp7InJvbGVzIjpbIm1vZHVsZS51cGRhdGUiLCJjIiwiZCIsImFkbWluIiwiZnVuY3Rpb24uY3JlYXRlIiwiZnVuY3Rpb24udXBkYXRlIiwiZmxvdy5jcmVhdGUiLCJtb2R1bGUuc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