jwalker 2.0.0 → 3.0.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/bin/index.js +36 -48
- package/eslint.config.mjs +63 -0
- package/lib/index.js +2 -4
- package/package.json +42 -37
package/bin/index.js
CHANGED
|
@@ -1,50 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'--'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
process.exit(0);
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
if (args.help === true) return help();
|
|
44
|
-
|
|
45
|
-
args.input = args.input || '--';
|
|
46
|
-
args.output = args.output || '--';
|
|
47
|
-
|
|
48
|
-
(args.input === '--' ? process.stdin : fs.createReadStream(args.input))
|
|
49
|
-
.pipe(new JWalker({ passthroughNonJSON: args.passthrough, spaces: args.spaces }))
|
|
50
|
-
.pipe((args.output === '--' ? process.stdout : fs.createWriteStream(args.output)));
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
|
|
5
|
+
import argumentsParser from '@trenskow/arguments-parser';
|
|
6
|
+
|
|
7
|
+
import JWalker from '../lib/index.js';
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
input,
|
|
11
|
+
output,
|
|
12
|
+
spaces = '\t',
|
|
13
|
+
passthrough
|
|
14
|
+
} = await argumentsParser().options({
|
|
15
|
+
'input': {
|
|
16
|
+
type: String,
|
|
17
|
+
default: '--',
|
|
18
|
+
description: 'Input file (-- for stdin).'
|
|
19
|
+
},
|
|
20
|
+
'output': {
|
|
21
|
+
type: String,
|
|
22
|
+
default: '--',
|
|
23
|
+
description: 'Output file (-- for stdout).'
|
|
24
|
+
},
|
|
25
|
+
'spaces': {
|
|
26
|
+
type: Number,
|
|
27
|
+
description: 'Use number of spaces for indentation (default is tab).'
|
|
28
|
+
},
|
|
29
|
+
'passthrough': {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false,
|
|
32
|
+
description: 'Passthrough non-JSON lines.'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
(input === '--' ? process.stdin : fs.createReadStream(input))
|
|
37
|
+
.pipe(new JWalker({ passthroughNonJSON: passthrough, spaces: spaces }))
|
|
38
|
+
.pipe((output === '--' ? process.stdout : fs.createWriteStream(output)));
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import js from '@eslint/js';
|
|
5
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
6
|
+
import { includeIgnoreFile } from '@eslint/compat';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
const compat = new FlatCompat({
|
|
11
|
+
baseDirectory: __dirname,
|
|
12
|
+
recommendedConfig: js.configs.recommended,
|
|
13
|
+
allConfig: js.configs.all
|
|
14
|
+
});
|
|
15
|
+
const gitIgnorePath = path.resolve(__dirname, '.gitignore');
|
|
16
|
+
|
|
17
|
+
export default [...compat.extends('eslint:recommended'),
|
|
18
|
+
includeIgnoreFile(gitIgnorePath), {
|
|
19
|
+
languageOptions: {
|
|
20
|
+
globals: {
|
|
21
|
+
...globals.node,
|
|
22
|
+
...globals.mocha,
|
|
23
|
+
Router: true,
|
|
24
|
+
Endpoint: true,
|
|
25
|
+
app: true
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
ecmaVersion: 'latest',
|
|
29
|
+
sourceType: 'module'
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
rules: {
|
|
33
|
+
indent: ['error', 'tab', {
|
|
34
|
+
SwitchCase: 1
|
|
35
|
+
}],
|
|
36
|
+
|
|
37
|
+
'linebreak-style': ['error', 'unix'],
|
|
38
|
+
quotes: ['error', 'single'],
|
|
39
|
+
semi: ['error', 'always'],
|
|
40
|
+
|
|
41
|
+
'no-console': ['error', {
|
|
42
|
+
allow: ['warn', 'error', 'info']
|
|
43
|
+
}],
|
|
44
|
+
|
|
45
|
+
'no-unused-vars': ['warn', {
|
|
46
|
+
argsIgnorePattern: '^_',
|
|
47
|
+
caughtErrors: 'none'
|
|
48
|
+
}],
|
|
49
|
+
|
|
50
|
+
'no-empty': ['error', {
|
|
51
|
+
allowEmptyCatch: true
|
|
52
|
+
}],
|
|
53
|
+
|
|
54
|
+
'no-trailing-spaces': ['error', {
|
|
55
|
+
ignoreComments: true
|
|
56
|
+
}],
|
|
57
|
+
|
|
58
|
+
'require-atomic-updates': 'off',
|
|
59
|
+
'no-implicit-globals': ['error'],
|
|
60
|
+
'eol-last': ['error', 'always'],
|
|
61
|
+
'comma-dangle': ['error', 'never']
|
|
62
|
+
}
|
|
63
|
+
}];
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,39 +1,44 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
2
|
+
"name": "jwalker",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "A JSON pretty-printer for each line in a stream. Useful for JSON logs.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"jwalker": "./bin/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "./node_modules/mocha/bin/mocha test/index.js"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/trenskow/jwalker.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"JSON",
|
|
19
|
+
"lint",
|
|
20
|
+
"pretty",
|
|
21
|
+
"print",
|
|
22
|
+
"line",
|
|
23
|
+
"readline",
|
|
24
|
+
"log",
|
|
25
|
+
"logs",
|
|
26
|
+
"stream"
|
|
27
|
+
],
|
|
28
|
+
"author": "Kristian Trenskow <trenskow@me.com>",
|
|
29
|
+
"license": "BSD-3-Clause",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/trenskow/jwalker/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/trenskow/jwalker#readme",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@eslint/compat": "^2.0.0",
|
|
36
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
37
|
+
"@eslint/js": "^9.39.2",
|
|
38
|
+
"eslint": "^9.39.2",
|
|
39
|
+
"globals": "^17.0.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@trenskow/arguments-parser": "^0.3.54"
|
|
43
|
+
}
|
|
39
44
|
}
|