claudekit-cli 1.2.1 → 1.3.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/dist/index.js CHANGED
@@ -3004,6 +3004,2542 @@ var require_cli_progress = __commonJS((exports, module) => {
3004
3004
  };
3005
3005
  });
3006
3006
 
3007
+ // node_modules/ms/index.js
3008
+ var require_ms = __commonJS((exports, module) => {
3009
+ var s = 1000;
3010
+ var m2 = s * 60;
3011
+ var h2 = m2 * 60;
3012
+ var d3 = h2 * 24;
3013
+ var w3 = d3 * 7;
3014
+ var y3 = d3 * 365.25;
3015
+ module.exports = function(val, options) {
3016
+ options = options || {};
3017
+ var type = typeof val;
3018
+ if (type === "string" && val.length > 0) {
3019
+ return parse(val);
3020
+ } else if (type === "number" && isFinite(val)) {
3021
+ return options.long ? fmtLong(val) : fmtShort(val);
3022
+ }
3023
+ throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
3024
+ };
3025
+ function parse(str) {
3026
+ str = String(str);
3027
+ if (str.length > 100) {
3028
+ return;
3029
+ }
3030
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
3031
+ if (!match) {
3032
+ return;
3033
+ }
3034
+ var n = parseFloat(match[1]);
3035
+ var type = (match[2] || "ms").toLowerCase();
3036
+ switch (type) {
3037
+ case "years":
3038
+ case "year":
3039
+ case "yrs":
3040
+ case "yr":
3041
+ case "y":
3042
+ return n * y3;
3043
+ case "weeks":
3044
+ case "week":
3045
+ case "w":
3046
+ return n * w3;
3047
+ case "days":
3048
+ case "day":
3049
+ case "d":
3050
+ return n * d3;
3051
+ case "hours":
3052
+ case "hour":
3053
+ case "hrs":
3054
+ case "hr":
3055
+ case "h":
3056
+ return n * h2;
3057
+ case "minutes":
3058
+ case "minute":
3059
+ case "mins":
3060
+ case "min":
3061
+ case "m":
3062
+ return n * m2;
3063
+ case "seconds":
3064
+ case "second":
3065
+ case "secs":
3066
+ case "sec":
3067
+ case "s":
3068
+ return n * s;
3069
+ case "milliseconds":
3070
+ case "millisecond":
3071
+ case "msecs":
3072
+ case "msec":
3073
+ case "ms":
3074
+ return n;
3075
+ default:
3076
+ return;
3077
+ }
3078
+ }
3079
+ function fmtShort(ms) {
3080
+ var msAbs = Math.abs(ms);
3081
+ if (msAbs >= d3) {
3082
+ return Math.round(ms / d3) + "d";
3083
+ }
3084
+ if (msAbs >= h2) {
3085
+ return Math.round(ms / h2) + "h";
3086
+ }
3087
+ if (msAbs >= m2) {
3088
+ return Math.round(ms / m2) + "m";
3089
+ }
3090
+ if (msAbs >= s) {
3091
+ return Math.round(ms / s) + "s";
3092
+ }
3093
+ return ms + "ms";
3094
+ }
3095
+ function fmtLong(ms) {
3096
+ var msAbs = Math.abs(ms);
3097
+ if (msAbs >= d3) {
3098
+ return plural(ms, msAbs, d3, "day");
3099
+ }
3100
+ if (msAbs >= h2) {
3101
+ return plural(ms, msAbs, h2, "hour");
3102
+ }
3103
+ if (msAbs >= m2) {
3104
+ return plural(ms, msAbs, m2, "minute");
3105
+ }
3106
+ if (msAbs >= s) {
3107
+ return plural(ms, msAbs, s, "second");
3108
+ }
3109
+ return ms + " ms";
3110
+ }
3111
+ function plural(ms, msAbs, n, name) {
3112
+ var isPlural = msAbs >= n * 1.5;
3113
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
3114
+ }
3115
+ });
3116
+
3117
+ // node_modules/debug/src/common.js
3118
+ var require_common = __commonJS((exports, module) => {
3119
+ function setup(env) {
3120
+ createDebug.debug = createDebug;
3121
+ createDebug.default = createDebug;
3122
+ createDebug.coerce = coerce2;
3123
+ createDebug.disable = disable;
3124
+ createDebug.enable = enable;
3125
+ createDebug.enabled = enabled;
3126
+ createDebug.humanize = require_ms();
3127
+ createDebug.destroy = destroy;
3128
+ Object.keys(env).forEach((key) => {
3129
+ createDebug[key] = env[key];
3130
+ });
3131
+ createDebug.names = [];
3132
+ createDebug.skips = [];
3133
+ createDebug.formatters = {};
3134
+ function selectColor(namespace) {
3135
+ let hash = 0;
3136
+ for (let i = 0;i < namespace.length; i++) {
3137
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
3138
+ hash |= 0;
3139
+ }
3140
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
3141
+ }
3142
+ createDebug.selectColor = selectColor;
3143
+ function createDebug(namespace) {
3144
+ let prevTime;
3145
+ let enableOverride = null;
3146
+ let namespacesCache;
3147
+ let enabledCache;
3148
+ function debug(...args) {
3149
+ if (!debug.enabled) {
3150
+ return;
3151
+ }
3152
+ const self = debug;
3153
+ const curr = Number(new Date);
3154
+ const ms = curr - (prevTime || curr);
3155
+ self.diff = ms;
3156
+ self.prev = prevTime;
3157
+ self.curr = curr;
3158
+ prevTime = curr;
3159
+ args[0] = createDebug.coerce(args[0]);
3160
+ if (typeof args[0] !== "string") {
3161
+ args.unshift("%O");
3162
+ }
3163
+ let index = 0;
3164
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
3165
+ if (match === "%%") {
3166
+ return "%";
3167
+ }
3168
+ index++;
3169
+ const formatter = createDebug.formatters[format];
3170
+ if (typeof formatter === "function") {
3171
+ const val = args[index];
3172
+ match = formatter.call(self, val);
3173
+ args.splice(index, 1);
3174
+ index--;
3175
+ }
3176
+ return match;
3177
+ });
3178
+ createDebug.formatArgs.call(self, args);
3179
+ const logFn = self.log || createDebug.log;
3180
+ logFn.apply(self, args);
3181
+ }
3182
+ debug.namespace = namespace;
3183
+ debug.useColors = createDebug.useColors();
3184
+ debug.color = createDebug.selectColor(namespace);
3185
+ debug.extend = extend;
3186
+ debug.destroy = createDebug.destroy;
3187
+ Object.defineProperty(debug, "enabled", {
3188
+ enumerable: true,
3189
+ configurable: false,
3190
+ get: () => {
3191
+ if (enableOverride !== null) {
3192
+ return enableOverride;
3193
+ }
3194
+ if (namespacesCache !== createDebug.namespaces) {
3195
+ namespacesCache = createDebug.namespaces;
3196
+ enabledCache = createDebug.enabled(namespace);
3197
+ }
3198
+ return enabledCache;
3199
+ },
3200
+ set: (v2) => {
3201
+ enableOverride = v2;
3202
+ }
3203
+ });
3204
+ if (typeof createDebug.init === "function") {
3205
+ createDebug.init(debug);
3206
+ }
3207
+ return debug;
3208
+ }
3209
+ function extend(namespace, delimiter) {
3210
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
3211
+ newDebug.log = this.log;
3212
+ return newDebug;
3213
+ }
3214
+ function enable(namespaces) {
3215
+ createDebug.save(namespaces);
3216
+ createDebug.namespaces = namespaces;
3217
+ createDebug.names = [];
3218
+ createDebug.skips = [];
3219
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
3220
+ for (const ns of split) {
3221
+ if (ns[0] === "-") {
3222
+ createDebug.skips.push(ns.slice(1));
3223
+ } else {
3224
+ createDebug.names.push(ns);
3225
+ }
3226
+ }
3227
+ }
3228
+ function matchesTemplate(search, template) {
3229
+ let searchIndex = 0;
3230
+ let templateIndex = 0;
3231
+ let starIndex = -1;
3232
+ let matchIndex = 0;
3233
+ while (searchIndex < search.length) {
3234
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
3235
+ if (template[templateIndex] === "*") {
3236
+ starIndex = templateIndex;
3237
+ matchIndex = searchIndex;
3238
+ templateIndex++;
3239
+ } else {
3240
+ searchIndex++;
3241
+ templateIndex++;
3242
+ }
3243
+ } else if (starIndex !== -1) {
3244
+ templateIndex = starIndex + 1;
3245
+ matchIndex++;
3246
+ searchIndex = matchIndex;
3247
+ } else {
3248
+ return false;
3249
+ }
3250
+ }
3251
+ while (templateIndex < template.length && template[templateIndex] === "*") {
3252
+ templateIndex++;
3253
+ }
3254
+ return templateIndex === template.length;
3255
+ }
3256
+ function disable() {
3257
+ const namespaces = [
3258
+ ...createDebug.names,
3259
+ ...createDebug.skips.map((namespace) => "-" + namespace)
3260
+ ].join(",");
3261
+ createDebug.enable("");
3262
+ return namespaces;
3263
+ }
3264
+ function enabled(name) {
3265
+ for (const skip of createDebug.skips) {
3266
+ if (matchesTemplate(name, skip)) {
3267
+ return false;
3268
+ }
3269
+ }
3270
+ for (const ns of createDebug.names) {
3271
+ if (matchesTemplate(name, ns)) {
3272
+ return true;
3273
+ }
3274
+ }
3275
+ return false;
3276
+ }
3277
+ function coerce2(val) {
3278
+ if (val instanceof Error) {
3279
+ return val.stack || val.message;
3280
+ }
3281
+ return val;
3282
+ }
3283
+ function destroy() {
3284
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
3285
+ }
3286
+ createDebug.enable(createDebug.load());
3287
+ return createDebug;
3288
+ }
3289
+ module.exports = setup;
3290
+ });
3291
+
3292
+ // node_modules/debug/src/browser.js
3293
+ var require_browser = __commonJS((exports, module) => {
3294
+ exports.formatArgs = formatArgs;
3295
+ exports.save = save;
3296
+ exports.load = load;
3297
+ exports.useColors = useColors;
3298
+ exports.storage = localstorage();
3299
+ exports.destroy = (() => {
3300
+ let warned = false;
3301
+ return () => {
3302
+ if (!warned) {
3303
+ warned = true;
3304
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
3305
+ }
3306
+ };
3307
+ })();
3308
+ exports.colors = [
3309
+ "#0000CC",
3310
+ "#0000FF",
3311
+ "#0033CC",
3312
+ "#0033FF",
3313
+ "#0066CC",
3314
+ "#0066FF",
3315
+ "#0099CC",
3316
+ "#0099FF",
3317
+ "#00CC00",
3318
+ "#00CC33",
3319
+ "#00CC66",
3320
+ "#00CC99",
3321
+ "#00CCCC",
3322
+ "#00CCFF",
3323
+ "#3300CC",
3324
+ "#3300FF",
3325
+ "#3333CC",
3326
+ "#3333FF",
3327
+ "#3366CC",
3328
+ "#3366FF",
3329
+ "#3399CC",
3330
+ "#3399FF",
3331
+ "#33CC00",
3332
+ "#33CC33",
3333
+ "#33CC66",
3334
+ "#33CC99",
3335
+ "#33CCCC",
3336
+ "#33CCFF",
3337
+ "#6600CC",
3338
+ "#6600FF",
3339
+ "#6633CC",
3340
+ "#6633FF",
3341
+ "#66CC00",
3342
+ "#66CC33",
3343
+ "#9900CC",
3344
+ "#9900FF",
3345
+ "#9933CC",
3346
+ "#9933FF",
3347
+ "#99CC00",
3348
+ "#99CC33",
3349
+ "#CC0000",
3350
+ "#CC0033",
3351
+ "#CC0066",
3352
+ "#CC0099",
3353
+ "#CC00CC",
3354
+ "#CC00FF",
3355
+ "#CC3300",
3356
+ "#CC3333",
3357
+ "#CC3366",
3358
+ "#CC3399",
3359
+ "#CC33CC",
3360
+ "#CC33FF",
3361
+ "#CC6600",
3362
+ "#CC6633",
3363
+ "#CC9900",
3364
+ "#CC9933",
3365
+ "#CCCC00",
3366
+ "#CCCC33",
3367
+ "#FF0000",
3368
+ "#FF0033",
3369
+ "#FF0066",
3370
+ "#FF0099",
3371
+ "#FF00CC",
3372
+ "#FF00FF",
3373
+ "#FF3300",
3374
+ "#FF3333",
3375
+ "#FF3366",
3376
+ "#FF3399",
3377
+ "#FF33CC",
3378
+ "#FF33FF",
3379
+ "#FF6600",
3380
+ "#FF6633",
3381
+ "#FF9900",
3382
+ "#FF9933",
3383
+ "#FFCC00",
3384
+ "#FFCC33"
3385
+ ];
3386
+ function useColors() {
3387
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
3388
+ return true;
3389
+ }
3390
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
3391
+ return false;
3392
+ }
3393
+ let m2;
3394
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m2 = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m2[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
3395
+ }
3396
+ function formatArgs(args) {
3397
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
3398
+ if (!this.useColors) {
3399
+ return;
3400
+ }
3401
+ const c2 = "color: " + this.color;
3402
+ args.splice(1, 0, c2, "color: inherit");
3403
+ let index = 0;
3404
+ let lastC = 0;
3405
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
3406
+ if (match === "%%") {
3407
+ return;
3408
+ }
3409
+ index++;
3410
+ if (match === "%c") {
3411
+ lastC = index;
3412
+ }
3413
+ });
3414
+ args.splice(lastC, 0, c2);
3415
+ }
3416
+ exports.log = console.debug || console.log || (() => {});
3417
+ function save(namespaces) {
3418
+ try {
3419
+ if (namespaces) {
3420
+ exports.storage.setItem("debug", namespaces);
3421
+ } else {
3422
+ exports.storage.removeItem("debug");
3423
+ }
3424
+ } catch (error) {}
3425
+ }
3426
+ function load() {
3427
+ let r2;
3428
+ try {
3429
+ r2 = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
3430
+ } catch (error) {}
3431
+ if (!r2 && typeof process !== "undefined" && "env" in process) {
3432
+ r2 = process.env.DEBUG;
3433
+ }
3434
+ return r2;
3435
+ }
3436
+ function localstorage() {
3437
+ try {
3438
+ return localStorage;
3439
+ } catch (error) {}
3440
+ }
3441
+ module.exports = require_common()(exports);
3442
+ var { formatters } = module.exports;
3443
+ formatters.j = function(v2) {
3444
+ try {
3445
+ return JSON.stringify(v2);
3446
+ } catch (error) {
3447
+ return "[UnexpectedJSONParseError]: " + error.message;
3448
+ }
3449
+ };
3450
+ });
3451
+
3452
+ // node_modules/has-flag/index.js
3453
+ var require_has_flag = __commonJS((exports, module) => {
3454
+ module.exports = (flag, argv = process.argv) => {
3455
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
3456
+ const position = argv.indexOf(prefix + flag);
3457
+ const terminatorPosition = argv.indexOf("--");
3458
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
3459
+ };
3460
+ });
3461
+
3462
+ // node_modules/supports-color/index.js
3463
+ var require_supports_color = __commonJS((exports, module) => {
3464
+ var os = __require("os");
3465
+ var tty = __require("tty");
3466
+ var hasFlag = require_has_flag();
3467
+ var { env } = process;
3468
+ var forceColor;
3469
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
3470
+ forceColor = 0;
3471
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
3472
+ forceColor = 1;
3473
+ }
3474
+ if ("FORCE_COLOR" in env) {
3475
+ if (env.FORCE_COLOR === "true") {
3476
+ forceColor = 1;
3477
+ } else if (env.FORCE_COLOR === "false") {
3478
+ forceColor = 0;
3479
+ } else {
3480
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
3481
+ }
3482
+ }
3483
+ function translateLevel(level) {
3484
+ if (level === 0) {
3485
+ return false;
3486
+ }
3487
+ return {
3488
+ level,
3489
+ hasBasic: true,
3490
+ has256: level >= 2,
3491
+ has16m: level >= 3
3492
+ };
3493
+ }
3494
+ function supportsColor(haveStream, streamIsTTY) {
3495
+ if (forceColor === 0) {
3496
+ return 0;
3497
+ }
3498
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
3499
+ return 3;
3500
+ }
3501
+ if (hasFlag("color=256")) {
3502
+ return 2;
3503
+ }
3504
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
3505
+ return 0;
3506
+ }
3507
+ const min = forceColor || 0;
3508
+ if (env.TERM === "dumb") {
3509
+ return min;
3510
+ }
3511
+ if (process.platform === "win32") {
3512
+ const osRelease = os.release().split(".");
3513
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
3514
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
3515
+ }
3516
+ return 1;
3517
+ }
3518
+ if ("CI" in env) {
3519
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
3520
+ return 1;
3521
+ }
3522
+ return min;
3523
+ }
3524
+ if ("TEAMCITY_VERSION" in env) {
3525
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
3526
+ }
3527
+ if (env.COLORTERM === "truecolor") {
3528
+ return 3;
3529
+ }
3530
+ if ("TERM_PROGRAM" in env) {
3531
+ const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
3532
+ switch (env.TERM_PROGRAM) {
3533
+ case "iTerm.app":
3534
+ return version >= 3 ? 3 : 2;
3535
+ case "Apple_Terminal":
3536
+ return 2;
3537
+ }
3538
+ }
3539
+ if (/-256(color)?$/i.test(env.TERM)) {
3540
+ return 2;
3541
+ }
3542
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
3543
+ return 1;
3544
+ }
3545
+ if ("COLORTERM" in env) {
3546
+ return 1;
3547
+ }
3548
+ return min;
3549
+ }
3550
+ function getSupportLevel(stream) {
3551
+ const level = supportsColor(stream, stream && stream.isTTY);
3552
+ return translateLevel(level);
3553
+ }
3554
+ module.exports = {
3555
+ supportsColor: getSupportLevel,
3556
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
3557
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
3558
+ };
3559
+ });
3560
+
3561
+ // node_modules/debug/src/node.js
3562
+ var require_node = __commonJS((exports, module) => {
3563
+ var tty = __require("tty");
3564
+ var util3 = __require("util");
3565
+ exports.init = init;
3566
+ exports.log = log;
3567
+ exports.formatArgs = formatArgs;
3568
+ exports.save = save;
3569
+ exports.load = load;
3570
+ exports.useColors = useColors;
3571
+ exports.destroy = util3.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
3572
+ exports.colors = [6, 2, 3, 4, 5, 1];
3573
+ try {
3574
+ const supportsColor = require_supports_color();
3575
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
3576
+ exports.colors = [
3577
+ 20,
3578
+ 21,
3579
+ 26,
3580
+ 27,
3581
+ 32,
3582
+ 33,
3583
+ 38,
3584
+ 39,
3585
+ 40,
3586
+ 41,
3587
+ 42,
3588
+ 43,
3589
+ 44,
3590
+ 45,
3591
+ 56,
3592
+ 57,
3593
+ 62,
3594
+ 63,
3595
+ 68,
3596
+ 69,
3597
+ 74,
3598
+ 75,
3599
+ 76,
3600
+ 77,
3601
+ 78,
3602
+ 79,
3603
+ 80,
3604
+ 81,
3605
+ 92,
3606
+ 93,
3607
+ 98,
3608
+ 99,
3609
+ 112,
3610
+ 113,
3611
+ 128,
3612
+ 129,
3613
+ 134,
3614
+ 135,
3615
+ 148,
3616
+ 149,
3617
+ 160,
3618
+ 161,
3619
+ 162,
3620
+ 163,
3621
+ 164,
3622
+ 165,
3623
+ 166,
3624
+ 167,
3625
+ 168,
3626
+ 169,
3627
+ 170,
3628
+ 171,
3629
+ 172,
3630
+ 173,
3631
+ 178,
3632
+ 179,
3633
+ 184,
3634
+ 185,
3635
+ 196,
3636
+ 197,
3637
+ 198,
3638
+ 199,
3639
+ 200,
3640
+ 201,
3641
+ 202,
3642
+ 203,
3643
+ 204,
3644
+ 205,
3645
+ 206,
3646
+ 207,
3647
+ 208,
3648
+ 209,
3649
+ 214,
3650
+ 215,
3651
+ 220,
3652
+ 221
3653
+ ];
3654
+ }
3655
+ } catch (error) {}
3656
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
3657
+ return /^debug_/i.test(key);
3658
+ }).reduce((obj, key) => {
3659
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_3, k2) => {
3660
+ return k2.toUpperCase();
3661
+ });
3662
+ let val = process.env[key];
3663
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
3664
+ val = true;
3665
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
3666
+ val = false;
3667
+ } else if (val === "null") {
3668
+ val = null;
3669
+ } else {
3670
+ val = Number(val);
3671
+ }
3672
+ obj[prop] = val;
3673
+ return obj;
3674
+ }, {});
3675
+ function useColors() {
3676
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
3677
+ }
3678
+ function formatArgs(args) {
3679
+ const { namespace: name, useColors: useColors2 } = this;
3680
+ if (useColors2) {
3681
+ const c2 = this.color;
3682
+ const colorCode = "\x1B[3" + (c2 < 8 ? c2 : "8;5;" + c2);
3683
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
3684
+ args[0] = prefix + args[0].split(`
3685
+ `).join(`
3686
+ ` + prefix);
3687
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
3688
+ } else {
3689
+ args[0] = getDate() + name + " " + args[0];
3690
+ }
3691
+ }
3692
+ function getDate() {
3693
+ if (exports.inspectOpts.hideDate) {
3694
+ return "";
3695
+ }
3696
+ return new Date().toISOString() + " ";
3697
+ }
3698
+ function log(...args) {
3699
+ return process.stderr.write(util3.formatWithOptions(exports.inspectOpts, ...args) + `
3700
+ `);
3701
+ }
3702
+ function save(namespaces) {
3703
+ if (namespaces) {
3704
+ process.env.DEBUG = namespaces;
3705
+ } else {
3706
+ delete process.env.DEBUG;
3707
+ }
3708
+ }
3709
+ function load() {
3710
+ return process.env.DEBUG;
3711
+ }
3712
+ function init(debug) {
3713
+ debug.inspectOpts = {};
3714
+ const keys = Object.keys(exports.inspectOpts);
3715
+ for (let i = 0;i < keys.length; i++) {
3716
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
3717
+ }
3718
+ }
3719
+ module.exports = require_common()(exports);
3720
+ var { formatters } = module.exports;
3721
+ formatters.o = function(v2) {
3722
+ this.inspectOpts.colors = this.useColors;
3723
+ return util3.inspect(v2, this.inspectOpts).split(`
3724
+ `).map((str) => str.trim()).join(" ");
3725
+ };
3726
+ formatters.O = function(v2) {
3727
+ this.inspectOpts.colors = this.useColors;
3728
+ return util3.inspect(v2, this.inspectOpts);
3729
+ };
3730
+ });
3731
+
3732
+ // node_modules/debug/src/index.js
3733
+ var require_src2 = __commonJS((exports, module) => {
3734
+ if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
3735
+ module.exports = require_browser();
3736
+ } else {
3737
+ module.exports = require_node();
3738
+ }
3739
+ });
3740
+
3741
+ // node_modules/wrappy/wrappy.js
3742
+ var require_wrappy = __commonJS((exports, module) => {
3743
+ module.exports = wrappy;
3744
+ function wrappy(fn, cb) {
3745
+ if (fn && cb)
3746
+ return wrappy(fn)(cb);
3747
+ if (typeof fn !== "function")
3748
+ throw new TypeError("need wrapper function");
3749
+ Object.keys(fn).forEach(function(k2) {
3750
+ wrapper[k2] = fn[k2];
3751
+ });
3752
+ return wrapper;
3753
+ function wrapper() {
3754
+ var args = new Array(arguments.length);
3755
+ for (var i = 0;i < args.length; i++) {
3756
+ args[i] = arguments[i];
3757
+ }
3758
+ var ret = fn.apply(this, args);
3759
+ var cb2 = args[args.length - 1];
3760
+ if (typeof ret === "function" && ret !== cb2) {
3761
+ Object.keys(cb2).forEach(function(k2) {
3762
+ ret[k2] = cb2[k2];
3763
+ });
3764
+ }
3765
+ return ret;
3766
+ }
3767
+ }
3768
+ });
3769
+
3770
+ // node_modules/once/once.js
3771
+ var require_once = __commonJS((exports, module) => {
3772
+ var wrappy = require_wrappy();
3773
+ module.exports = wrappy(once);
3774
+ module.exports.strict = wrappy(onceStrict);
3775
+ once.proto = once(function() {
3776
+ Object.defineProperty(Function.prototype, "once", {
3777
+ value: function() {
3778
+ return once(this);
3779
+ },
3780
+ configurable: true
3781
+ });
3782
+ Object.defineProperty(Function.prototype, "onceStrict", {
3783
+ value: function() {
3784
+ return onceStrict(this);
3785
+ },
3786
+ configurable: true
3787
+ });
3788
+ });
3789
+ function once(fn) {
3790
+ var f = function() {
3791
+ if (f.called)
3792
+ return f.value;
3793
+ f.called = true;
3794
+ return f.value = fn.apply(this, arguments);
3795
+ };
3796
+ f.called = false;
3797
+ return f;
3798
+ }
3799
+ function onceStrict(fn) {
3800
+ var f = function() {
3801
+ if (f.called)
3802
+ throw new Error(f.onceError);
3803
+ f.called = true;
3804
+ return f.value = fn.apply(this, arguments);
3805
+ };
3806
+ var name = fn.name || "Function wrapped with `once`";
3807
+ f.onceError = name + " shouldn't be called more than once";
3808
+ f.called = false;
3809
+ return f;
3810
+ }
3811
+ });
3812
+
3813
+ // node_modules/end-of-stream/index.js
3814
+ var require_end_of_stream = __commonJS((exports, module) => {
3815
+ var once = require_once();
3816
+ var noop = function() {};
3817
+ var qnt = global.Bare ? queueMicrotask : process.nextTick.bind(process);
3818
+ var isRequest = function(stream) {
3819
+ return stream.setHeader && typeof stream.abort === "function";
3820
+ };
3821
+ var isChildProcess = function(stream) {
3822
+ return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3;
3823
+ };
3824
+ var eos = function(stream, opts, callback) {
3825
+ if (typeof opts === "function")
3826
+ return eos(stream, null, opts);
3827
+ if (!opts)
3828
+ opts = {};
3829
+ callback = once(callback || noop);
3830
+ var ws = stream._writableState;
3831
+ var rs = stream._readableState;
3832
+ var readable = opts.readable || opts.readable !== false && stream.readable;
3833
+ var writable = opts.writable || opts.writable !== false && stream.writable;
3834
+ var cancelled = false;
3835
+ var onlegacyfinish = function() {
3836
+ if (!stream.writable)
3837
+ onfinish();
3838
+ };
3839
+ var onfinish = function() {
3840
+ writable = false;
3841
+ if (!readable)
3842
+ callback.call(stream);
3843
+ };
3844
+ var onend = function() {
3845
+ readable = false;
3846
+ if (!writable)
3847
+ callback.call(stream);
3848
+ };
3849
+ var onexit = function(exitCode) {
3850
+ callback.call(stream, exitCode ? new Error("exited with error code: " + exitCode) : null);
3851
+ };
3852
+ var onerror = function(err) {
3853
+ callback.call(stream, err);
3854
+ };
3855
+ var onclose = function() {
3856
+ qnt(onclosenexttick);
3857
+ };
3858
+ var onclosenexttick = function() {
3859
+ if (cancelled)
3860
+ return;
3861
+ if (readable && !(rs && (rs.ended && !rs.destroyed)))
3862
+ return callback.call(stream, new Error("premature close"));
3863
+ if (writable && !(ws && (ws.ended && !ws.destroyed)))
3864
+ return callback.call(stream, new Error("premature close"));
3865
+ };
3866
+ var onrequest = function() {
3867
+ stream.req.on("finish", onfinish);
3868
+ };
3869
+ if (isRequest(stream)) {
3870
+ stream.on("complete", onfinish);
3871
+ stream.on("abort", onclose);
3872
+ if (stream.req)
3873
+ onrequest();
3874
+ else
3875
+ stream.on("request", onrequest);
3876
+ } else if (writable && !ws) {
3877
+ stream.on("end", onlegacyfinish);
3878
+ stream.on("close", onlegacyfinish);
3879
+ }
3880
+ if (isChildProcess(stream))
3881
+ stream.on("exit", onexit);
3882
+ stream.on("end", onend);
3883
+ stream.on("finish", onfinish);
3884
+ if (opts.error !== false)
3885
+ stream.on("error", onerror);
3886
+ stream.on("close", onclose);
3887
+ return function() {
3888
+ cancelled = true;
3889
+ stream.removeListener("complete", onfinish);
3890
+ stream.removeListener("abort", onclose);
3891
+ stream.removeListener("request", onrequest);
3892
+ if (stream.req)
3893
+ stream.req.removeListener("finish", onfinish);
3894
+ stream.removeListener("end", onlegacyfinish);
3895
+ stream.removeListener("close", onlegacyfinish);
3896
+ stream.removeListener("finish", onfinish);
3897
+ stream.removeListener("exit", onexit);
3898
+ stream.removeListener("end", onend);
3899
+ stream.removeListener("error", onerror);
3900
+ stream.removeListener("close", onclose);
3901
+ };
3902
+ };
3903
+ module.exports = eos;
3904
+ });
3905
+
3906
+ // node_modules/pump/index.js
3907
+ var require_pump = __commonJS((exports, module) => {
3908
+ var once = require_once();
3909
+ var eos = require_end_of_stream();
3910
+ var fs;
3911
+ try {
3912
+ fs = __require("fs");
3913
+ } catch (e2) {}
3914
+ var noop = function() {};
3915
+ var ancient = typeof process === "undefined" ? false : /^v?\.0/.test(process.version);
3916
+ var isFn = function(fn) {
3917
+ return typeof fn === "function";
3918
+ };
3919
+ var isFS = function(stream) {
3920
+ if (!ancient)
3921
+ return false;
3922
+ if (!fs)
3923
+ return false;
3924
+ return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close);
3925
+ };
3926
+ var isRequest = function(stream) {
3927
+ return stream.setHeader && isFn(stream.abort);
3928
+ };
3929
+ var destroyer = function(stream, reading, writing, callback) {
3930
+ callback = once(callback);
3931
+ var closed = false;
3932
+ stream.on("close", function() {
3933
+ closed = true;
3934
+ });
3935
+ eos(stream, { readable: reading, writable: writing }, function(err) {
3936
+ if (err)
3937
+ return callback(err);
3938
+ closed = true;
3939
+ callback();
3940
+ });
3941
+ var destroyed = false;
3942
+ return function(err) {
3943
+ if (closed)
3944
+ return;
3945
+ if (destroyed)
3946
+ return;
3947
+ destroyed = true;
3948
+ if (isFS(stream))
3949
+ return stream.close(noop);
3950
+ if (isRequest(stream))
3951
+ return stream.abort();
3952
+ if (isFn(stream.destroy))
3953
+ return stream.destroy();
3954
+ callback(err || new Error("stream was destroyed"));
3955
+ };
3956
+ };
3957
+ var call = function(fn) {
3958
+ fn();
3959
+ };
3960
+ var pipe = function(from, to) {
3961
+ return from.pipe(to);
3962
+ };
3963
+ var pump = function() {
3964
+ var streams = Array.prototype.slice.call(arguments);
3965
+ var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop;
3966
+ if (Array.isArray(streams[0]))
3967
+ streams = streams[0];
3968
+ if (streams.length < 2)
3969
+ throw new Error("pump requires two streams per minimum");
3970
+ var error;
3971
+ var destroys = streams.map(function(stream, i) {
3972
+ var reading = i < streams.length - 1;
3973
+ var writing = i > 0;
3974
+ return destroyer(stream, reading, writing, function(err) {
3975
+ if (!error)
3976
+ error = err;
3977
+ if (err)
3978
+ destroys.forEach(call);
3979
+ if (reading)
3980
+ return;
3981
+ destroys.forEach(call);
3982
+ callback(error);
3983
+ });
3984
+ });
3985
+ return streams.reduce(pipe);
3986
+ };
3987
+ module.exports = pump;
3988
+ });
3989
+
3990
+ // node_modules/extract-zip/node_modules/get-stream/buffer-stream.js
3991
+ var require_buffer_stream = __commonJS((exports, module) => {
3992
+ var { PassThrough: PassThroughStream } = __require("stream");
3993
+ module.exports = (options) => {
3994
+ options = { ...options };
3995
+ const { array } = options;
3996
+ let { encoding } = options;
3997
+ const isBuffer = encoding === "buffer";
3998
+ let objectMode = false;
3999
+ if (array) {
4000
+ objectMode = !(encoding || isBuffer);
4001
+ } else {
4002
+ encoding = encoding || "utf8";
4003
+ }
4004
+ if (isBuffer) {
4005
+ encoding = null;
4006
+ }
4007
+ const stream = new PassThroughStream({ objectMode });
4008
+ if (encoding) {
4009
+ stream.setEncoding(encoding);
4010
+ }
4011
+ let length = 0;
4012
+ const chunks = [];
4013
+ stream.on("data", (chunk) => {
4014
+ chunks.push(chunk);
4015
+ if (objectMode) {
4016
+ length = chunks.length;
4017
+ } else {
4018
+ length += chunk.length;
4019
+ }
4020
+ });
4021
+ stream.getBufferedValue = () => {
4022
+ if (array) {
4023
+ return chunks;
4024
+ }
4025
+ return isBuffer ? Buffer.concat(chunks, length) : chunks.join("");
4026
+ };
4027
+ stream.getBufferedLength = () => length;
4028
+ return stream;
4029
+ };
4030
+ });
4031
+
4032
+ // node_modules/extract-zip/node_modules/get-stream/index.js
4033
+ var require_get_stream = __commonJS((exports, module) => {
4034
+ var { constants: BufferConstants } = __require("buffer");
4035
+ var pump = require_pump();
4036
+ var bufferStream = require_buffer_stream();
4037
+
4038
+ class MaxBufferError extends Error {
4039
+ constructor() {
4040
+ super("maxBuffer exceeded");
4041
+ this.name = "MaxBufferError";
4042
+ }
4043
+ }
4044
+ async function getStream(inputStream, options) {
4045
+ if (!inputStream) {
4046
+ return Promise.reject(new Error("Expected a stream"));
4047
+ }
4048
+ options = {
4049
+ maxBuffer: Infinity,
4050
+ ...options
4051
+ };
4052
+ const { maxBuffer } = options;
4053
+ let stream;
4054
+ await new Promise((resolve, reject) => {
4055
+ const rejectPromise = (error) => {
4056
+ if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
4057
+ error.bufferedData = stream.getBufferedValue();
4058
+ }
4059
+ reject(error);
4060
+ };
4061
+ stream = pump(inputStream, bufferStream(options), (error) => {
4062
+ if (error) {
4063
+ rejectPromise(error);
4064
+ return;
4065
+ }
4066
+ resolve();
4067
+ });
4068
+ stream.on("data", () => {
4069
+ if (stream.getBufferedLength() > maxBuffer) {
4070
+ rejectPromise(new MaxBufferError);
4071
+ }
4072
+ });
4073
+ });
4074
+ return stream.getBufferedValue();
4075
+ }
4076
+ module.exports = getStream;
4077
+ module.exports.default = getStream;
4078
+ module.exports.buffer = (stream, options) => getStream(stream, { ...options, encoding: "buffer" });
4079
+ module.exports.array = (stream, options) => getStream(stream, { ...options, array: true });
4080
+ module.exports.MaxBufferError = MaxBufferError;
4081
+ });
4082
+
4083
+ // node_modules/pend/index.js
4084
+ var require_pend = __commonJS((exports, module) => {
4085
+ module.exports = Pend;
4086
+ function Pend() {
4087
+ this.pending = 0;
4088
+ this.max = Infinity;
4089
+ this.listeners = [];
4090
+ this.waiting = [];
4091
+ this.error = null;
4092
+ }
4093
+ Pend.prototype.go = function(fn) {
4094
+ if (this.pending < this.max) {
4095
+ pendGo(this, fn);
4096
+ } else {
4097
+ this.waiting.push(fn);
4098
+ }
4099
+ };
4100
+ Pend.prototype.wait = function(cb) {
4101
+ if (this.pending === 0) {
4102
+ cb(this.error);
4103
+ } else {
4104
+ this.listeners.push(cb);
4105
+ }
4106
+ };
4107
+ Pend.prototype.hold = function() {
4108
+ return pendHold(this);
4109
+ };
4110
+ function pendHold(self) {
4111
+ self.pending += 1;
4112
+ var called = false;
4113
+ return onCb;
4114
+ function onCb(err) {
4115
+ if (called)
4116
+ throw new Error("callback called twice");
4117
+ called = true;
4118
+ self.error = self.error || err;
4119
+ self.pending -= 1;
4120
+ if (self.waiting.length > 0 && self.pending < self.max) {
4121
+ pendGo(self, self.waiting.shift());
4122
+ } else if (self.pending === 0) {
4123
+ var listeners = self.listeners;
4124
+ self.listeners = [];
4125
+ listeners.forEach(cbListener);
4126
+ }
4127
+ }
4128
+ function cbListener(listener) {
4129
+ listener(self.error);
4130
+ }
4131
+ }
4132
+ function pendGo(self, fn) {
4133
+ fn(pendHold(self));
4134
+ }
4135
+ });
4136
+
4137
+ // node_modules/fd-slicer/index.js
4138
+ var require_fd_slicer = __commonJS((exports) => {
4139
+ var fs = __require("fs");
4140
+ var util3 = __require("util");
4141
+ var stream = __require("stream");
4142
+ var Readable = stream.Readable;
4143
+ var Writable = stream.Writable;
4144
+ var PassThrough = stream.PassThrough;
4145
+ var Pend = require_pend();
4146
+ var EventEmitter2 = __require("events").EventEmitter;
4147
+ exports.createFromBuffer = createFromBuffer;
4148
+ exports.createFromFd = createFromFd;
4149
+ exports.BufferSlicer = BufferSlicer;
4150
+ exports.FdSlicer = FdSlicer;
4151
+ util3.inherits(FdSlicer, EventEmitter2);
4152
+ function FdSlicer(fd, options) {
4153
+ options = options || {};
4154
+ EventEmitter2.call(this);
4155
+ this.fd = fd;
4156
+ this.pend = new Pend;
4157
+ this.pend.max = 1;
4158
+ this.refCount = 0;
4159
+ this.autoClose = !!options.autoClose;
4160
+ }
4161
+ FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
4162
+ var self = this;
4163
+ self.pend.go(function(cb) {
4164
+ fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
4165
+ cb();
4166
+ callback(err, bytesRead, buffer2);
4167
+ });
4168
+ });
4169
+ };
4170
+ FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
4171
+ var self = this;
4172
+ self.pend.go(function(cb) {
4173
+ fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer2) {
4174
+ cb();
4175
+ callback(err, written, buffer2);
4176
+ });
4177
+ });
4178
+ };
4179
+ FdSlicer.prototype.createReadStream = function(options) {
4180
+ return new ReadStream(this, options);
4181
+ };
4182
+ FdSlicer.prototype.createWriteStream = function(options) {
4183
+ return new WriteStream(this, options);
4184
+ };
4185
+ FdSlicer.prototype.ref = function() {
4186
+ this.refCount += 1;
4187
+ };
4188
+ FdSlicer.prototype.unref = function() {
4189
+ var self = this;
4190
+ self.refCount -= 1;
4191
+ if (self.refCount > 0)
4192
+ return;
4193
+ if (self.refCount < 0)
4194
+ throw new Error("invalid unref");
4195
+ if (self.autoClose) {
4196
+ fs.close(self.fd, onCloseDone);
4197
+ }
4198
+ function onCloseDone(err) {
4199
+ if (err) {
4200
+ self.emit("error", err);
4201
+ } else {
4202
+ self.emit("close");
4203
+ }
4204
+ }
4205
+ };
4206
+ util3.inherits(ReadStream, Readable);
4207
+ function ReadStream(context, options) {
4208
+ options = options || {};
4209
+ Readable.call(this, options);
4210
+ this.context = context;
4211
+ this.context.ref();
4212
+ this.start = options.start || 0;
4213
+ this.endOffset = options.end;
4214
+ this.pos = this.start;
4215
+ this.destroyed = false;
4216
+ }
4217
+ ReadStream.prototype._read = function(n) {
4218
+ var self = this;
4219
+ if (self.destroyed)
4220
+ return;
4221
+ var toRead = Math.min(self._readableState.highWaterMark, n);
4222
+ if (self.endOffset != null) {
4223
+ toRead = Math.min(toRead, self.endOffset - self.pos);
4224
+ }
4225
+ if (toRead <= 0) {
4226
+ self.destroyed = true;
4227
+ self.push(null);
4228
+ self.context.unref();
4229
+ return;
4230
+ }
4231
+ self.context.pend.go(function(cb) {
4232
+ if (self.destroyed)
4233
+ return cb();
4234
+ var buffer = new Buffer(toRead);
4235
+ fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
4236
+ if (err) {
4237
+ self.destroy(err);
4238
+ } else if (bytesRead === 0) {
4239
+ self.destroyed = true;
4240
+ self.push(null);
4241
+ self.context.unref();
4242
+ } else {
4243
+ self.pos += bytesRead;
4244
+ self.push(buffer.slice(0, bytesRead));
4245
+ }
4246
+ cb();
4247
+ });
4248
+ });
4249
+ };
4250
+ ReadStream.prototype.destroy = function(err) {
4251
+ if (this.destroyed)
4252
+ return;
4253
+ err = err || new Error("stream destroyed");
4254
+ this.destroyed = true;
4255
+ this.emit("error", err);
4256
+ this.context.unref();
4257
+ };
4258
+ util3.inherits(WriteStream, Writable);
4259
+ function WriteStream(context, options) {
4260
+ options = options || {};
4261
+ Writable.call(this, options);
4262
+ this.context = context;
4263
+ this.context.ref();
4264
+ this.start = options.start || 0;
4265
+ this.endOffset = options.end == null ? Infinity : +options.end;
4266
+ this.bytesWritten = 0;
4267
+ this.pos = this.start;
4268
+ this.destroyed = false;
4269
+ this.on("finish", this.destroy.bind(this));
4270
+ }
4271
+ WriteStream.prototype._write = function(buffer, encoding, callback) {
4272
+ var self = this;
4273
+ if (self.destroyed)
4274
+ return;
4275
+ if (self.pos + buffer.length > self.endOffset) {
4276
+ var err = new Error("maximum file length exceeded");
4277
+ err.code = "ETOOBIG";
4278
+ self.destroy();
4279
+ callback(err);
4280
+ return;
4281
+ }
4282
+ self.context.pend.go(function(cb) {
4283
+ if (self.destroyed)
4284
+ return cb();
4285
+ fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err2, bytes) {
4286
+ if (err2) {
4287
+ self.destroy();
4288
+ cb();
4289
+ callback(err2);
4290
+ } else {
4291
+ self.bytesWritten += bytes;
4292
+ self.pos += bytes;
4293
+ self.emit("progress");
4294
+ cb();
4295
+ callback();
4296
+ }
4297
+ });
4298
+ });
4299
+ };
4300
+ WriteStream.prototype.destroy = function() {
4301
+ if (this.destroyed)
4302
+ return;
4303
+ this.destroyed = true;
4304
+ this.context.unref();
4305
+ };
4306
+ util3.inherits(BufferSlicer, EventEmitter2);
4307
+ function BufferSlicer(buffer, options) {
4308
+ EventEmitter2.call(this);
4309
+ options = options || {};
4310
+ this.refCount = 0;
4311
+ this.buffer = buffer;
4312
+ this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
4313
+ }
4314
+ BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
4315
+ var end = position + length;
4316
+ var delta = end - this.buffer.length;
4317
+ var written = delta > 0 ? delta : length;
4318
+ this.buffer.copy(buffer, offset, position, end);
4319
+ setImmediate(function() {
4320
+ callback(null, written);
4321
+ });
4322
+ };
4323
+ BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
4324
+ buffer.copy(this.buffer, position, offset, offset + length);
4325
+ setImmediate(function() {
4326
+ callback(null, length, buffer);
4327
+ });
4328
+ };
4329
+ BufferSlicer.prototype.createReadStream = function(options) {
4330
+ options = options || {};
4331
+ var readStream = new PassThrough(options);
4332
+ readStream.destroyed = false;
4333
+ readStream.start = options.start || 0;
4334
+ readStream.endOffset = options.end;
4335
+ readStream.pos = readStream.endOffset || this.buffer.length;
4336
+ var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
4337
+ var offset = 0;
4338
+ while (true) {
4339
+ var nextOffset = offset + this.maxChunkSize;
4340
+ if (nextOffset >= entireSlice.length) {
4341
+ if (offset < entireSlice.length) {
4342
+ readStream.write(entireSlice.slice(offset, entireSlice.length));
4343
+ }
4344
+ break;
4345
+ }
4346
+ readStream.write(entireSlice.slice(offset, nextOffset));
4347
+ offset = nextOffset;
4348
+ }
4349
+ readStream.end();
4350
+ readStream.destroy = function() {
4351
+ readStream.destroyed = true;
4352
+ };
4353
+ return readStream;
4354
+ };
4355
+ BufferSlicer.prototype.createWriteStream = function(options) {
4356
+ var bufferSlicer = this;
4357
+ options = options || {};
4358
+ var writeStream = new Writable(options);
4359
+ writeStream.start = options.start || 0;
4360
+ writeStream.endOffset = options.end == null ? this.buffer.length : +options.end;
4361
+ writeStream.bytesWritten = 0;
4362
+ writeStream.pos = writeStream.start;
4363
+ writeStream.destroyed = false;
4364
+ writeStream._write = function(buffer, encoding, callback) {
4365
+ if (writeStream.destroyed)
4366
+ return;
4367
+ var end = writeStream.pos + buffer.length;
4368
+ if (end > writeStream.endOffset) {
4369
+ var err = new Error("maximum file length exceeded");
4370
+ err.code = "ETOOBIG";
4371
+ writeStream.destroyed = true;
4372
+ callback(err);
4373
+ return;
4374
+ }
4375
+ buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
4376
+ writeStream.bytesWritten += buffer.length;
4377
+ writeStream.pos = end;
4378
+ writeStream.emit("progress");
4379
+ callback();
4380
+ };
4381
+ writeStream.destroy = function() {
4382
+ writeStream.destroyed = true;
4383
+ };
4384
+ return writeStream;
4385
+ };
4386
+ BufferSlicer.prototype.ref = function() {
4387
+ this.refCount += 1;
4388
+ };
4389
+ BufferSlicer.prototype.unref = function() {
4390
+ this.refCount -= 1;
4391
+ if (this.refCount < 0) {
4392
+ throw new Error("invalid unref");
4393
+ }
4394
+ };
4395
+ function createFromBuffer(buffer, options) {
4396
+ return new BufferSlicer(buffer, options);
4397
+ }
4398
+ function createFromFd(fd, options) {
4399
+ return new FdSlicer(fd, options);
4400
+ }
4401
+ });
4402
+
4403
+ // node_modules/buffer-crc32/index.js
4404
+ var require_buffer_crc32 = __commonJS((exports, module) => {
4405
+ var Buffer2 = __require("buffer").Buffer;
4406
+ var CRC_TABLE = [
4407
+ 0,
4408
+ 1996959894,
4409
+ 3993919788,
4410
+ 2567524794,
4411
+ 124634137,
4412
+ 1886057615,
4413
+ 3915621685,
4414
+ 2657392035,
4415
+ 249268274,
4416
+ 2044508324,
4417
+ 3772115230,
4418
+ 2547177864,
4419
+ 162941995,
4420
+ 2125561021,
4421
+ 3887607047,
4422
+ 2428444049,
4423
+ 498536548,
4424
+ 1789927666,
4425
+ 4089016648,
4426
+ 2227061214,
4427
+ 450548861,
4428
+ 1843258603,
4429
+ 4107580753,
4430
+ 2211677639,
4431
+ 325883990,
4432
+ 1684777152,
4433
+ 4251122042,
4434
+ 2321926636,
4435
+ 335633487,
4436
+ 1661365465,
4437
+ 4195302755,
4438
+ 2366115317,
4439
+ 997073096,
4440
+ 1281953886,
4441
+ 3579855332,
4442
+ 2724688242,
4443
+ 1006888145,
4444
+ 1258607687,
4445
+ 3524101629,
4446
+ 2768942443,
4447
+ 901097722,
4448
+ 1119000684,
4449
+ 3686517206,
4450
+ 2898065728,
4451
+ 853044451,
4452
+ 1172266101,
4453
+ 3705015759,
4454
+ 2882616665,
4455
+ 651767980,
4456
+ 1373503546,
4457
+ 3369554304,
4458
+ 3218104598,
4459
+ 565507253,
4460
+ 1454621731,
4461
+ 3485111705,
4462
+ 3099436303,
4463
+ 671266974,
4464
+ 1594198024,
4465
+ 3322730930,
4466
+ 2970347812,
4467
+ 795835527,
4468
+ 1483230225,
4469
+ 3244367275,
4470
+ 3060149565,
4471
+ 1994146192,
4472
+ 31158534,
4473
+ 2563907772,
4474
+ 4023717930,
4475
+ 1907459465,
4476
+ 112637215,
4477
+ 2680153253,
4478
+ 3904427059,
4479
+ 2013776290,
4480
+ 251722036,
4481
+ 2517215374,
4482
+ 3775830040,
4483
+ 2137656763,
4484
+ 141376813,
4485
+ 2439277719,
4486
+ 3865271297,
4487
+ 1802195444,
4488
+ 476864866,
4489
+ 2238001368,
4490
+ 4066508878,
4491
+ 1812370925,
4492
+ 453092731,
4493
+ 2181625025,
4494
+ 4111451223,
4495
+ 1706088902,
4496
+ 314042704,
4497
+ 2344532202,
4498
+ 4240017532,
4499
+ 1658658271,
4500
+ 366619977,
4501
+ 2362670323,
4502
+ 4224994405,
4503
+ 1303535960,
4504
+ 984961486,
4505
+ 2747007092,
4506
+ 3569037538,
4507
+ 1256170817,
4508
+ 1037604311,
4509
+ 2765210733,
4510
+ 3554079995,
4511
+ 1131014506,
4512
+ 879679996,
4513
+ 2909243462,
4514
+ 3663771856,
4515
+ 1141124467,
4516
+ 855842277,
4517
+ 2852801631,
4518
+ 3708648649,
4519
+ 1342533948,
4520
+ 654459306,
4521
+ 3188396048,
4522
+ 3373015174,
4523
+ 1466479909,
4524
+ 544179635,
4525
+ 3110523913,
4526
+ 3462522015,
4527
+ 1591671054,
4528
+ 702138776,
4529
+ 2966460450,
4530
+ 3352799412,
4531
+ 1504918807,
4532
+ 783551873,
4533
+ 3082640443,
4534
+ 3233442989,
4535
+ 3988292384,
4536
+ 2596254646,
4537
+ 62317068,
4538
+ 1957810842,
4539
+ 3939845945,
4540
+ 2647816111,
4541
+ 81470997,
4542
+ 1943803523,
4543
+ 3814918930,
4544
+ 2489596804,
4545
+ 225274430,
4546
+ 2053790376,
4547
+ 3826175755,
4548
+ 2466906013,
4549
+ 167816743,
4550
+ 2097651377,
4551
+ 4027552580,
4552
+ 2265490386,
4553
+ 503444072,
4554
+ 1762050814,
4555
+ 4150417245,
4556
+ 2154129355,
4557
+ 426522225,
4558
+ 1852507879,
4559
+ 4275313526,
4560
+ 2312317920,
4561
+ 282753626,
4562
+ 1742555852,
4563
+ 4189708143,
4564
+ 2394877945,
4565
+ 397917763,
4566
+ 1622183637,
4567
+ 3604390888,
4568
+ 2714866558,
4569
+ 953729732,
4570
+ 1340076626,
4571
+ 3518719985,
4572
+ 2797360999,
4573
+ 1068828381,
4574
+ 1219638859,
4575
+ 3624741850,
4576
+ 2936675148,
4577
+ 906185462,
4578
+ 1090812512,
4579
+ 3747672003,
4580
+ 2825379669,
4581
+ 829329135,
4582
+ 1181335161,
4583
+ 3412177804,
4584
+ 3160834842,
4585
+ 628085408,
4586
+ 1382605366,
4587
+ 3423369109,
4588
+ 3138078467,
4589
+ 570562233,
4590
+ 1426400815,
4591
+ 3317316542,
4592
+ 2998733608,
4593
+ 733239954,
4594
+ 1555261956,
4595
+ 3268935591,
4596
+ 3050360625,
4597
+ 752459403,
4598
+ 1541320221,
4599
+ 2607071920,
4600
+ 3965973030,
4601
+ 1969922972,
4602
+ 40735498,
4603
+ 2617837225,
4604
+ 3943577151,
4605
+ 1913087877,
4606
+ 83908371,
4607
+ 2512341634,
4608
+ 3803740692,
4609
+ 2075208622,
4610
+ 213261112,
4611
+ 2463272603,
4612
+ 3855990285,
4613
+ 2094854071,
4614
+ 198958881,
4615
+ 2262029012,
4616
+ 4057260610,
4617
+ 1759359992,
4618
+ 534414190,
4619
+ 2176718541,
4620
+ 4139329115,
4621
+ 1873836001,
4622
+ 414664567,
4623
+ 2282248934,
4624
+ 4279200368,
4625
+ 1711684554,
4626
+ 285281116,
4627
+ 2405801727,
4628
+ 4167216745,
4629
+ 1634467795,
4630
+ 376229701,
4631
+ 2685067896,
4632
+ 3608007406,
4633
+ 1308918612,
4634
+ 956543938,
4635
+ 2808555105,
4636
+ 3495958263,
4637
+ 1231636301,
4638
+ 1047427035,
4639
+ 2932959818,
4640
+ 3654703836,
4641
+ 1088359270,
4642
+ 936918000,
4643
+ 2847714899,
4644
+ 3736837829,
4645
+ 1202900863,
4646
+ 817233897,
4647
+ 3183342108,
4648
+ 3401237130,
4649
+ 1404277552,
4650
+ 615818150,
4651
+ 3134207493,
4652
+ 3453421203,
4653
+ 1423857449,
4654
+ 601450431,
4655
+ 3009837614,
4656
+ 3294710456,
4657
+ 1567103746,
4658
+ 711928724,
4659
+ 3020668471,
4660
+ 3272380065,
4661
+ 1510334235,
4662
+ 755167117
4663
+ ];
4664
+ if (typeof Int32Array !== "undefined") {
4665
+ CRC_TABLE = new Int32Array(CRC_TABLE);
4666
+ }
4667
+ function ensureBuffer(input) {
4668
+ if (Buffer2.isBuffer(input)) {
4669
+ return input;
4670
+ }
4671
+ var hasNewBufferAPI = typeof Buffer2.alloc === "function" && typeof Buffer2.from === "function";
4672
+ if (typeof input === "number") {
4673
+ return hasNewBufferAPI ? Buffer2.alloc(input) : new Buffer2(input);
4674
+ } else if (typeof input === "string") {
4675
+ return hasNewBufferAPI ? Buffer2.from(input) : new Buffer2(input);
4676
+ } else {
4677
+ throw new Error("input must be buffer, number, or string, received " + typeof input);
4678
+ }
4679
+ }
4680
+ function bufferizeInt(num) {
4681
+ var tmp = ensureBuffer(4);
4682
+ tmp.writeInt32BE(num, 0);
4683
+ return tmp;
4684
+ }
4685
+ function _crc32(buf, previous) {
4686
+ buf = ensureBuffer(buf);
4687
+ if (Buffer2.isBuffer(previous)) {
4688
+ previous = previous.readUInt32BE(0);
4689
+ }
4690
+ var crc = ~~previous ^ -1;
4691
+ for (var n = 0;n < buf.length; n++) {
4692
+ crc = CRC_TABLE[(crc ^ buf[n]) & 255] ^ crc >>> 8;
4693
+ }
4694
+ return crc ^ -1;
4695
+ }
4696
+ function crc32() {
4697
+ return bufferizeInt(_crc32.apply(null, arguments));
4698
+ }
4699
+ crc32.signed = function() {
4700
+ return _crc32.apply(null, arguments);
4701
+ };
4702
+ crc32.unsigned = function() {
4703
+ return _crc32.apply(null, arguments) >>> 0;
4704
+ };
4705
+ module.exports = crc32;
4706
+ });
4707
+
4708
+ // node_modules/yauzl/index.js
4709
+ var require_yauzl = __commonJS((exports) => {
4710
+ var fs = __require("fs");
4711
+ var zlib = __require("zlib");
4712
+ var fd_slicer = require_fd_slicer();
4713
+ var crc32 = require_buffer_crc32();
4714
+ var util3 = __require("util");
4715
+ var EventEmitter2 = __require("events").EventEmitter;
4716
+ var Transform = __require("stream").Transform;
4717
+ var PassThrough = __require("stream").PassThrough;
4718
+ var Writable = __require("stream").Writable;
4719
+ exports.open = open;
4720
+ exports.fromFd = fromFd;
4721
+ exports.fromBuffer = fromBuffer;
4722
+ exports.fromRandomAccessReader = fromRandomAccessReader;
4723
+ exports.dosDateTimeToDate = dosDateTimeToDate;
4724
+ exports.validateFileName = validateFileName;
4725
+ exports.ZipFile = ZipFile;
4726
+ exports.Entry = Entry;
4727
+ exports.RandomAccessReader = RandomAccessReader;
4728
+ function open(path, options, callback) {
4729
+ if (typeof options === "function") {
4730
+ callback = options;
4731
+ options = null;
4732
+ }
4733
+ if (options == null)
4734
+ options = {};
4735
+ if (options.autoClose == null)
4736
+ options.autoClose = true;
4737
+ if (options.lazyEntries == null)
4738
+ options.lazyEntries = false;
4739
+ if (options.decodeStrings == null)
4740
+ options.decodeStrings = true;
4741
+ if (options.validateEntrySizes == null)
4742
+ options.validateEntrySizes = true;
4743
+ if (options.strictFileNames == null)
4744
+ options.strictFileNames = false;
4745
+ if (callback == null)
4746
+ callback = defaultCallback;
4747
+ fs.open(path, "r", function(err, fd) {
4748
+ if (err)
4749
+ return callback(err);
4750
+ fromFd(fd, options, function(err2, zipfile) {
4751
+ if (err2)
4752
+ fs.close(fd, defaultCallback);
4753
+ callback(err2, zipfile);
4754
+ });
4755
+ });
4756
+ }
4757
+ function fromFd(fd, options, callback) {
4758
+ if (typeof options === "function") {
4759
+ callback = options;
4760
+ options = null;
4761
+ }
4762
+ if (options == null)
4763
+ options = {};
4764
+ if (options.autoClose == null)
4765
+ options.autoClose = false;
4766
+ if (options.lazyEntries == null)
4767
+ options.lazyEntries = false;
4768
+ if (options.decodeStrings == null)
4769
+ options.decodeStrings = true;
4770
+ if (options.validateEntrySizes == null)
4771
+ options.validateEntrySizes = true;
4772
+ if (options.strictFileNames == null)
4773
+ options.strictFileNames = false;
4774
+ if (callback == null)
4775
+ callback = defaultCallback;
4776
+ fs.fstat(fd, function(err, stats) {
4777
+ if (err)
4778
+ return callback(err);
4779
+ var reader = fd_slicer.createFromFd(fd, { autoClose: true });
4780
+ fromRandomAccessReader(reader, stats.size, options, callback);
4781
+ });
4782
+ }
4783
+ function fromBuffer(buffer, options, callback) {
4784
+ if (typeof options === "function") {
4785
+ callback = options;
4786
+ options = null;
4787
+ }
4788
+ if (options == null)
4789
+ options = {};
4790
+ options.autoClose = false;
4791
+ if (options.lazyEntries == null)
4792
+ options.lazyEntries = false;
4793
+ if (options.decodeStrings == null)
4794
+ options.decodeStrings = true;
4795
+ if (options.validateEntrySizes == null)
4796
+ options.validateEntrySizes = true;
4797
+ if (options.strictFileNames == null)
4798
+ options.strictFileNames = false;
4799
+ var reader = fd_slicer.createFromBuffer(buffer, { maxChunkSize: 65536 });
4800
+ fromRandomAccessReader(reader, buffer.length, options, callback);
4801
+ }
4802
+ function fromRandomAccessReader(reader, totalSize, options, callback) {
4803
+ if (typeof options === "function") {
4804
+ callback = options;
4805
+ options = null;
4806
+ }
4807
+ if (options == null)
4808
+ options = {};
4809
+ if (options.autoClose == null)
4810
+ options.autoClose = true;
4811
+ if (options.lazyEntries == null)
4812
+ options.lazyEntries = false;
4813
+ if (options.decodeStrings == null)
4814
+ options.decodeStrings = true;
4815
+ var decodeStrings = !!options.decodeStrings;
4816
+ if (options.validateEntrySizes == null)
4817
+ options.validateEntrySizes = true;
4818
+ if (options.strictFileNames == null)
4819
+ options.strictFileNames = false;
4820
+ if (callback == null)
4821
+ callback = defaultCallback;
4822
+ if (typeof totalSize !== "number")
4823
+ throw new Error("expected totalSize parameter to be a number");
4824
+ if (totalSize > Number.MAX_SAFE_INTEGER) {
4825
+ throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
4826
+ }
4827
+ reader.ref();
4828
+ var eocdrWithoutCommentSize = 22;
4829
+ var maxCommentSize = 65535;
4830
+ var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
4831
+ var buffer = newBuffer(bufferSize);
4832
+ var bufferReadStart = totalSize - buffer.length;
4833
+ readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
4834
+ if (err)
4835
+ return callback(err);
4836
+ for (var i = bufferSize - eocdrWithoutCommentSize;i >= 0; i -= 1) {
4837
+ if (buffer.readUInt32LE(i) !== 101010256)
4838
+ continue;
4839
+ var eocdrBuffer = buffer.slice(i);
4840
+ var diskNumber = eocdrBuffer.readUInt16LE(4);
4841
+ if (diskNumber !== 0) {
4842
+ return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
4843
+ }
4844
+ var entryCount = eocdrBuffer.readUInt16LE(10);
4845
+ var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
4846
+ var commentLength = eocdrBuffer.readUInt16LE(20);
4847
+ var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
4848
+ if (commentLength !== expectedCommentLength) {
4849
+ return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
4850
+ }
4851
+ var comment = decodeStrings ? decodeBuffer(eocdrBuffer, 22, eocdrBuffer.length, false) : eocdrBuffer.slice(22);
4852
+ if (!(entryCount === 65535 || centralDirectoryOffset === 4294967295)) {
4853
+ return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
4854
+ }
4855
+ var zip64EocdlBuffer = newBuffer(20);
4856
+ var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
4857
+ readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err2) {
4858
+ if (err2)
4859
+ return callback(err2);
4860
+ if (zip64EocdlBuffer.readUInt32LE(0) !== 117853008) {
4861
+ return callback(new Error("invalid zip64 end of central directory locator signature"));
4862
+ }
4863
+ var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
4864
+ var zip64EocdrBuffer = newBuffer(56);
4865
+ readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err3) {
4866
+ if (err3)
4867
+ return callback(err3);
4868
+ if (zip64EocdrBuffer.readUInt32LE(0) !== 101075792) {
4869
+ return callback(new Error("invalid zip64 end of central directory record signature"));
4870
+ }
4871
+ entryCount = readUInt64LE(zip64EocdrBuffer, 32);
4872
+ centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
4873
+ return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
4874
+ });
4875
+ });
4876
+ return;
4877
+ }
4878
+ callback(new Error("end of central directory record signature not found"));
4879
+ });
4880
+ }
4881
+ util3.inherits(ZipFile, EventEmitter2);
4882
+ function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
4883
+ var self = this;
4884
+ EventEmitter2.call(self);
4885
+ self.reader = reader;
4886
+ self.reader.on("error", function(err) {
4887
+ emitError(self, err);
4888
+ });
4889
+ self.reader.once("close", function() {
4890
+ self.emit("close");
4891
+ });
4892
+ self.readEntryCursor = centralDirectoryOffset;
4893
+ self.fileSize = fileSize;
4894
+ self.entryCount = entryCount;
4895
+ self.comment = comment;
4896
+ self.entriesRead = 0;
4897
+ self.autoClose = !!autoClose;
4898
+ self.lazyEntries = !!lazyEntries;
4899
+ self.decodeStrings = !!decodeStrings;
4900
+ self.validateEntrySizes = !!validateEntrySizes;
4901
+ self.strictFileNames = !!strictFileNames;
4902
+ self.isOpen = true;
4903
+ self.emittedError = false;
4904
+ if (!self.lazyEntries)
4905
+ self._readEntry();
4906
+ }
4907
+ ZipFile.prototype.close = function() {
4908
+ if (!this.isOpen)
4909
+ return;
4910
+ this.isOpen = false;
4911
+ this.reader.unref();
4912
+ };
4913
+ function emitErrorAndAutoClose(self, err) {
4914
+ if (self.autoClose)
4915
+ self.close();
4916
+ emitError(self, err);
4917
+ }
4918
+ function emitError(self, err) {
4919
+ if (self.emittedError)
4920
+ return;
4921
+ self.emittedError = true;
4922
+ self.emit("error", err);
4923
+ }
4924
+ ZipFile.prototype.readEntry = function() {
4925
+ if (!this.lazyEntries)
4926
+ throw new Error("readEntry() called without lazyEntries:true");
4927
+ this._readEntry();
4928
+ };
4929
+ ZipFile.prototype._readEntry = function() {
4930
+ var self = this;
4931
+ if (self.entryCount === self.entriesRead) {
4932
+ setImmediate(function() {
4933
+ if (self.autoClose)
4934
+ self.close();
4935
+ if (self.emittedError)
4936
+ return;
4937
+ self.emit("end");
4938
+ });
4939
+ return;
4940
+ }
4941
+ if (self.emittedError)
4942
+ return;
4943
+ var buffer = newBuffer(46);
4944
+ readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
4945
+ if (err)
4946
+ return emitErrorAndAutoClose(self, err);
4947
+ if (self.emittedError)
4948
+ return;
4949
+ var entry = new Entry;
4950
+ var signature = buffer.readUInt32LE(0);
4951
+ if (signature !== 33639248)
4952
+ return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
4953
+ entry.versionMadeBy = buffer.readUInt16LE(4);
4954
+ entry.versionNeededToExtract = buffer.readUInt16LE(6);
4955
+ entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
4956
+ entry.compressionMethod = buffer.readUInt16LE(10);
4957
+ entry.lastModFileTime = buffer.readUInt16LE(12);
4958
+ entry.lastModFileDate = buffer.readUInt16LE(14);
4959
+ entry.crc32 = buffer.readUInt32LE(16);
4960
+ entry.compressedSize = buffer.readUInt32LE(20);
4961
+ entry.uncompressedSize = buffer.readUInt32LE(24);
4962
+ entry.fileNameLength = buffer.readUInt16LE(28);
4963
+ entry.extraFieldLength = buffer.readUInt16LE(30);
4964
+ entry.fileCommentLength = buffer.readUInt16LE(32);
4965
+ entry.internalFileAttributes = buffer.readUInt16LE(36);
4966
+ entry.externalFileAttributes = buffer.readUInt32LE(38);
4967
+ entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
4968
+ if (entry.generalPurposeBitFlag & 64)
4969
+ return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));
4970
+ self.readEntryCursor += 46;
4971
+ buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
4972
+ readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err2) {
4973
+ if (err2)
4974
+ return emitErrorAndAutoClose(self, err2);
4975
+ if (self.emittedError)
4976
+ return;
4977
+ var isUtf8 = (entry.generalPurposeBitFlag & 2048) !== 0;
4978
+ entry.fileName = self.decodeStrings ? decodeBuffer(buffer, 0, entry.fileNameLength, isUtf8) : buffer.slice(0, entry.fileNameLength);
4979
+ var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
4980
+ var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
4981
+ entry.extraFields = [];
4982
+ var i = 0;
4983
+ while (i < extraFieldBuffer.length - 3) {
4984
+ var headerId = extraFieldBuffer.readUInt16LE(i + 0);
4985
+ var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
4986
+ var dataStart = i + 4;
4987
+ var dataEnd = dataStart + dataSize;
4988
+ if (dataEnd > extraFieldBuffer.length)
4989
+ return emitErrorAndAutoClose(self, new Error("extra field length exceeds extra field buffer size"));
4990
+ var dataBuffer = newBuffer(dataSize);
4991
+ extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
4992
+ entry.extraFields.push({
4993
+ id: headerId,
4994
+ data: dataBuffer
4995
+ });
4996
+ i = dataEnd;
4997
+ }
4998
+ entry.fileComment = self.decodeStrings ? decodeBuffer(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8) : buffer.slice(fileCommentStart, fileCommentStart + entry.fileCommentLength);
4999
+ entry.comment = entry.fileComment;
5000
+ self.readEntryCursor += buffer.length;
5001
+ self.entriesRead += 1;
5002
+ if (entry.uncompressedSize === 4294967295 || entry.compressedSize === 4294967295 || entry.relativeOffsetOfLocalHeader === 4294967295) {
5003
+ var zip64EiefBuffer = null;
5004
+ for (var i = 0;i < entry.extraFields.length; i++) {
5005
+ var extraField = entry.extraFields[i];
5006
+ if (extraField.id === 1) {
5007
+ zip64EiefBuffer = extraField.data;
5008
+ break;
5009
+ }
5010
+ }
5011
+ if (zip64EiefBuffer == null) {
5012
+ return emitErrorAndAutoClose(self, new Error("expected zip64 extended information extra field"));
5013
+ }
5014
+ var index = 0;
5015
+ if (entry.uncompressedSize === 4294967295) {
5016
+ if (index + 8 > zip64EiefBuffer.length) {
5017
+ return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
5018
+ }
5019
+ entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
5020
+ index += 8;
5021
+ }
5022
+ if (entry.compressedSize === 4294967295) {
5023
+ if (index + 8 > zip64EiefBuffer.length) {
5024
+ return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
5025
+ }
5026
+ entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
5027
+ index += 8;
5028
+ }
5029
+ if (entry.relativeOffsetOfLocalHeader === 4294967295) {
5030
+ if (index + 8 > zip64EiefBuffer.length) {
5031
+ return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
5032
+ }
5033
+ entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
5034
+ index += 8;
5035
+ }
5036
+ }
5037
+ if (self.decodeStrings) {
5038
+ for (var i = 0;i < entry.extraFields.length; i++) {
5039
+ var extraField = entry.extraFields[i];
5040
+ if (extraField.id === 28789) {
5041
+ if (extraField.data.length < 6) {
5042
+ continue;
5043
+ }
5044
+ if (extraField.data.readUInt8(0) !== 1) {
5045
+ continue;
5046
+ }
5047
+ var oldNameCrc32 = extraField.data.readUInt32LE(1);
5048
+ if (crc32.unsigned(buffer.slice(0, entry.fileNameLength)) !== oldNameCrc32) {
5049
+ continue;
5050
+ }
5051
+ entry.fileName = decodeBuffer(extraField.data, 5, extraField.data.length, true);
5052
+ break;
5053
+ }
5054
+ }
5055
+ }
5056
+ if (self.validateEntrySizes && entry.compressionMethod === 0) {
5057
+ var expectedCompressedSize = entry.uncompressedSize;
5058
+ if (entry.isEncrypted()) {
5059
+ expectedCompressedSize += 12;
5060
+ }
5061
+ if (entry.compressedSize !== expectedCompressedSize) {
5062
+ var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
5063
+ return emitErrorAndAutoClose(self, new Error(msg));
5064
+ }
5065
+ }
5066
+ if (self.decodeStrings) {
5067
+ if (!self.strictFileNames) {
5068
+ entry.fileName = entry.fileName.replace(/\\/g, "/");
5069
+ }
5070
+ var errorMessage = validateFileName(entry.fileName, self.validateFileNameOptions);
5071
+ if (errorMessage != null)
5072
+ return emitErrorAndAutoClose(self, new Error(errorMessage));
5073
+ }
5074
+ self.emit("entry", entry);
5075
+ if (!self.lazyEntries)
5076
+ self._readEntry();
5077
+ });
5078
+ });
5079
+ };
5080
+ ZipFile.prototype.openReadStream = function(entry, options, callback) {
5081
+ var self = this;
5082
+ var relativeStart = 0;
5083
+ var relativeEnd = entry.compressedSize;
5084
+ if (callback == null) {
5085
+ callback = options;
5086
+ options = {};
5087
+ } else {
5088
+ if (options.decrypt != null) {
5089
+ if (!entry.isEncrypted()) {
5090
+ throw new Error("options.decrypt can only be specified for encrypted entries");
5091
+ }
5092
+ if (options.decrypt !== false)
5093
+ throw new Error("invalid options.decrypt value: " + options.decrypt);
5094
+ if (entry.isCompressed()) {
5095
+ if (options.decompress !== false)
5096
+ throw new Error("entry is encrypted and compressed, and options.decompress !== false");
5097
+ }
5098
+ }
5099
+ if (options.decompress != null) {
5100
+ if (!entry.isCompressed()) {
5101
+ throw new Error("options.decompress can only be specified for compressed entries");
5102
+ }
5103
+ if (!(options.decompress === false || options.decompress === true)) {
5104
+ throw new Error("invalid options.decompress value: " + options.decompress);
5105
+ }
5106
+ }
5107
+ if (options.start != null || options.end != null) {
5108
+ if (entry.isCompressed() && options.decompress !== false) {
5109
+ throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
5110
+ }
5111
+ if (entry.isEncrypted() && options.decrypt !== false) {
5112
+ throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
5113
+ }
5114
+ }
5115
+ if (options.start != null) {
5116
+ relativeStart = options.start;
5117
+ if (relativeStart < 0)
5118
+ throw new Error("options.start < 0");
5119
+ if (relativeStart > entry.compressedSize)
5120
+ throw new Error("options.start > entry.compressedSize");
5121
+ }
5122
+ if (options.end != null) {
5123
+ relativeEnd = options.end;
5124
+ if (relativeEnd < 0)
5125
+ throw new Error("options.end < 0");
5126
+ if (relativeEnd > entry.compressedSize)
5127
+ throw new Error("options.end > entry.compressedSize");
5128
+ if (relativeEnd < relativeStart)
5129
+ throw new Error("options.end < options.start");
5130
+ }
5131
+ }
5132
+ if (!self.isOpen)
5133
+ return callback(new Error("closed"));
5134
+ if (entry.isEncrypted()) {
5135
+ if (options.decrypt !== false)
5136
+ return callback(new Error("entry is encrypted, and options.decrypt !== false"));
5137
+ }
5138
+ self.reader.ref();
5139
+ var buffer = newBuffer(30);
5140
+ readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
5141
+ try {
5142
+ if (err)
5143
+ return callback(err);
5144
+ var signature = buffer.readUInt32LE(0);
5145
+ if (signature !== 67324752) {
5146
+ return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
5147
+ }
5148
+ var fileNameLength = buffer.readUInt16LE(26);
5149
+ var extraFieldLength = buffer.readUInt16LE(28);
5150
+ var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
5151
+ var decompress;
5152
+ if (entry.compressionMethod === 0) {
5153
+ decompress = false;
5154
+ } else if (entry.compressionMethod === 8) {
5155
+ decompress = options.decompress != null ? options.decompress : true;
5156
+ } else {
5157
+ return callback(new Error("unsupported compression method: " + entry.compressionMethod));
5158
+ }
5159
+ var fileDataStart = localFileHeaderEnd;
5160
+ var fileDataEnd = fileDataStart + entry.compressedSize;
5161
+ if (entry.compressedSize !== 0) {
5162
+ if (fileDataEnd > self.fileSize) {
5163
+ return callback(new Error("file data overflows file bounds: " + fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
5164
+ }
5165
+ }
5166
+ var readStream = self.reader.createReadStream({
5167
+ start: fileDataStart + relativeStart,
5168
+ end: fileDataStart + relativeEnd
5169
+ });
5170
+ var endpointStream = readStream;
5171
+ if (decompress) {
5172
+ var destroyed = false;
5173
+ var inflateFilter = zlib.createInflateRaw();
5174
+ readStream.on("error", function(err2) {
5175
+ setImmediate(function() {
5176
+ if (!destroyed)
5177
+ inflateFilter.emit("error", err2);
5178
+ });
5179
+ });
5180
+ readStream.pipe(inflateFilter);
5181
+ if (self.validateEntrySizes) {
5182
+ endpointStream = new AssertByteCountStream(entry.uncompressedSize);
5183
+ inflateFilter.on("error", function(err2) {
5184
+ setImmediate(function() {
5185
+ if (!destroyed)
5186
+ endpointStream.emit("error", err2);
5187
+ });
5188
+ });
5189
+ inflateFilter.pipe(endpointStream);
5190
+ } else {
5191
+ endpointStream = inflateFilter;
5192
+ }
5193
+ endpointStream.destroy = function() {
5194
+ destroyed = true;
5195
+ if (inflateFilter !== endpointStream)
5196
+ inflateFilter.unpipe(endpointStream);
5197
+ readStream.unpipe(inflateFilter);
5198
+ readStream.destroy();
5199
+ };
5200
+ }
5201
+ callback(null, endpointStream);
5202
+ } finally {
5203
+ self.reader.unref();
5204
+ }
5205
+ });
5206
+ };
5207
+ function Entry() {}
5208
+ Entry.prototype.getLastModDate = function() {
5209
+ return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
5210
+ };
5211
+ Entry.prototype.isEncrypted = function() {
5212
+ return (this.generalPurposeBitFlag & 1) !== 0;
5213
+ };
5214
+ Entry.prototype.isCompressed = function() {
5215
+ return this.compressionMethod === 8;
5216
+ };
5217
+ function dosDateTimeToDate(date, time) {
5218
+ var day = date & 31;
5219
+ var month = (date >> 5 & 15) - 1;
5220
+ var year = (date >> 9 & 127) + 1980;
5221
+ var millisecond = 0;
5222
+ var second = (time & 31) * 2;
5223
+ var minute = time >> 5 & 63;
5224
+ var hour = time >> 11 & 31;
5225
+ return new Date(year, month, day, hour, minute, second, millisecond);
5226
+ }
5227
+ function validateFileName(fileName) {
5228
+ if (fileName.indexOf("\\") !== -1) {
5229
+ return "invalid characters in fileName: " + fileName;
5230
+ }
5231
+ if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
5232
+ return "absolute path: " + fileName;
5233
+ }
5234
+ if (fileName.split("/").indexOf("..") !== -1) {
5235
+ return "invalid relative path: " + fileName;
5236
+ }
5237
+ return null;
5238
+ }
5239
+ function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
5240
+ if (length === 0) {
5241
+ return setImmediate(function() {
5242
+ callback(null, newBuffer(0));
5243
+ });
5244
+ }
5245
+ reader.read(buffer, offset, length, position, function(err, bytesRead) {
5246
+ if (err)
5247
+ return callback(err);
5248
+ if (bytesRead < length) {
5249
+ return callback(new Error("unexpected EOF"));
5250
+ }
5251
+ callback();
5252
+ });
5253
+ }
5254
+ util3.inherits(AssertByteCountStream, Transform);
5255
+ function AssertByteCountStream(byteCount) {
5256
+ Transform.call(this);
5257
+ this.actualByteCount = 0;
5258
+ this.expectedByteCount = byteCount;
5259
+ }
5260
+ AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
5261
+ this.actualByteCount += chunk.length;
5262
+ if (this.actualByteCount > this.expectedByteCount) {
5263
+ var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
5264
+ return cb(new Error(msg));
5265
+ }
5266
+ cb(null, chunk);
5267
+ };
5268
+ AssertByteCountStream.prototype._flush = function(cb) {
5269
+ if (this.actualByteCount < this.expectedByteCount) {
5270
+ var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
5271
+ return cb(new Error(msg));
5272
+ }
5273
+ cb();
5274
+ };
5275
+ util3.inherits(RandomAccessReader, EventEmitter2);
5276
+ function RandomAccessReader() {
5277
+ EventEmitter2.call(this);
5278
+ this.refCount = 0;
5279
+ }
5280
+ RandomAccessReader.prototype.ref = function() {
5281
+ this.refCount += 1;
5282
+ };
5283
+ RandomAccessReader.prototype.unref = function() {
5284
+ var self = this;
5285
+ self.refCount -= 1;
5286
+ if (self.refCount > 0)
5287
+ return;
5288
+ if (self.refCount < 0)
5289
+ throw new Error("invalid unref");
5290
+ self.close(onCloseDone);
5291
+ function onCloseDone(err) {
5292
+ if (err)
5293
+ return self.emit("error", err);
5294
+ self.emit("close");
5295
+ }
5296
+ };
5297
+ RandomAccessReader.prototype.createReadStream = function(options) {
5298
+ var start = options.start;
5299
+ var end = options.end;
5300
+ if (start === end) {
5301
+ var emptyStream = new PassThrough;
5302
+ setImmediate(function() {
5303
+ emptyStream.end();
5304
+ });
5305
+ return emptyStream;
5306
+ }
5307
+ var stream = this._readStreamForRange(start, end);
5308
+ var destroyed = false;
5309
+ var refUnrefFilter = new RefUnrefFilter(this);
5310
+ stream.on("error", function(err) {
5311
+ setImmediate(function() {
5312
+ if (!destroyed)
5313
+ refUnrefFilter.emit("error", err);
5314
+ });
5315
+ });
5316
+ refUnrefFilter.destroy = function() {
5317
+ stream.unpipe(refUnrefFilter);
5318
+ refUnrefFilter.unref();
5319
+ stream.destroy();
5320
+ };
5321
+ var byteCounter = new AssertByteCountStream(end - start);
5322
+ refUnrefFilter.on("error", function(err) {
5323
+ setImmediate(function() {
5324
+ if (!destroyed)
5325
+ byteCounter.emit("error", err);
5326
+ });
5327
+ });
5328
+ byteCounter.destroy = function() {
5329
+ destroyed = true;
5330
+ refUnrefFilter.unpipe(byteCounter);
5331
+ refUnrefFilter.destroy();
5332
+ };
5333
+ return stream.pipe(refUnrefFilter).pipe(byteCounter);
5334
+ };
5335
+ RandomAccessReader.prototype._readStreamForRange = function(start, end) {
5336
+ throw new Error("not implemented");
5337
+ };
5338
+ RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
5339
+ var readStream = this.createReadStream({ start: position, end: position + length });
5340
+ var writeStream = new Writable;
5341
+ var written = 0;
5342
+ writeStream._write = function(chunk, encoding, cb) {
5343
+ chunk.copy(buffer, offset + written, 0, chunk.length);
5344
+ written += chunk.length;
5345
+ cb();
5346
+ };
5347
+ writeStream.on("finish", callback);
5348
+ readStream.on("error", function(error) {
5349
+ callback(error);
5350
+ });
5351
+ readStream.pipe(writeStream);
5352
+ };
5353
+ RandomAccessReader.prototype.close = function(callback) {
5354
+ setImmediate(callback);
5355
+ };
5356
+ util3.inherits(RefUnrefFilter, PassThrough);
5357
+ function RefUnrefFilter(context) {
5358
+ PassThrough.call(this);
5359
+ this.context = context;
5360
+ this.context.ref();
5361
+ this.unreffedYet = false;
5362
+ }
5363
+ RefUnrefFilter.prototype._flush = function(cb) {
5364
+ this.unref();
5365
+ cb();
5366
+ };
5367
+ RefUnrefFilter.prototype.unref = function(cb) {
5368
+ if (this.unreffedYet)
5369
+ return;
5370
+ this.unreffedYet = true;
5371
+ this.context.unref();
5372
+ };
5373
+ var cp437 = "\x00☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";
5374
+ function decodeBuffer(buffer, start, end, isUtf8) {
5375
+ if (isUtf8) {
5376
+ return buffer.toString("utf8", start, end);
5377
+ } else {
5378
+ var result = "";
5379
+ for (var i = start;i < end; i++) {
5380
+ result += cp437[buffer[i]];
5381
+ }
5382
+ return result;
5383
+ }
5384
+ }
5385
+ function readUInt64LE(buffer, offset) {
5386
+ var lower32 = buffer.readUInt32LE(offset);
5387
+ var upper32 = buffer.readUInt32LE(offset + 4);
5388
+ return upper32 * 4294967296 + lower32;
5389
+ }
5390
+ var newBuffer;
5391
+ if (typeof Buffer.allocUnsafe === "function") {
5392
+ newBuffer = function(len) {
5393
+ return Buffer.allocUnsafe(len);
5394
+ };
5395
+ } else {
5396
+ newBuffer = function(len) {
5397
+ return new Buffer(len);
5398
+ };
5399
+ }
5400
+ function defaultCallback(err) {
5401
+ if (err)
5402
+ throw err;
5403
+ }
5404
+ });
5405
+
5406
+ // node_modules/extract-zip/index.js
5407
+ var require_extract_zip = __commonJS((exports, module) => {
5408
+ var debug = require_src2()("extract-zip");
5409
+ var { createWriteStream: createWriteStream2, promises: fs } = __require("fs");
5410
+ var getStream = require_get_stream();
5411
+ var path = __require("path");
5412
+ var { promisify } = __require("util");
5413
+ var stream = __require("stream");
5414
+ var yauzl = require_yauzl();
5415
+ var openZip = promisify(yauzl.open);
5416
+ var pipeline = promisify(stream.pipeline);
5417
+
5418
+ class Extractor {
5419
+ constructor(zipPath, opts) {
5420
+ this.zipPath = zipPath;
5421
+ this.opts = opts;
5422
+ }
5423
+ async extract() {
5424
+ debug("opening", this.zipPath, "with opts", this.opts);
5425
+ this.zipfile = await openZip(this.zipPath, { lazyEntries: true });
5426
+ this.canceled = false;
5427
+ return new Promise((resolve, reject) => {
5428
+ this.zipfile.on("error", (err) => {
5429
+ this.canceled = true;
5430
+ reject(err);
5431
+ });
5432
+ this.zipfile.readEntry();
5433
+ this.zipfile.on("close", () => {
5434
+ if (!this.canceled) {
5435
+ debug("zip extraction complete");
5436
+ resolve();
5437
+ }
5438
+ });
5439
+ this.zipfile.on("entry", async (entry) => {
5440
+ if (this.canceled) {
5441
+ debug("skipping entry", entry.fileName, { cancelled: this.canceled });
5442
+ return;
5443
+ }
5444
+ debug("zipfile entry", entry.fileName);
5445
+ if (entry.fileName.startsWith("__MACOSX/")) {
5446
+ this.zipfile.readEntry();
5447
+ return;
5448
+ }
5449
+ const destDir = path.dirname(path.join(this.opts.dir, entry.fileName));
5450
+ try {
5451
+ await fs.mkdir(destDir, { recursive: true });
5452
+ const canonicalDestDir = await fs.realpath(destDir);
5453
+ const relativeDestDir = path.relative(this.opts.dir, canonicalDestDir);
5454
+ if (relativeDestDir.split(path.sep).includes("..")) {
5455
+ throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
5456
+ }
5457
+ await this.extractEntry(entry);
5458
+ debug("finished processing", entry.fileName);
5459
+ this.zipfile.readEntry();
5460
+ } catch (err) {
5461
+ this.canceled = true;
5462
+ this.zipfile.close();
5463
+ reject(err);
5464
+ }
5465
+ });
5466
+ });
5467
+ }
5468
+ async extractEntry(entry) {
5469
+ if (this.canceled) {
5470
+ debug("skipping entry extraction", entry.fileName, { cancelled: this.canceled });
5471
+ return;
5472
+ }
5473
+ if (this.opts.onEntry) {
5474
+ this.opts.onEntry(entry, this.zipfile);
5475
+ }
5476
+ const dest = path.join(this.opts.dir, entry.fileName);
5477
+ const mode = entry.externalFileAttributes >> 16 & 65535;
5478
+ const IFMT = 61440;
5479
+ const IFDIR = 16384;
5480
+ const IFLNK = 40960;
5481
+ const symlink = (mode & IFMT) === IFLNK;
5482
+ let isDir = (mode & IFMT) === IFDIR;
5483
+ if (!isDir && entry.fileName.endsWith("/")) {
5484
+ isDir = true;
5485
+ }
5486
+ const madeBy = entry.versionMadeBy >> 8;
5487
+ if (!isDir)
5488
+ isDir = madeBy === 0 && entry.externalFileAttributes === 16;
5489
+ debug("extracting entry", { filename: entry.fileName, isDir, isSymlink: symlink });
5490
+ const procMode = this.getExtractedMode(mode, isDir) & 511;
5491
+ const destDir = isDir ? dest : path.dirname(dest);
5492
+ const mkdirOptions = { recursive: true };
5493
+ if (isDir) {
5494
+ mkdirOptions.mode = procMode;
5495
+ }
5496
+ debug("mkdir", { dir: destDir, ...mkdirOptions });
5497
+ await fs.mkdir(destDir, mkdirOptions);
5498
+ if (isDir)
5499
+ return;
5500
+ debug("opening read stream", dest);
5501
+ const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry);
5502
+ if (symlink) {
5503
+ const link = await getStream(readStream);
5504
+ debug("creating symlink", link, dest);
5505
+ await fs.symlink(link, dest);
5506
+ } else {
5507
+ await pipeline(readStream, createWriteStream2(dest, { mode: procMode }));
5508
+ }
5509
+ }
5510
+ getExtractedMode(entryMode, isDir) {
5511
+ let mode = entryMode;
5512
+ if (mode === 0) {
5513
+ if (isDir) {
5514
+ if (this.opts.defaultDirMode) {
5515
+ mode = parseInt(this.opts.defaultDirMode, 10);
5516
+ }
5517
+ if (!mode) {
5518
+ mode = 493;
5519
+ }
5520
+ } else {
5521
+ if (this.opts.defaultFileMode) {
5522
+ mode = parseInt(this.opts.defaultFileMode, 10);
5523
+ }
5524
+ if (!mode) {
5525
+ mode = 420;
5526
+ }
5527
+ }
5528
+ }
5529
+ return mode;
5530
+ }
5531
+ }
5532
+ module.exports = async function(zipPath, opts) {
5533
+ debug("creating target directory", opts.dir);
5534
+ if (!path.isAbsolute(opts.dir)) {
5535
+ throw new Error("Target directory is expected to be absolute");
5536
+ }
5537
+ await fs.mkdir(opts.dir, { recursive: true });
5538
+ opts.dir = await fs.realpath(opts.dir);
5539
+ return new Extractor(zipPath, opts).extract();
5540
+ };
5541
+ });
5542
+
3007
5543
  // node_modules/ignore/index.js
