@vercel/ruby 31.0.0 → 32.0.0-snapshot-4bb5562899c1

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.
Files changed (2) hide show
  1. package/dist/index.js +45 -12
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -6959,6 +6959,7 @@ var import_path = require("path");
6959
6959
  var import_semver = __toESM(require_semver2());
6960
6960
  var import_build_utils = require("@vercel/build-utils");
6961
6961
  var import_child_process = require("child_process");
6962
+ var import_fs = require("fs");
6962
6963
  var import_os = require("os");
6963
6964
  var RubyVersion = class extends import_build_utils.Version {
6964
6965
  };
@@ -7022,7 +7023,6 @@ function makeLocalRubyEnv({
7022
7023
  rubyPath,
7023
7024
  gemPath
7024
7025
  }) {
7025
- const gemHome = (0, import_path.join)((0, import_os.tmpdir)(), `vercel-ruby-${major}${minor}-${process.pid}`);
7026
7026
  const matchedOption = allOptions.find(
7027
7027
  (o) => o.major === major && o.minor === minor && o.state !== "discontinued"
7028
7028
  );
@@ -7033,9 +7033,11 @@ function makeLocalRubyEnv({
7033
7033
  message: `Local Ruby ${major}.${minor} does not match any supported Vercel runtime. Supported: ${allOptions.filter((o) => o.state !== "discontinued").map((o) => `${o.major}.${o.minor}`).join(", ")}`
7034
7034
  });
7035
7035
  }
