@stigmer/cli 3.15.3-dev.20260916211208 → 3.16.1-dev.20260917224426
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/commands/agent-exec-flags.d.ts +2 -5
- package/commands/agent-exec-flags.d.ts.map +1 -1
- package/commands/agent-exec-flags.js +6 -13
- package/commands/agent-exec-flags.js.map +1 -1
- package/commands/connect.js +1 -1
- package/commands/connect.js.map +1 -1
- package/commands/install.d.ts +3 -0
- package/commands/install.d.ts.map +1 -0
- package/commands/install.js +68 -0
- package/commands/install.js.map +1 -0
- package/commands/marketplace.d.ts +3 -0
- package/commands/marketplace.d.ts.map +1 -0
- package/commands/marketplace.js +94 -0
- package/commands/marketplace.js.map +1 -0
- package/commands/push.js +2 -7
- package/commands/push.js.map +1 -1
- package/commands/run.js +0 -3
- package/commands/run.js.map +1 -1
- package/config/config.d.ts +19 -0
- package/config/config.d.ts.map +1 -1
- package/config/config.js +15 -0
- package/config/config.js.map +1 -1
- package/config/index.d.ts +1 -1
- package/config/index.d.ts.map +1 -1
- package/config/index.js.map +1 -1
- package/local/bootstrap.d.ts +21 -0
- package/local/bootstrap.d.ts.map +1 -0
- package/local/bootstrap.js +88 -0
- package/local/bootstrap.js.map +1 -0
- package/local/daemon/launch.d.ts +2 -2
- package/local/daemon/launch.d.ts.map +1 -1
- package/local/daemon/launch.js +4 -34
- package/local/daemon/launch.js.map +1 -1
- package/local/daemon/process.d.ts +1 -1
- package/local/plugins/defaults.d.ts +35 -0
- package/local/plugins/defaults.d.ts.map +1 -0
- package/local/plugins/defaults.js +83 -0
- package/local/plugins/defaults.js.map +1 -0
- package/local/seedpack/content.d.ts +2 -1
- package/local/seedpack/content.d.ts.map +1 -1
- package/local/seedpack/content.js +5 -34
- package/local/seedpack/content.js.map +1 -1
- package/marketplace/config.d.ts +59 -0
- package/marketplace/config.d.ts.map +1 -0
- package/marketplace/config.js +162 -0
- package/marketplace/config.js.map +1 -0
- package/marketplace/github.d.ts +31 -0
- package/marketplace/github.d.ts.map +1 -0
- package/marketplace/github.js +203 -0
- package/marketplace/github.js.map +1 -0
- package/marketplace/index.d.ts +8 -0
- package/marketplace/index.d.ts.map +1 -0
- package/marketplace/index.js +12 -0
- package/marketplace/index.js.map +1 -0
- package/marketplace/install.d.ts +28 -0
- package/marketplace/install.d.ts.map +1 -0
- package/marketplace/install.js +109 -0
- package/marketplace/install.js.map +1 -0
- package/marketplace/materialize.d.ts +19 -0
- package/marketplace/materialize.d.ts.map +1 -0
- package/marketplace/materialize.js +53 -0
- package/marketplace/materialize.js.map +1 -0
- package/marketplace/official.d.ts +28 -0
- package/marketplace/official.d.ts.map +1 -0
- package/marketplace/official.js +86 -0
- package/marketplace/official.js.map +1 -0
- package/marketplace/read.d.ts +17 -0
- package/marketplace/read.d.ts.map +1 -0
- package/marketplace/read.js +44 -0
- package/marketplace/read.js.map +1 -0
- package/marketplace/ref.d.ts +13 -0
- package/marketplace/ref.d.ts.map +1 -0
- package/marketplace/ref.js +54 -0
- package/marketplace/ref.js.map +1 -0
- package/marketplace/render.d.ts +22 -0
- package/marketplace/render.d.ts.map +1 -0
- package/marketplace/render.js +118 -0
- package/marketplace/render.js.map +1 -0
- package/output/ndjson.js +1 -1
- package/output/ndjson.js.map +1 -1
- package/package.json +7 -6
- package/program.d.ts.map +1 -1
- package/program.js +4 -2
- package/program.js.map +1 -1
- package/resources/ignore/index.d.ts +2 -4
- package/resources/ignore/index.d.ts.map +1 -1
- package/resources/ignore/index.js +5 -5
- package/resources/ignore/index.js.map +1 -1
- package/resources/ignore/matcher.d.ts +2 -35
- package/resources/ignore/matcher.d.ts.map +1 -1
- package/resources/ignore/matcher.js +25 -109
- package/resources/ignore/matcher.js.map +1 -1
- package/resources/plugin.d.ts +50 -18
- package/resources/plugin.d.ts.map +1 -1
- package/resources/plugin.js +73 -74
- package/resources/plugin.js.map +1 -1
- package/resources/run/agent-exec.js +1 -1
- package/resources/run/agent-exec.js.map +1 -1
- package/resources/run/prepare.d.ts +8 -19
- package/resources/run/prepare.d.ts.map +1 -1
- package/resources/run/prepare.js +4 -4
- package/resources/run/prepare.js.map +1 -1
- package/resources/skill.d.ts +2 -2
- package/resources/skill.d.ts.map +1 -1
- package/resources/skill.js +6 -10
- package/resources/skill.js.map +1 -1
- package/src/commands/agent-exec-flags.ts +6 -12
- package/src/commands/connect.ts +1 -1
- package/src/commands/install.test.ts +289 -0
- package/src/commands/install.ts +108 -0
- package/src/commands/marketplace.test.ts +200 -0
- package/src/commands/marketplace.ts +131 -0
- package/src/commands/push.ts +5 -10
- package/src/commands/run.ts +0 -3
- package/src/config/config.ts +37 -0
- package/src/config/index.ts +1 -0
- package/src/local/bootstrap.test.ts +71 -0
- package/src/local/bootstrap.ts +133 -0
- package/src/local/daemon/launch.ts +5 -40
- package/src/local/daemon/process.ts +1 -1
- package/src/local/plugins/defaults.test.ts +238 -0
- package/src/local/plugins/defaults.ts +135 -0
- package/src/local/seedpack/content.ts +11 -42
- package/src/marketplace/__fixtures__/cursor-marketplace.ts +62 -0
- package/src/marketplace/config.test.ts +245 -0
- package/src/marketplace/config.ts +236 -0
- package/src/marketplace/github.test.ts +318 -0
- package/src/marketplace/github.ts +296 -0
- package/src/marketplace/index.ts +54 -0
- package/src/marketplace/install.test.ts +194 -0
- package/src/marketplace/install.ts +159 -0
- package/src/marketplace/materialize.ts +80 -0
- package/src/marketplace/official.test.ts +107 -0
- package/src/marketplace/official.ts +125 -0
- package/src/marketplace/read.test.ts +94 -0
- package/src/marketplace/read.ts +76 -0
- package/src/marketplace/ref.test.ts +179 -0
- package/src/marketplace/ref.ts +74 -0
- package/src/marketplace/render.ts +154 -0
- package/src/output/ndjson.ts +1 -1
- package/src/program.test.ts +4 -13
- package/src/program.ts +4 -2
- package/src/resources/ignore/ignore.test.ts +23 -100
- package/src/resources/ignore/index.ts +11 -8
- package/src/resources/ignore/matcher.ts +33 -136
- package/src/resources/plugin.test.ts +35 -6
- package/src/resources/plugin.ts +132 -85
- package/src/resources/run/agent-exec.ts +1 -1
- package/src/resources/run/prepare.test.ts +4 -18
- package/src/resources/run/prepare.ts +12 -24
- package/src/resources/skill.ts +6 -10
- package/commands/draft.d.ts +0 -3
- package/commands/draft.d.ts.map +0 -1
- package/commands/draft.js +0 -115
- package/commands/draft.js.map +0 -1
- package/resources/ignore/defaults.d.ts +0 -2
- package/resources/ignore/defaults.d.ts.map +0 -1
- package/resources/ignore/defaults.js +0 -140
- package/resources/ignore/defaults.js.map +0 -1
- package/resources/ignore/match.d.ts +0 -3
- package/resources/ignore/match.d.ts.map +0 -1
- package/resources/ignore/match.js +0 -166
- package/resources/ignore/match.js.map +0 -1
- package/resources/ignore/pattern.d.ts +0 -13
- package/resources/ignore/pattern.d.ts.map +0 -1
- package/resources/ignore/pattern.js +0 -118
- package/resources/ignore/pattern.js.map +0 -1
- package/src/commands/draft.ts +0 -189
- package/src/resources/ignore/defaults.ts +0 -155
- package/src/resources/ignore/match.ts +0 -158
- package/src/resources/ignore/pattern.ts +0 -131
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
// Built-in security-first ignore patterns, applied (lowest priority) unless
|
|
2
|
-
// disabled. A verbatim port of the Go CLI's DefaultPatterns so `push` excludes
|
|
3
|
-
// the same secrets, VCS metadata, and build artifacts on both CLIs.
|
|
4
|
-
|
|
5
|
-
export const DEFAULT_PATTERNS: readonly string[] = [
|
|
6
|
-
// Version control
|
|
7
|
-
".git/",
|
|
8
|
-
".svn/",
|
|
9
|
-
".hg/",
|
|
10
|
-
".bzr/",
|
|
11
|
-
|
|
12
|
-
// Environment files (often contain secrets)
|
|
13
|
-
".env",
|
|
14
|
-
".env.*",
|
|
15
|
-
"!.env.example",
|
|
16
|
-
"!.env.template",
|
|
17
|
-
"!.env.sample",
|
|
18
|
-
|
|
19
|
-
// Private keys and certificates
|
|
20
|
-
"*.pem",
|
|
21
|
-
"*.key",
|
|
22
|
-
"*.p12",
|
|
23
|
-
"*.pfx",
|
|
24
|
-
"*.keystore",
|
|
25
|
-
"*.jks",
|
|
26
|
-
"id_rsa",
|
|
27
|
-
"id_rsa.*",
|
|
28
|
-
"id_ed25519",
|
|
29
|
-
"id_ed25519.*",
|
|
30
|
-
"id_dsa",
|
|
31
|
-
"id_dsa.*",
|
|
32
|
-
|
|
33
|
-
// Cloud credentials
|
|
34
|
-
"credentials.json",
|
|
35
|
-
"service-account*.json",
|
|
36
|
-
"gcp-credentials*.json",
|
|
37
|
-
"aws-credentials",
|
|
38
|
-
".aws/credentials",
|
|
39
|
-
".aws/config",
|
|
40
|
-
|
|
41
|
-
// Generic secrets
|
|
42
|
-
".secrets",
|
|
43
|
-
".secrets/",
|
|
44
|
-
"*.secret",
|
|
45
|
-
".credentials/",
|
|
46
|
-
"secrets.yaml",
|
|
47
|
-
"secrets.yml",
|
|
48
|
-
"secrets.json",
|
|
49
|
-
|
|
50
|
-
// Package manager auth
|
|
51
|
-
".npmrc",
|
|
52
|
-
".pypirc",
|
|
53
|
-
".gem/credentials",
|
|
54
|
-
".docker/config.json",
|
|
55
|
-
|
|
56
|
-
// IDE and editor
|
|
57
|
-
".idea/",
|
|
58
|
-
".vscode/",
|
|
59
|
-
"*.swp",
|
|
60
|
-
"*.swo",
|
|
61
|
-
"*.swn",
|
|
62
|
-
"*~",
|
|
63
|
-
".project",
|
|
64
|
-
".classpath",
|
|
65
|
-
".settings/",
|
|
66
|
-
"*.sublime-workspace",
|
|
67
|
-
"*.sublime-project",
|
|
68
|
-
".vs/",
|
|
69
|
-
|
|
70
|
-
// Operating system
|
|
71
|
-
".DS_Store",
|
|
72
|
-
".DS_Store?",
|
|
73
|
-
"._*",
|
|
74
|
-
".Spotlight-V100",
|
|
75
|
-
".Trashes",
|
|
76
|
-
"Thumbs.db",
|
|
77
|
-
"Thumbs.db:encryptable",
|
|
78
|
-
"desktop.ini",
|
|
79
|
-
"ehthumbs.db",
|
|
80
|
-
"ehthumbs_vista.db",
|
|
81
|
-
|
|
82
|
-
// Node.js
|
|
83
|
-
"node_modules/",
|
|
84
|
-
"npm-debug.log*",
|
|
85
|
-
"yarn-debug.log*",
|
|
86
|
-
"yarn-error.log*",
|
|
87
|
-
".npm/",
|
|
88
|
-
".yarn/cache/",
|
|
89
|
-
".yarn/unplugged/",
|
|
90
|
-
".pnp.*",
|
|
91
|
-
|
|
92
|
-
// Python
|
|
93
|
-
"__pycache__/",
|
|
94
|
-
"*.py[cod]",
|
|
95
|
-
"*$py.class",
|
|
96
|
-
".Python",
|
|
97
|
-
"*.so",
|
|
98
|
-
".venv/",
|
|
99
|
-
"venv/",
|
|
100
|
-
"env/",
|
|
101
|
-
"ENV/",
|
|
102
|
-
".pytest_cache/",
|
|
103
|
-
".mypy_cache/",
|
|
104
|
-
".ruff_cache/",
|
|
105
|
-
".tox/",
|
|
106
|
-
".nox/",
|
|
107
|
-
"*.egg-info/",
|
|
108
|
-
".eggs/",
|
|
109
|
-
"dist/",
|
|
110
|
-
"build/",
|
|
111
|
-
"develop-eggs/",
|
|
112
|
-
".installed.cfg",
|
|
113
|
-
"*.manifest",
|
|
114
|
-
"*.spec",
|
|
115
|
-
"pip-log.txt",
|
|
116
|
-
"pip-delete-this-directory.txt",
|
|
117
|
-
|
|
118
|
-
// Java/JVM
|
|
119
|
-
"target/",
|
|
120
|
-
"*.class",
|
|
121
|
-
"*.jar",
|
|
122
|
-
"*.war",
|
|
123
|
-
"*.ear",
|
|
124
|
-
".gradle/",
|
|
125
|
-
"gradle-app.setting",
|
|
126
|
-
".gradletasknamecache",
|
|
127
|
-
|
|
128
|
-
// Go
|
|
129
|
-
"vendor/",
|
|
130
|
-
|
|
131
|
-
// Rust
|
|
132
|
-
"target/",
|
|
133
|
-
"Cargo.lock",
|
|
134
|
-
|
|
135
|
-
// Coverage and test reports
|
|
136
|
-
"coverage/",
|
|
137
|
-
".coverage",
|
|
138
|
-
"htmlcov/",
|
|
139
|
-
".nyc_output/",
|
|
140
|
-
"coverage.xml",
|
|
141
|
-
"*.cover",
|
|
142
|
-
".hypothesis/",
|
|
143
|
-
|
|
144
|
-
// Logs
|
|
145
|
-
"*.log",
|
|
146
|
-
"logs/",
|
|
147
|
-
|
|
148
|
-
// Temporary files
|
|
149
|
-
"tmp/",
|
|
150
|
-
"temp/",
|
|
151
|
-
"*.tmp",
|
|
152
|
-
"*.temp",
|
|
153
|
-
"*.bak",
|
|
154
|
-
"*.backup",
|
|
155
|
-
];
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
// Faithful port of Go's path/filepath Match, used by the gitignore pattern
|
|
2
|
-
// engine to match a single glob against a single path component.
|
|
3
|
-
//
|
|
4
|
-
// The separator is fixed to "/" (paths are normalized to forward slashes and
|
|
5
|
-
// individual components never contain a separator). Matching operates on UTF-16
|
|
6
|
-
// code units rather than runes — correct for the ASCII glob syntax gitignore
|
|
7
|
-
// patterns use; exotic multi-byte classes are out of scope.
|
|
8
|
-
//
|
|
9
|
-
// Go returns ErrBadPattern for malformed patterns; every go-git caller treats
|
|
10
|
-
// that as "no match", so `matchName` swallows the error and returns false.
|
|
11
|
-
|
|
12
|
-
const SEPARATOR = "/";
|
|
13
|
-
|
|
14
|
-
class BadPatternError extends Error {}
|
|
15
|
-
|
|
16
|
-
/** Match `name` against the glob `pattern` (Go filepath.Match semantics). */
|
|
17
|
-
export function matchName(pattern: string, name: string): boolean {
|
|
18
|
-
try {
|
|
19
|
-
return matchImpl(pattern, name);
|
|
20
|
-
} catch (err) {
|
|
21
|
-
if (err instanceof BadPatternError) return false;
|
|
22
|
-
throw err;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function matchImpl(pattern: string, name: string): boolean {
|
|
27
|
-
outer: while (pattern.length > 0) {
|
|
28
|
-
const [star, chunk, rest] = scanChunk(pattern);
|
|
29
|
-
pattern = rest;
|
|
30
|
-
|
|
31
|
-
if (star && chunk === "") {
|
|
32
|
-
// Trailing `*` matches the rest of the component (which has no separator).
|
|
33
|
-
return !name.includes(SEPARATOR);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const [t, ok] = matchChunk(chunk, name);
|
|
37
|
-
if (ok && (t.length === 0 || pattern.length > 0)) {
|
|
38
|
-
name = t;
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (star) {
|
|
43
|
-
for (let i = 0; i < name.length && name[i] !== SEPARATOR; i++) {
|
|
44
|
-
const [t2, ok2] = matchChunk(chunk, name.slice(i + 1));
|
|
45
|
-
if (ok2) {
|
|
46
|
-
if (pattern.length === 0 && t2.length > 0) continue;
|
|
47
|
-
name = t2;
|
|
48
|
-
continue outer;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return name.length === 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function scanChunk(pattern: string): [boolean, string, string] {
|
|
58
|
-
let star = false;
|
|
59
|
-
while (pattern.length > 0 && pattern[0] === "*") {
|
|
60
|
-
pattern = pattern.slice(1);
|
|
61
|
-
star = true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let inrange = false;
|
|
65
|
-
let i = 0;
|
|
66
|
-
scan: for (i = 0; i < pattern.length; i++) {
|
|
67
|
-
switch (pattern[i]) {
|
|
68
|
-
case "\\":
|
|
69
|
-
if (i + 1 < pattern.length) i++;
|
|
70
|
-
break;
|
|
71
|
-
case "[":
|
|
72
|
-
inrange = true;
|
|
73
|
-
break;
|
|
74
|
-
case "]":
|
|
75
|
-
inrange = false;
|
|
76
|
-
break;
|
|
77
|
-
case "*":
|
|
78
|
-
if (!inrange) break scan;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return [star, pattern.slice(0, i), pattern.slice(i)];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function matchChunk(chunk: string, s: string): [string, boolean] {
|
|
86
|
-
let failed = false;
|
|
87
|
-
while (chunk.length > 0) {
|
|
88
|
-
if (!failed && s.length === 0) failed = true;
|
|
89
|
-
|
|
90
|
-
const c = chunk[0];
|
|
91
|
-
if (c === "[") {
|
|
92
|
-
let r = "";
|
|
93
|
-
if (!failed) {
|
|
94
|
-
r = s[0];
|
|
95
|
-
s = s.slice(1);
|
|
96
|
-
}
|
|
97
|
-
chunk = chunk.slice(1);
|
|
98
|
-
let negated = false;
|
|
99
|
-
if (chunk.length > 0 && chunk[0] === "^") {
|
|
100
|
-
negated = true;
|
|
101
|
-
chunk = chunk.slice(1);
|
|
102
|
-
}
|
|
103
|
-
let match = false;
|
|
104
|
-
let nrange = 0;
|
|
105
|
-
for (;;) {
|
|
106
|
-
if (chunk.length > 0 && chunk[0] === "]" && nrange > 0) {
|
|
107
|
-
chunk = chunk.slice(1);
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
let lo: string;
|
|
111
|
-
[lo, chunk] = getEsc(chunk);
|
|
112
|
-
let hi = lo;
|
|
113
|
-
if (chunk[0] === "-") {
|
|
114
|
-
[hi, chunk] = getEsc(chunk.slice(1));
|
|
115
|
-
}
|
|
116
|
-
if (lo <= r && r <= hi) match = true;
|
|
117
|
-
nrange++;
|
|
118
|
-
}
|
|
119
|
-
if (match === negated) failed = true;
|
|
120
|
-
} else if (c === "?") {
|
|
121
|
-
if (!failed) {
|
|
122
|
-
if (s[0] === SEPARATOR) failed = true;
|
|
123
|
-
s = s.slice(1);
|
|
124
|
-
}
|
|
125
|
-
chunk = chunk.slice(1);
|
|
126
|
-
} else if (c === "\\") {
|
|
127
|
-
chunk = chunk.slice(1);
|
|
128
|
-
if (chunk.length === 0) throw new BadPatternError("bad pattern");
|
|
129
|
-
if (!failed) {
|
|
130
|
-
if (chunk[0] !== s[0]) failed = true;
|
|
131
|
-
s = s.slice(1);
|
|
132
|
-
}
|
|
133
|
-
chunk = chunk.slice(1);
|
|
134
|
-
} else {
|
|
135
|
-
if (!failed) {
|
|
136
|
-
if (chunk[0] !== s[0]) failed = true;
|
|
137
|
-
s = s.slice(1);
|
|
138
|
-
}
|
|
139
|
-
chunk = chunk.slice(1);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (failed) return ["", false];
|
|
143
|
-
return [s, true];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function getEsc(chunk: string): [string, string] {
|
|
147
|
-
if (chunk.length === 0 || chunk[0] === "-" || chunk[0] === "]") {
|
|
148
|
-
throw new BadPatternError("bad pattern");
|
|
149
|
-
}
|
|
150
|
-
if (chunk[0] === "\\") {
|
|
151
|
-
chunk = chunk.slice(1);
|
|
152
|
-
if (chunk.length === 0) throw new BadPatternError("bad pattern");
|
|
153
|
-
}
|
|
154
|
-
const r = chunk[0];
|
|
155
|
-
const nchunk = chunk.slice(1);
|
|
156
|
-
if (nchunk.length === 0) throw new BadPatternError("bad pattern");
|
|
157
|
-
return [r, nchunk];
|
|
158
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
// Faithful port of go-git's plumbing/format/gitignore Pattern (ParsePattern +
|
|
2
|
-
// Match). This is what gives `push` its exact gitignore semantics: domain
|
|
3
|
-
// scoping, directory-only patterns, single-name vs glob matching, and the
|
|
4
|
-
// `**` zero-to-many-directories wildcard.
|
|
5
|
-
|
|
6
|
-
import { matchName } from "./match.js";
|
|
7
|
-
|
|
8
|
-
export enum MatchResult {
|
|
9
|
-
NoMatch = 0,
|
|
10
|
-
Exclude = 1,
|
|
11
|
-
Include = 2,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const INCLUSION_PREFIX = "!";
|
|
15
|
-
const ZERO_TO_MANY = "**";
|
|
16
|
-
const DIR_SEP = "/";
|
|
17
|
-
|
|
18
|
-
export interface Pattern {
|
|
19
|
-
/** Whether this is a negation (`!`) pattern — needed for source ordering. */
|
|
20
|
-
readonly inclusion: boolean;
|
|
21
|
-
match(path: readonly string[], isDir: boolean): MatchResult;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
class GitignorePattern implements Pattern {
|
|
25
|
-
readonly inclusion: boolean;
|
|
26
|
-
private readonly domain: readonly string[];
|
|
27
|
-
private readonly parts: readonly string[];
|
|
28
|
-
private readonly dirOnly: boolean;
|
|
29
|
-
private readonly isGlob: boolean;
|
|
30
|
-
|
|
31
|
-
constructor(domain: readonly string[], parts: readonly string[], inclusion: boolean, dirOnly: boolean, isGlob: boolean) {
|
|
32
|
-
this.domain = domain;
|
|
33
|
-
this.parts = parts;
|
|
34
|
-
this.inclusion = inclusion;
|
|
35
|
-
this.dirOnly = dirOnly;
|
|
36
|
-
this.isGlob = isGlob;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
match(path: readonly string[], isDir: boolean): MatchResult {
|
|
40
|
-
const matchResult = this.inclusion ? MatchResult.Include : MatchResult.Exclude;
|
|
41
|
-
|
|
42
|
-
if (path.length <= this.domain.length) return MatchResult.NoMatch;
|
|
43
|
-
for (let i = 0; i < this.domain.length; i++) {
|
|
44
|
-
if (path[i] !== this.domain[i]) return MatchResult.NoMatch;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const scoped = path.slice(this.domain.length);
|
|
48
|
-
const matched = this.isGlob ? this.globMatch(scoped, isDir) : this.simpleNameMatch(scoped, isDir);
|
|
49
|
-
return matched ? matchResult : MatchResult.NoMatch;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private simpleNameMatch(path: readonly string[], isDir: boolean): boolean {
|
|
53
|
-
for (let i = 0; i < path.length; i++) {
|
|
54
|
-
if (!matchName(this.parts[0], path[i])) continue;
|
|
55
|
-
if (this.dirOnly && !isDir && i === path.length - 1) return false;
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private globMatch(path: readonly string[], isDir: boolean): boolean {
|
|
62
|
-
let matched = false;
|
|
63
|
-
let canTraverse = false;
|
|
64
|
-
let remaining = path;
|
|
65
|
-
|
|
66
|
-
for (let i = 0; i < this.parts.length; i++) {
|
|
67
|
-
const part = this.parts[i];
|
|
68
|
-
if (part === "") {
|
|
69
|
-
canTraverse = false;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (part === ZERO_TO_MANY) {
|
|
73
|
-
if (i === this.parts.length - 1) break;
|
|
74
|
-
canTraverse = true;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (part.includes(ZERO_TO_MANY)) return false;
|
|
78
|
-
if (remaining.length === 0) return false;
|
|
79
|
-
|
|
80
|
-
if (canTraverse) {
|
|
81
|
-
canTraverse = false;
|
|
82
|
-
for (;;) {
|
|
83
|
-
if (remaining.length === 0) {
|
|
84
|
-
matched = false;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
const e = remaining[0];
|
|
88
|
-
remaining = remaining.slice(1);
|
|
89
|
-
if (matchName(part, e)) {
|
|
90
|
-
matched = true;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
if (!matchName(part, remaining[0])) return false;
|
|
96
|
-
matched = true;
|
|
97
|
-
remaining = remaining.slice(1);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (matched && this.dirOnly && !isDir && remaining.length === 0) {
|
|
102
|
-
matched = false;
|
|
103
|
-
}
|
|
104
|
-
return matched;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** Parse a gitignore pattern string into a matchable Pattern (go-git parity). */
|
|
109
|
-
export function parsePattern(raw: string, domain: readonly string[]): Pattern {
|
|
110
|
-
let p = raw;
|
|
111
|
-
let inclusion = false;
|
|
112
|
-
|
|
113
|
-
if (p.startsWith(INCLUSION_PREFIX)) {
|
|
114
|
-
inclusion = true;
|
|
115
|
-
p = p.slice(1);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (!p.endsWith("\\ ")) {
|
|
119
|
-
p = p.replace(/ +$/, "");
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
let dirOnly = false;
|
|
123
|
-
if (p.endsWith(DIR_SEP)) {
|
|
124
|
-
dirOnly = true;
|
|
125
|
-
p = p.slice(0, -1);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const isGlob = p.includes(DIR_SEP);
|
|
129
|
-
const parts = p.split(DIR_SEP);
|
|
130
|
-
return new GitignorePattern(domain, parts, inclusion, dirOnly, isGlob);
|
|
131
|
-
}
|