3008
5544
  var require_ignore = __commonJS((exports, module) => {
3009
5545
  function makeArray(subject) {
@@ -3264,11 +5800,6 @@ var require_ignore = __commonJS((exports, module) => {
3264
5800
  }
3265
5801
  });
3266
5802
 
3267
- // src/index.ts
3268
- import { readFileSync } from "fs";
3269
- import { join as join6 } from "path";
3270
- import { fileURLToPath } from "url";
3271
-
3272
5803
  // node_modules/cac/dist/index.mjs
3273
5804
  import { EventEmitter } from "events";
3274
5805
  function toArr(any) {
@@ -3872,7 +6403,7 @@ var cac = (name = "") => new CAC(name);
3872
6403
 
3873
6404
  // src/commands/new.ts
3874
6405
  var import_fs_extra2 = __toESM(require_lib(), 1);
3875
- import { resolve } from "node:path";
6406
+ import { resolve as resolve2 } from "node:path";
3876
6407
 
3877
6408
  // src/lib/auth.ts
3878
6409
  import { execSync } from "node:child_process";
@@ -8394,7 +10925,8 @@ var KitType = exports_external.enum(["engineer", "marketing"]);
8394
10925
  var NewCommandOptionsSchema = exports_external.object({
8395
10926
  dir: exports_external.string().default("."),
8396
10927
  kit: KitType.optional(),
8397
- version: exports_external.string().optional()
10928
+ version: exports_external.string().optional(),
10929
+ force: exports_external.boolean().default(false)
8398
10930
  });
8399
10931
  var UpdateCommandOptionsSchema = exports_external.object({
8400
10932
  dir: exports_external.string().default("."),
@@ -8787,13 +11319,12 @@ class AuthManager {
8787
11319
 
8788
11320
  // src/lib/download.ts
8789
11321
  var import_cli_progress = __toESM(require_cli_progress(), 1);
11322
+ var import_extract_zip = __toESM(require_extract_zip(), 1);
8790
11323
  var import_ignore = __toESM(require_ignore(), 1);
8791
- import { createReadStream, createWriteStream as createWriteStream2 } from "node:fs";
11324
+ import { createWriteStream as createWriteStream2 } from "node:fs";
8792
11325
  import { mkdir as mkdir3 } from "node:fs/promises";
8793
11326
  import { tmpdir } from "node:os";
8794
- import { join as join3 } from "node:path";
8795
- import { pipeline } from "node:stream";
8796
- import { promisify } from "node:util";
11327
+ import { join as join3, relative, resolve } from "node:path";
8797
11328
 
8798
11329
  // node_modules/@isaacs/fs-minipass/dist/esm/index.js
8799
11330
  import EE from "events";
@@ -15596,9 +18127,6 @@ var mtimeFilter = (opt) => {
15596
18127
  }
15597
18128
  opt.filter = filter ? (path8, stat) => filter(path8, stat) && !((opt.mtimeCache?.get(path8) ?? stat.mtime ?? 0) > (stat.mtime ?? 0)) : (path8, stat) => !((opt.mtimeCache?.get(path8) ?? stat.mtime ?? 0) > (stat.mtime ?? 0));
15598
18129
  };
15599
- // src/lib/download.ts
15600
- import unzipper from "unzipper";
15601
-
15602
18130
  // node_modules/ora/index.js
15603
18131
  import process8 from "node:process";
15604
18132
 
@@ -18671,9 +21199,8 @@ function createSpinner(options) {
18671
21199
  }
18672
21200
 
18673
21201
  // src/lib/download.ts
18674
- var streamPipeline = promisify(pipeline);
18675
-
18676
21202
  class DownloadManager {
21203
+ static MAX_EXTRACTION_SIZE = 500 * 1024 * 1024;
18677
21204
  static EXCLUDE_PATTERNS = [
18678
21205
  ".git",
18679
21206
  ".git/**",
@@ -18685,10 +21212,26 @@ class DownloadManager {
18685
21212
  "Thumbs.db",
18686
21213
  "*.log"
18687
21214
  ];
21215
+ totalExtractedSize = 0;
18688
21216
  shouldExclude(filePath) {
18689
21217
  const ig = import_ignore.default().add(DownloadManager.EXCLUDE_PATTERNS);
18690
21218
  return ig.ignores(filePath);
18691
21219
  }
21220
+ isPathSafe(basePath, targetPath) {
21221
+ const resolvedBase = resolve(basePath);
21222
+ const resolvedTarget = resolve(targetPath);
21223
+ const relativePath = relative(resolvedBase, resolvedTarget);
21224
+ return !relativePath.startsWith("..") && !relativePath.startsWith("/") && resolvedTarget.startsWith(resolvedBase);
21225
+ }
21226
+ checkExtractionSize(fileSize) {
21227
+ this.totalExtractedSize += fileSize;
21228
+ if (this.totalExtractedSize > DownloadManager.MAX_EXTRACTION_SIZE) {
21229
+ throw new ExtractionError(`Archive exceeds maximum extraction size of ${this.formatBytes(DownloadManager.MAX_EXTRACTION_SIZE)}. Possible archive bomb detected.`);
21230
+ }
21231
+ }
21232
+ resetExtractionSize() {
21233
+ this.totalExtractedSize = 0;
21234
+ }
18692
21235
  async downloadAsset(asset, destDir) {
18693
21236
  try {
18694
21237
  const destPath = join3(destDir, asset.name);
@@ -18798,6 +21341,7 @@ class DownloadManager {
18798
21341
  async extractArchive(archivePath, destDir, archiveType) {
18799
21342
  const spinner = createSpinner("Extracting files...").start();
18800
21343
  try {
21344
+ this.resetExtractionSize();
18801
21345
  const detectedType = archiveType || this.detectArchiveType(archivePath);
18802
21346
  await mkdir3(destDir, { recursive: true });
18803
21347
  if (detectedType === "tar.gz") {
@@ -18814,18 +21358,63 @@ class DownloadManager {
18814
21358
  }
18815
21359
  }
18816
21360
  async extractTarGz(archivePath, destDir) {
18817
- await extract({
18818
- file: archivePath,
18819
- cwd: destDir,
18820
- strip: 1,
18821
- filter: (path8) => {
18822
- const shouldInclude = !this.shouldExclude(path8);
18823
- if (!shouldInclude) {
18824
- logger.debug(`Excluding: ${path8}`);
21361
+ const { readdir, stat, mkdir: mkdirPromise, copyFile, rm } = await import("node:fs/promises");
21362
+ const { join: pathJoin } = await import("node:path");
21363
+ const tempExtractDir = `${destDir}-temp`;
21364
+ await mkdirPromise(tempExtractDir, { recursive: true });
21365
+ try {
21366
+ await extract({
21367
+ file: archivePath,
21368
+ cwd: tempExtractDir,
21369
+ strip: 0,
21370
+ filter: (path8) => {
21371
+ const shouldInclude = !this.shouldExclude(path8);
21372
+ if (!shouldInclude) {
21373
+ logger.debug(`Excluding: ${path8}`);
21374
+ }
21375
+ return shouldInclude;
21376
+ }
21377
+ });
21378
+ logger.debug(`Extracted TAR.GZ to temp: ${tempExtractDir}`);
21379
+ const entries = await readdir(tempExtractDir);
21380
+ logger.debug(`Root entries: ${entries.join(", ")}`);
21381
+ if (entries.length === 1) {
21382
+ const rootEntry = entries[0];
21383
+ const rootPath = pathJoin(tempExtractDir, rootEntry);
21384
+ const rootStat = await stat(rootPath);
21385
+ if (rootStat.isDirectory()) {
21386
+ const rootContents = await readdir(rootPath);
21387
+ logger.debug(`Root directory '${rootEntry}' contains: ${rootContents.join(", ")}`);
21388
+ const isWrapper = this.isWrapperDirectory(rootEntry);
21389
+ logger.debug(`Is wrapper directory: ${isWrapper}`);
21390
+ if (isWrapper) {
21391
+ logger.debug(`Stripping wrapper directory: ${rootEntry}`);
21392
+ await this.moveDirectoryContents(rootPath, destDir);
21393
+ } else {
21394
+ logger.debug("Preserving complete directory structure");
21395
+ await this.moveDirectoryContents(tempExtractDir, destDir);
21396
+ }
21397
+ } else {
21398
+ await mkdirPromise(destDir, { recursive: true });
21399
+ await copyFile(rootPath, pathJoin(destDir, rootEntry));
18825
21400
  }
18826
- return shouldInclude;
21401
+ } else {
21402
+ logger.debug("Multiple root entries - moving all");
21403
+ await this.moveDirectoryContents(tempExtractDir, destDir);
18827
21404
  }
18828
- });
21405
+ logger.debug(`Moved contents to: ${destDir}`);
21406
+ await rm(tempExtractDir, { recursive: true, force: true });
21407
+ } catch (error2) {
21408
+ try {
21409
+ await rm(tempExtractDir, { recursive: true, force: true });
21410
+ } catch {}
21411
+ throw error2;
21412
+ }
21413
+ }
21414
+ isWrapperDirectory(dirName) {
21415
+ const versionPattern = /^[\w-]+-v?\d+\.\d+\.\d+(-[\w.]+)?$/;
21416
+ const hashPattern = /^[\w-]+-[a-f0-9]{7,40}$/;
21417
+ return versionPattern.test(dirName) || hashPattern.test(dirName);
18829
21418
  }
18830
21419
  async extractZip(archivePath, destDir) {
18831
21420
  const { readdir, stat, mkdir: mkdirPromise, copyFile, rm } = await import("node:fs/promises");
@@ -18833,21 +21422,35 @@ class DownloadManager {
18833
21422
  const tempExtractDir = `${destDir}-temp`;
18834
21423
  await mkdirPromise(tempExtractDir, { recursive: true });
18835
21424
  try {
18836
- await streamPipeline(createReadStream(archivePath), unzipper.Extract({ path: tempExtractDir }));
21425
+ await import_extract_zip.default(archivePath, { dir: tempExtractDir });
21426
+ logger.debug(`Extracted ZIP to temp: ${tempExtractDir}`);
18837
21427
  const entries = await readdir(tempExtractDir);
21428
+ logger.debug(`Root entries: ${entries.join(", ")}`);
18838
21429
  if (entries.length === 1) {
18839
21430
  const rootEntry = entries[0];
18840
21431
  const rootPath = pathJoin(tempExtractDir, rootEntry);
18841
21432
  const rootStat = await stat(rootPath);
18842
21433
  if (rootStat.isDirectory()) {
18843
- await this.moveDirectoryContents(rootPath, destDir);
21434
+ const rootContents = await readdir(rootPath);
21435
+ logger.debug(`Root directory '${rootEntry}' contains: ${rootContents.join(", ")}`);
21436
+ const isWrapper = this.isWrapperDirectory(rootEntry);
21437
+ logger.debug(`Is wrapper directory: ${isWrapper}`);
21438
+ if (isWrapper) {
21439
+ logger.debug(`Stripping wrapper directory: ${rootEntry}`);
21440
+ await this.moveDirectoryContents(rootPath, destDir);
21441
+ } else {
21442
+ logger.debug("Preserving complete directory structure");
21443
+ await this.moveDirectoryContents(tempExtractDir, destDir);
21444
+ }
18844
21445
  } else {
18845
21446
  await mkdirPromise(destDir, { recursive: true });
18846
21447
  await copyFile(rootPath, pathJoin(destDir, rootEntry));
18847
21448
  }
18848
21449
  } else {
21450
+ logger.debug("Multiple root entries - moving all");
18849
21451
  await this.moveDirectoryContents(tempExtractDir, destDir);
18850
21452
  }
21453
+ logger.debug(`Moved contents to: ${destDir}`);
18851
21454
  await rm(tempExtractDir, { recursive: true, force: true });
18852
21455
  } catch (error2) {
18853
21456
  try {
@@ -18858,13 +21461,17 @@ class DownloadManager {
18858
21461
  }
18859
21462
  async moveDirectoryContents(sourceDir, destDir) {
18860
21463
  const { readdir, stat, mkdir: mkdirPromise, copyFile } = await import("node:fs/promises");
18861
- const { join: pathJoin, relative } = await import("node:path");
21464
+ const { join: pathJoin, relative: relative2 } = await import("node:path");
18862
21465
  await mkdirPromise(destDir, { recursive: true });
18863
21466
  const entries = await readdir(sourceDir);
18864
21467
  for (const entry of entries) {
18865
21468
  const sourcePath = pathJoin(sourceDir, entry);
18866
21469
  const destPath = pathJoin(destDir, entry);
18867
- const relativePath = relative(sourceDir, sourcePath);
21470
+ const relativePath = relative2(sourceDir, sourcePath);
21471
+ if (!this.isPathSafe(destDir, destPath)) {
21472
+ logger.warning(`Skipping unsafe path: ${relativePath}`);
21473
+ throw new ExtractionError(`Path traversal attempt detected: ${relativePath}`);
21474
+ }
18868
21475
  if (this.shouldExclude(relativePath)) {
18869
21476
  logger.debug(`Excluding: ${relativePath}`);
18870
21477
  continue;
@@ -18873,19 +21480,24 @@ class DownloadManager {
18873
21480
  if (entryStat.isDirectory()) {
18874
21481
  await this.copyDirectory(sourcePath, destPath);
18875
21482
  } else {
21483
+ this.checkExtractionSize(entryStat.size);
18876
21484
  await copyFile(sourcePath, destPath);
18877
21485
  }
18878
21486
  }
18879
21487
  }
18880
21488
  async copyDirectory(sourceDir, destDir) {
18881
21489
  const { readdir, stat, mkdir: mkdirPromise, copyFile } = await import("node:fs/promises");
18882
- const { join: pathJoin, relative } = await import("node:path");
21490
+ const { join: pathJoin, relative: relative2 } = await import("node:path");
18883
21491
  await mkdirPromise(destDir, { recursive: true });
18884
21492
  const entries = await readdir(sourceDir);
18885
21493
  for (const entry of entries) {
18886
21494
  const sourcePath = pathJoin(sourceDir, entry);
18887
21495
  const destPath = pathJoin(destDir, entry);
18888
- const relativePath = relative(sourceDir, sourcePath);
21496
+ const relativePath = relative2(sourceDir, sourcePath);
21497
+ if (!this.isPathSafe(destDir, destPath)) {
21498
+ logger.warning(`Skipping unsafe path: ${relativePath}`);
21499
+ throw new ExtractionError(`Path traversal attempt detected: ${relativePath}`);
21500
+ }
18889
21501
  if (this.shouldExclude(relativePath)) {
18890
21502
  logger.debug(`Excluding: ${relativePath}`);
18891
21503
  continue;
@@ -18894,6 +21506,7 @@ class DownloadManager {
18894
21506
  if (entryStat.isDirectory()) {
18895
21507
  await this.copyDirectory(sourcePath, destPath);
18896
21508
  } else {
21509
+ this.checkExtractionSize(entryStat.size);
18897
21510
  await copyFile(sourcePath, destPath);
18898
21511
  }
18899
21512
  }
@@ -18907,6 +21520,38 @@ class DownloadManager {
18907
21520
  }
18908
21521
  throw new ExtractionError(`Cannot detect archive type from filename: ${filename}`);
18909
21522
  }
21523
+ async validateExtraction(extractDir) {
21524
+ const { readdir, access } = await import("node:fs/promises");
21525
+ const { join: pathJoin } = await import("node:path");
21526
+ const { constants: constants2 } = await import("node:fs");
21527
+ try {
21528
+ const entries = await readdir(extractDir);
21529
+ logger.debug(`Extracted files: ${entries.join(", ")}`);
21530
+ if (entries.length === 0) {
21531
+ throw new ExtractionError("Extraction resulted in no files");
21532
+ }
21533
+ const criticalPaths = [".claude", "CLAUDE.md"];
21534
+ const missingPaths = [];
21535
+ for (const path8 of criticalPaths) {
21536
+ try {
21537
+ await access(pathJoin(extractDir, path8), constants2.F_OK);
21538
+ logger.debug(`✓ Found: ${path8}`);
21539
+ } catch {
21540
+ logger.warning(`Expected path not found: ${path8}`);
21541
+ missingPaths.push(path8);
21542
+ }
21543
+ }
21544
+ if (missingPaths.length > 0) {
21545
+ logger.warning(`Some expected paths are missing: ${missingPaths.join(", ")}. This may not be a ClaudeKit project.`);
21546
+ }
21547
+ logger.debug("Extraction validation passed");
21548
+ } catch (error2) {
21549
+ if (error2 instanceof ExtractionError) {
21550
+ throw error2;
21551
+ }
21552
+ throw new ExtractionError(`Validation failed: ${error2 instanceof Error ? error2.message : "Unknown error"}`);
21553
+ }
21554
+ }
18910
21555
  async createTempDir() {
18911
21556
  const tempDir = join3(tmpdir(), `claudekit-${Date.now()}`);
18912
21557
  await mkdir3(tempDir, { recursive: true });
@@ -19064,7 +21709,7 @@ class GitHubClient {
19064
21709
  }
19065
21710
 
19066
21711
  // src/lib/merge.ts
19067
- import { join as join4, relative } from "node:path";
21712
+ import { join as join4, relative as relative2 } from "node:path";
19068
21713
  var import_fs_extra = __toESM(require_lib(), 1);
19069
21714
  var import_ignore2 = __toESM(require_ignore(), 1);
19070
21715
  class FileMerger {
@@ -19090,7 +21735,7 @@ class FileMerger {
19090
21735
  const conflicts = [];
19091
21736
  const files = await this.getFiles(sourceDir);
19092
21737
  for (const file of files) {
19093
- const relativePath = relative(sourceDir, file);
21738
+ const relativePath = relative2(sourceDir, file);
19094
21739
  if (this.ig.ignores(relativePath)) {
19095
21740
  continue;
19096
21741
  }
@@ -19106,7 +21751,7 @@ class FileMerger {
19106
21751
  let copiedCount = 0;
19107
21752
  let skippedCount = 0;
19108
21753
  for (const file of files) {
19109
- const relativePath = relative(sourceDir, file);
21754
+ const relativePath = relative2(sourceDir, file);
19110
21755
  if (this.ig.ignores(relativePath)) {
19111
21756
  logger.debug(`Skipping protected file: ${relativePath}`);
19112
21757
  skippedCount++;
@@ -19244,27 +21889,42 @@ async function newCommand(options) {
19244
21889
  prompts.intro("\uD83D\uDE80 ClaudeKit - Create New Project");
19245
21890
  try {
19246
21891
  const validOptions = NewCommandOptionsSchema.parse(options);
21892
+ const isNonInteractive = !process.stdin.isTTY || process.env.CI === "true" || process.env.NON_INTERACTIVE === "true";
19247
21893
  const config = await ConfigManager.get();
19248
21894
  let kit = validOptions.kit || config.defaults?.kit;
19249
21895
  if (!kit) {
21896
+ if (isNonInteractive) {
21897
+ throw new Error("Kit must be specified via --kit flag in non-interactive mode");
21898
+ }
19250
21899
  kit = await prompts.selectKit();
19251
21900
  }
19252
21901
  const kitConfig = AVAILABLE_KITS[kit];
19253
21902
  logger.info(`Selected kit: ${kitConfig.name}`);
19254
21903
  let targetDir = validOptions.dir || config.defaults?.dir || ".";
19255
21904
  if (!validOptions.dir && !config.defaults?.dir) {
19256
- targetDir = await prompts.getDirectory(targetDir);
21905
+ if (isNonInteractive) {
21906
+ targetDir = ".";
21907
+ } else {
21908
+ targetDir = await prompts.getDirectory(targetDir);
21909
+ }
19257
21910
  }
19258
- const resolvedDir = resolve(targetDir);
21911
+ const resolvedDir = resolve2(targetDir);
19259
21912
  logger.info(`Target directory: ${resolvedDir}`);
19260
21913
  if (await import_fs_extra2.pathExists(resolvedDir)) {
19261
21914
  const files = await import_fs_extra2.readdir(resolvedDir);
19262
21915
  const isEmpty = files.length === 0;
19263
21916
  if (!isEmpty) {
19264
- const continueAnyway = await prompts.confirm("Directory is not empty. Files may be overwritten. Continue?");
19265
- if (!continueAnyway) {
19266
- logger.warning("Operation cancelled");
19267
- return;
21917
+ if (isNonInteractive) {
21918
+ if (!validOptions.force) {
21919
+ throw new Error("Directory is not empty. Use --force flag to overwrite in non-interactive mode");
21920
+ }
21921
+ logger.info("Directory is not empty. Proceeding with --force flag");
21922
+ } else {
21923
+ const continueAnyway = await prompts.confirm("Directory is not empty. Files may be overwritten. Continue?");
21924
+ if (!continueAnyway) {
21925
+ logger.warning("Operation cancelled");
21926
+ return;
21927
+ }
19268
21928
  }
19269
21929
  }
19270
21930
  }
@@ -19323,6 +21983,7 @@ async function newCommand(options) {
19323
21983
  }
19324
21984
  const extractDir = `${tempDir}/extracted`;
19325
21985
  await downloadManager.extractArchive(archivePath, extractDir);
21986
+ await downloadManager.validateExtraction(extractDir);
19326
21987
  const merger = new FileMerger;
19327
21988
  await merger.merge(extractDir, resolvedDir, true);
19328
21989
  prompts.outro(`✨ Project created successfully at ${resolvedDir}`);
@@ -19337,11 +21998,11 @@ bun run dev`, "Next steps");
19337
21998
 
19338
21999
  // src/commands/update.ts
19339
22000
  var import_fs_extra4 = __toESM(require_lib(), 1);
19340
- import { resolve as resolve3 } from "node:path";
22001
+ import { resolve as resolve4 } from "node:path";
19341
22002
 
19342
22003
  // src/utils/file-scanner.ts
19343
22004
  var import_fs_extra3 = __toESM(require_lib(), 1);
19344
- import { join as join5, relative as relative2, resolve as resolve2 } from "node:path";
22005
+ import { join as join5, relative as relative3, resolve as resolve3 } from "node:path";
19345
22006
  class FileScanner {
19346
22007
  static async getFiles(dirPath, relativeTo) {
19347
22008
  const basePath = relativeTo || dirPath;
@@ -19366,7 +22027,7 @@ class FileScanner {
19366
22027
  const subFiles = await FileScanner.getFiles(fullPath, basePath);
19367
22028
  files.push(...subFiles);
19368
22029
  } else if (stats.isFile()) {
19369
- const relativePath = relative2(basePath, fullPath);
22030
+ const relativePath = relative3(basePath, fullPath);
19370
22031
  files.push(relativePath);
19371
22032
  }
19372
22033
  }
@@ -19394,8 +22055,8 @@ class FileScanner {
19394
22055
  return customFiles;
19395
22056
  }
19396
22057
  static isSafePath(basePath, targetPath) {
19397
- const resolvedBase = resolve2(basePath);
19398
- const resolvedTarget = resolve2(targetPath);
22058
+ const resolvedBase = resolve3(basePath);
22059
+ const resolvedTarget = resolve3(targetPath);
19399
22060
  return resolvedTarget.startsWith(resolvedBase);
19400
22061
  }
19401
22062
  }
@@ -19417,7 +22078,7 @@ async function updateCommand(options) {
19417
22078
  if (!validOptions.dir && !config.defaults?.dir) {
19418
22079
  targetDir = await prompts.getDirectory(targetDir);
19419
22080
  }
19420
- const resolvedDir = resolve3(targetDir);
22081
+ const resolvedDir = resolve4(targetDir);
19421
22082
  logger.info(`Target directory: ${resolvedDir}`);
19422
22083
  if (!await import_fs_extra4.pathExists(resolvedDir)) {
19423
22084
  logger.error(`Directory does not exist: ${resolvedDir}`);
@@ -19479,6 +22140,7 @@ async function updateCommand(options) {
19479
22140
  }
19480
22141
  const extractDir = `${tempDir}/extracted`;
19481
22142
  await downloadManager.extractArchive(archivePath, extractDir);
22143
+ await downloadManager.validateExtraction(extractDir);
19482
22144
  logger.info("Scanning for custom .claude files...");
19483
22145
  const customClaudeFiles = await FileScanner.findCustomFiles(resolvedDir, extractDir, ".claude");
19484
22146
  const merger = new FileMerger;
@@ -19692,6 +22354,10 @@ class Logger2 {
19692
22354
  }
19693
22355
  }
19694
22356
  var logger2 = new Logger2;
22357
+ // src/version.json
22358
+ var version_default = {
22359
+ version: "1.2.1"
22360
+ };
19695
22361
 
19696
22362
  // src/index.ts
19697
22363
  if (process.stdout.setEncoding) {
@@ -19700,12 +22366,11 @@ if (process.stdout.setEncoding) {
19700
22366
  if (process.stderr.setEncoding) {
19701
22367
  process.stderr.setEncoding("utf8");
19702
22368
  }
19703
- var __dirname2 = fileURLToPath(new URL(".", import.meta.url));
19704
- var packageJson = JSON.parse(readFileSync(join6(__dirname2, "../package.json"), "utf-8"));
22369
+ var packageVersion = version_default.version;
19705
22370
  var cli = cac("ck");
19706
22371
  cli.option("--verbose, -v", "Enable verbose logging for debugging");
19707
22372
  cli.option("--log-file <path>", "Write logs to file");
19708
- cli.command("new", "Bootstrap a new ClaudeKit project").option("--dir <dir>", "Target directory (default: .)").option("--kit <kit>", "Kit to use (engineer, marketing)").option("--version <version>", "Specific version to download (default: latest)").action(async (options) => {
22373
+ cli.command("new", "Bootstrap a new ClaudeKit project").option("--dir <dir>", "Target directory (default: .)").option("--kit <kit>", "Kit to use (engineer, marketing)").option("--version <version>", "Specific version to download (default: latest)").option("--force", "Overwrite existing files without confirmation").action(async (options) => {
19709
22374
  await newCommand(options);
19710
22375
  });
19711
22376
  cli.command("update", "Update existing ClaudeKit project").option("--dir <dir>", "Target directory (default: .)").option("--kit <kit>", "Kit to use (engineer, marketing)").option("--version <version>", "Specific version to download (default: latest)").action(async (options) => {
@@ -19714,7 +22379,7 @@ cli.command("update", "Update existing ClaudeKit project").option("--dir <dir>",
19714
22379
  cli.command("versions", "List available versions of ClaudeKit repositories").option("--kit <kit>", "Filter by specific kit (engineer, marketing)").option("--limit <limit>", "Number of releases to show (default: 30)").option("--all", "Show all releases including prereleases").action(async (options) => {
19715
22380
  await versionCommand(options);
19716
22381
  });
19717
- cli.version(packageJson.version);
22382
+ cli.version(packageVersion);
19718
22383
  cli.help();
19719
22384
  var parsed = cli.parse(process.argv, { run: false });
19720
22385
  var envVerbose = process.env.CLAUDEKIT_VERBOSE === "1" || process.env.CLAUDEKIT_VERBOSE === "true";
@@ -19726,7 +22391,7 @@ if (parsed.options.logFile) {
19726
22391
  logger2.setLogFile(parsed.options.logFile);
19727
22392
  }
19728
22393
  logger2.verbose("ClaudeKit CLI starting", {
19729
- version: packageJson.version,
22394
+ version: packageVersion,
19730
22395
  command: parsed.args[0] || "none",
19731
22396
  options: parsed.options,
19732
22397
  cwd: process.cwd(),