7036
+ const gemHome = (0, import_fs.mkdtempSync)((0, import_path.join)((0, import_os.tmpdir)(), `vercel-ruby-${major}${minor}-`));
7036
7037
  return {
7037
7038
  major,
7038
7039
  gemHome,
7040
+ temporaryGemHome: true,
7039
7041
  runtime: matchedOption.runtime,
7040
7042
  rubyPath,
7041
7043
  gemPath,
@@ -7111,6 +7113,7 @@ function getRubyPath(meta, gemfileContents) {
7111
7113
  const result = {
7112
7114
  major,
7113
7115
  gemHome,
7116
+ temporaryGemHome: false,
7114
7117
  runtime,
7115
7118
  rubyPath: (0, import_path.join)(gemHome, "bin", "ruby"),
7116
7119
  gemPath: (0, import_path.join)(gemHome, "bin", "gem"),
@@ -7134,7 +7137,15 @@ function getRubyPath(meta, gemfileContents) {
7134
7137
  });
7135
7138
  }
7136
7139
  async function installBundler(meta, gemfileContents) {
7137
- const { gemHome, rubyPath, gemPath, vendorPath, runtime, major } = getRubyPath(meta, gemfileContents);
7140
+ const {
7141
+ gemHome,
7142
+ rubyPath,
7143
+ gemPath,
7144
+ vendorPath,
7145
+ runtime,
7146
+ major,
7147
+ temporaryGemHome
7148
+ } = getRubyPath(meta, gemfileContents);
7138
7149
  (0, import_build_utils.debug)("installing bundler...");
7139
7150
  await (0, import_execa.default)(gemPath, ["install", "bundler", "--no-document"], {
7140
7151
  stdio: "pipe",
@@ -7145,6 +7156,7 @@ async function installBundler(meta, gemfileContents) {
7145
7156
  return {
7146
7157
  major,
7147
7158
  gemHome,
7159
+ temporaryGemHome,
7148
7160
  rubyPath,
7149
7161
  gemPath,
7150
7162
  vendorPath,
@@ -7163,7 +7175,7 @@ var diagnostics = (0, import_build_utils2.createDiagnostics)("ruby");
7163
7175
 
7164
7176
  // src/start-dev-server.ts
7165
7177
  var import_child_process2 = require("child_process");
7166
- var import_fs = require("fs");
7178
+ var import_fs2 = require("fs");
7167
7179
  var import_path2 = require("path");
7168
7180
  var import_which2 = __toESM(require_lib2());
7169
7181
  var import_build_utils3 = require("@vercel/build-utils");
@@ -7235,16 +7247,16 @@ function installGlobalCleanupHandlers() {
7235
7247
  function createDevRubyShim(workPath, entrypoint) {
7236
7248
  try {
7237
7249
  const vercelRubyDir = (0, import_path2.join)(workPath, ".vercel", "ruby");
7238
- (0, import_fs.mkdirSync)(vercelRubyDir, { recursive: true });
7250
+ (0, import_fs2.mkdirSync)(vercelRubyDir, { recursive: true });
7239
7251
  const shimPath = (0, import_path2.join)(vercelRubyDir, `vc_init_dev.rb`);
7240
7252
  const utilsPath = (0, import_path2.join)(vercelRubyDir, "vc__utils__ruby.rb");
7241
7253
  const templatePath = (0, import_path2.join)(__dirname, "..", "vc_init_dev.rb");
7242
7254
  const utilsTemplatePath = (0, import_path2.join)(__dirname, "..", "vc_utils.rb");
7243
- const template = (0, import_fs.readFileSync)(templatePath, "utf8");
7244
- const utilsTemplate = (0, import_fs.readFileSync)(utilsTemplatePath, "utf8");
7255
+ const template = (0, import_fs2.readFileSync)(templatePath, "utf8");
7256
+ const utilsTemplate = (0, import_fs2.readFileSync)(utilsTemplatePath, "utf8");
7245
7257
  const shimSource = template.replace(/__VC_DEV_ENTRYPOINT__/g, entrypoint);
7246
- (0, import_fs.writeFileSync)(shimPath, shimSource, "utf8");
7247
- (0, import_fs.writeFileSync)(utilsPath, utilsTemplate, "utf8");
7258
+ (0, import_fs2.writeFileSync)(shimPath, shimSource, "utf8");
7259
+ (0, import_fs2.writeFileSync)(utilsPath, utilsTemplate, "utf8");
7248
7260
  (0, import_build_utils3.debug)(`Prepared Ruby dev shim at ${shimPath}`);
7249
7261
  return shimPath;
7250
7262
  } catch (err) {
@@ -7255,10 +7267,10 @@ function createDevRubyShim(workPath, entrypoint) {
7255
7267
  function detectGemfile(workPath, entrypoint) {
7256
7268
  const entryDir = (0, import_path2.dirname)(entrypoint);
7257
7269
  const localGemfile = (0, import_path2.join)(workPath, entryDir, "Gemfile");
7258
- if ((0, import_fs.existsSync)(localGemfile))
7270
+ if ((0, import_fs2.existsSync)(localGemfile))
7259
7271
  return localGemfile;
7260
7272
  const rootGemfile = (0, import_path2.join)(workPath, "Gemfile");
7261
- if ((0, import_fs.existsSync)(rootGemfile))
7273
+ if ((0, import_fs2.existsSync)(rootGemfile))
7262
7274
  return rootGemfile;
7263
7275
  return null;
7264
7276
  }
@@ -7607,7 +7619,16 @@ var build = async ({
7607
7619
  await (0, import_fs_extra.writeFile)(gemfilePath, `source "https://rubygems.org"${import_os2.EOL}`);
7608
7620
  }
7609
7621
  const gemfileContents = gemfilePath ? await (0, import_fs_extra.readFile)(gemfilePath, "utf8") : "";
7610
- const { gemHome, bundlerPath, vendorPath, runtime, rubyPath, major } = await installBundler(meta, gemfileContents);
7622
+ const {
7623
+ gemHome,
7624
+ bundlerPath,
7625
+ vendorPath,
7626
+ runtime,
7627
+ rubyPath,
7628
+ major,
7629
+ temporaryGemHome
7630
+ } = await installBundler(meta, gemfileContents);
7631
+ const previousGemHome = process.env.GEM_HOME;
7611
7632
  process.env.GEM_HOME = gemHome;
7612
7633
  try {
7613
7634
  (0, import_build_utils4.debug)("preparing Gemfile");
@@ -7639,7 +7660,19 @@ var build = async ({
7639
7660
  (0, import_build_utils4.debug)("found vendor directory in project root");
7640
7661
  }
7641
7662
  await (0, import_fs_extra.ensureDir)(vendorDir);
7642
- await bundleInstall(bundlerPath, bundleDir, gemfilePath, rubyPath);
7663
+ try {
7664
+ await bundleInstall(bundlerPath, bundleDir, gemfilePath, rubyPath);
7665
+ } finally {
7666
+ if (temporaryGemHome) {
7667
+ await (0, import_fs_extra.remove)(gemHome).catch(() => {
7668
+ });
7669
+ if (previousGemHome === void 0) {
7670
+ delete process.env.GEM_HOME;
7671
+ } else {
7672
+ process.env.GEM_HOME = previousGemHome;
7673
+ }
7674
+ }
7675
+ }
7643
7676
  try {
7644
7677
  await (0, import_fs_extra.remove)((0, import_path3.join)(vendorDir, "cache"));
7645
7678
  } catch (_e) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vercel/ruby",
3
3
  "author": "Nathan Cahill <nathan@nathancahill.com>",
4
- "version": "31.0.0",
4
+ "version": "32.0.0-snapshot-4bb5562899c1",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index",
7
7
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {},
20
20
  "peerDependencies": {
21
- "@vercel/build-utils": "15.7.0"
21
+ "@vercel/build-utils": "15.8.0-snapshot-4bb5562899c1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/fs-extra": "8.0.0",
@@ -29,7 +29,7 @@
29
29
  "semver": "6.3.1",
30
30
  "vitest": "4.1.10",
31
31
  "which": "3.0.0",
32
- "@vercel/build-utils": "15.7.0"
32
+ "@vercel/build-utils": "15.8.0-snapshot-4bb5562899c1"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "node ../../utils/build-builder.mjs",