vercel 30.2.1 → 30.2.2

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 +137 -76
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -222855,15 +222855,20 @@ class LocalFileSystemDetector extends filesystem_1.DetectorFilesystem {
222855
222855
  };
222856
222856
  return dir.map(dirent => ({
222857
222857
  name: dirent.name,
222858
- path: path_1.default.join(dirPath, dirent.name),
222858
+ path: path_1.default.join(this.getRelativeFilePath(name), dirent.name),
222859
222859
  type: getType(dirent),
222860
222860
  }));
222861
222861
  }
222862
222862
  _chdir(name) {
222863
222863
  return new LocalFileSystemDetector(this.getFilePath(name));
222864
222864
  }
222865
+ getRelativeFilePath(name) {
222866
+ return name.startsWith(this.rootPath)
222867
+ ? path_1.default.relative(this.rootPath, name)
222868
+ : name;
222869
+ }
222865
222870
  getFilePath(name) {
222866
- return path_1.default.join(this.rootPath, name);
222871
+ return path_1.default.join(this.rootPath, this.getRelativeFilePath(name));
222867
222872
  }
222868
222873
  }
222869
222874
  exports.LocalFileSystemDetector = LocalFileSystemDetector;
@@ -225731,10 +225736,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
225731
225736
  const fs_extra_1 = __importDefault(__webpack_require__(36365));
225732
225737
  const chalk_1 = __importDefault(__webpack_require__(90877));
225733
225738
  const dotenv_1 = __importDefault(__webpack_require__(9116));
225739
+ const semver_1 = __importDefault(__webpack_require__(54373));
225740
+ const minimatch_1 = __importDefault(__webpack_require__(47345));
225734
225741
  const path_1 = __webpack_require__(85622);
225742
+ const frameworks_1 = __importDefault(__webpack_require__(36678));
225735
225743
  const build_utils_1 = __webpack_require__(63445);
225736
225744
  const fs_detectors_1 = __webpack_require__(88995);
225737
- const minimatch_1 = __importDefault(__webpack_require__(47345));
225738
225745
  const routing_utils_1 = __webpack_require__(679);
225739
225746
  const client_1 = __webpack_require__(40521);
225740
225747
  const pull_1 = __importDefault(__webpack_require__(65158));
@@ -225757,9 +225764,6 @@ const sort_builders_1 = __webpack_require__(84701);
225757
225764
  const error_1 = __webpack_require__(4400);
225758
225765
  const validate_config_1 = __webpack_require__(21144);
225759
225766
  const monorepo_1 = __webpack_require__(21481);
225760
- const frameworks_1 = __importDefault(__webpack_require__(36678));
225761
- const fs_detectors_2 = __webpack_require__(88995);
225762
- const semver_1 = __importDefault(__webpack_require__(54373));
225763
225767
  const help = () => {
225764
225768
  return console.log(`
225765
225769
  ${chalk_1.default.bold(`${cli.logo} ${cli.name} build`)}
@@ -225785,7 +225789,8 @@ const help = () => {
225785
225789
  `);
225786
225790
  };
