vercel 29.3.5 → 29.4.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 +307 -34
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -221772,7 +221772,7 @@ async function detectBuilders(files, pkg, options = {}) {
|
|
221772
221772
|
apiBuilders.some(b => (0, is_official_runtime_1.isOfficialRuntime)('node', b.use))) {
|
221773
221773
|
warnings.push({
|
221774
221774
|
code: 'conflicting_files',
|
221775
|
-
message: 'When using Next.js, it is recommended to place
|
221775
|
+
message: 'When using Next.js, it is recommended to place JavaScript Functions inside of the `pages/api` (provided by Next.js) directory instead of `api` (provided by Vercel). Other languages (Python, Go, etc) should still go in the `api` directory.',
|
221776
221776
|
link: 'https://nextjs.org/docs/api-routes/introduction',
|
221777
221777
|
action: 'Learn More',
|
221778
221778
|
});
|
@@ -230640,8 +230640,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
230640
230640
|
const chalk_1 = __importDefault(__webpack_require__(90877));
|
230641
230641
|
const get_args_1 = __importDefault(__webpack_require__(2505));
|
230642
230642
|
const logo_1 = __importDefault(__webpack_require__(66669));
|
230643
|
+
const cmd_1 = __importDefault(__webpack_require__(62422));
|
230643
230644
|
const pkg_name_1 = __webpack_require__(79000);
|
230644
230645
|
const ensure_link_1 = __webpack_require__(65382);
|
230646
|
+
const repo_1 = __webpack_require__(18726);
|
230645
230647
|
const help = () => {
|
230646
230648
|
console.log(`
|
230647
230649
|
${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()} link`)} [options]
|
@@ -230649,6 +230651,7 @@ const help = () => {
|
|
230649
230651
|
${chalk_1.default.dim('Options:')}
|
230650
230652
|
|
230651
230653
|
-h, --help Output usage information
|
230654
|
+
-r, --repo Link multiple projects based on Git repository (alpha)
|
230652
230655
|
-A ${chalk_1.default.bold.underline('FILE')}, --local-config=${chalk_1.default.bold.underline('FILE')} Path to the local ${'`vercel.json`'} file
|
230653
230656
|
-Q ${chalk_1.default.bold.underline('DIR')}, --global-config=${chalk_1.default.bold.underline('DIR')} Path to the global ${'`.vercel`'} directory
|
230654
230657
|
-d, --debug Debug mode [off]
|
@@ -230669,7 +230672,12 @@ const help = () => {
|
|
230669
230672
|
|
230670
230673
|
${chalk_1.default.gray('–')} Link a specific directory to a Vercel Project
|
230671
230674
|
|
230672
|
-
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} link /
|
230675
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} link --cwd /path/to/project`)}
|
230676
|
+
|
230677
|
+
${chalk_1.default.gray('–')} ${chalk_1.default.yellow('(alpha)')} Link to the current Git repository, allowing for multiple
|
230678
|
+
Vercel Projects to be linked simultaneously (useful for monorepos)
|
230679
|
+
|
230680
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} link --repo`)}
|
230673
230681
|
`);
|
230674
230682
|
};
|
230675
230683
|
async function main(client) {
|
@@ -230678,6 +230686,8 @@ async function main(client) {
|
|
230678
230686
|
'-y': '--yes',
|
230679
230687
|
'--project': String,
|
230680
230688
|
'-p': '--project',
|
230689
|
+
'--repo': Boolean,
|
230690
|
+
'-r': '--repo',
|
230681
230691
|
// deprecated
|
230682
230692
|
'--confirm': Boolean,
|
230683
230693
|
'-c': '--confirm',
|
@@ -230690,15 +230700,28 @@ async function main(client) {
|
|
230690
230700
|
client.output.warn('`--confirm` is deprecated, please use `--yes` instead');
|
230691
230701
|
argv['--yes'] = argv['--confirm'];
|
230692
230702
|
}
|
230693
|
-
const
|
230694
|
-
|
230695
|
-
|
230696
|
-
|
230697
|
-
|
230698
|
-
|
230699
|
-
|
230700
|
-
|
230701
|
-
|
230703
|
+
const yes = !!argv['--yes'];
|
230704
|
+
let cwd = argv._[1];
|
230705
|
+
if (cwd) {
|
230706
|
+
client.output.warn(`The ${(0, cmd_1.default)('vc link <directory>')} syntax is deprecated, please use ${(0, cmd_1.default)(`vc link --cwd ${cwd}`)} instead`);
|
230707
|
+
}
|
230708
|
+
else {
|
230709
|
+
cwd = process.cwd();
|
230710
|
+
}
|
230711
|
+
if (argv['--repo']) {
|
230712
|
+
client.output.warn(`The ${(0, cmd_1.default)('--repo')} flag is in alpha, please report issues`);
|
230713
|
+
await (0, repo_1.ensureRepoLink)(client, cwd, yes);
|
230714
|
+
}
|
230715
|
+
else {
|
230716
|
+
const link = await (0, ensure_link_1.ensureLink)('link', client, cwd, {
|
230717
|
+
autoConfirm: yes,
|
230718
|
+
forceDelete: true,
|
230719
|
+
projectName: argv['--project'],
|
230720
|
+
successEmoji: 'success',
|
230721
|
+
});
|
230722
|
+
if (typeof link === 'number') {
|
230723
|
+
return link;
|
230724
|
+
}
|
230702
230725
|
}
|
230703
230726
|
return 0;
|
230704
230727
|
}
|
@@ -245059,6 +245082,46 @@ function isValidName(name = '') {
|
|
245059
245082
|
exports.isValidName = isValidName;
|
245060
245083
|
|
245061
245084
|
|
245085
|
+
/***/ }),
|
245086
|
+
|
245087
|
+
/***/ 19159:
|
245088
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
245089
|
+
|
245090
|
+
"use strict";
|
245091
|
+
|
245092
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
245093
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
245094
|
+
};
|
245095
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
245096
|
+
exports.addToGitIgnore = void 0;
|
245097
|
+
const os_1 = __importDefault(__webpack_require__(12087));
|
245098
|
+
const path_1 = __webpack_require__(85622);
|
245099
|
+
const fs_extra_1 = __webpack_require__(36365);
|
245100
|
+
const link_1 = __webpack_require__(49347);
|
245101
|
+
async function addToGitIgnore(path, ignore = link_1.VERCEL_DIR) {
|
245102
|
+
let isGitIgnoreUpdated = false;
|
245103
|
+
try {
|
245104
|
+
const gitIgnorePath = (0, path_1.join)(path, '.gitignore');
|
245105
|
+
let gitIgnore = (await (0, fs_extra_1.readFile)(gitIgnorePath, 'utf8').catch(() => null)) ?? '';
|
245106
|
+
const EOL = gitIgnore.includes('\r\n') ? '\r\n' : os_1.default.EOL;
|
245107
|
+
let contentModified = false;
|
245108
|
+
if (!gitIgnore.split(EOL).includes(ignore)) {
|
245109
|
+
gitIgnore += `${gitIgnore.endsWith(EOL) || gitIgnore.length === 0 ? '' : EOL}${ignore}${EOL}`;
|
245110
|
+
contentModified = true;
|
245111
|
+
}
|
245112
|
+
if (contentModified) {
|
245113
|
+
await (0, fs_extra_1.writeFile)(gitIgnorePath, gitIgnore);
|
245114
|
+
isGitIgnoreUpdated = true;
|
245115
|
+
}
|
245116
|
+
}
|
245117
|
+
catch (error) {
|
245118
|
+
// ignore errors since this is non-critical
|
245119
|
+
}
|
245120
|
+
return isGitIgnoreUpdated;
|
245121
|
+
}
|
245122
|
+
exports.addToGitIgnore = addToGitIgnore;
|
245123
|
+
|
245124
|
+
|
245062
245125
|
/***/ }),
|
245063
245126
|
|
245064
245127
|
/***/ 65382:
|
@@ -245115,6 +245178,204 @@ async function ensureLink(commandName, client, cwd, opts) {
|
|
245115
245178
|
exports.ensureLink = ensureLink;
|
245116
245179
|
|
245117
245180
|
|
245181
|
+
/***/ }),
|
245182
|
+
|
245183
|
+
/***/ 18726:
|
245184
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
245185
|
+
|
245186
|
+
"use strict";
|
245187
|
+
|
245188
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
245189
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
245190
|
+
};
|
245191
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
245192
|
+
exports.findProjectFromPath = exports.traverseUpDirectories = exports.findRepoRoot = exports.ensureRepoLink = exports.getRepoLink = void 0;
|
245193
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
245194
|
+
const pluralize_1 = __importDefault(__webpack_require__(43669));
|
245195
|
+
const os_1 = __webpack_require__(12087);
|
245196
|
+
const path_1 = __webpack_require__(85622);
|
245197
|
+
const build_utils_1 = __webpack_require__(63445);
|
245198
|
+
const fs_extra_1 = __webpack_require__(36365);
|
245199
|
+
const confirm_1 = __importDefault(__webpack_require__(59320));
|
245200
|
+
const humanize_path_1 = __importDefault(__webpack_require__(33234));
|
245201
|
+
const link_1 = __webpack_require__(49347);
|
245202
|
+
const create_git_meta_1 = __webpack_require__(30019);
|
245203
|
+
const link_2 = __importDefault(__webpack_require__(39302));
|
245204
|
+
const emoji_1 = __webpack_require__(35172);
|
245205
|
+
const select_org_1 = __importDefault(__webpack_require__(96339));
|
245206
|
+
const add_to_gitignore_1 = __webpack_require__(19159);
|
245207
|
+
const home = (0, os_1.homedir)();
|
245208
|
+
/**
|
245209
|
+
* Given a directory path `cwd`, finds the root of the Git repository
|
245210
|
+
* and returns the parsed `.vercel/repo.json` file if the repository
|
245211
|
+
* has already been linked.
|
245212
|
+
*/
|
245213
|
+
async function getRepoLink(cwd) {
|
245214
|
+
// Determine where the root of the repo is
|
245215
|
+
const rootPath = await findRepoRoot(cwd);
|
245216
|
+
if (!rootPath)
|
245217
|
+
return undefined;
|
245218
|
+
// Read the `repo.json`, if this repo has already been linked
|
245219
|
+
const repoConfigPath = (0, path_1.join)(rootPath, link_1.VERCEL_DIR, link_1.VERCEL_DIR_REPO);
|
245220
|
+
const repoConfig = await (0, fs_extra_1.readJSON)(repoConfigPath).catch(err => {
|
245221
|
+
if (err.code !== 'ENOENT')
|
245222
|
+
throw err;
|
245223
|
+
});
|
245224
|
+
return { rootPath, repoConfig, repoConfigPath };
|
245225
|
+
}
|
245226
|
+
exports.getRepoLink = getRepoLink;
|
245227
|
+
async function ensureRepoLink(client, cwd, yes = false) {
|
245228
|
+
const { output } = client;
|
245229
|
+
const repoLink = await getRepoLink(cwd);
|
245230
|
+
if (repoLink) {
|
245231
|
+
output.debug(`Found Git repository root directory: ${repoLink.rootPath}`);
|
245232
|
+
}
|
245233
|
+
else {
|
245234
|
+
throw new Error('Could not determine Git repository root directory');
|
245235
|
+
}
|
245236
|
+
let { rootPath, repoConfig, repoConfigPath } = repoLink;
|
245237
|
+
if (!repoConfig) {
|
245238
|
+
// Not yet linked, so prompt user to begin linking
|
245239
|
+
let shouldLink = yes ||
|
245240
|
+
(await (0, confirm_1.default)(client, `Link Git repository at ${chalk_1.default.cyan(`“${(0, humanize_path_1.default)(rootPath)}”`)} to your Project(s)?`, true));
|
245241
|
+
if (!shouldLink) {
|
245242
|
+
output.print(`Canceled. Repository not linked.\n`);
|
245243
|
+
return;
|
245244
|
+
}
|
245245
|
+
const org = await (0, select_org_1.default)(client, 'Which scope should contain your Project(s)?', yes);
|
245246
|
+
client.config.currentTeam = org.type === 'team' ? org.id : undefined;
|
245247
|
+
const remoteUrls = await (0, create_git_meta_1.getRemoteUrls)((0, path_1.join)(rootPath, '.git/config'), output);
|
245248
|
+
if (!remoteUrls) {
|
245249
|
+
throw new Error('Could not determine Git remote URLs');
|
245250
|
+
}
|
245251
|
+
const remoteNames = Object.keys(remoteUrls);
|
245252
|
+
let remoteName;
|
245253
|
+
if (remoteNames.length === 1) {
|
245254
|
+
remoteName = remoteNames[0];
|
245255
|
+
}
|
245256
|
+
else {
|
245257
|
+
// Prompt user to select which remote to use
|
245258
|
+
const originIndex = remoteNames.indexOf('origin');
|
245259
|
+
const answer = await client.prompt({
|
245260
|
+
type: 'list',
|
245261
|
+
name: 'value',
|
245262
|
+
message: 'Which Git remote should be used?',
|
245263
|
+
choices: remoteNames.map(name => {
|
245264
|
+
return { name: name, value: name };
|
245265
|
+
}),
|
245266
|
+
default: originIndex === -1 ? 0 : originIndex,
|
245267
|
+
});
|
245268
|
+
remoteName = answer.value;
|
245269
|
+
}
|
245270
|
+
const repoUrl = remoteUrls[remoteName];
|
245271
|
+
output.spinner(`Fetching Projects for ${(0, link_2.default)(repoUrl)} under ${chalk_1.default.bold(org.slug)}…`);
|
245272
|
+
// TODO: Add pagination to fetch all Projects
|
245273
|
+
const query = new URLSearchParams({ repoUrl, limit: '100' });
|
245274
|
+
const projects = await client.fetch(`/v2/projects?${query}`);
|
245275
|
+
if (projects.length === 0) {
|
245276
|
+
output.log(`No Projects are linked to ${(0, link_2.default)(repoUrl)} under ${chalk_1.default.bold(org.slug)}.`);
|
245277
|
+
// TODO: run detection logic to find potential projects.
|
245278
|
+
// then prompt user to select valid projects.
|
245279
|
+
// then create new Projects
|
245280
|
+
}
|
245281
|
+
else {
|
245282
|
+
output.log(`Found ${chalk_1.default.bold(projects.length)} ${(0, pluralize_1.default)('Project', projects.length)} linked to ${(0, link_2.default)(repoUrl)} under ${chalk_1.default.bold(org.slug)}:`);
|
245283
|
+
}
|
245284
|
+
for (const project of projects) {
|
245285
|
+
output.print(` * ${chalk_1.default.cyan(`${org.slug}/${project.name}\n`)}`);
|
245286
|
+
}
|
245287
|
+
shouldLink =
|
245288
|
+
yes ||
|
245289
|
+
(await (0, confirm_1.default)(client, `Link to ${projects.length === 1 ? 'it' : 'them'}?`, true));
|
245290
|
+
if (!shouldLink) {
|
245291
|
+
output.print(`Canceled. Repository not linked.\n`);
|
245292
|
+
return;
|
245293
|
+
}
|
245294
|
+
repoConfig = {
|
245295
|
+
orgId: org.id,
|
245296
|
+
remoteName,
|
245297
|
+
projects: projects.map(project => {
|
245298
|
+
return {
|
245299
|
+
id: project.id,
|
245300
|
+
name: project.name,
|
245301
|
+
directory: (0, path_1.normalize)(project.rootDirectory || ''),
|
245302
|
+
};
|
245303
|
+
}),
|
245304
|
+
};
|
245305
|
+
await (0, fs_extra_1.outputJSON)(repoConfigPath, repoConfig, { spaces: 2 });
|
245306
|
+
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'));
|
245307
|
+
// update .gitignore
|
245308
|
+
const isGitIgnoreUpdated = await (0, add_to_gitignore_1.addToGitIgnore)(rootPath);
|
245309
|
+
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');
|
245310
|
+
}
|
245311
|
+
return {
|
245312
|
+
repoConfig,
|
245313
|
+
repoConfigPath,
|
245314
|
+
rootPath,
|
245315
|
+
};
|
245316
|
+
}
|
245317
|
+
exports.ensureRepoLink = ensureRepoLink;
|
245318
|
+
/**
|
245319
|
+
* Given a `start` directory, traverses up the directory hierarchy until
|
245320
|
+
* the nearest `.git/config` file is found. Returns the directory where
|
245321
|
+
* the Git config was found, or `undefined` when no Git repo was found.
|
245322
|
+
*/
|
245323
|
+
async function findRepoRoot(start) {
|
245324
|
+
for (const current of traverseUpDirectories(start)) {
|
245325
|
+
if (current === home) {
|
245326
|
+
// Sometimes the $HOME directory is set up as a Git repo
|
245327
|
+
// (for dotfiles, etc.). In this case it's safe to say that
|
245328
|
+
// this isn't the repo we're looking for. Bail.
|
245329
|
+
break;
|
245330
|
+
}
|
245331
|
+
const gitConfigPath = (0, path_1.join)(current, '.git/config');
|
245332
|
+
const stat = await (0, fs_extra_1.lstat)(gitConfigPath).catch(err => {
|
245333
|
+
if (err.code !== 'ENOENT')
|
245334
|
+
throw err;
|
245335
|
+
});
|
245336
|
+
if (stat) {
|
245337
|
+
return current;
|
245338
|
+
}
|
245339
|
+
}
|
245340
|
+
}
|
245341
|
+
exports.findRepoRoot = findRepoRoot;
|
245342
|
+
function* traverseUpDirectories(start) {
|
245343
|
+
let current = (0, path_1.normalize)(start);
|
245344
|
+
while (current) {
|
245345
|
+
yield current;
|
245346
|
+
// Go up one directory
|
245347
|
+
const next = (0, path_1.join)(current, '..');
|
245348
|
+
current = next === current ? undefined : next;
|
245349
|
+
}
|
245350
|
+
}
|
245351
|
+
exports.traverseUpDirectories = traverseUpDirectories;
|
245352
|
+
function sortByDirectory(a, b) {
|
245353
|
+
const aParts = a.directory.split('/');
|
245354
|
+
const bParts = b.directory.split('/');
|
245355
|
+
return bParts.length - aParts.length;
|
245356
|
+
}
|
245357
|
+
/**
|
245358
|
+
* Finds the matching Project from an array of Project links
|
245359
|
+
* where the provided relative path is within the Project's
|
245360
|
+
* root directory.
|
245361
|
+
*/
|
245362
|
+
function findProjectFromPath(projects, path) {
|
245363
|
+
const normalizedPath = (0, build_utils_1.normalizePath)(path);
|
245364
|
+
return projects
|
245365
|
+
.slice()
|
245366
|
+
.sort(sortByDirectory)
|
245367
|
+
.find(project => {
|
245368
|
+
if (project.directory === '.') {
|
245369
|
+
// Project has no "Root Directory" setting, so any path is valid
|
245370
|
+
return true;
|
245371
|
+
}
|
245372
|
+
return (normalizedPath === project.directory ||
|
245373
|
+
normalizedPath.startsWith(`${project.directory}/`));
|
245374
|
+
});
|
245375
|
+
}
|
245376
|
+
exports.findProjectFromPath = findProjectFromPath;
|
245377
|
+
|
245378
|
+
|
245118
245379
|
/***/ }),
|
245119
245380
|
|
245120
245381
|
/***/ 71225:
|
@@ -247226,9 +247487,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
247226
247487
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
247227
247488
|
};
|
247228
247489
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
247229
|
-
exports.linkFolderToProject = exports.getLinkedProject = exports.getLinkFromDir = exports.getVercelDirectory = exports.VERCEL_DIR_PROJECT = exports.VERCEL_DIR_README = exports.VERCEL_DIR_FALLBACK = exports.VERCEL_DIR = void 0;
|
247490
|
+
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;
|
247230
247491
|
const fs_1 = __importDefault(__webpack_require__(35747));
|
247231
|
-
const os_1 = __importDefault(__webpack_require__(12087));
|
247232
247492
|
const ajv_1 = __importDefault(__webpack_require__(35669));
|
247233
247493
|
const chalk_1 = __importDefault(__webpack_require__(90877));
|
247234
247494
|
const path_1 = __webpack_require__(85622);
|
@@ -247243,12 +247503,15 @@ const global_path_1 = __webpack_require__(88976);
|
|
247243
247503
|
const build_utils_1 = __webpack_require__(63445);
|
247244
247504
|
const code_1 = __importDefault(__webpack_require__(94542));
|
247245
247505
|
const error_utils_1 = __webpack_require__(39799);
|
247506
|
+
const repo_1 = __webpack_require__(18726);
|
247507
|
+
const add_to_gitignore_1 = __webpack_require__(19159);
|
247246
247508
|
const readFile = (0, util_1.promisify)(fs_1.default.readFile);
|
247247
247509
|
const writeFile = (0, util_1.promisify)(fs_1.default.writeFile);
|
247248
247510
|
exports.VERCEL_DIR = '.vercel';
|
247249
247511
|
exports.VERCEL_DIR_FALLBACK = '.now';
|
247250
247512
|
exports.VERCEL_DIR_README = 'README.txt';
|
247251
247513
|
exports.VERCEL_DIR_PROJECT = 'project.json';
|
247514
|
+
exports.VERCEL_DIR_REPO = 'repo.json';
|
247252
247515
|
const linkSchema = {
|
247253
247516
|
type: 'object',
|
247254
247517
|
required: ['projectId', 'orgId'],
|
@@ -247269,7 +247532,7 @@ const linkSchema = {
|
|
247269
247532
|
*
|
247270
247533
|
* Throws an error if *both* `.vercel` and `.now` directories exist.
|
247271
247534
|
*/
|
247272
|
-
function getVercelDirectory(cwd
|
247535
|
+
function getVercelDirectory(cwd) {
|
247273
247536
|
const possibleDirs = [(0, path_1.join)(cwd, exports.VERCEL_DIR), (0, path_1.join)(cwd, exports.VERCEL_DIR_FALLBACK)];
|
247274
247537
|
const existingDirs = possibleDirs.filter(d => (0, global_path_1.isDirectory)(d));
|
247275
247538
|
if (existingDirs.length > 1) {
|
@@ -247283,8 +247546,35 @@ function getVercelDirectory(cwd = process.cwd()) {
|
|
247283
247546
|
}
|
247284
247547
|
exports.getVercelDirectory = getVercelDirectory;
|
247285
247548
|
async function getLink(path) {
|
247549
|
+
// Try the individual project linking style (`${cwd}/.vercel/project.json`)
|
247286
247550
|
const dir = getVercelDirectory(path);
|
247287
|
-
|
247551
|
+
const linkFromProject = await getLinkFromDir(dir);
|
247552
|
+
if (linkFromProject) {
|
247553
|
+
return linkFromProject;
|
247554
|
+
}
|
247555
|
+
// Try the repo linking style (`${repoRoot}/.vercel/repo.json`)
|
247556
|
+
return getLinkFromRepo(path);
|
247557
|
+
}
|
247558
|
+
async function getLinkFromRepo(path) {
|
247559
|
+
const repoRoot = await (0, repo_1.findRepoRoot)(path);
|
247560
|
+
if (!repoRoot) {
|
247561
|
+
return null;
|
247562
|
+
}
|
247563
|
+
try {
|
247564
|
+
const vercelDir = (0, path_1.join)(repoRoot, exports.VERCEL_DIR);
|
247565
|
+
const repoJsonPath = (0, path_1.join)(vercelDir, exports.VERCEL_DIR_REPO);
|
247566
|
+
const repoJson = await (0, fs_extra_1.readJSON)(repoJsonPath);
|
247567
|
+
const project = (0, repo_1.findProjectFromPath)(repoJson.projects, (0, path_1.relative)(repoRoot, path));
|
247568
|
+
if (project) {
|
247569
|
+
return { orgId: repoJson.orgId, projectId: project.id };
|
247570
|
+
}
|
247571
|
+
}
|
247572
|
+
catch (err) {
|
247573
|
+
if (!(0, error_utils_1.isErrnoException)(err) || err.code !== 'ENOENT') {
|
247574
|
+
throw err;
|
247575
|
+
}
|
247576
|
+
}
|
247577
|
+
return null;
|
247288
247578
|
}
|
247289
247579
|
async function getLinkFromDir(dir) {
|
247290
247580
|
try {
|
@@ -247323,7 +247613,7 @@ async function getOrgById(client, orgId) {
|
|
247323
247613
|
return null;
|
247324
247614
|
return { type: 'user', id: orgId, slug: user.username };
|
247325
247615
|
}
|
247326
|
-
async function getLinkedProject(client, path) {
|
247616
|
+
async function getLinkedProject(client, path = process.cwd()) {
|
247327
247617
|
const { output } = client;
|
247328
247618
|
const VERCEL_ORG_ID = (0, build_utils_1.getPlatformEnv)('ORG_ID');
|
247329
247619
|
const VERCEL_PROJECT_ID = (0, build_utils_1.getPlatformEnv)('PROJECT_ID');
|
@@ -247409,24 +247699,7 @@ async function linkFolderToProject(output, path, projectLink, projectName, orgSl
|
|
247409
247699
|
await writeFile((0, path_1.join)(path, exports.VERCEL_DIR, exports.VERCEL_DIR_PROJECT), JSON.stringify(projectLink));
|
247410
247700
|
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'));
|
247411
247701
|
// update .gitignore
|
247412
|
-
|
247413
|
-
try {
|
247414
|
-
const gitIgnorePath = (0, path_1.join)(path, '.gitignore');
|
247415
|
-
let gitIgnore = (await readFile(gitIgnorePath, 'utf8').catch(() => null)) ?? '';
|
247416
|
-
const EOL = gitIgnore.includes('\r\n') ? '\r\n' : os_1.default.EOL;
|
247417
|
-
let contentModified = false;
|
247418
|
-
if (!gitIgnore.split(EOL).includes(exports.VERCEL_DIR)) {
|
247419
|
-
gitIgnore += `${gitIgnore.endsWith(EOL) || gitIgnore.length === 0 ? '' : EOL}${exports.VERCEL_DIR}${EOL}`;
|
247420
|
-
contentModified = true;
|
247421
|
-
}
|
247422
|
-
if (contentModified) {
|
247423
|
-
await writeFile(gitIgnorePath, gitIgnore);
|
247424
|
-
isGitIgnoreUpdated = true;
|
247425
|
-
}
|
247426
|
-
}
|
247427
|
-
catch (error) {
|
247428
|
-
// ignore errors since this is non-critical
|
247429
|
-
}
|
247702
|
+
const isGitIgnoreUpdated = await (0, add_to_gitignore_1.addToGitIgnore)(path);
|
247430
247703
|
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');
|
247431
247704
|
}
|
247432
247705
|
exports.linkFolderToProject = linkFolderToProject;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "vercel",
|
3
|
-
"version": "29.
|
3
|
+
"version": "29.4.0",
|
4
4
|
"preferGlobal": true,
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"description": "The command-line interface for Vercel",
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"@vercel/redwood": "1.1.15",
|
32
32
|
"@vercel/remix-builder": "1.8.10",
|
33
33
|
"@vercel/ruby": "1.3.76",
|
34
|
-
"@vercel/static-build": "1.3.
|
34
|
+
"@vercel/static-build": "1.3.32"
|
35
35
|
},
|
36
36
|
"devDependencies": {
|
37
37
|
"@alex_neo/jest-expect-message": "1.0.5",
|
@@ -81,7 +81,7 @@
|
|
81
81
|
"@vercel/client": "12.5.1",
|
82
82
|
"@vercel/error-utils": "1.0.10",
|
83
83
|
"@vercel/frameworks": "1.4.2",
|
84
|
-
"@vercel/fs-detectors": "3.9.
|
84
|
+
"@vercel/fs-detectors": "3.9.3",
|
85
85
|
"@vercel/fun": "1.0.4",
|
86
86
|
"@vercel/ncc": "0.24.0",
|
87
87
|
"@vercel/routing-utils": "2.2.1",
|