Skip to content

Commit 112c341

Browse files
authored
feat: upgrade to commander.js v8 (#307)
1 parent d397a8e commit 112c341

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@api-platform/api-doc-parser": "^0.12.0",
3939
"@babel/runtime": "^7.0.0",
4040
"chalk": "^4.1.0",
41-
"commander": "^6.2.1",
41+
"commander": "^8.2.0",
4242
"handlebars": "^4.0.12",
4343
"handlebars-helpers": "^0.10.0",
4444
"isomorphic-fetch": "^3.0.0",

src/index.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ if (
5555
program.help();
5656
}
5757

58+
const options = program.opts();
59+
5860
const entrypoint =
5961
program.args[0] || process.env.API_PLATFORM_CLIENT_GENERATOR_ENTRYPOINT;
6062
const outputDirectory =
@@ -64,29 +66,29 @@ const entrypointWithSlash = entrypoint.endsWith("/")
6466
? entrypoint
6567
: entrypoint + "/";
6668

67-
const generator = generators(program.generator)({
68-
hydraPrefix: program.hydraPrefix,
69-
templateDirectory: program.templateDirectory,
69+
const generator = generators(options.generator)({
70+
hydraPrefix: options.hydraPrefix,
71+
templateDirectory: options.templateDirectory,
7072
});
71-
const resourceToGenerate = program.resource
72-
? program.resource.toLowerCase()
73+
const resourceToGenerate = options.resource
74+
? options.resource.toLowerCase()
7375
: null;
74-
const serverPath = program.serverPath ? program.serverPath.toLowerCase() : null;
76+
const serverPath = options.serverPath ? options.serverPath.toLowerCase() : null;
7577

7678
const parser = (entrypointWithSlash) => {
7779
const options = {};
78-
if (program.username && program.password) {
80+
if (options.username && options.password) {
7981
const encoded = Buffer.from(
80-
`${program.username}:${program.password}`
82+
`${options.username}:${options.password}`
8183
).toString("base64");
8284
options.headers = new Headers();
8385
options.headers.set("Authorization", `Basic ${encoded}`);
8486
}
85-
if (program.bearer) {
87+
if (options.bearer) {
8688
options.headers = new Headers();
87-
options.headers.set("Authorization", `Bearer ${program.bearer}`);
89+
options.headers.set("Authorization", `Bearer ${options.bearer}`);
8890
}
89-
switch (program.format) {
91+
switch (options.format) {
9092
case "swagger": // deprecated
9193
case "openapi2":
9294
return parseSwaggerDocumentation(entrypointWithSlash);

yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,11 +2102,16 @@ commander@^4.0.1:
21022102
resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068"
21032103
integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==
21042104

2105-
commander@^6.2.0, commander@^6.2.1:
2105+
commander@^6.2.0:
21062106
version "6.2.1"
21072107
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
21082108
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==
21092109

2110+
commander@^8.2.0:
2111+
version "8.2.0"
2112+
resolved "https://registry.yarnpkg.com/commander/-/commander-8.2.0.tgz#37fe2bde301d87d47a53adeff8b5915db1381ca8"
2113+
integrity sha512-LLKxDvHeL91/8MIyTAD5BFMNtoIwztGPMiM/7Bl8rIPmHCZXRxmSWr91h57dpOpnQ6jIUqEWdXE/uBYMfiVZDA==
2114+
21102115
compare-versions@^3.6.0:
21112116
version "3.6.0"
21122117
resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.6.0.tgz#1a5689913685e5a87637b8d3ffca75514ec41d62"

0 commit comments

Comments
 (0)