putout 41.0.7 → 41.0.9
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 +34 -0
- package/lib/cli/{get-files.js → get-files.mjs} +29 -17
- package/lib/cli/get-options.js +11 -2
- package/lib/cli/index.js +23 -9
- package/lib/cli/runner/runner.js +27 -6
- package/lib/cli/runner/writer.js +9 -2
- package/lib/loader/loader.mjs +1 -0
- package/package.json +3 -3
package/ChangeLog
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
2025.12.26, v41.0.9
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 8ea3d2aff putout: @putout/cli-staged v2.0.0
|
|
5
|
+
- 9191746f8 @putout/cli-staged: migrate to ESM
|
|
6
|
+
- ebcefac19 @putout/cli-staged: get rid of mock-require
|
|
7
|
+
- d91e55f21 @putout/plugin-eslint: remove-parser-options: typescript: false positive
|
|
8
|
+
- 710c5f16d @putout/plugin-nodejs: apply-global-this: add
|
|
9
|
+
- 37a32c478 @putout/plugin-filesystem: remove-ds-store-file: add
|
|
10
|
+
- e1c44e536 @putout/plugin-nodejs: declare: buffer: add
|
|
11
|
+
- 0acc4ffc7 @putout/plugin-variables: remove-unused: ArrayPattern: improve support
|
|
12
|
+
- f9d0d6ac5 @putout/plugin-regexp: remove-useless-escape: ^
|
|
13
|
+
- 4daf1bb0f @putout/plugin-regexp: apply-starts-with: \n
|
|
14
|
+
- 62c8c8b28 @putout/plugin-regexp: apply-ends-with: dot
|
|
15
|
+
- 88f6ec881 @putout/plugin-regexp: apply-starts-with: dot
|
|
16
|
+
- 6d4099d45 eslint-plugin-putout: @putout/eslint-config v13.0.0
|
|
17
|
+
- 397531d6a eslint-plugin-putout: rm no-debugger, no-unused-vars
|
|
18
|
+
- 1ac6e8626 @putout/eslint-config: no-debugger, no-unused-vars: off
|
|
19
|
+
- 9e83fcb4d variables: remove-unused: ArrayPattern inside ArrayPattern: add support
|
|
20
|
+
- fa2b4d35e deno config: add
|
|
21
|
+
- b9a7eb0e0 @putout/engine-parser: hermes-parser v0.33.0
|
|
22
|
+
- bcae5b9ce putout: @putout/engine-reporter v6.0.0
|
|
23
|
+
- 333852573 @putout/engine-reporter: get rid of mock-require
|
|
24
|
+
- a3432f746 putout: cli: get-options: putout --no-config: do not exit when no plugins passed
|
|
25
|
+
- 4a45df8f2 @putout/engine-reporter: do not exit when no plugins
|
|
26
|
+
|
|
27
|
+
2025.12.20, v41.0.8
|
|
28
|
+
|
|
29
|
+
feature:
|
|
30
|
+
- 9802375a2 putout: @putout/engine-reporter v6.0.0
|
|
31
|
+
- 0b686ec56 @putout/engine-reporter: get rid of mock-require
|
|
32
|
+
- e899de3bf putout: cli: get-options: putout --no-config: do not exit when no plugins passed
|
|
33
|
+
- bf9b31cfe @putout/engine-reporter: do not exit when no plugins
|
|
34
|
+
|
|
1
35
|
2025.12.19, v41.0.7
|
|
2
36
|
|
|
3
37
|
fix:
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const fastGlob = require('fast-glob');
|
|
7
|
-
const tryToCatch = require('try-to-catch');
|
|
8
|
-
|
|
9
|
-
const {getSupportedGlob} = require('./supported-files');
|
|
1
|
+
import {normalize} from 'node:path';
|
|
2
|
+
import {lstat as _lstat} from 'node:fs/promises';
|
|
3
|
+
import _fastGlob from 'fast-glob';
|
|
4
|
+
import tryToCatch from 'try-to-catch';
|
|
5
|
+
import {getSupportedGlob as _getSupportedGlob} from './supported-files.js';
|
|
10
6
|
|
|
11
7
|
const rmDuplicates = (a) => Array.from(new Set(a));
|
|
12
8
|
const unixifyPath = (a) => !a.includes('\\') ? a : a.replace(/\\/g, '/');
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
export const getFiles = async (args, options, overrides = {}) => {
|
|
11
|
+
const {
|
|
12
|
+
fastGlob = _fastGlob,
|
|
13
|
+
lstat = _lstat,
|
|
14
|
+
getSupportedGlob = _getSupportedGlob,
|
|
15
|
+
} = overrides;
|
|
16
|
+
|
|
17
|
+
return await tryToCatch(getFilesProcessor, args, options, {
|
|
18
|
+
fastGlob,
|
|
19
|
+
lstat,
|
|
20
|
+
getSupportedGlob,
|
|
21
|
+
});
|
|
16
22
|
};
|
|
17
23
|
|
|
18
|
-
async function
|
|
19
|
-
const promises = args.map(addExt(options));
|
|
24
|
+
async function getFilesProcessor(args, options, overrides) {
|
|
25
|
+
const promises = args.map(addExt(options, overrides));
|
|
20
26
|
const files = await Promise.all(promises);
|
|
21
27
|
const mergedFiles = files.flat();
|
|
22
28
|
|
|
@@ -28,10 +34,16 @@ const globOptions = {
|
|
|
28
34
|
dot: true,
|
|
29
35
|
};
|
|
30
36
|
|
|
31
|
-
const addExt = (options) => async function addExt(a) {
|
|
37
|
+
const addExt = (options, overrides = {}) => async function addExt(a) {
|
|
38
|
+
const {
|
|
39
|
+
fastGlob,
|
|
40
|
+
lstat,
|
|
41
|
+
getSupportedGlob,
|
|
42
|
+
} = overrides;
|
|
43
|
+
|
|
32
44
|
const [[e], files] = await Promise.all([
|
|
33
45
|
tryToCatch(lstat, a),
|
|
34
|
-
safeGlob(a, {
|
|
46
|
+
safeGlob(a, fastGlob, {
|
|
35
47
|
onlyFiles: false,
|
|
36
48
|
...options,
|
|
37
49
|
}),
|
|
@@ -48,7 +60,7 @@ const addExt = (options) => async function addExt(a) {
|
|
|
48
60
|
|
|
49
61
|
if (info.isDirectory()) {
|
|
50
62
|
const glob = getSupportedGlob(file);
|
|
51
|
-
promises.push(await safeGlob(glob, options));
|
|
63
|
+
promises.push(await safeGlob(glob, fastGlob, options));
|
|
52
64
|
continue;
|
|
53
65
|
}
|
|
54
66
|
|
|
@@ -69,7 +81,7 @@ function throwNotFound(a) {
|
|
|
69
81
|
throw Error(`No files matching the pattern '${a}' were found`);
|
|
70
82
|
}
|
|
71
83
|
|
|
72
|
-
async function safeGlob(glob, options) {
|
|
84
|
+
async function safeGlob(glob, fastGlob, options) {
|
|
73
85
|
const result = await fastGlob(unixifyPath(glob), {
|
|
74
86
|
...options,
|
|
75
87
|
...globOptions,
|
package/lib/cli/get-options.js
CHANGED
|
@@ -4,7 +4,7 @@ const process = require('node:process');
|
|
|
4
4
|
const {join, dirname} = require('node:path');
|
|
5
5
|
|
|
6
6
|
const buildPlugins = require('./build-plugins');
|
|
7
|
-
const
|
|
7
|
+
const _parseOptions = require('../parse-options');
|
|
8
8
|
|
|
9
9
|
const {assign} = Object;
|
|
10
10
|
const {env} = process;
|
|
@@ -19,7 +19,16 @@ PUTOUT_CONFIG_FILE && assign(maybeConfig, require(join(
|
|
|
19
19
|
PUTOUT_CONFIG_FILE,
|
|
20
20
|
)));
|
|
21
21
|
|
|
22
|
-
module.exports = (
|
|
22
|
+
module.exports = (overrides = {}) => {
|
|
23
|
+
const {
|
|
24
|
+
noConfig,
|
|
25
|
+
plugins = [],
|
|
26
|
+
name,
|
|
27
|
+
transform,
|
|
28
|
+
rulesdir,
|
|
29
|
+
parseOptions = _parseOptions,
|
|
30
|
+
} = overrides;
|
|
31
|
+
|
|
23
32
|
const transformPlugins = buildPlugins(transform);
|
|
24
33
|
|
|
25
34
|
if (noConfig)
|
package/lib/cli/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const {nanomemoize} = require('nano-memoize');
|
|
|
8
8
|
const tryCatch = require('try-catch');
|
|
9
9
|
const wraptile = require('wraptile');
|
|
10
10
|
const fullstore = require('fullstore');
|
|
11
|
+
const _cliStaged = require('@putout/cli-staged');
|
|
11
12
|
|
|
12
13
|
const {
|
|
13
14
|
getFilePatterns,
|
|
@@ -15,13 +16,14 @@ const {
|
|
|
15
16
|
defaultProcessors,
|
|
16
17
|
} = require('@putout/engine-processor');
|
|
17
18
|
|
|
19
|
+
const _initReport = require('@putout/engine-reporter/report');
|
|
18
20
|
const {keypress: _keypress} = require('@putout/cli-keypress');
|
|
19
21
|
|
|
20
22
|
const supportedFiles = require('./supported-files');
|
|
21
|
-
const
|
|
23
|
+
const _getOptions = require('./get-options');
|
|
22
24
|
const {argvConfig, parseArgs} = require('./parse-args');
|
|
23
25
|
|
|
24
|
-
const getFiles = require('./get-files');
|
|
26
|
+
const {getFiles: _getFiles} = require('./get-files.mjs');
|
|
25
27
|
const {version, dependencies} = require('../../package.json');
|
|
26
28
|
const {formatter: defaultFormatter} = require('../../putout.json');
|
|
27
29
|
const {simpleImport} = require('./simple-import');
|
|
@@ -46,11 +48,12 @@ const {
|
|
|
46
48
|
const noop = () => {};
|
|
47
49
|
const {keys} = Object;
|
|
48
50
|
const {isSupported} = supportedFiles;
|
|
49
|
-
const
|
|
51
|
+
const _getFormatter = nanomemoize(require('@putout/engine-reporter/formatter').getFormatter);
|
|
50
52
|
|
|
51
53
|
const cwd = process.cwd();
|
|
52
|
-
const {
|
|
53
|
-
|
|
54
|
+
const {env} = process;
|
|
55
|
+
|
|
56
|
+
const getEnvNames = () => !env.PUTOUT_FILES ? [] : env.PUTOUT_FILES.split(',');
|
|
54
57
|
|
|
55
58
|
const getExitCode = (wasStop) => wasStop() ? WAS_STOP : OK;
|
|
56
59
|
const isStr = (a) => typeof a === 'string';
|
|
@@ -76,6 +79,13 @@ module.exports = async (overrides = {}) => {
|
|
|
76
79
|
writeFile,
|
|
77
80
|
trace = noop,
|
|
78
81
|
keypress = _keypress,
|
|
82
|
+
getOptions = _getOptions,
|
|
83
|
+
getFiles = _getFiles,
|
|
84
|
+
cliStaged = _cliStaged,
|
|
85
|
+
cliCache,
|
|
86
|
+
initProcessFile,
|
|
87
|
+
initReport = _initReport,
|
|
88
|
+
getFormatter = _getFormatter,
|
|
79
89
|
} = overrides;
|
|
80
90
|
|
|
81
91
|
const isStop = parseIsStop(overrides.isStop || noop, {
|
|
@@ -212,7 +222,7 @@ module.exports = async (overrides = {}) => {
|
|
|
212
222
|
const stagedNames = [];
|
|
213
223
|
|
|
214
224
|
if (staged) {
|
|
215
|
-
const {get} =
|
|
225
|
+
const {get} = cliStaged;
|
|
216
226
|
const {findUp} = await simpleImport('find-up');
|
|
217
227
|
|
|
218
228
|
const [error, names] = await tryToCatch(get, {
|
|
@@ -229,7 +239,7 @@ module.exports = async (overrides = {}) => {
|
|
|
229
239
|
const globFiles = [
|
|
230
240
|
...stagedNames,
|
|
231
241
|
...args._.map(String),
|
|
232
|
-
...
|
|
242
|
+
...getEnvNames(),
|
|
233
243
|
];
|
|
234
244
|
|
|
235
245
|
const [e, names] = await getFiles(globFiles, {
|
|
@@ -247,7 +257,7 @@ module.exports = async (overrides = {}) => {
|
|
|
247
257
|
if (noFiles)
|
|
248
258
|
return exit();
|
|
249
259
|
|
|
250
|
-
const {createCache} = await simpleImport('@putout/cli-cache');
|
|
260
|
+
const {createCache} = cliCache || await simpleImport('@putout/cli-cache');
|
|
251
261
|
|
|
252
262
|
const fileCache = await createCache({
|
|
253
263
|
version,
|
|
@@ -273,7 +283,10 @@ module.exports = async (overrides = {}) => {
|
|
|
273
283
|
plugins,
|
|
274
284
|
};
|
|
275
285
|
|
|
286
|
+
const report = initReport();
|
|
287
|
+
|
|
276
288
|
const {places, exited} = await run({
|
|
289
|
+
report,
|
|
277
290
|
processorRunners,
|
|
278
291
|
trace,
|
|
279
292
|
fix,
|
|
@@ -294,6 +307,7 @@ module.exports = async (overrides = {}) => {
|
|
|
294
307
|
noConfig,
|
|
295
308
|
plugins,
|
|
296
309
|
transform,
|
|
310
|
+
initProcessFile,
|
|
297
311
|
});
|
|
298
312
|
|
|
299
313
|
if (exited)
|
|
@@ -313,7 +327,7 @@ module.exports = async (overrides = {}) => {
|
|
|
313
327
|
}
|
|
314
328
|
|
|
315
329
|
if (fix && staged) {
|
|
316
|
-
const {set} =
|
|
330
|
+
const {set} = cliStaged;
|
|
317
331
|
const {findUp} = await simpleImport('find-up');
|
|
318
332
|
|
|
319
333
|
const stagedNames = await set({
|
package/lib/cli/runner/runner.js
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const initProcessFile = require('@putout/cli-process-file');
|
|
3
|
+
const _initProcessFile = require('@putout/cli-process-file');
|
|
6
4
|
const {runWriter} = require('./writer.js');
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
module.exports.run = async (overrides) => {
|
|
7
|
+
const {
|
|
8
|
+
transform,
|
|
9
|
+
plugins,
|
|
10
|
+
noConfig,
|
|
11
|
+
readFile,
|
|
12
|
+
writeFile,
|
|
13
|
+
exit,
|
|
14
|
+
isStop,
|
|
15
|
+
wasStop,
|
|
16
|
+
names,
|
|
17
|
+
write,
|
|
18
|
+
log,
|
|
19
|
+
rulesdir,
|
|
20
|
+
fix,
|
|
21
|
+
processorRunners,
|
|
22
|
+
fileCache,
|
|
23
|
+
currentFormat,
|
|
24
|
+
formatterOptions,
|
|
25
|
+
options,
|
|
26
|
+
raw,
|
|
27
|
+
trace,
|
|
28
|
+
initProcessFile = _initProcessFile,
|
|
29
|
+
report,
|
|
30
|
+
} = overrides;
|
|
31
|
+
|
|
11
32
|
const processFile = initProcessFile(options);
|
|
12
33
|
const {length} = names;
|
|
13
34
|
const places = [];
|
package/lib/cli/runner/writer.js
CHANGED
|
@@ -11,8 +11,15 @@ const {runReader} = require('./reader.js');
|
|
|
11
11
|
|
|
12
12
|
const isParser = (rule) => rule.startsWith('parser');
|
|
13
13
|
const isParsingError = ({rule}) => isParser(rule);
|
|
14
|
-
|
|
15
|
-
const
|
|
14
|
+
|
|
15
|
+
const chooseName = (name, resolvedName) => !isIDE() ? name : resolvedName;
|
|
16
|
+
|
|
17
|
+
const isIDE = () => {
|
|
18
|
+
if (/JetBrains/.test(env.TERMINAL_EMULATOR))
|
|
19
|
+
return true;
|
|
20
|
+
|
|
21
|
+
return env.TERM_PROGRAM === 'vscode';
|
|
22
|
+
};
|
|
16
23
|
|
|
17
24
|
const createFormatterProxy = (options) => {
|
|
18
25
|
return new Proxy(options, {
|
package/lib/loader/loader.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "41.0.
|
|
3
|
+
"version": "41.0.9",
|
|
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",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"@putout/cli-match": "^2.0.0",
|
|
59
59
|
"@putout/cli-process-file": "^4.0.0",
|
|
60
60
|
"@putout/cli-ruler": "^4.0.0",
|
|
61
|
-
"@putout/cli-staged": "^
|
|
61
|
+
"@putout/cli-staged": "^2.0.0",
|
|
62
62
|
"@putout/cli-validate-args": "^2.0.0",
|
|
63
63
|
"@putout/compare": "^19.0.0",
|
|
64
64
|
"@putout/engine-loader": "^16.0.0",
|
|
65
65
|
"@putout/engine-parser": "^15.0.1",
|
|
66
66
|
"@putout/engine-processor": "^14.0.0",
|
|
67
|
-
"@putout/engine-reporter": "^
|
|
67
|
+
"@putout/engine-reporter": "^6.0.0",
|
|
68
68
|
"@putout/engine-runner": "^26.0.0",
|
|
69
69
|
"@putout/formatter-codeframe": "^10.0.0",
|
|
70
70
|
"@putout/formatter-dump": "^6.0.0",
|