225787
225791
  async function main(client) {
225788
- const { cwd, output } = client;
225792
+ let { cwd } = client;
225793
+ const { output } = client;
225789
225794
  // Ensure that `vc build` is not being invoked recursively
225790
225795
  if (process.env.__VERCEL_BUILD_RUNNING) {
225791
225796
  output.error(`${(0, cmd_1.default)(`${cli.name} build`)} must not recursively invoke itself. Check the Build Command in the Project Settings or the ${(0, cmd_1.default)('build')} script in ${(0, cmd_1.default)('package.json')}`);
@@ -225816,9 +225821,16 @@ async function main(client) {
225816
225821
  output.prettyError(err);
225817
225822
  return 1;
225818
225823
  }
225824
+ // If repo linked, update `cwd` to the repo root
225825
+ const link = await (0, link_1.getProjectLink)(client, cwd);
225826
+ const projectRootDirectory = link?.projectRootDirectory ?? '';
225827
+ if (link?.repoRoot) {
225828
+ cwd = client.cwd = link.repoRoot;
225829
+ }
225819
225830
  // TODO: read project settings from the API, fall back to local `project.json` if that fails
225820
225831
  // Read project settings, and pull them from Vercel if necessary
225821
- let project = await (0, project_settings_1.readProjectSettings)((0, path_1.join)(cwd, link_1.VERCEL_DIR));
225832
+ const vercelDir = (0, path_1.join)(cwd, projectRootDirectory, link_1.VERCEL_DIR);
225833
+ let project = await (0, project_settings_1.readProjectSettings)(vercelDir);
225822
225834
  const isTTY = process.stdin.isTTY;
225823
225835
  while (!project?.settings) {
225824
225836
  let confirmed = yes;
@@ -225834,6 +225846,7 @@ async function main(client) {
225834
225846
  return 0;
225835
225847
  }
225836
225848
  const { argv: originalArgv } = client;
225849
+ client.cwd = (0, path_1.join)(cwd, projectRootDirectory);
225837
225850
  client.argv = [
225838
225851
  ...originalArgv.slice(0, 2),
225839
225852
  'pull',
@@ -225844,11 +225857,12 @@ async function main(client) {
225844
225857
  if (result !== 0) {
225845
225858
  return result;
225846
225859
  }
225860
+ client.cwd = cwd;
225847
225861
  client.argv = originalArgv;
225848
- project = await (0, project_settings_1.readProjectSettings)((0, path_1.join)(cwd, link_1.VERCEL_DIR));
225862
+ project = await (0, project_settings_1.readProjectSettings)(vercelDir);
225849
225863
  }
225850
225864
  // Delete output directory from potential previous build
225851
- const defaultOutputDir = (0, path_1.join)(cwd, write_build_result_1.OUTPUT_DIR);
225865
+ const defaultOutputDir = (0, path_1.join)(cwd, projectRootDirectory, write_build_result_1.OUTPUT_DIR);
225852
225866
  const outputDir = argv['--output']
225853
225867
  ? (0, path_1.resolve)(argv['--output'])
225854
225868
  : defaultOutputDir;
@@ -225864,7 +225878,7 @@ async function main(client) {
225864
225878
  };
225865
225879
  const envToUnset = new Set(['VERCEL', 'NOW_BUILDER']);
225866
225880
  try {
225867
- const envPath = (0, path_1.join)(cwd, link_1.VERCEL_DIR, `.env.${target}.local`);
225881
+ const envPath = (0, path_1.join)(cwd, projectRootDirectory, link_1.VERCEL_DIR, `.env.${target}.local`);
225868
225882
  // TODO (maybe?): load env vars from the API, fall back to the local file if that fails
225869
225883
  const dotenvResult = dotenv_1.default.config({
225870
225884
  path: envPath,
@@ -226226,7 +226240,7 @@ async function getFramework(cwd, buildResults) {
226226
226240
  }
226227
226241
  }
226228
226242
  // determine framework version with runtime lookup
226229
- const frameworkVersion = (0, fs_detectors_2.detectFrameworkVersion)(detectedFramework);
226243
+ const frameworkVersion = (0, fs_detectors_1.detectFrameworkVersion)(detectedFramework);
226230
226244
  if (frameworkVersion) {
226231
226245
  return {
226232
226246
  version: frameworkVersion,
@@ -227067,36 +227081,6 @@ exports.default = async (client) => {
227067
227081
  if (typeof target === 'number') {
227068
227082
  return target;
227069
227083
  }
227070
- // build `--prebuilt`
227071
- if (argv['--prebuilt']) {
227072
- const prebuiltExists = await fs_extra_1.default.pathExists((0, path_1.join)(cwd, '.vercel/output'));
227073
- if (!prebuiltExists) {
227074
- error(`The ${(0, param_1.default)('--prebuilt')} option was used, but no prebuilt output found in ".vercel/output". Run ${(0, pkg_name_1.getCommandName)('build')} to generate a local build.`);
227075
- return 1;
227076
- }
227077
- const prebuiltBuild = await (0, get_prebuilt_json_1.default)(cwd);
227078
- // Ensure that there was not a build error
227079
- const prebuiltError = prebuiltBuild?.error ||
227080
- prebuiltBuild?.builds?.find(build => 'error' in build)?.error;
227081
- if (prebuiltError) {
227082
- output.log(`Prebuilt deployment cannot be created because ${(0, pkg_name_1.getCommandName)('build')} failed with error:\n`);
227083
- prettyError(prebuiltError);
227084
- return 1;
227085
- }
227086
- // Ensure that the deploy target matches the build target
227087
- const assumedTarget = target || 'preview';
227088
- if (prebuiltBuild?.target && prebuiltBuild.target !== assumedTarget) {
227089
- let specifyTarget = '';
227090
- if (prebuiltBuild.target === 'production') {
227091
- specifyTarget = ` --prod`;
227092
- }
227093
- prettyError({
227094
- message: `The ${(0, param_1.default)('--prebuilt')} option was used with the target environment "${assumedTarget}", but the prebuilt output found in ".vercel/output" was built with target environment "${prebuiltBuild.target}". Please run ${(0, pkg_name_1.getCommandName)(`--prebuilt${specifyTarget}`)}.`,
227095
- link: 'https://vercel.link/prebuilt-environment-mismatch',
227096
- });
227097
- return 1;
227098
- }
227099
- }
227100
227084
  const archive = argv['--archive'];
227101
227085
  if (typeof archive === 'string' && !(0, validate_archive_format_1.isValidArchive)(archive)) {
227102
227086
  output.error(`Format must be one of: ${client_1.VALID_ARCHIVE_FORMATS.join(', ')}`);
@@ -227164,6 +227148,43 @@ exports.default = async (client) => {
227164
227148
  if (!org) {
227165
227149
  throw new Error(`"org" is not defined`);
227166
227150
  }
227151
+ // build `--prebuilt`
227152
+ if (argv['--prebuilt']) {
227153
+ // For repo-style linking, update `cwd` to be the Project
227154
+ // subdirectory when `rootDirectory` setting is defined
227155
+ if (link.status === 'linked' &&
227156
+ link.repoRoot &&
227157
+ link.project.rootDirectory) {
227158
+ cwd = (0, path_1.join)(cwd, link.project.rootDirectory);
227159
+ }
227160
+ const prebuiltExists = await fs_extra_1.default.pathExists((0, path_1.join)(cwd, '.vercel/output'));
227161
+ if (!prebuiltExists) {
227162
+ error(`The ${(0, param_1.default)('--prebuilt')} option was used, but no prebuilt output found in ".vercel/output". Run ${(0, pkg_name_1.getCommandName)('build')} to generate a local build.`);
227163
+ return 1;
227164
+ }
227165
+ const prebuiltBuild = await (0, get_prebuilt_json_1.default)(cwd);
227166
+ // Ensure that there was not a build error
227167
+ const prebuiltError = prebuiltBuild?.error ||
227168
+ prebuiltBuild?.builds?.find(build => 'error' in build)?.error;
227169
+ if (prebuiltError) {
227170
+ output.log(`Prebuilt deployment cannot be created because ${(0, pkg_name_1.getCommandName)('build')} failed with error:\n`);
227171
+ prettyError(prebuiltError);
227172
+ return 1;
227173
+ }
227174
+ // Ensure that the deploy target matches the build target
227175
+ const assumedTarget = target || 'preview';
227176
+ if (prebuiltBuild?.target && prebuiltBuild.target !== assumedTarget) {
227177
+ let specifyTarget = '';
227178
+ if (prebuiltBuild.target === 'production') {
227179
+ specifyTarget = ` --prod`;
227180
+ }
227181
+ prettyError({
227182
+ message: `The ${(0, param_1.default)('--prebuilt')} option was used with the target environment "${assumedTarget}", but the prebuilt output found in ".vercel/output" was built with target environment "${prebuiltBuild.target}". Please run ${(0, pkg_name_1.getCommandName)(`--prebuilt${specifyTarget}`)}.`,
227183
+ link: 'https://vercel.link/prebuilt-environment-mismatch',
227184
+ });
227185
+ return 1;
227186
+ }
227187
+ }
227167
227188
  // Set the `contextName` and `currentTeam` as specified by the
227168
227189
  // Project Settings, so that API calls happen with the proper scope
227169
227190
  const contextName = org.slug;
@@ -227509,7 +227530,11 @@ async function dev(client, opts, args) {
227509
227530
  let projectSettings;
227510
227531
  let envValues = {};
227511
227532
  if (link.status === 'linked') {
227512
- const { project, org } = link;
227533
+ const { project, org, repoRoot } = link;
227534
+ // If repo linked, update `cwd` to the repo root
227535
+ if (repoRoot) {
227536
+ cwd = repoRoot;
227537
+ }
227513
227538
  client.config.currentTeam = org.type === 'team' ? org.id : undefined;
227514
227539
  projectSettings = project;
227515
227540
  if (project.rootDirectory) {
@@ -229359,7 +229384,7 @@ async function main(client) {
229359
229384
  case 'rm':
229360
229385
  return (0, rm_1.default)(client, project, argv, args, output);
229361
229386
  case 'pull':
229362
- return (0, pull_1.default)(client, project, target, argv, args, output, cwd, 'vercel-cli:env:pull');
229387
+ return (0, pull_1.default)(client, link, project, target, argv, args, output, cwd, 'vercel-cli:env:pull');
229363
229388
  default:
229364
229389
  output.error((0, get_invalid_subcommand_1.default)(COMMAND_CONFIG));
229365
229390
  help();
@@ -229474,6 +229499,7 @@ const pkg_name_1 = __webpack_require__(79000);
229474
229499
  const get_env_records_1 = __webpack_require__(72913);
229475
229500
  const diff_env_files_1 = __webpack_require__(65117);
229476
229501
  const error_utils_1 = __webpack_require__(39799);
229502
+ const add_to_gitignore_1 = __webpack_require__(19159);
229477
229503
  const CONTENTS_PREFIX = '# Created by Vercel CLI\n';
229478
229504
  function readHeadSync(path, length) {
229479
229505
  const buffer = Buffer.alloc(length);
@@ -229496,7 +229522,7 @@ function tryReadHeadSync(path, length) {
229496
229522
  }
229497
229523
  }
229498
229524
  }
229499
- async function pull(client, project, environment, opts, args, output, cwd, source) {
229525
+ async function pull(client, link, project, environment, opts, args, output, cwd, source) {
229500
229526
  if (args.length > 1) {
229501
229527
  output.error(`Invalid number of arguments. Usage: ${(0, pkg_name_1.getCommandName)(`env pull <file>`)}`);
229502
229528
  return 1;
@@ -229550,7 +229576,17 @@ async function pull(client, project, environment, opts, args, output, cwd, sourc
229550
229576
  else if (oldEnv && exists) {
229551
229577
  output.log('No changes found.');
229552
229578
  }
229553
- output.print(`${(0, emoji_1.prependEmoji)(`${exists ? 'Updated' : 'Created'} ${chalk_1.default.bold(filename)} file ${chalk_1.default.gray(pullStamp())}`, (0, emoji_1.emoji)('success'))}\n`);
229579
+ let isGitIgnoreUpdated = false;
229580
+ if (filename === '.env.local') {
229581
+ // When the file is `.env.local`, we also add it to `.gitignore`
229582
+ // to avoid accidentally committing it to git.
229583
+ // We use '.env*.local' to match the default .gitignore from
229584
+ // create-next-app template. See:
229585
+ // https://github.com/vercel/next.js/blob/06abd634899095b6cc28e6e8315b1e8b9c8df939/packages/create-next-app/templates/app/js/gitignore#L28
229586
+ const rootPath = link.repoRoot ?? cwd;
229587
+ isGitIgnoreUpdated = await (0, add_to_gitignore_1.addToGitIgnore)(rootPath, '.env*.local');
229588
+ }
229589
+ output.print(`${(0, emoji_1.prependEmoji)(`${exists ? 'Updated' : 'Created'} ${chalk_1.default.bold(filename)} file ${isGitIgnoreUpdated ? 'and added it to .gitignore' : ''} ${chalk_1.default.gray(pullStamp())}`, (0, emoji_1.emoji)('success'))}\n`);
229554
229590
  return 0;
229555
229591
  }
229556
229592
  exports.default = pull;
@@ -232090,6 +232126,7 @@ const project_settings_1 = __webpack_require__(61440);
232090
232126
  const pull_1 = __importDefault(__webpack_require__(80800));
232091
232127
  const env_target_1 = __webpack_require__(20229);
232092
232128
  const ensure_link_1 = __webpack_require__(65382);
232129
+ const humanize_path_1 = __importDefault(__webpack_require__(33234));
232093
232130
  const help = () => {
232094
232131
  return console.log(`
232095
232132
  ${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()} pull`)} [project-path]
@@ -232137,9 +232174,9 @@ function parseArgs(client) {
232137
232174
  }
232138
232175
  return argv;
232139
232176
  }
232140
- async function pullAllEnvFiles(environment, client, project, argv, cwd) {
232177
+ async function pullAllEnvFiles(environment, client, link, project, argv, cwd) {
232141
232178
  const environmentFile = `.env.${environment}.local`;
232142
- return (0, pull_1.default)(client, project, environment, argv, [(0, path_1.join)('.vercel', environmentFile)], client.output, cwd, 'vercel-cli:pull');
232179
+ return (0, pull_1.default)(client, link, project, environment, argv, [(0, path_1.join)('.vercel', environmentFile)], client.output, cwd, 'vercel-cli:pull');
232143
232180
  }
232144
232181
  function parseEnvironment(environment = 'development') {
232145
232182
  if (!(0, env_target_1.isValidEnvTarget)(environment)) {
@@ -232153,24 +232190,28 @@ async function main(client) {
232153
232190
  if (typeof argv === 'number') {
232154
232191
  return argv;
232155
232192
  }
232156
- const cwd = argv._[1] || process.cwd();
232193
+ let cwd = argv._[1] || client.cwd;
232157
232194
  const autoConfirm = Boolean(argv['--yes']);
232158
232195
  const environment = parseEnvironment(argv['--environment'] || undefined);
232159
232196
  const link = await (0, ensure_link_1.ensureLink)('pull', client, cwd, { autoConfirm });
232160
232197
  if (typeof link === 'number') {
232161
232198
  return link;
232162
232199
  }
232163
- const { project, org } = link;
232200
+ const { project, org, repoRoot } = link;
232201
+ if (repoRoot) {
232202
+ cwd = (0, path_1.join)(repoRoot, project.rootDirectory || '');
232203
+ }
232164
232204
  client.config.currentTeam = org.type === 'team' ? org.id : undefined;
232165
- const pullResultCode = await pullAllEnvFiles(environment, client, project, argv, cwd);
232205
+ const pullResultCode = await pullAllEnvFiles(environment, client, link, project, argv, cwd);
232166
232206
  if (pullResultCode !== 0) {
232167
232207
  return pullResultCode;
232168
232208
  }
232169
232209
  client.output.print('\n');
232170
232210
  client.output.log('Downloading project settings');
232171
- await (0, project_settings_1.writeProjectSettings)(cwd, project, org);
232211
+ const isRepoLinked = typeof repoRoot === 'string';
232212
+ await (0, project_settings_1.writeProjectSettings)(cwd, project, org, isRepoLinked);
232172
232213
  const settingsStamp = (0, stamp_1.default)();
232173
- client.output.print(`${(0, emoji_1.prependEmoji)(`Downloaded project settings to ${chalk_1.default.bold((0, path_1.join)(link_1.VERCEL_DIR, link_1.VERCEL_DIR_PROJECT))} ${chalk_1.default.gray(settingsStamp())}`, (0, emoji_1.emoji)('success'))}\n`);
232214
+ client.output.print(`${(0, emoji_1.prependEmoji)(`Downloaded project settings to ${chalk_1.default.bold((0, humanize_path_1.default)((0, path_1.join)(cwd, link_1.VERCEL_DIR, link_1.VERCEL_DIR_PROJECT)))} ${chalk_1.default.gray(settingsStamp())}`, (0, emoji_1.emoji)('success'))}\n`);
232174
232215
  return 0;
232175
232216
  }
232176
232217
  exports.default = main;
@@ -246010,10 +246051,10 @@ const link_1 = __webpack_require__(49347);
246010
246051
  * directory
246011
246052
  * @param opts.projectName - The project name to use when linking, otherwise
246012
246053
  * the current directory
246013
- * @returns {Promise<LinkResult|number>} Returns a numeric exit code when aborted or
246054
+ * @returns {Promise<ProjectLinked|number>} Returns a numeric exit code when aborted or
246014
246055
  * error, otherwise an object containing the org an project
246015
246056
  */
246016
- async function ensureLink(commandName, client, cwd, opts) {
246057
+ async function ensureLink(commandName, client, cwd, opts = {}) {
246017
246058
  let { link } = opts;
246018
246059
  if (!link) {
246019
246060
  link = await (0, link_1.getLinkedProject)(client, cwd);
@@ -246033,7 +246074,7 @@ async function ensureLink(commandName, client, cwd, opts) {
246033
246074
  }
246034
246075
  return link.exitCode;
246035
246076
  }
246036
- return { org: link.org, project: link.project };
246077
+ return link;
246037
246078
  }
246038
246079
  exports.ensureLink = ensureLink;
246039
246080
 
@@ -246049,7 +246090,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
246049
246090
  return (mod && mod.__esModule) ? mod : { "default": mod };
246050
246091
  };
246051
246092
  Object.defineProperty(exports, "__esModule", ({ value: true }));
246052
- exports.findProjectFromPath = exports.findProjectsFromPath = exports.traverseUpDirectories = exports.findRepoRoot = exports.ensureRepoLink = exports.getRepoLink = void 0;
246093
+ exports.findProjectsFromPath = exports.traverseUpDirectories = exports.findRepoRoot = exports.ensureRepoLink = exports.getRepoLink = void 0;
246053
246094
  const chalk_1 = __importDefault(__webpack_require__(90877));
246054
246095
  const pluralize_1 = __importDefault(__webpack_require__(43669));
246055
246096
  const os_1 = __webpack_require__(12087);
@@ -246173,7 +246214,7 @@ async function ensureRepoLink(client, cwd, yes = false) {
246173
246214
  }),
246174
246215
  };
246175
246216
  await (0, fs_extra_1.outputJSON)(repoConfigPath, repoConfig, { spaces: 2 });
246176
- await (0, fs_extra_1.writeFile)((0, path_1.join)(rootPath, link_1.VERCEL_DIR, link_1.VERCEL_DIR_README), await (0, fs_extra_1.readFile)((0, path_1.join)(__dirname, 'VERCEL_DIR_README.txt'), 'utf8'));
246217
+ await (0, link_1.writeReadme)(rootPath);
246177
246218
  // update .gitignore
246178
246219
  const isGitIgnoreUpdated = await (0, add_to_gitignore_1.addToGitIgnore)(rootPath);
246179
246220
  output.print((0, emoji_1.prependEmoji)(`Linked to ${(0, link_2.default)(repoUrl)} under ${chalk_1.default.bold(org.slug)} (created ${link_1.VERCEL_DIR}${isGitIgnoreUpdated ? ' and added it to .gitignore' : ''})`, (0, emoji_1.emoji)('link')) + '\n');
@@ -246243,7 +246284,7 @@ function sortByDirectory(a, b) {
246243
246284
  */
246244
246285
  function findProjectsFromPath(projects, path) {
246245
246286
  const normalizedPath = (0, build_utils_1.normalizePath)(path);
246246
- return projects
246287
+ const matches = projects
246247
246288
  .slice()
246248
246289
  .sort(sortByDirectory)
246249
246290
  .filter(project => {
@@ -246254,15 +246295,13 @@ function findProjectsFromPath(projects, path) {
246254
246295
  return (normalizedPath === project.directory ||
246255
246296
  normalizedPath.startsWith(`${project.directory}/`));
246256
246297
  });
246298
+ // If there are multiple matches, we only want the most relevant
246299
+ // selections (with the deepest directory depth), so pick the first
246300
+ // one and filter on those matches.
246301
+ const firstMatch = matches[0];
246302
+ return matches.filter(match => match.directory === firstMatch.directory);
246257
246303
  }
246258
246304
  exports.findProjectsFromPath = findProjectsFromPath;
246259
- /**
246260
- * TODO: remove
246261
- */
246262
- function findProjectFromPath(projects, path) {
246263
- return findProjectsFromPath(projects, path)[0];
246264
- }
246265
- exports.findProjectFromPath = findProjectFromPath;
246266
246305
 
246267
246306
 
246268
246307
  /***/ }),
@@ -248429,7 +248468,7 @@ async function getProjectByDeployment({ client, deployId, output, }) {
248429
248468
  throw err;
248430
248469
  }
248431
248470
  }
248432
- if (team) {
248471
+ else if (team) {
248433
248472
  const err = new Error(`Deployment doesn't belong to current team ${chalk_1.default.bold(contextName)}`);
248434
248473
  err.code = 'ERR_INVALID_TEAM';
248435
248474
  throw err;
@@ -248490,7 +248529,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
248490
248529
  return (mod && mod.__esModule) ? mod : { "default": mod };
248491
248530
  };
248492
248531
  Object.defineProperty(exports, "__esModule", ({ value: true }));
248493
- exports.linkFolderToProject = exports.getLinkedProject = exports.getLinkFromDir = exports.getVercelDirectory = exports.VERCEL_DIR_REPO = exports.VERCEL_DIR_PROJECT = exports.VERCEL_DIR_README = exports.VERCEL_DIR_FALLBACK = exports.VERCEL_DIR = void 0;
248532
+ exports.linkFolderToProject = exports.writeReadme = exports.getLinkedProject = exports.getLinkFromDir = exports.getProjectLink = exports.getVercelDirectory = exports.VERCEL_DIR_REPO = exports.VERCEL_DIR_PROJECT = exports.VERCEL_DIR_README = exports.VERCEL_DIR_FALLBACK = exports.VERCEL_DIR = void 0;
248494
248533
  const fs_1 = __importDefault(__webpack_require__(35747));
248495
248534
  const ajv_1 = __importDefault(__webpack_require__(35669));
248496
248535
  const chalk_1 = __importDefault(__webpack_require__(90877));
@@ -248552,6 +248591,7 @@ async function getProjectLink(client, path) {
248552
248591
  return ((await getProjectLinkFromRepoLink(client, path)) ||
248553
248592
  (await getLinkFromDir(getVercelDirectory(path))));
248554
248593
  }
248594
+ exports.getProjectLink = getProjectLink;
248555
248595
  async function getProjectLinkFromRepoLink(client, path) {
248556
248596
  const repoLink = await (0, repo_1.getRepoLink)(path);
248557
248597
  if (!repoLink?.repoConfig) {
@@ -248576,9 +248616,10 @@ async function getProjectLinkFromRepoLink(client, path) {
248576
248616
  }
248577
248617
  if (project) {
248578
248618
  return {
248619
+ repoRoot: repoLink.rootPath,
248579
248620
  orgId: repoLink.repoConfig.orgId,
248580
248621
  projectId: project.id,
248581
- repoRoot: repoLink.rootPath,
248622
+ projectRootDirectory: project.directory,
248582
248623
  };
248583
248624
  }
248584
248625
  return null;
@@ -248701,6 +248742,10 @@ async function getLinkedProject(client, path = client.cwd) {
248701
248742
  return { status: 'linked', org, project, repoRoot: link.repoRoot };
248702
248743
  }
248703
248744
  exports.getLinkedProject = getLinkedProject;
248745
+ async function writeReadme(path) {
248746
+ await writeFile((0, path_1.join)(path, exports.VERCEL_DIR, exports.VERCEL_DIR_README), await readFile((0, path_1.join)(__dirname, 'VERCEL_DIR_README.txt'), 'utf8'));
248747
+ }
248748
+ exports.writeReadme = writeReadme;
248704
248749
  async function linkFolderToProject(client, path, projectLink, projectName, orgSlug, successEmoji = 'link') {
248705
248750
  // if the project is already linked, we skip linking
248706
248751
  if (await hasProjectLink(projectLink, path)) {
@@ -248718,7 +248763,7 @@ async function linkFolderToProject(client, path, projectLink, projectName, orgSl
248718
248763
  throw err;
248719
248764
  }
248720
248765
  await writeFile((0, path_1.join)(path, exports.VERCEL_DIR, exports.VERCEL_DIR_PROJECT), JSON.stringify(projectLink));
248721
- await writeFile((0, path_1.join)(path, exports.VERCEL_DIR, exports.VERCEL_DIR_README), await readFile((0, path_1.join)(__dirname, 'VERCEL_DIR_README.txt'), 'utf8'));
248766
+ await writeReadme(path);
248722
248767
  // update .gitignore
248723
248768
  const isGitIgnoreUpdated = await (0, add_to_gitignore_1.addToGitIgnore)(path);
248724
248769
  client.output.print((0, emoji_1.prependEmoji)(`Linked to ${chalk_1.default.bold(`${orgSlug}/${projectName}`)} (created ${exports.VERCEL_DIR}${isGitIgnoreUpdated ? ' and added it to .gitignore' : ''})`, (0, emoji_1.emoji)(successEmoji)) + '\n');
@@ -248735,13 +248780,14 @@ exports.linkFolderToProject = linkFolderToProject;
248735
248780
 
248736
248781
  Object.defineProperty(exports, "__esModule", ({ value: true }));
248737
248782
  exports.pickOverrides = exports.readProjectSettings = exports.writeProjectSettings = void 0;
248783
+ const path_1 = __webpack_require__(85622);
248738
248784
  const fs_extra_1 = __webpack_require__(36365);
248739
248785
  const link_1 = __webpack_require__(49347);
248740
- const path_1 = __webpack_require__(85622);
248786
+ const error_utils_1 = __webpack_require__(39799);
248741
248787
  // writeProjectSettings writes the project configuration to `vercel/project.json`
248742
248788
  // Write the project configuration to `.vercel/project.json`
248743
248789
  // that is needed for `vercel build` and `vercel dev` commands
248744
- async function writeProjectSettings(cwd, project, org) {
248790
+ async function writeProjectSettings(cwd, project, org, isRepoLinked) {
248745
248791
  let analyticsId;
248746
248792
  if (project.analytics?.id &&
248747
248793
  (!project.analytics.disabledAt ||
@@ -248750,8 +248796,8 @@ async function writeProjectSettings(cwd, project, org) {
248750
248796
  analyticsId = project.analytics.id;
248751
248797
  }
248752
248798
  const projectLinkAndSettings = {
248753
- projectId: project.id,
248754
- orgId: org.id,
248799
+ projectId: isRepoLinked ? undefined : project.id,
248800
+ orgId: isRepoLinked ? undefined : org.id,
248755
248801
  settings: {
248756
248802
  createdAt: project.createdAt,
248757
248803
  framework: project.framework,
@@ -248771,8 +248817,23 @@ async function writeProjectSettings(cwd, project, org) {
248771
248817
  });
248772
248818
  }
248773
248819
  exports.writeProjectSettings = writeProjectSettings;
248774
- async function readProjectSettings(cwd) {
248775
- return await (0, link_1.getLinkFromDir)(cwd);
248820
+ async function readProjectSettings(vercelDir) {
248821
+ try {
248822
+ return JSON.parse(await (0, fs_extra_1.readFile)((0, path_1.join)(vercelDir, link_1.VERCEL_DIR_PROJECT), 'utf8'));
248823
+ }
248824
+ catch (err) {
248825
+ // `project.json` file does not exists, so project settings have not been pulled
248826
+ if ((0, error_utils_1.isErrnoException)(err) &&
248827
+ err.code &&
248828
+ ['ENOENT', 'ENOTDIR'].includes(err.code)) {
248829
+ return null;
248830
+ }
248831
+ // failed to parse JSON, treat the same as if project settings have not been pulled
248832
+ if ((0, error_utils_1.isError)(err) && err.name === 'SyntaxError') {
248833
+ return null;
248834
+ }
248835
+ throw err;
248836
+ }
248776
248837
  }
248777
248838
  exports.readProjectSettings = readProjectSettings;
248778
248839
  function pickOverrides(vercelConfig) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vercel",
3
- "version": "30.2.1",
3
+ "version": "30.2.2",
4
4
  "preferGlobal": true,
5
5
  "license": "Apache-2.0",
6
6
  "description": "The command-line interface for Vercel",
@@ -81,7 +81,7 @@
81
81
  "@vercel/client": "12.6.2",
82
82
  "@vercel/error-utils": "1.0.10",
83
83
  "@vercel/frameworks": "1.4.2",
84
- "@vercel/fs-detectors": "3.9.3",
84
+ "@vercel/fs-detectors": "4.0.0",
85
85
  "@vercel/fun": "1.0.4",
86
86
  "@vercel/ncc": "0.24.0",
87
87
  "@vercel/routing-utils": "2.2.1",