@putout/engine-runner 19.1.0 β†’ 20.0.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 CHANGED
@@ -19,7 +19,7 @@ There is a couple plugin types available in 🐊**Putout**:
19
19
  - βœ… [**Replacer**](#replacer)
20
20
  - βœ… [**Includer**](#includer)
21
21
  - βœ… [**Traverser**](#traverser)
22
- - βœ… [**Scanner**](#filer)
22
+ - βœ… [**Scanner**](#scanner)
23
23
  - βœ… [**Finder**](#finder)
24
24
 
25
25
  All of them supports subset of **JavaScript** 🦎[**PutoutScript**](https://github.com/coderaiser/putout/blob/master/docs/putout-script.md#-putoutscript) described in [`@putout/compare`](https://github.com/coderaiser/putout/tree/master/packages/compare#readme).
@@ -1,8 +1,14 @@
1
1
  'use strict';
2
2
 
3
- const {__filesystem} = require('@putout/operator-json');
3
+ const fullstore = require('fullstore');
4
+ const {compare} = require('@putout/compare');
5
+ const {__filesystem_name} = require('@putout/operator-json');
6
+ const {pause, start} = require('@putout/operator-filesystem');
4
7
  const log = require('debug')('putout:runner:scanner');
5
8
 
9
+ const fromSimple = require('@putout/plugin-filesystem/from-simple');
10
+ const toSimple = require('@putout/plugin-filesystem/to-simple');
11
+
6
12
  module.exports = ({rule, plugin, msg, options}) => {
7
13
  const {
8
14
  scan,
@@ -28,13 +34,73 @@ module.exports = ({rule, plugin, msg, options}) => {
28
34
  };
29
35
 
30
36
  const getTraverse = ({scan, rule}) => ({push, options}) => ({
31
- [__filesystem](path) {
37
+ ['__putout_processor_filesystem(__)'](path) {
32
38
  log(rule);
33
39
 
34
40
  const rootPath = path.get('arguments.0');
41
+ const isSimple = fullstore(false);
42
+
43
+ runSimple(fromSimple, {
44
+ path,
45
+ rootPath,
46
+ isSimple,
47
+ });
48
+
35
49
  scan(rootPath, {
36
50
  push,
37
51
  options,
38
52
  });
53
+
54
+ runSimple(toSimple, {
55
+ condition: isSimple(),
56
+ path,
57
+ rootPath,
58
+ isSimple,
59
+ });
39
60
  },
40
61
  });
62
+
63
+ const runFix = ({fix, isSimple}) => (...a) => {
64
+ isSimple(true);
65
+ return fix(...a);
66
+ };
67
+
68
+ function runSimple(plugin, {path, isSimple, condition = true}) {
69
+ const {traverse, fix} = plugin;
70
+
71
+ if (!condition)
72
+ return;
73
+
74
+ const push = runFix({
75
+ fix,
76
+ isSimple,
77
+ });
78
+
79
+ const visitors = traverse({
80
+ push,
81
+ });
82
+
83
+ const [visit, template] = parseVisitor(visitors);
84
+
85
+ if (compare(path, template)) {
86
+ pause();
87
+ visit(path);
88
+ start();
89
+ }
90
+ }
91
+
92
+ function parseVisitor(visitors) {
93
+ const to = visitors[`${__filesystem_name}(__object)`];
94
+ const from = visitors[`${__filesystem_name}(__array)`];
95
+
96
+ if (to)
97
+ return [
98
+ to,
99
+ `${__filesystem_name}(__object)`,
100
+ ];
101
+
102
+ return [
103
+ from,
104
+ `${__filesystem_name}(__array)`,
105
+ ];
106
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-runner",
3
- "version": "19.1.0",
3
+ "version": "20.0.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Run 🐊Putout plugins",
@@ -26,11 +26,14 @@
26
26
  "dependencies": {
27
27
  "@putout/babel": "^1.0.5",
28
28
  "@putout/compare": "^13.0.0",
29
- "@putout/engine-parser": "^9.0.0",
29
+ "@putout/engine-parser": "^10.0.0",
30
30
  "@putout/operate": "^11.0.0",
31
31
  "@putout/operator-declare": "^8.0.0",
32
+ "@putout/operator-filesystem": "^2.10.0",
32
33
  "@putout/operator-json": "^1.3.0",
34
+ "@putout/plugin-filesystem": "^2.0.0",
33
35
  "debug": "^4.1.1",
36
+ "fullstore": "^3.0.0",
34
37
  "jessy": "^3.0.0",
35
38
  "nessy": "^4.0.0",
36
39
  "once": "^1.4.0",
@@ -42,7 +45,6 @@
42
45
  "putout-engine"
43
46
  ],
44
47
  "devDependencies": {
45
- "@putout/operator-filesystem": "^2.9.2",
46
48
  "@putout/plugin-minify": "*",
47
49
  "c8": "^8.0.0",
48
50
  "eslint": "^8.0.1",
@@ -50,7 +52,7 @@
50
52
  "eslint-plugin-putout": "^21.0.0",
51
53
  "just-camel-case": "^4.0.2",
52
54
  "lerna": "^6.0.1",
53
- "madrun": "^9.0.0",
55
+ "madrun": "^10.0.0",
54
56
  "mock-require": "^3.0.3",
55
57
  "montag": "^1.0.0",
56
58
  "nodemon": "^3.0.1",
@@ -62,7 +64,7 @@
62
64
  },
63
65
  "license": "MIT",
64
66
  "engines": {
65
- "node": ">=16"
67
+ "node": ">=18"
66
68
  },
67
69
  "publishConfig": {
68
70
  "access": "public"