Skip to content

Commit 11202d1

Browse files
committed
feature: @putout/plugin-cloudcmd: convert to ESM
1 parent 8e4c2d6 commit 11202d1

File tree

11 files changed

+33
-52
lines changed

11 files changed

+33
-52
lines changed
Original file line numberDiff line numberDiff line change
@@ -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';
42

53
const cpFrom = `
64
IO.cp({
@@ -12,6 +10,6 @@ const cpFrom = `
1210

1311
const cpTo = 'IO.copy(__a, __b, __c)';
1412

15-
module.exports.replace = () => ({
13+
export const replace = () => ({
1614
[cpFrom]: cpTo,
1715
});

packages/plugin-cloudcmd/lib/convert-io-cp-to-io-copy/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as convertIoCpToIoCopy from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const convertIoCpToIoCopy = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['cloudcmd/convert-io-cp-to-io-copy', convertIoCpToIoCopy],
97
],
Original file line numberDiff line numberDiff line change
@@ -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';
42

53
const mvFrom = `
64
IO.mv({
@@ -12,6 +10,6 @@ const mvFrom = `
1210

1311
const mvTo = 'IO.move(__a, __b, __c)';
1412

15-
module.exports.replace = () => ({
13+
export const replace = () => ({
1614
[mvFrom]: mvTo,
1715
});

packages/plugin-cloudcmd/lib/convert-io-mv-to-io-move/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as convertIoMvToIoMove from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const convertIoMvToIoMove = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['cloudcmd/convert-io-mv-to-io-move', convertIoMvToIoMove],
97
],

packages/plugin-cloudcmd/lib/convert-io-write-to-io-create-directory/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
1+
export const report = () => 'IO.createDirectory should be used instead of IO.write';
22

3-
module.exports.report = () => 'IO.createDirectory should be used instead of IO.write';
4-
5-
module.exports.match = () => ({
3+
export const match = () => ({
64
'IO.write("__a")': ({__a}) => {
75
return __a.value.endsWith('?dir');
86
},
@@ -11,7 +9,7 @@ module.exports.match = () => ({
119
},
1210
});
1311

14-
module.exports.replace = () => ({
12+
export const replace = () => ({
1513
'IO.write(`${__a}?dir`)': 'IO.createDirectory(__a)',
1614
'IO.write("__a")': ({__a}) => {
1715
const value = __a.value.replace(/\?dir$/, '');

packages/plugin-cloudcmd/lib/convert-io-write-to-io-create-directory/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as convertIoWriteToIoCreateDirectory from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const convertIoWriteToIoCreateDirectory = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['cloudcmd/convert-io-write-to-io-create-directory', convertIoWriteToIoCreateDirectory],
97
],

packages/plugin-cloudcmd/lib/convert-load-dir-to-change-dir/index.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
'use strict';
1+
import {operator} from 'putout';
22

3-
const {operator} = require('putout');
43
const {rename, remove} = operator;
54

65
const renameAll = (path) => {
76
rename(path, 'loadDir', 'changeDir');
87
};
98

10-
module.exports.report = () => `Use 'CloudCmd.changeDir()' instead of 'CloudCmd.loadDir()'`;
9+
export const report = () => `Use 'CloudCmd.changeDir()' instead of 'CloudCmd.loadDir()'`;
1110

12-
module.exports.replace = () => ({
11+
export const replace = () => ({
1312
'CloudCmd.loadDir({path})': 'CloudCmd.changeDir(path)',
1413
'CloudCmd.loadDir({path: __a})': 'CloudCmd.changeDir(__a)',
1514
'CloudCmd.loadDir(__object)': (vars, path) => {

packages/plugin-cloudcmd/lib/convert-load-dir-to-change-dir/index.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const plugin = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['cloudcmd/convert-load-dir-to-change-dir', plugin],
97
],

packages/plugin-cloudcmd/lib/index.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
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';
25

3-
const convertIoMvToIoMove = require('./convert-io-mv-to-io-move');
4-
const convertIoCpToIoCopy = require('./convert-io-cp-to-io-copy');
5-
const convertIoWriteToIoCreateDirectory = require('./convert-io-write-to-io-create-directory');
6-
const convertLoadDirToChangeDir = require('./convert-load-dir-to-change-dir');
7-
8-
module.exports.rules = {
6+
export const rules = {
97
'convert-io-mv-to-io-move': convertIoMvToIoMove,
108
'convert-io-cp-to-io-copy': convertIoCpToIoCopy,
119
'convert-io-write-to-io-create-directory': convertIoWriteToIoCreateDirectory,

packages/plugin-cloudcmd/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@putout/plugin-cloudcmd",
33
"version": "3.1.1",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
66
"description": "🐊Putout plugin adds ability to transform code to new API of Cloud Commander",
77
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-cloudcmd#readme",
@@ -43,11 +43,11 @@
4343
"nodemon": "^3.0.1"
4444
},
4545
"peerDependencies": {
46-
"putout": ">=29"
46+
"putout": ">=39"
4747
},
4848
"license": "MIT",
4949
"engines": {
50-
"node": ">=16"
50+
"node": ">=20"
5151
},
5252
"publishConfig": {
5353
"access": "public"

packages/plugin-cloudcmd/test/cloudcmd.spec.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as cloudcmd from '../lib/index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const cloudcmd = require('..');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['cloudcmd', cloudcmd],
97
],

0 commit comments

Comments
 (0)