@putout/plugin-cloudcmd 3.1.1 → 4.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.
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.report = () => 'IO.copy should be used instead of IO.cp';
1
+ export const report = () => 'IO.copy should be used instead of IO.cp';
4
2
 
5
3
  const cpFrom = `
6
4
  IO.cp({
@@ -12,6 +10,6 @@ const cpFrom = `
12
10
 
13
11
  const cpTo = 'IO.copy(__a, __b, __c)';
14
12
 
15
- module.exports.replace = () => ({
13
+ export const replace = () => ({
16
14
  [cpFrom]: cpTo,
17
15
  });
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.report = () => 'IO.move should be used instead of IO.mv';
1
+ export const report = () => 'IO.move should be used instead of IO.mv';
4
2
 
5
3
  const mvFrom = `
6
4
  IO.mv({
@@ -12,6 +10,6 @@ const mvFrom = `
12
10
 
13
11
  const mvTo = 'IO.move(__a, __b, __c)';
14
12
 
15
- module.exports.replace = () => ({
13
+ export const replace = () => ({
16
14
  [mvFrom]: mvTo,
17
15
  });
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => 'IO.createDirectory should be used instead of IO.write';
2
2
 
3
- module.exports.report = () => 'IO.createDirectory should be used instead of IO.write';
4
-
5
- module.exports.match = () => ({
3
+ export const match = () => ({
6
4
  'IO.write("__a")': ({__a}) => {
7
5
  return __a.value.endsWith('?dir');
8
6
  },
@@ -11,7 +9,7 @@ module.exports.match = () => ({
11
9
  },
12
10
  });
13
11
 
14
- module.exports.replace = () => ({
12
+ export const replace = () => ({
15
13
  'IO.write(`${__a}?dir`)': 'IO.createDirectory(__a)',
16
14
  'IO.write("__a")': ({__a}) => {
17
15
  const value = __a.value.replace(/\?dir$/, '');
@@ -1,19 +1,18 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
- const {rename} = operator;
3
+ const {rename, remove} = operator;
5
4
 
6
5
  const renameAll = (path) => {
7
6
  rename(path, 'loadDir', 'changeDir');
8
7
  };
9
8
 
10
- module.exports.report = () => `Use 'CloudCmd.changeDir()' instead of 'CloudCmd.loadDir()'`;
9
+ export const report = () => `Use 'CloudCmd.changeDir()' instead of 'CloudCmd.loadDir()'`;
11
10
 
12
- module.exports.replace = () => ({
11
+ export const replace = () => ({
13
12
  'CloudCmd.loadDir({path})': 'CloudCmd.changeDir(path)',
14
13
  'CloudCmd.loadDir({path: __a})': 'CloudCmd.changeDir(__a)',
15
14
  'CloudCmd.loadDir(__object)': (vars, path) => {
16
- convert(vars, path);
15
+ convert(path);
17
16
  path.node.callee.property.name = 'changeDir';
18
17
 
19
18
  return path;
@@ -27,7 +26,7 @@ module.exports.replace = () => ({
27
26
  return 'changeDir(path)';
28
27
  },
29
28
  'loadDir(__object)': (vars, path) => {
30
- convert(vars, path);
29
+ convert(path);
31
30
  renameAll(path);
32
31
 
33
32
  return path;
@@ -35,13 +34,13 @@ module.exports.replace = () => ({
35
34
  'changeDir({path: __a})': 'changeDir(__a)',
36
35
  'changeDir({path})': 'changeDir(path)',
37
36
  'changeDir(__object)': (vars, path) => {
38
- convert(vars, path);
37
+ convert(path);
39
38
 
40
39
  return path;
41
40
  },
42
41
  });
43
42
 
44
- function convert(vars, path) {
43
+ function convert(path) {
45
44
  const args = path.node.arguments;
46
45
  const [obj] = path.get('arguments');
47
46
  const properties = obj.get('properties');
@@ -51,7 +50,7 @@ function convert(vars, path) {
51
50
 
52
51
  if (keyPath.isIdentifier({name: 'path'})) {
53
52
  args.unshift(property.node.value);
54
- property.remove();
53
+ remove(property);
55
54
  break;
56
55
  }
57
56
  }
package/lib/index.js CHANGED
@@ -1,12 +1,11 @@
1
- 'use strict';
1
+ import * as convertIoMvToIoMove from './convert-io-mv-to-io-move/index.js';
2
+ import * as convertIoCpToIoCopy from './convert-io-cp-to-io-copy/index.js';
3
+ import * as convertIoWriteToIoCreateDirectory from './convert-io-write-to-io-create-directory/index.js';
4
+ import * as convertLoadDirToChangeDir from './convert-load-dir-to-change-dir/index.js';
2
5
 
3
- const getRule = (a) => ({
4
- [a]: require(`./${a}`),
5
- });
6
-
7
- module.exports.rules = {
8
- ...getRule('convert-io-mv-to-io-move'),
9
- ...getRule('convert-io-cp-to-io-copy'),
10
- ...getRule('convert-io-write-to-io-create-directory'),
11
- ...getRule('convert-load-dir-to-change-dir'),
6
+ export const rules = {
7
+ 'convert-io-mv-to-io-move': convertIoMvToIoMove,
8
+ 'convert-io-cp-to-io-copy': convertIoCpToIoCopy,
9
+ 'convert-io-write-to-io-create-directory': convertIoWriteToIoCreateDirectory,
10
+ 'convert-load-dir-to-change-dir': convertLoadDirToChangeDir,
12
11
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@putout/plugin-cloudcmd",
3
- "version": "3.1.1",
4
- "type": "commonjs",
3
+ "version": "4.0.0",
4
+ "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to transform code to new API of Cloud Commander",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-cloudcmd#readme",
@@ -11,7 +11,7 @@
11
11
  "changelog": false,
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git://github.com/coderaiser/putout.git"
14
+ "url": "git+https://github.com/coderaiser/putout.git"
15
15
  },
16
16
  "scripts": {
17
17
  "test": "madrun test",
@@ -31,23 +31,23 @@
31
31
  "cloudcmd"
32
32
  ],
33
33
  "devDependencies": {
34
+ "@putout/eslint-flat": "^3.0.0",
34
35
  "@putout/plugin-remove-unused-expressions": "*",
35
36
  "@putout/plugin-strict-mode": "*",
36
- "@putout/test": "^6.0.0",
37
- "c8": "^7.5.0",
38
- "eslint": "^8.0.1",
39
- "eslint-plugin-n": "^16.0.0",
40
- "eslint-plugin-putout": "^17.0.0",
41
- "lerna": "^6.0.1",
42
- "madrun": "^9.0.0",
43
- "nodemon": "^2.0.1"
37
+ "@putout/test": "^13.0.0",
38
+ "c8": "^10.0.0",
39
+ "eslint": "^9.0.0",
40
+ "eslint-plugin-n": "^17.0.0",
41
+ "eslint-plugin-putout": "^26.0.0",
42
+ "madrun": "^11.0.0",
43
+ "nodemon": "^3.0.1"
44
44
  },
45
45
  "peerDependencies": {
46
- "putout": ">=29"
46
+ "putout": ">=39"
47
47
  },
48
48
  "license": "MIT",
49
49
  "engines": {
50
- "node": ">=16"
50
+ "node": ">=20"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"