@putout/engine-runner 24.0.1 → 24.1.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/lib/debug.js +20 -0
- package/lib/{declare.js → declarator/index.js} +3 -3
- package/lib/{include.js → includer/index.js} +3 -3
- package/lib/index.js +8 -7
- package/lib/{replace → replacer}/index.js +8 -7
- package/lib/run-fix.js +4 -3
- package/lib/scanner/index.js +1 -1
- package/lib/template/index.js +2 -1
- package/package.json +3 -4
- /package/lib/{replace → replacer}/find-path.js +0 -0
- /package/lib/{replace → replacer}/watermark.js +0 -0
package/lib/debug.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug');
|
|
4
|
+
|
|
5
|
+
module.exports.createDebug = (namespace) => {
|
|
6
|
+
const log = debug(namespace);
|
|
7
|
+
|
|
8
|
+
return new Proxy(log, {
|
|
9
|
+
apply(target, thisArg, args) {
|
|
10
|
+
global.__putout_debug(namespace, ...args);
|
|
11
|
+
return target(...args);
|
|
12
|
+
},
|
|
13
|
+
get(target, prop) {
|
|
14
|
+
if (global.__putout_debug?.[prop])
|
|
15
|
+
return true;
|
|
16
|
+
|
|
17
|
+
return target[prop];
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {declare} = require('@putout/operator-declare');
|
|
3
|
+
const {declare: index} = require('@putout/operator-declare');
|
|
4
4
|
|
|
5
5
|
const {stringify} = JSON;
|
|
6
6
|
const isFn = (a) => typeof a === 'function';
|
|
7
7
|
|
|
8
|
-
module.exports = ({rule, plugin, msg, options}) => {
|
|
8
|
+
module.exports.declare = ({rule, plugin, msg, options}) => {
|
|
9
9
|
validateDeclare(plugin.declare);
|
|
10
10
|
|
|
11
11
|
return {
|
|
12
12
|
rule,
|
|
13
|
-
plugin:
|
|
13
|
+
plugin: index(plugin.declare()),
|
|
14
14
|
msg,
|
|
15
15
|
options,
|
|
16
16
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const log = require('debug')('putout:runner:include');
|
|
4
|
-
const maybeArray = require('
|
|
5
|
-
const {validate} = require('
|
|
4
|
+
const maybeArray = require('../maybe-array');
|
|
5
|
+
const {validate} = require('../validate');
|
|
6
6
|
|
|
7
7
|
const stub = () => [];
|
|
8
8
|
const good = () => true;
|
|
9
9
|
|
|
10
|
-
module.exports = ({rule, plugin, msg, options}) => {
|
|
10
|
+
module.exports.include = ({rule, plugin, msg, options}) => {
|
|
11
11
|
const {
|
|
12
12
|
fix,
|
|
13
13
|
report,
|
package/lib/index.js
CHANGED
|
@@ -7,14 +7,15 @@ const debug = require('debug')('putout:runner:find');
|
|
|
7
7
|
const runFix = require('./run-fix');
|
|
8
8
|
const mergeVisitors = require('./merge-visitors');
|
|
9
9
|
const superFind = require('./super-find');
|
|
10
|
-
const
|
|
11
|
-
const replace = require('./replace');
|
|
12
|
-
const declare = require('./declare');
|
|
13
|
-
const scanner = require('./scanner');
|
|
14
|
-
const template = require('./template');
|
|
10
|
+
const template = require('./template/index.js');
|
|
15
11
|
const {createProgress} = require('./progress');
|
|
16
12
|
const {tryThrowWithReason} = require('./try-throw-with-reason');
|
|
17
13
|
|
|
14
|
+
const {include} = require('./includer/index.js');
|
|
15
|
+
const {replace, clearWatermark} = require('./replacer/index.js');
|
|
16
|
+
const {declare} = require('./declarator/index.js');
|
|
17
|
+
const {scan} = require('./scanner/index.js');
|
|
18
|
+
|
|
18
19
|
const {getPath, getPosition} = require('./get-position');
|
|
19
20
|
|
|
20
21
|
const isRemoved = (a) => a?.removed;
|
|
@@ -47,7 +48,7 @@ module.exports.runPlugins = ({ast, shebang, fix, fixCount = 2, plugins, progress
|
|
|
47
48
|
if (!fix || !places.length)
|
|
48
49
|
return places;
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
clearWatermark(ast);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
return places;
|
|
@@ -182,7 +183,7 @@ function splitPlugins(plugins, {progress}) {
|
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
if (plugin.scan) {
|
|
185
|
-
pluginsTraverse.push(
|
|
186
|
+
pluginsTraverse.push(scan(item, {
|
|
186
187
|
progress,
|
|
187
188
|
}));
|
|
188
189
|
continue;
|
|
@@ -11,10 +11,15 @@ const {
|
|
|
11
11
|
setValues,
|
|
12
12
|
} = require('@putout/compare');
|
|
13
13
|
|
|
14
|
-
const debug = require('debug')('putout:runner:replace');
|
|
15
14
|
const maybeArray = require('../maybe-array');
|
|
16
|
-
|
|
17
15
|
const watermark = require('./watermark');
|
|
16
|
+
const {createDebug} = require('../debug');
|
|
17
|
+
const debug = createDebug('putout:runner:replace');
|
|
18
|
+
|
|
19
|
+
const log = (from, path) => {
|
|
20
|
+
debug.enabled && debug(`${from} -> ${path}\n`);
|
|
21
|
+
};
|
|
22
|
+
|
|
18
23
|
const {
|
|
19
24
|
isExpression,
|
|
20
25
|
isStatement,
|
|
@@ -34,10 +39,6 @@ const PRINT_OPTIONS = {
|
|
|
34
39
|
|
|
35
40
|
const isString = (a) => typeof a === 'string';
|
|
36
41
|
|
|
37
|
-
const log = (from, path) => {
|
|
38
|
-
debug.enabled && debug(`${from} -> ${path}\n`);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
42
|
const {keys, entries} = Object;
|
|
42
43
|
const {stringify} = JSON;
|
|
43
44
|
|
|
@@ -46,7 +47,7 @@ const stubMatch = () => ({});
|
|
|
46
47
|
const packKeys = (a) => () => keys(a);
|
|
47
48
|
const isObject = (a) => typeof a === 'object';
|
|
48
49
|
|
|
49
|
-
module.exports = ({rule, plugin, msg, options}) => {
|
|
50
|
+
module.exports.replace = ({rule, plugin, msg, options}) => {
|
|
50
51
|
const maybeMatch = plugin.match || stubMatch;
|
|
51
52
|
const match = maybeMatch({
|
|
52
53
|
options,
|
package/lib/run-fix.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const tryCatch = require('try-catch');
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const {createDebug} = require('./debug');
|
|
5
|
+
|
|
6
6
|
const {stringify} = JSON;
|
|
7
7
|
|
|
8
8
|
const isFn = (a) => typeof a === 'function';
|
|
9
9
|
const getPath = (path) => path.path || path;
|
|
10
|
+
const debug = createDebug('putout:runner:fix');
|
|
10
11
|
|
|
11
12
|
const chooseFixArgs = ({path, pathOptions, options}) => {
|
|
12
13
|
if (pathOptions)
|
|
@@ -51,7 +52,7 @@ module.exports = (is, fix, {path, pathOptions, rule, position, options}) => {
|
|
|
51
52
|
if (!is)
|
|
52
53
|
return;
|
|
53
54
|
|
|
54
|
-
if (enabled)
|
|
55
|
+
if (debug.enabled)
|
|
55
56
|
debug(`fix: ${rule}`, position, getPath(path).toString());
|
|
56
57
|
|
|
57
58
|
validate('fix', fix);
|
package/lib/scanner/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const log = require('debug')('putout:runner:scanner');
|
|
|
15
15
|
const fromSimple = require('@putout/plugin-filesystem/from-simple');
|
|
16
16
|
const toSimple = require('@putout/plugin-filesystem/to-simple');
|
|
17
17
|
|
|
18
|
-
module.exports = ({rule, plugin, msg, options}, {progress}) => {
|
|
18
|
+
module.exports.scan = ({rule, plugin, msg, options}, {progress}) => {
|
|
19
19
|
const {
|
|
20
20
|
scan,
|
|
21
21
|
report,
|
package/lib/template/index.js
CHANGED
|
@@ -10,7 +10,8 @@ const {
|
|
|
10
10
|
} = require('@putout/compare');
|
|
11
11
|
|
|
12
12
|
const maybeArray = require('../maybe-array');
|
|
13
|
-
const
|
|
13
|
+
const {createDebug} = require('../debug');
|
|
14
|
+
const debug = createDebug('putout:runner:template');
|
|
14
15
|
|
|
15
16
|
const {entries} = Object;
|
|
16
17
|
const isFn = (a) => typeof a === 'function';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-runner",
|
|
3
|
-
"version": "24.0
|
|
3
|
+
"version": "24.1.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Run 🐊Putout plugins",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@putout/operator-declare": "^12.0.0",
|
|
36
36
|
"@putout/operator-filesystem": "^7.0.0",
|
|
37
37
|
"@putout/operator-json": "^2.0.0",
|
|
38
|
-
"@putout/plugin-filesystem": "^
|
|
38
|
+
"@putout/plugin-filesystem": "^9.0.0",
|
|
39
39
|
"debug": "^4.1.1",
|
|
40
40
|
"fullstore": "^3.0.0",
|
|
41
41
|
"jessy": "^4.0.0",
|
|
@@ -58,11 +58,10 @@
|
|
|
58
58
|
"eslint-plugin-putout": "^26.0.0",
|
|
59
59
|
"just-camel-case": "^6.2.0",
|
|
60
60
|
"madrun": "^11.0.0",
|
|
61
|
-
"mock-require": "^3.0.3",
|
|
62
61
|
"montag": "^1.0.0",
|
|
63
62
|
"nodemon": "^3.0.1",
|
|
64
63
|
"putout": "*",
|
|
65
|
-
"supertape": "^
|
|
64
|
+
"supertape": "^11.0.3"
|
|
66
65
|
},
|
|
67
66
|
"peerDependencies": {
|
|
68
67
|
"putout": "*"
|
|
File without changes
|
|
File without changes
|