view-ignored 0.10.1 → 0.11.1
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 +116 -66
- package/out/browser.d.ts +1 -0
- package/out/browser.js +1 -0
- package/out/browser_scan.d.ts +1 -3
- package/out/browser_scan.js +11 -46
- package/out/browser_stream.d.ts +6 -1
- package/out/browser_stream.js +6 -1
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/patterns/extractor.d.ts +7 -7
- package/out/patterns/gitignore.d.ts +2 -2
- package/out/patterns/gitignore.js +14 -6
- package/out/patterns/ignores.d.ts +17 -8
- package/out/patterns/index.d.ts +1 -0
- package/out/patterns/index.js +1 -0
- package/out/patterns/init.d.ts +2 -2
- package/out/patterns/initState.d.ts +0 -7
- package/out/patterns/jsrjson.d.ts +2 -3
- package/out/patterns/jsrjson.js +25 -38
- package/out/patterns/matcherContext.d.ts +12 -9
- package/out/patterns/matcherContextPatch.js +153 -73
- package/out/patterns/matcherStream.d.ts +19 -59
- package/out/patterns/matcherStream.js +75 -25
- package/out/patterns/matcherStreamTypes.d.ts +65 -0
- package/out/patterns/matcherStreamTypes.js +1 -0
- package/out/patterns/packagejson.d.ts +2 -2
- package/out/patterns/packagejson.js +11 -14
- package/out/patterns/patternCompile.js +35 -37
- package/out/patterns/patternList.d.ts +6 -2
- package/out/patterns/patternList.js +8 -3
- package/out/patterns/resolveSources.d.ts +22 -5
- package/out/patterns/resolveSources.js +153 -97
- package/out/patterns/resource.d.ts +16 -0
- package/out/patterns/resource.js +1 -0
- package/out/patterns/rule.d.ts +59 -11
- package/out/patterns/rule.js +101 -64
- package/out/patterns/source.d.ts +9 -17
- package/out/scan.d.ts +11 -3
- package/out/scan.js +16 -4
- package/out/scanCb.d.ts +16 -0
- package/out/scanCb.js +73 -0
- package/out/scanParallel.d.ts +18 -0
- package/out/scanParallel.js +146 -0
- package/out/stream.d.ts +6 -1
- package/out/stream.js +7 -2
- package/out/targets/bun.js +43 -36
- package/out/targets/deno.js +25 -23
- package/out/targets/git.js +3 -3
- package/out/targets/jsr.js +25 -23
- package/out/targets/jsrManifest.d.ts +8 -7
- package/out/targets/jsrManifest.js +40 -9
- package/out/targets/npm.js +30 -23
- package/out/targets/npmManifest.d.ts +18 -46
- package/out/targets/npmManifest.js +96 -23
- package/out/targets/target.d.ts +8 -16
- package/out/targets/vsce.js +20 -27
- package/out/targets/vsceManifest.d.ts +7 -0
- package/out/targets/vsceManifest.js +18 -0
- package/out/targets/yarn.js +48 -39
- package/out/targets/yarnClassic.js +20 -18
- package/out/types.d.ts +8 -7
- package/out/unixify.d.ts +1 -1
- package/out/unixify.js +40 -21
- package/out/walk.d.ts +42 -4
- package/out/walk.js +146 -92
- package/package.json +42 -27
- package/out/getDepth.d.ts +0 -4
- package/out/getDepth.js +0 -21
- package/out/opendir.d.ts +0 -3
- package/out/opendir.js +0 -28
package/out/scan.d.ts
CHANGED
|
@@ -4,10 +4,7 @@ export type * from "./types.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Scan the directory for included files based on the provided targets.
|
|
6
6
|
*
|
|
7
|
-
* Note that this function uses `fs.promises.readFile` and `fs.promises.opendir` without options within
|
|
8
|
-
* custom recursion, instead of `fs.promises.readdir` with `{ withFileTypes: true }.
|
|
9
7
|
* It also normalizes paths to use forward slashes.
|
|
10
|
-
* Please report any issues if you encounter problems related to this behavior.
|
|
11
8
|
*
|
|
12
9
|
* @param options Scan options.
|
|
13
10
|
* @returns A promise that resolves to a {@link MatcherContext} containing the scan results.
|
|
@@ -15,3 +12,14 @@ export type * from "./types.js";
|
|
|
15
12
|
* @since 0.6.0
|
|
16
13
|
*/
|
|
17
14
|
export declare function scan(options: ScanOptions): Promise<MatcherContext>;
|
|
15
|
+
/**
|
|
16
|
+
* Scan the directory for included files based on the provided targets.
|
|
17
|
+
*
|
|
18
|
+
* It also normalizes paths to use forward slashes.
|
|
19
|
+
*
|
|
20
|
+
* @param options Scan options.
|
|
21
|
+
* @param cb Callback function.
|
|
22
|
+
*
|
|
23
|
+
* @since 0.11.0
|
|
24
|
+
*/
|
|
25
|
+
export declare function scanCb(options: ScanOptions, cb: (err: Error | null, ctx: MatcherContext) => void): void;
|
package/out/scan.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import * as nodefs from "node:fs";
|
|
2
2
|
import * as process from "node:process";
|
|
3
3
|
import { scan as browserScan } from "./browser_scan.js";
|
|
4
|
+
import { scanCb as browserScanCb } from "./scanCb.js";
|
|
4
5
|
/**
|
|
5
6
|
* Scan the directory for included files based on the provided targets.
|
|
6
7
|
*
|
|
7
|
-
* Note that this function uses `fs.promises.readFile` and `fs.promises.opendir` without options within
|
|
8
|
-
* custom recursion, instead of `fs.promises.readdir` with `{ withFileTypes: true }.
|
|
9
8
|
* It also normalizes paths to use forward slashes.
|
|
10
|
-
* Please report any issues if you encounter problems related to this behavior.
|
|
11
9
|
*
|
|
12
10
|
* @param options Scan options.
|
|
13
11
|
* @returns A promise that resolves to a {@link MatcherContext} containing the scan results.
|
|
@@ -16,5 +14,19 @@ import { scan as browserScan } from "./browser_scan.js";
|
|
|
16
14
|
*/
|
|
17
15
|
export function scan(options) {
|
|
18
16
|
const { cwd = process.cwd(), fs = nodefs } = options;
|
|
19
|
-
return browserScan({
|
|
17
|
+
return browserScan({ cwd, fs, ...options });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Scan the directory for included files based on the provided targets.
|
|
21
|
+
*
|
|
22
|
+
* It also normalizes paths to use forward slashes.
|
|
23
|
+
*
|
|
24
|
+
* @param options Scan options.
|
|
25
|
+
* @param cb Callback function.
|
|
26
|
+
*
|
|
27
|
+
* @since 0.11.0
|
|
28
|
+
*/
|
|
29
|
+
export function scanCb(options, cb) {
|
|
30
|
+
const { cwd = process.cwd(), fs = nodefs } = options;
|
|
31
|
+
browserScanCb({ cwd, fs, ...options }, cb);
|
|
20
32
|
}
|
package/out/scanCb.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MatcherContext } from "./patterns/matcherContext.js";
|
|
2
|
+
import type { ScanOptions, FsAdapter } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Scan the directory for included files based on the provided targets.
|
|
5
|
+
*
|
|
6
|
+
* It also normalizes paths to use forward slashes.
|
|
7
|
+
*
|
|
8
|
+
* @param options Scan options.
|
|
9
|
+
* @param cb Callback function.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.11.0
|
|
12
|
+
*/
|
|
13
|
+
export declare function scanCb(options: ScanOptions & {
|
|
14
|
+
fs: FsAdapter;
|
|
15
|
+
cwd: string;
|
|
16
|
+
}, cb: (err: Error | null, ctx: MatcherContext) => void): void;
|
package/out/scanCb.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { scanParallel } from "./scanParallel.js";
|
|
2
|
+
import { unixify } from "./unixify.js";
|
|
3
|
+
import { walkPatchResult, walkPatchTotal, propagateTotals } from "./walk.js";
|
|
4
|
+
/**
|
|
5
|
+
* Scan the directory for included files based on the provided targets.
|
|
6
|
+
*
|
|
7
|
+
* It also normalizes paths to use forward slashes.
|
|
8
|
+
*
|
|
9
|
+
* @param options Scan options.
|
|
10
|
+
* @param cb Callback function.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.11.0
|
|
13
|
+
*/
|
|
14
|
+
export function scanCb(options, cb) {
|
|
15
|
+
const { target, cwd, within = ".", invert = false, depth: maxDepth = Infinity, signal = null, fastDepth = false, fastInternal = false, fs, } = options;
|
|
16
|
+
if (maxDepth < 0) {
|
|
17
|
+
cb(new TypeError("Depth must be a non-negative integer"), null);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const ctx = {
|
|
21
|
+
external: new Map(),
|
|
22
|
+
failed: [],
|
|
23
|
+
paths: new Map(),
|
|
24
|
+
total: new Map([[".", { totalDirs: 0, totalFiles: 0, totalMatchedFiles: 0 }]]),
|
|
25
|
+
};
|
|
26
|
+
const normalCwd = unixify(cwd);
|
|
27
|
+
const scanOptions = {
|
|
28
|
+
cwd: normalCwd,
|
|
29
|
+
depth: maxDepth,
|
|
30
|
+
fastDepth,
|
|
31
|
+
fastInternal,
|
|
32
|
+
fs,
|
|
33
|
+
invert,
|
|
34
|
+
signal,
|
|
35
|
+
target,
|
|
36
|
+
within,
|
|
37
|
+
};
|
|
38
|
+
const startScan = () => {
|
|
39
|
+
scanParallel({
|
|
40
|
+
external: ctx.external,
|
|
41
|
+
failed: ctx.failed,
|
|
42
|
+
onResult: (result) => {
|
|
43
|
+
if ("dir" in result) {
|
|
44
|
+
walkPatchTotal(ctx, scanOptions.depth, result);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
walkPatchResult(ctx, result);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
scanOptions,
|
|
51
|
+
within,
|
|
52
|
+
}, (err) => {
|
|
53
|
+
if (err) {
|
|
54
|
+
cb(err, null);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
propagateTotals(ctx.total);
|
|
58
|
+
cb(null, ctx);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
if (target.init) {
|
|
62
|
+
target.init({ cwd: normalCwd, fs, signal, target }, (err) => {
|
|
63
|
+
if (err) {
|
|
64
|
+
cb(err, null);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
startScan();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
startScan();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MatcherStream } from "./patterns/matcherStream.js";
|
|
2
|
+
import type { Resource, InvalidSource } from "./patterns/resource.js";
|
|
3
|
+
import type { ScanOptions } from "./types.js";
|
|
4
|
+
import { type WalkResult, type WalkTotal } from "./walk.js";
|
|
5
|
+
export interface ScanParallelOptions {
|
|
6
|
+
scanOptions: Required<ScanOptions>;
|
|
7
|
+
within: string;
|
|
8
|
+
stream?: MatcherStream;
|
|
9
|
+
external: Map<string, Resource>;
|
|
10
|
+
failed?: InvalidSource[];
|
|
11
|
+
onResult?: (result: WalkResult | WalkTotal) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Executes a parallel directory scan.
|
|
15
|
+
*
|
|
16
|
+
* @since 0.11.0
|
|
17
|
+
*/
|
|
18
|
+
export declare function scanParallel(options: ScanParallelOptions, cb: (err: Error | null, results: WalkResult[] | null) => void): void;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { resolveSources } from "./patterns/resolveSources.js";
|
|
2
|
+
import { join, unixify } from "./unixify.js";
|
|
3
|
+
import { walkIncludes } from "./walk.js";
|
|
4
|
+
/**
|
|
5
|
+
* Executes a parallel directory scan.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.11.0
|
|
8
|
+
*/
|
|
9
|
+
export function scanParallel(options, cb) {
|
|
10
|
+
const { scanOptions, stream, external, failed, onResult } = options;
|
|
11
|
+
scanOptions.cwd = unixify(scanOptions.cwd);
|
|
12
|
+
let { within } = options;
|
|
13
|
+
if (within.startsWith("./"))
|
|
14
|
+
within = within.slice(2);
|
|
15
|
+
const results = onResult ? null : [];
|
|
16
|
+
let activeTasks = 0;
|
|
17
|
+
let errorOccurred = null;
|
|
18
|
+
function walk(relPath, depth, resource, lowerRelPath) {
|
|
19
|
+
if (errorOccurred)
|
|
20
|
+
return;
|
|
21
|
+
activeTasks++;
|
|
22
|
+
scanOptions.fs.readdir(join(scanOptions.cwd, relPath), { withFileTypes: true }, (err, entries) => {
|
|
23
|
+
if (err) {
|
|
24
|
+
handleError(err);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
resolveSources({ ...scanOptions, dir: relPath, entries, external, resource }, (err, res) => {
|
|
28
|
+
if (err) {
|
|
29
|
+
handleError(err);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (res && "error" in res && res.error) {
|
|
33
|
+
if (failed) {
|
|
34
|
+
failed.push(res);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
handleError(res.error);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const len = entries.length;
|
|
42
|
+
const prefix = relPath === "." || relPath === "" ? "" : relPath + "/";
|
|
43
|
+
const lowerPrefix = lowerRelPath
|
|
44
|
+
? lowerRelPath + "/"
|
|
45
|
+
: prefix
|
|
46
|
+
? prefix.toLowerCase()
|
|
47
|
+
: "";
|
|
48
|
+
let pendingResults = len;
|
|
49
|
+
let dirFiles = 0;
|
|
50
|
+
let dirMatched = 0;
|
|
51
|
+
let dirDirs = 0;
|
|
52
|
+
if (len === 0) {
|
|
53
|
+
if (onResult) {
|
|
54
|
+
onResult({
|
|
55
|
+
depth,
|
|
56
|
+
dir: relPath,
|
|
57
|
+
dirs: 0,
|
|
58
|
+
files: 0,
|
|
59
|
+
ignored: false,
|
|
60
|
+
matched: 0,
|
|
61
|
+
type: "total",
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (let i = 0; i < len; i++) {
|
|
66
|
+
const entry = entries[i];
|
|
67
|
+
activeTasks++;
|
|
68
|
+
const name = entry.name;
|
|
69
|
+
const currentRelPath = prefix + name;
|
|
70
|
+
const currentLowerRelPath = lowerPrefix + name.toLowerCase();
|
|
71
|
+
walkIncludes({
|
|
72
|
+
depth,
|
|
73
|
+
entry,
|
|
74
|
+
lowerRelPath: currentLowerRelPath,
|
|
75
|
+
parentPath: relPath,
|
|
76
|
+
relPath: currentRelPath,
|
|
77
|
+
resource: res,
|
|
78
|
+
scanOptions,
|
|
79
|
+
stream,
|
|
80
|
+
}, (err, self) => {
|
|
81
|
+
if (err) {
|
|
82
|
+
handleError(err);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (self && self.match) {
|
|
86
|
+
if (self.isDir) {
|
|
87
|
+
dirDirs++;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
dirFiles++;
|
|
91
|
+
if (!self.match.ignored)
|
|
92
|
+
dirMatched++;
|
|
93
|
+
}
|
|
94
|
+
if (onResult) {
|
|
95
|
+
onResult(self);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
results.push(self);
|
|
99
|
+
}
|
|
100
|
+
if (entry.isDirectory() && self.next === 0) {
|
|
101
|
+
walk(currentRelPath, depth + 1, res, currentLowerRelPath);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
pendingResults--;
|
|
105
|
+
if (pendingResults === 0) {
|
|
106
|
+
if (onResult) {
|
|
107
|
+
onResult({
|
|
108
|
+
depth,
|
|
109
|
+
dir: relPath,
|
|
110
|
+
dirs: dirDirs,
|
|
111
|
+
files: dirFiles,
|
|
112
|
+
ignored: false,
|
|
113
|
+
matched: dirMatched,
|
|
114
|
+
type: "total",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
taskDone();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
taskDone();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function handleError(err) {
|
|
126
|
+
if (!errorOccurred) {
|
|
127
|
+
errorOccurred = err;
|
|
128
|
+
cb(err, null);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function taskDone() {
|
|
132
|
+
activeTasks--;
|
|
133
|
+
if (activeTasks === 0 && !errorOccurred) {
|
|
134
|
+
cb(null, results);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
let initialDepth = 0;
|
|
138
|
+
if (within !== "." && within !== "") {
|
|
139
|
+
const len = within.length;
|
|
140
|
+
for (let i = 0; i < len; i++) {
|
|
141
|
+
if (within.charCodeAt(i) === 47)
|
|
142
|
+
initialDepth++;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
walk(within, initialDepth, undefined, within === "." || within === "" ? "" : within.toLowerCase());
|
|
146
|
+
}
|
package/out/stream.d.ts
CHANGED
|
@@ -2,7 +2,12 @@ import type { MatcherStream } from "./patterns/matcherStream.js";
|
|
|
2
2
|
import type { ScanOptions } from "./types.js";
|
|
3
3
|
export type * from "./types.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Scan the directory for included files based on the provided targets.
|
|
6
|
+
*
|
|
7
|
+
* It also normalizes paths to use forward slashes.
|
|
8
|
+
*
|
|
9
|
+
* @param options Scan options.
|
|
10
|
+
* @returns A stream containing the scan results.
|
|
6
11
|
*
|
|
7
12
|
* @since 0.6.0
|
|
8
13
|
*/
|
package/out/stream.js
CHANGED
|
@@ -2,11 +2,16 @@ import * as nodefs from "node:fs";
|
|
|
2
2
|
import * as process from "node:process";
|
|
3
3
|
import { scanStream as browserStream } from "./browser_stream.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Scan the directory for included files based on the provided targets.
|
|
6
|
+
*
|
|
7
|
+
* It also normalizes paths to use forward slashes.
|
|
8
|
+
*
|
|
9
|
+
* @param options Scan options.
|
|
10
|
+
* @returns A stream containing the scan results.
|
|
6
11
|
*
|
|
7
12
|
* @since 0.6.0
|
|
8
13
|
*/
|
|
9
14
|
export function scanStream(options) {
|
|
10
15
|
const { cwd = process.cwd(), fs = nodefs } = options;
|
|
11
|
-
return browserStream({
|
|
16
|
+
return browserStream({ cwd, fs, ...options });
|
|
12
17
|
}
|
package/out/targets/bun.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type } from "arktype";
|
|
2
1
|
import { ruleTest, ruleCompile, extractPackageJson, extractGitignore, } from "../patterns/index.js";
|
|
3
2
|
import { join, unixify } from "../unixify.js";
|
|
4
3
|
import { npmManifestParse } from "./npmManifest.js";
|
|
@@ -17,13 +16,14 @@ const extractors = [
|
|
|
17
16
|
},
|
|
18
17
|
];
|
|
19
18
|
const internalInclude = {
|
|
19
|
+
compiled: [],
|
|
20
20
|
excludes: false,
|
|
21
21
|
pattern: [], // filled within init
|
|
22
|
-
compiled: [],
|
|
23
22
|
};
|
|
24
23
|
const internal = [
|
|
25
24
|
internalInclude,
|
|
26
25
|
ruleCompile({
|
|
26
|
+
compiled: null,
|
|
27
27
|
excludes: true,
|
|
28
28
|
pattern: [
|
|
29
29
|
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L180
|
|
@@ -58,9 +58,9 @@ const internal = [
|
|
|
58
58
|
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L285
|
|
59
59
|
"node_modules",
|
|
60
60
|
],
|
|
61
|
-
compiled: null,
|
|
62
61
|
}), // nocase should be false here
|
|
63
62
|
ruleCompile({
|
|
63
|
+
compiled: null,
|
|
64
64
|
excludes: true,
|
|
65
65
|
pattern: [
|
|
66
66
|
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L2586
|
|
@@ -73,46 +73,53 @@ const internal = [
|
|
|
73
73
|
"README",
|
|
74
74
|
"README.*",
|
|
75
75
|
],
|
|
76
|
-
compiled: null,
|
|
77
76
|
}, { nocase: true }),
|
|
78
77
|
];
|
|
79
78
|
/**
|
|
80
79
|
* @since 0.8.1
|
|
81
80
|
*/
|
|
82
81
|
export const Bun = {
|
|
83
|
-
internalRules: internal,
|
|
84
82
|
extractors,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
let content;
|
|
83
|
+
ignores: ruleTest,
|
|
84
|
+
init({ fs, cwd }, cb) {
|
|
88
85
|
const normalCwd = unixify(cwd);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
set
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
86
|
+
fs.readFile(normalCwd + "/" + "package.json", (err, content) => {
|
|
87
|
+
if (err) {
|
|
88
|
+
cb(new Error("Error while initializing Bun", { cause: err }));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
let dist;
|
|
92
|
+
try {
|
|
93
|
+
dist = npmManifestParse(content.toString());
|
|
94
|
+
// const set = new Set<string>()
|
|
95
|
+
// TODO: NPM should include bundled deps
|
|
96
|
+
// internalInclude.pattern = Array.from(set)
|
|
97
|
+
// ruleCompile(internalInclude, { nocase: true })
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
cb(new Error("Invalid 'package.json'", { cause: error }));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const set = new Set();
|
|
104
|
+
function normal(path) {
|
|
105
|
+
const result = unixify(join(normalCwd, path)).substring(normalCwd.length);
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
// https://github.com/oven-sh/bun/blob/main/src/cli/pack_command.zig#L1440
|
|
109
|
+
if (typeof dist.bin === "string") {
|
|
110
|
+
set.add(normal(dist.bin));
|
|
111
|
+
}
|
|
112
|
+
else if (typeof dist.bin === "object") {
|
|
113
|
+
Object.values(dist.bin).forEach((binPath) => set.add(normal(binPath)));
|
|
114
|
+
}
|
|
115
|
+
// TODO: Bun should include bundled deps
|
|
116
|
+
// nothing else
|
|
117
|
+
// link zig code
|
|
118
|
+
internalInclude.pattern = Array.from(set);
|
|
119
|
+
ruleCompile(internalInclude, { nocase: true });
|
|
120
|
+
cb();
|
|
121
|
+
});
|
|
116
122
|
},
|
|
117
|
-
|
|
123
|
+
internalRules: internal,
|
|
124
|
+
root: ".",
|
|
118
125
|
};
|
package/out/targets/deno.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type } from "arktype";
|
|
2
1
|
import { ruleTest, ruleCompile, extractJsrJson, extractJsrJsonc, extractPackageJson, } from "../patterns/index.js";
|
|
3
2
|
import { unixify } from "../unixify.js";
|
|
4
3
|
import { jsrManifestParse } from "./jsrManifest.js";
|
|
@@ -26,40 +25,43 @@ const extractors = [
|
|
|
26
25
|
];
|
|
27
26
|
const internal = [
|
|
28
27
|
ruleCompile({
|
|
28
|
+
compiled: null,
|
|
29
29
|
excludes: true,
|
|
30
30
|
pattern: [".git", ".DS_Store"],
|
|
31
|
-
compiled: null,
|
|
32
31
|
}),
|
|
33
32
|
];
|
|
34
33
|
/**
|
|
35
34
|
* @since 0.8.1
|
|
36
35
|
*/
|
|
37
36
|
export const Deno = {
|
|
38
|
-
internalRules: internal,
|
|
39
37
|
extractors,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let content;
|
|
38
|
+
ignores: ruleTest,
|
|
39
|
+
init({ fs, cwd }, cb) {
|
|
43
40
|
const normalCwd = unixify(cwd);
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
let i = 0;
|
|
42
|
+
function next() {
|
|
43
|
+
if (i >= extractors.length) {
|
|
44
|
+
cb(new Error("Error while initializing Deno: No valid manifest found"));
|
|
45
|
+
return;
|
|
49
46
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
const extractor = extractors[i++];
|
|
48
|
+
fs.readFile(normalCwd + "/" + extractor.path, (err, data) => {
|
|
49
|
+
if (err) {
|
|
50
|
+
next();
|
|
51
|
+
return;
|
|
55
52
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
try {
|
|
54
|
+
jsrManifestParse(data.toString());
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
cb(new Error("Invalid '" + extractor.path + "'", { cause: error }));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
cb();
|
|
61
|
+
});
|
|
62
62
|
}
|
|
63
|
+
next();
|
|
63
64
|
},
|
|
64
|
-
|
|
65
|
+
internalRules: internal,
|
|
66
|
+
root: ".",
|
|
65
67
|
};
|
package/out/targets/git.js
CHANGED
|
@@ -11,18 +11,18 @@ const extractors = [
|
|
|
11
11
|
];
|
|
12
12
|
const internal = [
|
|
13
13
|
ruleCompile({
|
|
14
|
+
compiled: null,
|
|
14
15
|
excludes: true,
|
|
15
16
|
pattern: [".git", ".DS_Store"],
|
|
16
|
-
compiled: null,
|
|
17
17
|
}),
|
|
18
18
|
];
|
|
19
19
|
/**
|
|
20
20
|
* @since 0.6.0
|
|
21
21
|
*/
|
|
22
22
|
export const Git = {
|
|
23
|
-
internalRules: internal,
|
|
24
23
|
extractors,
|
|
25
|
-
root: "/",
|
|
26
24
|
// TODO: Git should read configs
|
|
27
25
|
ignores: ruleTest,
|
|
26
|
+
internalRules: internal,
|
|
27
|
+
root: "/",
|
|
28
28
|
};
|
package/out/targets/jsr.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type } from "arktype";
|
|
2
1
|
import { ruleTest, ruleCompile, extractJsrJson, extractJsrJsonc, } from "../patterns/index.js";
|
|
3
2
|
import { unixify } from "../unixify.js";
|
|
4
3
|
import { jsrManifestParse } from "./jsrManifest.js";
|
|
@@ -14,40 +13,43 @@ const extractors = [
|
|
|
14
13
|
];
|
|
15
14
|
const internal = [
|
|
16
15
|
ruleCompile({
|
|
16
|
+
compiled: null,
|
|
17
17
|
excludes: true,
|
|
18
18
|
pattern: [".git", ".DS_Store"],
|
|
19
|
-
compiled: null,
|
|
20
19
|
}),
|
|
21
20
|
];
|
|
22
21
|
/**
|
|
23
22
|
* @since 0.6.0
|
|
24
23
|
*/
|
|
25
24
|
export const JSR = {
|
|
26
|
-
internalRules: internal,
|
|
27
25
|
extractors,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let content;
|
|
26
|
+
ignores: ruleTest,
|
|
27
|
+
init({ fs, cwd }, cb) {
|
|
31
28
|
const normalCwd = unixify(cwd);
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
let i = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
if (i >= extractors.length) {
|
|
32
|
+
cb(new Error("Error while initializing JSR: No valid manifest found"));
|
|
33
|
+
return;
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const extractor = extractors[i++];
|
|
36
|
+
fs.readFile(normalCwd + "/" + extractor.path, (err, data) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
next();
|
|
39
|
+
return;
|
|
43
40
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
try {
|
|
42
|
+
jsrManifestParse(data.toString());
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
cb(new Error("Invalid '" + extractor.path + "'", { cause: error }));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
cb();
|
|
49
|
+
});
|
|
50
50
|
}
|
|
51
|
+
next();
|
|
51
52
|
},
|
|
52
|
-
|
|
53
|
+
internalRules: internal,
|
|
54
|
+
root: ".",
|
|
53
55
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface JsrPublishConfig {
|
|
2
|
+
include?: string[];
|
|
3
|
+
exclude?: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface JsrManifest extends JsrPublishConfig {
|
|
2
6
|
name: string;
|
|
3
7
|
version: string;
|
|
4
8
|
exports: string | Record<string, string>;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
version: string;
|
|
9
|
-
exports: string | Record<string, string>;
|
|
10
|
-
}>, {}>;
|
|
9
|
+
publish?: JsrPublishConfig;
|
|
10
|
+
}
|
|
11
|
+
export declare function jsrManifestParse(s: string): JsrManifest;
|