@putout/plugin-putout 28.2.1 → 28.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 CHANGED
@@ -24,6 +24,7 @@ npm i @putout/plugin-putout -D
24
24
  - ✅ [apply-create-test](#apply-create-test);
25
25
  - ✅ [apply-create-nested-directory](#apply-create-nested-directory);
26
26
  - ✅ [apply-declare](#apply-declare);
27
+ - ✅ [apply-engine-node-version](#apply-engine-node-version);
27
28
  - ✅ [apply-exports](#apply-exports);
28
29
  - ✅ [apply-exports-to-add-args](#apply-exports-to-add-args);
29
30
  - ✅ [apply-exports-to-match-files](#apply-exports-to-match-files);
@@ -102,6 +103,7 @@ npm i @putout/plugin-putout -D
102
103
  "putout/apply-create-nested-directory": "on",
103
104
  "putout/apply-async-formatter": "on",
104
105
  "putout/apply-declare": "on",
106
+ "putout/apply-engine-node-version": "off",
105
107
  "putout/apply-exports": "off",
106
108
  "putout/apply-exports-to-add-args": "on",
107
109
  "putout/apply-exports-to-match-files": "on",
@@ -492,6 +494,24 @@ module.exports.declare = () => ({
492
494
  });
493
495
  ```
494
496
 
497
+ ## apply-engine-node-version
498
+
499
+ Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/7ed4860732476de489ae149c7f09e2fe/d8b6e131596c0888ec8b99d4728cd999b17165c9).
500
+
501
+ ```diff
502
+ {
503
+ "name": "@putout/plugin-variables",
504
+ "peerDependencies": {
505
+ "putout": ">=41"
506
+ },
507
+ "license": "MIT",
508
+ "engines": {
509
+ - "node": ">=20"
510
+ + "node": ">=22"
511
+ }
512
+ }
513
+ ```
514
+
495
515
  ## apply-exports
496
516
 
497
517
  Check out in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/cf35de5e80e8f7aad866358a50c5eded/0af6142fc9c9e71ac2a2aa96cb85613dd95c9fbf).
@@ -0,0 +1,58 @@
1
+ import {operator} from 'putout';
2
+
3
+ const {
4
+ getProperties,
5
+ setLiteralValue,
6
+ __json,
7
+ } = operator;
8
+
9
+ export const report = ({nodeVersion, currentNodeVersion, putoutVersion}) => {
10
+ return `Set engines node '>=${nodeVersion}' instead of '>=${currentNodeVersion}' for 🐊 '>=${putoutVersion}'`;
11
+ };
12
+
13
+ export const fix = ({path}) => {
14
+ setLiteralValue(path.node, `>=22`);
15
+ };
16
+
17
+ export const traverse = ({push, options}) => ({
18
+ [__json]: (path) => {
19
+ const {nodeVersion = 22, putoutVersion = 41} = options;
20
+ const __aPath = path.get('arguments.0');
21
+ const {
22
+ peerDependenciesPath,
23
+ enginesPath,
24
+ } = getProperties(__aPath, ['peerDependencies', 'engines']);
25
+
26
+ if (!peerDependenciesPath || !enginesPath)
27
+ return;
28
+
29
+ const peerProperties = peerDependenciesPath.get('value.properties');
30
+
31
+ if (!peerProperties.length)
32
+ return;
33
+
34
+ const enginesProperties = enginesPath.get('value.properties');
35
+
36
+ if (!enginesProperties.length)
37
+ return;
38
+
39
+ const peer = peerProperties[0].get('value');
40
+
41
+ if (Number(peer.node.value.slice(2)) < putoutVersion)
42
+ return;
43
+
44
+ const engine = enginesPath.get('value.properties.0.value');
45
+
46
+ const currentNodeVersion = Number(engine.node.value.slice(2));
47
+
48
+ if (currentNodeVersion >= nodeVersion)
49
+ return;
50
+
51
+ push({
52
+ path: engine,
53
+ nodeVersion,
54
+ currentNodeVersion,
55
+ putoutVersion,
56
+ });
57
+ },
58
+ });
@@ -1,4 +1,4 @@
1
- import tryCatch from 'try-catch';
1
+ import {tryCatch} from 'try-catch';
2
2
  import putout from 'putout';
3
3
 
4
4
  const {types, operator} = putout;
@@ -3,7 +3,7 @@ import {
3
3
  print,
4
4
  transform,
5
5
  } from 'putout';
6
- import tryCatch from 'try-catch';
6
+ import {tryCatch} from 'try-catch';
7
7
  import * as pluginGenerate from './plugin-generate.js';
8
8
 
9
9
  export default (rootPath, source) => {
@@ -1,4 +1,4 @@
1
- import tryCatch from 'try-catch';
1
+ import {tryCatch} from 'try-catch';
2
2
  import {
3
3
  operator,
4
4
  parse,
@@ -33,7 +33,7 @@ export const report = ({path, code, error}) => {
33
33
  const [, key] = parseKey(path);
34
34
  const value = extract(path.node.value);
35
35
 
36
- return `transform mismatch: "${key}" -> "${value}" !== "${code}"`;
36
+ return `transform mismatch: '${key}' -> '${value}' !== '${code}'`;
37
37
  };
38
38
 
39
39
  export const fix = ({mainPath}) => {
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as applyEngineNodeVersion from './apply-engine-node-version/index.js';
1
2
  import * as convertPushObjectToPushPath from './convert-push-object-to-push-path/index.js';
2
3
  import * as applyTransformWithOptions from './apply-transform-with-options/index.js';
3
4
  import * as convertPluginsElementToTuple from './convert-plugins-element-to-tuple/index.js';
@@ -144,4 +145,5 @@ export const rules = {
144
145
  'convert-plugins-element-to-tuple': convertPluginsElementToTuple,
145
146
  'apply-transform-with-options': applyTransformWithOptions,
146
147
  'convert-push-object-to-push-path': convertPushObjectToPushPath,
148
+ 'apply-engine-node-version': applyEngineNodeVersion,
147
149
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "28.2.1",
3
+ "version": "28.4.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",
@@ -44,16 +44,16 @@
44
44
  ],
45
45
  "devDependencies": {
46
46
  "@putout/eslint-flat": "^3.0.0",
47
- "@putout/plugin-esm": "*",
48
47
  "@putout/plugin-destructuring": "*",
48
+ "@putout/plugin-esm": "*",
49
49
  "@putout/plugin-nodejs": "*",
50
50
  "@putout/plugin-tape": "*",
51
- "@putout/test": "^14.0.0",
51
+ "@putout/test": "^15.0.0",
52
52
  "c8": "^10.0.0",
53
53
  "eslint": "^10.0.0-alpha.0",
54
54
  "eslint-plugin-n": "^17.0.0",
55
55
  "eslint-plugin-putout": "^29.0.0",
56
- "madrun": "^11.0.0",
56
+ "madrun": "^12.0.0",
57
57
  "montag": "^1.2.1",
58
58
  "nodemon": "^3.0.1",
59
59
  "supertape": "^11.0.3"
@@ -63,7 +63,7 @@
63
63
  },
64
64
  "license": "MIT",
65
65
  "engines": {
66
- "node": ">=20"
66
+ "node": ">=22"
67
67
  },
68
68
  "publishConfig": {
69
69
  "access": "public"