@vercel/build-utils 13.30.0 → 13.31.1

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.
@@ -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
@@ -55,6 +55,7 @@ export interface Meta {
55
55
  filesRemoved?: string[];
56
56
  env?: Env;
57
57
  buildEnv?: Env;
58
+ port?: number;
58
59
  [key: string]: unknown;
59
60
  }
60
61
  export interface BuildOptions {
@@ -288,6 +289,7 @@ export declare namespace PackageJson {
288
289
  node?: string;
289
290
  npm?: string;
290
291
  pnpm?: string;
292
+ bun?: string;
291
293
  }
292
294
  interface PublishConfig {
293
295
  registry?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "13.30.0",
3
+ "version": "13.31.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -56,7 +56,7 @@
56
56
  "typescript": "4.9.5",
57
57
  "yazl": "2.5.1",
58
58
  "@vercel/error-utils": "2.2.0",
59
- "@vercel/routing-utils": "6.3.0"
59
+ "@vercel/routing-utils": "6.3.1"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "node build.mjs",