putout 41.1.2 → 41.1.4
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 +16 -0
- package/bin/debugger-exit.mjs +2 -2
- package/bin/putout.mjs +1 -1
- package/lib/cli/chalk.mjs +2 -10
- package/lib/cli/exit.mjs +1 -3
- package/lib/cli/get-options.js +14 -8
- package/lib/cli/{index.js → index.mjs} +39 -33
- package/lib/cli/runner/reader.js +15 -2
- package/lib/cli/runner/runner.js +2 -0
- package/lib/cli/runner/writer.js +2 -0
- package/lib/cli/supported-files.js +6 -0
- package/lib/putout.js +0 -1
- package/package.json +7 -5
package/ChangeLog
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
2025.12.30, v41.1.4
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- bc7b89136 putout: cli: migrate to ESM
|
|
5
|
+
|
|
6
|
+
2025.12.30, v41.1.3
|
|
7
|
+
|
|
8
|
+
fix:
|
|
9
|
+
- fb4ff3ca0 @putout/engine-reporter: get rid of cjs
|
|
10
|
+
|
|
11
|
+
feature:
|
|
12
|
+
- 1d1490153 putout: @putout/engine-reporter v8.0.2
|
|
13
|
+
- a849259bd @putout/test: initReport from @putout/engine-reporter
|
|
14
|
+
- d529678b3 @putout/engine-reporter: formatter: migrate to ESM
|
|
15
|
+
- 74b5650d0 @putout/plugin-esm: apply-namespace-import-to-file: improve errors handling
|
|
16
|
+
|
|
1
17
|
2025.12.29, v41.1.2
|
|
2
18
|
|
|
3
19
|
feature:
|
package/bin/debugger-exit.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {bgBlueBright} from '../lib/cli/chalk.mjs';
|
|
2
2
|
|
|
3
3
|
export const onDebuggerExit = ({log, process, inspector}) => {
|
|
4
4
|
const {pid} = process;
|
|
@@ -11,7 +11,7 @@ export const onDebuggerExit = ({log, process, inspector}) => {
|
|
|
11
11
|
return;
|
|
12
12
|
|
|
13
13
|
inspector.close();
|
|
14
|
-
log(
|
|
14
|
+
log(bgBlueBright(`node --inspect: 'kill ${pid}'`));
|
|
15
15
|
process.kill(pid);
|
|
16
16
|
});
|
|
17
17
|
};
|
package/bin/putout.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import {createTrace} from './trace.mjs';
|
|
|
8
8
|
import {createIsStop} from './is-stop.mjs';
|
|
9
9
|
import {createWrite} from './write.mjs';
|
|
10
10
|
import {createCommunication} from './communication.mjs';
|
|
11
|
-
import cli from '../lib/cli/index.
|
|
11
|
+
import cli from '../lib/cli/index.mjs';
|
|
12
12
|
import {parseArgs} from '../lib/cli/parse-args.js';
|
|
13
13
|
import {createExit} from '../lib/cli/exit.mjs';
|
|
14
14
|
import {onDebuggerExit} from './debugger-exit.mjs';
|
package/lib/cli/chalk.mjs
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import {styleText} from 'node:util';
|
|
2
2
|
|
|
3
|
-
const red = (a) => styleText('red', a);
|
|
4
|
-
|
|
5
|
-
const bgBlueBright = (a) => styleText('bgBlueBright', a);
|
|
6
|
-
|
|
7
|
-
const chalk = {
|
|
8
|
-
red,
|
|
9
|
-
bgBlueBright,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default chalk;
|
|
3
|
+
export const red = (a) => styleText('red', a);
|
|
4
|
+
export const bgBlueBright = (a) => styleText('bgBlueBright', a);
|
package/lib/cli/exit.mjs
CHANGED
package/lib/cli/get-options.js
CHANGED
|
@@ -8,17 +8,22 @@ const _parseOptions = require('../parse-options');
|
|
|
8
8
|
|
|
9
9
|
const {assign} = Object;
|
|
10
10
|
const {env} = process;
|
|
11
|
-
const {PUTOUT_CONFIG_FILE} = env;
|
|
12
11
|
|
|
13
|
-
const
|
|
14
|
-
|
|
12
|
+
const getMaybeConfig = () => {
|
|
13
|
+
const config = {
|
|
14
|
+
plugins: [],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const {PUTOUT_CONFIG_FILE} = env;
|
|
18
|
+
|
|
19
|
+
PUTOUT_CONFIG_FILE && assign(config, require(join(
|
|
20
|
+
process.cwd(),
|
|
21
|
+
PUTOUT_CONFIG_FILE,
|
|
22
|
+
)));
|
|
23
|
+
|
|
24
|
+
return config;
|
|
15
25
|
};
|
|
16
26
|
|
|
17
|
-
PUTOUT_CONFIG_FILE && assign(maybeConfig, require(join(
|
|
18
|
-
process.cwd(),
|
|
19
|
-
PUTOUT_CONFIG_FILE,
|
|
20
|
-
)));
|
|
21
|
-
|
|
22
27
|
module.exports = (overrides = {}) => {
|
|
23
28
|
const {
|
|
24
29
|
noConfig,
|
|
@@ -30,6 +35,7 @@ module.exports = (overrides = {}) => {
|
|
|
30
35
|
} = overrides;
|
|
31
36
|
|
|
32
37
|
const transformPlugins = buildPlugins(transform);
|
|
38
|
+
const maybeConfig = getMaybeConfig();
|
|
33
39
|
|
|
34
40
|
if (noConfig)
|
|
35
41
|
return {
|
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import {createRequire} from 'node:module';
|
|
3
|
+
import tryToCatch from 'try-to-catch';
|
|
4
|
+
import {isCI as _isCI} from 'ci-info';
|
|
5
|
+
import tryCatch from 'try-catch';
|
|
6
|
+
import wraptile from 'wraptile';
|
|
7
|
+
import fullstore from 'fullstore';
|
|
8
|
+
import nano from 'nano-memoize';
|
|
9
|
+
import * as _cliStaged from '@putout/cli-staged';
|
|
10
|
+
import {initReport as _initReport} from '@putout/engine-reporter/report';
|
|
11
|
+
import {keypress as _keypress} from '@putout/cli-keypress';
|
|
12
|
+
import {getFormatter} from '@putout/engine-reporter/formatter';
|
|
13
|
+
import {
|
|
14
|
+
runProcessors as _runProcessors,
|
|
15
|
+
getFilePatterns as _getFilePatterns,
|
|
16
|
+
getProcessorRunners as _getProcessorRunners,
|
|
16
17
|
defaultProcessors,
|
|
17
|
-
}
|
|
18
|
+
} from '@putout/engine-processor';
|
|
19
|
+
import supportedFiles from './supported-files.js';
|
|
20
|
+
import _getOptions from './get-options.js';
|
|
21
|
+
import {argvConfig, parseArgs} from './parse-args.js';
|
|
22
|
+
import {getFiles as _getFiles} from './get-files.mjs';
|
|
23
|
+
import {simpleImport as _simpleImport} from './simple-import.js';
|
|
24
|
+
import {run} from './runner/runner.js';
|
|
18
25
|
|
|
19
|
-
const
|
|
20
|
-
const {keypress: _keypress} = require('@putout/cli-keypress');
|
|
21
|
-
|
|
22
|
-
const supportedFiles = require('./supported-files');
|
|
23
|
-
const _getOptions = require('./get-options');
|
|
24
|
-
const {argvConfig, parseArgs} = require('./parse-args');
|
|
25
|
-
|
|
26
|
-
const {getFiles: _getFiles} = require('./get-files.mjs');
|
|
27
|
-
const {version, dependencies} = require('../../package.json');
|
|
26
|
+
const require = createRequire(import.meta.url);
|
|
28
27
|
const {formatter: defaultFormatter} = require('../../putout.json');
|
|
29
|
-
const {
|
|
30
|
-
const {run} = require('./runner/runner.js');
|
|
28
|
+
const {version, dependencies} = require('../../package.json');
|
|
31
29
|
|
|
32
30
|
const {
|
|
33
31
|
OK,
|
|
@@ -45,11 +43,10 @@ const {
|
|
|
45
43
|
INTERACTIVE_CANCELED,
|
|
46
44
|
} = require('./exit-codes');
|
|
47
45
|
|
|
48
|
-
const
|
|
49
|
-
const {keys} = Object;
|
|
46
|
+
const _getFormatter = nano.nanomemoize(getFormatter);
|
|
50
47
|
const {isSupported} = supportedFiles;
|
|
51
|
-
const
|
|
52
|
-
|
|
48
|
+
const {keys} = Object;
|
|
49
|
+
const noop = () => {};
|
|
53
50
|
const cwd = process.cwd();
|
|
54
51
|
const {env} = process;
|
|
55
52
|
|
|
@@ -68,7 +65,7 @@ const parseIsStop = (passedIsStop, {keypress}) => {
|
|
|
68
65
|
return isStop;
|
|
69
66
|
};
|
|
70
67
|
|
|
71
|
-
|
|
68
|
+
export default async (overrides = {}) => {
|
|
72
69
|
const {
|
|
73
70
|
argv,
|
|
74
71
|
halt,
|
|
@@ -88,6 +85,7 @@ module.exports = async (overrides = {}) => {
|
|
|
88
85
|
getFormatter = _getFormatter,
|
|
89
86
|
isCI = _isCI,
|
|
90
87
|
simpleImport = _simpleImport,
|
|
88
|
+
processor = {},
|
|
91
89
|
} = overrides;
|
|
92
90
|
|
|
93
91
|
const isStop = parseIsStop(overrides.isStop || noop, {
|
|
@@ -211,6 +209,12 @@ module.exports = async (overrides = {}) => {
|
|
|
211
209
|
processors = defaultProcessors,
|
|
212
210
|
} = config;
|
|
213
211
|
|
|
212
|
+
const {
|
|
213
|
+
runProcessors = _runProcessors,
|
|
214
|
+
getFilePatterns = _getFilePatterns,
|
|
215
|
+
getProcessorRunners = _getProcessorRunners,
|
|
216
|
+
} = processor;
|
|
217
|
+
|
|
214
218
|
const [currentFormat, formatterOptions] = await getFormatter(newFormatter || format || formatter, exit);
|
|
215
219
|
const [error, processorRunners] = await tryToCatch(getProcessorRunners, processors, simpleImport);
|
|
216
220
|
|
|
@@ -311,6 +315,7 @@ module.exports = async (overrides = {}) => {
|
|
|
311
315
|
transform,
|
|
312
316
|
initProcessFile,
|
|
313
317
|
getOptions,
|
|
318
|
+
runProcessors,
|
|
314
319
|
});
|
|
315
320
|
|
|
316
321
|
if (exited)
|
|
@@ -349,7 +354,8 @@ module.exports = async (overrides = {}) => {
|
|
|
349
354
|
exit(exitCode);
|
|
350
355
|
};
|
|
351
356
|
|
|
352
|
-
|
|
357
|
+
export const _addOnce = addOnce;
|
|
358
|
+
|
|
353
359
|
function addOnce(emitter, name, fn) {
|
|
354
360
|
if (!emitter.listenerCount(name))
|
|
355
361
|
emitter.on(name, fn);
|
package/lib/cli/runner/reader.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const tryToCatch = require('try-to-catch');
|
|
4
|
-
const {runProcessors} = require('@putout/engine-processor');
|
|
4
|
+
const {runProcessors: _runProcessors} = require('@putout/engine-processor');
|
|
5
5
|
|
|
6
6
|
const parseError = require('../../parse-error.js');
|
|
7
7
|
const {simpleImport} = require('../simple-import');
|
|
8
8
|
const ignores = require('../../ignores.js');
|
|
9
9
|
|
|
10
|
-
module.exports.runReader = async (
|
|
10
|
+
module.exports.runReader = async (overrides) => {
|
|
11
|
+
const {
|
|
12
|
+
raw,
|
|
13
|
+
log,
|
|
14
|
+
dir,
|
|
15
|
+
resolvedName,
|
|
16
|
+
options,
|
|
17
|
+
readFile,
|
|
18
|
+
fix,
|
|
19
|
+
processFile,
|
|
20
|
+
processorRunners,
|
|
21
|
+
runProcessors = _runProcessors,
|
|
22
|
+
} = overrides;
|
|
23
|
+
|
|
11
24
|
let isProcessed = true;
|
|
12
25
|
let places = [];
|
|
13
26
|
let rawSource = '';
|
package/lib/cli/runner/runner.js
CHANGED
|
@@ -28,6 +28,7 @@ module.exports.run = async (overrides) => {
|
|
|
28
28
|
initProcessFile = _initProcessFile,
|
|
29
29
|
report,
|
|
30
30
|
getOptions,
|
|
31
|
+
runProcessors,
|
|
31
32
|
} = overrides;
|
|
32
33
|
|
|
33
34
|
const processFile = initProcessFile(options);
|
|
@@ -66,6 +67,7 @@ module.exports.run = async (overrides) => {
|
|
|
66
67
|
transform,
|
|
67
68
|
trace,
|
|
68
69
|
getOptions,
|
|
70
|
+
runProcessors,
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
places.push(...currentPlaces);
|
package/lib/cli/runner/writer.js
CHANGED
|
@@ -57,6 +57,7 @@ module.exports.runWriter = async (overrides = {}) => {
|
|
|
57
57
|
count,
|
|
58
58
|
trace,
|
|
59
59
|
getOptions = _getOptions,
|
|
60
|
+
runProcessors,
|
|
60
61
|
} = overrides;
|
|
61
62
|
|
|
62
63
|
const resolvedName = resolve(name).replace(/^\./, cwd);
|
|
@@ -107,6 +108,7 @@ module.exports.runWriter = async (overrides = {}) => {
|
|
|
107
108
|
readFile,
|
|
108
109
|
processFile,
|
|
109
110
|
resolvedName,
|
|
111
|
+
runProcessors,
|
|
110
112
|
});
|
|
111
113
|
|
|
112
114
|
const line = await report(currentFormat, {
|
|
@@ -4,6 +4,7 @@ const {normalize} = require('node:path');
|
|
|
4
4
|
const picomatch = require('picomatch');
|
|
5
5
|
const fullstore = require('fullstore');
|
|
6
6
|
|
|
7
|
+
const noop = () => {};
|
|
7
8
|
const isMatchStore = fullstore();
|
|
8
9
|
|
|
9
10
|
let patterns = [];
|
|
@@ -26,6 +27,11 @@ module.exports.isSupported = (name) => {
|
|
|
26
27
|
return isMatch(name);
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
module.exports.clear = () => {
|
|
31
|
+
isMatchStore(noop);
|
|
32
|
+
patterns = [];
|
|
33
|
+
};
|
|
34
|
+
|
|
29
35
|
module.exports.getSupportedGlob = (file) => normalize(`${file}/**/{${patterns.join(',')}}`);
|
|
30
36
|
|
|
31
37
|
module.exports.getPatterns = () => patterns;
|
package/lib/putout.js
CHANGED
|
@@ -115,7 +115,6 @@ module.exports.traverse = traverse;
|
|
|
115
115
|
module.exports.types = types;
|
|
116
116
|
module.exports.template = template;
|
|
117
117
|
module.exports.generate = generate;
|
|
118
|
-
module.exports.initReport = require('@putout/engine-reporter/report');
|
|
119
118
|
|
|
120
119
|
module.exports.operator = {
|
|
121
120
|
...require('@putout/operate'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "41.1.
|
|
3
|
+
"version": "41.1.4",
|
|
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",
|
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
"./parse-options": "./lib/parse-options/index.js",
|
|
16
16
|
"./parse-match": "./lib/parse-options/parse-match.js",
|
|
17
17
|
"./merge-options": "./lib/parse-options/merge-options.js",
|
|
18
|
-
"./exit-codes":
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
"./exit-codes": {
|
|
19
|
+
"import": "./lib/cli/exit-codes.mjs",
|
|
20
|
+
"require": "./lib/cli/exit-codes.js"
|
|
21
|
+
},
|
|
22
|
+
"./cli": "./lib/cli/index.mjs",
|
|
21
23
|
"./cli/get-options": "./lib/cli/get-options.js",
|
|
22
24
|
"./package.json": "./package.json",
|
|
23
25
|
"./putout.json": "./putout.json",
|
|
@@ -64,7 +66,7 @@
|
|
|
64
66
|
"@putout/engine-loader": "^17.0.0",
|
|
65
67
|
"@putout/engine-parser": "^15.0.1",
|
|
66
68
|
"@putout/engine-processor": "^15.0.0",
|
|
67
|
-
"@putout/engine-reporter": "^
|
|
69
|
+
"@putout/engine-reporter": "^8.0.2",
|
|
68
70
|
"@putout/engine-runner": "^26.0.0",
|
|
69
71
|
"@putout/formatter-codeframe": "^10.0.0",
|
|
70
72
|
"@putout/formatter-dump": "^6.0.0",
|