putout 32.10.0 → 32.11.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/ChangeLog +12 -0
- package/README.md +1 -0
- package/help.json +1 -0
- package/lib/cli/formatter/choose-formatter.mjs +35 -0
- package/lib/cli/{formatter.js → formatter/formatter.js} +2 -2
- package/lib/cli/index.js +11 -2
- package/package.json +3 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2023.10.31, v32.11.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 2b1600e6b putout: -i: add support of interactive configuration of linting
|
|
5
|
+
|
|
6
|
+
2023.10.30, v32.10.1
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 8768be856 putout: @putout/plugin-putout-config v4.0.0
|
|
10
|
+
- f94be2d97 @putout/plugin-putout-config: convert-boolean-to-string: report
|
|
11
|
+
- 73877cca7 @putout/plugin-putout-config: drop support of 🐊 < 32
|
|
12
|
+
|
|
1
13
|
2023.10.30, v32.10.0
|
|
2
14
|
|
|
3
15
|
fix:
|
package/README.md
CHANGED
|
@@ -166,6 +166,7 @@ Options:
|
|
|
166
166
|
-v, --version output version information and exit
|
|
167
167
|
-f, --format [formatter] use a specific output format, the default is: 'progress-bar' locally and 'dump' on CI
|
|
168
168
|
-s, --staged add staged files when in git repository
|
|
169
|
+
-i, --interactive set lint options using interactive menu
|
|
169
170
|
--fix apply fixes of errors to code
|
|
170
171
|
--fix-count [count = 10] count of fixes rounds
|
|
171
172
|
--rulesdir use additional rules from directory
|
package/help.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"-v, --version ": "output version information and exit",
|
|
4
4
|
"-f, --format [formatter] ": "use a specific output format, the default is: 'progress-bar' locally and 'dump' on CI",
|
|
5
5
|
"-s, --staged ": "add staged files when in git repository",
|
|
6
|
+
"-i, --interactive ": "set lint options using interactive menu",
|
|
6
7
|
"--fix ": "apply fixes of errors to code",
|
|
7
8
|
"--fix-count [count = 10] ": "count of fixes rounds",
|
|
8
9
|
"--rulesdir ": "use additional rules from directory",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {choose as customChoose} from '@putout/cli-choose';
|
|
2
|
+
import {readFile as customReadFile} from 'node:fs/promises';
|
|
3
|
+
import tryCatch from 'try-catch';
|
|
4
|
+
|
|
5
|
+
const {keys} = Object;
|
|
6
|
+
const {parse} = JSON;
|
|
7
|
+
const PREFIX = '@putout/formatter-';
|
|
8
|
+
|
|
9
|
+
const infoPath = new URL('../../../package.json', import.meta.url).pathname;
|
|
10
|
+
|
|
11
|
+
export const chooseFormatter = async ({readFile = customReadFile, choose = customChoose} = {}) => {
|
|
12
|
+
const data = await readFile(infoPath, 'utf8');
|
|
13
|
+
const [error, parsed] = tryCatch(parse, data);
|
|
14
|
+
|
|
15
|
+
if (error)
|
|
16
|
+
return [error];
|
|
17
|
+
|
|
18
|
+
const formatters = getFormatters(parsed);
|
|
19
|
+
|
|
20
|
+
return [null, await choose('Choose formatter', formatters)];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function getFormatters({dependencies}) {
|
|
24
|
+
const formatters = [];
|
|
25
|
+
|
|
26
|
+
for (const name of keys(dependencies)) {
|
|
27
|
+
if (!name.startsWith(PREFIX))
|
|
28
|
+
continue;
|
|
29
|
+
|
|
30
|
+
const shortName = name.replace(PREFIX, '');
|
|
31
|
+
formatters.push(shortName);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return formatters;
|
|
35
|
+
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const tryToCatch = require('try-to-catch');
|
|
4
4
|
const {createAsyncLoader} = require('@putout/engine-loader');
|
|
5
|
-
const {simpleImport} = require('
|
|
5
|
+
const {simpleImport} = require('../simple-import');
|
|
6
6
|
|
|
7
7
|
const {
|
|
8
8
|
NO_FORMATTER,
|
|
9
9
|
CANNOT_LOAD_FORMATTER,
|
|
10
|
-
} = require('
|
|
10
|
+
} = require('../exit-codes');
|
|
11
11
|
|
|
12
12
|
const {isArray} = Array;
|
|
13
13
|
const maybeArray = (a) => isArray(a) ? a : [a, {}];
|
package/lib/cli/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const {
|
|
|
44
44
|
} = require('./exit-codes');
|
|
45
45
|
|
|
46
46
|
const {isSupported} = supportedFiles;
|
|
47
|
-
const getFormatter = nanomemoize(require('./formatter').getFormatter);
|
|
47
|
+
const getFormatter = nanomemoize(require('./formatter/formatter').getFormatter);
|
|
48
48
|
|
|
49
49
|
const cwd = process.cwd();
|
|
50
50
|
const {PUTOUT_FILES = '', PUTOUT_PRINTER} = process.env;
|
|
@@ -83,6 +83,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
|
|
|
83
83
|
'flow',
|
|
84
84
|
'config',
|
|
85
85
|
'staged',
|
|
86
|
+
'interactive',
|
|
86
87
|
],
|
|
87
88
|
number: ['fix-count'],
|
|
88
89
|
string: [
|
|
@@ -100,6 +101,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
|
|
|
100
101
|
format: 'f',
|
|
101
102
|
staged: 's',
|
|
102
103
|
transform: 't',
|
|
104
|
+
interactive: 'i',
|
|
103
105
|
},
|
|
104
106
|
default: {
|
|
105
107
|
ci: true,
|
|
@@ -168,6 +170,13 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
|
|
|
168
170
|
return exit();
|
|
169
171
|
}
|
|
170
172
|
|
|
173
|
+
let newFormatter;
|
|
174
|
+
|
|
175
|
+
if (args.interactive) {
|
|
176
|
+
const {chooseFormatter} = await simpleImport('./formatter/choose-formatter.mjs');
|
|
177
|
+
[, newFormatter] = await chooseFormatter();
|
|
178
|
+
}
|
|
179
|
+
|
|
171
180
|
if (args.help) {
|
|
172
181
|
const help = require('./help');
|
|
173
182
|
log(help());
|
|
@@ -221,7 +230,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
|
|
|
221
230
|
processors = defaultProcessors,
|
|
222
231
|
} = config;
|
|
223
232
|
|
|
224
|
-
const [currentFormat, formatterOptions] = await getFormatter(format || formatter, exit);
|
|
233
|
+
const [currentFormat, formatterOptions] = await getFormatter(newFormatter || format || formatter, exit);
|
|
225
234
|
const [error, processorRunners] = await tryToCatch(getProcessorRunners, processors, simpleImport);
|
|
226
235
|
|
|
227
236
|
if (error)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.11.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@putout/babel": "^1.0.0",
|
|
47
47
|
"@putout/cli-cache": "^2.0.1",
|
|
48
|
+
"@putout/cli-choose": "^1.0.0",
|
|
48
49
|
"@putout/cli-keypress": "^2.0.0",
|
|
49
50
|
"@putout/cli-match": "^2.0.0",
|
|
50
51
|
"@putout/cli-ruler": "^3.0.0",
|
|
@@ -120,7 +121,7 @@
|
|
|
120
121
|
"@putout/plugin-package-json": "^5.0.0",
|
|
121
122
|
"@putout/plugin-promises": "^13.0.0",
|
|
122
123
|
"@putout/plugin-putout": "^15.0.0",
|
|
123
|
-
"@putout/plugin-putout-config": "^
|
|
124
|
+
"@putout/plugin-putout-config": "^4.0.0",
|
|
124
125
|
"@putout/plugin-regexp": "^8.0.0",
|
|
125
126
|
"@putout/plugin-remove-console": "^6.0.0",
|
|
126
127
|
"@putout/plugin-remove-constant-conditions": "^4.0.0",
|