@vercel/build-utils 13.29.1 → 13.31.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/CHANGELOG.md +20 -0
- package/dist/deploy-manifest.d.ts +9 -0
- package/dist/deploy-manifest.js +16 -0
- package/dist/fs/run-user-scripts.js +62 -25
- package/dist/index.d.ts +4 -2
- package/dist/index.js +556 -324
- package/dist/prerender.d.ts +23 -1
- package/dist/prerender.js +20 -4
- package/dist/ruby-diagnostics.d.ts +21 -0
- package/dist/ruby-diagnostics.js +219 -0
- package/dist/types.d.ts +1 -0
- package/package.json +2 -2
package/dist/prerender.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ interface PrerenderOptions {
|
|
|
19
19
|
exposeErrBody?: boolean;
|
|
20
20
|
partialFallback?: boolean;
|
|
21
21
|
hasPostponed?: boolean;
|
|
22
|
+
hasFallback?: boolean;
|
|
23
|
+
htmlSize?: number;
|
|
24
|
+
isDynamicRoute?: boolean;
|
|
22
25
|
}
|
|
23
26
|
export declare class Prerender {
|
|
24
27
|
type: 'Prerender';
|
|
@@ -55,6 +58,25 @@ export declare class Prerender {
|
|
|
55
58
|
* not provide the signal.
|
|
56
59
|
*/
|
|
57
60
|
hasPostponed?: boolean;
|
|
58
|
-
|
|
61
|
+
/**
|
|
62
|
+
* `true` when the route's dynamic template had a static fallback page (the
|
|
63
|
+
* prerender-manifest `fallback` was a string). `false` for blocking/omitted
|
|
64
|
+
* dynamic templates (manifest `fallback` was `null`/`false`). `undefined` for
|
|
65
|
+
* concrete prerenders, where the notion of a fallback doesn't apply.
|
|
66
|
+
*/
|
|
67
|
+
hasFallback?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Byte size on disk of the route's prerendered `.html` shell. `0` for an
|
|
70
|
+
* empty shell (PPR template that postponed everything). `undefined` when
|
|
71
|
+
* there's no `.html` on disk (pages router, route handlers, edge).
|
|
72
|
+
*/
|
|
73
|
+
htmlSize?: number;
|
|
74
|
+
/**
|
|
75
|
+
* `true` when this entry came from a dynamic route template (the
|
|
76
|
+
* prerender-manifest `dynamicRoutes` section: fallback, blocking, or omitted)
|
|
77
|
+
* rather than a concrete prerender.
|
|
78
|
+
*/
|
|
79
|
+
isDynamicRoute?: boolean;
|
|
80
|
+
constructor({ expiration, staleExpiration, lambda, fallback, group, bypassToken, allowQuery, allowHeader, initialHeaders, initialStatus, passQuery, sourcePath, experimentalBypassFor, experimentalStreamingLambdaPath, chain, exposeErrBody, partialFallback, hasPostponed, hasFallback, htmlSize, isDynamicRoute, }: PrerenderOptions);
|
|
59
81
|
}
|
|
60
82
|
export {};
|
package/dist/prerender.js
CHANGED
|
@@ -21,6 +21,13 @@ __export(prerender_exports, {
|
|
|
21
21
|
Prerender: () => Prerender
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(prerender_exports);
|
|
24
|
+
function assertOptionalBoolean(value, name) {
|
|
25
|
+
if (value !== void 0 && typeof value !== "boolean") {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`The \`${name}\` argument for \`Prerender\` must be a boolean or undefined.`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
24
31
|
class Prerender {
|
|
25
32
|
constructor({
|
|
26
33
|
expiration,
|
|
@@ -40,18 +47,27 @@ class Prerender {
|
|
|
40
47
|
chain,
|
|
41
48
|
exposeErrBody,
|
|
42
49
|
partialFallback,
|
|
43
|
-
hasPostponed
|
|
50
|
+
hasPostponed,
|
|
51
|
+
hasFallback,
|
|
52
|
+
htmlSize,
|
|
53
|
+
isDynamicRoute
|
|
44
54
|
}) {
|
|
45
55
|
this.type = "Prerender";
|
|
46
56
|
this.expiration = expiration;
|
|
47
57
|
this.staleExpiration = staleExpiration;
|
|
48
58
|
this.sourcePath = sourcePath;
|
|
49
|
-
|
|
59
|
+
assertOptionalBoolean(hasPostponed, "hasPostponed");
|
|
60
|
+
this.hasPostponed = hasPostponed;
|
|
61
|
+
assertOptionalBoolean(hasFallback, "hasFallback");
|
|
62
|
+
this.hasFallback = hasFallback;
|
|
63
|
+
assertOptionalBoolean(isDynamicRoute, "isDynamicRoute");
|
|
64
|
+
this.isDynamicRoute = isDynamicRoute;
|
|
65
|
+
if (htmlSize !== void 0 && (!Number.isInteger(htmlSize) || htmlSize < 0)) {
|
|
50
66
|
throw new Error(
|
|
51
|
-
"The `
|
|
67
|
+
"The `htmlSize` argument for `Prerender` must be a non-negative integer or undefined."
|
|
52
68
|
);
|
|
53
69
|
}
|
|
54
|
-
this.
|
|
70
|
+
this.htmlSize = htmlSize;
|
|
55
71
|
this.lambda = lambda;
|
|
56
72
|
if (this.lambda) {
|
|
57
73
|
this.lambda.operationType = this.lambda.operationType || "ISR";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare enum GemSource {
|
|
2
|
+
REGISTRY = "registry",
|
|
3
|
+
GIT = "git",
|
|
4
|
+
PLUGIN = "plugin"
|
|
5
|
+
}
|
|
6
|
+
interface GemEntry {
|
|
7
|
+
version: string;
|
|
8
|
+
source: GemSource;
|
|
9
|
+
sourceUrl: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseGemfileLock(content: string): {
|
|
12
|
+
gems: Map<string, GemEntry>;
|
|
13
|
+
directGems: Map<string, string | undefined>;
|
|
14
|
+
};
|
|
15
|
+
export declare function generateRubyProjectManifest({ workPath, gemfileLockPath, framework, serviceType, }: {
|
|
16
|
+
workPath: string;
|
|
17
|
+
gemfileLockPath: string | undefined;
|
|
18
|
+
framework?: string | null;
|
|
19
|
+
serviceType?: string | null;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var ruby_diagnostics_exports = {};
|
|
30
|
+
__export(ruby_diagnostics_exports, {
|
|
31
|
+
generateRubyProjectManifest: () => generateRubyProjectManifest,
|
|
32
|
+
parseGemfileLock: () => parseGemfileLock
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(ruby_diagnostics_exports);
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_package_manifest = require("./package-manifest");
|
|
37
|
+
const GEM_SPEC_PATTERN = /^(\S+) \(([^)]+)\)$/;
|
|
38
|
+
const DEPENDENCY_PATTERN = /^([^\s!]+)(!?)(?:\s+\(([^)]+)\))?$/;
|
|
39
|
+
var GemSource = /* @__PURE__ */ ((GemSource2) => {
|
|
40
|
+
GemSource2["REGISTRY"] = "registry";
|
|
41
|
+
GemSource2["GIT"] = "git";
|
|
42
|
+
GemSource2["PLUGIN"] = "plugin";
|
|
43
|
+
return GemSource2;
|
|
44
|
+
})(GemSource || {});
|
|
45
|
+
function parseGemfileLock(content) {
|
|
46
|
+
const gems = /* @__PURE__ */ new Map();
|
|
47
|
+
const pathGems = /* @__PURE__ */ new Set();
|
|
48
|
+
const directGems = /* @__PURE__ */ new Map();
|
|
49
|
+
let Section;
|
|
50
|
+
((Section2) => {
|
|
51
|
+
Section2["GEM"] = "gem";
|
|
52
|
+
Section2["GIT"] = "git";
|
|
53
|
+
Section2["PATH"] = "path";
|
|
54
|
+
Section2["PLUGIN"] = "plugin";
|
|
55
|
+
Section2["DEPENDENCIES"] = "dependencies";
|
|
56
|
+
})(Section || (Section = {}));
|
|
57
|
+
let SubSection;
|
|
58
|
+
((SubSection2) => {
|
|
59
|
+
SubSection2["SPECS"] = "specs";
|
|
60
|
+
})(SubSection || (SubSection = {}));
|
|
61
|
+
let section = null;
|
|
62
|
+
let subSection = null;
|
|
63
|
+
let currentRemote = "";
|
|
64
|
+
for (const rawLine of content.split("\n")) {
|
|
65
|
+
const line = rawLine.trimEnd();
|
|
66
|
+
if (!line)
|
|
67
|
+
continue;
|
|
68
|
+
if (!line.startsWith(" ")) {
|
|
69
|
+
currentRemote = "";
|
|
70
|
+
if (line === "GEM")
|
|
71
|
+
section = "gem" /* GEM */;
|
|
72
|
+
else if (line === "GIT")
|
|
73
|
+
section = "git" /* GIT */;
|
|
74
|
+
else if (line === "PATH")
|
|
75
|
+
section = "path" /* PATH */;
|
|
76
|
+
else if (line === "PLUGIN SOURCE")
|
|
77
|
+
section = "plugin" /* PLUGIN */;
|
|
78
|
+
else if (line === "DEPENDENCIES")
|
|
79
|
+
section = "dependencies" /* DEPENDENCIES */;
|
|
80
|
+
else
|
|
81
|
+
section = null;
|
|
82
|
+
subSection = null;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const indent = line.length - line.trimStart().length;
|
|
86
|
+
const text = line.trimStart();
|
|
87
|
+
if (section === "gem" /* GEM */ || section === "git" /* GIT */ || section === "plugin" /* PLUGIN */) {
|
|
88
|
+
if (indent === 2) {
|
|
89
|
+
if (text.startsWith("remote:")) {
|
|
90
|
+
currentRemote = text.slice("remote:".length).trim();
|
|
91
|
+
subSection = null;
|
|
92
|
+
} else if (text === "specs:") {
|
|
93
|
+
subSection = "specs" /* SPECS */;
|
|
94
|
+
}
|
|
95
|
+
} else if (indent === 4 && subSection === "specs" /* SPECS */) {
|
|
96
|
+
const m = text.match(GEM_SPEC_PATTERN);
|
|
97
|
+
if (!m)
|
|
98
|
+
continue;
|
|
99
|
+
const [, name, version] = m;
|
|
100
|
+
let gem;
|
|
101
|
+
if (section === "git" /* GIT */) {
|
|
102
|
+
gem = { version, source: "git" /* GIT */, sourceUrl: currentRemote };
|
|
103
|
+
} else if (section === "plugin" /* PLUGIN */) {
|
|
104
|
+
gem = { version, source: "plugin" /* PLUGIN */, sourceUrl: currentRemote };
|
|
105
|
+
} else {
|
|
106
|
+
let sourceUrl = currentRemote;
|
|
107
|
+
try {
|
|
108
|
+
sourceUrl = new URL(currentRemote).origin;
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
111
|
+
gem = { version, source: "registry" /* REGISTRY */, sourceUrl };
|
|
112
|
+
}
|
|
113
|
+
if (gems.has(name)) {
|
|
114
|
+
const existing = gems.get(name);
|
|
115
|
+
const isPlatformVariant = /-[a-zA-Z]/.test(version);
|
|
116
|
+
const existingIsPlatformVariant = /-[a-zA-Z]/.test(existing.version);
|
|
117
|
+
if (isPlatformVariant)
|
|
118
|
+
continue;
|
|
119
|
+
if (existing.source === gem.source && !existingIsPlatformVariant)
|
|
120
|
+
continue;
|
|
121
|
+
if (gem.source !== "registry" /* REGISTRY */)
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
gems.set(name, gem);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (section === "path" /* PATH */) {
|
|
128
|
+
if (indent === 2 && text === "specs:") {
|
|
129
|
+
subSection = "specs" /* SPECS */;
|
|
130
|
+
} else if (indent === 4 && subSection === "specs" /* SPECS */) {
|
|
131
|
+
const m = text.match(GEM_SPEC_PATTERN);
|
|
132
|
+
if (!m)
|
|
133
|
+
continue;
|
|
134
|
+
const [, name] = m;
|
|
135
|
+
pathGems.add(name);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (section === "dependencies" /* DEPENDENCIES */) {
|
|
139
|
+
if (indent === 2) {
|
|
140
|
+
const m = text.match(DEPENDENCY_PATTERN);
|
|
141
|
+
if (!m)
|
|
142
|
+
continue;
|
|
143
|
+
const [, name, , version] = m;
|
|
144
|
+
directGems.set(name, version);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
for (const name of pathGems) {
|
|
149
|
+
directGems.delete(name);
|
|
150
|
+
}
|
|
151
|
+
return { gems, directGems };
|
|
152
|
+
}
|
|
153
|
+
async function generateRubyProjectManifest({
|
|
154
|
+
workPath,
|
|
155
|
+
gemfileLockPath,
|
|
156
|
+
framework,
|
|
157
|
+
serviceType
|
|
158
|
+
}) {
|
|
159
|
+
try {
|
|
160
|
+
if (!gemfileLockPath)
|
|
161
|
+
return;
|
|
162
|
+
let content;
|
|
163
|
+
try {
|
|
164
|
+
content = await import_fs.default.promises.readFile(gemfileLockPath, "utf-8");
|
|
165
|
+
} catch {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const { gems, directGems } = parseGemfileLock(content);
|
|
169
|
+
const directEntries = [];
|
|
170
|
+
const transitiveEntries = [];
|
|
171
|
+
for (const [name, version] of directGems) {
|
|
172
|
+
const gem = gems.get(name);
|
|
173
|
+
const entry = {
|
|
174
|
+
name,
|
|
175
|
+
type: "direct",
|
|
176
|
+
scopes: ["prod"],
|
|
177
|
+
...version ? { requested: version } : {},
|
|
178
|
+
resolved: gem?.version ?? ""
|
|
179
|
+
};
|
|
180
|
+
if (gem?.source)
|
|
181
|
+
entry.source = gem.source;
|
|
182
|
+
if (gem?.sourceUrl)
|
|
183
|
+
entry.sourceUrl = gem.sourceUrl;
|
|
184
|
+
directEntries.push(entry);
|
|
185
|
+
}
|
|
186
|
+
for (const [name, gem] of gems) {
|
|
187
|
+
if (directGems.has(name))
|
|
188
|
+
continue;
|
|
189
|
+
const entry = {
|
|
190
|
+
name,
|
|
191
|
+
type: "transitive",
|
|
192
|
+
scopes: ["prod"],
|
|
193
|
+
resolved: gem.version
|
|
194
|
+
};
|
|
195
|
+
if (gem.source)
|
|
196
|
+
entry.source = gem.source;
|
|
197
|
+
if (gem.sourceUrl)
|
|
198
|
+
entry.sourceUrl = gem.sourceUrl;
|
|
199
|
+
transitiveEntries.push(entry);
|
|
200
|
+
}
|
|
201
|
+
const manifest = {
|
|
202
|
+
version: import_package_manifest.MANIFEST_VERSION,
|
|
203
|
+
runtime: "ruby",
|
|
204
|
+
...framework ? { framework } : {},
|
|
205
|
+
...serviceType ? { serviceType } : {},
|
|
206
|
+
dependencies: [
|
|
207
|
+
...directEntries.sort((a, b) => a.name.localeCompare(b.name)),
|
|
208
|
+
...transitiveEntries.sort((a, b) => a.name.localeCompare(b.name))
|
|
209
|
+
]
|
|
210
|
+
};
|
|
211
|
+
await (0, import_package_manifest.writeProjectManifest)(manifest, workPath, "ruby");
|
|
212
|
+
} catch {
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
216
|
+
0 && (module.exports = {
|
|
217
|
+
generateRubyProjectManifest,
|
|
218
|
+
parseGemfileLock
|
|
219
|
+
});
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/build-utils",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.31.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"vitest": "2.0.1",
|
|
56
56
|
"typescript": "4.9.5",
|
|
57
57
|
"yazl": "2.5.1",
|
|
58
|
-
"@vercel/routing-utils": "6.3.
|
|
58
|
+
"@vercel/routing-utils": "6.3.1",
|
|
59
59
|
"@vercel/error-utils": "2.2.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|