@vercel/python 6.45.1 → 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 +1587 -170
- package/package.json +4 -2
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();
|
|
@@ -4652,7 +5831,7 @@ var PythonDependencyExternalizer = class {
|
|
|
4652
5831
|
* and determine whether runtime installation is needed.
|
|
4653
5832
|
* Must be called before generateBundle().
|
|
4654
5833
|
*/
|
|
4655
|
-
async analyze(files) {
|
|
5834
|
+
async analyze(files, options = {}) {
|
|
4656
5835
|
this.sitePackageDirs = await getVenvSitePackagesDirs(this.venvPath);
|
|
4657
5836
|
this.distributions = /* @__PURE__ */ new Map();
|
|
4658
5837
|
for (const dir of this.sitePackageDirs) {
|
|
@@ -4676,6 +5855,10 @@ var PythonDependencyExternalizer = class {
|
|
|
4676
5855
|
(0, import_build_utils7.debug)(`Total bundle size: ${totalBundleSizeMB} MB`);
|
|
4677
5856
|
const runtimeInstallEnabled = this.shouldEnableRuntimeInstall();
|
|
4678
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
|
+
});
|
|
4679
5862
|
if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.hasCustomCommand && !pythonOnHiveEnabled) {
|
|
4680
5863
|
const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
|
|
4681
5864
|
throw new import_build_utils7.NowBuildError({
|
|
@@ -6603,6 +7786,9 @@ var startDevServer = async (opts) => {
|
|
|
6603
7786
|
try {
|
|
6604
7787
|
const { pythonPath: systemPython } = getDefaultPythonVersion(meta);
|
|
6605
7788
|
const uvPath = await findUvBinary(systemPython);
|
|
7789
|
+
if (uvPath) {
|
|
7790
|
+
checkUvBinaryVersion(uvPath);
|
|
7791
|
+
}
|
|
6606
7792
|
const venv = isInVirtualEnv();
|
|
6607
7793
|
const serviceCount = meta.serviceCount ?? 0;
|
|
6608
7794
|
const pythonServiceCount = meta.pythonServiceCount ?? 1;
|
|
@@ -7360,7 +8546,177 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
7360
8546
|
|
|
7361
8547
|
// src/index.ts
|
|
7362
8548
|
var import_python_analysis9 = require("@vercel/python-analysis");
|
|
7363
|
-
|
|
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;
|
|
7364
8720
|
var PYTHON_ENTRYPOINT_DOCS_URL2 = "https://vercel.com/docs/functions/runtimes/python#python-entrypoints";
|
|
7365
8721
|
var version = -1;
|
|
7366
8722
|
function addFiles(target, source) {
|
|
@@ -7424,7 +8780,7 @@ var frameworkHooks = {
|
|
|
7424
8780
|
detected
|
|
7425
8781
|
}) => {
|
|
7426
8782
|
if (detected?.baseDir === void 0) {
|
|
7427
|
-
(0,
|
|
8783
|
+
(0, import_build_utils19.debug)("Django hook: no manage.py detected, skipping");
|
|
7428
8784
|
return;
|
|
7429
8785
|
}
|
|
7430
8786
|
let settingsResult;
|
|
@@ -7438,13 +8794,13 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
|
|
|
7438
8794
|
} else {
|
|
7439
8795
|
detail = err?.stderr || err?.message || String(err);
|
|
7440
8796
|
}
|
|
7441
|
-
throw new
|
|
8797
|
+
throw new import_build_utils19.NowBuildError({
|
|
7442
8798
|
code: "DJANGO_SETTINGS_FAILED",
|
|
7443
8799
|
message: `Failed to read Django application settings from ${projectDir}/manage.py:
|
|
7444
8800
|
${detail}`
|
|
7445
8801
|
});
|
|
7446
8802
|
}
|
|
7447
|
-
(0,
|
|
8803
|
+
(0, import_build_utils19.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
|
|
7448
8804
|
const { djangoSettings, settingsModule, djangoVersion } = settingsResult;
|
|
7449
8805
|
if (djangoVersion) {
|
|
7450
8806
|
console.log(`Django ${djangoVersion.join(".")} detected`);
|
|
@@ -7457,7 +8813,7 @@ ${detail}`
|
|
|
7457
8813
|
const variableName = parts.at(-1);
|
|
7458
8814
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
7459
8815
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
7460
|
-
(0,
|
|
8816
|
+
(0, import_build_utils19.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
|
|
7461
8817
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
7462
8818
|
} else {
|
|
7463
8819
|
const wsgiApp = djangoSettings["WSGI_APPLICATION"];
|
|
@@ -7466,7 +8822,7 @@ ${detail}`
|
|
|
7466
8822
|
const variableName = parts.at(-1);
|
|
7467
8823
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
7468
8824
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
7469
|
-
(0,
|
|
8825
|
+
(0, import_build_utils19.debug)(
|
|
7470
8826
|
`Django hook: WSGI entrypoint: ${ep} (variable: ${variableName})`
|
|
7471
8827
|
);
|
|
7472
8828
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
@@ -7474,7 +8830,7 @@ ${detail}`
|
|
|
7474
8830
|
}
|
|
7475
8831
|
let djangoStatic = null;
|
|
7476
8832
|
if (workPath && venvPath) {
|
|
7477
|
-
const outputStaticDir = (0,
|
|
8833
|
+
const outputStaticDir = (0, import_path15.join)(workPath, ".vercel", "output", "static");
|
|
7478
8834
|
djangoStatic = await runDjangoCollectStatic(
|
|
7479
8835
|
venvPath,
|
|
7480
8836
|
workPath,
|
|
@@ -7488,29 +8844,78 @@ ${detail}`
|
|
|
7488
8844
|
return { entrypoint: resolvedEntrypoint, djangoStatic };
|
|
7489
8845
|
}
|
|
7490
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
|
+
}
|
|
7491
8896
|
async function downloadFilesInWorkPath({
|
|
7492
8897
|
entrypoint,
|
|
7493
8898
|
workPath,
|
|
7494
8899
|
files,
|
|
7495
8900
|
meta = {}
|
|
7496
8901
|
}) {
|
|
7497
|
-
(0,
|
|
7498
|
-
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);
|
|
7499
8904
|
if (meta.isDev && entrypoint) {
|
|
7500
8905
|
const normalizedEntrypoint = entrypoint.endsWith(".py") ? entrypoint : `${entrypoint}.py`;
|
|
7501
8906
|
if (!hasProp(downloadedFiles, entrypoint) && !hasProp(downloadedFiles, normalizedEntrypoint)) {
|
|
7502
|
-
throw new
|
|
8907
|
+
throw new import_build_utils19.NowBuildError({
|
|
7503
8908
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
7504
8909
|
message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
|
|
7505
8910
|
link: PYTHON_ENTRYPOINT_DOCS_URL2,
|
|
7506
8911
|
action: "Learn More"
|
|
7507
8912
|
});
|
|
7508
8913
|
}
|
|
7509
|
-
const { devCacheDir = (0,
|
|
7510
|
-
const cacheKey = (0,
|
|
7511
|
-
const destCache = (0,
|
|
7512
|
-
await (0,
|
|
7513
|
-
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);
|
|
7514
8919
|
workPath = destCache;
|
|
7515
8920
|
}
|
|
7516
8921
|
return workPath;
|
|
@@ -7543,11 +8948,11 @@ async function installInjectedPackage({
|
|
|
7543
8948
|
projectDir,
|
|
7544
8949
|
pipPlatformArgs
|
|
7545
8950
|
}) {
|
|
7546
|
-
const localDir = (0,
|
|
7547
|
-
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"));
|
|
7548
8953
|
const dep = envOverride || (isLocalDev ? localDir : pinned);
|
|
7549
8954
|
const noExclude = ["--exclude-newer-package", `${name}=false`];
|
|
7550
|
-
(0,
|
|
8955
|
+
(0, import_build_utils19.debug)(`Installing ${dep}`);
|
|
7551
8956
|
await uv.pip({
|
|
7552
8957
|
venvPath,
|
|
7553
8958
|
projectDir,
|
|
@@ -7573,23 +8978,28 @@ var build = async ({
|
|
|
7573
8978
|
registerPreDeploy
|
|
7574
8979
|
}) => {
|
|
7575
8980
|
let entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
|
|
7576
|
-
const builderSpan = parentSpan ?? new
|
|
8981
|
+
const builderSpan = parentSpan ?? new import_build_utils19.Span({ name: "vc.builder" });
|
|
7577
8982
|
const framework = config?.framework;
|
|
7578
|
-
|
|
8983
|
+
let shouldInstallVercelWorkers = config?.hasWorkerServices === true;
|
|
8984
|
+
let subscribers = [];
|
|
7579
8985
|
let spawnEnv;
|
|
7580
8986
|
let projectInstallCommand;
|
|
7581
8987
|
let hasCustomCommand = false;
|
|
7582
8988
|
const target = getTargetPlatform(meta.isDev ?? false);
|
|
7583
|
-
(0,
|
|
8989
|
+
(0, import_build_utils19.debug)(`workPath: ${workPath}`);
|
|
7584
8990
|
workPath = await downloadFilesInWorkPath({
|
|
7585
8991
|
workPath,
|
|
7586
8992
|
files: originalFiles,
|
|
7587
8993
|
entrypoint,
|
|
7588
8994
|
meta
|
|
7589
8995
|
});
|
|
8996
|
+
if (!service && (0, import_build_utils19.isPythonFramework)(framework)) {
|
|
8997
|
+
subscribers = await getPyprojectSubscribers(workPath);
|
|
8998
|
+
shouldInstallVercelWorkers ||= subscribers.length > 0;
|
|
8999
|
+
}
|
|
7590
9000
|
try {
|
|
7591
9001
|
if (meta.isDev) {
|
|
7592
|
-
const setupCfg = (0,
|
|
9002
|
+
const setupCfg = (0, import_path15.join)(workPath, "setup.cfg");
|
|
7593
9003
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
7594
9004
|
}
|
|
7595
9005
|
} catch (err) {
|
|
@@ -7605,15 +9015,15 @@ var build = async ({
|
|
|
7605
9015
|
filePath: entrypoint,
|
|
7606
9016
|
// For schedule-triggered jobs, the WSGI variable is always 'app' (created dynamically).
|
|
7607
9017
|
// For other services, handlerFunction is used as the entrypoint variable name.
|
|
7608
|
-
varName: service && (0,
|
|
9018
|
+
varName: service && (0, import_build_utils19.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
|
|
7609
9019
|
} : void 0,
|
|
7610
9020
|
service
|
|
7611
9021
|
) ?? void 0;
|
|
7612
9022
|
if (detected?.error && detected?.baseDir === void 0) {
|
|
7613
9023
|
throw detected?.error;
|
|
7614
9024
|
}
|
|
7615
|
-
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0,
|
|
7616
|
-
const entrypointAbsDir = (0,
|
|
9025
|
+
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0, import_path15.dirname)(entrypoint) : ".");
|
|
9026
|
+
const entrypointAbsDir = (0, import_path15.join)(workPath, entryDirectory);
|
|
7617
9027
|
const rootDir = repoRootPath ?? workPath;
|
|
7618
9028
|
const pythonPackage = await builderSpan.child("vc.builder.python.discover").trace(
|
|
7619
9029
|
() => discoverPackage({
|
|
@@ -7646,22 +9056,20 @@ var build = async ({
|
|
|
7646
9056
|
try {
|
|
7647
9057
|
const uvPath = await getUvBinaryOrInstall(pythonVersion.pythonPath);
|
|
7648
9058
|
uv = new UvRunner(uvPath, uvCacheDir);
|
|
7649
|
-
const uvVersionOutput = (0, import_child_process3.execSync)(`${uvPath} --version`, {
|
|
7650
|
-
encoding: "utf8"
|
|
7651
|
-
}).trim();
|
|
7652
|
-
console.log(`Using ${uvVersionOutput}`);
|
|
7653
9059
|
} catch (err) {
|
|
7654
9060
|
console.log("Failed to install or locate uv");
|
|
7655
9061
|
throw new Error(
|
|
7656
9062
|
`uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
|
|
7657
9063
|
);
|
|
7658
9064
|
}
|
|
7659
|
-
const
|
|
7660
|
-
|
|
7661
|
-
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);
|
|
7662
9070
|
const restoredCache = hasCachedVenv && hasCachedUv ? "both" : hasCachedVenv ? "venv" : hasCachedUv ? "uv" : "none";
|
|
7663
9071
|
if (hasCachedVenv || hasCachedUv) {
|
|
7664
|
-
(0,
|
|
9072
|
+
(0, import_build_utils19.debug)(
|
|
7665
9073
|
`Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
|
|
7666
9074
|
);
|
|
7667
9075
|
}
|
|
@@ -7673,14 +9081,14 @@ var build = async ({
|
|
|
7673
9081
|
uvCacheDir
|
|
7674
9082
|
});
|
|
7675
9083
|
});
|
|
7676
|
-
if ((0,
|
|
9084
|
+
if ((0, import_build_utils19.isPythonFramework)(framework)) {
|
|
7677
9085
|
const {
|
|
7678
9086
|
cliType,
|
|
7679
9087
|
lockfileVersion,
|
|
7680
9088
|
packageJsonPackageManager,
|
|
7681
9089
|
turboSupportsCorepackHome
|
|
7682
|
-
} = await (0,
|
|
7683
|
-
spawnEnv = (0,
|
|
9090
|
+
} = await (0, import_build_utils19.scanParentDirs)(workPath, true);
|
|
9091
|
+
spawnEnv = (0, import_build_utils19.getEnvForPackageManager)({
|
|
7684
9092
|
cliType,
|
|
7685
9093
|
lockfileVersion,
|
|
7686
9094
|
packageJsonPackageManager,
|
|
@@ -7705,13 +9113,13 @@ var build = async ({
|
|
|
7705
9113
|
let uvLockPath = null;
|
|
7706
9114
|
let uvProjectDir = null;
|
|
7707
9115
|
let projectName;
|
|
7708
|
-
await builderSpan.child(
|
|
9116
|
+
await builderSpan.child(import_build_utils19.BUILDER_INSTALLER_STEP, {
|
|
7709
9117
|
installCommand: projectInstallCommand || void 0,
|
|
7710
9118
|
runtime: "python",
|
|
7711
9119
|
"python.cache.restored": restoredCache
|
|
7712
9120
|
}).trace(async () => {
|
|
7713
9121
|
if (projectInstallCommand) {
|
|
7714
|
-
await
|
|
9122
|
+
await import_fs15.default.promises.rm(venvPath, { recursive: true, force: true });
|
|
7715
9123
|
await ensureVenv({
|
|
7716
9124
|
pythonVersion,
|
|
7717
9125
|
venvPath,
|
|
@@ -7722,7 +9130,7 @@ var build = async ({
|
|
|
7722
9130
|
console.log(
|
|
7723
9131
|
`Running "install" command: \`${projectInstallCommand}\`...`
|
|
7724
9132
|
);
|
|
7725
|
-
await (0,
|
|
9133
|
+
await (0, import_build_utils19.execCommand)(projectInstallCommand, {
|
|
7726
9134
|
env: pythonEnv,
|
|
7727
9135
|
cwd: workPath
|
|
7728
9136
|
});
|
|
@@ -7743,7 +9151,7 @@ var build = async ({
|
|
|
7743
9151
|
}
|
|
7744
9152
|
if (!assumeDepsInstalled) {
|
|
7745
9153
|
const lockCacheKey = service?.name ? `uv.lock.${service.name}` : "uv.lock";
|
|
7746
|
-
const cachedLockPath = (0,
|
|
9154
|
+
const cachedLockPath = (0, import_path15.join)(uvCacheDir, lockCacheKey);
|
|
7747
9155
|
const { projectDir, lockPath, lockFileProvidedByUser } = await ensureUvProject({
|
|
7748
9156
|
workPath,
|
|
7749
9157
|
rootDir,
|
|
@@ -7764,21 +9172,21 @@ var build = async ({
|
|
|
7764
9172
|
locked: !lockFileProvidedByUser,
|
|
7765
9173
|
pythonPlatform: target.uvPlatform
|
|
7766
9174
|
});
|
|
7767
|
-
if (lockPath &&
|
|
7768
|
-
await
|
|
7769
|
-
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);
|
|
7770
9178
|
}
|
|
7771
9179
|
}
|
|
7772
9180
|
});
|
|
7773
|
-
if ((0,
|
|
9181
|
+
if ((0, import_build_utils19.isPythonFramework)(framework)) {
|
|
7774
9182
|
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
7775
9183
|
config?.buildCommand;
|
|
7776
|
-
await builderSpan.child(
|
|
9184
|
+
await builderSpan.child(import_build_utils19.BUILDER_COMPILE_STEP, {
|
|
7777
9185
|
buildCommand: projectBuildCommand || void 0
|
|
7778
9186
|
}).trace(async () => {
|
|
7779
9187
|
if (projectBuildCommand) {
|
|
7780
9188
|
console.log(`Running "${projectBuildCommand}"`);
|
|
7781
|
-
await (0,
|
|
9189
|
+
await (0, import_build_utils19.execCommand)(projectBuildCommand, {
|
|
7782
9190
|
env: pythonEnv,
|
|
7783
9191
|
cwd: workPath
|
|
7784
9192
|
});
|
|
@@ -7793,7 +9201,7 @@ var build = async ({
|
|
|
7793
9201
|
}
|
|
7794
9202
|
const hookResult = await runFrameworkHook(framework, {
|
|
7795
9203
|
pythonEnv,
|
|
7796
|
-
projectDir: (0,
|
|
9204
|
+
projectDir: (0, import_path15.join)(workPath, entryDirectory),
|
|
7797
9205
|
workPath,
|
|
7798
9206
|
venvPath,
|
|
7799
9207
|
entrypoint,
|
|
@@ -7805,7 +9213,7 @@ var build = async ({
|
|
|
7805
9213
|
}
|
|
7806
9214
|
entrypoint = resolved?.entrypoint;
|
|
7807
9215
|
if (!entrypoint) {
|
|
7808
|
-
throw new
|
|
9216
|
+
throw new import_build_utils19.NowBuildError({
|
|
7809
9217
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
7810
9218
|
message: "No Python entrypoint could be detected. Please specify an entrypoint file."
|
|
7811
9219
|
});
|
|
@@ -7818,7 +9226,7 @@ var build = async ({
|
|
|
7818
9226
|
envOverride: baseEnv.VERCEL_RUNTIME_PYTHON,
|
|
7819
9227
|
uv,
|
|
7820
9228
|
venvPath,
|
|
7821
|
-
projectDir: (0,
|
|
9229
|
+
projectDir: (0, import_path15.join)(workPath, entryDirectory),
|
|
7822
9230
|
pipPlatformArgs
|
|
7823
9231
|
});
|
|
7824
9232
|
if (shouldInstallVercelWorkers) {
|
|
@@ -7828,7 +9236,7 @@ var build = async ({
|
|
|
7828
9236
|
envOverride: baseEnv.VERCEL_WORKERS_PYTHON,
|
|
7829
9237
|
uv,
|
|
7830
9238
|
venvPath,
|
|
7831
|
-
projectDir: (0,
|
|
9239
|
+
projectDir: (0, import_path15.join)(workPath, entryDirectory),
|
|
7832
9240
|
pipPlatformArgs
|
|
7833
9241
|
});
|
|
7834
9242
|
}
|
|
@@ -7841,25 +9249,25 @@ var build = async ({
|
|
|
7841
9249
|
const capturedEnv = { ...pythonEnv };
|
|
7842
9250
|
const capturedCwd = workPath;
|
|
7843
9251
|
registerPreDeploy(async () => {
|
|
7844
|
-
await builderSpan.child(
|
|
9252
|
+
await builderSpan.child(import_build_utils19.BUILDER_PRE_DEPLOY_STEP, {
|
|
7845
9253
|
preDeployCommand
|
|
7846
9254
|
}).trace(async () => {
|
|
7847
9255
|
console.log(`Running pre-deploy command: \`${preDeployCommand}\``);
|
|
7848
|
-
await (0,
|
|
9256
|
+
await (0, import_build_utils19.execCommand)(preDeployCommand, {
|
|
7849
9257
|
env: capturedEnv,
|
|
7850
9258
|
cwd: capturedCwd
|
|
7851
9259
|
});
|
|
7852
9260
|
});
|
|
7853
9261
|
});
|
|
7854
9262
|
}
|
|
7855
|
-
(0,
|
|
9263
|
+
(0, import_build_utils19.debug)("Entrypoint is", entrypoint);
|
|
7856
9264
|
const moduleName = entrypointToModule(entrypoint);
|
|
7857
9265
|
if (handlerFunction) {
|
|
7858
|
-
const entrypointPath = (0,
|
|
7859
|
-
const source = await
|
|
9266
|
+
const entrypointPath = (0, import_path15.join)(workPath, entrypoint);
|
|
9267
|
+
const source = await import_fs15.default.promises.readFile(entrypointPath, "utf-8");
|
|
7860
9268
|
const found = await (0, import_python_analysis9.containsTopLevelCallable)(source, handlerFunction);
|
|
7861
9269
|
if (!found) {
|
|
7862
|
-
throw new
|
|
9270
|
+
throw new import_build_utils19.NowBuildError({
|
|
7863
9271
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
7864
9272
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
7865
9273
|
});
|
|
@@ -7868,7 +9276,7 @@ var build = async ({
|
|
|
7868
9276
|
const vendorDir = resolveVendorDir();
|
|
7869
9277
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
7870
9278
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
7871
|
-
(0,
|
|
9279
|
+
(0, import_build_utils19.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
7872
9280
|
const crons = await getServiceCrons({
|
|
7873
9281
|
service,
|
|
7874
9282
|
entrypoint,
|
|
@@ -7878,53 +9286,20 @@ var build = async ({
|
|
|
7878
9286
|
env: pythonEnv,
|
|
7879
9287
|
workPath
|
|
7880
9288
|
});
|
|
7881
|
-
|
|
9289
|
+
const extraTrampolineEnv = [];
|
|
7882
9290
|
if (crons?.length) {
|
|
7883
9291
|
const json = JSON.stringify(buildCronRouteTable(crons));
|
|
7884
9292
|
(0, import_assert.default)(!json.includes("\\"), `backslash in cron route table: ${json}`);
|
|
7885
|
-
|
|
7886
|
-
"__VC_CRON_ROUTES": '${json}',`;
|
|
9293
|
+
extraTrampolineEnv.push(`"__VC_CRON_ROUTES": '${json}'`);
|
|
7887
9294
|
}
|
|
7888
9295
|
const variableName = resolved?.variableName ?? "";
|
|
7889
|
-
const runtimeTrampoline =
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
_here = os.path.dirname(__file__)
|
|
7897
|
-
|
|
7898
|
-
os.environ.update({
|
|
7899
|
-
"__VC_HANDLER_MODULE_NAME": "${moduleName}",
|
|
7900
|
-
"__VC_HANDLER_ENTRYPOINT": "${entrypointWithSuffix}",
|
|
7901
|
-
"__VC_HANDLER_ENTRYPOINT_ABS": os.path.join(_here, "${entrypointWithSuffix}"),
|
|
7902
|
-
"__VC_HANDLER_VENDOR_DIR": "${vendorDir}",
|
|
7903
|
-
"__VC_HANDLER_VARIABLE_NAME": "${variableName}",${cronEnvLine}
|
|
7904
|
-
})
|
|
7905
|
-
|
|
7906
|
-
_vendor_rel = '${vendorDir}'
|
|
7907
|
-
_vendor = os.path.normpath(os.path.join(_here, _vendor_rel))
|
|
7908
|
-
|
|
7909
|
-
if os.path.isdir(_vendor):
|
|
7910
|
-
# Process .pth files like a real site-packages dir
|
|
7911
|
-
site.addsitedir(_vendor)
|
|
7912
|
-
|
|
7913
|
-
# Move _vendor to the front (after script dir if present)
|
|
7914
|
-
try:
|
|
7915
|
-
while _vendor in sys.path:
|
|
7916
|
-
sys.path.remove(_vendor)
|
|
7917
|
-
except ValueError:
|
|
7918
|
-
pass
|
|
7919
|
-
|
|
7920
|
-
# Put vendored deps ahead of site-packages but after the script dir
|
|
7921
|
-
idx = 1 if (sys.path and sys.path[0] in ('', _here)) else 0
|
|
7922
|
-
sys.path.insert(idx, _vendor)
|
|
7923
|
-
|
|
7924
|
-
importlib.invalidate_caches()
|
|
7925
|
-
|
|
7926
|
-
from vercel_runtime.vc_init import vc_handler
|
|
7927
|
-
`;
|
|
9296
|
+
const runtimeTrampoline = createRuntimeTrampoline({
|
|
9297
|
+
moduleName,
|
|
9298
|
+
entrypoint: entrypointWithSuffix,
|
|
9299
|
+
vendorDir,
|
|
9300
|
+
variableName,
|
|
9301
|
+
extraEnv: extraTrampolineEnv
|
|
9302
|
+
});
|
|
7928
9303
|
const automaticCompileAllEnabled = shouldUseCompileAll({
|
|
7929
9304
|
isDev: meta.isDev,
|
|
7930
9305
|
hasCustomCommand
|
|
@@ -7958,17 +9333,16 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
7958
9333
|
cwd: workPath,
|
|
7959
9334
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
7960
9335
|
};
|
|
7961
|
-
const files = await (0,
|
|
9336
|
+
const files = await (0, import_build_utils19.glob)("**", globOptions);
|
|
7962
9337
|
if (djangoStatic?.manifestRelPath) {
|
|
7963
|
-
files[djangoStatic.manifestRelPath] = new
|
|
7964
|
-
fsPath: (0,
|
|
9338
|
+
files[djangoStatic.manifestRelPath] = new import_build_utils19.FileFsRef({
|
|
9339
|
+
fsPath: (0, import_path15.join)(workPath, djangoStatic.manifestRelPath)
|
|
7965
9340
|
});
|
|
7966
9341
|
}
|
|
7967
9342
|
const handlerPyFilename = "vc__handler__python";
|
|
7968
|
-
files[`${handlerPyFilename}.py`] = new import_build_utils18.FileBlob({ data: runtimeTrampoline });
|
|
7969
9343
|
if (config.framework === "fasthtml") {
|
|
7970
9344
|
const { SESSKEY = "" } = process.env;
|
|
7971
|
-
files[".sesskey"] = new
|
|
9345
|
+
files[".sesskey"] = new import_build_utils19.FileBlob({ data: `"${SESSKEY}"` });
|
|
7972
9346
|
}
|
|
7973
9347
|
const depExternalizer = new PythonDependencyExternalizer({
|
|
7974
9348
|
venvPath,
|
|
@@ -7987,12 +9361,15 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
7987
9361
|
]
|
|
7988
9362
|
});
|
|
7989
9363
|
await builderSpan.child("vc.builder.python.bundle").trace(async (bundleSpan) => {
|
|
7990
|
-
const depAnalysis = await depExternalizer.analyze(files
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
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
|
+
}
|
|
7996
9373
|
});
|
|
7997
9374
|
if (depAnalysis.runtimeInstallEnabled) {
|
|
7998
9375
|
await depExternalizer.generateBundle(files);
|
|
@@ -8000,7 +9377,7 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8000
9377
|
addFiles(files, depAnalysis.allVendorFiles);
|
|
8001
9378
|
if (automaticCompileAllEnabled) {
|
|
8002
9379
|
await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
|
|
8003
|
-
const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) =>
|
|
9380
|
+
const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) => import_fs15.default.existsSync(d));
|
|
8004
9381
|
const pythonBin = getVenvPythonBin(venvPath);
|
|
8005
9382
|
console.log("Compiling Python application bytecode...");
|
|
8006
9383
|
await runCompileAll({
|
|
@@ -8022,10 +9399,8 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8022
9399
|
)
|
|
8023
9400
|
});
|
|
8024
9401
|
});
|
|
8025
|
-
const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
|
|
8026
|
-
const activeThreshold = pythonOnHiveEnabled ? HIVE_LAMBDA_SIZE_BYTES : LAMBDA_SIZE_THRESHOLD_BYTES;
|
|
8027
9402
|
const currentSize = await calculateBundleSize(files);
|
|
8028
|
-
let remainingCapacity =
|
|
9403
|
+
let remainingCapacity = HIVE_LAMBDA_SIZE_BYTES - currentSize;
|
|
8029
9404
|
if (pythonVersion.major != null && pythonVersion.minor != null) {
|
|
8030
9405
|
const appBytecodeInfo = await collectAppBytecodeFiles({
|
|
8031
9406
|
workPath,
|
|
@@ -8054,14 +9429,55 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8054
9429
|
}
|
|
8055
9430
|
}
|
|
8056
9431
|
});
|
|
8057
|
-
const
|
|
8058
|
-
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,
|
|
8059
9438
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
8060
9439
|
runtime: pythonVersion.runtime,
|
|
8061
9440
|
architecture: target.architecture,
|
|
8062
9441
|
environment: lambdaEnv,
|
|
8063
9442
|
supportsResponseStreaming: true
|
|
8064
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
|
+
}
|
|
8065
9481
|
if (uvLockPath && !meta.isDev) {
|
|
8066
9482
|
try {
|
|
8067
9483
|
await generateProjectManifest({
|
|
@@ -8070,25 +9486,26 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
8070
9486
|
pythonVersion,
|
|
8071
9487
|
uvLockPath,
|
|
8072
9488
|
framework,
|
|
8073
|
-
serviceType: service ? (0,
|
|
9489
|
+
serviceType: service ? (0, import_build_utils19.getReportedServiceType)(service) : void 0
|
|
8074
9490
|
});
|
|
8075
9491
|
} catch (err) {
|
|
8076
|
-
(0,
|
|
9492
|
+
(0, import_build_utils19.debug)(
|
|
8077
9493
|
`Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
|
|
8078
9494
|
);
|
|
8079
9495
|
}
|
|
8080
9496
|
}
|
|
8081
|
-
if (!(0,
|
|
9497
|
+
if (!(0, import_build_utils19.isPythonFramework)(framework) && !service?.name) {
|
|
8082
9498
|
return { resultVersion: 3, result: { output } };
|
|
8083
9499
|
}
|
|
8084
9500
|
const lambdaPath = service?.name ? `_svc/${service.name}/index` : "index";
|
|
8085
|
-
const staticFiles = djangoStatic?.cdnOutputDir ? await (0,
|
|
9501
|
+
const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils19.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
|
|
8086
9502
|
const routes = service?.name ? void 0 : [{ handle: "filesystem" }, { src: "/(.*)", dest: `/${lambdaPath}` }];
|
|
8087
9503
|
return {
|
|
8088
9504
|
resultVersion: 2,
|
|
8089
9505
|
result: {
|
|
8090
9506
|
output: {
|
|
8091
9507
|
[lambdaPath]: output,
|
|
9508
|
+
...subscriberLambdas,
|
|
8092
9509
|
...staticFiles
|
|
8093
9510
|
},
|
|
8094
9511
|
...routes ? { routes } : {},
|
|
@@ -8111,14 +9528,14 @@ var prepareCache = async ({
|
|
|
8111
9528
|
}
|
|
8112
9529
|
} catch {
|
|
8113
9530
|
}
|
|
8114
|
-
return (0,
|
|
9531
|
+
return (0, import_build_utils19.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
|
|
8115
9532
|
cwd: root,
|
|
8116
9533
|
ignore
|
|
8117
9534
|
});
|
|
8118
9535
|
};
|
|
8119
9536
|
var shouldServe = (opts) => {
|
|
8120
9537
|
const framework = opts.config.framework;
|
|
8121
|
-
if ((0,
|
|
9538
|
+
if ((0, import_build_utils19.isPythonFramework)(framework)) {
|
|
8122
9539
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
8123
9540
|
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
8124
9541
|
return false;
|
|
@@ -8137,7 +9554,7 @@ var defaultShouldServe = ({
|
|
|
8137
9554
|
if (entrypoint === requestPath && hasProp(files, entrypoint)) {
|
|
8138
9555
|
return true;
|
|
8139
9556
|
}
|
|
8140
|
-
const { dir, name } = (0,
|
|
9557
|
+
const { dir, name } = (0, import_path15.parse)(entrypoint);
|
|
8141
9558
|
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
|
|
8142
9559
|
return true;
|
|
8143
9560
|
}
|