view-ignored 0.8.1 → 0.9.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/README.md +5 -3
- package/out/browser_stream.d.ts +1 -1
- package/out/patterns/gitignore.js +10 -3
- package/out/patterns/jsrjson.js +9 -5
- package/out/patterns/matcherStream.d.ts +1 -1
- package/out/patterns/packagejson.js +16 -12
- package/out/patterns/pattern.d.ts +5 -0
- package/out/patterns/patternMatcher.d.ts +2 -2
- package/out/patterns/resolveSources.js +3 -6
- package/out/patterns/signedPattern.d.ts +8 -37
- package/out/patterns/signedPattern.js +21 -64
- package/out/patterns/source.d.ts +2 -2
- package/out/patterns/source.js +3 -4
- package/out/patterns/stringCompile.js +3 -1
- package/out/targets/bun.js +93 -48
- package/out/targets/deno.js +38 -8
- package/out/targets/git.js +7 -6
- package/out/targets/jsr.js +33 -7
- package/out/targets/jsrManifest.d.ts +10 -0
- package/out/targets/jsrManifest.js +9 -0
- package/out/targets/npm.js +78 -46
- package/out/targets/npmManifest.d.ts +46 -0
- package/out/targets/npmManifest.js +23 -0
- package/out/targets/vsce.js +66 -39
- package/out/targets/yarn.js +43 -44
- package/out/targets/yarnClassic.js +67 -44
- package/out/unixify.d.ts +1 -0
- package/out/unixify.js +3 -0
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -146,28 +146,30 @@ The following built-in scanners are available:
|
|
|
146
146
|
- Check this scanner by running `git ls-files --others --exclude-standard --cached`.
|
|
147
147
|
- NPM ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/npm.ts))
|
|
148
148
|
- Expecting to be compatible with PNPM, and others.
|
|
149
|
+
- Validates `package.json`.
|
|
149
150
|
- Reads `package.json` `files` field, `.npmignore` and `.gitignore`.
|
|
150
151
|
- Starts searching from `.` (current working directory).
|
|
151
|
-
- No additional checks for `name`, `version` or `publishConfig`.
|
|
152
152
|
- Check this scanner by running `npm pack --dry-run`.
|
|
153
153
|
- Bun ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/bun.ts))
|
|
154
154
|
- Bun tries to mimic NPM, but that does not mean it behaves the same way.
|
|
155
155
|
- Check this scanner by running `bun pm pack --dry-run`.
|
|
156
156
|
- Yarn ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/yarn.ts))
|
|
157
157
|
- Modern Berry behavior.
|
|
158
|
+
- Validates `package.json`.
|
|
158
159
|
- Reads `package.json` `files` field, `.npmignore` and `.gitignore`.
|
|
159
160
|
- Requires `package.json`: includes paths from `main`, `module`, `browser` and `bin`.
|
|
160
161
|
- Starts searching from `.` (current working directory).
|
|
161
162
|
- `YarnClassic` is available. ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/yarnClassic.ts))
|
|
162
163
|
- VSCE ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/vsce.ts))
|
|
164
|
+
- Validates `package.json`.
|
|
163
165
|
- Reads `package.json` `files` field, `.vscodeignore` and `.gitignore`.
|
|
164
166
|
- Starts searching from `.` (current working directory).
|
|
165
167
|
- Check this scanner by running `vsce ls`.
|
|
166
168
|
- JSR ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/jsr.ts))
|
|
167
|
-
-
|
|
169
|
+
- Validates and reads `jsr.json(c)` `include` and `exclude` fields.
|
|
168
170
|
- Starts searching from `.` (current working directory).
|
|
169
171
|
- Deno ([implementation](https://github.com/Mopsgamer/view-ignored/tree/main/src/targets/deno.ts))
|
|
170
|
-
-
|
|
172
|
+
- Validates and reads `jsr.json(c)` and `deno.json(c)` `include` and `exclude` fields.
|
|
171
173
|
- Starts searching from `.` (current working directory).
|
|
172
174
|
|
|
173
175
|
## See also
|
package/out/browser_stream.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ import { sourcePushNegatable } from "./source.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export function extractGitignore(source, content) {
|
|
11
11
|
extract(source, content);
|
|
12
|
-
|
|
12
|
+
for (const element of source.pattern) {
|
|
13
|
+
signedPatternCompile(element);
|
|
14
|
+
}
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Extracts and compiles patterns from the file.
|
|
@@ -20,10 +22,14 @@ export function extractGitignore(source, content) {
|
|
|
20
22
|
*/
|
|
21
23
|
export function extractGitignoreNocase(source, content) {
|
|
22
24
|
extract(source, content);
|
|
23
|
-
|
|
25
|
+
for (const element of source.pattern) {
|
|
26
|
+
signedPatternCompile(element, { nocase: true });
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
extractGitignore;
|
|
26
30
|
function extract(source, content) {
|
|
31
|
+
const include = { compiled: null, excludes: false, pattern: [] };
|
|
32
|
+
const exclude = { compiled: null, excludes: true, pattern: [] };
|
|
27
33
|
for (let line of content.toString().split("\n")) {
|
|
28
34
|
line = line.trim();
|
|
29
35
|
if (line === "" || line.startsWith("#")) {
|
|
@@ -33,6 +39,7 @@ function extract(source, content) {
|
|
|
33
39
|
if (cdx >= 0) {
|
|
34
40
|
line = line.substring(-cdx);
|
|
35
41
|
}
|
|
36
|
-
sourcePushNegatable(
|
|
42
|
+
sourcePushNegatable(line, false, include, exclude);
|
|
37
43
|
}
|
|
44
|
+
source.pattern.push(include, exclude);
|
|
38
45
|
}
|
package/out/patterns/jsrjson.js
CHANGED
|
@@ -19,6 +19,8 @@ const parse = type("string")
|
|
|
19
19
|
*/
|
|
20
20
|
export function extractJsrJson(source, content, ctx) {
|
|
21
21
|
const dist = parse(content.toString());
|
|
22
|
+
const include = { compiled: null, excludes: false, pattern: [] };
|
|
23
|
+
const exclude = { compiled: null, excludes: true, pattern: [] };
|
|
22
24
|
if (dist instanceof type.errors) {
|
|
23
25
|
source.error = new Error("Invalid '" + source.path + "': " + dist.summary, { cause: dist });
|
|
24
26
|
ctx.failed.push(source);
|
|
@@ -26,21 +28,23 @@ export function extractJsrJson(source, content, ctx) {
|
|
|
26
28
|
}
|
|
27
29
|
if (!dist.publish) {
|
|
28
30
|
if (dist.exclude) {
|
|
29
|
-
|
|
31
|
+
exclude.pattern.push(...dist.exclude);
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
else if (dist.publish.exclude) {
|
|
33
|
-
|
|
35
|
+
exclude.pattern.push(...dist.publish.exclude);
|
|
34
36
|
}
|
|
35
37
|
if (!dist.publish) {
|
|
36
38
|
if (dist.include) {
|
|
37
|
-
|
|
39
|
+
include.pattern.push(...dist.include);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
else if (dist.publish.include) {
|
|
41
|
-
|
|
43
|
+
include.pattern.push(...dist.publish.include);
|
|
44
|
+
}
|
|
45
|
+
for (const element of source.pattern) {
|
|
46
|
+
signedPatternCompile(element);
|
|
42
47
|
}
|
|
43
|
-
signedPatternCompile(source.pattern);
|
|
44
48
|
}
|
|
45
49
|
extractJsrJson;
|
|
46
50
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
1
|
import type { Dirent } from "node:fs";
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
3
|
import type { MatcherContext } from "../patterns/matcherContext.js";
|
|
4
4
|
import type { ScanOptions, FsAdapter } from "../types.js";
|
|
5
5
|
import type { SignedPatternMatch } from "./signedPattern.js";
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { type } from "arktype";
|
|
2
|
+
import { npmManifestParse } from "../targets/npmManifest.js";
|
|
2
3
|
import { signedPatternCompile } from "./resolveSources.js";
|
|
3
4
|
import { sourcePushNegatable } from "./source.js";
|
|
4
|
-
const npmManifest = type({
|
|
5
|
-
"files?": "string[]",
|
|
6
|
-
});
|
|
7
|
-
const parse = type("string")
|
|
8
|
-
.pipe((s) => JSON.parse(s))
|
|
9
|
-
.pipe(npmManifest);
|
|
10
5
|
/**
|
|
11
6
|
* Extracts and compiles patterns from the file.
|
|
12
7
|
*
|
|
@@ -16,8 +11,11 @@ const parse = type("string")
|
|
|
16
11
|
*/
|
|
17
12
|
export function extractPackageJson(source, content) {
|
|
18
13
|
const result = extract(source, content);
|
|
19
|
-
if (result === undefined)
|
|
20
|
-
|
|
14
|
+
if (result === undefined) {
|
|
15
|
+
for (const element of source.pattern) {
|
|
16
|
+
signedPatternCompile(element);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
21
19
|
if (result === "error")
|
|
22
20
|
return;
|
|
23
21
|
return result;
|
|
@@ -31,15 +29,20 @@ export function extractPackageJson(source, content) {
|
|
|
31
29
|
*/
|
|
32
30
|
export function extractPackageJsonNocase(source, content) {
|
|
33
31
|
const result = extract(source, content);
|
|
34
|
-
if (result === undefined)
|
|
35
|
-
|
|
32
|
+
if (result === undefined) {
|
|
33
|
+
for (const element of source.pattern) {
|
|
34
|
+
signedPatternCompile(element, { nocase: true });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
36
37
|
if (result === "error")
|
|
37
38
|
return;
|
|
38
39
|
return result;
|
|
39
40
|
}
|
|
40
41
|
function extract(source, content) {
|
|
41
42
|
source.inverted = true;
|
|
42
|
-
const
|
|
43
|
+
const include = { compiled: null, excludes: false, pattern: [] };
|
|
44
|
+
const exclude = { compiled: null, excludes: true, pattern: [] };
|
|
45
|
+
const dist = npmManifestParse(content.toString());
|
|
43
46
|
if (dist instanceof type.errors) {
|
|
44
47
|
source.error = new Error("Invalid '" + source.path + "': " + dist.summary, { cause: dist });
|
|
45
48
|
return "error";
|
|
@@ -48,7 +51,8 @@ function extract(source, content) {
|
|
|
48
51
|
return "none";
|
|
49
52
|
}
|
|
50
53
|
for (const pattern of dist.files) {
|
|
51
|
-
sourcePushNegatable(
|
|
54
|
+
sourcePushNegatable(pattern, true, include, exclude);
|
|
52
55
|
}
|
|
56
|
+
source.pattern.push(include, exclude);
|
|
53
57
|
}
|
|
54
58
|
extractPackageJson;
|
|
@@ -8,6 +8,11 @@ import { type StringCompileOptions } from "./stringCompile.js";
|
|
|
8
8
|
* @since 0.6.0
|
|
9
9
|
*/
|
|
10
10
|
export type PatternMinimatch = {
|
|
11
|
+
/**
|
|
12
|
+
* The regular expression instance.
|
|
13
|
+
*
|
|
14
|
+
* @since 0.6.0
|
|
15
|
+
*/
|
|
11
16
|
re: RegExp;
|
|
12
17
|
/**
|
|
13
18
|
* The original pattern string this minimatch was compiled from.
|
|
@@ -13,11 +13,11 @@ export type PatternMatcher = {
|
|
|
13
13
|
*
|
|
14
14
|
* @since 0.6.0
|
|
15
15
|
*/
|
|
16
|
-
internal: SignedPattern;
|
|
16
|
+
internal: SignedPattern[];
|
|
17
17
|
/**
|
|
18
18
|
* External patterns are sourced from existing project files at runtime.
|
|
19
19
|
*
|
|
20
20
|
* @since 0.6.0
|
|
21
21
|
*/
|
|
22
|
-
external: SignedPattern;
|
|
22
|
+
external: SignedPattern[];
|
|
23
23
|
};
|
|
@@ -11,10 +11,7 @@ import { patternCompile } from "./pattern.js";
|
|
|
11
11
|
* @since 0.6.0
|
|
12
12
|
*/
|
|
13
13
|
export function signedPatternCompile(signedPattern, options) {
|
|
14
|
-
signedPattern.compiled =
|
|
15
|
-
include: patternCompile(signedPattern.include, options),
|
|
16
|
-
exclude: patternCompile(signedPattern.exclude, options),
|
|
17
|
-
};
|
|
14
|
+
signedPattern.compiled = patternCompile(signedPattern.pattern, options);
|
|
18
15
|
return signedPattern;
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
@@ -110,10 +107,10 @@ async function tryExtractor(cwd, fs, ctx, extractor) {
|
|
|
110
107
|
const path = relative(cwd, abs);
|
|
111
108
|
const name = path.substring(path.lastIndexOf("/") + 1);
|
|
112
109
|
const newSource = {
|
|
113
|
-
inverted: false,
|
|
114
110
|
name,
|
|
115
111
|
path,
|
|
116
|
-
|
|
112
|
+
inverted: false,
|
|
113
|
+
pattern: [],
|
|
117
114
|
};
|
|
118
115
|
let buff;
|
|
119
116
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PatternFinderOptions } from "./extractor.js";
|
|
2
|
-
import { type Pattern, type PatternMinimatch } from "./pattern.js";
|
|
3
2
|
import type { Source } from "./source.js";
|
|
3
|
+
import { type Pattern, type PatternMinimatch } from "./pattern.js";
|
|
4
4
|
/**
|
|
5
5
|
* Represents a set of include and exclude patterns.
|
|
6
6
|
* These patterns are positive minimatch patterns.
|
|
@@ -18,17 +18,17 @@ export type SignedPattern = {
|
|
|
18
18
|
*
|
|
19
19
|
* @see {@link signedPatternIgnores} provides the ignoring algorithm.
|
|
20
20
|
*
|
|
21
|
-
* @since 0.
|
|
21
|
+
* @since 0.9.0
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
pattern: Pattern;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* If `true`, pattern "test" will exclude file named "test".
|
|
26
26
|
*
|
|
27
27
|
* @see {@link signedPatternIgnores} provides the ignoring algorithm.
|
|
28
28
|
*
|
|
29
|
-
* @since 0.
|
|
29
|
+
* @since 0.9.0
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
excludes: boolean;
|
|
32
32
|
/**
|
|
33
33
|
* Provides compiled ignored or included file and directory patterns.
|
|
34
34
|
*
|
|
@@ -36,24 +36,7 @@ export type SignedPattern = {
|
|
|
36
36
|
*
|
|
37
37
|
* @since 0.6.0
|
|
38
38
|
*/
|
|
39
|
-
compiled: null |
|
|
40
|
-
/**
|
|
41
|
-
* Provides compiled ignored or included file and directory patterns.
|
|
42
|
-
*
|
|
43
|
-
* @see {@link signedPatternIgnores} provides the ignoring algorithm.
|
|
44
|
-
*
|
|
45
|
-
* @since 0.6.0
|
|
46
|
-
*/
|
|
47
|
-
include: PatternMinimatch[];
|
|
48
|
-
/**
|
|
49
|
-
* Provides compiled ignored or included file and directory patterns.
|
|
50
|
-
*
|
|
51
|
-
* @see {@link signedPatternIgnores} provides the ignoring algorithm.
|
|
52
|
-
*
|
|
53
|
-
* @since 0.6.0
|
|
54
|
-
*/
|
|
55
|
-
exclude: PatternMinimatch[];
|
|
56
|
-
};
|
|
39
|
+
compiled: null | PatternMinimatch[];
|
|
57
40
|
};
|
|
58
41
|
/**
|
|
59
42
|
* @see {@link signedPatternIgnores}
|
|
@@ -103,24 +86,12 @@ export interface SignedPatternIgnoresOptions extends PatternFinderOptions {
|
|
|
103
86
|
*
|
|
104
87
|
* @since 0.6.0
|
|
105
88
|
*/
|
|
106
|
-
internal: SignedPattern;
|
|
89
|
+
internal: SignedPattern[];
|
|
107
90
|
}
|
|
108
91
|
/**
|
|
109
92
|
* Checks whether a given entry should be ignored based on internal and external patterns.
|
|
110
93
|
* Populates unknown sources using {@link resolveSources}.
|
|
111
94
|
*
|
|
112
|
-
* Algorithm:
|
|
113
|
-
* 1. Check internal exclude patterns. If matched, return true.
|
|
114
|
-
* 2. Check internal include patterns. If matched, return false.
|
|
115
|
-
* 3. Check external patterns:
|
|
116
|
-
* - If not inverted:
|
|
117
|
-
* a. Check external include patterns. If matched, return false.
|
|
118
|
-
* b. Check external exclude patterns. If matched, return true.
|
|
119
|
-
* - If inverted:
|
|
120
|
-
* a. Check external exclude patterns. If matched, return true.
|
|
121
|
-
* b. Check external include patterns. If matched, return false.
|
|
122
|
-
* 4. If no patterns matched, return the inverted state.
|
|
123
|
-
*
|
|
124
95
|
* @since 0.6.0
|
|
125
96
|
*/
|
|
126
97
|
export declare function signedPatternIgnores(options: SignedPatternIgnoresOptions): Promise<SignedPatternMatch>;
|
|
@@ -19,25 +19,21 @@ function signedPatternCompiledMatchInternal(options, path) {
|
|
|
19
19
|
let err;
|
|
20
20
|
const kind = "internal";
|
|
21
21
|
const signedPattern = options.internal;
|
|
22
|
-
const compiled = signedPattern.compiled; // no null
|
|
23
22
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (patternMatch) {
|
|
39
|
-
// return false
|
|
40
|
-
return { kind, pattern: patternMatch, ignored: false };
|
|
23
|
+
for (const si of signedPattern) {
|
|
24
|
+
const compiled = si.compiled;
|
|
25
|
+
if (compiled === null) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
;
|
|
29
|
+
[patternMatch, err] = patternRegExpTest(path, compiled);
|
|
30
|
+
if (err) {
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
if (patternMatch) {
|
|
34
|
+
// return true
|
|
35
|
+
return { kind, pattern: patternMatch, ignored: si.excludes };
|
|
36
|
+
}
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
39
|
catch (error) {
|
|
@@ -54,47 +50,20 @@ function signedPatternCompiledMatchExternal(options, path, source) {
|
|
|
54
50
|
let patternMatch = "";
|
|
55
51
|
let err;
|
|
56
52
|
const kind = "external";
|
|
57
|
-
const signedPattern = source.pattern;
|
|
58
|
-
const compiled = signedPattern.compiled; // no null
|
|
59
53
|
try {
|
|
60
|
-
|
|
61
|
-
;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
throw err;
|
|
54
|
+
for (const si of source.pattern) {
|
|
55
|
+
const compiled = si.compiled;
|
|
56
|
+
if (compiled === null) {
|
|
57
|
+
continue;
|
|
65
58
|
}
|
|
66
|
-
if (patternMatch) {
|
|
67
|
-
// return true
|
|
68
|
-
return { kind, source, pattern: patternMatch, ignored: true };
|
|
69
|
-
}
|
|
70
|
-
;
|
|
71
|
-
[patternMatch, err] = patternRegExpTest(path, compiled.include);
|
|
72
|
-
if (err) {
|
|
73
|
-
throw err;
|
|
74
|
-
}
|
|
75
|
-
if (patternMatch) {
|
|
76
|
-
// return false
|
|
77
|
-
return { kind, source, pattern: patternMatch, ignored: false };
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
59
|
;
|
|
82
|
-
[patternMatch, err] = patternRegExpTest(path, compiled
|
|
83
|
-
if (err) {
|
|
84
|
-
throw err;
|
|
85
|
-
}
|
|
86
|
-
if (patternMatch) {
|
|
87
|
-
// return false
|
|
88
|
-
return { kind, source, pattern: patternMatch, ignored: false };
|
|
89
|
-
}
|
|
90
|
-
;
|
|
91
|
-
[patternMatch, err] = patternRegExpTest(path, compiled.exclude);
|
|
60
|
+
[patternMatch, err] = patternRegExpTest(path, compiled);
|
|
92
61
|
if (err) {
|
|
93
62
|
throw err;
|
|
94
63
|
}
|
|
95
64
|
if (patternMatch) {
|
|
96
65
|
// return true
|
|
97
|
-
return { kind,
|
|
66
|
+
return { kind, pattern: patternMatch, ignored: si.excludes, source };
|
|
98
67
|
}
|
|
99
68
|
}
|
|
100
69
|
}
|
|
@@ -109,18 +78,6 @@ function signedPatternCompiledMatchExternal(options, path, source) {
|
|
|
109
78
|
* Checks whether a given entry should be ignored based on internal and external patterns.
|
|
110
79
|
* Populates unknown sources using {@link resolveSources}.
|
|
111
80
|
*
|
|
112
|
-
* Algorithm:
|
|
113
|
-
* 1. Check internal exclude patterns. If matched, return true.
|
|
114
|
-
* 2. Check internal include patterns. If matched, return false.
|
|
115
|
-
* 3. Check external patterns:
|
|
116
|
-
* - If not inverted:
|
|
117
|
-
* a. Check external include patterns. If matched, return false.
|
|
118
|
-
* b. Check external exclude patterns. If matched, return true.
|
|
119
|
-
* - If inverted:
|
|
120
|
-
* a. Check external exclude patterns. If matched, return true.
|
|
121
|
-
* b. Check external include patterns. If matched, return false.
|
|
122
|
-
* 4. If no patterns matched, return the inverted state.
|
|
123
|
-
*
|
|
124
81
|
* @since 0.6.0
|
|
125
82
|
*/
|
|
126
83
|
export async function signedPatternIgnores(options) {
|
|
@@ -131,7 +88,7 @@ export async function signedPatternIgnores(options) {
|
|
|
131
88
|
source = options.ctx.external.get(parent);
|
|
132
89
|
}
|
|
133
90
|
if (source === undefined || source === "none") {
|
|
134
|
-
return { kind: "missing-source", ignored:
|
|
91
|
+
return { kind: "missing-source", ignored: false };
|
|
135
92
|
}
|
|
136
93
|
if (typeof source === "object" && source.error) {
|
|
137
94
|
return { kind: "broken-source", ignored: true, source };
|
package/out/patterns/source.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type Source = {
|
|
|
14
14
|
*
|
|
15
15
|
* @since 0.6.0
|
|
16
16
|
*/
|
|
17
|
-
pattern: SignedPattern;
|
|
17
|
+
pattern: SignedPattern[];
|
|
18
18
|
/**
|
|
19
19
|
* Name of the source file.
|
|
20
20
|
*
|
|
@@ -54,4 +54,4 @@ export type Source = {
|
|
|
54
54
|
*
|
|
55
55
|
* @since 0.6.0
|
|
56
56
|
*/
|
|
57
|
-
export declare function sourcePushNegatable(
|
|
57
|
+
export declare function sourcePushNegatable(pattern: string, invert: boolean, include: SignedPattern, exclude: SignedPattern): void;
|
package/out/patterns/source.js
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @since 0.6.0
|
|
7
7
|
*/
|
|
8
|
-
export function sourcePushNegatable(
|
|
9
|
-
|
|
10
|
-
if (source.inverted) {
|
|
8
|
+
export function sourcePushNegatable(pattern, invert, include, exclude) {
|
|
9
|
+
if (invert) {
|
|
11
10
|
;
|
|
12
11
|
[exclude, include] = [include, exclude];
|
|
13
12
|
}
|
|
@@ -16,5 +15,5 @@ export function sourcePushNegatable(source, pattern) {
|
|
|
16
15
|
dist = include;
|
|
17
16
|
pattern = pattern.substring(1);
|
|
18
17
|
}
|
|
19
|
-
dist.push(pattern);
|
|
18
|
+
dist.pattern.push(pattern);
|
|
20
19
|
}
|
|
@@ -17,7 +17,9 @@ export function stringCompile(pattern, context = [], options) {
|
|
|
17
17
|
else if (!pattern.startsWith("**/")) {
|
|
18
18
|
pattern = "**/" + pattern;
|
|
19
19
|
}
|
|
20
|
-
pattern
|
|
20
|
+
if (!pattern.endsWith("/**")) {
|
|
21
|
+
pattern += "/**";
|
|
22
|
+
}
|
|
21
23
|
const re = makeRe(pattern, {
|
|
22
24
|
dot: true,
|
|
23
25
|
nonegate: true,
|
package/out/targets/bun.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { type } from "arktype";
|
|
1
2
|
import { signedPatternIgnores, signedPatternCompile, extractPackageJson, extractGitignore, } from "../patterns/index.js";
|
|
3
|
+
import { join, unixify } from "../unixify.js";
|
|
4
|
+
import { npmManifestParse } from "./npmManifest.js";
|
|
2
5
|
const extractors = [
|
|
3
6
|
{
|
|
4
7
|
extract: extractPackageJson,
|
|
@@ -13,59 +16,101 @@ const extractors = [
|
|
|
13
16
|
path: ".gitignore",
|
|
14
17
|
},
|
|
15
18
|
];
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"yarn.lock",
|
|
21
|
-
"pnpm-lock.yaml",
|
|
22
|
-
"bun.lockb",
|
|
23
|
-
"bun.lock", // npm includes it
|
|
24
|
-
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L189
|
|
25
|
-
".*.swp",
|
|
26
|
-
"._*",
|
|
27
|
-
".DS_Store",
|
|
28
|
-
".git",
|
|
29
|
-
".gitignore",
|
|
30
|
-
".hg",
|
|
31
|
-
".npmignore",
|
|
32
|
-
".npmrc",
|
|
33
|
-
".lock-wscript",
|
|
34
|
-
".svn",
|
|
35
|
-
"wafpickle-*",
|
|
36
|
-
"CVS",
|
|
37
|
-
"npm-debug.log",
|
|
38
|
-
// bun says it is "mentioned in the docs but does not appear to be ignored by default"
|
|
39
|
-
// but we know it should be /build/config.gypi, not just config.gypi, haha
|
|
40
|
-
// "config.gypi",
|
|
41
|
-
".env.production", // npm includes it
|
|
42
|
-
"bunfig.toml", // npm includes it
|
|
43
|
-
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L284
|
|
44
|
-
// manifest should be included, but bun ignores it on this line
|
|
45
|
-
// bun forces it later: https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2586
|
|
46
|
-
// "package.json",
|
|
47
|
-
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L285
|
|
48
|
-
"node_modules",
|
|
49
|
-
],
|
|
50
|
-
include: [
|
|
51
|
-
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2586
|
|
52
|
-
"package.json",
|
|
53
|
-
// the special?.* check works this way: https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2599
|
|
54
|
-
"LICENSE",
|
|
55
|
-
"LICENSE.*",
|
|
56
|
-
"LICENCE",
|
|
57
|
-
"LICENCE.*",
|
|
58
|
-
"README",
|
|
59
|
-
"README.*",
|
|
60
|
-
],
|
|
61
|
-
compiled: null,
|
|
19
|
+
const internalInclude = {
|
|
20
|
+
excludes: false,
|
|
21
|
+
pattern: [], // filled within init
|
|
22
|
+
compiled: [],
|
|
62
23
|
};
|
|
63
|
-
|
|
24
|
+
const internal = [
|
|
25
|
+
internalInclude,
|
|
26
|
+
signedPatternCompile({
|
|
27
|
+
excludes: true,
|
|
28
|
+
pattern: [
|
|
29
|
+
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L180
|
|
30
|
+
"package-lock.json",
|
|
31
|
+
"yarn.lock",
|
|
32
|
+
"pnpm-lock.yaml",
|
|
33
|
+
"bun.lockb",
|
|
34
|
+
"bun.lock", // npm includes it
|
|
35
|
+
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L189
|
|
36
|
+
".*.swp",
|
|
37
|
+
"._*",
|
|
38
|
+
".DS_Store",
|
|
39
|
+
".git",
|
|
40
|
+
".gitignore",
|
|
41
|
+
".hg",
|
|
42
|
+
".npmignore",
|
|
43
|
+
".npmrc",
|
|
44
|
+
".lock-wscript",
|
|
45
|
+
".svn",
|
|
46
|
+
"wafpickle-*",
|
|
47
|
+
"CVS",
|
|
48
|
+
"npm-debug.log",
|
|
49
|
+
// bun says it is "mentioned in the docs but does not appear to be ignored by default"
|
|
50
|
+
// but we know it should be /build/config.gypi, not just config.gypi, haha
|
|
51
|
+
// "config.gypi",
|
|
52
|
+
".env.production", // npm includes it
|
|
53
|
+
"bunfig.toml", // npm includes it
|
|
54
|
+
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L284
|
|
55
|
+
// manifest should be included, but bun ignores it on this line
|
|
56
|
+
// bun forces it later: https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2586
|
|
57
|
+
// "package.json",
|
|
58
|
+
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L285
|
|
59
|
+
"node_modules",
|
|
60
|
+
],
|
|
61
|
+
compiled: null,
|
|
62
|
+
}), // nocase should be false here
|
|
63
|
+
signedPatternCompile({
|
|
64
|
+
excludes: true,
|
|
65
|
+
pattern: [
|
|
66
|
+
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2586
|
|
67
|
+
"package.json",
|
|
68
|
+
// the special?.* check works this way: https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2599
|
|
69
|
+
"LICENSE",
|
|
70
|
+
"LICENSE.*",
|
|
71
|
+
"LICENCE",
|
|
72
|
+
"LICENCE.*",
|
|
73
|
+
"README",
|
|
74
|
+
"README.*",
|
|
75
|
+
],
|
|
76
|
+
compiled: null,
|
|
77
|
+
}, { nocase: true }),
|
|
78
|
+
];
|
|
64
79
|
/**
|
|
65
80
|
* @since 0.8.1
|
|
66
81
|
*/
|
|
67
82
|
export const Bun = {
|
|
68
|
-
|
|
83
|
+
async init({ fs, cwd }) {
|
|
84
|
+
let content;
|
|
85
|
+
const normalCwd = unixify(cwd);
|
|
86
|
+
try {
|
|
87
|
+
content = await fs.promises.readFile(normalCwd + "/" + "package.json");
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw new Error("Error while initializing Bun", { cause: error });
|
|
91
|
+
}
|
|
92
|
+
const dist = npmManifestParse(content.toString());
|
|
93
|
+
if (dist instanceof type.errors) {
|
|
94
|
+
throw new Error("Invalid 'package.json': " + dist.summary, { cause: dist });
|
|
95
|
+
}
|
|
96
|
+
const set = new Set();
|
|
97
|
+
function normal(path) {
|
|
98
|
+
const result = unixify(join(normalCwd, path)).substring(normalCwd.length);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L1440
|
|
102
|
+
if (typeof dist.bin === "string") {
|
|
103
|
+
set.add(normal(dist.bin));
|
|
104
|
+
}
|
|
105
|
+
else if (typeof dist.bin === "object" && dist.bin !== null) {
|
|
106
|
+
Object.values(dist.bin).forEach((binPath) => set.add(normal(binPath)));
|
|
107
|
+
}
|
|
108
|
+
// TODO: Bun should include bundled deps
|
|
109
|
+
// nothing else
|
|
110
|
+
// link zig code
|
|
111
|
+
internalInclude.pattern = Array.from(set);
|
|
112
|
+
signedPatternCompile(internalInclude, { nocase: true });
|
|
113
|
+
},
|
|
69
114
|
extractors,
|
|
70
115
|
ignores(o) {
|
|
71
116
|
return signedPatternIgnores({
|