redput 4.3.0 → 4.5.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/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2026.06.26, v4.5.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 69a0e06 redput: convert rule to ESM
|
|
5
|
+
|
|
6
|
+
2026.05.10, v4.4.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 102a7c3 redput: write: nested: search for the same name of js as plugin name first
|
|
10
|
+
- 0e81a86 redput: supertape v13.0.0
|
|
11
|
+
|
|
1
12
|
2026.05.05, v4.3.0
|
|
2
13
|
|
|
3
14
|
feature:
|
package/lib/write/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {access} from 'node:fs/promises';
|
|
2
2
|
import {tryToCatch} from 'try-to-catch';
|
|
3
|
+
import {isTSCode} from './is-ts/index.js';
|
|
3
4
|
import {
|
|
4
5
|
updateNestedIndex,
|
|
5
6
|
updateOverallNestedFixtures,
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
writeRule,
|
|
14
15
|
writeTests,
|
|
15
16
|
} from './simple.js';
|
|
16
|
-
import {isTSCode} from './is-ts/index.js';
|
|
17
17
|
|
|
18
18
|
export const writePlugin = async (name, {rule, fixture, report, options}) => {
|
|
19
19
|
const [isNested] = await tryToCatch(access, './package.json');
|
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
isSpreadElement,
|
|
11
11
|
} = types;
|
|
12
12
|
|
|
13
|
-
const {
|
|
13
|
+
const {superTraverse} = operator;
|
|
14
14
|
|
|
15
15
|
export const report = () => `Insert 'getRule()'`;
|
|
16
16
|
|
|
@@ -69,7 +69,7 @@ const createCheck = (options) => ({__object}) => {
|
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
superTraverse(__object, {
|
|
73
73
|
[`getRule('${name}')`]: () => {
|
|
74
74
|
exists = true;
|
|
75
75
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
access as _access,
|
|
2
3
|
mkdir,
|
|
3
4
|
readFile,
|
|
4
5
|
writeFile,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
} from 'node:path';
|
|
11
12
|
import process from 'node:process';
|
|
12
13
|
import {rendy} from 'rendy';
|
|
14
|
+
import {tryToCatch} from 'try-to-catch';
|
|
13
15
|
import {addRule} from './add-rule/add-rule.js';
|
|
14
16
|
import {insertTest} from './insert-test/insert-test.js';
|
|
15
17
|
import {prepareRule} from './prepare-rule/prepare-rule.js';
|
|
@@ -47,17 +49,37 @@ export const writeNestedTests = async (name, report) => {
|
|
|
47
49
|
}));
|
|
48
50
|
};
|
|
49
51
|
|
|
50
|
-
export const updateNestedIndex = async (name, options) => {
|
|
51
|
-
const
|
|
52
|
+
export const updateNestedIndex = async (name, options, overrides = {}) => {
|
|
53
|
+
const {
|
|
54
|
+
read = readFile,
|
|
55
|
+
write = writeFile,
|
|
56
|
+
access = _access,
|
|
57
|
+
plugin = getPluginName(process.cwd()),
|
|
58
|
+
} = overrides;
|
|
59
|
+
|
|
60
|
+
const [error] = await tryToCatch(access, `./${plugin}.js`);
|
|
61
|
+
|
|
62
|
+
if (error) {
|
|
63
|
+
const source = await read('./index.js', 'utf8');
|
|
64
|
+
const code = addRule(name, source, options);
|
|
65
|
+
|
|
66
|
+
await write(`./index.js`, code);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const source = await read(`./${plugin}.js`, 'utf8');
|
|
52
71
|
const code = addRule(name, source, options);
|
|
53
72
|
|
|
54
|
-
await
|
|
73
|
+
await write(`./${plugin}.js`, code);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const getPluginName = (dir) => {
|
|
77
|
+
const nestedPluginName = basename(dirname(join(dir)));
|
|
78
|
+
return nestedPluginName.replace('plugin-', '');
|
|
55
79
|
};
|
|
56
80
|
|
|
57
81
|
export const updateOverallNestedTest = async (name) => {
|
|
58
|
-
const
|
|
59
|
-
const plugin = nestedPluginName.replace('plugin-', '');
|
|
60
|
-
|
|
82
|
+
const plugin = getPluginName(process.cwd());
|
|
61
83
|
const source = await readFile(`../test/${plugin}.js`, 'utf8');
|
|
62
84
|
const code = insertTest(name, plugin, source);
|
|
63
85
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import putout from 'putout';
|
|
2
2
|
import * as putoutPlugin from '@putout/plugin-putout';
|
|
3
3
|
import * as declare from '@putout/plugin-declare';
|
|
4
|
+
import * as convertCommonjsToESM from '@putout/plugin-nodejs/convert-commonjs-to-esm';
|
|
4
5
|
import * as declareBeforeReference from '@putout/plugin-declare-before-reference';
|
|
5
6
|
|
|
6
7
|
export const prepareRule = (source) => {
|
|
7
8
|
const {code} = putout(source, {
|
|
8
9
|
plugins: [
|
|
10
|
+
['convert-commonjs-to-esm', convertCommonjsToESM],
|
|
9
11
|
['declare', declare],
|
|
10
12
|
['declare-before-reference', declareBeforeReference],
|
|
11
13
|
['putout', putoutPlugin],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redput",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "CLI tool to convert source from 🐊Putout Editor to files",
|
|
5
5
|
"main": "lib/redput.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,13 +16,11 @@
|
|
|
16
16
|
"lint:fresh": "madrun lint:fresh",
|
|
17
17
|
"fix:lint": "madrun fix:lint",
|
|
18
18
|
"test": "madrun test",
|
|
19
|
-
"test:mock": "madrun test:mock",
|
|
20
19
|
"watch:test": "madrun watch:test",
|
|
21
20
|
"watch:tape": "madrun watch:tape",
|
|
22
21
|
"watch:lint": "madrun watch:lint",
|
|
23
22
|
"watcher": "madrun watcher",
|
|
24
23
|
"coverage": "madrun coverage",
|
|
25
|
-
"coverage:es": "madrun coverage:es",
|
|
26
24
|
"report": "madrun report",
|
|
27
25
|
"wisdom": "madrun wisdom"
|
|
28
26
|
},
|
|
@@ -77,7 +75,7 @@
|
|
|
77
75
|
"nodemon": "^3.0.1",
|
|
78
76
|
"redlint": "^6.0.0",
|
|
79
77
|
"superc8": "^12.2.4",
|
|
80
|
-
"supertape": "^
|
|
78
|
+
"supertape": "^13.0.0"
|
|
81
79
|
},
|
|
82
80
|
"publishConfig": {
|
|
83
81
|
"access": "public"
|