vibedgames 0.6.2 → 0.7.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 +14 -9
- package/dist/THIRD_PARTY_NOTICES.txt +383 -0
- package/dist/chunk-2GL2WJZX.js +172 -0
- package/dist/chunk-2QBYTIMH.js +511 -0
- package/dist/chunk-34AHIMX7.js +466 -0
- package/dist/chunk-6FZPPUQH.js +107 -0
- package/dist/chunk-BVVYDSFJ.js +99 -0
- package/dist/chunk-CAKBGDCY.js +47 -0
- package/dist/chunk-CBKOPVU6.js +1780 -0
- package/dist/chunk-CU7UY5YJ.js +1108 -0
- package/dist/chunk-CZPKN32Z.js +257 -0
- package/dist/chunk-DHEXGWJY.js +111 -0
- package/dist/chunk-FL6IFBUF.js +22 -0
- package/dist/chunk-FLUXEHMU.js +1360 -0
- package/dist/chunk-FNYBZNW2.js +165 -0
- package/dist/chunk-G5FRIFA3.js +22 -0
- package/dist/chunk-HCMTSR7E.js +69 -0
- package/dist/chunk-HKA5LBYW.js +159 -0
- package/dist/chunk-I6O4HIDY.js +1063 -0
- package/dist/chunk-J6PKNPI2.js +26 -0
- package/dist/chunk-JT2AU24K.js +759 -0
- package/dist/chunk-MBXCVCC4.js +478 -0
- package/dist/chunk-MJQSHP3Y.js +415 -0
- package/dist/chunk-MYFLYNPO.js +68 -0
- package/dist/chunk-PEUP4MZR.js +59 -0
- package/dist/chunk-PHEDW6C7.js +32 -0
- package/dist/chunk-PQDBCZRT.js +2017 -0
- package/dist/chunk-QGEITHUP.js +395 -0
- package/dist/chunk-QIVCBUYD.js +273 -0
- package/dist/chunk-RYFO3ZPO.js +71 -0
- package/dist/chunk-RZ4DIJQW.js +68 -0
- package/dist/chunk-SAANBZ25.js +118 -0
- package/dist/chunk-VFFOT7KD.js +2980 -0
- package/dist/chunk-Y552BNFZ.js +41 -0
- package/dist/chunk-Z4Z24FWO.js +39 -0
- package/dist/chunk-ZI6PKVXG.js +64 -0
- package/dist/chunk-ZYCSYJWX.js +87 -0
- package/dist/index.js +67 -60
- package/package.json +13 -16
- package/templates/none/_gitignore +3 -0
- package/templates/none/index.html +29 -0
- package/templates/none/package.json +16 -0
- package/templates/none/src/main.ts +16 -0
- package/templates/none/tsconfig.json +18 -0
- package/templates/none/vite.config.ts +8 -0
- package/templates/phaser/_gitignore +3 -0
- package/templates/phaser/index.html +24 -0
- package/templates/phaser/package.json +19 -0
- package/templates/phaser/src/main.ts +16 -0
- package/templates/phaser/src/scenes/game-scene.ts +65 -0
- package/templates/phaser/tsconfig.json +18 -0
- package/templates/phaser/vite.config.ts +8 -0
- package/templates/react-r3f/_gitignore +3 -0
- package/templates/react-r3f/index.html +24 -0
- package/templates/react-r3f/package.json +27 -0
- package/templates/react-r3f/src/app.tsx +33 -0
- package/templates/react-r3f/src/main.tsx +15 -0
- package/templates/react-r3f/tsconfig.json +19 -0
- package/templates/react-r3f/vite.config.ts +10 -0
- package/templates/threejs/_gitignore +3 -0
- package/templates/threejs/index.html +36 -0
- package/templates/threejs/package.json +20 -0
- package/templates/threejs/src/main.ts +44 -0
- package/templates/threejs/tsconfig.json +18 -0
- package/templates/threejs/vite.config.ts +8 -0
- package/dist/commands/completions.d.ts +0 -7
- package/dist/commands/completions.js +0 -145
- package/dist/commands/credits.d.ts +0 -10
- package/dist/commands/credits.js +0 -136
- package/dist/commands/deploy.d.ts +0 -26
- package/dist/commands/deploy.js +0 -257
- package/dist/commands/factory.d.ts +0 -3
- package/dist/commands/factory.js +0 -73
- package/dist/commands/fork.d.ts +0 -29
- package/dist/commands/fork.js +0 -124
- package/dist/commands/generate.d.ts +0 -1
- package/dist/commands/generate.js +0 -565
- package/dist/commands/init.d.ts +0 -20
- package/dist/commands/init.js +0 -105
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +0 -45
- package/dist/commands/logout.d.ts +0 -1
- package/dist/commands/logout.js +0 -13
- package/dist/commands/new.d.ts +0 -26
- package/dist/commands/new.js +0 -318
- package/dist/commands/playtest-run.d.ts +0 -66
- package/dist/commands/playtest-run.js +0 -268
- package/dist/commands/playtest.d.ts +0 -76
- package/dist/commands/playtest.js +0 -372
- package/dist/commands/update.d.ts +0 -13
- package/dist/commands/update.js +0 -82
- package/dist/commands/whoami.d.ts +0 -10
- package/dist/commands/whoami.js +0 -44
- package/dist/index.d.ts +0 -2
- package/dist/lib/api.d.ts +0 -18
- package/dist/lib/api.js +0 -27
- package/dist/lib/archive.d.ts +0 -17
- package/dist/lib/archive.js +0 -228
- package/dist/lib/codex.d.ts +0 -117
- package/dist/lib/codex.js +0 -426
- package/dist/lib/config-file.d.ts +0 -16
- package/dist/lib/config-file.js +0 -54
- package/dist/lib/config.d.ts +0 -11
- package/dist/lib/config.js +0 -54
- package/dist/lib/manifest.d.ts +0 -10
- package/dist/lib/manifest.js +0 -91
- package/dist/lib/media-args.d.ts +0 -30
- package/dist/lib/media-args.js +0 -219
- package/dist/lib/media-download.d.ts +0 -37
- package/dist/lib/media-download.js +0 -268
- package/dist/lib/media-poll.d.ts +0 -18
- package/dist/lib/media-poll.js +0 -86
- package/dist/lib/media-upload.d.ts +0 -12
- package/dist/lib/media-upload.js +0 -52
- package/dist/lib/output.d.ts +0 -68
- package/dist/lib/output.js +0 -102
- package/dist/lib/package-manager.d.ts +0 -25
- package/dist/lib/package-manager.js +0 -77
- package/dist/lib/playtest/agent.d.ts +0 -192
- package/dist/lib/playtest/agent.js +0 -652
- package/dist/lib/playtest/browser.d.ts +0 -109
- package/dist/lib/playtest/browser.js +0 -219
- package/dist/lib/playtest/controls.d.ts +0 -47
- package/dist/lib/playtest/controls.js +0 -218
- package/dist/lib/playtest/errors.d.ts +0 -9
- package/dist/lib/playtest/errors.js +0 -12
- package/dist/lib/playtest/keys.d.ts +0 -41
- package/dist/lib/playtest/keys.js +0 -157
- package/dist/lib/playtest/run.d.ts +0 -195
- package/dist/lib/playtest/run.js +0 -409
- package/dist/lib/run.d.ts +0 -19
- package/dist/lib/run.js +0 -23
- package/dist/lib/strict-args.d.ts +0 -27
- package/dist/lib/strict-args.js +0 -78
- package/dist/lib/types.d.ts +0 -16
- package/dist/lib/types.js +0 -10
- package/dist/lib/update.d.ts +0 -10
- package/dist/lib/update.js +0 -110
- package/dist/lib/upload.d.ts +0 -16
- package/dist/lib/upload.js +0 -41
|
@@ -0,0 +1,1063 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
Qn,
|
|
9
|
+
So
|
|
10
|
+
} from "./chunk-VFFOT7KD.js";
|
|
11
|
+
import {
|
|
12
|
+
isJsonObject,
|
|
13
|
+
isJsonString
|
|
14
|
+
} from "./chunk-J6PKNPI2.js";
|
|
15
|
+
import {
|
|
16
|
+
__commonJS,
|
|
17
|
+
__toESM
|
|
18
|
+
} from "./chunk-CAKBGDCY.js";
|
|
19
|
+
|
|
20
|
+
// ../../node_modules/.pnpm/ignore@7.0.12/node_modules/ignore/index.js
|
|
21
|
+
var require_ignore = __commonJS({
|
|
22
|
+
"../../node_modules/.pnpm/ignore@7.0.12/node_modules/ignore/index.js"(exports, module) {
|
|
23
|
+
function makeArray(subject) {
|
|
24
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
25
|
+
}
|
|
26
|
+
var UNDEFINED = void 0;
|
|
27
|
+
var EMPTY = "";
|
|
28
|
+
var SPACE = " ";
|
|
29
|
+
var ESCAPE = "\\";
|
|
30
|
+
var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
|
|
31
|
+
var BOM = "\uFEFF";
|
|
32
|
+
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
33
|
+
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
34
|
+
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
35
|
+
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
36
|
+
var DOUBLE_SLASH = "//";
|
|
37
|
+
var SLASH_CODE = 47;
|
|
38
|
+
var DOT_CODE = 46;
|
|
39
|
+
var SLASH = "/";
|
|
40
|
+
var TMP_KEY_IGNORE = "node-ignore";
|
|
41
|
+
if (typeof Symbol !== "undefined") {
|
|
42
|
+
TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
|
|
43
|
+
}
|
|
44
|
+
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
45
|
+
var define = (object, key, value) => {
|
|
46
|
+
Object.defineProperty(object, key, { value });
|
|
47
|
+
return value;
|
|
48
|
+
};
|
|
49
|
+
var RETURN_FALSE = () => false;
|
|
50
|
+
var cleanRangeBackSlash = (slashes) => {
|
|
51
|
+
const { length } = slashes;
|
|
52
|
+
return slashes.slice(0, length - length % 2);
|
|
53
|
+
};
|
|
54
|
+
var POSIX_CLASSES = {
|
|
55
|
+
alnum: "0-9A-Za-z",
|
|
56
|
+
alpha: "A-Za-z",
|
|
57
|
+
blank: " \\t",
|
|
58
|
+
cntrl: "\\x00-\\x1f\\x7f",
|
|
59
|
+
digit: "0-9",
|
|
60
|
+
graph: "!-.0-~",
|
|
61
|
+
lower: "a-z",
|
|
62
|
+
print: " -.0-~",
|
|
63
|
+
punct: "!-.:-@\\[-`{-~",
|
|
64
|
+
// git's `sane-ctype.h` classifies \v and \f as control, not space,
|
|
65
|
+
// unlike C's `isspace`
|
|
66
|
+
space: " \\t\\n\\r",
|
|
67
|
+
upper: "A-Z",
|
|
68
|
+
xdigit: "0-9A-Fa-f"
|
|
69
|
+
};
|
|
70
|
+
var CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
|
|
71
|
+
var escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
|
|
72
|
+
var NON_SLASH = "(?!\\/)";
|
|
73
|
+
var classSource = (negated, body) => {
|
|
74
|
+
if (negated) {
|
|
75
|
+
return `[^\\/${body}]`;
|
|
76
|
+
}
|
|
77
|
+
const source = `[${body}]`;
|
|
78
|
+
return new RegExp(source).test("/") ? NON_SLASH + source : source;
|
|
79
|
+
};
|
|
80
|
+
var scanBracket = (pattern, start) => {
|
|
81
|
+
const { length } = pattern;
|
|
82
|
+
let index = start + 1;
|
|
83
|
+
let negated = EMPTY;
|
|
84
|
+
const lead = pattern[index];
|
|
85
|
+
if (lead === "!" || lead === "^") {
|
|
86
|
+
negated = "^";
|
|
87
|
+
index++;
|
|
88
|
+
}
|
|
89
|
+
let body = EMPTY;
|
|
90
|
+
let prev = EMPTY;
|
|
91
|
+
for (; ; ) {
|
|
92
|
+
const char = pattern[index];
|
|
93
|
+
if (char === UNDEFINED) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
if (char === ESCAPE) {
|
|
97
|
+
const escaped = pattern[index + 1];
|
|
98
|
+
if (escaped === UNDEFINED) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
body += escapeMember(escaped);
|
|
102
|
+
prev = escaped;
|
|
103
|
+
index++;
|
|
104
|
+
} else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
|
|
105
|
+
index++;
|
|
106
|
+
let to = pattern[index];
|
|
107
|
+
if (to === ESCAPE) {
|
|
108
|
+
to = pattern[index += 1];
|
|
109
|
+
}
|
|
110
|
+
if (prev <= to) {
|
|
111
|
+
body += `-${escapeMember(to)}`;
|
|
112
|
+
}
|
|
113
|
+
prev = EMPTY;
|
|
114
|
+
} else if (char === "[" && pattern[index + 1] === ":") {
|
|
115
|
+
const nameStart = index + 2;
|
|
116
|
+
let end = nameStart;
|
|
117
|
+
while (end < length && pattern[end] !== "]") {
|
|
118
|
+
end++;
|
|
119
|
+
}
|
|
120
|
+
if (end === length) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
if (end > nameStart && pattern[end - 1] === ":") {
|
|
124
|
+
const expanded = POSIX_CLASSES[pattern.slice(nameStart, end - 1)];
|
|
125
|
+
if (expanded === UNDEFINED) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
body += expanded;
|
|
129
|
+
prev = EMPTY;
|
|
130
|
+
index = end;
|
|
131
|
+
} else {
|
|
132
|
+
body += escapeMember("[");
|
|
133
|
+
prev = "[";
|
|
134
|
+
index = nameStart - 2;
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
body += escapeMember(char);
|
|
138
|
+
prev = char;
|
|
139
|
+
}
|
|
140
|
+
index++;
|
|
141
|
+
if (pattern[index] === "]") {
|
|
142
|
+
return {
|
|
143
|
+
end: index,
|
|
144
|
+
source: classSource(negated, body)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
var NEVER_MATCH = "[]";
|
|
150
|
+
var PLACEHOLDER = "\0";
|
|
151
|
+
var REGEX_RESTORE_PLACEHOLDER = new RegExp(
|
|
152
|
+
`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`,
|
|
153
|
+
"g"
|
|
154
|
+
);
|
|
155
|
+
var TRAILING_WILDCARD = "\uE000";
|
|
156
|
+
var TRAILING_DOUBLESTAR = "\uE001";
|
|
157
|
+
var extractBrackets = (pattern) => {
|
|
158
|
+
const sources = [];
|
|
159
|
+
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
160
|
+
const { length } = pattern;
|
|
161
|
+
let out = EMPTY;
|
|
162
|
+
let index = 0;
|
|
163
|
+
while (index < length) {
|
|
164
|
+
const char = pattern[index];
|
|
165
|
+
if (char === ESCAPE) {
|
|
166
|
+
const escaped = pattern[index + 1];
|
|
167
|
+
if (escaped === UNDEFINED || escaped === SLASH && index + 2 === length) {
|
|
168
|
+
out += hold(NEVER_MATCH);
|
|
169
|
+
} else if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
|
|
170
|
+
out += pattern.slice(index, index + 2);
|
|
171
|
+
} else {
|
|
172
|
+
out += hold(
|
|
173
|
+
REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
index += 2;
|
|
177
|
+
} else if (char === PLACEHOLDER) {
|
|
178
|
+
out += hold(`[${PLACEHOLDER}]`);
|
|
179
|
+
index++;
|
|
180
|
+
} else if (char === "[") {
|
|
181
|
+
const scanned = scanBracket(pattern, index);
|
|
182
|
+
if (scanned === null) {
|
|
183
|
+
out += hold(NEVER_MATCH);
|
|
184
|
+
index = length;
|
|
185
|
+
} else {
|
|
186
|
+
out += hold(scanned.source);
|
|
187
|
+
index = scanned.end + 1;
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
out += char;
|
|
191
|
+
index++;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
source: out,
|
|
196
|
+
sources
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
var DIRECT = null;
|
|
200
|
+
var REGEX_INNER_SLASH = /\/(?!$)/;
|
|
201
|
+
var REPLACERS = [
|
|
202
|
+
// Replace (\ ) with ' '
|
|
203
|
+
// Only a space: an escaped tab or other whitespace is already a literal by
|
|
204
|
+
// the time it reaches here, and a bare tab must be left as one, not turned
|
|
205
|
+
// into a space.
|
|
206
|
+
// (\ ) -> ' '
|
|
207
|
+
// (\\ ) -> '\\ '
|
|
208
|
+
// (\\\ ) -> '\\ '
|
|
209
|
+
[
|
|
210
|
+
// A run of backslashes is taken whole, from its first one, so no match
|
|
211
|
+
// ever starts again inside it -- `(\\+?) ` did, which made a long run
|
|
212
|
+
// quadratic.
|
|
213
|
+
/(\\+)( ?)/g,
|
|
214
|
+
(_, run, space) => space ? run.slice(0, run.length - run.length % 2) + SPACE : run,
|
|
215
|
+
ESCAPE + SPACE
|
|
216
|
+
],
|
|
217
|
+
// Escape metacharacters
|
|
218
|
+
// which is written down by users but means special for regular expressions.
|
|
219
|
+
// > There are 12 characters with special meanings:
|
|
220
|
+
// > - the backslash \,
|
|
221
|
+
// > - the caret ^,
|
|
222
|
+
// > - the dollar sign $,
|
|
223
|
+
// > - the period or dot .,
|
|
224
|
+
// > - the vertical bar or pipe symbol |,
|
|
225
|
+
// > - the question mark ?,
|
|
226
|
+
// > - the asterisk or star *,
|
|
227
|
+
// > - the plus sign +,
|
|
228
|
+
// > - the opening parenthesis (,
|
|
229
|
+
// > - the closing parenthesis ),
|
|
230
|
+
// > - and the opening square bracket [,
|
|
231
|
+
// > - the opening curly brace {,
|
|
232
|
+
// > These special characters are often called "metacharacters".
|
|
233
|
+
[
|
|
234
|
+
/[\\$.|*+(){^]/g,
|
|
235
|
+
(match) => `\\${match}`
|
|
236
|
+
],
|
|
237
|
+
[
|
|
238
|
+
// > a question mark (?) matches a single character
|
|
239
|
+
/(?!\\)\?/g,
|
|
240
|
+
() => "[^/]",
|
|
241
|
+
"?"
|
|
242
|
+
],
|
|
243
|
+
// leading slash
|
|
244
|
+
[
|
|
245
|
+
// > A leading slash matches the beginning of the pathname.
|
|
246
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
247
|
+
// A leading slash matches the beginning of the pathname
|
|
248
|
+
/^\//,
|
|
249
|
+
() => "^",
|
|
250
|
+
SLASH
|
|
251
|
+
],
|
|
252
|
+
// replace special metacharacter slash after the leading slash
|
|
253
|
+
[
|
|
254
|
+
/\//g,
|
|
255
|
+
() => "\\/",
|
|
256
|
+
SLASH
|
|
257
|
+
],
|
|
258
|
+
[
|
|
259
|
+
// > A leading "**" followed by a slash means match in all directories.
|
|
260
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
261
|
+
// > the same as pattern "foo".
|
|
262
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
263
|
+
// > under directory "foo".
|
|
264
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
265
|
+
/^\^*(?:\\\*\\\*\\\/)+/,
|
|
266
|
+
// '**/foo' <-> 'foo'
|
|
267
|
+
() => "^(?:.*\\/)?",
|
|
268
|
+
"*"
|
|
269
|
+
],
|
|
270
|
+
// starting
|
|
271
|
+
[
|
|
272
|
+
// there will be no leading '/'
|
|
273
|
+
// (which has been replaced by section "leading slash")
|
|
274
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
275
|
+
DIRECT,
|
|
276
|
+
(source, pattern) => {
|
|
277
|
+
if (!source || source[0] === "^") {
|
|
278
|
+
return source;
|
|
279
|
+
}
|
|
280
|
+
const anchor = !REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^";
|
|
281
|
+
return anchor + source;
|
|
282
|
+
}
|
|
283
|
+
],
|
|
284
|
+
// two globstars
|
|
285
|
+
[
|
|
286
|
+
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
287
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
288
|
+
// Zero, one or several directories
|
|
289
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
290
|
+
// Check if it is not the last `'/**'`
|
|
291
|
+
(_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
|
|
292
|
+
"*"
|
|
293
|
+
],
|
|
294
|
+
// normal intermediate wildcards
|
|
295
|
+
[
|
|
296
|
+
// Never replace escaped '*'
|
|
297
|
+
// ignore rule '\*' will match the path '*'
|
|
298
|
+
// 'abc.*/' -> go
|
|
299
|
+
// 'abc.*' -> skip this rule,
|
|
300
|
+
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
301
|
+
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
302
|
+
// '*.js' matches '.js'
|
|
303
|
+
// '*.js' doesn't match 'abc'
|
|
304
|
+
(_, p1, p2) => {
|
|
305
|
+
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
306
|
+
return p1 + unescaped;
|
|
307
|
+
},
|
|
308
|
+
"*"
|
|
309
|
+
],
|
|
310
|
+
// trailing wildcard, held apart from a literal star
|
|
311
|
+
[
|
|
312
|
+
// The step above leaves a trailing `*` alone, so a single `\*` is all that
|
|
313
|
+
// can be left at the end here. Whether it is a wildcard or a literal
|
|
314
|
+
// turns on the backslashes the user put in front of it: the escaper has
|
|
315
|
+
// since doubled every one, so what stands here is those `2N` doubled
|
|
316
|
+
// backslashes and then the star's own escape. An even number of the
|
|
317
|
+
// original `N` leaves the star unescaped -- a wildcard -- and an odd
|
|
318
|
+
// number escapes it -- a literal. This runs while the two are still
|
|
319
|
+
// distinct, before the unescape steps below collapse the literal onto
|
|
320
|
+
// the very `\*` a wildcard leaves behind.
|
|
321
|
+
/(^|[^\\])((?:\\\\)*)\\\*$/,
|
|
322
|
+
(match, p1, p2) => (
|
|
323
|
+
// `p2` holds the doubled user backslashes; half of them is `N`.
|
|
324
|
+
p2.length / 2 % 2 === 0 ? p1 + p2 + TRAILING_WILDCARD : match
|
|
325
|
+
),
|
|
326
|
+
"*"
|
|
327
|
+
],
|
|
328
|
+
[
|
|
329
|
+
// unescape, revert step 3 except for back slash
|
|
330
|
+
// For example, if a user escape a '\\*',
|
|
331
|
+
// after step 3, the result will be '\\\\\\*'
|
|
332
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
333
|
+
() => ESCAPE,
|
|
334
|
+
ESCAPE + ESCAPE
|
|
335
|
+
],
|
|
336
|
+
[
|
|
337
|
+
// '\\\\' -> '\\'
|
|
338
|
+
/\\\\/g,
|
|
339
|
+
() => ESCAPE,
|
|
340
|
+
ESCAPE + ESCAPE
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
// Every real bracket expression -- POSIX classes included -- has already
|
|
344
|
+
// been held aside by `extractBrackets`, so the only `[` left in the
|
|
345
|
+
// pattern is an escaped, literal one.
|
|
346
|
+
// `\` is escaped by step 3
|
|
347
|
+
/\\\[([^\]/]*?)(\\*)($|\])/g,
|
|
348
|
+
// '\\[bar]' -> '\\\\[bar\\]'
|
|
349
|
+
(match, range, endEscape, close) => `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`,
|
|
350
|
+
"["
|
|
351
|
+
],
|
|
352
|
+
// ending
|
|
353
|
+
[
|
|
354
|
+
// 'js' will not match 'js.'
|
|
355
|
+
// 'ab' will not match 'abc'
|
|
356
|
+
DIRECT,
|
|
357
|
+
// WTF!
|
|
358
|
+
// https://git-scm.com/docs/gitignore
|
|
359
|
+
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
360
|
+
// which re-fixes #24, #38
|
|
361
|
+
// > If there is a separator at the end of the pattern then the pattern
|
|
362
|
+
// > will only match directories, otherwise the pattern can match both
|
|
363
|
+
// > files and directories.
|
|
364
|
+
// 'js*' will not match 'a.js'
|
|
365
|
+
// 'js/' will not match 'a.js'
|
|
366
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
367
|
+
(source) => {
|
|
368
|
+
const last = source[source.length - 1];
|
|
369
|
+
if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
|
|
370
|
+
return source;
|
|
371
|
+
}
|
|
372
|
+
return last === SLASH ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
];
|
|
376
|
+
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
|
|
377
|
+
var MODE_IGNORE = "regex";
|
|
378
|
+
var MODE_CHECK_IGNORE = "checkRegex";
|
|
379
|
+
var UNDERSCORE = "_";
|
|
380
|
+
var replaceTrailingWildcard = (_, p1) => {
|
|
381
|
+
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
382
|
+
return `${prefix}(?=$|\\/$)`;
|
|
383
|
+
};
|
|
384
|
+
var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
|
|
385
|
+
var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
|
|
386
|
+
var WILDCARD = "[^\\/]*";
|
|
387
|
+
var separatorAfter = (run, at) => {
|
|
388
|
+
let separator = EMPTY;
|
|
389
|
+
for (let index = at + 1; index < run.length && !run[index].wildcard; index++) {
|
|
390
|
+
separator += run[index].single;
|
|
391
|
+
}
|
|
392
|
+
return separator;
|
|
393
|
+
};
|
|
394
|
+
var pinWildcards = (source) => {
|
|
395
|
+
if (source.indexOf(WILDCARD) < 0) {
|
|
396
|
+
return source;
|
|
397
|
+
}
|
|
398
|
+
const tokens = [];
|
|
399
|
+
const { length } = source;
|
|
400
|
+
let index = 0;
|
|
401
|
+
while (index < length) {
|
|
402
|
+
const char = source[index];
|
|
403
|
+
if (source.startsWith(WILDCARD, index)) {
|
|
404
|
+
tokens.push({ wildcard: true });
|
|
405
|
+
index += WILDCARD.length;
|
|
406
|
+
} else if (char === "[") {
|
|
407
|
+
let end = index + 1;
|
|
408
|
+
if (source[end] === "^") {
|
|
409
|
+
end++;
|
|
410
|
+
}
|
|
411
|
+
if (source[end] === "]") {
|
|
412
|
+
end++;
|
|
413
|
+
}
|
|
414
|
+
while (end < length && source[end] !== "]") {
|
|
415
|
+
end += source[end] === ESCAPE ? 2 : 1;
|
|
416
|
+
}
|
|
417
|
+
end++;
|
|
418
|
+
tokens.push({ single: source.slice(index, end) });
|
|
419
|
+
index = end;
|
|
420
|
+
} else if (char === ESCAPE) {
|
|
421
|
+
tokens.push({ single: source.slice(index, index + 2) });
|
|
422
|
+
index += 2;
|
|
423
|
+
} else if (char === "(") {
|
|
424
|
+
let depth = 0;
|
|
425
|
+
let end = index;
|
|
426
|
+
do {
|
|
427
|
+
if (source[end] === ESCAPE) {
|
|
428
|
+
end++;
|
|
429
|
+
} else if (source[end] === "(") {
|
|
430
|
+
depth++;
|
|
431
|
+
} else if (source[end] === ")") {
|
|
432
|
+
depth--;
|
|
433
|
+
}
|
|
434
|
+
end++;
|
|
435
|
+
} while (end < length && depth > 0);
|
|
436
|
+
if ("*+?".indexOf(source[end]) >= 0) {
|
|
437
|
+
end++;
|
|
438
|
+
}
|
|
439
|
+
tokens.push({ boundary: source.slice(index, end) });
|
|
440
|
+
index = end;
|
|
441
|
+
} else if (char === "^" || char === "$") {
|
|
442
|
+
tokens.push({ boundary: char });
|
|
443
|
+
index++;
|
|
444
|
+
} else {
|
|
445
|
+
tokens.push({ single: char });
|
|
446
|
+
index++;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
let out = EMPTY;
|
|
450
|
+
let run = [];
|
|
451
|
+
const flush = () => {
|
|
452
|
+
let lastWildcard;
|
|
453
|
+
run.forEach((token, at) => {
|
|
454
|
+
if (token.wildcard) {
|
|
455
|
+
lastWildcard = at;
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
run.forEach((token, at) => {
|
|
459
|
+
if (!token.wildcard) {
|
|
460
|
+
out += token.single;
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
out += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run, at)})[^\\/])*`;
|
|
464
|
+
});
|
|
465
|
+
run = [];
|
|
466
|
+
};
|
|
467
|
+
tokens.forEach((token) => {
|
|
468
|
+
if (token.boundary === void 0) {
|
|
469
|
+
run.push(token);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
flush();
|
|
473
|
+
out += token.boundary;
|
|
474
|
+
});
|
|
475
|
+
flush();
|
|
476
|
+
return out;
|
|
477
|
+
};
|
|
478
|
+
var makeRegexPrefix = (pattern) => {
|
|
479
|
+
const { source, sources } = extractBrackets(pattern);
|
|
480
|
+
const replaced = REPLACERS.reduce(
|
|
481
|
+
// A pass whose matcher finds nothing hands back the very string it was
|
|
482
|
+
// given, so asking first costs a search and saves a rewrite. Ten of the
|
|
483
|
+
// fifteen passes never fire for a typical .gitignore line, and between
|
|
484
|
+
// them they were 45% of this chain.
|
|
485
|
+
(prev, [matcher, replacer, required]) => {
|
|
486
|
+
if (matcher === DIRECT) {
|
|
487
|
+
return replacer(prev, pattern);
|
|
488
|
+
}
|
|
489
|
+
if (required !== UNDEFINED && prev.indexOf(required) < 0) {
|
|
490
|
+
return prev;
|
|
491
|
+
}
|
|
492
|
+
return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
|
|
493
|
+
},
|
|
494
|
+
source
|
|
495
|
+
);
|
|
496
|
+
return sources.length ? replaced.replace(
|
|
497
|
+
REGEX_RESTORE_PLACEHOLDER,
|
|
498
|
+
(match, index) => sources[index]
|
|
499
|
+
) : replaced;
|
|
500
|
+
};
|
|
501
|
+
var checkSourceOf = (body, prefix) => {
|
|
502
|
+
if (body[body.length - 1] === SLASH) {
|
|
503
|
+
prefix = makeRegexPrefix(body.slice(0, -1));
|
|
504
|
+
}
|
|
505
|
+
const head = prefix.slice(0, -1);
|
|
506
|
+
const last = prefix[prefix.length - 1];
|
|
507
|
+
return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
|
|
508
|
+
};
|
|
509
|
+
var matchesBasename = (body) => {
|
|
510
|
+
const index = body.indexOf(SLASH);
|
|
511
|
+
return index < 0 || index === body.length - 1;
|
|
512
|
+
};
|
|
513
|
+
var basenameOf = (path2) => {
|
|
514
|
+
const end = path2.length - 1;
|
|
515
|
+
const index = path2.lastIndexOf(
|
|
516
|
+
SLASH,
|
|
517
|
+
path2[end] === SLASH ? end - 1 : end
|
|
518
|
+
);
|
|
519
|
+
return index < 0 ? path2 : path2.slice(index + 1);
|
|
520
|
+
};
|
|
521
|
+
var parentOf = (path2) => {
|
|
522
|
+
if (path2.charCodeAt(0) === SLASH_CODE || path2.indexOf(DOUBLE_SLASH) >= 0) {
|
|
523
|
+
const slices = path2.split(SLASH).filter(Boolean);
|
|
524
|
+
slices.pop();
|
|
525
|
+
return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
|
|
526
|
+
}
|
|
527
|
+
const end = path2.length - 1;
|
|
528
|
+
const cut = path2.lastIndexOf(
|
|
529
|
+
SLASH,
|
|
530
|
+
path2.charCodeAt(end) === SLASH_CODE ? end - 1 : end
|
|
531
|
+
);
|
|
532
|
+
return cut < 0 ? EMPTY : path2.slice(0, cut + 1);
|
|
533
|
+
};
|
|
534
|
+
var isString = (subject) => typeof subject === "string";
|
|
535
|
+
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern);
|
|
536
|
+
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
537
|
+
var IgnoreRule = class {
|
|
538
|
+
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
539
|
+
this.pattern = pattern;
|
|
540
|
+
this.mark = mark;
|
|
541
|
+
this.negative = negative;
|
|
542
|
+
define(this, "body", body);
|
|
543
|
+
define(this, "ignoreCase", ignoreCase);
|
|
544
|
+
define(this, "regexPrefix", prefix);
|
|
545
|
+
}
|
|
546
|
+
// Worked out on first use and kept behind an own property, the way `regex`
|
|
547
|
+
// caches itself in `_regex`. Deciding it in the constructor instead would
|
|
548
|
+
// add a fourth `defineProperty` to every rule ever built, which cost 4% of
|
|
549
|
+
// every compile -- including the compiles of rules that are never matched
|
|
550
|
+
// against anything.
|
|
551
|
+
get _basenameOnly() {
|
|
552
|
+
return define(this, "_basenameOnly", matchesBasename(this.body));
|
|
553
|
+
}
|
|
554
|
+
get regex() {
|
|
555
|
+
const key = UNDERSCORE + MODE_IGNORE;
|
|
556
|
+
if (this[key]) {
|
|
557
|
+
return this[key];
|
|
558
|
+
}
|
|
559
|
+
return this._make(MODE_IGNORE, key);
|
|
560
|
+
}
|
|
561
|
+
get checkRegex() {
|
|
562
|
+
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
563
|
+
if (this[key]) {
|
|
564
|
+
return this[key];
|
|
565
|
+
}
|
|
566
|
+
return this._make(MODE_CHECK_IGNORE, key);
|
|
567
|
+
}
|
|
568
|
+
_make(mode, key) {
|
|
569
|
+
const str = pinWildcards(
|
|
570
|
+
mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
|
|
571
|
+
);
|
|
572
|
+
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
573
|
+
return define(this, key, regex);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
var isLineEnd = (char) => char === "\r" || char === "\n";
|
|
577
|
+
var trimEnd = (body) => {
|
|
578
|
+
let end = body.length;
|
|
579
|
+
while (end && isLineEnd(body[end - 1])) {
|
|
580
|
+
end--;
|
|
581
|
+
}
|
|
582
|
+
const lineEnd = end;
|
|
583
|
+
while (end && body[end - 1] === SPACE) {
|
|
584
|
+
end--;
|
|
585
|
+
}
|
|
586
|
+
if (end === lineEnd) {
|
|
587
|
+
return body.slice(0, end);
|
|
588
|
+
}
|
|
589
|
+
let backslashes = 0;
|
|
590
|
+
while (backslashes < end && body[end - backslashes - 1] === ESCAPE) {
|
|
591
|
+
backslashes++;
|
|
592
|
+
}
|
|
593
|
+
return backslashes % 2 ? body.slice(0, end - 1) + SPACE : body.slice(0, end);
|
|
594
|
+
};
|
|
595
|
+
var createRule = ({
|
|
596
|
+
pattern,
|
|
597
|
+
mark
|
|
598
|
+
}, ignoreCase) => {
|
|
599
|
+
let body = pattern[0] === BOM ? pattern.slice(1) : pattern;
|
|
600
|
+
if (body[0] === "#") {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
let negative = false;
|
|
604
|
+
if (body[0] === "!") {
|
|
605
|
+
negative = true;
|
|
606
|
+
body = body.slice(1);
|
|
607
|
+
}
|
|
608
|
+
const last = body[body.length - 1];
|
|
609
|
+
if (last === SPACE || last === "\r" || last === "\n") {
|
|
610
|
+
body = trimEnd(body);
|
|
611
|
+
}
|
|
612
|
+
if (!body) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
616
|
+
const regexPrefix = makeRegexPrefix(body);
|
|
617
|
+
return new IgnoreRule(
|
|
618
|
+
pattern,
|
|
619
|
+
mark,
|
|
620
|
+
body,
|
|
621
|
+
ignoreCase,
|
|
622
|
+
negative,
|
|
623
|
+
regexPrefix
|
|
624
|
+
);
|
|
625
|
+
};
|
|
626
|
+
var RuleManager = class {
|
|
627
|
+
constructor(ignoreCase) {
|
|
628
|
+
this._ignoreCase = ignoreCase;
|
|
629
|
+
this._rules = [];
|
|
630
|
+
this._basenameCount = 0;
|
|
631
|
+
}
|
|
632
|
+
_add(pattern) {
|
|
633
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
634
|
+
this._rules = this._rules.concat(pattern._rules._rules);
|
|
635
|
+
this._basenameCount += pattern._rules._basenameCount;
|
|
636
|
+
this._added = true;
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if (isString(pattern)) {
|
|
640
|
+
pattern = {
|
|
641
|
+
pattern
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
const rule = checkPattern(pattern.pattern) && createRule(pattern, this._ignoreCase);
|
|
645
|
+
if (rule) {
|
|
646
|
+
this._added = true;
|
|
647
|
+
this._rules.push(rule);
|
|
648
|
+
if (matchesBasename(rule.body)) {
|
|
649
|
+
this._basenameCount++;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
// @param {Array<string> | string | Ignore} pattern
|
|
654
|
+
add(pattern) {
|
|
655
|
+
this._added = false;
|
|
656
|
+
makeArray(
|
|
657
|
+
isString(pattern) ? splitPattern(pattern) : pattern
|
|
658
|
+
).forEach(this._add, this);
|
|
659
|
+
if (this._added) {
|
|
660
|
+
this._literalRules = UNDEFINED;
|
|
661
|
+
}
|
|
662
|
+
return this._added;
|
|
663
|
+
}
|
|
664
|
+
// Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
|
|
665
|
+
// ending in a wildcard can match it (see `checkSourceOf`), so the rest
|
|
666
|
+
// are left out once, rather than tested or compiled for every path.
|
|
667
|
+
testLiteral(path2) {
|
|
668
|
+
const rules = this._literalRules || (this._literalRules = this._rules.filter(
|
|
669
|
+
({ body }) => body[body.length - (body[body.length - 1] === SLASH ? 2 : 1)] === "*"
|
|
670
|
+
));
|
|
671
|
+
let ignored = false;
|
|
672
|
+
let unignored = false;
|
|
673
|
+
let matchedRule;
|
|
674
|
+
for (let index = rules.length - 1; index >= 0; index--) {
|
|
675
|
+
const rule = rules[index];
|
|
676
|
+
if (rule.checkRegex.test(path2)) {
|
|
677
|
+
ignored = !rule.negative;
|
|
678
|
+
unignored = rule.negative;
|
|
679
|
+
matchedRule = rule.negative ? UNDEFINED : rule;
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
const ret = {
|
|
684
|
+
ignored,
|
|
685
|
+
unignored
|
|
686
|
+
};
|
|
687
|
+
if (matchedRule) {
|
|
688
|
+
ret.rule = matchedRule;
|
|
689
|
+
}
|
|
690
|
+
return ret;
|
|
691
|
+
}
|
|
692
|
+
// Test one single path without recursively checking parent directories
|
|
693
|
+
//
|
|
694
|
+
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
695
|
+
// setting `checkUnignored` to `false` could reduce additional
|
|
696
|
+
// path matching.
|
|
697
|
+
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
698
|
+
// @returns {TestResult} true if a file is ignored
|
|
699
|
+
test(path2, checkUnignored, mode) {
|
|
700
|
+
let ignored = false;
|
|
701
|
+
let unignored = false;
|
|
702
|
+
let matchedRule;
|
|
703
|
+
const rules = this._rules;
|
|
704
|
+
const { length } = rules;
|
|
705
|
+
const shortcut = this._basenameCount * 2 >= length;
|
|
706
|
+
const basename = shortcut ? basenameOf(path2) : path2;
|
|
707
|
+
for (let index = 0; index < length; index++) {
|
|
708
|
+
const rule = rules[index];
|
|
709
|
+
const { negative } = rule;
|
|
710
|
+
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
711
|
+
if (!skip && rule[mode].test(
|
|
712
|
+
shortcut && rule._basenameOnly ? basename : path2
|
|
713
|
+
)) {
|
|
714
|
+
ignored = !negative;
|
|
715
|
+
unignored = negative;
|
|
716
|
+
matchedRule = negative ? UNDEFINED : rule;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
const ret = {
|
|
720
|
+
ignored,
|
|
721
|
+
unignored
|
|
722
|
+
};
|
|
723
|
+
if (matchedRule) {
|
|
724
|
+
ret.rule = matchedRule;
|
|
725
|
+
}
|
|
726
|
+
return ret;
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
var throwError = (message, Ctor) => {
|
|
730
|
+
throw new Ctor(message);
|
|
731
|
+
};
|
|
732
|
+
var checkPath = (path2, originalPath, doThrow) => {
|
|
733
|
+
if (!isString(path2)) {
|
|
734
|
+
return doThrow(
|
|
735
|
+
`path must be a string, but got \`${originalPath}\``,
|
|
736
|
+
TypeError
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
if (!path2) {
|
|
740
|
+
return doThrow(`path must not be empty`, TypeError);
|
|
741
|
+
}
|
|
742
|
+
if (checkPath.isNotRelative(path2)) {
|
|
743
|
+
const r = "`path.relative()`d";
|
|
744
|
+
return doThrow(
|
|
745
|
+
`path should be a ${r} string, but got "${originalPath}"`,
|
|
746
|
+
RangeError
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
return true;
|
|
750
|
+
};
|
|
751
|
+
var isNotRelative = (path2) => {
|
|
752
|
+
const first = path2.charCodeAt(0);
|
|
753
|
+
if (first === SLASH_CODE) {
|
|
754
|
+
return true;
|
|
755
|
+
}
|
|
756
|
+
if (first !== DOT_CODE) {
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
if (path2.length === 1) {
|
|
760
|
+
return true;
|
|
761
|
+
}
|
|
762
|
+
const second = path2.charCodeAt(1);
|
|
763
|
+
if (second === SLASH_CODE) {
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
if (second !== DOT_CODE) {
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
return path2.length === 2 || path2.charCodeAt(2) === SLASH_CODE;
|
|
770
|
+
};
|
|
771
|
+
checkPath.isNotRelative = isNotRelative;
|
|
772
|
+
checkPath.convert = (p) => p;
|
|
773
|
+
var Ignore = class {
|
|
774
|
+
constructor({
|
|
775
|
+
ignorecase = true,
|
|
776
|
+
ignoreCase = ignorecase,
|
|
777
|
+
allowRelativePaths = false
|
|
778
|
+
} = {}) {
|
|
779
|
+
define(this, KEY_IGNORE, true);
|
|
780
|
+
this._rules = new RuleManager(ignoreCase);
|
|
781
|
+
this._strictPathCheck = !allowRelativePaths;
|
|
782
|
+
this._initCache();
|
|
783
|
+
}
|
|
784
|
+
_initCache() {
|
|
785
|
+
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
786
|
+
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
787
|
+
}
|
|
788
|
+
add(pattern) {
|
|
789
|
+
if (this._rules.add(pattern)) {
|
|
790
|
+
this._initCache();
|
|
791
|
+
}
|
|
792
|
+
return this;
|
|
793
|
+
}
|
|
794
|
+
// legacy
|
|
795
|
+
addPattern(pattern) {
|
|
796
|
+
return this.add(pattern);
|
|
797
|
+
}
|
|
798
|
+
// @returns {TestResult}
|
|
799
|
+
_test(originalPath, cache, checkUnignored) {
|
|
800
|
+
const path2 = originalPath && checkPath.convert(originalPath);
|
|
801
|
+
checkPath(
|
|
802
|
+
path2,
|
|
803
|
+
originalPath,
|
|
804
|
+
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
805
|
+
);
|
|
806
|
+
return this._t(path2, cache, checkUnignored);
|
|
807
|
+
}
|
|
808
|
+
checkIgnore(path2) {
|
|
809
|
+
if (path2.charCodeAt(path2.length - 1) !== SLASH_CODE) {
|
|
810
|
+
return this.test(path2);
|
|
811
|
+
}
|
|
812
|
+
const dir = this._t(path2, this._testCache, true);
|
|
813
|
+
if (dir.ignored) {
|
|
814
|
+
return dir;
|
|
815
|
+
}
|
|
816
|
+
const literal = this._rules.testLiteral(path2);
|
|
817
|
+
return literal.ignored || literal.unignored ? literal : dir;
|
|
818
|
+
}
|
|
819
|
+
_t(path2, cache, checkUnignored) {
|
|
820
|
+
if (path2 in cache) {
|
|
821
|
+
return cache[path2];
|
|
822
|
+
}
|
|
823
|
+
const parentPath = parentOf(path2);
|
|
824
|
+
const parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
|
|
825
|
+
return cache[path2] = parent && parent.ignored ? parent : this._rules.test(path2, checkUnignored, MODE_IGNORE);
|
|
826
|
+
}
|
|
827
|
+
ignores(path2) {
|
|
828
|
+
return this._test(path2, this._ignoreCache, false).ignored;
|
|
829
|
+
}
|
|
830
|
+
createFilter() {
|
|
831
|
+
return (path2) => !this.ignores(path2);
|
|
832
|
+
}
|
|
833
|
+
filter(paths) {
|
|
834
|
+
return makeArray(paths).filter(this.createFilter());
|
|
835
|
+
}
|
|
836
|
+
// @returns {TestResult}
|
|
837
|
+
test(path2) {
|
|
838
|
+
return this._test(path2, this._testCache, true);
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
var factory = (options) => new Ignore(options);
|
|
842
|
+
var isPathValid = (path2) => checkPath(path2 && checkPath.convert(path2), path2, RETURN_FALSE);
|
|
843
|
+
var setupWindows = () => {
|
|
844
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
845
|
+
checkPath.convert = makePosix;
|
|
846
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
847
|
+
checkPath.isNotRelative = (path2) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path2) || isNotRelative(path2);
|
|
848
|
+
};
|
|
849
|
+
if (
|
|
850
|
+
// Detect `process` so that it can run in browsers.
|
|
851
|
+
typeof process !== "undefined" && process.platform === "win32"
|
|
852
|
+
) {
|
|
853
|
+
setupWindows();
|
|
854
|
+
}
|
|
855
|
+
module.exports = factory;
|
|
856
|
+
factory.default = factory;
|
|
857
|
+
module.exports.isPathValid = isPathValid;
|
|
858
|
+
define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// src/lib/archive.ts
|
|
863
|
+
var import_ignore = __toESM(require_ignore(), 1);
|
|
864
|
+
import { createHash } from "node:crypto";
|
|
865
|
+
import {
|
|
866
|
+
copyFileSync,
|
|
867
|
+
existsSync,
|
|
868
|
+
mkdirSync,
|
|
869
|
+
mkdtempSync,
|
|
870
|
+
readdirSync,
|
|
871
|
+
readFileSync,
|
|
872
|
+
rmSync,
|
|
873
|
+
statSync,
|
|
874
|
+
writeFileSync
|
|
875
|
+
} from "node:fs";
|
|
876
|
+
import path from "node:path";
|
|
877
|
+
var HARD_EXCLUDES = [
|
|
878
|
+
"node_modules",
|
|
879
|
+
".git",
|
|
880
|
+
"dist",
|
|
881
|
+
"build",
|
|
882
|
+
".next",
|
|
883
|
+
".turbo",
|
|
884
|
+
".cache",
|
|
885
|
+
".vercel",
|
|
886
|
+
".wrangler",
|
|
887
|
+
"coverage",
|
|
888
|
+
".DS_Store",
|
|
889
|
+
"*.log",
|
|
890
|
+
// secrets — never ship these
|
|
891
|
+
".env",
|
|
892
|
+
".env.*",
|
|
893
|
+
"*.pem",
|
|
894
|
+
"*.key",
|
|
895
|
+
"*.p12",
|
|
896
|
+
"*.pfx",
|
|
897
|
+
"id_rsa",
|
|
898
|
+
"id_dsa",
|
|
899
|
+
"id_ecdsa",
|
|
900
|
+
"id_ed25519",
|
|
901
|
+
".npmrc",
|
|
902
|
+
".git-credentials",
|
|
903
|
+
// archives (avoid bundling our own output)
|
|
904
|
+
"*.tgz",
|
|
905
|
+
"*.tar.gz"
|
|
906
|
+
];
|
|
907
|
+
var buildIgnorer = (root) => {
|
|
908
|
+
const hard = (0, import_ignore.default)().add(HARD_EXCLUDES);
|
|
909
|
+
const user = (0, import_ignore.default)();
|
|
910
|
+
for (const name of [".gitignore", ".vibedgamesignore"]) {
|
|
911
|
+
const p = path.join(root, name);
|
|
912
|
+
if (existsSync(p)) {
|
|
913
|
+
user.add(readFileSync(p, "utf-8"));
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return (rel) => hard.ignores(rel) || user.ignores(rel);
|
|
917
|
+
};
|
|
918
|
+
var collectFiles = (root, ignored) => {
|
|
919
|
+
const out = [];
|
|
920
|
+
const walk = (dir) => {
|
|
921
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
922
|
+
const abs = path.join(dir, entry.name);
|
|
923
|
+
const rel = path.relative(root, abs).split(path.sep).join("/");
|
|
924
|
+
if (!rel) {
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
927
|
+
if (entry.isDirectory()) {
|
|
928
|
+
if (ignored(`${rel}/`) || ignored(rel)) {
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
walk(abs);
|
|
932
|
+
} else if (entry.isFile()) {
|
|
933
|
+
if (ignored(rel)) {
|
|
934
|
+
continue;
|
|
935
|
+
}
|
|
936
|
+
out.push(rel);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
walk(root);
|
|
941
|
+
return out.toSorted();
|
|
942
|
+
};
|
|
943
|
+
var installedVersion = (root, name) => {
|
|
944
|
+
let dir = root;
|
|
945
|
+
while (true) {
|
|
946
|
+
const p = path.join(dir, "node_modules", name, "package.json");
|
|
947
|
+
if (existsSync(p)) {
|
|
948
|
+
try {
|
|
949
|
+
const pkg = JSON.parse(readFileSync(p, "utf-8"));
|
|
950
|
+
const v = isJsonObject(pkg) ? pkg.version : void 0;
|
|
951
|
+
if (isJsonString(v)) {
|
|
952
|
+
return v;
|
|
953
|
+
}
|
|
954
|
+
} catch {
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
const parent = path.dirname(dir);
|
|
958
|
+
if (parent === dir) {
|
|
959
|
+
return null;
|
|
960
|
+
}
|
|
961
|
+
dir = parent;
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
var resolveSpec = (root, name, spec) => {
|
|
965
|
+
if (spec.startsWith("workspace:")) {
|
|
966
|
+
const range = spec.slice("workspace:".length);
|
|
967
|
+
if (/\d/u.test(range)) {
|
|
968
|
+
return range;
|
|
969
|
+
}
|
|
970
|
+
const v2 = installedVersion(root, name);
|
|
971
|
+
if (!v2) {
|
|
972
|
+
return null;
|
|
973
|
+
}
|
|
974
|
+
if (range === "~") {
|
|
975
|
+
return `~${v2}`;
|
|
976
|
+
}
|
|
977
|
+
if (range === "*") {
|
|
978
|
+
return v2;
|
|
979
|
+
}
|
|
980
|
+
return `^${v2}`;
|
|
981
|
+
}
|
|
982
|
+
const v = installedVersion(root, name);
|
|
983
|
+
return v ? `^${v}` : null;
|
|
984
|
+
};
|
|
985
|
+
var DEP_FIELDS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
|
|
986
|
+
var rewriteWorkspaceProtocols = (root) => {
|
|
987
|
+
let pkg;
|
|
988
|
+
try {
|
|
989
|
+
pkg = JSON.parse(readFileSync(path.join(root, "package.json"), "utf-8"));
|
|
990
|
+
} catch {
|
|
991
|
+
return null;
|
|
992
|
+
}
|
|
993
|
+
if (!isJsonObject(pkg)) {
|
|
994
|
+
return null;
|
|
995
|
+
}
|
|
996
|
+
let changed = false;
|
|
997
|
+
for (const field of DEP_FIELDS) {
|
|
998
|
+
const deps = pkg[field];
|
|
999
|
+
if (!isJsonObject(deps)) {
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
for (const [name, spec] of Object.entries(deps)) {
|
|
1003
|
+
if (!isJsonString(spec)) {
|
|
1004
|
+
continue;
|
|
1005
|
+
}
|
|
1006
|
+
if (!spec.startsWith("workspace:") && !spec.startsWith("catalog:")) {
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
const resolved = resolveSpec(root, name, spec);
|
|
1010
|
+
if (resolved && resolved !== spec) {
|
|
1011
|
+
deps[name] = resolved;
|
|
1012
|
+
changed = true;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
return changed ? `${JSON.stringify(pkg, null, 2)}
|
|
1017
|
+
` : null;
|
|
1018
|
+
};
|
|
1019
|
+
var packSource = async (root, tmpDir) => {
|
|
1020
|
+
const ignored = buildIgnorer(root);
|
|
1021
|
+
const files = collectFiles(root, ignored);
|
|
1022
|
+
if (files.length === 0) {
|
|
1023
|
+
throw new Error("No source files to archive (everything was ignored?).");
|
|
1024
|
+
}
|
|
1025
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
1026
|
+
const rewritten = files.includes("package.json") ? rewriteWorkspaceProtocols(root) : null;
|
|
1027
|
+
let cwd = root;
|
|
1028
|
+
let stage = null;
|
|
1029
|
+
if (rewritten) {
|
|
1030
|
+
stage = mkdtempSync(path.join(tmpDir, "stage-"));
|
|
1031
|
+
for (const f of files) {
|
|
1032
|
+
const dest = path.join(stage, f);
|
|
1033
|
+
mkdirSync(path.dirname(dest), { recursive: true });
|
|
1034
|
+
copyFileSync(path.join(root, f), dest);
|
|
1035
|
+
}
|
|
1036
|
+
writeFileSync(path.join(stage, "package.json"), rewritten);
|
|
1037
|
+
cwd = stage;
|
|
1038
|
+
}
|
|
1039
|
+
const tarball = path.join(tmpDir, `vg-source-${process.pid}-${files.length}.tgz`);
|
|
1040
|
+
try {
|
|
1041
|
+
await Qn({ cwd, file: tarball, gzip: true, portable: true }, files);
|
|
1042
|
+
} finally {
|
|
1043
|
+
if (stage) {
|
|
1044
|
+
rmSync(stage, { force: true, recursive: true });
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
const buf = readFileSync(tarball);
|
|
1048
|
+
return {
|
|
1049
|
+
bytes: statSync(tarball).size,
|
|
1050
|
+
files,
|
|
1051
|
+
path: tarball,
|
|
1052
|
+
sha256: createHash("sha256").update(buf).digest("hex")
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
var extractSource = async (archivePath, destDir) => {
|
|
1056
|
+
mkdirSync(destDir, { recursive: true });
|
|
1057
|
+
await So({ cwd: destDir, file: archivePath });
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
export {
|
|
1061
|
+
packSource,
|
|
1062
|
+
extractSource
|
|
1063
|
+
};
|