Skip to content

Commit 84f9dae

Browse files
committed
BREAKING_CHANGE: update deps to latest;
BREAKING_CHANGE: enable discriminator mapping; BREAKING_CHANGE: add eslint
1 parent b5307d1 commit 84f9dae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+4712
-1816
lines changed

.prettierignore renamed to .eslintignore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
.eslintrc
2+
node_modules
3+
.husky
4+
.vscode
5+
swagger-test-cli
6+
tests
7+
*.ejs
8+
*.eta
9+
.kube
10+
.idea
11+
*.json
12+
.eslintrc.js
13+
vite.config.ts
114
tests/**/*.ts
215
tests/**/schema.js
316
tests/**/schema.ts
@@ -7,7 +20,6 @@ swagger-test-cli.*
720
templates
821
*.md
922
.github
10-
node_modules
1123
.openapi-generator
1224
.vscode
1325
assets

.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
parserOptions: {
3+
"ecmaVersion": "latest"
4+
},
5+
env: {
6+
"node": true,
7+
"es6": true
8+
},
9+
extends: [
10+
'eslint:recommended',
11+
'plugin:prettier/recommended',
12+
],
13+
plugins: [
14+
'prettier',
15+
],
16+
rules: {
17+
'prettier/prettier': [
18+
'error',
19+
{
20+
endOfLine: 'auto',
21+
printWidth: 80,
22+
tabWidth: 2,
23+
trailingComma: 'all',
24+
semi: true,
25+
singleQuote: true,
26+
},
27+
],
28+
},
29+
};

.husky/post-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
git update-index -g

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run lint:fix

.ncurc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"upgrade": true,
3+
"reject": [
4+
"nanoid",
5+
"eta"
6+
]
7+
}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.16.0
1+
18.16.1

.prettierrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ Features:
532532
name?: string;
533533
path?: string;
534534
}) => string
535-
formatTSContent: (content: string) => string;
535+
formatTSContent: (content: string) => Promise<string>;
536536

537537

538538
// ...

cli/constants.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const root_command = Symbol("root");
2-
const skip_command = Symbol("skip");
1+
const root_command = Symbol('root');
2+
const skip_command = Symbol('skip');
33

4-
const reservedOptions = ["version", "help"];
4+
const reservedOptions = ['version', 'help'];
55

66
module.exports = {
77
root_command,

cli/execute.js

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
const _ = require("lodash");
2-
const { root_command, skip_command } = require("./constants");
3-
const { parseArgs } = require("./parse-args");
4-
const didYouMean = require("didyoumean");
1+
const _ = require('lodash');
2+
const { root_command, skip_command } = require('./constants');
3+
const { parseArgs } = require('./parse-args');
4+
const didYouMean = require('didyoumean');
55

66
didYouMean.threshold = 0.5;
77

8+
// eslint-disable-next-line no-unused-vars
89
const execute = (params, commands, instance) => {
910
const args = parseArgs(params.args, params.from);
1011

@@ -17,7 +18,9 @@ const execute = (params, commands, instance) => {
1718
}
1819

1920
if (!usageOptions.length && command.name === root_command) {
20-
usageOptions.push(command.options.find((option) => option.flags.name === "help"));
21+
usageOptions.push(
22+
command.options.find((option) => option.flags.name === 'help'),
23+
);
2124
}
2225

2326
const operationOptions = usageOptions.filter((option) => option.operation);
@@ -29,7 +32,7 @@ const execute = (params, commands, instance) => {
2932
});
3033
return;
3134
} else {
32-
let error = "";
35+
let error = '';
3336

3437
const processUserOptionData = (userOption, option) => {
3538
if (userOption) {
@@ -40,7 +43,7 @@ const execute = (params, commands, instance) => {
4043
if (option.flags.value) {
4144
if (option.flags.value.variadic) {
4245
return data.reduce((acc, d) => {
43-
acc.push(...d.split(",").map(option.flags.value.formatter));
46+
acc.push(...d.split(',').map(option.flags.value.formatter));
4447
return acc;
4548
}, []);
4649
} else {
@@ -55,7 +58,9 @@ const execute = (params, commands, instance) => {
5558
const parsedOptionsObject = command.options.reduce((acc, option) => {
5659
if (error) return acc;
5760

58-
const userOption = usageOptions.find((o) => o.flags.name === option.flags.name);
61+
const userOption = usageOptions.find(
62+
(o) => o.flags.name === option.flags.name,
63+
);
5964

6065
if (!userOption && option.required) {
6166
error = `required option '${option.flags.raw}' not specified`;
@@ -65,7 +70,9 @@ const execute = (params, commands, instance) => {
6570
const flagValue = processUserOptionData(userOption, option);
6671
if (!option.operation) {
6772
const internal = option.internal || {};
68-
acc[internal.name || option.flags.name] = internal.formatter ? internal.formatter(flagValue) : flagValue;
73+
acc[internal.name || option.flags.name] = internal.formatter
74+
? internal.formatter(flagValue)
75+
: flagValue;
6976
}
7077

7178
return acc;
@@ -87,7 +94,7 @@ const processArgs = (commands, args) => {
8794
let command = null;
8895
let usageOptions = [];
8996
let walkingOption = null;
90-
let error = "";
97+
let error = '';
9198

9299
let allFlagKeys = [];
93100

@@ -97,33 +104,44 @@ const processArgs = (commands, args) => {
97104
if (i === 0) {
98105
command = commands[arg];
99106

100-
if (!command && !arg.startsWith("-")) {
107+
if (!command && !arg.startsWith('-')) {
101108
const tip = didYouMean(arg, _.keys(commands));
102-
error = `unknown command ${arg}${tip ? `\n(Did you mean ${tip} ?)` : ""}`;
109+
error = `unknown command ${arg}${
110+
tip ? `\n(Did you mean ${tip} ?)` : ''
111+
}`;
103112
} else if (!command) {
104113
command = commands[root_command];
105114
}
106115

107116
if (command) {
108-
allFlagKeys = command.options.reduce((acc, option) => [...acc, ...option.flags.keys], []);
117+
allFlagKeys = command.options.reduce(
118+
(acc, option) => [...acc, ...option.flags.keys],
119+
[],
120+
);
109121
}
110122
}
111123

112124
if (error) return;
113125

114-
if (arg.startsWith("-")) {
115-
const option = command.options.find((option) => option.flags.keys.includes(arg));
126+
if (arg.startsWith('-')) {
127+
const option = command.options.find((option) =>
128+
option.flags.keys.includes(arg),
129+
);
116130

117131
if (!option) {
118132
const tip = didYouMean(arg, allFlagKeys);
119-
error = `unknown option ${arg}${tip ? `\n(Did you mean ${tip} ?)` : ""}`;
133+
error = `unknown option ${arg}${
134+
tip ? `\n(Did you mean ${tip} ?)` : ''
135+
}`;
120136
}
121137

122138
if (option) {
123139
if (walkingOption && walkingOption.flags.name === option.flags.name) {
124140
return;
125141
}
126-
const existedOption = usageOptions.find((o) => o.flags.name === option.flags.name);
142+
const existedOption = usageOptions.find(
143+
(o) => o.flags.name === option.flags.name,
144+
);
127145
if (existedOption) {
128146
walkingOption = existedOption;
129147
} else {

0 commit comments

Comments
 (0)