redlint 3.5.0 β 3.6.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 +10 -0
- package/bin/redlint.js +38 -31
- package/lib/choose.js +0 -6
- package/lib/cli/version.js +1 -1
- package/lib/lint/lint.js +3 -4
- package/lib/lint/slave.js +1 -1
- package/lib/menu.js +18 -2
- package/lib/pack/slave.js +0 -1
- package/lib/run.js +1 -1
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/bin/redlint.js
CHANGED
|
@@ -21,23 +21,24 @@ import {lint} from '../lib/lint/lint.js';
|
|
|
21
21
|
import {pack} from '../lib/pack/pack.js';
|
|
22
22
|
import {extract} from '../lib/extract/extract.js';
|
|
23
23
|
import {debug} from '../lib/debug.js';
|
|
24
|
+
import {logo} from '../lib/help/logo.js';
|
|
24
25
|
import {version} from '../lib/cli/version.js';
|
|
25
26
|
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
isScan,
|
|
28
|
+
isScanDebug,
|
|
29
|
+
isFix,
|
|
30
|
+
isFixDebug,
|
|
31
|
+
isPack,
|
|
32
|
+
isPackDebug,
|
|
33
|
+
isExtract,
|
|
34
|
+
isExtractDebug,
|
|
35
|
+
isGenerate,
|
|
36
|
+
isGenerateSimple,
|
|
37
|
+
isHelp,
|
|
38
|
+
isVersion,
|
|
39
|
+
isDebug,
|
|
40
|
+
isBack,
|
|
41
|
+
isExit,
|
|
41
42
|
} from '../lib/menu.js';
|
|
42
43
|
|
|
43
44
|
const {log} = console;
|
|
@@ -52,6 +53,12 @@ await uiLoop(arg);
|
|
|
52
53
|
|
|
53
54
|
async function uiLoop(arg) {
|
|
54
55
|
if (!arg) {
|
|
56
|
+
if (header) {
|
|
57
|
+
console.log('Lint your files according to πPutout rules.\n');
|
|
58
|
+
process.stdout.write(logo);
|
|
59
|
+
console.log('');
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
arg = await choose();
|
|
56
63
|
|
|
57
64
|
if (!arg)
|
|
@@ -60,24 +67,24 @@ async function uiLoop(arg) {
|
|
|
60
67
|
header = false;
|
|
61
68
|
}
|
|
62
69
|
|
|
63
|
-
if (arg
|
|
70
|
+
if (isDebug(arg)) {
|
|
64
71
|
arg = await debug();
|
|
65
72
|
|
|
66
|
-
if (arg
|
|
73
|
+
if (isBack(arg))
|
|
67
74
|
return await uiLoop();
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
if (arg
|
|
77
|
+
if (isExit(arg))
|
|
71
78
|
process.exit();
|
|
72
79
|
|
|
73
|
-
if (arg
|
|
80
|
+
if (isVersion(arg))
|
|
74
81
|
return version({
|
|
75
82
|
log,
|
|
76
83
|
exit,
|
|
77
84
|
readFile,
|
|
78
85
|
});
|
|
79
86
|
|
|
80
|
-
if (arg
|
|
87
|
+
if (isHelp(arg)) {
|
|
81
88
|
help({
|
|
82
89
|
header,
|
|
83
90
|
});
|
|
@@ -91,14 +98,14 @@ async function uiLoop(arg) {
|
|
|
91
98
|
|
|
92
99
|
spinner.succeed();
|
|
93
100
|
|
|
94
|
-
if (arg
|
|
101
|
+
if (isGenerateSimple(arg)) {
|
|
95
102
|
await writeFile('.filesystem.json', lintJSON(stringify(convertToSimple(result))));
|
|
96
103
|
process.exit(0);
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
const filesystem = lintJSON(stringify(result));
|
|
100
107
|
|
|
101
|
-
if (arg
|
|
108
|
+
if (isScan(arg)) {
|
|
102
109
|
const places = await masterLint(filesystem, {
|
|
103
110
|
fix: false,
|
|
104
111
|
});
|
|
@@ -122,7 +129,7 @@ async function uiLoop(arg) {
|
|
|
122
129
|
process.exit(1);
|
|
123
130
|
}
|
|
124
131
|
|
|
125
|
-
if (arg
|
|
132
|
+
if (isPack(arg)) {
|
|
126
133
|
const result = await masterPack(CWD, filesystem);
|
|
127
134
|
await writeFile(join(CWD, 'filesystem.red'), result);
|
|
128
135
|
const spinner = ora(`pack 'filesystem.red'`).start();
|
|
@@ -131,7 +138,7 @@ async function uiLoop(arg) {
|
|
|
131
138
|
process.exit();
|
|
132
139
|
}
|
|
133
140
|
|
|
134
|
-
if (arg
|
|
141
|
+
if (isExtract(arg)) {
|
|
135
142
|
const filesystem = await readFile(join(CWD, 'filesystem.red'), 'utf8');
|
|
136
143
|
await masterExtract(CWD, filesystem);
|
|
137
144
|
const spinner = ora(`extract 'filesystem.red'`).start();
|
|
@@ -140,7 +147,7 @@ async function uiLoop(arg) {
|
|
|
140
147
|
process.exit();
|
|
141
148
|
}
|
|
142
149
|
|
|
143
|
-
if (arg
|
|
150
|
+
if (isExtractDebug(arg)) {
|
|
144
151
|
const filesystem = await readFile(join(CWD, 'filesystem.red'), 'utf8');
|
|
145
152
|
await extract(CWD, filesystem);
|
|
146
153
|
const spinner = ora(`extract 'filesystem.red'`).start();
|
|
@@ -149,7 +156,7 @@ async function uiLoop(arg) {
|
|
|
149
156
|
process.exit();
|
|
150
157
|
}
|
|
151
158
|
|
|
152
|
-
if (arg
|
|
159
|
+
if (isPackDebug(arg)) {
|
|
153
160
|
const result = pack(CWD, filesystem);
|
|
154
161
|
await writeFile(join(CWD, 'filesystem.red'), result);
|
|
155
162
|
|
|
@@ -157,8 +164,8 @@ async function uiLoop(arg) {
|
|
|
157
164
|
process.exit();
|
|
158
165
|
}
|
|
159
166
|
|
|
160
|
-
if (arg
|
|
161
|
-
const places = lint(filesystem, {
|
|
167
|
+
if (isScanDebug(arg)) {
|
|
168
|
+
const places = await lint(filesystem, {
|
|
162
169
|
fix: false,
|
|
163
170
|
});
|
|
164
171
|
|
|
@@ -176,7 +183,7 @@ async function uiLoop(arg) {
|
|
|
176
183
|
process.exit(1);
|
|
177
184
|
}
|
|
178
185
|
|
|
179
|
-
if (arg
|
|
186
|
+
if (isFixDebug(arg)) {
|
|
180
187
|
const places = lint(filesystem, {
|
|
181
188
|
fix: true,
|
|
182
189
|
});
|
|
@@ -195,7 +202,7 @@ async function uiLoop(arg) {
|
|
|
195
202
|
process.exit();
|
|
196
203
|
}
|
|
197
204
|
|
|
198
|
-
if (arg
|
|
205
|
+
if (isFix(arg)) {
|
|
199
206
|
await masterLint(filesystem, {
|
|
200
207
|
fix: true,
|
|
201
208
|
});
|
|
@@ -203,7 +210,7 @@ async function uiLoop(arg) {
|
|
|
203
210
|
process.exit();
|
|
204
211
|
}
|
|
205
212
|
|
|
206
|
-
if (arg
|
|
213
|
+
if (isGenerate(arg))
|
|
207
214
|
await writeFile('.filesystem.json', filesystem);
|
|
208
215
|
|
|
209
216
|
done(`generate '.filesystem.json'`);
|
package/lib/choose.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {logo} from './help/logo.js';
|
|
2
|
-
import process from 'node:process';
|
|
3
1
|
import {choose as chooseDialog} from '@putout/cli-choose';
|
|
4
2
|
import {
|
|
5
3
|
SCAN,
|
|
@@ -15,10 +13,6 @@ import {
|
|
|
15
13
|
} from './menu.js';
|
|
16
14
|
|
|
17
15
|
export const choose = async () => {
|
|
18
|
-
console.log('Lint your files according to πPutout rules.\n');
|
|
19
|
-
process.stdout.write(logo);
|
|
20
|
-
console.log('');
|
|
21
|
-
|
|
22
16
|
const command = await chooseDialog('Command:', [
|
|
23
17
|
SCAN,
|
|
24
18
|
FIX,
|
package/lib/cli/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const {parse} = JSON;
|
|
2
2
|
|
|
3
3
|
export const version = async ({log, exit, readFile}) => {
|
|
4
|
-
const packagePath = new URL('
|
|
4
|
+
const packagePath = new URL('../../package.json', import.meta.url);
|
|
5
5
|
const packageData = await readFile(packagePath);
|
|
6
6
|
const {version} = parse(packageData);
|
|
7
7
|
|
package/lib/lint/lint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
transformAsync,
|
|
3
3
|
parse,
|
|
4
4
|
} from 'putout';
|
|
5
5
|
import parseOptions from 'putout/parse-options';
|
|
@@ -9,15 +9,14 @@ import {
|
|
|
9
9
|
merge,
|
|
10
10
|
} from '@putout/processor-filesystem';
|
|
11
11
|
|
|
12
|
-
export const lint = (filesystem, {fix, progress = createProgress()} = {}) => {
|
|
12
|
+
export const lint = async (filesystem, {fix, progress = createProgress()} = {}) => {
|
|
13
13
|
const [{source}] = branch(filesystem);
|
|
14
14
|
const options = parseOptions({
|
|
15
15
|
name: '.filesystem.json',
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
const ast = parse(source);
|
|
19
|
-
|
|
20
|
-
const places = transform(ast, source, {
|
|
19
|
+
const places = await transformAsync(ast, source, {
|
|
21
20
|
fix,
|
|
22
21
|
fixCount: 1,
|
|
23
22
|
...options,
|
package/lib/lint/slave.js
CHANGED
package/lib/menu.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const SCAN = 'β
scan';
|
|
2
2
|
export const SCAN_DEBUG = 'β
scan: debug';
|
|
3
|
-
export const FIX = '
|
|
4
|
-
export const FIX_DEBUG = '
|
|
3
|
+
export const FIX = 'π¨ fix';
|
|
4
|
+
export const FIX_DEBUG = 'π¨ fix: debug';
|
|
5
5
|
export const PACK = 'π¬ pack';
|
|
6
6
|
export const PACK_DEBUG = 'π¬ pack';
|
|
7
7
|
export const EXTRACT = 'π extract';
|
|
@@ -13,3 +13,19 @@ export const VERSION = 'β version';
|
|
|
13
13
|
export const DEBUG = 'πΏ debug';
|
|
14
14
|
export const BACK = 'π back';
|
|
15
15
|
export const EXIT = 'πͺ exit';
|
|
16
|
+
|
|
17
|
+
export const isScan = (a) => a === SCAN || a === 'scan';
|
|
18
|
+
export const isScanDebug = (a) => a === SCAN_DEBUG || a === 'scan:debug';
|
|
19
|
+
export const isFix = (a) => a === FIX || a === 'fix';
|
|
20
|
+
export const isFixDebug = (a) => a === FIX_DEBUG || a === 'fix:debug';
|
|
21
|
+
export const isPack = (a) => a === PACK || a === 'debug';
|
|
22
|
+
export const isPackDebug = (a) => a === PACK_DEBUG || a === 'pack:debug';
|
|
23
|
+
export const isExtract = (a) => a === EXTRACT || a === 'extract';
|
|
24
|
+
export const isExtractDebug = (a) => a === EXTRACT_DEBUG || a === 'extract:debug';
|
|
25
|
+
export const isGenerate = (a) => a === GENERATE || a === 'generate';
|
|
26
|
+
export const isGenerateSimple = (a) => a === GENERATE_SIMPLE || a === 'generate:simple';
|
|
27
|
+
export const isHelp = (a) => a === HELP || a === 'help';
|
|
28
|
+
export const isVersion = (a) => a === VERSION || a === 'version';
|
|
29
|
+
export const isDebug = (a) => a === DEBUG || a === 'debug';
|
|
30
|
+
export const isBack = (a) => a === BACK || a === 'back';
|
|
31
|
+
export const isExit = (a) => a === EXIT || a === 'exit';
|
package/lib/pack/slave.js
CHANGED
package/lib/run.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Worker} from 'node:worker_threads';
|
|
2
2
|
import fullstore from 'fullstore';
|
|
3
3
|
|
|
4
|
-
export function run({test,workerData, slave, push, fix, start, end, fail, success, suffix}) {
|
|
4
|
+
export function run({test, workerData, slave, push, fix, start, end, fail, success, suffix}) {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
6
6
|
const worker = new Worker(slave, {
|
|
7
7
|
workerData,
|