redput 4.9.0 β 4.9.2
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
package/lib/write/index.js
CHANGED
|
@@ -3,20 +3,19 @@ import {tryToCatch} from 'try-to-catch';
|
|
|
3
3
|
import {isTSCode} from './is-ts/index.js';
|
|
4
4
|
import {runRule} from '../run-rule/run-rule.js';
|
|
5
5
|
import {writeReadme} from './nested/write-readme/write-readme.js';
|
|
6
|
-
import
|
|
7
|
-
updateNestedIndex,
|
|
8
|
-
updateOverallNestedFixtures,
|
|
9
|
-
updateOverallNestedTest,
|
|
10
|
-
writeNestedFixtures,
|
|
11
|
-
writeNestedRule,
|
|
12
|
-
writeNestedTests,
|
|
13
|
-
} from './nested/nested.js';
|
|
6
|
+
import * as nested from './nested/nested.js';
|
|
14
7
|
import {
|
|
15
8
|
writeFixtures,
|
|
16
9
|
writeRule,
|
|
17
10
|
writeTests,
|
|
18
11
|
} from './simple.js';
|
|
19
12
|
|
|
13
|
+
const {
|
|
14
|
+
updateNestedIndex,
|
|
15
|
+
updateOverallNestedFixtures,
|
|
16
|
+
updateOverallNestedTest,
|
|
17
|
+
} = nested;
|
|
18
|
+
|
|
20
19
|
export const writePlugin = async (name, {rule, fixture, report, options, link}) => {
|
|
21
20
|
const [isNested] = await tryToCatch(access, './package.json');
|
|
22
21
|
|
|
@@ -36,7 +35,21 @@ export const writePlugin = async (name, {rule, fixture, report, options, link})
|
|
|
36
35
|
});
|
|
37
36
|
};
|
|
38
37
|
|
|
39
|
-
export const writeNested = async (name,
|
|
38
|
+
export const writeNested = async (name, overrides) => {
|
|
39
|
+
const {
|
|
40
|
+
rule,
|
|
41
|
+
fixture,
|
|
42
|
+
report,
|
|
43
|
+
options,
|
|
44
|
+
link,
|
|
45
|
+
writeNestedRule,
|
|
46
|
+
writeNestedFixtures,
|
|
47
|
+
writeNestedTests,
|
|
48
|
+
} = {
|
|
49
|
+
...nested,
|
|
50
|
+
...overrides,
|
|
51
|
+
};
|
|
52
|
+
|
|
40
53
|
const isTS = isTSCode(fixture);
|
|
41
54
|
const ext = isTS ? 'ts' : 'js';
|
|
42
55
|
const correct = runRule(rule, fixture);
|
|
@@ -45,7 +58,7 @@ export const writeNested = async (name, {rule, fixture, report, options, link})
|
|
|
45
58
|
await writeNestedFixtures(name, fixture, ext, correct);
|
|
46
59
|
await writeNestedTests(name, report);
|
|
47
60
|
|
|
48
|
-
await
|
|
61
|
+
await writeNestedOptional(name, {
|
|
49
62
|
options,
|
|
50
63
|
fixture,
|
|
51
64
|
ext,
|
|
@@ -6,6 +6,11 @@ const {
|
|
|
6
6
|
remove,
|
|
7
7
|
} = operator;
|
|
8
8
|
|
|
9
|
+
const createCodeblock = (source) => {
|
|
10
|
+
const escaped = source.replaceAll('`', '\\`');
|
|
11
|
+
return template.ast(`codeblock('js', \`${escaped}\`)`);
|
|
12
|
+
};
|
|
13
|
+
|
|
9
14
|
export const report = ({name}) => `Insert '${name}' to 'README.md'`;
|
|
10
15
|
|
|
11
16
|
export const fix = ({name, link, license, correct, incorrect}) => {
|
|
@@ -14,9 +19,9 @@ export const fix = ({name, link, license, correct, incorrect}) => {
|
|
|
14
19
|
const heading = template.ast(`heading(2, '${name}')`);
|
|
15
20
|
const paragraph = template.ast(`paragraph('Checkout in π', link(bold('Putout Editor'), '${link}'), '.')`);
|
|
16
21
|
const headingIncorrect = template.ast(`heading(3, 'β Example of incorrect code')`);
|
|
17
|
-
const codeIncorrect =
|
|
22
|
+
const codeIncorrect = createCodeblock(incorrect);
|
|
18
23
|
const headingCorrect = template.ast(`heading(3, 'β
Example of correct code')`);
|
|
19
|
-
const codeCorrect =
|
|
24
|
+
const codeCorrect = createCodeblock(correct);
|
|
20
25
|
|
|
21
26
|
const licenseType = license.getNextSibling();
|
|
22
27
|
|