@vercel/python 6.45.0 → 6.47.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 +1595 -193
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ var require_windows = __commonJS({
|
|
|
48
48
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module2) {
|
|
49
49
|
module2.exports = isexe;
|
|
50
50
|
isexe.sync = sync;
|
|
51
|
-
var
|
|
51
|
+
var fs14 = require("fs");
|
|
52
52
|
function checkPathExt(path, options) {
|
|
53
53
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
54
54
|
if (!pathext) {
|
|
@@ -73,12 +73,12 @@ var require_windows = __commonJS({
|
|
|
73
73
|
return checkPathExt(path, options);
|
|
74
74
|
}
|
|
75
75
|
function isexe(path, options, cb) {
|
|
76
|
-
|
|
76
|
+
fs14.stat(path, function(er, stat) {
|
|
77
77
|
cb(er, er ? false : checkStat(stat, path, options));
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function sync(path, options) {
|
|
81
|
-
return checkStat(
|
|
81
|
+
return checkStat(fs14.statSync(path), path, options);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
});
|
|
@@ -88,14 +88,14 @@ var require_mode = __commonJS({
|
|
|
88
88
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module2) {
|
|
89
89
|
module2.exports = isexe;
|
|
90
90
|
isexe.sync = sync;
|
|
91
|
-
var
|
|
91
|
+
var fs14 = require("fs");
|
|
92
92
|
function isexe(path, options, cb) {
|
|
93
|
-
|
|
93
|
+
fs14.stat(path, function(er, stat) {
|
|
94
94
|
cb(er, er ? false : checkStat(stat, options));
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
function sync(path, options) {
|
|
98
|
-
return checkStat(
|
|
98
|
+
return checkStat(fs14.statSync(path), options);
|
|
99
99
|
}
|
|
100
100
|
function checkStat(stat, options) {
|
|
101
101
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -119,7 +119,7 @@ var require_mode = __commonJS({
|
|
|
119
119
|
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
120
120
|
var require_isexe = __commonJS({
|
|
121
121
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module2) {
|
|
122
|
-
var
|
|
122
|
+
var fs14 = require("fs");
|
|
123
123
|
var core;
|
|
124
124
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
125
125
|
core = require_windows();
|
|
@@ -395,7 +395,7 @@ var require_shebang_command = __commonJS({
|
|
|
395
395
|
var require_readShebang = __commonJS({
|
|
396
396
|
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
|
|
397
397
|
"use strict";
|
|
398
|
-
var
|
|
398
|
+
var fs14 = require("fs");
|
|
399
399
|
var shebangCommand = require_shebang_command();
|
|
400
400
|
function readShebang(command) {
|
|
401
401
|
const size = 150;
|
|
@@ -408,9 +408,9 @@ var require_readShebang = __commonJS({
|
|
|
408
408
|
}
|
|
409
409
|
let fd;
|
|
410
410
|
try {
|
|
411
|
-
fd =
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
fd = fs14.openSync(command, "r");
|
|
412
|
+
fs14.readSync(fd, buffer, 0, size, 0);
|
|
413
|
+
fs14.closeSync(fd);
|
|
414
414
|
} catch (e) {
|
|
415
415
|
}
|
|
416
416
|
return shebangCommand(buffer.toString());
|
|
@@ -1497,11 +1497,11 @@ var require_parse = __commonJS({
|
|
|
1497
1497
|
var resolveCommand = require_resolveCommand();
|
|
1498
1498
|
var escape = require_escape();
|
|
1499
1499
|
var readShebang = require_readShebang();
|
|
1500
|
-
var
|
|
1500
|
+
var semver2 = require_semver();
|
|
1501
1501
|
var isWin3 = process.platform === "win32";
|
|
1502
1502
|
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
1503
1503
|
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
1504
|
-
var supportsShellOption = niceTry(() =>
|
|
1504
|
+
var supportsShellOption = niceTry(() => semver2.satisfies(process.version, "^4.8.0 || ^5.7.0 || >= 6.0.0", true)) || false;
|
|
1505
1505
|
function detectShebang(parsed) {
|
|
1506
1506
|
parsed.file = resolveCommand(parsed);
|
|
1507
1507
|
const shebang = parsed.file && readShebang(parsed.file);
|
|
@@ -1895,9 +1895,9 @@ var require_pump = __commonJS({
|
|
|
1895
1895
|
"../../node_modules/.pnpm/pump@3.0.4/node_modules/pump/index.js"(exports, module2) {
|
|
1896
1896
|
var once = require_once();
|
|
1897
1897
|
var eos = require_end_of_stream();
|
|
1898
|
-
var
|
|
1898
|
+
var fs14;
|
|
1899
1899
|
try {
|
|
1900
|
-
|
|
1900
|
+
fs14 = require("fs");
|
|
1901
1901
|
} catch (e) {
|
|
1902
1902
|
}
|
|
1903
1903
|
var noop = function() {
|
|
@@ -1909,9 +1909,9 @@ var require_pump = __commonJS({
|
|
|
1909
1909
|
var isFS = function(stream) {
|
|
1910
1910
|
if (!ancient)
|
|
1911
1911
|
return false;
|
|
1912
|
-
if (!
|
|
1912
|
+
if (!fs14)
|
|
1913
1913
|
return false;
|
|
1914
|
-
return (stream instanceof (
|
|
1914
|
+
return (stream instanceof (fs14.ReadStream || noop) || stream instanceof (fs14.WriteStream || noop)) && isFn(stream.close);
|
|
1915
1915
|
};
|
|
1916
1916
|
var isRequest = function(stream) {
|
|
1917
1917
|
return stream.setHeader && isFn(stream.abort);
|
|
@@ -2651,7 +2651,7 @@ ${stderr}${stdout}`;
|
|
|
2651
2651
|
var require_lib = __commonJS({
|
|
2652
2652
|
"../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
|
|
2653
2653
|
var isexe = require_isexe();
|
|
2654
|
-
var { join:
|
|
2654
|
+
var { join: join15, delimiter: delimiter2, sep: sep3, posix } = require("path");
|
|
2655
2655
|
var isWindows = process.platform === "win32";
|
|
2656
2656
|
var rSlash = new RegExp(`[${posix.sep}${sep3 === posix.sep ? "" : sep3}]`.replace(/(\\)/g, "\\$1"));
|
|
2657
2657
|
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
@@ -2680,7 +2680,7 @@ var require_lib = __commonJS({
|
|
|
2680
2680
|
var getPathPart = (raw, cmd) => {
|
|
2681
2681
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
2682
2682
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
2683
|
-
return prefix +
|
|
2683
|
+
return prefix + join15(pathPart, cmd);
|
|
2684
2684
|
};
|
|
2685
2685
|
var which2 = async (cmd, opt = {}) => {
|
|
2686
2686
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -2735,6 +2735,1156 @@ var require_lib = __commonJS({
|
|
|
2735
2735
|
}
|
|
2736
2736
|
});
|
|
2737
2737
|
|
|
2738
|
+
// ../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js
|
|
2739
|
+
var require_semver2 = __commonJS({
|
|
2740
|
+
"../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js"(exports, module2) {
|
|
2741
|
+
exports = module2.exports = SemVer;
|
|
2742
|
+
var debug13;
|
|
2743
|
+
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
2744
|
+
debug13 = function() {
|
|
2745
|
+
var args = Array.prototype.slice.call(arguments, 0);
|
|
2746
|
+
args.unshift("SEMVER");
|
|
2747
|
+
console.log.apply(console, args);
|
|
2748
|
+
};
|
|
2749
|
+
} else {
|
|
2750
|
+
debug13 = function() {
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
exports.SEMVER_SPEC_VERSION = "2.0.0";
|
|
2754
|
+
var MAX_LENGTH = 256;
|
|
2755
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
2756
|
+
9007199254740991;
|
|
2757
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
2758
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
2759
|
+
var re = exports.re = [];
|
|
2760
|
+
var safeRe = exports.safeRe = [];
|
|
2761
|
+
var src = exports.src = [];
|
|
2762
|
+
var t = exports.tokens = {};
|
|
2763
|
+
var R = 0;
|
|
2764
|
+
function tok(n) {
|
|
2765
|
+
t[n] = R++;
|
|
2766
|
+
}
|
|
2767
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
2768
|
+
var safeRegexReplacements = [
|
|
2769
|
+
["\\s", 1],
|
|
2770
|
+
["\\d", MAX_LENGTH],
|
|
2771
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
2772
|
+
];
|
|
2773
|
+
function makeSafeRe(value) {
|
|
2774
|
+
for (var i2 = 0; i2 < safeRegexReplacements.length; i2++) {
|
|
2775
|
+
var token = safeRegexReplacements[i2][0];
|
|
2776
|
+
var max = safeRegexReplacements[i2][1];
|
|
2777
|
+
value = value.split(token + "*").join(token + "{0," + max + "}").split(token + "+").join(token + "{1," + max + "}");
|
|
2778
|
+
}
|
|
2779
|
+
return value;
|
|
2780
|
+
}
|
|
2781
|
+
tok("NUMERICIDENTIFIER");
|
|
2782
|
+
src[t.NUMERICIDENTIFIER] = "0|[1-9]\\d*";
|
|
2783
|
+
tok("NUMERICIDENTIFIERLOOSE");
|
|
2784
|
+
src[t.NUMERICIDENTIFIERLOOSE] = "\\d+";
|
|
2785
|
+
tok("NONNUMERICIDENTIFIER");
|
|
2786
|
+
src[t.NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-]" + LETTERDASHNUMBER + "*";
|
|
2787
|
+
tok("MAINVERSION");
|
|
2788
|
+
src[t.MAINVERSION] = "(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")";
|
|
2789
|
+
tok("MAINVERSIONLOOSE");
|
|
2790
|
+
src[t.MAINVERSIONLOOSE] = "(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")";
|
|
2791
|
+
tok("PRERELEASEIDENTIFIER");
|
|
2792
|
+
src[t.PRERELEASEIDENTIFIER] = "(?:" + src[t.NUMERICIDENTIFIER] + "|" + src[t.NONNUMERICIDENTIFIER] + ")";
|
|
2793
|
+
tok("PRERELEASEIDENTIFIERLOOSE");
|
|
2794
|
+
src[t.PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[t.NUMERICIDENTIFIERLOOSE] + "|" + src[t.NONNUMERICIDENTIFIER] + ")";
|
|
2795
|
+
tok("PRERELEASE");
|
|
2796
|
+
src[t.PRERELEASE] = "(?:-(" + src[t.PRERELEASEIDENTIFIER] + "(?:\\." + src[t.PRERELEASEIDENTIFIER] + ")*))";
|
|
2797
|
+
tok("PRERELEASELOOSE");
|
|
2798
|
+
src[t.PRERELEASELOOSE] = "(?:-?(" + src[t.PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[t.PRERELEASEIDENTIFIERLOOSE] + ")*))";
|
|
2799
|
+
tok("BUILDIDENTIFIER");
|
|
2800
|
+
src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + "+";
|
|
2801
|
+
tok("BUILD");
|
|
2802
|
+
src[t.BUILD] = "(?:\\+(" + src[t.BUILDIDENTIFIER] + "(?:\\." + src[t.BUILDIDENTIFIER] + ")*))";
|
|
2803
|
+
tok("FULL");
|
|
2804
|
+
tok("FULLPLAIN");
|
|
2805
|
+
src[t.FULLPLAIN] = "v?" + src[t.MAINVERSION] + src[t.PRERELEASE] + "?" + src[t.BUILD] + "?";
|
|
2806
|
+
src[t.FULL] = "^" + src[t.FULLPLAIN] + "$";
|
|
2807
|
+
tok("LOOSEPLAIN");
|
|
2808
|
+
src[t.LOOSEPLAIN] = "[v=\\s]*" + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + "?" + src[t.BUILD] + "?";
|
|
2809
|
+
tok("LOOSE");
|
|
2810
|
+
src[t.LOOSE] = "^" + src[t.LOOSEPLAIN] + "$";
|
|
2811
|
+
tok("GTLT");
|
|
2812
|
+
src[t.GTLT] = "((?:<|>)?=?)";
|
|
2813
|
+
tok("XRANGEIDENTIFIERLOOSE");
|
|
2814
|
+
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
|
|
2815
|
+
tok("XRANGEIDENTIFIER");
|
|
2816
|
+
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + "|x|X|\\*";
|
|
2817
|
+
tok("XRANGEPLAIN");
|
|
2818
|
+
src[t.XRANGEPLAIN] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:" + src[t.PRERELEASE] + ")?" + src[t.BUILD] + "?)?)?";
|
|
2819
|
+
tok("XRANGEPLAINLOOSE");
|
|
2820
|
+
src[t.XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:" + src[t.PRERELEASELOOSE] + ")?" + src[t.BUILD] + "?)?)?";
|
|
2821
|
+
tok("XRANGE");
|
|
2822
|
+
src[t.XRANGE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAIN] + "$";
|
|
2823
|
+
tok("XRANGELOOSE");
|
|
2824
|
+
src[t.XRANGELOOSE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAINLOOSE] + "$";
|
|
2825
|
+
tok("COERCE");
|
|
2826
|
+
src[t.COERCE] = "(^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])";
|
|
2827
|
+
tok("COERCERTL");
|
|
2828
|
+
re[t.COERCERTL] = new RegExp(src[t.COERCE], "g");
|
|
2829
|
+
safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), "g");
|
|
2830
|
+
tok("LONETILDE");
|
|
2831
|
+
src[t.LONETILDE] = "(?:~>?)";
|
|
2832
|
+
tok("TILDETRIM");
|
|
2833
|
+
src[t.TILDETRIM] = "(\\s*)" + src[t.LONETILDE] + "\\s+";
|
|
2834
|
+
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], "g");
|
|
2835
|
+
safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), "g");
|
|
2836
|
+
var tildeTrimReplace = "$1~";
|
|
2837
|
+
tok("TILDE");
|
|
2838
|
+
src[t.TILDE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAIN] + "$";
|
|
2839
|
+
tok("TILDELOOSE");
|
|
2840
|
+
src[t.TILDELOOSE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + "$";
|
|
2841
|
+
tok("LONECARET");
|
|
2842
|
+
src[t.LONECARET] = "(?:\\^)";
|
|
2843
|
+
tok("CARETTRIM");
|
|
2844
|
+
src[t.CARETTRIM] = "(\\s*)" + src[t.LONECARET] + "\\s+";
|
|
2845
|
+
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], "g");
|
|
2846
|
+
safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), "g");
|
|
2847
|
+
var caretTrimReplace = "$1^";
|
|
2848
|
+
tok("CARET");
|
|
2849
|
+
src[t.CARET] = "^" + src[t.LONECARET] + src[t.XRANGEPLAIN] + "$";
|
|
2850
|
+
tok("CARETLOOSE");
|
|
2851
|
+
src[t.CARETLOOSE] = "^" + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + "$";
|
|
2852
|
+
tok("COMPARATORLOOSE");
|
|
2853
|
+
src[t.COMPARATORLOOSE] = "^" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + ")$|^$";
|
|
2854
|
+
tok("COMPARATOR");
|
|
2855
|
+
src[t.COMPARATOR] = "^" + src[t.GTLT] + "\\s*(" + src[t.FULLPLAIN] + ")$|^$";
|
|
2856
|
+
tok("COMPARATORTRIM");
|
|
2857
|
+
src[t.COMPARATORTRIM] = "(\\s*)" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + "|" + src[t.XRANGEPLAIN] + ")";
|
|
2858
|
+
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], "g");
|
|
2859
|
+
safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), "g");
|
|
2860
|
+
var comparatorTrimReplace = "$1$2$3";
|
|
2861
|
+
tok("HYPHENRANGE");
|
|
2862
|
+
src[t.HYPHENRANGE] = "^\\s*(" + src[t.XRANGEPLAIN] + ")\\s+-\\s+(" + src[t.XRANGEPLAIN] + ")\\s*$";
|
|
2863
|
+
tok("HYPHENRANGELOOSE");
|
|
2864
|
+
src[t.HYPHENRANGELOOSE] = "^\\s*(" + src[t.XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[t.XRANGEPLAINLOOSE] + ")\\s*$";
|
|
2865
|
+
tok("STAR");
|
|
2866
|
+
src[t.STAR] = "(<|>)?=?\\s*\\*";
|
|
2867
|
+
for (i = 0; i < R; i++) {
|
|
2868
|
+
debug13(i, src[i]);
|
|
2869
|
+
if (!re[i]) {
|
|
2870
|
+
re[i] = new RegExp(src[i]);
|
|
2871
|
+
safeRe[i] = new RegExp(makeSafeRe(src[i]));
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
var i;
|
|
2875
|
+
exports.parse = parse2;
|
|
2876
|
+
function parse2(version2, options) {
|
|
2877
|
+
if (!options || typeof options !== "object") {
|
|
2878
|
+
options = {
|
|
2879
|
+
loose: !!options,
|
|
2880
|
+
includePrerelease: false
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
if (version2 instanceof SemVer) {
|
|
2884
|
+
return version2;
|
|
2885
|
+
}
|
|
2886
|
+
if (typeof version2 !== "string") {
|
|
2887
|
+
return null;
|
|
2888
|
+
}
|
|
2889
|
+
if (version2.length > MAX_LENGTH) {
|
|
2890
|
+
return null;
|
|
2891
|
+
}
|
|
2892
|
+
var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL];
|
|
2893
|
+
if (!r.test(version2)) {
|
|
2894
|
+
return null;
|
|
2895
|
+
}
|
|
2896
|
+
try {
|
|
2897
|
+
return new SemVer(version2, options);
|
|
2898
|
+
} catch (er) {
|
|
2899
|
+
return null;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
exports.valid = valid;
|
|
2903
|
+
function valid(version2, options) {
|
|
2904
|
+
var v = parse2(version2, options);
|
|
2905
|
+
return v ? v.version : null;
|
|
2906
|
+
}
|
|
2907
|
+
exports.clean = clean;
|
|
2908
|
+
function clean(version2, options) {
|
|
2909
|
+
var s = parse2(version2.trim().replace(/^[=v]+/, ""), options);
|
|
2910
|
+
return s ? s.version : null;
|
|
2911
|
+
}
|
|
2912
|
+
exports.SemVer = SemVer;
|
|
2913
|
+
function SemVer(version2, options) {
|
|
2914
|
+
if (!options || typeof options !== "object") {
|
|
2915
|
+
options = {
|
|
2916
|
+
loose: !!options,
|
|
2917
|
+
includePrerelease: false
|
|
2918
|
+
};
|
|
2919
|
+
}
|
|
2920
|
+
if (version2 instanceof SemVer) {
|
|
2921
|
+
if (version2.loose === options.loose) {
|
|
2922
|
+
return version2;
|
|
2923
|
+
} else {
|
|
2924
|
+
version2 = version2.version;
|
|
2925
|
+
}
|
|
2926
|
+
} else if (typeof version2 !== "string") {
|
|
2927
|
+
throw new TypeError("Invalid Version: " + version2);
|
|
2928
|
+
}
|
|
2929
|
+
if (version2.length > MAX_LENGTH) {
|
|
2930
|
+
throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
|
|
2931
|
+
}
|
|
2932
|
+
if (!(this instanceof SemVer)) {
|
|
2933
|
+
return new SemVer(version2, options);
|
|
2934
|
+
}
|
|
2935
|
+
debug13("SemVer", version2, options);
|
|
2936
|
+
this.options = options;
|
|
2937
|
+
this.loose = !!options.loose;
|
|
2938
|
+
var m = version2.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]);
|
|
2939
|
+
if (!m) {
|
|
2940
|
+
throw new TypeError("Invalid Version: " + version2);
|
|
2941
|
+
}
|
|
2942
|
+
this.raw = version2;
|
|
2943
|
+
this.major = +m[1];
|
|
2944
|
+
this.minor = +m[2];
|
|
2945
|
+
this.patch = +m[3];
|
|
2946
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
2947
|
+
throw new TypeError("Invalid major version");
|
|
2948
|
+
}
|
|
2949
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
2950
|
+
throw new TypeError("Invalid minor version");
|
|
2951
|
+
}
|
|
2952
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
2953
|
+
throw new TypeError("Invalid patch version");
|
|
2954
|
+
}
|
|
2955
|
+
if (!m[4]) {
|
|
2956
|
+
this.prerelease = [];
|
|
2957
|
+
} else {
|
|
2958
|
+
this.prerelease = m[4].split(".").map(function(id) {
|
|
2959
|
+
if (/^[0-9]+$/.test(id)) {
|
|
2960
|
+
var num = +id;
|
|
2961
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
2962
|
+
return num;
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
return id;
|
|
2966
|
+
});
|
|
2967
|
+
}
|
|
2968
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
2969
|
+
this.format();
|
|
2970
|
+
}
|
|
2971
|
+
SemVer.prototype.format = function() {
|
|
2972
|
+
this.version = this.major + "." + this.minor + "." + this.patch;
|
|
2973
|
+
if (this.prerelease.length) {
|
|
2974
|
+
this.version += "-" + this.prerelease.join(".");
|
|
2975
|
+
}
|
|
2976
|
+
return this.version;
|
|
2977
|
+
};
|
|
2978
|
+
SemVer.prototype.toString = function() {
|
|
2979
|
+
return this.version;
|
|
2980
|
+
};
|
|
2981
|
+
SemVer.prototype.compare = function(other) {
|
|
2982
|
+
debug13("SemVer.compare", this.version, this.options, other);
|
|
2983
|
+
if (!(other instanceof SemVer)) {
|
|
2984
|
+
other = new SemVer(other, this.options);
|
|
2985
|
+
}
|
|
2986
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
2987
|
+
};
|
|
2988
|
+
SemVer.prototype.compareMain = function(other) {
|
|
2989
|
+
if (!(other instanceof SemVer)) {
|
|
2990
|
+
other = new SemVer(other, this.options);
|
|
2991
|
+
}
|
|
2992
|
+
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
|
|
2993
|
+
};
|
|
2994
|
+
SemVer.prototype.comparePre = function(other) {
|
|
2995
|
+
if (!(other instanceof SemVer)) {
|
|
2996
|
+
other = new SemVer(other, this.options);
|
|
2997
|
+
}
|
|
2998
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
2999
|
+
return -1;
|
|
3000
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
3001
|
+
return 1;
|
|
3002
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
3003
|
+
return 0;
|
|
3004
|
+
}
|
|
3005
|
+
var i2 = 0;
|
|
3006
|
+
do {
|
|
3007
|
+
var a = this.prerelease[i2];
|
|
3008
|
+
var b = other.prerelease[i2];
|
|
3009
|
+
debug13("prerelease compare", i2, a, b);
|
|
3010
|
+
if (a === void 0 && b === void 0) {
|
|
3011
|
+
return 0;
|
|
3012
|
+
} else if (b === void 0) {
|
|
3013
|
+
return 1;
|
|
3014
|
+
} else if (a === void 0) {
|
|
3015
|
+
return -1;
|
|
3016
|
+
} else if (a === b) {
|
|
3017
|
+
continue;
|
|
3018
|
+
} else {
|
|
3019
|
+
return compareIdentifiers(a, b);
|
|
3020
|
+
}
|
|
3021
|
+
} while (++i2);
|
|
3022
|
+
};
|
|
3023
|
+
SemVer.prototype.compareBuild = function(other) {
|
|
3024
|
+
if (!(other instanceof SemVer)) {
|
|
3025
|
+
other = new SemVer(other, this.options);
|
|
3026
|
+
}
|
|
3027
|
+
var i2 = 0;
|
|
3028
|
+
do {
|
|
3029
|
+
var a = this.build[i2];
|
|
3030
|
+
var b = other.build[i2];
|
|
3031
|
+
debug13("prerelease compare", i2, a, b);
|
|
3032
|
+
if (a === void 0 && b === void 0) {
|
|
3033
|
+
return 0;
|
|
3034
|
+
} else if (b === void 0) {
|
|
3035
|
+
return 1;
|
|
3036
|
+
} else if (a === void 0) {
|
|
3037
|
+
return -1;
|
|
3038
|
+
} else if (a === b) {
|
|
3039
|
+
continue;
|
|
3040
|
+
} else {
|
|
3041
|
+
return compareIdentifiers(a, b);
|
|
3042
|
+
}
|
|
3043
|
+
} while (++i2);
|
|
3044
|
+
};
|
|
3045
|
+
SemVer.prototype.inc = function(release, identifier) {
|
|
3046
|
+
switch (release) {
|
|
3047
|
+
case "premajor":
|
|
3048
|
+
this.prerelease.length = 0;
|
|
3049
|
+
this.patch = 0;
|
|
3050
|
+
this.minor = 0;
|
|
3051
|
+
this.major++;
|
|
3052
|
+
this.inc("pre", identifier);
|
|
3053
|
+
break;
|
|
3054
|
+
case "preminor":
|
|
3055
|
+
this.prerelease.length = 0;
|
|
3056
|
+
this.patch = 0;
|
|
3057
|
+
this.minor++;
|
|
3058
|
+
this.inc("pre", identifier);
|
|
3059
|
+
break;
|
|
3060
|
+
case "prepatch":
|
|
3061
|
+
this.prerelease.length = 0;
|
|
3062
|
+
this.inc("patch", identifier);
|
|
3063
|
+
this.inc("pre", identifier);
|
|
3064
|
+
break;
|
|
3065
|
+
case "prerelease":
|
|
3066
|
+
if (this.prerelease.length === 0) {
|
|
3067
|
+
this.inc("patch", identifier);
|
|
3068
|
+
}
|
|
3069
|
+
this.inc("pre", identifier);
|
|
3070
|
+
break;
|
|
3071
|
+
case "major":
|
|
3072
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
3073
|
+
this.major++;
|
|
3074
|
+
}
|
|
3075
|
+
this.minor = 0;
|
|
3076
|
+
this.patch = 0;
|
|
3077
|
+
this.prerelease = [];
|
|
3078
|
+
break;
|
|
3079
|
+
case "minor":
|
|
3080
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
3081
|
+
this.minor++;
|
|
3082
|
+
}
|
|
3083
|
+
this.patch = 0;
|
|
3084
|
+
this.prerelease = [];
|
|
3085
|
+
break;
|
|
3086
|
+
case "patch":
|
|
3087
|
+
if (this.prerelease.length === 0) {
|
|
3088
|
+
this.patch++;
|
|
3089
|
+
}
|
|
3090
|
+
this.prerelease = [];
|
|
3091
|
+
break;
|
|
3092
|
+
case "pre":
|
|
3093
|
+
if (this.prerelease.length === 0) {
|
|
3094
|
+
this.prerelease = [0];
|
|
3095
|
+
} else {
|
|
3096
|
+
var i2 = this.prerelease.length;
|
|
3097
|
+
while (--i2 >= 0) {
|
|
3098
|
+
if (typeof this.prerelease[i2] === "number") {
|
|
3099
|
+
this.prerelease[i2]++;
|
|
3100
|
+
i2 = -2;
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
if (i2 === -1) {
|
|
3104
|
+
this.prerelease.push(0);
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
if (identifier) {
|
|
3108
|
+
if (this.prerelease[0] === identifier) {
|
|
3109
|
+
if (isNaN(this.prerelease[1])) {
|
|
3110
|
+
this.prerelease = [identifier, 0];
|
|
3111
|
+
}
|
|
3112
|
+
} else {
|
|
3113
|
+
this.prerelease = [identifier, 0];
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
break;
|
|
3117
|
+
default:
|
|
3118
|
+
throw new Error("invalid increment argument: " + release);
|
|
3119
|
+
}
|
|
3120
|
+
this.format();
|
|
3121
|
+
this.raw = this.version;
|
|
3122
|
+
return this;
|
|
3123
|
+
};
|
|
3124
|
+
exports.inc = inc;
|
|
3125
|
+
function inc(version2, release, loose, identifier) {
|
|
3126
|
+
if (typeof loose === "string") {
|
|
3127
|
+
identifier = loose;
|
|
3128
|
+
loose = void 0;
|
|
3129
|
+
}
|
|
3130
|
+
try {
|
|
3131
|
+
return new SemVer(version2, loose).inc(release, identifier).version;
|
|
3132
|
+
} catch (er) {
|
|
3133
|
+
return null;
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
exports.diff = diff;
|
|
3137
|
+
function diff(version1, version2) {
|
|
3138
|
+
if (eq(version1, version2)) {
|
|
3139
|
+
return null;
|
|
3140
|
+
} else {
|
|
3141
|
+
var v1 = parse2(version1);
|
|
3142
|
+
var v2 = parse2(version2);
|
|
3143
|
+
var prefix = "";
|
|
3144
|
+
if (v1.prerelease.length || v2.prerelease.length) {
|
|
3145
|
+
prefix = "pre";
|
|
3146
|
+
var defaultResult = "prerelease";
|
|
3147
|
+
}
|
|
3148
|
+
for (var key in v1) {
|
|
3149
|
+
if (key === "major" || key === "minor" || key === "patch") {
|
|
3150
|
+
if (v1[key] !== v2[key]) {
|
|
3151
|
+
return prefix + key;
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
return defaultResult;
|
|
3156
|
+
}
|
|
3157
|
+
}
|
|
3158
|
+
exports.compareIdentifiers = compareIdentifiers;
|
|
3159
|
+
var numeric = /^[0-9]+$/;
|
|
3160
|
+
function compareIdentifiers(a, b) {
|
|
3161
|
+
var anum = numeric.test(a);
|
|
3162
|
+
var bnum = numeric.test(b);
|
|
3163
|
+
if (anum && bnum) {
|
|
3164
|
+
a = +a;
|
|
3165
|
+
b = +b;
|
|
3166
|
+
}
|
|
3167
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
3168
|
+
}
|
|
3169
|
+
exports.rcompareIdentifiers = rcompareIdentifiers;
|
|
3170
|
+
function rcompareIdentifiers(a, b) {
|
|
3171
|
+
return compareIdentifiers(b, a);
|
|
3172
|
+
}
|
|
3173
|
+
exports.major = major;
|
|
3174
|
+
function major(a, loose) {
|
|
3175
|
+
return new SemVer(a, loose).major;
|
|
3176
|
+
}
|
|
3177
|
+
exports.minor = minor;
|
|
3178
|
+
function minor(a, loose) {
|
|
3179
|
+
return new SemVer(a, loose).minor;
|
|
3180
|
+
}
|
|
3181
|
+
exports.patch = patch;
|
|
3182
|
+
function patch(a, loose) {
|
|
3183
|
+
return new SemVer(a, loose).patch;
|
|
3184
|
+
}
|
|
3185
|
+
exports.compare = compare;
|
|
3186
|
+
function compare(a, b, loose) {
|
|
3187
|
+
return new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
3188
|
+
}
|
|
3189
|
+
exports.compareLoose = compareLoose;
|
|
3190
|
+
function compareLoose(a, b) {
|
|
3191
|
+
return compare(a, b, true);
|
|
3192
|
+
}
|
|
3193
|
+
exports.compareBuild = compareBuild;
|
|
3194
|
+
function compareBuild(a, b, loose) {
|
|
3195
|
+
var versionA = new SemVer(a, loose);
|
|
3196
|
+
var versionB = new SemVer(b, loose);
|
|
3197
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
3198
|
+
}
|
|
3199
|
+
exports.rcompare = rcompare;
|
|
3200
|
+
function rcompare(a, b, loose) {
|
|
3201
|
+
return compare(b, a, loose);
|
|
3202
|
+
}
|
|
3203
|
+
exports.sort = sort;
|
|
3204
|
+
function sort(list, loose) {
|
|
3205
|
+
return list.sort(function(a, b) {
|
|
3206
|
+
return exports.compareBuild(a, b, loose);
|
|
3207
|
+
});
|
|
3208
|
+
}
|
|
3209
|
+
exports.rsort = rsort;
|
|
3210
|
+
function rsort(list, loose) {
|
|
3211
|
+
return list.sort(function(a, b) {
|
|
3212
|
+
return exports.compareBuild(b, a, loose);
|
|
3213
|
+
});
|
|
3214
|
+
}
|
|
3215
|
+
exports.gt = gt;
|
|
3216
|
+
function gt(a, b, loose) {
|
|
3217
|
+
return compare(a, b, loose) > 0;
|
|
3218
|
+
}
|
|
3219
|
+
exports.lt = lt;
|
|
3220
|
+
function lt(a, b, loose) {
|
|
3221
|
+
return compare(a, b, loose) < 0;
|
|
3222
|
+
}
|
|
3223
|
+
exports.eq = eq;
|
|
3224
|
+
function eq(a, b, loose) {
|
|
3225
|
+
return compare(a, b, loose) === 0;
|
|
3226
|
+
}
|
|
3227
|
+
exports.neq = neq;
|
|
3228
|
+
function neq(a, b, loose) {
|
|
3229
|
+
return compare(a, b, loose) !== 0;
|
|
3230
|
+
}
|
|
3231
|
+
exports.gte = gte;
|
|
3232
|
+
function gte(a, b, loose) {
|
|
3233
|
+
return compare(a, b, loose) >= 0;
|
|
3234
|
+
}
|
|
3235
|
+
exports.lte = lte;
|
|
3236
|
+
function lte(a, b, loose) {
|
|
3237
|
+
return compare(a, b, loose) <= 0;
|
|
3238
|
+
}
|
|
3239
|
+
exports.cmp = cmp;
|
|
3240
|
+
function cmp(a, op, b, loose) {
|
|
3241
|
+
switch (op) {
|
|
3242
|
+
case "===":
|
|
3243
|
+
if (typeof a === "object")
|
|
3244
|
+
a = a.version;
|
|
3245
|
+
if (typeof b === "object")
|
|
3246
|
+
b = b.version;
|
|
3247
|
+
return a === b;
|
|
3248
|
+
case "!==":
|
|
3249
|
+
if (typeof a === "object")
|
|
3250
|
+
a = a.version;
|
|
3251
|
+
if (typeof b === "object")
|
|
3252
|
+
b = b.version;
|
|
3253
|
+
return a !== b;
|
|
3254
|
+
case "":
|
|
3255
|
+
case "=":
|
|
3256
|
+
case "==":
|
|
3257
|
+
return eq(a, b, loose);
|
|
3258
|
+
case "!=":
|
|
3259
|
+
return neq(a, b, loose);
|
|
3260
|
+
case ">":
|
|
3261
|
+
return gt(a, b, loose);
|
|
3262
|
+
case ">=":
|
|
3263
|
+
return gte(a, b, loose);
|
|
3264
|
+
case "<":
|
|
3265
|
+
return lt(a, b, loose);
|
|
3266
|
+
case "<=":
|
|
3267
|
+
return lte(a, b, loose);
|
|
3268
|
+
default:
|
|
3269
|
+
throw new TypeError("Invalid operator: " + op);
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
exports.Comparator = Comparator;
|
|
3273
|
+
function Comparator(comp, options) {
|
|
3274
|
+
if (!options || typeof options !== "object") {
|
|
3275
|
+
options = {
|
|
3276
|
+
loose: !!options,
|
|
3277
|
+
includePrerelease: false
|
|
3278
|
+
};
|
|
3279
|
+
}
|
|
3280
|
+
if (comp instanceof Comparator) {
|
|
3281
|
+
if (comp.loose === !!options.loose) {
|
|
3282
|
+
return comp;
|
|
3283
|
+
} else {
|
|
3284
|
+
comp = comp.value;
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
if (!(this instanceof Comparator)) {
|
|
3288
|
+
return new Comparator(comp, options);
|
|
3289
|
+
}
|
|
3290
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
3291
|
+
debug13("comparator", comp, options);
|
|
3292
|
+
this.options = options;
|
|
3293
|
+
this.loose = !!options.loose;
|
|
3294
|
+
this.parse(comp);
|
|
3295
|
+
if (this.semver === ANY) {
|
|
3296
|
+
this.value = "";
|
|
3297
|
+
} else {
|
|
3298
|
+
this.value = this.operator + this.semver.version;
|
|
3299
|
+
}
|
|
3300
|
+
debug13("comp", this);
|
|
3301
|
+
}
|
|
3302
|
+
var ANY = {};
|
|
3303
|
+
Comparator.prototype.parse = function(comp) {
|
|
3304
|
+
var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR];
|
|
3305
|
+
var m = comp.match(r);
|
|
3306
|
+
if (!m) {
|
|
3307
|
+
throw new TypeError("Invalid comparator: " + comp);
|
|
3308
|
+
}
|
|
3309
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
3310
|
+
if (this.operator === "=") {
|
|
3311
|
+
this.operator = "";
|
|
3312
|
+
}
|
|
3313
|
+
if (!m[2]) {
|
|
3314
|
+
this.semver = ANY;
|
|
3315
|
+
} else {
|
|
3316
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
Comparator.prototype.toString = function() {
|
|
3320
|
+
return this.value;
|
|
3321
|
+
};
|
|
3322
|
+
Comparator.prototype.test = function(version2) {
|
|
3323
|
+
debug13("Comparator.test", version2, this.options.loose);
|
|
3324
|
+
if (this.semver === ANY || version2 === ANY) {
|
|
3325
|
+
return true;
|
|
3326
|
+
}
|
|
3327
|
+
if (typeof version2 === "string") {
|
|
3328
|
+
try {
|
|
3329
|
+
version2 = new SemVer(version2, this.options);
|
|
3330
|
+
} catch (er) {
|
|
3331
|
+
return false;
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
return cmp(version2, this.operator, this.semver, this.options);
|
|
3335
|
+
};
|
|
3336
|
+
Comparator.prototype.intersects = function(comp, options) {
|
|
3337
|
+
if (!(comp instanceof Comparator)) {
|
|
3338
|
+
throw new TypeError("a Comparator is required");
|
|
3339
|
+
}
|
|
3340
|
+
if (!options || typeof options !== "object") {
|
|
3341
|
+
options = {
|
|
3342
|
+
loose: !!options,
|
|
3343
|
+
includePrerelease: false
|
|
3344
|
+
};
|
|
3345
|
+
}
|
|
3346
|
+
var rangeTmp;
|
|
3347
|
+
if (this.operator === "") {
|
|
3348
|
+
if (this.value === "") {
|
|
3349
|
+
return true;
|
|
3350
|
+
}
|
|
3351
|
+
rangeTmp = new Range(comp.value, options);
|
|
3352
|
+
return satisfies(this.value, rangeTmp, options);
|
|
3353
|
+
} else if (comp.operator === "") {
|
|
3354
|
+
if (comp.value === "") {
|
|
3355
|
+
return true;
|
|
3356
|
+
}
|
|
3357
|
+
rangeTmp = new Range(this.value, options);
|
|
3358
|
+
return satisfies(comp.semver, rangeTmp, options);
|
|
3359
|
+
}
|
|
3360
|
+
var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
|
|
3361
|
+
var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
|
|
3362
|
+
var sameSemVer = this.semver.version === comp.semver.version;
|
|
3363
|
+
var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<=");
|
|
3364
|
+
var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && ((this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<"));
|
|
3365
|
+
var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && ((this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">"));
|
|
3366
|
+
return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
|
|
3367
|
+
};
|
|
3368
|
+
exports.Range = Range;
|
|
3369
|
+
function Range(range, options) {
|
|
3370
|
+
if (!options || typeof options !== "object") {
|
|
3371
|
+
options = {
|
|
3372
|
+
loose: !!options,
|
|
3373
|
+
includePrerelease: false
|
|
3374
|
+
};
|
|
3375
|
+
}
|
|
3376
|
+
if (range instanceof Range) {
|
|
3377
|
+
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
3378
|
+
return range;
|
|
3379
|
+
} else {
|
|
3380
|
+
return new Range(range.raw, options);
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
if (range instanceof Comparator) {
|
|
3384
|
+
return new Range(range.value, options);
|
|
3385
|
+
}
|
|
3386
|
+
if (!(this instanceof Range)) {
|
|
3387
|
+
return new Range(range, options);
|
|
3388
|
+
}
|
|
3389
|
+
this.options = options;
|
|
3390
|
+
this.loose = !!options.loose;
|
|
3391
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
3392
|
+
this.raw = range.trim().split(/\s+/).join(" ");
|
|
3393
|
+
this.set = this.raw.split("||").map(function(range2) {
|
|
3394
|
+
return this.parseRange(range2.trim());
|
|
3395
|
+
}, this).filter(function(c) {
|
|
3396
|
+
return c.length;
|
|
3397
|
+
});
|
|
3398
|
+
if (!this.set.length) {
|
|
3399
|
+
throw new TypeError("Invalid SemVer Range: " + this.raw);
|
|
3400
|
+
}
|
|
3401
|
+
this.format();
|
|
3402
|
+
}
|
|
3403
|
+
Range.prototype.format = function() {
|
|
3404
|
+
this.range = this.set.map(function(comps) {
|
|
3405
|
+
return comps.join(" ").trim();
|
|
3406
|
+
}).join("||").trim();
|
|
3407
|
+
return this.range;
|
|
3408
|
+
};
|
|
3409
|
+
Range.prototype.toString = function() {
|
|
3410
|
+
return this.range;
|
|
3411
|
+
};
|
|
3412
|
+
Range.prototype.parseRange = function(range) {
|
|
3413
|
+
var loose = this.options.loose;
|
|
3414
|
+
var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE];
|
|
3415
|
+
range = range.replace(hr, hyphenReplace);
|
|
3416
|
+
debug13("hyphen replace", range);
|
|
3417
|
+
range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
3418
|
+
debug13("comparator trim", range, safeRe[t.COMPARATORTRIM]);
|
|
3419
|
+
range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace);
|
|
3420
|
+
range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace);
|
|
3421
|
+
range = range.split(/\s+/).join(" ");
|
|
3422
|
+
var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR];
|
|
3423
|
+
var set = range.split(" ").map(function(comp) {
|
|
3424
|
+
return parseComparator(comp, this.options);
|
|
3425
|
+
}, this).join(" ").split(/\s+/);
|
|
3426
|
+
if (this.options.loose) {
|
|
3427
|
+
set = set.filter(function(comp) {
|
|
3428
|
+
return !!comp.match(compRe);
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
set = set.map(function(comp) {
|
|
3432
|
+
return new Comparator(comp, this.options);
|
|
3433
|
+
}, this);
|
|
3434
|
+
return set;
|
|
3435
|
+
};
|
|
3436
|
+
Range.prototype.intersects = function(range, options) {
|
|
3437
|
+
if (!(range instanceof Range)) {
|
|
3438
|
+
throw new TypeError("a Range is required");
|
|
3439
|
+
}
|
|
3440
|
+
return this.set.some(function(thisComparators) {
|
|
3441
|
+
return isSatisfiable(thisComparators, options) && range.set.some(function(rangeComparators) {
|
|
3442
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every(function(thisComparator) {
|
|
3443
|
+
return rangeComparators.every(function(rangeComparator) {
|
|
3444
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
3445
|
+
});
|
|
3446
|
+
});
|
|
3447
|
+
});
|
|
3448
|
+
});
|
|
3449
|
+
};
|
|
3450
|
+
function isSatisfiable(comparators, options) {
|
|
3451
|
+
var result = true;
|
|
3452
|
+
var remainingComparators = comparators.slice();
|
|
3453
|
+
var testComparator = remainingComparators.pop();
|
|
3454
|
+
while (result && remainingComparators.length) {
|
|
3455
|
+
result = remainingComparators.every(function(otherComparator) {
|
|
3456
|
+
return testComparator.intersects(otherComparator, options);
|
|
3457
|
+
});
|
|
3458
|
+
testComparator = remainingComparators.pop();
|
|
3459
|
+
}
|
|
3460
|
+
return result;
|
|
3461
|
+
}
|
|
3462
|
+
exports.toComparators = toComparators;
|
|
3463
|
+
function toComparators(range, options) {
|
|
3464
|
+
return new Range(range, options).set.map(function(comp) {
|
|
3465
|
+
return comp.map(function(c) {
|
|
3466
|
+
return c.value;
|
|
3467
|
+
}).join(" ").trim().split(" ");
|
|
3468
|
+
});
|
|
3469
|
+
}
|
|
3470
|
+
function parseComparator(comp, options) {
|
|
3471
|
+
debug13("comp", comp, options);
|
|
3472
|
+
comp = replaceCarets(comp, options);
|
|
3473
|
+
debug13("caret", comp);
|
|
3474
|
+
comp = replaceTildes(comp, options);
|
|
3475
|
+
debug13("tildes", comp);
|
|
3476
|
+
comp = replaceXRanges(comp, options);
|
|
3477
|
+
debug13("xrange", comp);
|
|
3478
|
+
comp = replaceStars(comp, options);
|
|
3479
|
+
debug13("stars", comp);
|
|
3480
|
+
return comp;
|
|
3481
|
+
}
|
|
3482
|
+
function isX(id) {
|
|
3483
|
+
return !id || id.toLowerCase() === "x" || id === "*";
|
|
3484
|
+
}
|
|
3485
|
+
function replaceTildes(comp, options) {
|
|
3486
|
+
return comp.trim().split(/\s+/).map(function(comp2) {
|
|
3487
|
+
return replaceTilde(comp2, options);
|
|
3488
|
+
}).join(" ");
|
|
3489
|
+
}
|
|
3490
|
+
function replaceTilde(comp, options) {
|
|
3491
|
+
var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE];
|
|
3492
|
+
return comp.replace(r, function(_, M, m, p, pr) {
|
|
3493
|
+
debug13("tilde", comp, _, M, m, p, pr);
|
|
3494
|
+
var ret;
|
|
3495
|
+
if (isX(M)) {
|
|
3496
|
+
ret = "";
|
|
3497
|
+
} else if (isX(m)) {
|
|
3498
|
+
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
|
|
3499
|
+
} else if (isX(p)) {
|
|
3500
|
+
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
3501
|
+
} else if (pr) {
|
|
3502
|
+
debug13("replaceTilde pr", pr);
|
|
3503
|
+
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
|
|
3504
|
+
} else {
|
|
3505
|
+
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
|
|
3506
|
+
}
|
|
3507
|
+
debug13("tilde return", ret);
|
|
3508
|
+
return ret;
|
|
3509
|
+
});
|
|
3510
|
+
}
|
|
3511
|
+
function replaceCarets(comp, options) {
|
|
3512
|
+
return comp.trim().split(/\s+/).map(function(comp2) {
|
|
3513
|
+
return replaceCaret(comp2, options);
|
|
3514
|
+
}).join(" ");
|
|
3515
|
+
}
|
|
3516
|
+
function replaceCaret(comp, options) {
|
|
3517
|
+
debug13("caret", comp, options);
|
|
3518
|
+
var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET];
|
|
3519
|
+
return comp.replace(r, function(_, M, m, p, pr) {
|
|
3520
|
+
debug13("caret", comp, _, M, m, p, pr);
|
|
3521
|
+
var ret;
|
|
3522
|
+
if (isX(M)) {
|
|
3523
|
+
ret = "";
|
|
3524
|
+
} else if (isX(m)) {
|
|
3525
|
+
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
|
|
3526
|
+
} else if (isX(p)) {
|
|
3527
|
+
if (M === "0") {
|
|
3528
|
+
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
3529
|
+
} else {
|
|
3530
|
+
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
|
|
3531
|
+
}
|
|
3532
|
+
} else if (pr) {
|
|
3533
|
+
debug13("replaceCaret pr", pr);
|
|
3534
|
+
if (M === "0") {
|
|
3535
|
+
if (m === "0") {
|
|
3536
|
+
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
|
|
3537
|
+
} else {
|
|
3538
|
+
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
|
|
3539
|
+
}
|
|
3540
|
+
} else {
|
|
3541
|
+
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
|
|
3542
|
+
}
|
|
3543
|
+
} else {
|
|
3544
|
+
debug13("no pr");
|
|
3545
|
+
if (M === "0") {
|
|
3546
|
+
if (m === "0") {
|
|
3547
|
+
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
|
|
3548
|
+
} else {
|
|
3549
|
+
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
|
|
3550
|
+
}
|
|
3551
|
+
} else {
|
|
3552
|
+
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
debug13("caret return", ret);
|
|
3556
|
+
return ret;
|
|
3557
|
+
});
|
|
3558
|
+
}
|
|
3559
|
+
function replaceXRanges(comp, options) {
|
|
3560
|
+
debug13("replaceXRanges", comp, options);
|
|
3561
|
+
return comp.split(/\s+/).map(function(comp2) {
|
|
3562
|
+
return replaceXRange(comp2, options);
|
|
3563
|
+
}).join(" ");
|
|
3564
|
+
}
|
|
3565
|
+
function replaceXRange(comp, options) {
|
|
3566
|
+
comp = comp.trim();
|
|
3567
|
+
var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE];
|
|
3568
|
+
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
|
|
3569
|
+
debug13("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
3570
|
+
var xM = isX(M);
|
|
3571
|
+
var xm = xM || isX(m);
|
|
3572
|
+
var xp = xm || isX(p);
|
|
3573
|
+
var anyX = xp;
|
|
3574
|
+
if (gtlt === "=" && anyX) {
|
|
3575
|
+
gtlt = "";
|
|
3576
|
+
}
|
|
3577
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
3578
|
+
if (xM) {
|
|
3579
|
+
if (gtlt === ">" || gtlt === "<") {
|
|
3580
|
+
ret = "<0.0.0-0";
|
|
3581
|
+
} else {
|
|
3582
|
+
ret = "*";
|
|
3583
|
+
}
|
|
3584
|
+
} else if (gtlt && anyX) {
|
|
3585
|
+
if (xm) {
|
|
3586
|
+
m = 0;
|
|
3587
|
+
}
|
|
3588
|
+
p = 0;
|
|
3589
|
+
if (gtlt === ">") {
|
|
3590
|
+
gtlt = ">=";
|
|
3591
|
+
if (xm) {
|
|
3592
|
+
M = +M + 1;
|
|
3593
|
+
m = 0;
|
|
3594
|
+
p = 0;
|
|
3595
|
+
} else {
|
|
3596
|
+
m = +m + 1;
|
|
3597
|
+
p = 0;
|
|
3598
|
+
}
|
|
3599
|
+
} else if (gtlt === "<=") {
|
|
3600
|
+
gtlt = "<";
|
|
3601
|
+
if (xm) {
|
|
3602
|
+
M = +M + 1;
|
|
3603
|
+
} else {
|
|
3604
|
+
m = +m + 1;
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
ret = gtlt + M + "." + m + "." + p + pr;
|
|
3608
|
+
} else if (xm) {
|
|
3609
|
+
ret = ">=" + M + ".0.0" + pr + " <" + (+M + 1) + ".0.0" + pr;
|
|
3610
|
+
} else if (xp) {
|
|
3611
|
+
ret = ">=" + M + "." + m + ".0" + pr + " <" + M + "." + (+m + 1) + ".0" + pr;
|
|
3612
|
+
}
|
|
3613
|
+
debug13("xRange return", ret);
|
|
3614
|
+
return ret;
|
|
3615
|
+
});
|
|
3616
|
+
}
|
|
3617
|
+
function replaceStars(comp, options) {
|
|
3618
|
+
debug13("replaceStars", comp, options);
|
|
3619
|
+
return comp.trim().replace(safeRe[t.STAR], "");
|
|
3620
|
+
}
|
|
3621
|
+
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
|
|
3622
|
+
if (isX(fM)) {
|
|
3623
|
+
from = "";
|
|
3624
|
+
} else if (isX(fm)) {
|
|
3625
|
+
from = ">=" + fM + ".0.0";
|
|
3626
|
+
} else if (isX(fp)) {
|
|
3627
|
+
from = ">=" + fM + "." + fm + ".0";
|
|
3628
|
+
} else {
|
|
3629
|
+
from = ">=" + from;
|
|
3630
|
+
}
|
|
3631
|
+
if (isX(tM)) {
|
|
3632
|
+
to = "";
|
|
3633
|
+
} else if (isX(tm)) {
|
|
3634
|
+
to = "<" + (+tM + 1) + ".0.0";
|
|
3635
|
+
} else if (isX(tp)) {
|
|
3636
|
+
to = "<" + tM + "." + (+tm + 1) + ".0";
|
|
3637
|
+
} else if (tpr) {
|
|
3638
|
+
to = "<=" + tM + "." + tm + "." + tp + "-" + tpr;
|
|
3639
|
+
} else {
|
|
3640
|
+
to = "<=" + to;
|
|
3641
|
+
}
|
|
3642
|
+
return (from + " " + to).trim();
|
|
3643
|
+
}
|
|
3644
|
+
Range.prototype.test = function(version2) {
|
|
3645
|
+
if (!version2) {
|
|
3646
|
+
return false;
|
|
3647
|
+
}
|
|
3648
|
+
if (typeof version2 === "string") {
|
|
3649
|
+
try {
|
|
3650
|
+
version2 = new SemVer(version2, this.options);
|
|
3651
|
+
} catch (er) {
|
|
3652
|
+
return false;
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
for (var i2 = 0; i2 < this.set.length; i2++) {
|
|
3656
|
+
if (testSet(this.set[i2], version2, this.options)) {
|
|
3657
|
+
return true;
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
return false;
|
|
3661
|
+
};
|
|
3662
|
+
function testSet(set, version2, options) {
|
|
3663
|
+
for (var i2 = 0; i2 < set.length; i2++) {
|
|
3664
|
+
if (!set[i2].test(version2)) {
|
|
3665
|
+
return false;
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3668
|
+
if (version2.prerelease.length && !options.includePrerelease) {
|
|
3669
|
+
for (i2 = 0; i2 < set.length; i2++) {
|
|
3670
|
+
debug13(set[i2].semver);
|
|
3671
|
+
if (set[i2].semver === ANY) {
|
|
3672
|
+
continue;
|
|
3673
|
+
}
|
|
3674
|
+
if (set[i2].semver.prerelease.length > 0) {
|
|
3675
|
+
var allowed = set[i2].semver;
|
|
3676
|
+
if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch) {
|
|
3677
|
+
return true;
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
}
|
|
3681
|
+
return false;
|
|
3682
|
+
}
|
|
3683
|
+
return true;
|
|
3684
|
+
}
|
|
3685
|
+
exports.satisfies = satisfies;
|
|
3686
|
+
function satisfies(version2, range, options) {
|
|
3687
|
+
try {
|
|
3688
|
+
range = new Range(range, options);
|
|
3689
|
+
} catch (er) {
|
|
3690
|
+
return false;
|
|
3691
|
+
}
|
|
3692
|
+
return range.test(version2);
|
|
3693
|
+
}
|
|
3694
|
+
exports.maxSatisfying = maxSatisfying;
|
|
3695
|
+
function maxSatisfying(versions, range, options) {
|
|
3696
|
+
var max = null;
|
|
3697
|
+
var maxSV = null;
|
|
3698
|
+
try {
|
|
3699
|
+
var rangeObj = new Range(range, options);
|
|
3700
|
+
} catch (er) {
|
|
3701
|
+
return null;
|
|
3702
|
+
}
|
|
3703
|
+
versions.forEach(function(v) {
|
|
3704
|
+
if (rangeObj.test(v)) {
|
|
3705
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
3706
|
+
max = v;
|
|
3707
|
+
maxSV = new SemVer(max, options);
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
});
|
|
3711
|
+
return max;
|
|
3712
|
+
}
|
|
3713
|
+
exports.minSatisfying = minSatisfying;
|
|
3714
|
+
function minSatisfying(versions, range, options) {
|
|
3715
|
+
var min = null;
|
|
3716
|
+
var minSV = null;
|
|
3717
|
+
try {
|
|
3718
|
+
var rangeObj = new Range(range, options);
|
|
3719
|
+
} catch (er) {
|
|
3720
|
+
return null;
|
|
3721
|
+
}
|
|
3722
|
+
versions.forEach(function(v) {
|
|
3723
|
+
if (rangeObj.test(v)) {
|
|
3724
|
+
if (!min || minSV.compare(v) === 1) {
|
|
3725
|
+
min = v;
|
|
3726
|
+
minSV = new SemVer(min, options);
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
});
|
|
3730
|
+
return min;
|
|
3731
|
+
}
|
|
3732
|
+
exports.minVersion = minVersion;
|
|
3733
|
+
function minVersion(range, loose) {
|
|
3734
|
+
range = new Range(range, loose);
|
|
3735
|
+
var minver = new SemVer("0.0.0");
|
|
3736
|
+
if (range.test(minver)) {
|
|
3737
|
+
return minver;
|
|
3738
|
+
}
|
|
3739
|
+
minver = new SemVer("0.0.0-0");
|
|
3740
|
+
if (range.test(minver)) {
|
|
3741
|
+
return minver;
|
|
3742
|
+
}
|
|
3743
|
+
minver = null;
|
|
3744
|
+
for (var i2 = 0; i2 < range.set.length; ++i2) {
|
|
3745
|
+
var comparators = range.set[i2];
|
|
3746
|
+
comparators.forEach(function(comparator) {
|
|
3747
|
+
var compver = new SemVer(comparator.semver.version);
|
|
3748
|
+
switch (comparator.operator) {
|
|
3749
|
+
case ">":
|
|
3750
|
+
if (compver.prerelease.length === 0) {
|
|
3751
|
+
compver.patch++;
|
|
3752
|
+
} else {
|
|
3753
|
+
compver.prerelease.push(0);
|
|
3754
|
+
}
|
|
3755
|
+
compver.raw = compver.format();
|
|
3756
|
+
case "":
|
|
3757
|
+
case ">=":
|
|
3758
|
+
if (!minver || gt(minver, compver)) {
|
|
3759
|
+
minver = compver;
|
|
3760
|
+
}
|
|
3761
|
+
break;
|
|
3762
|
+
case "<":
|
|
3763
|
+
case "<=":
|
|
3764
|
+
break;
|
|
3765
|
+
default:
|
|
3766
|
+
throw new Error("Unexpected operation: " + comparator.operator);
|
|
3767
|
+
}
|
|
3768
|
+
});
|
|
3769
|
+
}
|
|
3770
|
+
if (minver && range.test(minver)) {
|
|
3771
|
+
return minver;
|
|
3772
|
+
}
|
|
3773
|
+
return null;
|
|
3774
|
+
}
|
|
3775
|
+
exports.validRange = validRange;
|
|
3776
|
+
function validRange(range, options) {
|
|
3777
|
+
try {
|
|
3778
|
+
return new Range(range, options).range || "*";
|
|
3779
|
+
} catch (er) {
|
|
3780
|
+
return null;
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
exports.ltr = ltr;
|
|
3784
|
+
function ltr(version2, range, options) {
|
|
3785
|
+
return outside(version2, range, "<", options);
|
|
3786
|
+
}
|
|
3787
|
+
exports.gtr = gtr;
|
|
3788
|
+
function gtr(version2, range, options) {
|
|
3789
|
+
return outside(version2, range, ">", options);
|
|
3790
|
+
}
|
|
3791
|
+
exports.outside = outside;
|
|
3792
|
+
function outside(version2, range, hilo, options) {
|
|
3793
|
+
version2 = new SemVer(version2, options);
|
|
3794
|
+
range = new Range(range, options);
|
|
3795
|
+
var gtfn, ltefn, ltfn, comp, ecomp;
|
|
3796
|
+
switch (hilo) {
|
|
3797
|
+
case ">":
|
|
3798
|
+
gtfn = gt;
|
|
3799
|
+
ltefn = lte;
|
|
3800
|
+
ltfn = lt;
|
|
3801
|
+
comp = ">";
|
|
3802
|
+
ecomp = ">=";
|
|
3803
|
+
break;
|
|
3804
|
+
case "<":
|
|
3805
|
+
gtfn = lt;
|
|
3806
|
+
ltefn = gte;
|
|
3807
|
+
ltfn = gt;
|
|
3808
|
+
comp = "<";
|
|
3809
|
+
ecomp = "<=";
|
|
3810
|
+
break;
|
|
3811
|
+
default:
|
|
3812
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
3813
|
+
}
|
|
3814
|
+
if (satisfies(version2, range, options)) {
|
|
3815
|
+
return false;
|
|
3816
|
+
}
|
|
3817
|
+
for (var i2 = 0; i2 < range.set.length; ++i2) {
|
|
3818
|
+
var comparators = range.set[i2];
|
|
3819
|
+
var high = null;
|
|
3820
|
+
var low = null;
|
|
3821
|
+
comparators.forEach(function(comparator) {
|
|
3822
|
+
if (comparator.semver === ANY) {
|
|
3823
|
+
comparator = new Comparator(">=0.0.0");
|
|
3824
|
+
}
|
|
3825
|
+
high = high || comparator;
|
|
3826
|
+
low = low || comparator;
|
|
3827
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
3828
|
+
high = comparator;
|
|
3829
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
3830
|
+
low = comparator;
|
|
3831
|
+
}
|
|
3832
|
+
});
|
|
3833
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
3834
|
+
return false;
|
|
3835
|
+
}
|
|
3836
|
+
if ((!low.operator || low.operator === comp) && ltefn(version2, low.semver)) {
|
|
3837
|
+
return false;
|
|
3838
|
+
} else if (low.operator === ecomp && ltfn(version2, low.semver)) {
|
|
3839
|
+
return false;
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
return true;
|
|
3843
|
+
}
|
|
3844
|
+
exports.prerelease = prerelease;
|
|
3845
|
+
function prerelease(version2, options) {
|
|
3846
|
+
var parsed = parse2(version2, options);
|
|
3847
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
3848
|
+
}
|
|
3849
|
+
exports.intersects = intersects;
|
|
3850
|
+
function intersects(r1, r2, options) {
|
|
3851
|
+
r1 = new Range(r1, options);
|
|
3852
|
+
r2 = new Range(r2, options);
|
|
3853
|
+
return r1.intersects(r2);
|
|
3854
|
+
}
|
|
3855
|
+
exports.coerce = coerce;
|
|
3856
|
+
function coerce(version2, options) {
|
|
3857
|
+
if (version2 instanceof SemVer) {
|
|
3858
|
+
return version2;
|
|
3859
|
+
}
|
|
3860
|
+
if (typeof version2 === "number") {
|
|
3861
|
+
version2 = String(version2);
|
|
3862
|
+
}
|
|
3863
|
+
if (typeof version2 !== "string") {
|
|
3864
|
+
return null;
|
|
3865
|
+
}
|
|
3866
|
+
options = options || {};
|
|
3867
|
+
var match = null;
|
|
3868
|
+
if (!options.rtl) {
|
|
3869
|
+
match = version2.match(safeRe[t.COERCE]);
|
|
3870
|
+
} else {
|
|
3871
|
+
var next;
|
|
3872
|
+
while ((next = safeRe[t.COERCERTL].exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
|
|
3873
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
3874
|
+
match = next;
|
|
3875
|
+
}
|
|
3876
|
+
safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
|
|
3877
|
+
}
|
|
3878
|
+
safeRe[t.COERCERTL].lastIndex = -1;
|
|
3879
|
+
}
|
|
3880
|
+
if (match === null) {
|
|
3881
|
+
return null;
|
|
3882
|
+
}
|
|
3883
|
+
return parse2(match[2] + "." + (match[3] || "0") + "." + (match[4] || "0"), options);
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
});
|
|
3887
|
+
|
|
2738
3888
|
// ../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js
|
|
2739
3889
|
var require_process = __commonJS({
|
|
2740
3890
|
"../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js"(exports, module2) {
|
|
@@ -2762,27 +3912,27 @@ var require_process = __commonJS({
|
|
|
2762
3912
|
var require_filesystem = __commonJS({
|
|
2763
3913
|
"../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js"(exports, module2) {
|
|
2764
3914
|
"use strict";
|
|
2765
|
-
var
|
|
3915
|
+
var fs14 = require("fs");
|
|
2766
3916
|
var LDD_PATH = "/usr/bin/ldd";
|
|
2767
3917
|
var SELF_PATH = "/proc/self/exe";
|
|
2768
3918
|
var MAX_LENGTH = 2048;
|
|
2769
3919
|
var readFileSync2 = (path) => {
|
|
2770
|
-
const fd =
|
|
3920
|
+
const fd = fs14.openSync(path, "r");
|
|
2771
3921
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
2772
|
-
const bytesRead =
|
|
2773
|
-
|
|
3922
|
+
const bytesRead = fs14.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
3923
|
+
fs14.close(fd, () => {
|
|
2774
3924
|
});
|
|
2775
3925
|
return buffer.subarray(0, bytesRead);
|
|
2776
3926
|
};
|
|
2777
3927
|
var readFile2 = (path) => new Promise((resolve3, reject) => {
|
|
2778
|
-
|
|
3928
|
+
fs14.open(path, "r", (err, fd) => {
|
|
2779
3929
|
if (err) {
|
|
2780
3930
|
reject(err);
|
|
2781
3931
|
} else {
|
|
2782
3932
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
2783
|
-
|
|
3933
|
+
fs14.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
2784
3934
|
resolve3(buffer.subarray(0, bytesRead));
|
|
2785
|
-
|
|
3935
|
+
fs14.close(fd, () => {
|
|
2786
3936
|
});
|
|
2787
3937
|
});
|
|
2788
3938
|
}
|
|
@@ -3226,16 +4376,15 @@ __export(src_exports, {
|
|
|
3226
4376
|
});
|
|
3227
4377
|
module.exports = __toCommonJS(src_exports);
|
|
3228
4378
|
var import_assert = __toESM(require("assert"));
|
|
3229
|
-
var
|
|
3230
|
-
var
|
|
3231
|
-
var import_path14 = require("path");
|
|
4379
|
+
var import_fs15 = __toESM(require("fs"));
|
|
4380
|
+
var import_path15 = require("path");
|
|
3232
4381
|
|
|
3233
4382
|
// src/package-versions.ts
|
|
3234
|
-
var VERCEL_RUNTIME_VERSION = "0.
|
|
3235
|
-
var VERCEL_WORKERS_VERSION = "0.0.
|
|
4383
|
+
var VERCEL_RUNTIME_VERSION = "0.15.0";
|
|
4384
|
+
var VERCEL_WORKERS_VERSION = "0.0.25";
|
|
3236
4385
|
|
|
3237
4386
|
// src/index.ts
|
|
3238
|
-
var
|
|
4387
|
+
var import_build_utils19 = require("@vercel/build-utils");
|
|
3239
4388
|
|
|
3240
4389
|
// src/install.ts
|
|
3241
4390
|
var import_execa3 = __toESM(require_execa());
|
|
@@ -3261,8 +4410,10 @@ var import_execa = __toESM(require_execa());
|
|
|
3261
4410
|
var import_fs = __toESM(require("fs"));
|
|
3262
4411
|
var import_os = __toESM(require("os"));
|
|
3263
4412
|
var import_which = __toESM(require_lib());
|
|
4413
|
+
var import_semver = __toESM(require_semver2());
|
|
3264
4414
|
var import_build_utils = require("@vercel/build-utils");
|
|
3265
4415
|
var UV_VERSION = "0.10.11";
|
|
4416
|
+
var MIN_UV_VERSION = "0.9.25";
|
|
3266
4417
|
var UV_PYTHON_PATH_PREFIX = "/uv/python/";
|
|
3267
4418
|
var UV_PYTHON_DOWNLOADS_MODE = "automatic";
|
|
3268
4419
|
var UV_CACHE_DIR_SUBPATH = [".vercel", "python", "cache", "uv"];
|
|
@@ -3518,6 +4669,38 @@ async function findUvBinary(pythonPath) {
|
|
|
3518
4669
|
}
|
|
3519
4670
|
return null;
|
|
3520
4671
|
}
|
|
4672
|
+
function checkUvBinaryVersion(uvPath) {
|
|
4673
|
+
let output;
|
|
4674
|
+
try {
|
|
4675
|
+
output = (0, import_child_process.execFileSync)(uvPath, ["--version"], {
|
|
4676
|
+
encoding: "utf8",
|
|
4677
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
4678
|
+
shell: isWin
|
|
4679
|
+
}).trim();
|
|
4680
|
+
} catch (err) {
|
|
4681
|
+
throw new import_build_utils.NowBuildError({
|
|
4682
|
+
code: "UV_ERROR",
|
|
4683
|
+
link: "https://vercel.link/python-version",
|
|
4684
|
+
message: `Found uv at "${uvPath}" but could not run "uv --version": ${err instanceof Error ? err.message : String(err)}`
|
|
4685
|
+
});
|
|
4686
|
+
}
|
|
4687
|
+
const found = import_semver.default.coerce(output);
|
|
4688
|
+
if (!found) {
|
|
4689
|
+
throw new import_build_utils.NowBuildError({
|
|
4690
|
+
code: "UV_ERROR",
|
|
4691
|
+
link: "https://vercel.link/python-version",
|
|
4692
|
+
message: `Could not determine the uv version from "${output}".`
|
|
4693
|
+
});
|
|
4694
|
+
}
|
|
4695
|
+
if (import_semver.default.lt(found, MIN_UV_VERSION)) {
|
|
4696
|
+
throw new import_build_utils.NowBuildError({
|
|
4697
|
+
code: "UV_VERSION_TOO_OLD",
|
|
4698
|
+
link: "https://vercel.link/python-version",
|
|
4699
|
+
message: `Found uv ${found.version} at "${uvPath}", but Vercel requires uv ${MIN_UV_VERSION} or newer. Please upgrade uv: https://docs.astral.sh/uv/getting-started/installation/`
|
|
4700
|
+
});
|
|
4701
|
+
}
|
|
4702
|
+
return output;
|
|
4703
|
+
}
|
|
3521
4704
|
async function getUvBinaryOrInstall(pythonPath) {
|
|
3522
4705
|
const uvBin = await findUvBinary(pythonPath);
|
|
3523
4706
|
if (uvBin)
|
|
@@ -4466,17 +5649,18 @@ var import_execa4 = __toESM(require_execa());
|
|
|
4466
5649
|
var import_build_utils6 = require("@vercel/build-utils");
|
|
4467
5650
|
var import_fs5 = __toESM(require("fs"));
|
|
4468
5651
|
var import_path6 = require("path");
|
|
5652
|
+
function isPythonOnHive() {
|
|
5653
|
+
const hive = process.env.VERCEL_PYTHON_ON_HIVE;
|
|
5654
|
+
return hive === "1" || hive === "true";
|
|
5655
|
+
}
|
|
4469
5656
|
function isCompileAllEnabled() {
|
|
5657
|
+
if (!isPythonOnHive())
|
|
5658
|
+
return false;
|
|
4470
5659
|
const val = process.env.VERCEL_PYTHON_COMPILEALL;
|
|
4471
|
-
if (val
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
const hive = process.env.VERCEL_PYTHON_ON_HIVE;
|
|
4476
|
-
if (hive === "1" || hive === "true") {
|
|
4477
|
-
return true;
|
|
4478
|
-
}
|
|
4479
|
-
return false;
|
|
5660
|
+
if (val === void 0 || val === "")
|
|
5661
|
+
return false;
|
|
5662
|
+
const lower = val.toLowerCase();
|
|
5663
|
+
return lower === "1" || lower === "true";
|
|
4480
5664
|
}
|
|
4481
5665
|
function shouldUseCompileAll({
|
|
4482
5666
|
isDev,
|
|
@@ -4484,11 +5668,6 @@ function shouldUseCompileAll({
|
|
|
4484
5668
|
}) {
|
|
4485
5669
|
if (isDev)
|
|
4486
5670
|
return false;
|
|
4487
|
-
const val = process.env.VERCEL_PYTHON_COMPILEALL;
|
|
4488
|
-
if (val !== void 0 && val !== "") {
|
|
4489
|
-
const lower = val.toLowerCase();
|
|
4490
|
-
return lower === "1" || lower === "true";
|
|
4491
|
-
}
|
|
4492
5671
|
if (hasCustomCommand)
|
|
4493
5672
|
return false;
|
|
4494
5673
|
return isCompileAllEnabled();
|
|
@@ -4614,14 +5793,7 @@ var OTEL_LAYER_RESERVATION_BYTES = 5 * 1024 * 1024;
|
|
|
4614
5793
|
var LAMBDA_SIZE_THRESHOLD_BYTES = process.env.VERCEL_DEPLOYMENT_HAS_OTEL_LAYER === "1" ? LAMBDA_BASE_SIZE_THRESHOLD_BYTES - OTEL_LAYER_RESERVATION_BYTES : LAMBDA_BASE_SIZE_THRESHOLD_BYTES;
|
|
4615
5794
|
var LAMBDA_EPHEMERAL_STORAGE_BYTES = 500 * 1024 * 1024;
|
|
4616
5795
|
var HIVE_LAMBDA_SIZE_BYTES = 1 * 1024 * 1024 * 1024;
|
|
4617
|
-
var FUNCTIONS_BETA_CTA = "Run `vercel deploy --functions-beta` to use extended function limits (up to 1 GB), or reduce your dependency footprint.";
|
|
4618
5796
|
var BUNDLING_DOCS_LINK = "https://vercel.com/docs/functions/runtimes/python#controlling-what-gets-bundled";
|
|
4619
|
-
var FUNCTIONS_BETA_DOCS_LINK = "https://vercel.com/docs/functions/runtimes/python#extended-size-limits-with-functions-beta";
|
|
4620
|
-
var FUNCTIONS_BETA_EXCEEDED_CTA = "Your deployment is already using extended function limits (`--functions-beta`).\nReduce your dependency footprint to under 1 GB or split your application\ninto smaller functions.";
|
|
4621
|
-
function shouldShowFunctionsBetaHint() {
|
|
4622
|
-
const v = process.env.VERCEL_FUNCTIONS_BETA_HINT;
|
|
4623
|
-
return v === "1" || v === "true";
|
|
4624
|
-
}
|
|
4625
5797
|
var PythonDependencyExternalizer = class {
|
|
4626
5798
|
constructor(options) {
|
|
4627
5799
|
// Populated by analyze()
|
|
@@ -4659,7 +5831,7 @@ var PythonDependencyExternalizer = class {
|
|
|
4659
5831
|
* and determine whether runtime installation is needed.
|
|
4660
5832
|
* Must be called before generateBundle().
|
|
4661
5833
|
*/
|
|
4662
|
-
async analyze(files) {
|
|
5834
|
+
async analyze(files, options = {}) {
|
|
4663
5835
|
this.sitePackageDirs = await getVenvSitePackagesDirs(this.venvPath);
|
|
4664
5836
|
this.distributions = /* @__PURE__ */ new Map();
|
|
4665
5837
|
for (const dir of this.sitePackageDirs) {
|
|
@@ -4683,13 +5855,15 @@ var PythonDependencyExternalizer = class {
|
|
|
4683
5855
|
(0, import_build_utils7.debug)(`Total bundle size: ${totalBundleSizeMB} MB`);
|
|
4684
5856
|
const runtimeInstallEnabled = this.shouldEnableRuntimeInstall();
|
|
4685
5857
|
const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
|
|
5858
|
+
options.onSized?.({
|
|
5859
|
+
totalSizeBytes: this.totalBundleSize,
|
|
5860
|
+
runtimeInstallEnabled
|
|
5861
|
+
});
|
|
4686
5862
|
if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.hasCustomCommand && !pythonOnHiveEnabled) {
|
|
4687
5863
|
const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
|
|
4688
5864
|
throw new import_build_utils7.NowBuildError({
|
|
4689
5865
|
code: "LAMBDA_SIZE_EXCEEDED",
|
|
4690
|
-
message:
|
|
4691
|
-
|
|
4692
|
-
` + FUNCTIONS_BETA_CTA : `Total bundle size (${totalBundleSizeMB} MB) exceeds the size limit (${limitMB} MB).
|
|
5866
|
+
message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the size limit (${limitMB} MB).
|
|
4693
5867
|
|
|
4694
5868
|
When using a custom install command, Vercel cannot automatically
|
|
4695
5869
|
optimize dependency bundling. To reduce the size of your
|
|
@@ -4697,7 +5871,7 @@ dependencies, you can:
|
|
|
4697
5871
|
1. Remove unused dependencies from your project.
|
|
4698
5872
|
2. Remove the custom install command to allow Vercel to manage
|
|
4699
5873
|
and optimize dependencies automatically.`,
|
|
4700
|
-
link:
|
|
5874
|
+
link: BUNDLING_DOCS_LINK,
|
|
4701
5875
|
action: "Learn More"
|
|
4702
5876
|
});
|
|
4703
5877
|
}
|
|
@@ -4705,13 +5879,11 @@ dependencies, you can:
|
|
|
4705
5879
|
const limitMB = (HIVE_LAMBDA_SIZE_BYTES / (1024 * 1024)).toFixed(0);
|
|
4706
5880
|
throw new import_build_utils7.NowBuildError({
|
|
4707
5881
|
code: "LAMBDA_SIZE_EXCEEDED",
|
|
4708
|
-
message:
|
|
4709
|
-
|
|
4710
|
-
` + FUNCTIONS_BETA_EXCEEDED_CTA : `Total bundle size (${totalBundleSizeMB} MB) exceeds the extended function size limit (${limitMB} MB).
|
|
5882
|
+
message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the extended function size limit (${limitMB} MB).
|
|
4711
5883
|
|
|
4712
5884
|
Consider removing unused dependencies or splitting your
|
|
4713
5885
|
application into smaller functions.`,
|
|
4714
|
-
link:
|
|
5886
|
+
link: BUNDLING_DOCS_LINK,
|
|
4715
5887
|
action: "Learn More"
|
|
4716
5888
|
});
|
|
4717
5889
|
}
|
|
@@ -4747,15 +5919,13 @@ application into smaller functions.`,
|
|
|
4747
5919
|
const ephemeralLimitMB = (LAMBDA_EPHEMERAL_STORAGE_BYTES / (1024 * 1024)).toFixed(0);
|
|
4748
5920
|
throw new import_build_utils7.NowBuildError({
|
|
4749
5921
|
code: "LAMBDA_SIZE_EXCEEDED",
|
|
4750
|
-
message:
|
|
4751
|
-
|
|
4752
|
-
` + FUNCTIONS_BETA_CTA : `Total bundle size (${totalBundleSizeMB} MB) exceeds Lambda ephemeral storage limit (${ephemeralLimitMB} MB).
|
|
5922
|
+
message: `Total bundle size (${totalBundleSizeMB} MB) exceeds Lambda ephemeral storage limit (${ephemeralLimitMB} MB).
|
|
4753
5923
|
|
|
4754
5924
|
Even with runtime dependency installation, all packages must fit
|
|
4755
5925
|
within the ${ephemeralLimitMB} MB ephemeral storage available to Lambda
|
|
4756
5926
|
functions. Consider removing unused dependencies or splitting
|
|
4757
5927
|
your application into smaller functions.`,
|
|
4758
|
-
link:
|
|
5928
|
+
link: BUNDLING_DOCS_LINK,
|
|
4759
5929
|
action: "Learn More"
|
|
4760
5930
|
});
|
|
4761
5931
|
}
|
|
@@ -4946,15 +6116,13 @@ To fix this, either:
|
|
|
4946
6116
|
const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
|
|
4947
6117
|
throw new import_build_utils7.NowBuildError({
|
|
4948
6118
|
code: "LAMBDA_SIZE_EXCEEDED",
|
|
4949
|
-
message:
|
|
4950
|
-
|
|
4951
|
-
` + FUNCTIONS_BETA_CTA : `Total bundle size (${finalSizeMB} MB) exceeds Lambda limit (${limitMB} MB) even after
|
|
6119
|
+
message: `Total bundle size (${finalSizeMB} MB) exceeds Lambda limit (${limitMB} MB) even after
|
|
4952
6120
|
deferring public packages to runtime installation.
|
|
4953
6121
|
|
|
4954
6122
|
This usually means your private packages or source code are too
|
|
4955
6123
|
large. Consider reducing the size of private dependencies or
|
|
4956
6124
|
splitting your application.`,
|
|
4957
|
-
link:
|
|
6125
|
+
link: BUNDLING_DOCS_LINK,
|
|
4958
6126
|
action: "Learn More"
|
|
4959
6127
|
});
|
|
4960
6128
|
}
|
|
@@ -6618,6 +7786,9 @@ var startDevServer = async (opts) => {
|
|
|
6618
7786
|
try {
|
|
6619
7787
|
const { pythonPath: systemPython } = getDefaultPythonVersion(meta);
|
|
6620
7788
|
const uvPath = await findUvBinary(systemPython);
|
|
7789
|
+
if (uvPath) {
|
|
7790
|
+
checkUvBinaryVersion(uvPath);
|
|
7791
|
+
}
|
|
6621
7792
|
const venv = isInVirtualEnv();
|
|
6622
7793
|
const serviceCount = meta.serviceCount ?? 0;
|
|
6623
7794
|
const pythonServiceCount = meta.pythonServiceCount ?? 1;
|
|
@@ -7375,7 +8546,177 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
7375
8546
|
|
|
7376
8547
|
// src/index.ts
|
|
7377
8548
|
var import_python_analysis9 = require("@vercel/python-analysis");
|
|
7378
|
-
|
|
8549
|
+
|
|
8550
|
+
// src/subscribers.ts
|
|
8551
|
+
var import_path14 = require("path");
|
|
8552
|
+
var import_fs14 = __toESM(require("fs"));
|
|
8553
|
+
var import_build_utils18 = require("@vercel/build-utils");
|
|
8554
|
+
var SUBSCRIBER_NAME_RE = /^[A-Za-z]([A-Za-z0-9_-]*[A-Za-z0-9])?$/;
|
|
8555
|
+
var MODULE_ATTR_RE = /^([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*):([A-Za-z_][\w]*)$/;
|
|
8556
|
+
var TRIGGER_NUMBER_FIELDS = [
|
|
8557
|
+
{
|
|
8558
|
+
field: "max_deliveries",
|
|
8559
|
+
output: "maxDeliveries",
|
|
8560
|
+
isValid: (value) => Number.isInteger(value) && value >= 1,
|
|
8561
|
+
expected: "an integer greater than or equal to 1"
|
|
8562
|
+
},
|
|
8563
|
+
{
|
|
8564
|
+
field: "retry_after_seconds",
|
|
8565
|
+
output: "retryAfterSeconds",
|
|
8566
|
+
isValid: (value) => value > 0,
|
|
8567
|
+
expected: "greater than 0"
|
|
8568
|
+
},
|
|
8569
|
+
{
|
|
8570
|
+
field: "initial_delay_seconds",
|
|
8571
|
+
output: "initialDelaySeconds",
|
|
8572
|
+
isValid: (value) => value >= 0,
|
|
8573
|
+
expected: "greater than or equal to 0"
|
|
8574
|
+
},
|
|
8575
|
+
{
|
|
8576
|
+
field: "max_concurrency",
|
|
8577
|
+
output: "maxConcurrency",
|
|
8578
|
+
isValid: (value) => Number.isInteger(value) && value >= 1,
|
|
8579
|
+
expected: "an integer greater than or equal to 1"
|
|
8580
|
+
}
|
|
8581
|
+
];
|
|
8582
|
+
var SUBSCRIBER_FIELD_NAMES = /* @__PURE__ */ new Set([
|
|
8583
|
+
"entrypoint",
|
|
8584
|
+
"topics",
|
|
8585
|
+
...TRIGGER_NUMBER_FIELDS.map(({ field }) => field)
|
|
8586
|
+
]);
|
|
8587
|
+
function safePathSegment(value) {
|
|
8588
|
+
return [...value].map((char) => {
|
|
8589
|
+
if (char === "_") {
|
|
8590
|
+
return "__";
|
|
8591
|
+
}
|
|
8592
|
+
return /[A-Za-z0-9-]/.test(char) ? char : `_${char.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`;
|
|
8593
|
+
}).join("");
|
|
8594
|
+
}
|
|
8595
|
+
async function getPyprojectSubscribers(workPath) {
|
|
8596
|
+
const pyprojectPath = (0, import_path14.join)(workPath, "pyproject.toml");
|
|
8597
|
+
if (!import_fs14.default.existsSync(pyprojectPath)) {
|
|
8598
|
+
return [];
|
|
8599
|
+
}
|
|
8600
|
+
const pyproject = await (0, import_build_utils18.readConfigFile)(pyprojectPath);
|
|
8601
|
+
const subscribers = pyproject?.tool?.vercel?.subscribers;
|
|
8602
|
+
if (!subscribers) {
|
|
8603
|
+
return [];
|
|
8604
|
+
}
|
|
8605
|
+
if (typeof subscribers !== "object" || Array.isArray(subscribers)) {
|
|
8606
|
+
throw subscriberError('"tool.vercel.subscribers" must be an object');
|
|
8607
|
+
}
|
|
8608
|
+
return Promise.all(
|
|
8609
|
+
Object.entries(subscribers).map(
|
|
8610
|
+
([name, config]) => parseSubscriber(workPath, name, config)
|
|
8611
|
+
)
|
|
8612
|
+
);
|
|
8613
|
+
}
|
|
8614
|
+
async function parseSubscriber(workPath, name, config) {
|
|
8615
|
+
if (!SUBSCRIBER_NAME_RE.test(name)) {
|
|
8616
|
+
throw subscriberError(
|
|
8617
|
+
`subscriber name "${name}" is invalid. Names must start with a letter, end with an alphanumeric character, and contain only alphanumeric characters, hyphens, and underscores`
|
|
8618
|
+
);
|
|
8619
|
+
}
|
|
8620
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
8621
|
+
throw subscriberError(`subscriber "${name}" must be an object`);
|
|
8622
|
+
}
|
|
8623
|
+
for (const key of Object.keys(config)) {
|
|
8624
|
+
if (!SUBSCRIBER_FIELD_NAMES.has(key)) {
|
|
8625
|
+
throw subscriberError(
|
|
8626
|
+
`subscriber "${name}" has unrecognized field "${key}"`
|
|
8627
|
+
);
|
|
8628
|
+
}
|
|
8629
|
+
}
|
|
8630
|
+
if (typeof config.entrypoint !== "string") {
|
|
8631
|
+
throw subscriberError(
|
|
8632
|
+
`subscriber "${name}" must define string field "entrypoint"`
|
|
8633
|
+
);
|
|
8634
|
+
}
|
|
8635
|
+
const entrypoint = parseEntrypoint(name, config.entrypoint);
|
|
8636
|
+
const existingEntrypoint = await resolveExistingEntrypoint(
|
|
8637
|
+
workPath,
|
|
8638
|
+
entrypoint.filePath
|
|
8639
|
+
);
|
|
8640
|
+
if (!existingEntrypoint) {
|
|
8641
|
+
throw subscriberError(
|
|
8642
|
+
`subscriber "${name}" has entrypoint "${config.entrypoint}" but file "${entrypoint.filePath}" does not exist`
|
|
8643
|
+
);
|
|
8644
|
+
}
|
|
8645
|
+
return {
|
|
8646
|
+
name,
|
|
8647
|
+
entrypoint: existingEntrypoint,
|
|
8648
|
+
moduleName: entrypoint.moduleName,
|
|
8649
|
+
variableName: entrypoint.variableName,
|
|
8650
|
+
topics: parseTopics(name, config.topics),
|
|
8651
|
+
triggerDefaults: parseTriggerDefaults(name, config)
|
|
8652
|
+
};
|
|
8653
|
+
}
|
|
8654
|
+
function parseEntrypoint(name, value) {
|
|
8655
|
+
const match = MODULE_ATTR_RE.exec(value);
|
|
8656
|
+
if (!match) {
|
|
8657
|
+
throw subscriberError(
|
|
8658
|
+
`subscriber "${name}" has invalid entrypoint "${value}". Use "module:object"`
|
|
8659
|
+
);
|
|
8660
|
+
}
|
|
8661
|
+
return {
|
|
8662
|
+
moduleName: match[1],
|
|
8663
|
+
variableName: match[2],
|
|
8664
|
+
filePath: `${match[1].replace(/\./g, "/")}.py`
|
|
8665
|
+
};
|
|
8666
|
+
}
|
|
8667
|
+
async function resolveExistingEntrypoint(workPath, filePath) {
|
|
8668
|
+
const candidates = [filePath, filePath.replace(/\.py$/i, "/__init__.py")];
|
|
8669
|
+
for (const candidate of candidates) {
|
|
8670
|
+
try {
|
|
8671
|
+
const stat = await import_fs14.default.promises.stat((0, import_path14.join)(workPath, candidate));
|
|
8672
|
+
if (stat.isFile()) {
|
|
8673
|
+
return candidate;
|
|
8674
|
+
}
|
|
8675
|
+
} catch {
|
|
8676
|
+
}
|
|
8677
|
+
}
|
|
8678
|
+
return null;
|
|
8679
|
+
}
|
|
8680
|
+
function parseTopics(name, value) {
|
|
8681
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
8682
|
+
throw subscriberError(
|
|
8683
|
+
`subscriber "${name}" must define non-empty array field "topics"`
|
|
8684
|
+
);
|
|
8685
|
+
}
|
|
8686
|
+
for (const topic of value) {
|
|
8687
|
+
if (typeof topic !== "string" || topic.length === 0) {
|
|
8688
|
+
throw subscriberError(
|
|
8689
|
+
`subscriber "${name}" field "topics" must contain only non-empty strings`
|
|
8690
|
+
);
|
|
8691
|
+
}
|
|
8692
|
+
}
|
|
8693
|
+
return value;
|
|
8694
|
+
}
|
|
8695
|
+
function parseTriggerDefaults(subscriber, config) {
|
|
8696
|
+
const defaults = {};
|
|
8697
|
+
for (const { field, output, isValid, expected } of TRIGGER_NUMBER_FIELDS) {
|
|
8698
|
+
const value = config[field];
|
|
8699
|
+
if (value === void 0) {
|
|
8700
|
+
continue;
|
|
8701
|
+
}
|
|
8702
|
+
if (typeof value !== "number" || !isValid(value)) {
|
|
8703
|
+
throw subscriberError(
|
|
8704
|
+
`subscriber "${subscriber}" field "${field}" must be ${expected}`
|
|
8705
|
+
);
|
|
8706
|
+
}
|
|
8707
|
+
defaults[output] = value;
|
|
8708
|
+
}
|
|
8709
|
+
return defaults;
|
|
8710
|
+
}
|
|
8711
|
+
function subscriberError(message) {
|
|
8712
|
+
return new import_build_utils18.NowBuildError({
|
|
8713
|
+
code: "PYTHON_INVALID_SUBSCRIBER_CONFIG",
|
|
8714
|
+
message
|
|
8715
|
+
});
|
|
8716
|
+
}
|
|
8717
|
+
|
|
8718
|
+
// src/index.ts
|
|
8719
|
+
var writeFile = import_fs15.default.promises.writeFile;
|
|
7379
8720
|
var PYTHON_ENTRYPOINT_DOCS_URL2 = "https://vercel.com/docs/functions/runtimes/python#python-entrypoints";
|
|
7380
8721
|
var version = -1;
|
|
7381
8722
|
function addFiles(target, source) {
|
|
@@ -7439,7 +8780,7 @@ var frameworkHooks = {
|
|
|
7439
8780
|
detected
|
|
7440
8781
|
}) => {
|
|
7441
8782
|
if (detected?.baseDir === void 0) {
|
|
7442
|
-
(0,
|
|
8783
|
+
(0, import_build_utils19.debug)("Django hook: no manage.py detected, skipping");
|
|
7443
8784
|
return;
|
|
7444
8785
|
}
|
|
7445
8786
|
let settingsResult;
|
|
@@ -7453,13 +8794,13 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
|
|
|
7453
8794
|
} else {
|
|
7454
8795
|
detail = err?.stderr || err?.message || String(err);
|
|
7455
8796
|
}
|
|
7456
|
-
throw new
|
|
8797
|
+
throw new import_build_utils19.NowBuildError({
|
|
7457
8798
|
code: "DJANGO_SETTINGS_FAILED",
|
|
7458
8799
|
message: `Failed to read Django application settings from ${projectDir}/manage.py:
|
|
7459
8800
|
${detail}`
|
|
7460
8801
|
});
|
|
7461
8802
|
}
|
|
7462
|
-
(0,
|
|
8803
|
+
(0, import_build_utils19.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
|
|
7463
8804
|
const { djangoSettings, settingsModule, djangoVersion } = settingsResult;
|
|
7464
8805
|
if (djangoVersion) {
|
|
7465
8806
|
console.log(`Django ${djangoVersion.join(".")} detected`);
|
|
@@ -7472,7 +8813,7 @@ ${detail}`
|
|
|
7472
8813
|
const variableName = parts.at(-1);
|
|
7473
8814
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
7474
8815
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
7475
|
-
(0,
|
|
8816
|
+
(0, import_build_utils19.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
|
|
7476
8817
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
7477
8818
|
} else {
|
|
7478
8819
|
const wsgiApp = djangoSettings["WSGI_APPLICATION"];
|
|
@@ -7481,7 +8822,7 @@ ${detail}`
|
|
|
7481
8822
|
const variableName = parts.at(-1);
|
|
7482
8823
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
7483
8824
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
7484
|
-
(0,
|
|
8825
|
+
(0, import_build_utils19.debug)(
|
|
7485
8826
|
`Django hook: WSGI entrypoint: ${ep} (variable: ${variableName})`
|
|
7486
8827
|
);
|
|
7487
8828
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
@@ -7489,7 +8830,7 @@ ${detail}`
|
|
|
7489
8830
|
}
|
|
7490
8831
|
let djangoStatic = null;
|
|
7491
8832
|
if (workPath && venvPath) {
|
|
7492
|
-
const outputStaticDir = (0,
|
|
8833
|
+
const outputStaticDir = (0, import_path15.join)(workPath, ".vercel", "output", "static");
|
|
7493
8834
|
djangoStatic = await runDjangoCollectStatic(
|
|
7494
8835
|
venvPath,
|
|
7495
8836
|
workPath,
|
|
@@ -7503,29 +8844,78 @@ ${detail}`
|
|
|
7503
8844
|
return { entrypoint: resolvedEntrypoint, djangoStatic };
|
|
7504
8845
|
}
|
|
7505
8846
|
};
|
|
8847
|
+
function createRuntimeTrampoline({
|
|
8848
|
+
moduleName,
|
|
8849
|
+
entrypoint,
|
|
8850
|
+
vendorDir,
|
|
8851
|
+
variableName,
|
|
8852
|
+
extraEnv = []
|
|
8853
|
+
}) {
|
|
8854
|
+
const extraEnvLines = extraEnv.map((line) => `,
|
|
8855
|
+
${line}`).join("");
|
|
8856
|
+
return `
|
|
8857
|
+
import importlib
|
|
8858
|
+
import os
|
|
8859
|
+
import os.path
|
|
8860
|
+
import site
|
|
8861
|
+
import sys
|
|
8862
|
+
|
|
8863
|
+
_here = os.path.dirname(__file__)
|
|
8864
|
+
|
|
8865
|
+
os.environ.update({
|
|
8866
|
+
"__VC_HANDLER_MODULE_NAME": "${moduleName}",
|
|
8867
|
+
"__VC_HANDLER_ENTRYPOINT": "${entrypoint}",
|
|
8868
|
+
"__VC_HANDLER_ENTRYPOINT_ABS": os.path.join(_here, "${entrypoint}"),
|
|
8869
|
+
"__VC_HANDLER_VENDOR_DIR": "${vendorDir}",
|
|
8870
|
+
"__VC_HANDLER_VARIABLE_NAME": "${variableName}"${extraEnvLines}
|
|
8871
|
+
})
|
|
8872
|
+
|
|
8873
|
+
_vendor_rel = '${vendorDir}'
|
|
8874
|
+
_vendor = os.path.normpath(os.path.join(_here, _vendor_rel))
|
|
8875
|
+
|
|
8876
|
+
if os.path.isdir(_vendor):
|
|
8877
|
+
# Process .pth files like a real site-packages dir
|
|
8878
|
+
site.addsitedir(_vendor)
|
|
8879
|
+
|
|
8880
|
+
# Move _vendor to the front (after script dir if present)
|
|
8881
|
+
try:
|
|
8882
|
+
while _vendor in sys.path:
|
|
8883
|
+
sys.path.remove(_vendor)
|
|
8884
|
+
except ValueError:
|
|
8885
|
+
pass
|
|
8886
|
+
|
|
8887
|
+
# Put vendored deps ahead of site-packages but after the script dir
|
|
8888
|
+
idx = 1 if (sys.path and sys.path[0] in ('', _here)) else 0
|
|
8889
|
+
sys.path.insert(idx, _vendor)
|
|
8890
|
+
|
|
8891
|
+
importlib.invalidate_caches()
|
|
8892
|
+
|
|
8893
|
+
from vercel_runtime.vc_init import vc_handler
|
|
8894
|
+
`;
|
|
8895
|
+
}
|
|
7506
8896
|
async function downloadFilesInWorkPath({
|
|
7507
8897
|
entrypoint,
|
|
7508
8898
|
workPath,
|
|
7509
8899
|
files,
|
|
7510
8900
|
meta = {}
|
|
7511
8901
|
}) {
|
|
7512
|
-
(0,
|
|
7513
|
-
let downloadedFiles = await (0,
|
|
8902
|
+
(0, import_build_utils19.debug)("Downloading user files...");
|
|
8903
|
+
let downloadedFiles = await (0, import_build_utils19.download)(files, workPath, meta);
|
|
7514
8904
|
if (meta.isDev && entrypoint) {
|
|
7515
8905
|
const normalizedEntrypoint = entrypoint.endsWith(".py") ? entrypoint : `${entrypoint}.py`;
|
|
7516
8906
|
if (!hasProp(downloadedFiles, entrypoint) && !hasProp(downloadedFiles, normalizedEntrypoint)) {
|
|
7517
|
-
throw new
|
|
8907
|
+
throw new import_build_utils19.NowBuildError({
|
|
7518
8908
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
7519
8909
|
message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
|
|
7520
8910
|
link: PYTHON_ENTRYPOINT_DOCS_URL2,
|
|
7521
8911
|
action: "Learn More"
|
|
7522
8912
|
});
|
|
7523
8913
|
}
|
|
7524
|
-
const { devCacheDir = (0,
|
|
7525
|
-
const cacheKey = (0,
|
|
7526
|
-
const destCache = (0,
|
|
7527
|
-
await (0,
|
|
7528
|
-
downloadedFiles = await (0,
|
|
8914
|
+
const { devCacheDir = (0, import_path15.join)(workPath, ".now", "cache") } = meta;
|
|
8915
|
+
const cacheKey = (0, import_path15.basename)(entrypoint).replace(/\./g, "_");
|
|
8916
|
+
const destCache = (0, import_path15.join)(devCacheDir, cacheKey);
|
|
8917
|
+
await (0, import_build_utils19.download)(downloadedFiles, destCache);
|
|
8918
|
+
downloadedFiles = await (0, import_build_utils19.glob)("**", destCache);
|
|
7529
8919
|
workPath = destCache;
|
|
7530
8920
|
}
|
|
7531
8921
|
return workPath;
|
|
@@ -7558,11 +8948,11 @@ async function installInjectedPackage({
|
|
|
7558
8948
|
projectDir,
|
|
7559
8949
|
pipPlatformArgs
|
|
7560
8950
|
}) {
|
|
7561
|
-
const localDir = (0,
|
|
7562
|
-
const isLocalDev =
|
|
8951
|
+
const localDir = (0, import_path15.join)(__dirname, "..", "..", "..", "python", name);
|
|
8952
|
+
const isLocalDev = import_fs15.default.existsSync((0, import_path15.join)(localDir, "pyproject.toml"));
|
|
7563
8953
|
const dep = envOverride || (isLocalDev ? localDir : pinned);
|
|
7564
8954
|
const noExclude = ["--exclude-newer-package", `${name}=false`];
|
|
7565
|
-
(0,
|
|
8955
|
+
(0, import_build_utils19.debug)(`Installing ${dep}`);
|
|
7566
8956
|
await uv.pip({
|
|
7567
8957
|
venvPath,
|
|
7568
8958
|
projectDir,
|
|
@@ -7588,23 +8978,28 @@ var build = async ({
|
|
|
7588
8978
|
registerPreDeploy
|
|
7589
8979
|
}) => {
|
|
7590
8980
|
let entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
|
|
7591
|
-
const builderSpan = parentSpan ?? new
|
|
8981
|
+
const builderSpan = parentSpan ?? new import_build_utils19.Span({ name: "vc.builder" });
|
|
7592
8982
|
const framework = config?.framework;
|
|
7593
|
-
|
|
8983
|
+
let shouldInstallVercelWorkers = config?.hasWorkerServices === true;
|
|
8984
|
+
let subscribers = [];
|
|
7594
8985
|
let spawnEnv;
|
|
7595
8986
|
let projectInstallCommand;
|
|
7596
8987
|
let hasCustomCommand = false;
|
|
7597
8988
|
const target = getTargetPlatform(meta.isDev ?? false);
|
|
7598
|
-
(0,
|
|
8989
|
+
(0, import_build_utils19.debug)(`workPath: ${workPath}`);
|
|
7599
8990
|
workPath = await downloadFilesInWorkPath({
|
|
7600
8991
|
workPath,
|
|
7601
8992
|
files: originalFiles,
|
|
7602
8993
|
entrypoint,
|
|
7603
8994
|
meta
|
|
7604
8995
|
});
|
|
8996
|
+
if (!service && (0, import_build_utils19.isPythonFramework)(framework)) {
|
|
8997
|
+
subscribers = await getPyprojectSubscribers(workPath);
|
|
8998
|
+
shouldInstallVercelWorkers ||= subscribers.length > 0;
|
|
8999
|
+
}
|
|
7605
9000
|
try {
|
|
7606
9001
|
if (meta.isDev) {
|
|
7607
|
-
const setupCfg = (0,
|
|
9002
|
+
const setupCfg = (0, import_path15.join)(workPath, "setup.cfg");
|
|
7608
9003
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
7609
9004
|
}
|
|
7610
9005
|
} catch (err) {
|
|
@@ -7620,15 +9015,15 @@ var build = async ({
|
|
|
7620
9015
|
filePath: entrypoint,
|
|
7621
9016
|
// For schedule-triggered jobs, the WSGI variable is always 'app' (created dynamically).
|
|
7622
9017
|
// For other services, handlerFunction is used as the entrypoint variable name.
|
|
7623
|
-
varName: service && (0,
|
|
9018
|
+
varName: service && (0, import_build_utils19.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
|
|
7624
9019
|
} : void 0,
|
|
7625
9020
|
service
|
|
7626
9021
|
) ?? void 0;
|
|
7627
9022
|
if (detected?.error && detected?.baseDir === void 0) {
|
|
7628
9023
|
throw detected?.error;
|
|
7629
9024
|
}
|
|
7630
|
-
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0,
|
|
7631
|
-
const entrypointAbsDir = (0,
|
|
9025
|
+
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0, import_path15.dirname)(entrypoint) : ".");
|
|
9026
|
+
const entrypointAbsDir = (0, import_path15.join)(workPath, entryDirectory);
|
|
7632
9027
|
const rootDir = repoRootPath ?? workPath;
|
|
7633
9028
|
const pythonPackage = await builderSpan.child("vc.builder.python.discover").trace(
|
|
7634
9029
|
() => discoverPackage({
|
|
@@ -7661,22 +9056,20 @@ var build = async ({
|
|
|
7661
9056
|
try {
|
|
7662
9057
|
const uvPath = await getUvBinaryOrInstall(pythonVersion.pythonPath);
|
|
7663
9058
|
uv = new UvRunner(uvPath, uvCacheDir);
|
|
7664
|
-
const uvVersionOutput = (0, import_child_process3.execSync)(`${uvPath} --version`, {
|
|
7665
|
-
encoding: "utf8"
|
|
7666
|
-
}).trim();
|
|
7667
|
-
console.log(`Using ${uvVersionOutput}`);
|
|
7668
9059
|
} catch (err) {
|
|
7669
9060
|
console.log("Failed to install or locate uv");
|
|
7670
9061
|
throw new Error(
|
|
7671
9062
|
`uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
|
|
7672
9063
|
);
|
|
7673
9064
|
}
|
|
7674
|
-
const
|
|
7675
|
-
|
|
7676
|
-
const
|
|
9065
|
+
const uvVersion = checkUvBinaryVersion(uv.getPath());
|
|
9066
|
+
console.log(`Using ${uvVersion}`);
|
|
9067
|
+
const venvPath = service?.name ? (0, import_path15.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path15.join)(workPath, ".vercel", "python", ".venv");
|
|
9068
|
+
const hasCachedVenv = import_fs15.default.existsSync((0, import_path15.join)(venvPath, "pyvenv.cfg"));
|
|
9069
|
+
const hasCachedUv = import_fs15.default.existsSync(uvCacheDir);
|
|
7677
9070
|
const restoredCache = hasCachedVenv && hasCachedUv ? "both" : hasCachedVenv ? "venv" : hasCachedUv ? "uv" : "none";
|
|
7678
9071
|
if (hasCachedVenv || hasCachedUv) {
|
|
7679
|
-
(0,
|
|
9072
|
+
(0, import_build_utils19.debug)(
|
|
7680
9073
|
`Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
|
|
7681
9074
|
);
|
|
7682
9075
|
}
|
|
@@ -7688,14 +9081,14 @@ var build = async ({
|
|
|
7688
9081
|
uvCacheDir
|
|
7689
9082
|
});
|
|
7690
9083
|
});
|
|
7691
|
-
if ((0,
|
|
9084
|
+
if ((0, import_build_utils19.isPythonFramework)(framework)) {
|
|
7692
9085
|
const {
|
|
7693
9086
|
cliType,
|
|
7694
9087
|
lockfileVersion,
|
|
7695
9088
|
packageJsonPackageManager,
|
|
7696
9089
|
turboSupportsCorepackHome
|
|
7697
|
-
} = await (0,
|
|
7698
|
-
spawnEnv = (0,
|
|
9090
|
+
} = await (0, import_build_utils19.scanParentDirs)(workPath, true);
|
|
9091
|
+
spawnEnv = (0, import_build_utils19.getEnvForPackageManager)({
|
|
7699
9092
|
cliType,
|
|
7700
9093
|
lockfileVersion,
|
|
7701
9094
|
packageJsonPackageManager,
|
|
@@ -7720,13 +9113,13 @@ var build = async ({
|
|
|
7720
9113
|
let uvLockPath = null;
|
|
7721
9114
|
let uvProjectDir = null;
|
|
7722
9115
|
let projectName;
|
|
7723
|
-
await builderSpan.child(
|
|
9116
|
+
await builderSpan.child(import_build_utils19.BUILDER_INSTALLER_STEP, {
|
|
7724
9117
|
installCommand: projectInstallCommand || void 0,
|
|
7725
9118
|
runtime: "python",
|
|
7726
9119
|
"python.cache.restored": restoredCache
|
|
7727
9120
|
}).trace(async () => {
|
|
7728
9121
|
if (projectInstallCommand) {
|
|
7729
|
-
await
|
|
9122
|
+
await import_fs15.default.promises.rm(venvPath, { recursive: true, force: true });
|
|
7730
9123
|
await ensureVenv({
|
|
7731
9124
|
pythonVersion,
|
|
7732
9125
|
venvPath,
|
|
@@ -7737,7 +9130,7 @@ var build = async ({
|
|
|
7737
9130
|
console.log(
|
|
7738
9131
|
`Running "install" command: \`${projectInstallCommand}\`...`
|
|
7739
9132
|
);
|
|
7740
|
-
await (0,
|
|
9133
|
+
await (0, import_build_utils19.execCommand)(projectInstallCommand, {
|
|
7741
9134
|
env: pythonEnv,
|
|
7742
9135
|
cwd: workPath
|
|
7743
9136
|
});
|
|
@@ -7758,7 +9151,7 @@ var build = async ({
|
|
|
7758
9151
|
}
|
|
7759
9152
|
if (!assumeDepsInstalled) {
|
|
7760
9153
|
const lockCacheKey = service?.name ? `uv.lock.${service.name}` : "uv.lock";
|
|
7761
|
-
const cachedLockPath = (0,
|
|
9154
|
+
const cachedLockPath = (0, import_path15.join)(uvCacheDir, lockCacheKey);
|
|
7762
9155
|
const { projectDir, lockPath, lockFileProvidedByUser } = await ensureUvProject({
|
|
7763
9156
|
workPath,
|
|
7764
9157
|
rootDir,
|
|
@@ -7779,21 +9172,21 @@ var build = async ({
|
|
|
7779
9172
|
locked: !lockFileProvidedByUser,
|
|
7780
9173
|
pythonPlatform: target.uvPlatform
|
|
7781
9174
|
});
|
|
7782
|
-
if (lockPath &&
|
|
7783
|
-
await
|
|
7784
|
-
await
|
|
9175
|
+
if (lockPath && import_fs15.default.existsSync(lockPath)) {
|
|
9176
|
+
await import_fs15.default.promises.mkdir(uvCacheDir, { recursive: true });
|
|
9177
|
+
await import_fs15.default.promises.copyFile(lockPath, cachedLockPath);
|
|
7785
9178
|
}
|
|
7786
9179
|
}
|
|
7787
9180
|
});
|
|
7788
|
-
if ((0,
|
|
9181
|
+
if ((0, import_build_utils19.isPythonFramework)(framework)) {
|
|
7789
9182
|
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
7790
9183
|
config?.buildCommand;
|
|
7791
|
-
await builderSpan.child(
|
|
9184
|
+
await builderSpan.child(import_build_utils19.BUILDER_COMPILE_STEP, {
|
|
7792
9185
|
buildCommand: projectBuildCommand || void 0
|
|
7793
9186
|
}).trace(async () => {
|
|
7794
9187
|
if (projectBuildCommand) {
|
|
7795
9188
|
console.log(`Running "${projectBuildCommand}"`);
|
|
7796
|
-
await (0,
|
|
9189
|
+
await (0, import_build_utils19.execCommand)(projectBuildCommand, {
|
|
7797
9190
|
env: pythonEnv,
|
|
7798
9191
|
cwd: workPath
|
|
7799
9192
|
});
|
|
@@ -7808,7 +9201,7 @@ var build = async ({
|
|
|
7808
9201
|
}
|
|
7809
9202
|
const hookResult = await runFrameworkHook(framework, {
|
|
7810
9203
|
pythonEnv,
|
|
7811
|
-
projectDir: (0,
|
|
9204
|
+
projectDir: (0, import_path15.join)(workPath, entryDirectory),
|
|
7812
9205
|
workPath,
|
|
7813
9206
|
venvPath,
|
|
7814
9207
|
entrypoint,
|
|
@@ -7820,7 +9213,7 @@ var build = async ({
|
|
|
7820
9213
|
}
|
|
7821
9214
|
entrypoint = resolved?.entrypoint;
|
|
7822
9215
|
if (!entrypoint) {
|
|
7823
|
-
throw new
|
|
9216
|
+
throw new import_build_utils19.NowBuildError({
|
|
7824
9217
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
7825
9218
|
message: "No Python entrypoint could be detected. Please specify an entrypoint file."
|
|
7826
9219
|
});
|
|
@@ -7833,7 +9226,7 @@ var build = async ({
|
|
|
7833
9226
|
envOverride: baseEnv.VERCEL_RUNTIME_PYTHON,
|
|
7834
9227
|
uv,
|
|
7835
9228
|
venvPath,
|
|
7836
|
-
projectDir: (0,
|
|
9229
|
+
projectDir: (0, import_path15.join)(workPath, entryDirectory),
|
|
7837
9230
|
pipPlatformArgs
|
|
7838
9231
|
});
|
|
7839
9232
|
if (shouldInstallVercelWorkers) {
|
|
@@ -7843,7 +9236,7 @@ var build = async ({
|
|
|
7843
9236
|
envOverride: baseEnv.VERCEL_WORKERS_PYTHON,
|
|
7844
9237
|
uv,
|
|
7845
9238
|
venvPath,
|
|
7846
|
-
projectDir: (0,
|
|
9239
|
+
projectDir: (0, import_path15.join)(workPath, entryDirectory),
|
|
7847
9240
|
pipPlatformArgs
|
|
7848
9241
|
});
|
|
7849
9242
|
}
|
|
@@ -7856,25 +9249,25 @@ var build = async ({
|
|
|
7856
9249
|
const capturedEnv = { ...pythonEnv };
|
|
7857
9250
|
const capturedCwd = workPath;
|
|
7858
9251
|
registerPreDeploy(async () => {
|
|
7859
|
-
await builderSpan.child(
|
|
9252
|
+
await builderSpan.child(import_build_utils19.BUILDER_PRE_DEPLOY_STEP, {
|
|
7860
9253
|
preDeployCommand
|
|
7861
9254
|
}).trace(async () => {
|
|
7862
9255
|
console.log(`Running pre-deploy command: \`${preDeployCommand}\``);
|
|
7863
|
-
await (0,
|
|
9256
|
+
await (0, import_build_utils19.execCommand)(preDeployCommand, {
|
|
7864
9257
|
env: capturedEnv,
|
|
7865
9258
|
cwd: capturedCwd
|
|
7866
9259
|
});
|
|
7867
9260
|
});
|
|
7868
9261
|
});
|
|
7869
9262
|
}
|
|
7870
|
-
(0,
|
|
9263
|
+
(0, import_build_utils19.debug)("Entrypoint is", entrypoint);
|
|
7871
9264
|
const moduleName = entrypointToModule(entrypoint);
|
|
7872
9265
|
if (handlerFunction) {
|
|
7873
|
-
const entrypointPath = (0,
|
|
7874
|
-
const source = await
|
|
9266
|
+
const entrypointPath = (0, import_path15.join)(workPath, entrypoint);
|
|
9267
|
+
const source = await import_fs15.default.promises.readFile(entrypointPath, "utf-8");
|
|
7875
9268
|
const found = await (0, import_python_analysis9.containsTopLevelCallable)(source, handlerFunction);
|
|
7876
9269
|
if (!found) {
|
|
7877
|
-
throw new
|
|
9270
|
+
throw new import_build_utils19.NowBuildError({
|
|
7878
9271
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
7879
9272
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
7880
9273
|
});
|
|
@@ -7883,7 +9276,7 @@ var build = async ({
|
|
|
7883
9276
|
const vendorDir = resolveVendorDir();
|
|
7884
9277
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
7885
9278
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
7886
|
-
(0,
|
|
9279
|
+
(0, import_build_utils19.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
7887
9280
|
const crons = await getServiceCrons({
|
|
7888
9281
|
service,
|
|
7889
9282
|
entrypoint,
|
|
@@ -7893,53 +9286,20 @@ var build = async ({
|
|
|
7893
9286
|
env: pythonEnv,
|
|
7894
9287
|
workPath
|
|
7895
9288
|
});
|
|
7896
|
-
|
|
9289
|
+
const extraTrampolineEnv = [];
|
|
7897
9290
|
if (crons?.length) {
|
|
7898
9291
|
const json = JSON.stringify(buildCronRouteTable(crons));
|
|
7899
9292
|
(0, import_assert.default)(!json.includes("\\"), `backslash in cron route table: ${json}`);
|
|
7900
|
-
|
|
7901
|
-
"__VC_CRON_ROUTES": '${json}',`;
|
|
9293
|
+
extraTrampolineEnv.push(`"__VC_CRON_ROUTES": '${json}'`);
|
|
7902
9294
|
}
|
|
7903
9295
|
const variableName = resolved?.variableName ?? "";
|
|
7904
|
-
const runtimeTrampoline =
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
_here = os.path.dirname(__file__)
|
|
7912
|
-
|
|
7913
|
-
os.environ.update({
|
|
7914
|
-
"__VC_HANDLER_MODULE_NAME": "${moduleName}",
|
|
7915
|
-
"__VC_HANDLER_ENTRYPOINT": "${entrypointWithSuffix}",
|
|
7916
|
-
"__VC_HANDLER_ENTRYPOINT_ABS": os.path.join(_here, "${entrypointWithSuffix}"),
|
|
7917
|
-
"__VC_HANDLER_VENDOR_DIR": "${vendorDir}",
|
|
7918
|
-
"__VC_HANDLER_VARIABLE_NAME": "${variableName}",${cronEnvLine}
|
|
7919
|
-
})
|
|
7920
|
-
|
|
7921
|
-
_vendor_rel = '${vendorDir}'
|
|
7922
|
-
_vendor = os.path.normpath(os.path.join(_here, _vendor_rel))
|
|
7923
|
-
|
|
7924
|
-
if os.path.isdir(_vendor):
|
|
7925
|
-
# Process .pth files like a real site-packages dir
|
|
7926
|
-
site.addsitedir(_vendor)
|
|
7927
|
-
|
|
7928
|
-
# Move _vendor to the front (after script dir if present)
|
|
7929
|
-
try:
|
|
7930
|
-
while _vendor in sys.path:
|
|
7931
|
-
sys.path.remove(_vendor)
|
|
7932
|
-
except ValueError:
|
|
7933
|
-
pass
|
|
7934
|
-
|
|
7935
|
-
# Put vendored deps ahead of site-packages but after the script dir
|
|
7936
|
-
idx = 1 if (sys.path and sys.path[0] in ('', _here)) else 0
|
|
7937
|
-
sys.path.insert(idx, _vendor)
|
|
7938
|
-
|
|
7939
|
-
importlib.invalidate_caches()
|
|
7940
|
-
|
|
7941
|
-
from vercel_runtime.vc_init import vc_handler
|
|
7942
|
-
`;
|
|
9296
|
+
const runtimeTrampoline = createRuntimeTrampoline({
|
|
9297
|
+
moduleName,
|
|
9298
|
+
entrypoint: entrypointWithSuffix,
|
|
9299
|
+
vendorDir,
|
|
9300
|
+
variableName,
|
|
9301
|
+
extraEnv: extraTrampolineEnv
|
|
9302
|
+
});
|
|
7943
9303
|
const automaticCompileAllEnabled = shouldUseCompileAll({
|
|
7944
9304
|
isDev: meta.isDev,
|
|
7945
9305
|
hasCustomCommand
|
|
@@ -7973,17 +9333,16 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
7973
9333
|
cwd: workPath,
|
|
7974
9334
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
7975
9335
|
};
|
|
7976
|
-
const files = await (0,
|
|
9336
|
+
const files = await (0, import_build_utils19.glob)("**", globOptions);
|
|
7977
9337
|
if (djangoStatic?.manifestRelPath) {
|
|
7978
|
-
files[djangoStatic.manifestRelPath] = new
|
|
7979
|
-
fsPath: (0,
|
|
9338
|
+
files[djangoStatic.manifestRelPath] = new import_build_utils19.FileFsRef({
|
|
9339
|
+
fsPath: (0, import_path15.join)(workPath, djangoStatic.manifestRelPath)
|
|
7980
9340
|
});
|
|
7981
9341
|
}
|
|
7982
9342
|
const handlerPyFilename = "vc__handler__python";
|
|
7983
|
-
files[`${handlerPyFilename}.py`] = new import_build_utils18.FileBlob({ data: runtimeTrampoline });
|
|
7984
9343
|
if (config.framework === "fasthtml") {
|
|
7985
9344
|
const { SESSKEY = "" } = process.env;
|
|
7986
|
-
files[".sesskey"] = new
|
|
9345
|
+
files[".sesskey"] = new import_build_utils19.FileBlob({ data: `"${SESSKEY}"` });
|
|
7987
9346
|
}
|
|
7988
9347
|
const depExternalizer = new PythonDependencyExternalizer({
|
|
7989
9348
|
venvPath,
|
|
@@ -8002,12 +9361,15 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8002
9361
|
]
|
|
8003
9362
|
});
|
|
8004
9363
|
await builderSpan.child("vc.builder.python.bundle").trace(async (bundleSpan) => {
|
|
8005
|
-
const depAnalysis = await depExternalizer.analyze(files
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
9364
|
+
const depAnalysis = await depExternalizer.analyze(files, {
|
|
9365
|
+
onSized: ({ totalSizeBytes, runtimeInstallEnabled }) => {
|
|
9366
|
+
bundleSpan.setAttributes({
|
|
9367
|
+
"python.bundle.totalSizeBytes": String(totalSizeBytes),
|
|
9368
|
+
"python.bundle.runtimeInstallEnabled": String(
|
|
9369
|
+
runtimeInstallEnabled
|
|
9370
|
+
)
|
|
9371
|
+
});
|
|
9372
|
+
}
|
|
8011
9373
|
});
|
|
8012
9374
|
if (depAnalysis.runtimeInstallEnabled) {
|
|
8013
9375
|
await depExternalizer.generateBundle(files);
|
|
@@ -8015,7 +9377,7 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8015
9377
|
addFiles(files, depAnalysis.allVendorFiles);
|
|
8016
9378
|
if (automaticCompileAllEnabled) {
|
|
8017
9379
|
await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
|
|
8018
|
-
const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) =>
|
|
9380
|
+
const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) => import_fs15.default.existsSync(d));
|
|
8019
9381
|
const pythonBin = getVenvPythonBin(venvPath);
|
|
8020
9382
|
console.log("Compiling Python application bytecode...");
|
|
8021
9383
|
await runCompileAll({
|
|
@@ -8037,10 +9399,8 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8037
9399
|
)
|
|
8038
9400
|
});
|
|
8039
9401
|
});
|
|
8040
|
-
const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
|
|
8041
|
-
const activeThreshold = pythonOnHiveEnabled ? HIVE_LAMBDA_SIZE_BYTES : LAMBDA_SIZE_THRESHOLD_BYTES;
|
|
8042
9402
|
const currentSize = await calculateBundleSize(files);
|
|
8043
|
-
let remainingCapacity =
|
|
9403
|
+
let remainingCapacity = HIVE_LAMBDA_SIZE_BYTES - currentSize;
|
|
8044
9404
|
if (pythonVersion.major != null && pythonVersion.minor != null) {
|
|
8045
9405
|
const appBytecodeInfo = await collectAppBytecodeFiles({
|
|
8046
9406
|
workPath,
|
|
@@ -8069,14 +9429,55 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8069
9429
|
}
|
|
8070
9430
|
}
|
|
8071
9431
|
});
|
|
8072
|
-
const
|
|
8073
|
-
files,
|
|
9432
|
+
const webFiles = {
|
|
9433
|
+
...files,
|
|
9434
|
+
[`${handlerPyFilename}.py`]: new import_build_utils19.FileBlob({ data: runtimeTrampoline })
|
|
9435
|
+
};
|
|
9436
|
+
const output = new import_build_utils19.Lambda({
|
|
9437
|
+
files: webFiles,
|
|
8074
9438
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
8075
9439
|
runtime: pythonVersion.runtime,
|
|
8076
9440
|
architecture: target.architecture,
|
|
8077
9441
|
environment: lambdaEnv,
|
|
8078
9442
|
supportsResponseStreaming: true
|
|
8079
9443
|
});
|
|
9444
|
+
const subscriberLambdas = {};
|
|
9445
|
+
for (const subscriber of subscribers) {
|
|
9446
|
+
const safeName = safePathSegment(subscriber.name);
|
|
9447
|
+
const outputPath = `_py_subscribers/${safeName}`;
|
|
9448
|
+
const consumer = (0, import_build_utils19.sanitizeConsumerName)(outputPath);
|
|
9449
|
+
const experimentalTriggers = subscriber.topics.map(
|
|
9450
|
+
(topic) => ({
|
|
9451
|
+
type: "queue/v2beta",
|
|
9452
|
+
topic,
|
|
9453
|
+
consumer,
|
|
9454
|
+
...subscriber.triggerDefaults
|
|
9455
|
+
})
|
|
9456
|
+
);
|
|
9457
|
+
subscriberLambdas[outputPath] = new import_build_utils19.Lambda({
|
|
9458
|
+
files: {
|
|
9459
|
+
...files,
|
|
9460
|
+
[`${handlerPyFilename}.py`]: new import_build_utils19.FileBlob({
|
|
9461
|
+
data: createRuntimeTrampoline({
|
|
9462
|
+
moduleName: subscriber.moduleName,
|
|
9463
|
+
entrypoint: subscriber.entrypoint,
|
|
9464
|
+
vendorDir,
|
|
9465
|
+
variableName: subscriber.variableName
|
|
9466
|
+
})
|
|
9467
|
+
})
|
|
9468
|
+
},
|
|
9469
|
+
handler: `${handlerPyFilename}.vc_handler`,
|
|
9470
|
+
runtime: pythonVersion.runtime,
|
|
9471
|
+
architecture: target.architecture,
|
|
9472
|
+
environment: {
|
|
9473
|
+
...lambdaEnv,
|
|
9474
|
+
VERCEL_HAS_WORKER_SERVICES: "1",
|
|
9475
|
+
VERCEL_SERVICE_TYPE: "worker"
|
|
9476
|
+
},
|
|
9477
|
+
experimentalTriggers,
|
|
9478
|
+
supportsResponseStreaming: true
|
|
9479
|
+
});
|
|
9480
|
+
}
|
|
8080
9481
|
if (uvLockPath && !meta.isDev) {
|
|
8081
9482
|
try {
|
|
8082
9483
|
await generateProjectManifest({
|
|
@@ -8085,25 +9486,26 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8085
9486
|
pythonVersion,
|
|
8086
9487
|
uvLockPath,
|
|
8087
9488
|
framework,
|
|
8088
|
-
serviceType: service ? (0,
|
|
9489
|
+
serviceType: service ? (0, import_build_utils19.getReportedServiceType)(service) : void 0
|
|
8089
9490
|
});
|
|
8090
9491
|
} catch (err) {
|
|
8091
|
-
(0,
|
|
9492
|
+
(0, import_build_utils19.debug)(
|
|
8092
9493
|
`Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
|
|
8093
9494
|
);
|
|
8094
9495
|
}
|
|
8095
9496
|
}
|
|
8096
|
-
if (!(0,
|
|
9497
|
+
if (!(0, import_build_utils19.isPythonFramework)(framework) && !service?.name) {
|
|
8097
9498
|
return { resultVersion: 3, result: { output } };
|
|
8098
9499
|
}
|
|
8099
9500
|
const lambdaPath = service?.name ? `_svc/${service.name}/index` : "index";
|
|
8100
|
-
const staticFiles = djangoStatic?.cdnOutputDir ? await (0,
|
|
9501
|
+
const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils19.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
|
|
8101
9502
|
const routes = service?.name ? void 0 : [{ handle: "filesystem" }, { src: "/(.*)", dest: `/${lambdaPath}` }];
|
|
8102
9503
|
return {
|
|
8103
9504
|
resultVersion: 2,
|
|
8104
9505
|
result: {
|
|
8105
9506
|
output: {
|
|
8106
9507
|
[lambdaPath]: output,
|
|
9508
|
+
...subscriberLambdas,
|
|
8107
9509
|
...staticFiles
|
|
8108
9510
|
},
|
|
8109
9511
|
...routes ? { routes } : {},
|
|
@@ -8126,14 +9528,14 @@ var prepareCache = async ({
|
|
|
8126
9528
|
}
|
|
8127
9529
|
} catch {
|
|
8128
9530
|
}
|
|
8129
|
-
return (0,
|
|
9531
|
+
return (0, import_build_utils19.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
|
|
8130
9532
|
cwd: root,
|
|
8131
9533
|
ignore
|
|
8132
9534
|
});
|
|
8133
9535
|
};
|
|
8134
9536
|
var shouldServe = (opts) => {
|
|
8135
9537
|
const framework = opts.config.framework;
|
|
8136
|
-
if ((0,
|
|
9538
|
+
if ((0, import_build_utils19.isPythonFramework)(framework)) {
|
|
8137
9539
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
8138
9540
|
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
8139
9541
|
return false;
|
|
@@ -8152,7 +9554,7 @@ var defaultShouldServe = ({
|
|
|
8152
9554
|
if (entrypoint === requestPath && hasProp(files, entrypoint)) {
|
|
8153
9555
|
return true;
|
|
8154
9556
|
}
|
|
8155
|
-
const { dir, name } = (0,
|
|
9557
|
+
const { dir, name } = (0, import_path15.parse)(entrypoint);
|
|
8156
9558
|
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
|
|
8157
9559
|
return true;
|
|
8158
9560
|
}
|