@putout/plugin-cloudcmd 1.2.0 β†’ 2.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
@@ -1,12 +1,9 @@
1
- # @putout/plugin-cloudcmd [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL]
1
+ # @putout/plugin-cloudcmd [![NPM version][NPMIMGURL]][NPMURL]
2
2
 
3
- [NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-cloudcmd.svg?style=flat&longCache=true
4
- [NPMURL]: https://npmjs.org/package/@putout/plugin-cloudcmd"npm"
3
+ [NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-cloudcmd.svg?style=flat&longCache=true
4
+ [NPMURL]: https://npmjs.org/package/@putout/plugin-cloudcmd"npm"
5
5
 
6
- [DependencyStatusURL]: https://david-dm.org/coderaiser/putout?path=packages/plugin-cloudcmd
7
- [DependencyStatusIMGURL]: https://david-dm.org/coderaiser/putout.svg?path=packages/plugin-cloudcmd
8
-
9
- `putout` plugin adds ability to transform to new [Cloud Commander](https://cloudcmd.io) API.
6
+ 🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to transform to new [Cloud Commander](https://cloudcmd.io) API.
10
7
 
11
8
  ## Install
12
9
 
@@ -30,14 +27,15 @@ Add `.putout.json` with:
30
27
  {
31
28
  "rules": {
32
29
  "cloudcmd/convert-io-mv-to-io-move": "on",
33
- "cloudcmd/convert-io-cp-to-io-copy": "on"
30
+ "cloudcmd/convert-io-cp-to-io-copy": "on",
31
+ "cloudcmd/convert-load-dir-to-change-dir": "on"
34
32
  }
35
33
  }
36
34
  ```
37
35
 
38
36
  # convert-io-mv-to-io-move
39
37
 
40
- ## ❌ Incorrect code example
38
+ ## ❌ Example of incorrect code
41
39
 
42
40
  ```js
43
41
  await IO.mv({
@@ -47,7 +45,7 @@ await IO.mv({
47
45
  });
48
46
  ```
49
47
 
50
- ## βœ… Correct code Example
48
+ ## βœ… Example of correct code
51
49
 
52
50
  ```js
53
51
  await IO.move(dirPath, mp3Dir, mp3Names);
@@ -55,7 +53,7 @@ await IO.move(dirPath, mp3Dir, mp3Names);
55
53
 
56
54
  # convert-io-cp-to-io-copy
57
55
 
58
- ## ❌ Incorrect code example
56
+ ## ❌ Example of incorrect code
59
57
 
60
58
  ```js
61
59
  await IO.cp({
@@ -65,7 +63,7 @@ await IO.cp({
65
63
  });
66
64
  ```
67
65
 
68
- ## βœ… Correct code Example
66
+ ## βœ… Example of correct code
69
67
 
70
68
  ```js
71
69
  await IO.copy(dirPath, mp3Dir, mp3Names);
@@ -73,20 +71,41 @@ await IO.copy(dirPath, mp3Dir, mp3Names);
73
71
 
74
72
  # convert-io-write-to-io-create-directory
75
73
 
76
- ## ❌ Incorrect code example
74
+ ## ❌ Example of incorrect code
77
75
 
78
76
  ```js
79
77
  await IO.write(`${mp3Dir}?dir`);
80
78
 
81
79
  ```
82
80
 
83
- ## βœ… Correct code Example
81
+ ## βœ… Example of correct code
84
82
 
85
83
  ```js
86
84
  await IO.createDirectory(mp3Dir);
87
85
  ```
88
86
 
87
+ # convert-load-dir-to-change-dir
88
+
89
+ Check out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/c840227d624971e9f3a9c5f368f1dd53/9c488f0809b4684a78866bc252a115cf83a65a79).
90
+
91
+ ## ❌ Example of incorrect code
92
+
93
+ ```js
94
+ await CloudCmd.loadDir({
95
+ path: '/',
96
+ panel,
97
+ });
98
+
99
+ ```
100
+
101
+ ## βœ… Example of correct code
102
+
103
+ ```js
104
+ await CloudCmd.changeDir(path, {
105
+ panel,
106
+ });
107
+ ```
108
+
89
109
  ## License
90
110
 
91
111
  MIT
92
-
@@ -4,10 +4,10 @@ module.exports.report = () => 'IO.createDirectory should be used instead of IO.w
4
4
 
5
5
  module.exports.match = () => ({
6
6
  'IO.write("__a")': ({__a}) => {
7
- return /\?dir$/.test(__a.value);
7
+ return __a.value.endsWith('?dir');
8
8
  },
9
9
  'IO.write(`__a`)': ({__a}) => {
10
- return /\?dir$/.test(__a.value.raw);
10
+ return __a.value.raw.endsWith('?dir');
11
11
  },
12
12
  });
13
13
 
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ const rename = (path) => path.scope.rename('loadDir', 'changeDir');
4
+
5
+ module.exports.report = () => `Use 'CloudCmd.changeDir()' instead of 'CloudCmd.loadDir()'`;
6
+
7
+ module.exports.replace = () => ({
8
+ 'CloudCmd.loadDir({path})': 'CloudCmd.changeDir(path)',
9
+ 'CloudCmd.loadDir(__object)': (vars, path) => {
10
+ convert(vars, path);
11
+ path.node.callee.property.name = 'changeDir';
12
+
13
+ return path;
14
+ },
15
+ 'loadDir({path: __a})': (vars, path) => {
16
+ rename(path);
17
+ return 'changeDir(__a)';
18
+ },
19
+ 'loadDir({path})': (vars, path) => {
20
+ rename(path);
21
+ return 'changeDir(path)';
22
+ },
23
+ 'loadDir(__object)': (vars, path) => {
24
+ convert(vars, path);
25
+ rename(path);
26
+
27
+ return path;
28
+ },
29
+ 'changeDir({path: __a})': 'changeDir(__a)',
30
+ 'changeDir({path})': 'changeDir(path)',
31
+ 'changeDir(__object)': (vars, path) => {
32
+ convert(vars, path);
33
+
34
+ return path;
35
+ },
36
+ });
37
+
38
+ function convert(vars, path) {
39
+ const args = path.node.arguments;
40
+ const [obj] = path.get('arguments');
41
+ const properties = obj.get('properties');
42
+
43
+ for (const property of properties) {
44
+ const keyPath = property.get('key');
45
+
46
+ if (keyPath.isIdentifier({name: 'path'})) {
47
+ args.unshift(property.node.value);
48
+ property.remove();
49
+ break;
50
+ }
51
+ }
52
+ }
53
+
package/lib/index.js CHANGED
@@ -8,5 +8,6 @@ module.exports.rules = {
8
8
  ...getRule('convert-io-mv-to-io-move'),
9
9
  ...getRule('convert-io-cp-to-io-copy'),
10
10
  ...getRule('convert-io-write-to-io-create-directory'),
11
+ ...getRule('convert-load-dir-to-change-dir'),
11
12
  };
12
13
 
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@putout/plugin-cloudcmd",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
+ "type": "commonjs",
4
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
- "description": "putout plugin adds ability to transform code to new API of Cloud Commander",
6
- "homepage": "http://github.com/coderaiser/putout",
6
+ "description": "🐊Putout plugin adds ability to transform code to new API of Cloud Commander",
7
+ "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-cloudcmd#readme",
7
8
  "main": "lib/index.js",
9
+ "commitType": "colon",
8
10
  "release": false,
9
11
  "tag": false,
10
12
  "changelog": false,
@@ -13,21 +15,15 @@
13
15
  "url": "git://github.com/coderaiser/putout.git"
14
16
  },
15
17
  "scripts": {
16
- "prepublishOnly": "madrun prepublishOnly",
17
18
  "test": "madrun test",
18
19
  "watch:test": "madrun watch:test",
19
20
  "lint": "madrun lint",
21
+ "fresh:lint": "madrun fresh:lint",
22
+ "lint:fresh": "madrun lint:fresh",
20
23
  "fix:lint": "madrun fix:lint",
21
- "putout": "madrun putout",
22
24
  "coverage": "madrun coverage",
23
25
  "report": "madrun report"
24
26
  },
25
- "nyc": {
26
- "exclude": [
27
- "*/**/*.spec.js",
28
- "test"
29
- ]
30
- },
31
27
  "dependencies": {},
32
28
  "keywords": [
33
29
  "putout",
@@ -36,24 +32,23 @@
36
32
  "cloudcmd"
37
33
  ],
38
34
  "devDependencies": {
39
- "@putout/plugin-remove-unused-expressions": "^1.2.1",
40
- "@putout/plugin-strict-mode": "^1.2.1",
41
- "@putout/test": "^2.0.0",
42
- "coveralls": "^3.0.0",
43
- "eslint": "^7.6.0",
44
- "eslint-plugin-node": "^11.0.0",
45
- "eslint-plugin-putout": "^5.0.1",
46
- "lerna": "^3.8.5",
47
- "madrun": "^7.0.0",
48
- "nodemon": "^2.0.1",
49
- "nyc": "^15.0.1"
35
+ "@putout/plugin-remove-unused-expressions": "*",
36
+ "@putout/plugin-strict-mode": "*",
37
+ "@putout/test": "^5.0.0",
38
+ "c8": "^7.5.0",
39
+ "eslint": "^8.0.1",
40
+ "eslint-plugin-n": "^15.2.4",
41
+ "eslint-plugin-putout": "^16.0.0",
42
+ "lerna": "^6.0.1",
43
+ "madrun": "^9.0.0",
44
+ "nodemon": "^2.0.1"
50
45
  },
51
46
  "peerDependencies": {
52
- "putout": ">=9"
47
+ "putout": ">=28"
53
48
  },
54
49
  "license": "MIT",
55
50
  "engines": {
56
- "node": ">=10"
51
+ "node": ">=16"
57
52
  },
58
53
  "publishConfig": {
59
54
  "access": "public"