view-ignored 0.4.4 → 0.4.6
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/README.md +2 -1
- package/bin/viewig +0 -0
- package/out/browser/binds/plugins/jsr.js +11 -3
- package/out/browser/binds/scanner.js +8 -12
- package/out/browser/fs/directory.d.ts +1 -1
- package/out/cli.js +36 -35
- package/out/styling.js +2 -2
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ tools.
|
|
|
10
10
|
|
|
11
11
|
## Requirements
|
|
12
12
|
|
|
13
|
-
Requires Node.js
|
|
13
|
+
Requires Node.js v18 or later.
|
|
14
14
|
|
|
15
15
|
## Highlights
|
|
16
16
|
|
|
@@ -48,6 +48,7 @@ view-ignored --help
|
|
|
48
48
|
# scan: git (default) and npm
|
|
49
49
|
viewig scan
|
|
50
50
|
viewig scan --target=npm
|
|
51
|
+
viewig sc -t npm
|
|
51
52
|
viewig scan --parsable
|
|
52
53
|
|
|
53
54
|
# scan: plugins (space, comma or pipe separated)
|
package/bin/viewig
CHANGED
|
File without changes
|
|
@@ -3,6 +3,7 @@ import { z } from 'zod';
|
|
|
3
3
|
import { BadSourceError, Directory, InvalidPatternError, } from '../../index.js';
|
|
4
4
|
import { ScannerGitignore } from '../scanner.js';
|
|
5
5
|
import * as git from './git.js';
|
|
6
|
+
import stripJsonComments from 'strip-json-comments';
|
|
6
7
|
const id = 'jsr';
|
|
7
8
|
const name = 'JSR';
|
|
8
9
|
const icon = {
|
|
@@ -24,7 +25,10 @@ export function isValidManifestJsr(value) {
|
|
|
24
25
|
return z.object({
|
|
25
26
|
name: z.string(),
|
|
26
27
|
version: z.string(),
|
|
27
|
-
exports: z.
|
|
28
|
+
exports: z.union([
|
|
29
|
+
z.string(),
|
|
30
|
+
z.record(z.string(), z.string()),
|
|
31
|
+
]).optional(),
|
|
28
32
|
exclude: z.array(z.string()).optional(),
|
|
29
33
|
include: z.array(z.string()).optional(),
|
|
30
34
|
publish: z.object({
|
|
@@ -59,9 +63,13 @@ export const sourceSearch = (priority, scanner) => function (tree, o) {
|
|
|
59
63
|
continue;
|
|
60
64
|
}
|
|
61
65
|
if (/^(deno|jsr).jsonc?$/.test(sourceFile.base)) {
|
|
62
|
-
|
|
66
|
+
let manifestString = o.modules.fs.readFileSync(sourceFile.absolutePath).toString();
|
|
67
|
+
if (sourceFile.base[sourceFile.base.length - 1] === 'c') {
|
|
68
|
+
manifestString = stripJsonComments(manifestString, { whitespace: false, trailingCommas: false });
|
|
69
|
+
}
|
|
70
|
+
const manifest = JSON.parse(manifestString);
|
|
63
71
|
if (!isValidManifestJsr(manifest)) {
|
|
64
|
-
throw new BadSourceError(sourceFile, 'Must have \'name\', \'version\'.');
|
|
72
|
+
throw new BadSourceError(sourceFile, 'Must have \'name\', \'version\', valid \'export\', \'exclude\' and \'include\'.');
|
|
65
73
|
}
|
|
66
74
|
const { exclude, include, publish } = manifest;
|
|
67
75
|
if (exclude === undefined && include === undefined
|
|
@@ -55,20 +55,16 @@ export class ScannerMinimatch {
|
|
|
55
55
|
}
|
|
56
56
|
isMatch(p, pattern, options) {
|
|
57
57
|
const patternList = pattern.split('\n');
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
while (patternList.length) {
|
|
59
|
+
const pat = patternList.pop();
|
|
60
|
+
if (!/^[*/]$/.test(pat[pat.length - 1])) {
|
|
61
|
+
patternList.push(pat + '/**');
|
|
62
|
+
}
|
|
60
63
|
if (pat[0] === '!') {
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
if (!isMatch(p, pat.substring(1), options))
|
|
65
|
+
continue;
|
|
66
|
+
return false;
|
|
63
67
|
}
|
|
64
|
-
positiveList.push(pat);
|
|
65
|
-
}
|
|
66
|
-
for (const pat of negativeList) {
|
|
67
|
-
if (!isMatch(p, pat, options))
|
|
68
|
-
continue;
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
for (const pat of positiveList) {
|
|
72
68
|
if (!isMatch(p, pat, options))
|
|
73
69
|
continue;
|
|
74
70
|
return true;
|
|
@@ -4,7 +4,7 @@ import { type RealScanOptions } from '../lib.js';
|
|
|
4
4
|
import { File } from './file.js';
|
|
5
5
|
export type DeepStreamEventEmitter = EventEmitter<DeepStreamEventMap> & {
|
|
6
6
|
endPromise: Promise<DeepStreamDataRoot>;
|
|
7
|
-
run():
|
|
7
|
+
run(): Promise<DeepStreamDataRoot>;
|
|
8
8
|
};
|
|
9
9
|
export type DeepStreamDataRoot = {
|
|
10
10
|
tree: Directory;
|
package/out/cli.js
CHANGED
|
@@ -222,36 +222,37 @@ export async function actionScan() {
|
|
|
222
222
|
cwd: optionsReal.cwd,
|
|
223
223
|
modules: optionsReal.modules,
|
|
224
224
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let name = decorCondition(flags.decor, { ifNerd: bind.icon?.value, postfix: ' ' })
|
|
238
|
-
+ bind.name;
|
|
239
|
-
if (bind.icon?.color !== undefined) {
|
|
240
|
-
name = chalk.hex('#' + bind.icon.color)(name);
|
|
225
|
+
try {
|
|
226
|
+
if (flags.parsable) {
|
|
227
|
+
await stream.run();
|
|
228
|
+
const fileInfoList = await scan(stream, {
|
|
229
|
+
...optionsReal,
|
|
230
|
+
target: flags.target,
|
|
231
|
+
filter: flags.filter,
|
|
232
|
+
maxDepth: flags.depth,
|
|
233
|
+
});
|
|
234
|
+
console.log(fileInfoList.map(fileInfo => fileInfo.relativePath + (flags.showSources && fileInfo.source !== undefined
|
|
235
|
+
? '<' + (fileInfo.source.relativePath)
|
|
236
|
+
: '')).join(','));
|
|
241
237
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
238
|
+
else {
|
|
239
|
+
let name = decorCondition(flags.decor, { ifNerd: bind.icon?.value, postfix: ' ' })
|
|
240
|
+
+ bind.name;
|
|
241
|
+
if (bind.icon?.color !== undefined) {
|
|
242
|
+
name = chalk.hex('#' + bind.icon.color)(name);
|
|
243
|
+
}
|
|
244
|
+
const context = {
|
|
245
|
+
progress: { current: 0, directories: 0, files: 0, total: 0 },
|
|
246
|
+
fileInfoList: [],
|
|
247
|
+
stream,
|
|
248
|
+
message: '',
|
|
249
|
+
reading: new Promise((resolve) => {
|
|
250
|
+
stream.on('end', (data) => {
|
|
251
|
+
resolve(data);
|
|
252
|
+
});
|
|
253
|
+
}),
|
|
254
|
+
};
|
|
255
|
+
await context.stream.run();
|
|
255
256
|
console.log(`${name} ${chalk.hex('#73A7DE')(flags.filter)} ${cwd}`);
|
|
256
257
|
await oraPromise(async (spinner) => {
|
|
257
258
|
const proc = scan(context.stream, {
|
|
@@ -302,16 +303,16 @@ export async function actionScan() {
|
|
|
302
303
|
if (bind.testCommand) {
|
|
303
304
|
message += '\n';
|
|
304
305
|
message += `${chalk.blue(infoSymbol)}You can use ${highlight(`'${bind.testCommand}'`, chalk)} to check if the list is valid.`;
|
|
306
|
+
message += '\n';
|
|
305
307
|
}
|
|
306
|
-
message += '\n';
|
|
307
308
|
context.message = message;
|
|
309
|
+
console.log(context.message);
|
|
308
310
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
if (!(error instanceof ViewIgnoredError)) {
|
|
314
|
+
logError(format(error), { title: 'view-ignored - Error while scan.' });
|
|
313
315
|
}
|
|
314
|
-
console.log(context.message);
|
|
315
316
|
}
|
|
316
317
|
}
|
|
317
318
|
/**
|
package/out/styling.js
CHANGED
|
@@ -13,9 +13,9 @@ export function highlight(text, chalk) {
|
|
|
13
13
|
const rbracketsSquare = /(\[|])/g;
|
|
14
14
|
const rnumber = /\d+/g;
|
|
15
15
|
const rspecial = /(true|false|null|Infinity)/g;
|
|
16
|
-
const rall = new RegExp(
|
|
16
|
+
const rall = new RegExp([ansiRegex(), rstring, rseparator, rbracketsSquare, rnumber, rspecial]
|
|
17
17
|
.map(r => `(${typeof r === 'string' ? r : r.source})`)
|
|
18
|
-
.join('|')
|
|
18
|
+
.join('|'), 'g');
|
|
19
19
|
const colored = text.replaceAll(rall, (match) => {
|
|
20
20
|
if (match.match(ansiRegex()) !== null) {
|
|
21
21
|
return match;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "view-ignored",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Retrieve list of files ignored/included by Git, NPM, Yarn, JSR, VSCE or other tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"prerelease": "bun run build:pub && bun run lint",
|
|
12
12
|
"test": "bun run node --test out/**/*.test.js",
|
|
13
13
|
"build": "bun run build:clean && bun run tsc -p src",
|
|
14
|
-
"build:pub": "bun run build:clean && bun run tsc -p src --sourceMap false
|
|
15
|
-
"build:watch": "bun run build:clean && bun run tsc -p src --watch",
|
|
14
|
+
"build:pub": "bun run build:clean && bun run tsc -p src/tsconfig.pub.json --sourceMap false",
|
|
16
15
|
"build:clean": "rm -rf out",
|
|
17
16
|
"lint": "bun run eslint .",
|
|
18
17
|
"release:major": "bun run release-it --increment=major",
|
|
@@ -35,6 +34,9 @@
|
|
|
35
34
|
"url": "https://github.com/Mopsgamer/view-ignored/issues"
|
|
36
35
|
},
|
|
37
36
|
"homepage": "https://github.com/Mopsgamer/view-ignored",
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18"
|
|
39
|
+
},
|
|
38
40
|
"exports": {
|
|
39
41
|
".": {
|
|
40
42
|
"default": "./out/index.js",
|
|
@@ -81,15 +83,16 @@
|
|
|
81
83
|
"minimatch": "^10.0.3",
|
|
82
84
|
"ora": "^8.2.0",
|
|
83
85
|
"p-limit": "^6.2.0",
|
|
86
|
+
"strip-json-comments": "^5.0.2",
|
|
84
87
|
"treeify": "^1.1.0",
|
|
85
88
|
"yaml": "^2.8.0",
|
|
86
|
-
"zod": "^
|
|
89
|
+
"zod": "^4.0.14"
|
|
87
90
|
},
|
|
88
91
|
"devDependencies": {
|
|
89
92
|
"@eslint/js": "^9.30.1",
|
|
90
93
|
"@release-it/keep-a-changelog": "^7.0.0",
|
|
91
94
|
"@stylistic/eslint-plugin": "^5.1.0",
|
|
92
|
-
"@types/node": "
|
|
95
|
+
"@types/node": "18",
|
|
93
96
|
"@types/treeify": "^1.0.3",
|
|
94
97
|
"eslint": "^9.30.1",
|
|
95
98
|
"fs-fixture": "^2.8.1",
|