@vltpkg/cli-js 1.0.0-rc.29 → 1.0.0-rc.30
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/{access-6HRR4HXE.js → access-I7Q5S4HE.js} +1 -1
- package/{bugs-2CAZQ32S.js → bugs-XJDVOIWV.js} +4 -4
- package/{build-OAWTNBMS.js → build-KFMSG6YJ.js} +1 -1
- package/{cache-JTAFST6T.js → cache-RL4MUZZ4.js} +1 -1
- package/{chunk-K3RN3BGU.js → chunk-6SMCDBB5.js} +1 -1
- package/{chunk-CPM47YUH.js → chunk-AAO77QBG.js} +1 -1
- package/{chunk-ZINDEKAU.js → chunk-BCS77CZK.js} +72 -72
- package/{chunk-M7HPHM7B.js → chunk-CX6CSVSZ.js} +1 -1
- package/{chunk-HAGUS4HI.js → chunk-DPQWORL7.js} +1 -1
- package/{chunk-7RZL7BZI.js → chunk-E76YOTJF.js} +45 -9
- package/{chunk-VPKJNCKL.js → chunk-EGIFRSA7.js} +1 -1
- package/{chunk-CLDF5XLG.js → chunk-FXFN5J74.js} +2 -2
- package/chunk-HDWMQCAC.js +73 -0
- package/{chunk-WX2DCAG2.js → chunk-I626GJCR.js} +2 -2
- package/{chunk-VRIS5HAW.js → chunk-LUL76G2K.js} +2 -2
- package/chunk-QI6JZT5E.js +781 -0
- package/{chunk-3MWZTKGK.js → chunk-UUE6D7ZK.js} +52 -20
- package/{chunk-D2MVJDUA.js → chunk-YXHBZAYO.js} +1 -1
- package/{ci-TOJJVHI4.js → ci-25PDKMKT.js} +2 -2
- package/cli-package.json +5 -4
- package/{config-DVAPEE5D.js → config-EUN3UG63.js} +3 -3
- package/{config-GOV4E2KK.js → config-SGKD6FN7.js} +3 -3
- package/{create-NGJD7K4L.js → create-7MBL7X4J.js} +6 -6
- package/{deprecate-WROL4AHK.js → deprecate-RXSOKRB6.js} +2 -2
- package/{devtools-TPMVKPB5.js → devtools-6NFQDW4L.js} +29 -29
- package/{dist-tag-WZXXWXMB.js → dist-tag-TR6YTPWB.js} +1 -1
- package/{docs-YCOZFMZG.js → docs-SXJQN3VK.js} +4 -4
- package/{exec-URG5OWLH.js → exec-GZUI7N7U.js} +6 -6
- package/{exec-cache-KHDOEH2F.js → exec-cache-ERIWZB3O.js} +4 -4
- package/{exec-local-52TVUL5K.js → exec-local-5EIXJDU2.js} +3 -3
- package/{help-LNSDVBGJ.js → help-VZXBYP36.js} +1 -1
- package/{init-XNMWYATA.js → init-B3GRYNH5.js} +2 -2
- package/{install-SKUZERZJ.js → install-GFUAOCU3.js} +3 -3
- package/{list-XEDVFUD5.js → list-SWSGDOS2.js} +3 -3
- package/{login-52SA2DSI.js → login-2QU5SPGP.js} +1 -1
- package/{logout-5YYHNV5W.js → logout-DVW3KZKJ.js} +1 -1
- package/{pack-B7QZHMYP.js → pack-GNYL35NY.js} +3 -3
- package/package.json +1 -1
- package/{ping-PRGDYDRI.js → ping-5NKJAV3C.js} +1 -1
- package/{pkg-UEIQIVVD.js → pkg-XGXCIZCS.js} +3 -3
- package/{profile-46FKVQEL.js → profile-OZYH6GL2.js} +1 -1
- package/{publish-HBYHOSKH.js → publish-PUXCD3CT.js} +23 -14
- package/{query-5A4YLS2C.js → query-TUQMPQGD.js} +3 -3
- package/registry-client-package.json +1 -1
- package/registry-client-src-revalidate.js +46 -16
- package/{repo-I6X66PHD.js → repo-ALXGJFIG.js} +4 -4
- package/{reporter-NUXJTV4G.js → reporter-MSQWYN76.js} +1 -1
- package/{run-VEZMUMVH.js → run-GM2E5WHJ.js} +3 -3
- package/{run-exec-6ADY4BKH.js → run-exec-3AMM56A3.js} +3 -3
- package/{src-O32QL33R.js → src-QQVS7FWK.js} +4 -4
- package/{token-YK6L74PA.js → token-MW32RFPW.js} +73 -24
- package/{uninstall-UBUZBV7E.js → uninstall-QTAVWQNB.js} +3 -3
- package/{unpublish-ZHJEKT7A.js → unpublish-B5JROG62.js} +1 -1
- package/{update-WO4BHJF4.js → update-P274ATK3.js} +2 -2
- package/{version-RLESYHML.js → version-23AKGCGL.js} +2 -2
- package/{view-UA5HXFXG.js → view-Q35LCZGS.js} +2 -2
- package/vlr.js +1 -1
- package/vlrx.js +1 -1
- package/vlt.js +1 -1
- package/vlx.js +1 -1
- package/vlxl.js +1 -1
- package/{whoami-7H3FPR2O.js → whoami-XH64UEWS.js} +1 -1
- package/chunk-7WHVJ56C.js +0 -73
- package/chunk-BW6C3YUV.js +0 -301
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
var global = globalThis;
|
|
2
|
+
import {Buffer} from "node:buffer";
|
|
3
|
+
import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
|
|
4
|
+
globalThis.setTimeout = _vlt_setTimeout;
|
|
5
|
+
globalThis.clearTimeout = _vlt_clearTimeout;
|
|
6
|
+
globalThis.setImmediate = _vlt_setImmediate;
|
|
7
|
+
globalThis.clearImmediate = _vlt_clearImmediate;
|
|
8
|
+
globalThis.setInterval = _vlt_setInterval;
|
|
9
|
+
globalThis.clearInterval = _vlt_clearInterval;
|
|
10
|
+
import {createRequire as _vlt_createRequire} from "node:module";
|
|
11
|
+
var require = _vlt_createRequire(import.meta.filename);
|
|
12
|
+
import {
|
|
13
|
+
It,
|
|
14
|
+
Zn,
|
|
15
|
+
require_lib
|
|
16
|
+
} from "./chunk-HQ4US6G3.js";
|
|
17
|
+
import {
|
|
18
|
+
minimatch
|
|
19
|
+
} from "./chunk-XYCCQT7N.js";
|
|
20
|
+
import {
|
|
21
|
+
Spec2 as Spec
|
|
22
|
+
} from "./chunk-IEISSXS4.js";
|
|
23
|
+
import {
|
|
24
|
+
parse,
|
|
25
|
+
stringify
|
|
26
|
+
} from "./chunk-HTOTG4TS.js";
|
|
27
|
+
import {
|
|
28
|
+
error
|
|
29
|
+
} from "./chunk-WZWDS3W4.js";
|
|
30
|
+
import {
|
|
31
|
+
__commonJS,
|
|
32
|
+
__toESM
|
|
33
|
+
} from "./chunk-PZLD7RTK.js";
|
|
34
|
+
|
|
35
|
+
// ../../node_modules/.vlt/~npm~ignore@7.0.5/node_modules/ignore/index.js
|
|
36
|
+
var require_ignore = __commonJS({
|
|
37
|
+
"../../node_modules/.vlt/~npm~ignore@7.0.5/node_modules/ignore/index.js"(exports, module) {
|
|
38
|
+
function makeArray(subject) {
|
|
39
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
40
|
+
}
|
|
41
|
+
var UNDEFINED = void 0;
|
|
42
|
+
var EMPTY = "";
|
|
43
|
+
var SPACE = " ";
|
|
44
|
+
var ESCAPE = "\\";
|
|
45
|
+
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
46
|
+
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
47
|
+
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
48
|
+
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
49
|
+
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
50
|
+
var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
|
|
51
|
+
var REGEX_TEST_TRAILING_SLASH = /\/$/;
|
|
52
|
+
var SLASH = "/";
|
|
53
|
+
var TMP_KEY_IGNORE = "node-ignore";
|
|
54
|
+
if (typeof Symbol !== "undefined") {
|
|
55
|
+
TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
|
|
56
|
+
}
|
|
57
|
+
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
58
|
+
var define = (object, key, value) => {
|
|
59
|
+
Object.defineProperty(object, key, { value });
|
|
60
|
+
return value;
|
|
61
|
+
};
|
|
62
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
63
|
+
var RETURN_FALSE = () => false;
|
|
64
|
+
var sanitizeRange = (range) => range.replace(
|
|
65
|
+
REGEX_REGEXP_RANGE,
|
|
66
|
+
(match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
|
|
67
|
+
);
|
|
68
|
+
var cleanRangeBackSlash = (slashes) => {
|
|
69
|
+
const { length } = slashes;
|
|
70
|
+
return slashes.slice(0, length - length % 2);
|
|
71
|
+
};
|
|
72
|
+
var REPLACERS = [
|
|
73
|
+
[
|
|
74
|
+
// Remove BOM
|
|
75
|
+
// TODO:
|
|
76
|
+
// Other similar zero-width characters?
|
|
77
|
+
/^\uFEFF/,
|
|
78
|
+
() => EMPTY
|
|
79
|
+
],
|
|
80
|
+
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
81
|
+
[
|
|
82
|
+
// (a\ ) -> (a )
|
|
83
|
+
// (a ) -> (a)
|
|
84
|
+
// (a ) -> (a)
|
|
85
|
+
// (a \ ) -> (a )
|
|
86
|
+
/((?:\\\\)*?)(\\?\s+)$/,
|
|
87
|
+
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
88
|
+
],
|
|
89
|
+
// Replace (\ ) with ' '
|
|
90
|
+
// (\ ) -> ' '
|
|
91
|
+
// (\\ ) -> '\\ '
|
|
92
|
+
// (\\\ ) -> '\\ '
|
|
93
|
+
[
|
|
94
|
+
/(\\+?)\s/g,
|
|
95
|
+
(_, m1) => {
|
|
96
|
+
const { length } = m1;
|
|
97
|
+
return m1.slice(0, length - length % 2) + SPACE;
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
// Escape metacharacters
|
|
101
|
+
// which is written down by users but means special for regular expressions.
|
|
102
|
+
// > There are 12 characters with special meanings:
|
|
103
|
+
// > - the backslash \,
|
|
104
|
+
// > - the caret ^,
|
|
105
|
+
// > - the dollar sign $,
|
|
106
|
+
// > - the period or dot .,
|
|
107
|
+
// > - the vertical bar or pipe symbol |,
|
|
108
|
+
// > - the question mark ?,
|
|
109
|
+
// > - the asterisk or star *,
|
|
110
|
+
// > - the plus sign +,
|
|
111
|
+
// > - the opening parenthesis (,
|
|
112
|
+
// > - the closing parenthesis ),
|
|
113
|
+
// > - and the opening square bracket [,
|
|
114
|
+
// > - the opening curly brace {,
|
|
115
|
+
// > These special characters are often called "metacharacters".
|
|
116
|
+
[
|
|
117
|
+
/[\\$.|*+(){^]/g,
|
|
118
|
+
(match) => `\\${match}`
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
// > a question mark (?) matches a single character
|
|
122
|
+
/(?!\\)\?/g,
|
|
123
|
+
() => "[^/]"
|
|
124
|
+
],
|
|
125
|
+
// leading slash
|
|
126
|
+
[
|
|
127
|
+
// > A leading slash matches the beginning of the pathname.
|
|
128
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
129
|
+
// A leading slash matches the beginning of the pathname
|
|
130
|
+
/^\//,
|
|
131
|
+
() => "^"
|
|
132
|
+
],
|
|
133
|
+
// replace special metacharacter slash after the leading slash
|
|
134
|
+
[
|
|
135
|
+
/\//g,
|
|
136
|
+
() => "\\/"
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
// > A leading "**" followed by a slash means match in all directories.
|
|
140
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
141
|
+
// > the same as pattern "foo".
|
|
142
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
143
|
+
// > under directory "foo".
|
|
144
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
145
|
+
/^\^*\\\*\\\*\\\//,
|
|
146
|
+
// '**/foo' <-> 'foo'
|
|
147
|
+
() => "^(?:.*\\/)?"
|
|
148
|
+
],
|
|
149
|
+
// starting
|
|
150
|
+
[
|
|
151
|
+
// there will be no leading '/'
|
|
152
|
+
// (which has been replaced by section "leading slash")
|
|
153
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
154
|
+
/^(?=[^^])/,
|
|
155
|
+
function startingReplacer() {
|
|
156
|
+
return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
// two globstars
|
|
160
|
+
[
|
|
161
|
+
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
162
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
163
|
+
// Zero, one or several directories
|
|
164
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
165
|
+
// Check if it is not the last `'/**'`
|
|
166
|
+
(_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
|
|
167
|
+
],
|
|
168
|
+
// normal intermediate wildcards
|
|
169
|
+
[
|
|
170
|
+
// Never replace escaped '*'
|
|
171
|
+
// ignore rule '\*' will match the path '*'
|
|
172
|
+
// 'abc.*/' -> go
|
|
173
|
+
// 'abc.*' -> skip this rule,
|
|
174
|
+
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
175
|
+
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
176
|
+
// '*.js' matches '.js'
|
|
177
|
+
// '*.js' doesn't match 'abc'
|
|
178
|
+
(_, p1, p2) => {
|
|
179
|
+
const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
|
|
180
|
+
return p1 + unescaped;
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
// unescape, revert step 3 except for back slash
|
|
185
|
+
// For example, if a user escape a '\\*',
|
|
186
|
+
// after step 3, the result will be '\\\\\\*'
|
|
187
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
188
|
+
() => ESCAPE
|
|
189
|
+
],
|
|
190
|
+
[
|
|
191
|
+
// '\\\\' -> '\\'
|
|
192
|
+
/\\\\/g,
|
|
193
|
+
() => ESCAPE
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
// > The range notation, e.g. [a-zA-Z],
|
|
197
|
+
// > can be used to match one of the characters in a range.
|
|
198
|
+
// `\` is escaped by step 3
|
|
199
|
+
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
200
|
+
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
|
|
201
|
+
],
|
|
202
|
+
// ending
|
|
203
|
+
[
|
|
204
|
+
// 'js' will not match 'js.'
|
|
205
|
+
// 'ab' will not match 'abc'
|
|
206
|
+
/(?:[^*])$/,
|
|
207
|
+
// WTF!
|
|
208
|
+
// https://git-scm.com/docs/gitignore
|
|
209
|
+
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
210
|
+
// which re-fixes #24, #38
|
|
211
|
+
// > If there is a separator at the end of the pattern then the pattern
|
|
212
|
+
// > will only match directories, otherwise the pattern can match both
|
|
213
|
+
// > files and directories.
|
|
214
|
+
// 'js*' will not match 'a.js'
|
|
215
|
+
// 'js/' will not match 'a.js'
|
|
216
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
217
|
+
(match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
|
|
218
|
+
]
|
|
219
|
+
];
|
|
220
|
+
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
|
|
221
|
+
var MODE_IGNORE = "regex";
|
|
222
|
+
var MODE_CHECK_IGNORE = "checkRegex";
|
|
223
|
+
var UNDERSCORE = "_";
|
|
224
|
+
var TRAILING_WILD_CARD_REPLACERS = {
|
|
225
|
+
[MODE_IGNORE](_, p1) {
|
|
226
|
+
const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
|
|
227
|
+
return `${prefix}(?=$|\\/$)`;
|
|
228
|
+
},
|
|
229
|
+
[MODE_CHECK_IGNORE](_, p1) {
|
|
230
|
+
const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
|
|
231
|
+
return `${prefix}(?=$|\\/$)`;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var makeRegexPrefix = (pattern) => REPLACERS.reduce(
|
|
235
|
+
(prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
|
|
236
|
+
pattern
|
|
237
|
+
);
|
|
238
|
+
var isString = (subject) => typeof subject === "string";
|
|
239
|
+
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
240
|
+
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
241
|
+
var IgnoreRule = class {
|
|
242
|
+
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
243
|
+
this.pattern = pattern;
|
|
244
|
+
this.mark = mark;
|
|
245
|
+
this.negative = negative;
|
|
246
|
+
define(this, "body", body);
|
|
247
|
+
define(this, "ignoreCase", ignoreCase);
|
|
248
|
+
define(this, "regexPrefix", prefix);
|
|
249
|
+
}
|
|
250
|
+
get regex() {
|
|
251
|
+
const key = UNDERSCORE + MODE_IGNORE;
|
|
252
|
+
if (this[key]) {
|
|
253
|
+
return this[key];
|
|
254
|
+
}
|
|
255
|
+
return this._make(MODE_IGNORE, key);
|
|
256
|
+
}
|
|
257
|
+
get checkRegex() {
|
|
258
|
+
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
259
|
+
if (this[key]) {
|
|
260
|
+
return this[key];
|
|
261
|
+
}
|
|
262
|
+
return this._make(MODE_CHECK_IGNORE, key);
|
|
263
|
+
}
|
|
264
|
+
_make(mode, key) {
|
|
265
|
+
const str = this.regexPrefix.replace(
|
|
266
|
+
REGEX_REPLACE_TRAILING_WILDCARD,
|
|
267
|
+
// It does not need to bind pattern
|
|
268
|
+
TRAILING_WILD_CARD_REPLACERS[mode]
|
|
269
|
+
);
|
|
270
|
+
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
271
|
+
return define(this, key, regex);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
var createRule = ({
|
|
275
|
+
pattern,
|
|
276
|
+
mark
|
|
277
|
+
}, ignoreCase) => {
|
|
278
|
+
let negative = false;
|
|
279
|
+
let body = pattern;
|
|
280
|
+
if (body.indexOf("!") === 0) {
|
|
281
|
+
negative = true;
|
|
282
|
+
body = body.substr(1);
|
|
283
|
+
}
|
|
284
|
+
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
285
|
+
const regexPrefix = makeRegexPrefix(body);
|
|
286
|
+
return new IgnoreRule(
|
|
287
|
+
pattern,
|
|
288
|
+
mark,
|
|
289
|
+
body,
|
|
290
|
+
ignoreCase,
|
|
291
|
+
negative,
|
|
292
|
+
regexPrefix
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
var RuleManager = class {
|
|
296
|
+
constructor(ignoreCase) {
|
|
297
|
+
this._ignoreCase = ignoreCase;
|
|
298
|
+
this._rules = [];
|
|
299
|
+
}
|
|
300
|
+
_add(pattern) {
|
|
301
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
302
|
+
this._rules = this._rules.concat(pattern._rules._rules);
|
|
303
|
+
this._added = true;
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (isString(pattern)) {
|
|
307
|
+
pattern = {
|
|
308
|
+
pattern
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
if (checkPattern(pattern.pattern)) {
|
|
312
|
+
const rule = createRule(pattern, this._ignoreCase);
|
|
313
|
+
this._added = true;
|
|
314
|
+
this._rules.push(rule);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// @param {Array<string> | string | Ignore} pattern
|
|
318
|
+
add(pattern) {
|
|
319
|
+
this._added = false;
|
|
320
|
+
makeArray(
|
|
321
|
+
isString(pattern) ? splitPattern(pattern) : pattern
|
|
322
|
+
).forEach(this._add, this);
|
|
323
|
+
return this._added;
|
|
324
|
+
}
|
|
325
|
+
// Test one single path without recursively checking parent directories
|
|
326
|
+
//
|
|
327
|
+
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
328
|
+
// setting `checkUnignored` to `false` could reduce additional
|
|
329
|
+
// path matching.
|
|
330
|
+
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
331
|
+
// @returns {TestResult} true if a file is ignored
|
|
332
|
+
test(path, checkUnignored, mode) {
|
|
333
|
+
let ignored = false;
|
|
334
|
+
let unignored = false;
|
|
335
|
+
let matchedRule;
|
|
336
|
+
this._rules.forEach((rule) => {
|
|
337
|
+
const { negative } = rule;
|
|
338
|
+
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const matched = rule[mode].test(path);
|
|
342
|
+
if (!matched) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
ignored = !negative;
|
|
346
|
+
unignored = negative;
|
|
347
|
+
matchedRule = negative ? UNDEFINED : rule;
|
|
348
|
+
});
|
|
349
|
+
const ret = {
|
|
350
|
+
ignored,
|
|
351
|
+
unignored
|
|
352
|
+
};
|
|
353
|
+
if (matchedRule) {
|
|
354
|
+
ret.rule = matchedRule;
|
|
355
|
+
}
|
|
356
|
+
return ret;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
var throwError = (message, Ctor) => {
|
|
360
|
+
throw new Ctor(message);
|
|
361
|
+
};
|
|
362
|
+
var checkPath = (path, originalPath, doThrow) => {
|
|
363
|
+
if (!isString(path)) {
|
|
364
|
+
return doThrow(
|
|
365
|
+
`path must be a string, but got \`${originalPath}\``,
|
|
366
|
+
TypeError
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
if (!path) {
|
|
370
|
+
return doThrow(`path must not be empty`, TypeError);
|
|
371
|
+
}
|
|
372
|
+
if (checkPath.isNotRelative(path)) {
|
|
373
|
+
const r = "`path.relative()`d";
|
|
374
|
+
return doThrow(
|
|
375
|
+
`path should be a ${r} string, but got "${originalPath}"`,
|
|
376
|
+
RangeError
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
return true;
|
|
380
|
+
};
|
|
381
|
+
var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
|
|
382
|
+
checkPath.isNotRelative = isNotRelative;
|
|
383
|
+
checkPath.convert = (p) => p;
|
|
384
|
+
var Ignore = class {
|
|
385
|
+
constructor({
|
|
386
|
+
ignorecase = true,
|
|
387
|
+
ignoreCase = ignorecase,
|
|
388
|
+
allowRelativePaths = false
|
|
389
|
+
} = {}) {
|
|
390
|
+
define(this, KEY_IGNORE, true);
|
|
391
|
+
this._rules = new RuleManager(ignoreCase);
|
|
392
|
+
this._strictPathCheck = !allowRelativePaths;
|
|
393
|
+
this._initCache();
|
|
394
|
+
}
|
|
395
|
+
_initCache() {
|
|
396
|
+
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
397
|
+
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
398
|
+
}
|
|
399
|
+
add(pattern) {
|
|
400
|
+
if (this._rules.add(pattern)) {
|
|
401
|
+
this._initCache();
|
|
402
|
+
}
|
|
403
|
+
return this;
|
|
404
|
+
}
|
|
405
|
+
// legacy
|
|
406
|
+
addPattern(pattern) {
|
|
407
|
+
return this.add(pattern);
|
|
408
|
+
}
|
|
409
|
+
// @returns {TestResult}
|
|
410
|
+
_test(originalPath, cache, checkUnignored, slices) {
|
|
411
|
+
const path = originalPath && checkPath.convert(originalPath);
|
|
412
|
+
checkPath(
|
|
413
|
+
path,
|
|
414
|
+
originalPath,
|
|
415
|
+
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
416
|
+
);
|
|
417
|
+
return this._t(path, cache, checkUnignored, slices);
|
|
418
|
+
}
|
|
419
|
+
checkIgnore(path) {
|
|
420
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
|
|
421
|
+
return this.test(path);
|
|
422
|
+
}
|
|
423
|
+
const slices = path.split(SLASH).filter(Boolean);
|
|
424
|
+
slices.pop();
|
|
425
|
+
if (slices.length) {
|
|
426
|
+
const parent = this._t(
|
|
427
|
+
slices.join(SLASH) + SLASH,
|
|
428
|
+
this._testCache,
|
|
429
|
+
true,
|
|
430
|
+
slices
|
|
431
|
+
);
|
|
432
|
+
if (parent.ignored) {
|
|
433
|
+
return parent;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return this._rules.test(path, false, MODE_CHECK_IGNORE);
|
|
437
|
+
}
|
|
438
|
+
_t(path, cache, checkUnignored, slices) {
|
|
439
|
+
if (path in cache) {
|
|
440
|
+
return cache[path];
|
|
441
|
+
}
|
|
442
|
+
if (!slices) {
|
|
443
|
+
slices = path.split(SLASH).filter(Boolean);
|
|
444
|
+
}
|
|
445
|
+
slices.pop();
|
|
446
|
+
if (!slices.length) {
|
|
447
|
+
return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
448
|
+
}
|
|
449
|
+
const parent = this._t(
|
|
450
|
+
slices.join(SLASH) + SLASH,
|
|
451
|
+
cache,
|
|
452
|
+
checkUnignored,
|
|
453
|
+
slices
|
|
454
|
+
);
|
|
455
|
+
return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
456
|
+
}
|
|
457
|
+
ignores(path) {
|
|
458
|
+
return this._test(path, this._ignoreCache, false).ignored;
|
|
459
|
+
}
|
|
460
|
+
createFilter() {
|
|
461
|
+
return (path) => !this.ignores(path);
|
|
462
|
+
}
|
|
463
|
+
filter(paths) {
|
|
464
|
+
return makeArray(paths).filter(this.createFilter());
|
|
465
|
+
}
|
|
466
|
+
// @returns {TestResult}
|
|
467
|
+
test(path) {
|
|
468
|
+
return this._test(path, this._testCache, true);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
var factory = (options) => new Ignore(options);
|
|
472
|
+
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
473
|
+
var setupWindows = () => {
|
|
474
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
475
|
+
checkPath.convert = makePosix;
|
|
476
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
477
|
+
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
478
|
+
};
|
|
479
|
+
if (
|
|
480
|
+
// Detect `process` so that it can run in browsers.
|
|
481
|
+
typeof process !== "undefined" && process.platform === "win32"
|
|
482
|
+
) {
|
|
483
|
+
setupWindows();
|
|
484
|
+
}
|
|
485
|
+
module.exports = factory;
|
|
486
|
+
factory.default = factory;
|
|
487
|
+
module.exports.isPathValid = isPathValid;
|
|
488
|
+
define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// ../../src/cli-sdk/src/pack-tarball.ts
|
|
493
|
+
var ssri = __toESM(require_lib(), 1);
|
|
494
|
+
import assert from "node:assert";
|
|
495
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
496
|
+
import { join } from "node:path";
|
|
497
|
+
var import_ignore = __toESM(require_ignore(), 1);
|
|
498
|
+
var replaceWorkspaceAndCatalogSpecs = (manifest_, config) => {
|
|
499
|
+
const manifest = parse(stringify(manifest_));
|
|
500
|
+
const { monorepo, catalog = {}, catalogs = {} } = config.options;
|
|
501
|
+
const depTypes = [
|
|
502
|
+
"dependencies",
|
|
503
|
+
"devDependencies",
|
|
504
|
+
"optionalDependencies",
|
|
505
|
+
"peerDependencies"
|
|
506
|
+
];
|
|
507
|
+
for (const depType of depTypes) {
|
|
508
|
+
const deps = manifest[depType];
|
|
509
|
+
if (!deps || typeof deps !== "object") continue;
|
|
510
|
+
const depsObj = deps;
|
|
511
|
+
for (const [depName, depSpec] of Object.entries(depsObj)) {
|
|
512
|
+
if (typeof depSpec !== "string") continue;
|
|
513
|
+
const spec = Spec.parse(`${depName}@${depSpec}`, {
|
|
514
|
+
catalog,
|
|
515
|
+
catalogs
|
|
516
|
+
});
|
|
517
|
+
switch (spec.type) {
|
|
518
|
+
case "workspace": {
|
|
519
|
+
assert(
|
|
520
|
+
monorepo,
|
|
521
|
+
error(`No workspace configuration found for ${depName}`, {
|
|
522
|
+
found: depName
|
|
523
|
+
})
|
|
524
|
+
);
|
|
525
|
+
const workspaceName = spec.workspace;
|
|
526
|
+
assert(
|
|
527
|
+
workspaceName,
|
|
528
|
+
error(`No workspace name found for ${depName}`, {
|
|
529
|
+
found: depName
|
|
530
|
+
})
|
|
531
|
+
);
|
|
532
|
+
const workspace = monorepo.get(workspaceName);
|
|
533
|
+
assert(
|
|
534
|
+
workspace,
|
|
535
|
+
error(`Workspace '${workspaceName}' not found`, {
|
|
536
|
+
found: workspaceName,
|
|
537
|
+
validOptions: Array.from(monorepo.keys())
|
|
538
|
+
})
|
|
539
|
+
);
|
|
540
|
+
const actualVersion = workspace.manifest.version;
|
|
541
|
+
assert(
|
|
542
|
+
actualVersion,
|
|
543
|
+
error(
|
|
544
|
+
`No version found for workspace '${workspaceName}'`,
|
|
545
|
+
{
|
|
546
|
+
found: workspaceName,
|
|
547
|
+
wanted: "package version"
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
);
|
|
551
|
+
depsObj[depName] = actualVersion;
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
case "catalog": {
|
|
555
|
+
const catalogName = spec.catalog || "";
|
|
556
|
+
const targetCatalog = catalogName ? catalogs[catalogName] : catalog;
|
|
557
|
+
assert(
|
|
558
|
+
targetCatalog,
|
|
559
|
+
error(`Catalog '${catalogName}' not found`, {
|
|
560
|
+
found: catalogName,
|
|
561
|
+
validOptions: Object.keys(catalogs)
|
|
562
|
+
})
|
|
563
|
+
);
|
|
564
|
+
const actualVersion = targetCatalog[depName];
|
|
565
|
+
assert(
|
|
566
|
+
actualVersion,
|
|
567
|
+
error(
|
|
568
|
+
`Package '${depName}' not found in catalog '${catalogName || "default"}'`,
|
|
569
|
+
{
|
|
570
|
+
found: depName,
|
|
571
|
+
validOptions: Object.keys(targetCatalog)
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
);
|
|
575
|
+
depsObj[depName] = actualVersion;
|
|
576
|
+
break;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return manifest;
|
|
582
|
+
};
|
|
583
|
+
var alwaysExcludePatterns = [
|
|
584
|
+
/^\.?\/?\.git(\/|$)/,
|
|
585
|
+
/^\.?\/?node_modules(\/|$)/,
|
|
586
|
+
/^\.?\/?\.nyc_output(\/|$)/,
|
|
587
|
+
/^\.?\/?coverage(\/|$)/,
|
|
588
|
+
/^\.?\/?\.vscode(\/|$)/,
|
|
589
|
+
/^\.?\/?\.idea(\/|$)/,
|
|
590
|
+
/^\.?\/?\.DS_Store$/,
|
|
591
|
+
/^\.?\/?\.npmrc$/,
|
|
592
|
+
/^\.?\/?\.gitignore$/,
|
|
593
|
+
/^\.?\/?\.npmignore$/,
|
|
594
|
+
/^\.?\/?\.editorconfig$/,
|
|
595
|
+
/^\.?\/?package-lock\.json$/,
|
|
596
|
+
/^\.?\/?yarn\.lock$/,
|
|
597
|
+
/^\.?\/?pnpm-lock\.yaml$/,
|
|
598
|
+
/^\.?\/?bun\.lockb$/,
|
|
599
|
+
/^\.?\/?bun\.lock$/,
|
|
600
|
+
/^\.?\/?vlt-lock\.json$/,
|
|
601
|
+
/^\.?\/?vlt\.json$/,
|
|
602
|
+
/~$/,
|
|
603
|
+
/\.swp$/,
|
|
604
|
+
/\.tgz$/
|
|
605
|
+
];
|
|
606
|
+
var alwaysIncludePatterns = [
|
|
607
|
+
/^README(\..*)?$/i,
|
|
608
|
+
/^CHANGELOG(\..*)?$/i,
|
|
609
|
+
/^HISTORY(\..*)?$/i,
|
|
610
|
+
/^LICENSE(\..*)?$/i,
|
|
611
|
+
/^LICENCE(\..*)?$/i
|
|
612
|
+
];
|
|
613
|
+
var readIgnoreFile = (dir, name) => {
|
|
614
|
+
const filePath = join(dir, name);
|
|
615
|
+
if (!existsSync(filePath)) return void 0;
|
|
616
|
+
return readFileSync(filePath, "utf8");
|
|
617
|
+
};
|
|
618
|
+
var buildPackFilter = (manifest, packDir) => {
|
|
619
|
+
const manifestWithFiles = manifest;
|
|
620
|
+
const hasFilesField = Array.isArray(manifestWithFiles.files) && manifestWithFiles.files.length > 0;
|
|
621
|
+
const hasEmptyFilesField = Array.isArray(manifestWithFiles.files) && manifestWithFiles.files.length === 0;
|
|
622
|
+
let ig;
|
|
623
|
+
if (!hasFilesField && !hasEmptyFilesField) {
|
|
624
|
+
const npmignoreContent = readIgnoreFile(packDir, ".npmignore");
|
|
625
|
+
if (npmignoreContent !== void 0) {
|
|
626
|
+
ig = (0, import_ignore.default)().add(npmignoreContent);
|
|
627
|
+
} else {
|
|
628
|
+
const gitignoreContent = readIgnoreFile(packDir, ".gitignore");
|
|
629
|
+
if (gitignoreContent !== void 0) {
|
|
630
|
+
ig = (0, import_ignore.default)().add(gitignoreContent);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return (path) => {
|
|
635
|
+
const normalizedPath = path.replace(/^\.\//, "");
|
|
636
|
+
if (path === "." || normalizedPath === "") {
|
|
637
|
+
return true;
|
|
638
|
+
}
|
|
639
|
+
if (alwaysExcludePatterns.some(
|
|
640
|
+
(pattern) => pattern.test(normalizedPath)
|
|
641
|
+
)) {
|
|
642
|
+
return false;
|
|
643
|
+
}
|
|
644
|
+
if (alwaysIncludePatterns.some(
|
|
645
|
+
(pattern) => pattern.test(normalizedPath)
|
|
646
|
+
)) {
|
|
647
|
+
return true;
|
|
648
|
+
}
|
|
649
|
+
if (normalizedPath === "package.json") {
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
if (hasEmptyFilesField) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
if (hasFilesField && manifestWithFiles.files) {
|
|
656
|
+
return manifestWithFiles.files.some((pattern) => {
|
|
657
|
+
if (pattern.endsWith("/")) {
|
|
658
|
+
const dirName = pattern.slice(0, -1);
|
|
659
|
+
const globPattern = pattern.replace(/\/$/, "/**");
|
|
660
|
+
const matchesDir = normalizedPath === dirName;
|
|
661
|
+
const matchesContents = minimatch(
|
|
662
|
+
normalizedPath,
|
|
663
|
+
globPattern,
|
|
664
|
+
{ dot: true }
|
|
665
|
+
);
|
|
666
|
+
return matchesDir || matchesContents;
|
|
667
|
+
}
|
|
668
|
+
const directMatch = minimatch(normalizedPath, pattern, {
|
|
669
|
+
dot: true
|
|
670
|
+
});
|
|
671
|
+
const isParentDir = pattern.includes("/") && pattern.startsWith(normalizedPath + "/");
|
|
672
|
+
const isChildOfPattern = minimatch(
|
|
673
|
+
normalizedPath,
|
|
674
|
+
pattern + "/**",
|
|
675
|
+
{ dot: true }
|
|
676
|
+
);
|
|
677
|
+
return directMatch || isParentDir || isChildOfPattern;
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
if (ig?.ignores(normalizedPath)) {
|
|
681
|
+
return false;
|
|
682
|
+
}
|
|
683
|
+
return true;
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
var packTarball = async (manifest, dir, config) => {
|
|
687
|
+
let packDir = dir;
|
|
688
|
+
const cliPublishDir = config.get("publish-directory");
|
|
689
|
+
const manifestPublishDir = manifest.publishConfig?.directory;
|
|
690
|
+
const publishDirectory = cliPublishDir ?? manifestPublishDir;
|
|
691
|
+
if (publishDirectory) {
|
|
692
|
+
const resolvedPublishDir = cliPublishDir ? publishDirectory : join(dir, publishDirectory);
|
|
693
|
+
assert(
|
|
694
|
+
existsSync(resolvedPublishDir),
|
|
695
|
+
error(
|
|
696
|
+
`Publish directory does not exist: ${resolvedPublishDir}`,
|
|
697
|
+
{
|
|
698
|
+
found: resolvedPublishDir
|
|
699
|
+
}
|
|
700
|
+
)
|
|
701
|
+
);
|
|
702
|
+
assert(
|
|
703
|
+
statSync(resolvedPublishDir).isDirectory(),
|
|
704
|
+
error(
|
|
705
|
+
`Publish directory is not a directory: ${resolvedPublishDir}`,
|
|
706
|
+
{
|
|
707
|
+
found: resolvedPublishDir,
|
|
708
|
+
wanted: "directory"
|
|
709
|
+
}
|
|
710
|
+
)
|
|
711
|
+
);
|
|
712
|
+
if (existsSync(join(resolvedPublishDir, "package.json"))) {
|
|
713
|
+
manifest = config.options.packageJson.read(resolvedPublishDir);
|
|
714
|
+
}
|
|
715
|
+
packDir = resolvedPublishDir;
|
|
716
|
+
}
|
|
717
|
+
assert(
|
|
718
|
+
manifest.name && manifest.version,
|
|
719
|
+
error("Package must have a name and version")
|
|
720
|
+
);
|
|
721
|
+
const processedManifest = replaceWorkspaceAndCatalogSpecs(
|
|
722
|
+
manifest,
|
|
723
|
+
config
|
|
724
|
+
);
|
|
725
|
+
const filename = `${manifest.name.replace("@", "").replace("/", "-")}-${manifest.version}.tgz`;
|
|
726
|
+
const tarballName = `${manifest.name}-${manifest.version}.tgz`;
|
|
727
|
+
try {
|
|
728
|
+
config.options.packageJson.write(packDir, processedManifest);
|
|
729
|
+
const packFilter = buildPackFilter(manifest, packDir);
|
|
730
|
+
const tarballData = await Zn(
|
|
731
|
+
{
|
|
732
|
+
cwd: packDir,
|
|
733
|
+
gzip: true,
|
|
734
|
+
portable: true,
|
|
735
|
+
prefix: "package/",
|
|
736
|
+
filter: packFilter
|
|
737
|
+
},
|
|
738
|
+
["."]
|
|
739
|
+
).concat();
|
|
740
|
+
let unpackedSize = 0;
|
|
741
|
+
const files = [];
|
|
742
|
+
await new Promise((resolve, reject) => {
|
|
743
|
+
const stream = It({
|
|
744
|
+
onentry: (entry) => {
|
|
745
|
+
if (entry.type === "File") {
|
|
746
|
+
unpackedSize += entry.size;
|
|
747
|
+
const cleanPath = entry.path.replace(/^[^/]+\//, "");
|
|
748
|
+
if (cleanPath) {
|
|
749
|
+
files.push(cleanPath);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
stream.on("end", () => resolve()).on("error", reject).write(tarballData);
|
|
755
|
+
stream.end();
|
|
756
|
+
});
|
|
757
|
+
const integrityMap = ssri.fromData(tarballData, {
|
|
758
|
+
algorithms: [.../* @__PURE__ */ new Set(["sha1", "sha512"])]
|
|
759
|
+
});
|
|
760
|
+
const integrity = integrityMap.sha512?.[0]?.toString();
|
|
761
|
+
const shasum = integrityMap.sha1?.[0]?.hexDigest();
|
|
762
|
+
return {
|
|
763
|
+
name: manifest.name,
|
|
764
|
+
version: manifest.version,
|
|
765
|
+
filename,
|
|
766
|
+
tarballName,
|
|
767
|
+
tarballData,
|
|
768
|
+
unpackedSize,
|
|
769
|
+
files,
|
|
770
|
+
integrity,
|
|
771
|
+
shasum,
|
|
772
|
+
resolvedManifest: processedManifest
|
|
773
|
+
};
|
|
774
|
+
} finally {
|
|
775
|
+
config.options.packageJson.write(packDir, manifest);
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
export {
|
|
780
|
+
packTarball
|
|
781
|
+
};
|