redput 1.1.0 → 1.2.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
|
@@ -19,7 +19,6 @@ const templates = [
|
|
|
19
19
|
export const report = ({value}) => value;
|
|
20
20
|
export const fix = () => {};
|
|
21
21
|
export const traverse = ({push}) => {
|
|
22
|
-
const pushValue = process(push);
|
|
23
22
|
const visitors = {};
|
|
24
23
|
|
|
25
24
|
for (const template of templates) {
|
|
@@ -46,7 +45,7 @@ const process = ({push, template}) => (path) => {
|
|
|
46
45
|
});
|
|
47
46
|
|
|
48
47
|
path.stop();
|
|
49
|
-
}
|
|
48
|
+
};
|
|
50
49
|
|
|
51
50
|
function parseValue(a) {
|
|
52
51
|
if (isStringLiteral(a))
|
package/lib/redput.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import tryToCatch from 'try-to-catch';
|
|
2
|
+
import {exists} from 'fs';
|
|
3
|
+
import {access} from 'fs/promises';
|
|
2
4
|
import {getReport} from './get-report/get-report.js';
|
|
3
5
|
import {readGist} from './read-gist/read-gist.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
writeTestForNested,
|
|
8
|
-
} from './write.js';
|
|
6
|
+
import {writePlugin} from './write/index.js';
|
|
7
|
+
|
|
8
|
+
const SUCCESS = [null, 'Done'];
|
|
9
9
|
|
|
10
10
|
const URL = 'https://putout.cloudcmd.io/#/gist/';
|
|
11
11
|
|
|
@@ -34,9 +34,12 @@ export const redput = async (link, {token}) => {
|
|
|
34
34
|
const rule = lines.join('\n');
|
|
35
35
|
const report = getReport(rule);
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
writePlugin(name, {
|
|
38
|
+
rule,
|
|
39
|
+
fixture,
|
|
40
|
+
report,
|
|
41
|
+
});
|
|
40
42
|
|
|
41
|
-
return
|
|
43
|
+
return SUCCESS;
|
|
42
44
|
};
|
|
45
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import rendy from 'rendy';
|
|
2
|
+
import {
|
|
3
|
+
readFile,
|
|
4
|
+
writeFile,
|
|
5
|
+
mkdir,
|
|
6
|
+
access,
|
|
7
|
+
} from 'fs/promises';
|
|
8
|
+
import {
|
|
9
|
+
dirname,
|
|
10
|
+
basename,
|
|
11
|
+
join,
|
|
12
|
+
} from 'path';
|
|
13
|
+
import {
|
|
14
|
+
writeNestedFixtures,
|
|
15
|
+
writeNestedRule,
|
|
16
|
+
writeNestedTests,
|
|
17
|
+
} from './nested.js';
|
|
18
|
+
import {
|
|
19
|
+
writeFixtures,
|
|
20
|
+
writeRule,
|
|
21
|
+
writeTests,
|
|
22
|
+
} from './simple.js';
|
|
23
|
+
import tryToCatch from 'try-to-catch';
|
|
24
|
+
|
|
25
|
+
export const writePlugin = async (name, {rule, fixture, report}) => {
|
|
26
|
+
const [isNested] = await tryToCatch(access, './package.json');
|
|
27
|
+
|
|
28
|
+
if (isNested) {
|
|
29
|
+
return await writeNested(name, {
|
|
30
|
+
rule,
|
|
31
|
+
fixture,
|
|
32
|
+
report,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
await writeSimple(name, {
|
|
37
|
+
rule,
|
|
38
|
+
fixture,
|
|
39
|
+
report,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const writeNested = async (name, {rule, fixture, report}) => {
|
|
44
|
+
await writeNestedRule(name, rule);
|
|
45
|
+
await writeNestedFixtures(name, fixture);
|
|
46
|
+
await writeNestedTests(name, report);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const writeSimple = async (name, {rule, fixture, report}) => {
|
|
50
|
+
await writeRule(name, rule);
|
|
51
|
+
await writeFixtures(name, fixture);
|
|
52
|
+
await writeTests(name, report);
|
|
53
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import rendy from 'rendy';
|
|
2
1
|
import {
|
|
2
|
+
mkdir,
|
|
3
3
|
readFile,
|
|
4
4
|
writeFile,
|
|
5
|
-
mkdir,
|
|
6
5
|
} from 'fs/promises';
|
|
7
6
|
import {
|
|
8
|
-
dirname,
|
|
9
7
|
basename,
|
|
8
|
+
dirname,
|
|
10
9
|
join,
|
|
11
10
|
} from 'path';
|
|
11
|
+
import rendy from 'rendy';
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const writeNestedRule = async (name, data) => {
|
|
14
14
|
await mkdir(`./${name}`, {
|
|
15
15
|
recursive: true,
|
|
16
16
|
});
|
|
@@ -18,7 +18,7 @@ export const writeRule = async (name, data) => {
|
|
|
18
18
|
await writeFile(`./${name}/index.js`, data);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const writeNestedFixtures = async (name, data) => {
|
|
22
22
|
await mkdir(`./${name}/fixture`, {
|
|
23
23
|
recursive: true,
|
|
24
24
|
});
|
|
@@ -27,8 +27,8 @@ export const writeFixtures = async (name, data) => {
|
|
|
27
27
|
await writeFile(`./${name}/fixture/${name}-fix.js`, data);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export const
|
|
31
|
-
const templatePath = new URL('
|
|
30
|
+
export const writeNestedTests = async (name, report) => {
|
|
31
|
+
const templatePath = new URL('../../templates/plugin.js', import.meta.url).pathname;
|
|
32
32
|
const template = await readFile(templatePath, 'utf8');
|
|
33
33
|
const nestedPluginName = basename(dirname(join(process.cwd(), '..')));
|
|
34
34
|
const nested = nestedPluginName.replace('plugin-', '');
|
|
@@ -37,5 +37,6 @@ export const writeTestForNested = async (name, report) => {
|
|
|
37
37
|
name,
|
|
38
38
|
nested,
|
|
39
39
|
report,
|
|
40
|
+
importPath: '.',
|
|
40
41
|
}));
|
|
41
42
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mkdir,
|
|
3
|
+
readFile,
|
|
4
|
+
writeFile,
|
|
5
|
+
} from 'fs/promises';
|
|
6
|
+
import {
|
|
7
|
+
basename,
|
|
8
|
+
dirname,
|
|
9
|
+
join,
|
|
10
|
+
} from 'path';
|
|
11
|
+
import rendy from 'rendy';
|
|
12
|
+
|
|
13
|
+
export const writeRule = async (name, data) => {
|
|
14
|
+
await mkdir(`./lib`, {
|
|
15
|
+
recursive: true,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
await writeFile(`./lib/${name}.js`, data);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const writeFixtures = async (name, data) => {
|
|
22
|
+
await mkdir(`./test/fixture`, {
|
|
23
|
+
recursive: true,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await writeFile(`./test/fixture/${name}.js`, data);
|
|
27
|
+
await writeFile(`./test/fixture/${name}-fix.js`, data);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const writeTests = async (name, report) => {
|
|
31
|
+
const templatePath = new URL('../../templates/plugin.js', import.meta.url).pathname;
|
|
32
|
+
const template = await readFile(templatePath, 'utf8');
|
|
33
|
+
const nestedPluginName = basename(dirname(join(process.cwd(), '..')));
|
|
34
|
+
const nested = nestedPluginName.replace('plugin-', '');
|
|
35
|
+
|
|
36
|
+
await writeFile(`./test/${name}.js`, rendy(template, {
|
|
37
|
+
name,
|
|
38
|
+
nested,
|
|
39
|
+
report,
|
|
40
|
+
importPath: '..',
|
|
41
|
+
}));
|
|
42
|
+
};
|
package/package.json
CHANGED