@hahnpro/flow-cli 2.14.3 → 2.15.1
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 +7 -2
- package/lib/cli.mjs +46 -27
- package/lib/utils.mjs +4 -4
- package/package.json +19 -19
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
|
|
package/lib/cli.mjs
CHANGED
|
@@ -628,9 +628,9 @@ function zipDirectory(source, out) {
|
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
630
|
|
|
631
|
-
function deleteFile(
|
|
631
|
+
function deleteFile(filePath) {
|
|
632
632
|
return new Promise((resolve, reject) => {
|
|
633
|
-
fs.unlink(
|
|
633
|
+
fs.unlink(filePath, (error) => {
|
|
634
634
|
if (error) return reject(error);
|
|
635
635
|
return resolve();
|
|
636
636
|
});
|
|
@@ -639,23 +639,31 @@ function deleteFile(path) {
|
|
|
639
639
|
|
|
640
640
|
function getProcess(cmd) {
|
|
641
641
|
switch (cmd) {
|
|
642
|
-
case CMD.BUILD:
|
|
642
|
+
case CMD.BUILD: {
|
|
643
643
|
return 'tsc';
|
|
644
|
-
|
|
644
|
+
}
|
|
645
|
+
case CMD.FORMAT: {
|
|
645
646
|
return 'prettier';
|
|
647
|
+
}
|
|
646
648
|
case CMD.INSTALL:
|
|
647
|
-
case CMD.AUDIT:
|
|
649
|
+
case CMD.AUDIT: {
|
|
648
650
|
return 'npm';
|
|
649
|
-
|
|
651
|
+
}
|
|
652
|
+
case CMD.LINT: {
|
|
650
653
|
return 'eslint';
|
|
651
|
-
|
|
654
|
+
}
|
|
655
|
+
case CMD.RUN: {
|
|
652
656
|
return 'node';
|
|
653
|
-
|
|
657
|
+
}
|
|
658
|
+
case CMD.TEST: {
|
|
654
659
|
return 'jest';
|
|
655
|
-
|
|
660
|
+
}
|
|
661
|
+
case CMD.WATCH: {
|
|
656
662
|
return 'nodemon';
|
|
657
|
-
|
|
663
|
+
}
|
|
664
|
+
default: {
|
|
658
665
|
return '';
|
|
666
|
+
}
|
|
659
667
|
}
|
|
660
668
|
}
|
|
661
669
|
|
|
@@ -679,45 +687,56 @@ function copyProjectFiles(project) {
|
|
|
679
687
|
|
|
680
688
|
function getProcessArguments(cmd, project) {
|
|
681
689
|
switch (cmd) {
|
|
682
|
-
case CMD.AUDIT:
|
|
690
|
+
case CMD.AUDIT: {
|
|
683
691
|
return ['audit', '--audit-level=moderate'];
|
|
692
|
+
}
|
|
684
693
|
case CMD.BUILD: {
|
|
685
694
|
const filename = path.join(project.location, 'tsconfig.module.json');
|
|
686
695
|
const configFile = fs.existsSync(filename) ? filename : project.location;
|
|
687
696
|
return ['-p', configFile];
|
|
688
697
|
}
|
|
689
|
-
case CMD.FORMAT:
|
|
698
|
+
case CMD.FORMAT: {
|
|
690
699
|
return ['--write', '**/*.ts'];
|
|
691
|
-
|
|
700
|
+
}
|
|
701
|
+
case CMD.INSTALL: {
|
|
692
702
|
return ['install', '--no-package-lock'];
|
|
693
|
-
|
|
703
|
+
}
|
|
704
|
+
case CMD.LINT: {
|
|
694
705
|
return [project.location + '/**/*.{js,ts}', '--fix'];
|
|
695
|
-
|
|
706
|
+
}
|
|
707
|
+
case CMD.RUN: {
|
|
696
708
|
return [project.location];
|
|
697
|
-
|
|
709
|
+
}
|
|
710
|
+
case CMD.TEST: {
|
|
698
711
|
return project.name === 'all'
|
|
699
712
|
? ['--runInBand', '--coverage', '--forceExit', '--verbose', '--passWithNoTests']
|
|
700
713
|
: ['roots', project.location, '--forceExit', '--verbose', '--passWithNoTests'];
|
|
701
|
-
|
|
714
|
+
}
|
|
715
|
+
case CMD.WATCH: {
|
|
702
716
|
return ['--inspect', project.location];
|
|
703
|
-
|
|
717
|
+
}
|
|
718
|
+
default: {
|
|
704
719
|
return [];
|
|
720
|
+
}
|
|
705
721
|
}
|
|
706
722
|
}
|
|
707
723
|
|
|
708
724
|
function getProcessOptions(cmd, project) {
|
|
709
725
|
switch (cmd) {
|
|
710
|
-
case CMD.INSTALL:
|
|
726
|
+
case CMD.INSTALL: {
|
|
711
727
|
return { cwd: project.location };
|
|
728
|
+
}
|
|
712
729
|
}
|
|
713
730
|
}
|
|
714
731
|
|
|
715
732
|
function getLabel(cmd) {
|
|
716
733
|
switch (cmd) {
|
|
717
|
-
case CMD.RUN:
|
|
734
|
+
case CMD.RUN: {
|
|
718
735
|
return 'Running';
|
|
719
|
-
|
|
736
|
+
}
|
|
737
|
+
default: {
|
|
720
738
|
return `${cmd.charAt(0).toUpperCase()}${cmd.slice(1)}ing`;
|
|
739
|
+
}
|
|
721
740
|
}
|
|
722
741
|
}
|
|
723
742
|
|
|
@@ -737,20 +756,20 @@ function checkIfAll(projectName) {
|
|
|
737
756
|
return false;
|
|
738
757
|
}
|
|
739
758
|
|
|
740
|
-
function readJson(
|
|
759
|
+
function readJson(filePath) {
|
|
741
760
|
return new Promise((resolve, reject) => {
|
|
742
|
-
fs.readFile(
|
|
761
|
+
fs.readFile(filePath, { encoding: 'utf8' }, (error, data) => {
|
|
743
762
|
if (error) return reject(error);
|
|
744
763
|
try {
|
|
745
764
|
return resolve(JSON.parse(data));
|
|
746
|
-
} catch (
|
|
747
|
-
return reject(
|
|
765
|
+
} catch (error_) {
|
|
766
|
+
return reject(error_);
|
|
748
767
|
}
|
|
749
768
|
});
|
|
750
769
|
});
|
|
751
770
|
}
|
|
752
771
|
|
|
753
|
-
function writeJson(
|
|
772
|
+
function writeJson(filePath, data) {
|
|
754
773
|
return new Promise((resolve, reject) => {
|
|
755
774
|
let dataString;
|
|
756
775
|
try {
|
|
@@ -758,7 +777,7 @@ function writeJson(path, data) {
|
|
|
758
777
|
} catch (error) {
|
|
759
778
|
return reject(error);
|
|
760
779
|
}
|
|
761
|
-
fs.writeFile(
|
|
780
|
+
fs.writeFile(filePath, dataString, (error) => {
|
|
762
781
|
if (error) return reject(error);
|
|
763
782
|
return resolve();
|
|
764
783
|
});
|
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.1",
|
|
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": "~
|
|
31
|
-
"chalk": "^5.
|
|
30
|
+
"axios": "~1.1.3",
|
|
31
|
+
"chalk": "^5.1.2",
|
|
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.1",
|
|
36
36
|
"copyfiles": "^2.4.1",
|
|
37
|
-
"dotenv": "^16.0.
|
|
37
|
+
"dotenv": "^16.0.3",
|
|
38
38
|
"ejs": "^3.1.8",
|
|
39
39
|
"execa": "^6.1.0",
|
|
40
|
-
"express": "^4.18.
|
|
40
|
+
"express": "^4.18.2",
|
|
41
41
|
"form-data": "^4.0.0",
|
|
42
42
|
"get-port": "^6.1.2",
|
|
43
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.
|
|
48
|
-
"ora": "^6.1.
|
|
47
|
+
"openid-client": "^5.3.0",
|
|
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
|
-
"@types/express": "^4.17.
|
|
54
|
-
"@types/jest": "^
|
|
55
|
-
"@types/nconf": "^0.10.
|
|
56
|
-
"@types/node": "^
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-plugin-unicorn": "^
|
|
59
|
-
"jest": "^
|
|
60
|
-
"prettier": "^2.
|
|
61
|
-
"typescript": "^4.
|
|
53
|
+
"@types/express": "^4.17.14",
|
|
54
|
+
"@types/jest": "^29.2.2",
|
|
55
|
+
"@types/nconf": "^0.10.3",
|
|
56
|
+
"@types/node": "^18.11.9",
|
|
57
|
+
"eslint": "^8.27.0",
|
|
58
|
+
"eslint-plugin-unicorn": "^44.0.2",
|
|
59
|
+
"jest": "^29.3.1",
|
|
60
|
+
"prettier": "^2.7.1",
|
|
61
|
+
"typescript": "^4.8.4"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": "^14.13.1 || >=16.0.0"
|