@putout/engine-runner 12.1.0 → 12.4.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/README.md +7 -7
- package/lib/index.js +1 -0
- package/lib/replace/index.js +11 -2
- package/lib/run-fix.js +6 -1
- package/lib/store.js +1 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@ npm i @putout/engine-runner
|
|
|
15
15
|
|
|
16
16
|
### Replacer
|
|
17
17
|
|
|
18
|
-
`Replacer` converts code in declarative way. Simplest possible form, no need to use `fix`. Just `from` and `to` parts
|
|
18
|
+
`Replacer` converts code in declarative way. Simplest possible form, no need to use `fix`. Just `from` and `to` parts
|
|
19
|
+
according to [`template variables syntax`](https://github.com/coderaiser/putout/tree/master/packages/compare#supported-template-variables).
|
|
19
20
|
|
|
20
21
|
Simplest replace example:
|
|
21
22
|
|
|
@@ -321,12 +322,11 @@ const places = runPlugins({
|
|
|
321
322
|
|
|
322
323
|
To see logs, use:
|
|
323
324
|
|
|
324
|
-
|
|
325
|
-
DEBUG=putout:runner
|
|
326
|
-
DEBUG=putout:runner:
|
|
327
|
-
DEBUG=putout:runner:
|
|
328
|
-
DEBUG=putout:runner:
|
|
329
|
-
```
|
|
325
|
+
- ✅ `DEBUG=putout:runner:*`
|
|
326
|
+
- ✅ `DEBUG=putout:runner:fix`
|
|
327
|
+
- ✅ `DEBUG=putout:runner:find`
|
|
328
|
+
- ✅ `DEBUG=putout:runner:template`
|
|
329
|
+
- ✅ `DEBUG=putout:runner:replace`
|
|
330
330
|
|
|
331
331
|
## License
|
|
332
332
|
|
package/lib/index.js
CHANGED
package/lib/replace/index.js
CHANGED
|
@@ -11,10 +11,15 @@ const {
|
|
|
11
11
|
getValues,
|
|
12
12
|
setValues,
|
|
13
13
|
} = require('@putout/compare');
|
|
14
|
+
const debug = require('debug')('putout:runner:replace');
|
|
14
15
|
|
|
15
16
|
const maybeArray = require('../maybe-array');
|
|
16
17
|
const watermark = require('./watermark');
|
|
17
18
|
|
|
19
|
+
const log = (from, path) => {
|
|
20
|
+
debug.enabled && debug(`${from} -> ${path}\n`);
|
|
21
|
+
};
|
|
22
|
+
|
|
18
23
|
const {keys, entries} = Object;
|
|
19
24
|
const {stringify} = JSON;
|
|
20
25
|
|
|
@@ -89,8 +94,10 @@ const fix = (from, to, path) => {
|
|
|
89
94
|
|
|
90
95
|
const nodeTo = parseTo(to, values, path);
|
|
91
96
|
|
|
92
|
-
if (!nodeTo)
|
|
97
|
+
if (!nodeTo) {
|
|
98
|
+
log(from, `''`);
|
|
93
99
|
return remove(path);
|
|
100
|
+
}
|
|
94
101
|
|
|
95
102
|
const waysTo = findVarsWays(nodeTo);
|
|
96
103
|
const newPath = replaceWith(path, nodeTo);
|
|
@@ -105,7 +112,9 @@ const fix = (from, to, path) => {
|
|
|
105
112
|
|
|
106
113
|
mark.add();
|
|
107
114
|
path.scope.getBlockParent().crawl();
|
|
108
|
-
path.scope.getProgramParent().crawl();
|
|
115
|
+
//path.scope.getProgramParent().crawl();
|
|
116
|
+
|
|
117
|
+
log(from, newPath);
|
|
109
118
|
};
|
|
110
119
|
|
|
111
120
|
const getFix = (items) => (path) => {
|
package/lib/run-fix.js
CHANGED
|
@@ -6,9 +6,14 @@ const {enabled} = debug;
|
|
|
6
6
|
|
|
7
7
|
const tryToFix = (fix, {path, position, options}) => {
|
|
8
8
|
const [e] = tryCatch(fix, path, {options});
|
|
9
|
+
const {scope} = path.path || path;
|
|
9
10
|
|
|
10
|
-
if (!e)
|
|
11
|
+
if (!e && scope)
|
|
12
|
+
scope.getProgramParent().crawl();
|
|
13
|
+
|
|
14
|
+
if (!e) {
|
|
11
15
|
return;
|
|
16
|
+
}
|
|
12
17
|
|
|
13
18
|
e.loc = e.loc || position;
|
|
14
19
|
|
package/lib/store.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-runner",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "run putout plugins",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@babel/types": "^7.12.7",
|
|
29
29
|
"@putout/compare": "^8.0.0",
|
|
30
30
|
"@putout/engine-parser": "^4.0.1",
|
|
31
|
-
"@putout/operate": "^
|
|
31
|
+
"@putout/operate": "^7.0.0",
|
|
32
32
|
"debug": "^4.1.1",
|
|
33
33
|
"jessy": "^3.0.0",
|
|
34
34
|
"nessy": "^4.0.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"c8": "^7.5.0",
|
|
47
47
|
"eslint": "^8.0.1",
|
|
48
48
|
"eslint-plugin-node": "^11.0.0",
|
|
49
|
-
"eslint-plugin-putout": "^
|
|
49
|
+
"eslint-plugin-putout": "^13.0.0",
|
|
50
50
|
"just-camel-case": "^4.0.2",
|
|
51
51
|
"lerna": "^4.0.0",
|
|
52
52
|
"madrun": "^8.0.1",
|