redput 3.2.0 → 3.4.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
+ 2025.05.19, v3.4.0
2
+
3
+ feature:
4
+ - 92fe650 redput: isTSCode: add
5
+
6
+ 2025.05.08, v3.3.0
7
+
8
+ feature:
9
+ - e9285b6 redput: @putout/plugin-nodejs v16.1.0
10
+ - 0051886 redput: @putout/plugin-declare-before-reference v8.1.0
11
+
1
12
  2025.04.09, v3.2.0
2
13
 
3
14
  feature:
@@ -13,6 +13,7 @@ import {
13
13
  writeRule,
14
14
  writeTests,
15
15
  } from './simple.js';
16
+ import {isTSCode} from './is-ts/index.js';
16
17
 
17
18
  export const writePlugin = async (name, {rule, fixture, report, options}) => {
18
19
  const [isNested] = await tryToCatch(access, './package.json');
@@ -33,19 +34,23 @@ export const writePlugin = async (name, {rule, fixture, report, options}) => {
33
34
  };
34
35
 
35
36
  export const writeNested = async (name, {rule, fixture, report, options}) => {
37
+ const isTS = isTSCode(fixture);
38
+ const ext = isTS ? 'ts' : 'js';
39
+
36
40
  await writeNestedRule(name, rule, options);
37
- await writeNestedFixtures(name, fixture);
41
+ await writeNestedFixtures(name, fixture, ext);
38
42
  await writeNestedTests(name, report);
39
43
 
40
44
  await tryToCatch(writeNestedOptional, name, {
41
45
  options,
42
46
  fixture,
47
+ ext,
43
48
  });
44
49
  };
45
50
 
46
- export const writeNestedOptional = async (name, {options, fixture}) => {
51
+ export const writeNestedOptional = async (name, {options, fixture, ext}) => {
47
52
  await updateNestedIndex(name, options);
48
- await updateOverallNestedFixtures(name, fixture);
53
+ await updateOverallNestedFixtures(name, fixture, ext);
49
54
  await updateOverallNestedTest(name);
50
55
  };
51
56
 
@@ -0,0 +1,11 @@
1
+ import {parse} from 'putout';
2
+ import tryCatch from 'try-catch';
3
+
4
+ export const isTSCode = (source) => {
5
+ const [error] = tryCatch(parse, source, {
6
+ isTS: false,
7
+ });
8
+
9
+ return Boolean(error);
10
+ };
11
+
@@ -30,4 +30,3 @@ export const addRule = (name, source, ruleOptions) => {
30
30
 
31
31
  return code;
32
32
  };
33
-
@@ -24,13 +24,13 @@ export const writeNestedRule = async (name, data) => {
24
24
  await writeFile(`./${name}/index.js`, code);
25
25
  };
26
26
 
27
- export const writeNestedFixtures = async (name, data) => {
27
+ export const writeNestedFixtures = async (name, data, ext) => {
28
28
  await mkdir(`./${name}/fixture`, {
29
29
  recursive: true,
30
30
  });
31
31
 
32
- await writeFile(`./${name}/fixture/${name}.js`, data);
33
- await writeFile(`./${name}/fixture/${name}-fix.js`, data);
32
+ await writeFile(`./${name}/fixture/${name}.${ext}`, data);
33
+ await writeFile(`./${name}/fixture/${name}-fix.${ext}`, data);
34
34
  };
35
35
 
36
36
  export const writeNestedTests = async (name, report) => {
@@ -43,7 +43,7 @@ export const writeNestedTests = async (name, report) => {
43
43
  name,
44
44
  nested,
45
45
  report,
46
- importPath: '.',
46
+ importPath: './index.js',
47
47
  }));
48
48
  };
49
49
 
@@ -63,7 +63,7 @@ export const updateOverallNestedTest = async (name) => {
63
63
  await writeFile(`../test/${plugin}.js`, code);
64
64
  };
65
65
 
66
- export const updateOverallNestedFixtures = async (name, data) => {
67
- await writeFile(`../test/fixture/${name}.js`, data);
68
- await writeFile(`../test/fixture/${name}-fix.js`, data);
66
+ export const updateOverallNestedFixtures = async (name, data, ext) => {
67
+ await writeFile(`../test/fixture/${name}.${ext}`, data);
68
+ await writeFile(`../test/fixture/${name}-fix.${ext}`, data);
69
69
  };
@@ -14,4 +14,3 @@ export const prepareRule = (source) => {
14
14
 
15
15
  return code;
16
16
  };
17
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redput",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "description": "CLI tool to convert source from 🐊Putout Editor to files",
5
5
  "main": "lib/redput.js",
6
6
  "bin": {
@@ -56,9 +56,9 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@putout/plugin-declare": "^5.0.0",
59
- "@putout/plugin-declare-before-reference": "^6.2.0",
59
+ "@putout/plugin-declare-before-reference": "^8.1.0",
60
60
  "@putout/plugin-esm": "^4.0.0",
61
- "@putout/plugin-nodejs": "^15.0.0",
61
+ "@putout/plugin-nodejs": "^16.1.0",
62
62
  "@putout/plugin-putout": "^25.0.0",
63
63
  "@putout/plugin-remove-unused-variables": "^12.0.0",
64
64
  "node-fetch": "^3.3.2",
@@ -1,7 +1,7 @@
1
- const {createTest} = require('@putout/test');
2
- const plugin = require('{{ importPath }}');
1
+ import {createTest} from '@putout/test';
2
+ import * as plugin from '{{ importPath }}';
3
3
 
4
- const test = createTest(__dirname, {
4
+ const test = createTest(import.meta.url, {
5
5
  plugins: [
6
6
  ['{{ name }}', plugin],
7
7
  ],