@putout/plugin-cloudcmd 3.1.1 β 5.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 +57 -3
- package/lib/convert-arrow-to-declaration/index.js +17 -0
- package/lib/convert-io-cp-to-io-copy/index.js +2 -4
- package/lib/convert-io-mv-to-io-move/index.js +2 -4
- package/lib/convert-io-write-to-io-create-directory/index.js +3 -5
- package/lib/convert-load-dir-to-change-dir/index.js +9 -10
- package/lib/index.js +11 -10
- package/package.json +13 -14
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @putout/plugin-cloudcmd [![NPM version][NPMIMGURL]][NPMURL]
|
|
2
2
|
|
|
3
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"
|
|
4
|
+
[NPMURL]: https://npmjs.org/package/@putout/plugin-cloudcmd "npm"
|
|
5
5
|
|
|
6
6
|
π[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to transform to new [Cloud Commander](https://cloudcmd.io) API.
|
|
7
7
|
|
|
@@ -11,7 +11,14 @@
|
|
|
11
11
|
npm i putout @putout/plugin-cloudcmd -D
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- β
[convert-io-mv-to-io-move](#convert-io-mv-to-io-move);
|
|
17
|
+
- β
[convert-io-cp-to-io-copy](#convert-io-cp-to-io-copy);
|
|
18
|
+
- β
[convert-load-dir-to-change-dir](#convert-load-dir-to-change-dir);
|
|
19
|
+
- β
[convert-arrow-to-declaration](#convert-arrow-to-declaration);
|
|
20
|
+
|
|
21
|
+
## Config
|
|
15
22
|
|
|
16
23
|
```json
|
|
17
24
|
{
|
|
@@ -28,7 +35,8 @@ Add `.putout.json` with:
|
|
|
28
35
|
"rules": {
|
|
29
36
|
"cloudcmd/convert-io-mv-to-io-move": "on",
|
|
30
37
|
"cloudcmd/convert-io-cp-to-io-copy": "on",
|
|
31
|
-
"cloudcmd/convert-load-dir-to-change-dir": "on"
|
|
38
|
+
"cloudcmd/convert-load-dir-to-change-dir": "on",
|
|
39
|
+
"cloudcmd/convert-arrow-to-declaration": "on"
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
```
|
|
@@ -104,6 +112,52 @@ await CloudCmd.changeDir('/', {
|
|
|
104
112
|
});
|
|
105
113
|
```
|
|
106
114
|
|
|
115
|
+
# convert-arrow-to-declaration
|
|
116
|
+
|
|
117
|
+
Because right now all exported methods saved to global variable on top of a file.
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
CloudCmd.EditNamesVim = {
|
|
121
|
+
init,
|
|
122
|
+
show,
|
|
123
|
+
hide,
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Check out in π[Putout Editor](https://putout.cloudcmd.io/#/gist/8c21c0599b5d4d7c5faf49f3da604c9e/04a71d323fe1b0c25c1f34635c6f15eff805eff7).
|
|
128
|
+
|
|
129
|
+
## β Example of incorrect code
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
export const init = async (hello) => {
|
|
133
|
+
await CloudCmd.EditNames();
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const show = () => {
|
|
137
|
+
Events.addKey(listener);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const hide = () => {
|
|
141
|
+
CloudCmd.Edit.hide();
|
|
142
|
+
};
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## β
Example of correct code
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
export async function init(hello) {
|
|
149
|
+
await CloudCmd.EditNames();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function show() {
|
|
153
|
+
Events.addKey(listener);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function hide() {
|
|
157
|
+
CloudCmd.Edit.hide();
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
107
161
|
## License
|
|
108
162
|
|
|
109
163
|
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const report = () => `Use 'declaration' instead 'arrow' for 'init/show/hide'`;
|
|
2
|
+
|
|
3
|
+
export const match = () => ({
|
|
4
|
+
'export const __a = async (__args) => __body': isClientModule,
|
|
5
|
+
'export const __a = (__args) => __body': isClientModule,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const replace = () => ({
|
|
9
|
+
'export const __a = async (__args) => __body': 'export async function __a(__args) {__body}',
|
|
10
|
+
'export const __a = (__args) => __body': 'export function __a(__args) {__body}',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const isClientModule = ({__a}) => {
|
|
14
|
+
const {name} = __a;
|
|
15
|
+
|
|
16
|
+
return /^(init|show|hide)$/.test(name);
|
|
17
|
+
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
'
|
|
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
|
-
|
|
13
|
+
export const replace = () => ({
|
|
16
14
|
[cpFrom]: cpTo,
|
|
17
15
|
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
'
|
|
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
|
-
|
|
13
|
+
export const replace = () => ({
|
|
16
14
|
[mvFrom]: mvTo,
|
|
17
15
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
'
|
|
1
|
+
export const report = () => 'IO.createDirectory should be used instead of IO.write';
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
-
const {
|
|
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
|
-
|
|
9
|
+
export const report = () => `Use 'CloudCmd.changeDir()' instead of 'CloudCmd.loadDir()'`;
|
|
11
10
|
|
|
12
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
37
|
+
convert(path);
|
|
39
38
|
|
|
40
39
|
return path;
|
|
41
40
|
},
|
|
42
41
|
});
|
|
43
42
|
|
|
44
|
-
function convert(
|
|
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
|
-
|
|
53
|
+
remove(property);
|
|
55
54
|
break;
|
|
56
55
|
}
|
|
57
56
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import * as convertArrowToDeclaration from './convert-arrow-to-declaration/index.js';
|
|
2
|
+
import * as convertIoMvToIoMove from './convert-io-mv-to-io-move/index.js';
|
|
3
|
+
import * as convertIoCpToIoCopy from './convert-io-cp-to-io-copy/index.js';
|
|
4
|
+
import * as convertIoWriteToIoCreateDirectory from './convert-io-write-to-io-create-directory/index.js';
|
|
5
|
+
import * as convertLoadDirToChangeDir from './convert-load-dir-to-change-dir/index.js';
|
|
2
6
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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'),
|
|
7
|
+
export const rules = {
|
|
8
|
+
'convert-io-mv-to-io-move': convertIoMvToIoMove,
|
|
9
|
+
'convert-io-cp-to-io-copy': convertIoCpToIoCopy,
|
|
10
|
+
'convert-io-write-to-io-create-directory': convertIoWriteToIoCreateDirectory,
|
|
11
|
+
'convert-load-dir-to-change-dir': convertLoadDirToChangeDir,
|
|
12
|
+
'convert-arrow-to-declaration': convertArrowToDeclaration,
|
|
12
13
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-cloudcmd",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "5.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,22 @@
|
|
|
31
31
|
"cloudcmd"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@putout/eslint-flat": "^4.0.0",
|
|
34
35
|
"@putout/plugin-remove-unused-expressions": "*",
|
|
35
|
-
"@putout/
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"eslint": "^
|
|
39
|
-
"eslint-plugin-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"madrun": "^9.0.0",
|
|
43
|
-
"nodemon": "^2.0.1"
|
|
36
|
+
"@putout/test": "^15.0.0",
|
|
37
|
+
"c8": "^10.0.0",
|
|
38
|
+
"eslint": "^10.0.0-alpha.0",
|
|
39
|
+
"eslint-plugin-n": "^17.0.0",
|
|
40
|
+
"eslint-plugin-putout": "^30.0.0",
|
|
41
|
+
"madrun": "^12.0.0",
|
|
42
|
+
"nodemon": "^3.0.1"
|
|
44
43
|
},
|
|
45
44
|
"peerDependencies": {
|
|
46
|
-
"putout": ">=
|
|
45
|
+
"putout": ">=41"
|
|
47
46
|
},
|
|
48
47
|
"license": "MIT",
|
|
49
48
|
"engines": {
|
|
50
|
-
"node": ">=
|
|
49
|
+
"node": ">=22"
|
|
51
50
|
},
|
|
52
51
|
"publishConfig": {
|
|
53
52
|
"access": "public"
|