vercel 30.0.0 → 30.1.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 +1105 -640
- package/package.json +10 -9
package/dist/index.js
CHANGED
@@ -224854,6 +224854,7 @@ const help = () => `
|
|
224854
224854
|
ls | list [app] Lists deployments
|
224855
224855
|
login [email] Logs into your account or creates a new one
|
224856
224856
|
logout Logs out of your account
|
224857
|
+
promote [url|id] Promote an existing deployment to current
|
224857
224858
|
pull [path] Pull your Project Settings from the cloud
|
224858
224859
|
redeploy [url|id] Rebuild and deploy a previous deployment.
|
224859
224860
|
rollback [url|id] Quickly revert back to a previous deployment
|
@@ -225796,7 +225797,7 @@ const help = () => {
|
|
225796
225797
|
`);
|
225797
225798
|
};
|
225798
225799
|
async function main(client) {
|
225799
|
-
const { output } = client;
|
225800
|
+
const { cwd, output } = client;
|
225800
225801
|
// Ensure that `vc build` is not being invoked recursively
|
225801
225802
|
if (process.env.__VERCEL_BUILD_RUNNING) {
|
225802
225803
|
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')}`);
|
@@ -225817,7 +225818,6 @@ async function main(client) {
|
|
225817
225818
|
help();
|
225818
225819
|
return 2;
|
225819
225820
|
}
|
225820
|
-
const cwd = process.cwd();
|
225821
225821
|
// Build `target` influences which environment variables will be used
|
225822
225822
|
const target = argv['--prod'] ? 'production' : 'preview';
|
225823
225823
|
const yes = Boolean(argv['--yes']);
|
@@ -227027,21 +227027,17 @@ exports.default = async (client) => {
|
|
227027
227027
|
if (argv._.length > 0) {
|
227028
227028
|
// If path is relative: resolve
|
227029
227029
|
// if path is absolute: clear up strange `/` etc
|
227030
|
-
paths = argv._.map(item => (0, path_1.resolve)(
|
227030
|
+
paths = argv._.map(item => (0, path_1.resolve)(client.cwd, item));
|
227031
227031
|
}
|
227032
227032
|
else {
|
227033
|
-
paths = [
|
227033
|
+
paths = [client.cwd];
|
227034
227034
|
}
|
227035
|
-
|
227036
|
-
|
227037
|
-
|
227038
|
-
|
227039
|
-
}
|
227040
|
-
catch (err) {
|
227041
|
-
output.error(`The specified file or directory "${(0, path_1.basename)(path)}" does not exist.`);
|
227042
|
-
return 1;
|
227043
|
-
}
|
227035
|
+
// check paths
|
227036
|
+
const pathValidation = await (0, validate_paths_1.default)(client, paths);
|
227037
|
+
if (!pathValidation.valid) {
|
227038
|
+
return pathValidation.exitCode;
|
227044
227039
|
}
|
227040
|
+
let localConfig = client.localConfig || (0, files_1.readLocalConfig)(paths[0]);
|
227045
227041
|
if (localConfig) {
|
227046
227042
|
const { version } = localConfig;
|
227047
227043
|
const file = (0, highlight_1.default)(localConfig[client_1.fileNameSymbol]);
|
@@ -227062,12 +227058,7 @@ exports.default = async (client) => {
|
|
227062
227058
|
}
|
227063
227059
|
const { log, debug, error, prettyError } = output;
|
227064
227060
|
const quiet = !client.stdout.isTTY;
|
227065
|
-
|
227066
|
-
const pathValidation = await (0, validate_paths_1.default)(client, paths);
|
227067
|
-
if (!pathValidation.valid) {
|
227068
|
-
return pathValidation.exitCode;
|
227069
|
-
}
|
227070
|
-
const { path } = pathValidation;
|
227061
|
+
let { path: cwd } = pathValidation;
|
227071
227062
|
const autoConfirm = argv['--yes'];
|
227072
227063
|
// deprecate --name
|
227073
227064
|
if (argv['--name']) {
|
@@ -227083,12 +227074,12 @@ exports.default = async (client) => {
|
|
227083
227074
|
}
|
227084
227075
|
// build `--prebuilt`
|
227085
227076
|
if (argv['--prebuilt']) {
|
227086
|
-
const prebuiltExists = await fs_extra_1.default.pathExists((0, path_1.join)(
|
227077
|
+
const prebuiltExists = await fs_extra_1.default.pathExists((0, path_1.join)(cwd, '.vercel/output'));
|
227087
227078
|
if (!prebuiltExists) {
|
227088
227079
|
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.`);
|
227089
227080
|
return 1;
|
227090
227081
|
}
|
227091
|
-
const prebuiltBuild = await (0, get_prebuilt_json_1.default)(
|
227082
|
+
const prebuiltBuild = await (0, get_prebuilt_json_1.default)(cwd);
|
227092
227083
|
// Ensure that there was not a build error
|
227093
227084
|
const prebuiltError = prebuiltBuild?.error ||
|
227094
227085
|
prebuiltBuild?.builds?.find(build => 'error' in build)?.error;
|
@@ -227117,7 +227108,7 @@ exports.default = async (client) => {
|
|
227117
227108
|
return 1;
|
227118
227109
|
}
|
227119
227110
|
// retrieve `project` and `org` from .vercel
|
227120
|
-
const link = await (0, link_1.getLinkedProject)(client,
|
227111
|
+
const link = await (0, link_1.getLinkedProject)(client, cwd);
|
227121
227112
|
if (link.status === 'error') {
|
227122
227113
|
return link.exitCode;
|
227123
227114
|
}
|
@@ -227127,7 +227118,7 @@ exports.default = async (client) => {
|
|
227127
227118
|
let sourceFilesOutsideRootDirectory = true;
|
227128
227119
|
if (status === 'not_linked') {
|
227129
227120
|
const shouldStartSetup = autoConfirm ||
|
227130
|
-
(await (0, confirm_1.default)(client, `Set up and deploy ${chalk_1.default.cyan(`“${(0, humanize_path_1.default)(
|
227121
|
+
(await (0, confirm_1.default)(client, `Set up and deploy ${chalk_1.default.cyan(`“${(0, humanize_path_1.default)(cwd)}”`)}?`, true));
|
227131
227122
|
if (!shouldStartSetup) {
|
227132
227123
|
output.print(`Canceled. Project not set up.\n`);
|
227133
227124
|
return 0;
|
@@ -227156,20 +227147,24 @@ exports.default = async (client) => {
|
|
227156
227147
|
const projectOrNewProjectName = await (0, input_project_1.default)(client, org, detectedProjectName, autoConfirm);
|
227157
227148
|
if (typeof projectOrNewProjectName === 'string') {
|
227158
227149
|
newProjectName = projectOrNewProjectName;
|
227159
|
-
rootDirectory = await (0, input_root_directory_1.inputRootDirectory)(client,
|
227150
|
+
rootDirectory = await (0, input_root_directory_1.inputRootDirectory)(client, cwd, autoConfirm);
|
227160
227151
|
}
|
227161
227152
|
else {
|
227162
227153
|
project = projectOrNewProjectName;
|
227163
227154
|
rootDirectory = project.rootDirectory;
|
227164
227155
|
sourceFilesOutsideRootDirectory = project.sourceFilesOutsideRootDirectory;
|
227165
227156
|
// we can already link the project
|
227166
|
-
await (0, link_1.linkFolderToProject)(
|
227157
|
+
await (0, link_1.linkFolderToProject)(client, cwd, {
|
227167
227158
|
projectId: project.id,
|
227168
227159
|
orgId: org.id,
|
227169
227160
|
}, project.name, org.slug);
|
227170
227161
|
status = 'linked';
|
227171
227162
|
}
|
227172
227163
|
}
|
227164
|
+
// For repo-style linking, reset the path to the root of the repository
|
227165
|
+
if (link.status === 'linked' && link.repoRoot) {
|
227166
|
+
cwd = link.repoRoot;
|
227167
|
+
}
|
227173
227168
|
// At this point `org` should be populated
|
227174
227169
|
if (!org) {
|
227175
227170
|
throw new Error(`"org" is not defined`);
|
@@ -227181,10 +227176,10 @@ exports.default = async (client) => {
|
|
227181
227176
|
// if we have `sourceFilesOutsideRootDirectory` set to `true`, we use the current path
|
227182
227177
|
// and upload the entire directory.
|
227183
227178
|
const sourcePath = rootDirectory && !sourceFilesOutsideRootDirectory
|
227184
|
-
? (0, path_1.join)(
|
227185
|
-
:
|
227179
|
+
? (0, path_1.join)(cwd, rootDirectory)
|
227180
|
+
: cwd;
|
227186
227181
|
if (rootDirectory &&
|
227187
|
-
(await (0, validate_paths_1.validateRootDirectory)(output,
|
227182
|
+
(await (0, validate_paths_1.validateRootDirectory)(output, cwd, sourcePath, project
|
227188
227183
|
? `To change your Project Settings, go to https://vercel.com/${org?.slug}/${project.name}/settings`
|
227189
227184
|
: '')) === false) {
|
227190
227185
|
return 1;
|
@@ -227192,7 +227187,7 @@ exports.default = async (client) => {
|
|
227192
227187
|
// If Root Directory is used we'll try to read the config
|
227193
227188
|
// from there instead and use it if it exists.
|
227194
227189
|
if (rootDirectory) {
|
227195
|
-
const rootDirectoryConfig = (0, files_1.readLocalConfig)((0, path_1.join)(
|
227190
|
+
const rootDirectoryConfig = (0, files_1.readLocalConfig)((0, path_1.join)(cwd, rootDirectory));
|
227196
227191
|
if (rootDirectoryConfig) {
|
227197
227192
|
debug(`Read local config from root directory (${rootDirectory})`);
|
227198
227193
|
localConfig = rootDirectoryConfig;
|
@@ -227227,7 +227222,7 @@ exports.default = async (client) => {
|
|
227227
227222
|
}
|
227228
227223
|
// build `meta`
|
227229
227224
|
const meta = Object.assign({}, (0, parse_meta_1.default)(localConfig.meta), (0, parse_meta_1.default)(argv['--meta']));
|
227230
|
-
const gitMetadata = await (0, create_git_meta_1.createGitMeta)(
|
227225
|
+
const gitMetadata = await (0, create_git_meta_1.createGitMeta)(cwd, output, project);
|
227231
227226
|
// Merge dotenv config, `env` from vercel.json, and `--env` / `-e` arguments
|
227232
227227
|
const deploymentEnv = Object.assign({}, (0, parse_env_1.parseEnv)(localConfig.env), (0, parse_env_1.parseEnv)(argv['--env']));
|
227233
227228
|
// Merge build env out of `build.env` from vercel.json, and `--build-env` args
|
@@ -227296,7 +227291,7 @@ exports.default = async (client) => {
|
|
227296
227291
|
}
|
227297
227292
|
: { ...localConfigurationOverrides, sourceFilesOutsideRootDirectory };
|
227298
227293
|
}
|
227299
|
-
deployment = await (0, create_deploy_1.default)(client, now, contextName,
|
227294
|
+
deployment = await (0, create_deploy_1.default)(client, now, contextName, sourcePath, createArgs, org, !project, cwd, archive);
|
227300
227295
|
if (deployment.code === 'missing_project_settings') {
|
227301
227296
|
let { projectSettings, framework } = deployment;
|
227302
227297
|
if (rootDirectory) {
|
@@ -227311,7 +227306,7 @@ exports.default = async (client) => {
|
|
227311
227306
|
createArgs.projectSettings = settings;
|
227312
227307
|
deployStamp = (0, stamp_1.default)();
|
227313
227308
|
createArgs.deployStamp = deployStamp;
|
227314
|
-
deployment = await (0, create_deploy_1.default)(client, now, contextName,
|
227309
|
+
deployment = await (0, create_deploy_1.default)(client, now, contextName, sourcePath, createArgs, org, false, cwd);
|
227315
227310
|
}
|
227316
227311
|
if (deployment instanceof errors_ts_1.NotDomainOwner) {
|
227317
227312
|
output.error(deployment.message);
|
@@ -229342,10 +229337,9 @@ async function main(client) {
|
|
229342
229337
|
help();
|
229343
229338
|
return 2;
|
229344
229339
|
}
|
229345
|
-
const cwd = argv['--cwd'] || process.cwd();
|
229346
229340
|
const subArgs = argv._.slice(1);
|
229347
229341
|
const { subcommand, args } = (0, get_subcommand_1.default)(subArgs, COMMAND_CONFIG);
|
229348
|
-
const { output, config } = client;
|
229342
|
+
const { cwd, output, config } = client;
|
229349
229343
|
const target = argv['--environment']?.toLowerCase() || 'development';
|
229350
229344
|
if (!(0, env_target_1.isValidEnvTarget)(target)) {
|
229351
229345
|
output.error(`Invalid environment \`${chalk_1.default.cyan(target)}\`. Valid options: ${(0, env_target_1.getEnvTargetPlaceholder)()}`);
|
@@ -229686,9 +229680,8 @@ const list_1 = __importDefault(__webpack_require__(48778));
|
|
229686
229680
|
const link_1 = __importDefault(__webpack_require__(39302));
|
229687
229681
|
const pkg_name_1 = __webpack_require__(79000);
|
229688
229682
|
const connect_git_provider_1 = __webpack_require__(82748);
|
229689
|
-
const validate_paths_1 = __importDefault(__webpack_require__(33922));
|
229690
229683
|
async function connect(client, argv, args, project, org) {
|
229691
|
-
const { output } = client;
|
229684
|
+
const { cwd, output } = client;
|
229692
229685
|
const confirm = Boolean(argv['--yes']);
|
229693
229686
|
const repoArg = argv._[1];
|
229694
229687
|
if (args.length > 1) {
|
@@ -229699,16 +229692,10 @@ async function connect(client, argv, args, project, org) {
|
|
229699
229692
|
output.error(`Can't find \`org\` or \`project\`. Make sure your current directory is linked to a Vercel project by running ${(0, pkg_name_1.getCommandName)('link')}.`);
|
229700
229693
|
return 1;
|
229701
229694
|
}
|
229702
|
-
let paths = [process.cwd()];
|
229703
|
-
const validate = await (0, validate_paths_1.default)(client, paths);
|
229704
|
-
if (!validate.valid) {
|
229705
|
-
return validate.exitCode;
|
229706
|
-
}
|
229707
|
-
const { path } = validate;
|
229708
229695
|
const gitProviderLink = project.link;
|
229709
229696
|
client.config.currentTeam = org.type === 'team' ? org.id : undefined;
|
229710
229697
|
// get project from .git
|
229711
|
-
const gitConfigPath = (0, path_1.join)(
|
229698
|
+
const gitConfigPath = (0, path_1.join)(cwd, '.git/config');
|
229712
229699
|
const gitConfig = await (0, create_git_meta_1.parseGitConfig)(gitConfigPath, output);
|
229713
229700
|
if (repoArg) {
|
229714
229701
|
// parse repo arg
|
@@ -229993,7 +229980,6 @@ const get_invalid_subcommand_1 = __importDefault(__webpack_require__(6479));
|
|
229993
229980
|
const handle_error_1 = __importDefault(__webpack_require__(64377));
|
229994
229981
|
const logo_1 = __importDefault(__webpack_require__(66669));
|
229995
229982
|
const pkg_name_1 = __webpack_require__(79000);
|
229996
|
-
const validate_paths_1 = __importDefault(__webpack_require__(33922));
|
229997
229983
|
const connect_1 = __importDefault(__webpack_require__(44813));
|
229998
229984
|
const disconnect_1 = __importDefault(__webpack_require__(47108));
|
229999
229985
|
const help = () => {
|
@@ -230054,14 +230040,8 @@ async function main(client) {
|
|
230054
230040
|
subcommand = argv._[0];
|
230055
230041
|
const args = argv._.slice(1);
|
230056
230042
|
const autoConfirm = Boolean(argv['--yes']);
|
230057
|
-
const { output } = client;
|
230058
|
-
|
230059
|
-
const pathValidation = await (0, validate_paths_1.default)(client, paths);
|
230060
|
-
if (!pathValidation.valid) {
|
230061
|
-
return pathValidation.exitCode;
|
230062
|
-
}
|
230063
|
-
const { path } = pathValidation;
|
230064
|
-
const linkedProject = await (0, ensure_link_1.ensureLink)('git', client, path, { autoConfirm });
|
230043
|
+
const { cwd, output } = client;
|
230044
|
+
const linkedProject = await (0, ensure_link_1.ensureLink)('git', client, cwd, { autoConfirm });
|
230065
230045
|
if (typeof linkedProject === 'number') {
|
230066
230046
|
return linkedProject;
|
230067
230047
|
}
|
@@ -230117,6 +230097,7 @@ exports.default = new Map([
|
|
230117
230097
|
['ls', 'list'],
|
230118
230098
|
['project', 'project'],
|
230119
230099
|
['projects', 'project'],
|
230100
|
+
['promote', 'promote'],
|
230120
230101
|
['pull', 'pull'],
|
230121
230102
|
['redeploy', 'redeploy'],
|
230122
230103
|
['remove', 'remove'],
|
@@ -230655,7 +230636,7 @@ async function main(client) {
|
|
230655
230636
|
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`);
|
230656
230637
|
}
|
230657
230638
|
else {
|
230658
|
-
cwd =
|
230639
|
+
cwd = client.cwd;
|
230659
230640
|
}
|
230660
230641
|
if (argv['--repo']) {
|
230661
230642
|
client.output.warn(`The ${(0, cmd_1.default)('--repo')} flag is in alpha, please report issues`);
|
@@ -230704,7 +230685,6 @@ const parse_meta_1 = __importDefault(__webpack_require__(93983));
|
|
230704
230685
|
const is_valid_name_1 = __webpack_require__(64476);
|
230705
230686
|
const get_command_flags_1 = __importDefault(__webpack_require__(98395));
|
230706
230687
|
const pkg_name_1 = __webpack_require__(79000);
|
230707
|
-
const validate_paths_1 = __importDefault(__webpack_require__(33922));
|
230708
230688
|
const link_1 = __webpack_require__(49347);
|
230709
230689
|
const ensure_link_1 = __webpack_require__(65382);
|
230710
230690
|
const get_scope_1 = __importDefault(__webpack_require__(60324));
|
@@ -230767,7 +230747,7 @@ async function main(client) {
|
|
230767
230747
|
(0, error_1.handleError)(err);
|
230768
230748
|
return 1;
|
230769
230749
|
}
|
230770
|
-
const { output, config } = client;
|
230750
|
+
const { cwd, output, config } = client;
|
230771
230751
|
if ('--confirm' in argv) {
|
230772
230752
|
output.warn('`--confirm` is deprecated, please use `--yes` instead');
|
230773
230753
|
argv['--yes'] = argv['--confirm'];
|
@@ -230784,14 +230764,8 @@ async function main(client) {
|
|
230784
230764
|
const autoConfirm = !!argv['--yes'];
|
230785
230765
|
const prod = argv['--prod'] || false;
|
230786
230766
|
const meta = (0, parse_meta_1.default)(argv['--meta']);
|
230787
|
-
let paths = [process.cwd()];
|
230788
|
-
const pathValidation = await (0, validate_paths_1.default)(client, paths);
|
230789
|
-
if (!pathValidation.valid) {
|
230790
|
-
return pathValidation.exitCode;
|
230791
|
-
}
|
230792
|
-
const { path } = pathValidation;
|
230793
230767
|
// retrieve `project` and `org` from .vercel
|
230794
|
-
let link = await (0, link_1.getLinkedProject)(client,
|
230768
|
+
let link = await (0, link_1.getLinkedProject)(client, cwd);
|
230795
230769
|
if (link.status === 'error') {
|
230796
230770
|
return link.exitCode;
|
230797
230771
|
}
|
@@ -230806,7 +230780,7 @@ async function main(client) {
|
|
230806
230780
|
// If there's no linked project and user doesn't pass `app` arg,
|
230807
230781
|
// prompt to link their current directory.
|
230808
230782
|
if (status === 'not_linked' && !app) {
|
230809
|
-
const linkedProject = await (0, ensure_link_1.ensureLink)('list', client,
|
230783
|
+
const linkedProject = await (0, ensure_link_1.ensureLink)('list', client, cwd, {
|
230810
230784
|
autoConfirm,
|
230811
230785
|
link,
|
230812
230786
|
});
|
@@ -231764,117 +231738,7 @@ async function readConfirmation(client, projectName) {
|
|
231764
231738
|
|
231765
231739
|
/***/ }),
|
231766
231740
|
|
231767
|
-
/***/
|
231768
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
231769
|
-
|
231770
|
-
"use strict";
|
231771
|
-
|
231772
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
231773
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
231774
|
-
};
|
231775
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
231776
|
-
exports.parseEnvironment = void 0;
|
231777
|
-
const chalk_1 = __importDefault(__webpack_require__(90877));
|
231778
|
-
const path_1 = __webpack_require__(85622);
|
231779
|
-
const emoji_1 = __webpack_require__(35172);
|
231780
|
-
const get_args_1 = __importDefault(__webpack_require__(2505));
|
231781
|
-
const logo_1 = __importDefault(__webpack_require__(66669));
|
231782
|
-
const stamp_1 = __importDefault(__webpack_require__(49079));
|
231783
|
-
const pkg_name_1 = __webpack_require__(79000);
|
231784
|
-
const link_1 = __webpack_require__(49347);
|
231785
|
-
const project_settings_1 = __webpack_require__(61440);
|
231786
|
-
const pull_1 = __importDefault(__webpack_require__(80800));
|
231787
|
-
const env_target_1 = __webpack_require__(20229);
|
231788
|
-
const ensure_link_1 = __webpack_require__(65382);
|
231789
|
-
const help = () => {
|
231790
|
-
return console.log(`
|
231791
|
-
${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()} pull`)} [project-path]
|
231792
|
-
|
231793
|
-
${chalk_1.default.dim('Options:')}
|
231794
|
-
|
231795
|
-
-h, --help Output usage information
|
231796
|
-
-A ${chalk_1.default.bold.underline('FILE')}, --local-config=${chalk_1.default.bold.underline('FILE')} Path to the local ${'`vercel.json`'} file
|
231797
|
-
-Q ${chalk_1.default.bold.underline('DIR')}, --global-config=${chalk_1.default.bold.underline('DIR')} Path to the global ${'`.vercel`'} directory
|
231798
|
-
-d, --debug Debug mode [off]
|
231799
|
-
--no-color No color mode [off]
|
231800
|
-
--environment [environment] Deployment environment [development]
|
231801
|
-
-y, --yes Skip questions when setting up new project using default scope and settings
|
231802
|
-
|
231803
|
-
${chalk_1.default.dim('Examples:')}
|
231804
|
-
|
231805
|
-
${chalk_1.default.gray('–')} Pull the latest Environment Variables and Project Settings from the cloud
|
231806
|
-
and stores them in \`.vercel/.env.\${target}.local\` and \`.vercel/project.json\` respectively.
|
231807
|
-
|
231808
|
-
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} pull`)}
|
231809
|
-
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} pull ./path-to-project`)}
|
231810
|
-
|
231811
|
-
${chalk_1.default.gray('–')} Pull for a specific environment
|
231812
|
-
|
231813
|
-
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} pull --environment=${(0, env_target_1.getEnvTargetPlaceholder)()}`)}
|
231814
|
-
|
231815
|
-
${chalk_1.default.gray('If you want to download environment variables to a specific file, use `vercel env pull` instead.')}
|
231816
|
-
`);
|
231817
|
-
};
|
231818
|
-
function processArgs(client) {
|
231819
|
-
return (0, get_args_1.default)(client.argv.slice(2), {
|
231820
|
-
'--yes': Boolean,
|
231821
|
-
'--environment': String,
|
231822
|
-
'--git-branch': String,
|
231823
|
-
'--debug': Boolean,
|
231824
|
-
'-d': '--debug',
|
231825
|
-
'-y': '--yes',
|
231826
|
-
});
|
231827
|
-
}
|
231828
|
-
function parseArgs(client) {
|
231829
|
-
const argv = processArgs(client);
|
231830
|
-
if (argv['--help']) {
|
231831
|
-
help();
|
231832
|
-
return 2;
|
231833
|
-
}
|
231834
|
-
return argv;
|
231835
|
-
}
|
231836
|
-
async function pullAllEnvFiles(environment, client, project, argv, cwd) {
|
231837
|
-
const environmentFile = `.env.${environment}.local`;
|
231838
|
-
return (0, pull_1.default)(client, project, environment, argv, [(0, path_1.join)('.vercel', environmentFile)], client.output, cwd, 'vercel-cli:pull');
|
231839
|
-
}
|
231840
|
-
function parseEnvironment(environment = 'development') {
|
231841
|
-
if (!(0, env_target_1.isValidEnvTarget)(environment)) {
|
231842
|
-
throw new Error(`environment "${environment}" not supported; must be one of ${(0, env_target_1.getEnvTargetPlaceholder)()}`);
|
231843
|
-
}
|
231844
|
-
return environment;
|
231845
|
-
}
|
231846
|
-
exports.parseEnvironment = parseEnvironment;
|
231847
|
-
async function main(client) {
|
231848
|
-
const argv = parseArgs(client);
|
231849
|
-
if (typeof argv === 'number') {
|
231850
|
-
return argv;
|
231851
|
-
}
|
231852
|
-
const cwd = argv._[1] || process.cwd();
|
231853
|
-
const autoConfirm = Boolean(argv['--yes']);
|
231854
|
-
const environment = parseEnvironment(argv['--environment'] || undefined);
|
231855
|
-
const link = await (0, ensure_link_1.ensureLink)('pull', client, cwd, { autoConfirm });
|
231856
|
-
if (typeof link === 'number') {
|
231857
|
-
return link;
|
231858
|
-
}
|
231859
|
-
const { project, org } = link;
|
231860
|
-
client.config.currentTeam = org.type === 'team' ? org.id : undefined;
|
231861
|
-
const pullResultCode = await pullAllEnvFiles(environment, client, project, argv, cwd);
|
231862
|
-
if (pullResultCode !== 0) {
|
231863
|
-
return pullResultCode;
|
231864
|
-
}
|
231865
|
-
client.output.print('\n');
|
231866
|
-
client.output.log('Downloading project settings');
|
231867
|
-
await (0, project_settings_1.writeProjectSettings)(cwd, project, org);
|
231868
|
-
const settingsStamp = (0, stamp_1.default)();
|
231869
|
-
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`);
|
231870
|
-
return 0;
|
231871
|
-
}
|
231872
|
-
exports.default = main;
|
231873
|
-
|
231874
|
-
|
231875
|
-
/***/ }),
|
231876
|
-
|
231877
|
-
/***/ 29281:
|
231741
|
+
/***/ 62435:
|
231878
231742
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
231879
231743
|
|
231880
231744
|
"use strict";
|
@@ -231884,24 +231748,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
231884
231748
|
};
|
231885
231749
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
231886
231750
|
const chalk_1 = __importDefault(__webpack_require__(90877));
|
231887
|
-
const client_1 = __webpack_require__(40521);
|
231888
|
-
const emoji_1 = __webpack_require__(35172);
|
231889
231751
|
const get_args_1 = __importDefault(__webpack_require__(2505));
|
231752
|
+
const get_project_by_cwd_or_link_1 = __importDefault(__webpack_require__(90675));
|
231890
231753
|
const pkg_name_1 = __webpack_require__(79000);
|
231891
|
-
const get_deployment_by_id_or_url_1 = __webpack_require__(47662);
|
231892
|
-
const get_scope_1 = __importDefault(__webpack_require__(60324));
|
231893
231754
|
const handle_error_1 = __importDefault(__webpack_require__(64377));
|
231894
231755
|
const error_utils_1 = __webpack_require__(39799);
|
231895
231756
|
const logo_1 = __importDefault(__webpack_require__(66669));
|
231896
|
-
const
|
231897
|
-
const
|
231898
|
-
const
|
231899
|
-
const ua_1 = __importDefault(__webpack_require__(36308));
|
231757
|
+
const ms_1 = __importDefault(__webpack_require__(21378));
|
231758
|
+
const request_promote_1 = __importDefault(__webpack_require__(73455));
|
231759
|
+
const status_1 = __importDefault(__webpack_require__(48821));
|
231900
231760
|
const help = () => {
|
231901
231761
|
console.log(`
|
231902
|
-
${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()}
|
231762
|
+
${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()} promote`)} [deployment id/url]
|
231903
231763
|
|
231904
|
-
|
231764
|
+
Promote an existing deployment to current.
|
231905
231765
|
|
231906
231766
|
${chalk_1.default.dim('Options:')}
|
231907
231767
|
|
@@ -231910,23 +231770,26 @@ const help = () => {
|
|
231910
231770
|
-Q ${chalk_1.default.bold.underline('DIR')}, --global-config=${chalk_1.default.bold.underline('DIR')} Path to the global ${'`.vercel`'} directory
|
231911
231771
|
-d, --debug Debug mode [off]
|
231912
231772
|
--no-color No color mode [off]
|
231913
|
-
--no-wait Don't wait for the redeploy to finish
|
231914
231773
|
-t ${chalk_1.default.bold.underline('TOKEN')}, --token=${chalk_1.default.bold.underline('TOKEN')} Login token
|
231774
|
+
--timeout=${chalk_1.default.bold.underline('TIME')} Time to wait for promotion completion [3m]
|
231915
231775
|
-y, --yes Skip questions when setting up new project using default scope and settings
|
231916
231776
|
|
231917
231777
|
${chalk_1.default.dim('Examples:')}
|
231918
231778
|
|
231919
|
-
${chalk_1.default.gray('–')}
|
231779
|
+
${chalk_1.default.gray('–')} Show the status of any current pending promotions
|
231920
231780
|
|
231921
|
-
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()}
|
231781
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} promote`)}
|
231782
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} promote status`)}
|
231783
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} promote status <project>`)}
|
231784
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} promote status --timeout 30s`)}
|
231922
231785
|
|
231923
|
-
${chalk_1.default.gray('–')}
|
231786
|
+
${chalk_1.default.gray('–')} Promote a deployment using id or url
|
231924
231787
|
|
231925
|
-
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()}
|
231788
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} promote <deployment id/url>`)}
|
231926
231789
|
`);
|
231927
231790
|
};
|
231928
231791
|
/**
|
231929
|
-
* `vc
|
231792
|
+
* `vc promote` command
|
231930
231793
|
* @param {Client} client
|
231931
231794
|
* @returns {Promise<number>} Resolves an exit code; 0 on success
|
231932
231795
|
*/
|
@@ -231934,7 +231797,7 @@ exports.default = async (client) => {
|
|
231934
231797
|
let argv;
|
231935
231798
|
try {
|
231936
231799
|
argv = (0, get_args_1.default)(client.argv.slice(2), {
|
231937
|
-
'--
|
231800
|
+
'--timeout': String,
|
231938
231801
|
'--yes': Boolean,
|
231939
231802
|
'-y': '--yes',
|
231940
231803
|
});
|
@@ -231947,87 +231810,533 @@ exports.default = async (client) => {
|
|
231947
231810
|
help();
|
231948
231811
|
return 2;
|
231949
231812
|
}
|
231950
|
-
|
231951
|
-
|
231952
|
-
if (
|
231953
|
-
output.error(`
|
231813
|
+
// validate the timeout
|
231814
|
+
let timeout = argv['--timeout'];
|
231815
|
+
if (timeout && (0, ms_1.default)(timeout) === undefined) {
|
231816
|
+
client.output.error(`Invalid timeout "${timeout}"`);
|
231954
231817
|
return 1;
|
231955
231818
|
}
|
231956
|
-
const
|
231957
|
-
const noWait = !!argv['--no-wait'];
|
231819
|
+
const actionOrDeployId = argv._[1] || 'status';
|
231958
231820
|
try {
|
231959
|
-
|
231821
|
+
if (actionOrDeployId === 'status') {
|
231822
|
+
const project = await (0, get_project_by_cwd_or_link_1.default)({
|
231823
|
+
autoConfirm: Boolean(argv['--yes']),
|
231824
|
+
client,
|
231825
|
+
commandName: 'promote',
|
231826
|
+
cwd: client.cwd,
|
231827
|
+
projectNameOrId: argv._[2],
|
231828
|
+
});
|
231829
|
+
return await (0, status_1.default)({
|
231830
|
+
client,
|
231831
|
+
project,
|
231832
|
+
timeout,
|
231833
|
+
});
|
231834
|
+
}
|
231835
|
+
return await (0, request_promote_1.default)({
|
231960
231836
|
client,
|
231961
|
-
|
231962
|
-
|
231963
|
-
});
|
231964
|
-
const deployStamp = (0, stamp_1.default)();
|
231965
|
-
output.spinner(`Redeploying project ${fromDeployment.id}`, 0);
|
231966
|
-
let deployment = await client.fetch(`/v13/deployments?forceNew=1`, {
|
231967
|
-
body: {
|
231968
|
-
deploymentId: fromDeployment.id,
|
231969
|
-
meta: {
|
231970
|
-
action: 'redeploy',
|
231971
|
-
},
|
231972
|
-
name: fromDeployment.name,
|
231973
|
-
target: fromDeployment.target || 'production',
|
231974
|
-
},
|
231975
|
-
method: 'POST',
|
231837
|
+
deployId: actionOrDeployId,
|
231838
|
+
timeout,
|
231976
231839
|
});
|
231977
|
-
|
231978
|
-
|
231979
|
-
if (
|
231980
|
-
|
231981
|
-
|
231982
|
-
if (!noWait) {
|
231983
|
-
output.spinner(deployment.readyState === 'QUEUED' ? 'Queued' : 'Building', 0);
|
231984
|
-
if (deployment.readyState === 'READY' && deployment.aliasAssigned) {
|
231985
|
-
output.spinner('Completing', 0);
|
231840
|
+
}
|
231841
|
+
catch (err) {
|
231842
|
+
if ((0, error_utils_1.isErrnoException)(err)) {
|
231843
|
+
if (err.code === 'ERR_CANCELED') {
|
231844
|
+
return 0;
|
231986
231845
|
}
|
231987
|
-
|
231988
|
-
|
231989
|
-
|
231990
|
-
|
231991
|
-
|
231992
|
-
|
231993
|
-
|
231994
|
-
|
231995
|
-
|
231996
|
-
|
231997
|
-
|
231998
|
-
|
231999
|
-
|
232000
|
-
|
232001
|
-
|
232002
|
-
|
232003
|
-
|
232004
|
-
|
232005
|
-
|
232006
|
-
|
232007
|
-
|
232008
|
-
|
232009
|
-
|
232010
|
-
|
232011
|
-
|
232012
|
-
|
232013
|
-
|
232014
|
-
|
232015
|
-
|
232016
|
-
|
232017
|
-
|
232018
|
-
|
232019
|
-
|
232020
|
-
|
232021
|
-
|
232022
|
-
|
232023
|
-
|
232024
|
-
|
232025
|
-
|
232026
|
-
|
232027
|
-
|
232028
|
-
|
232029
|
-
|
232030
|
-
|
231846
|
+
if (err.code === 'ERR_INVALID_CWD' || err.code === 'ERR_LINK_PROJECT') {
|
231847
|
+
// do not show the message
|
231848
|
+
return 1;
|
231849
|
+
}
|
231850
|
+
}
|
231851
|
+
client.output.prettyError(err);
|
231852
|
+
return 1;
|
231853
|
+
}
|
231854
|
+
};
|
231855
|
+
|
231856
|
+
|
231857
|
+
/***/ }),
|
231858
|
+
|
231859
|
+
/***/ 73455:
|
231860
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
231861
|
+
|
231862
|
+
"use strict";
|
231863
|
+
|
231864
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
231865
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
231866
|
+
};
|
231867
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
231868
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
231869
|
+
const pkg_name_1 = __webpack_require__(79000);
|
231870
|
+
const get_project_by_deployment_1 = __importDefault(__webpack_require__(67231));
|
231871
|
+
const ms_1 = __importDefault(__webpack_require__(21378));
|
231872
|
+
const status_1 = __importDefault(__webpack_require__(48821));
|
231873
|
+
/**
|
231874
|
+
* Requests a promotion and waits for it complete.
|
231875
|
+
* @param {Client} client - The Vercel client instance
|
231876
|
+
* @param {string} deployId - The deployment name or id to promote
|
231877
|
+
* @param {string} [timeout] - Time to poll for succeeded/failed state
|
231878
|
+
* @returns {Promise<number>} Resolves an exit code; 0 on success
|
231879
|
+
*/
|
231880
|
+
async function requestPromote({ client, deployId, timeout, }) {
|
231881
|
+
const { output } = client;
|
231882
|
+
const { contextName, deployment, project } = await (0, get_project_by_deployment_1.default)({
|
231883
|
+
client,
|
231884
|
+
deployId,
|
231885
|
+
output: client.output,
|
231886
|
+
});
|
231887
|
+
// request the promotion
|
231888
|
+
await client.fetch(`/v9/projects/${project.id}/promote/${deployment.id}`, {
|
231889
|
+
body: {},
|
231890
|
+
json: false,
|
231891
|
+
method: 'POST',
|
231892
|
+
});
|
231893
|
+
if (timeout !== undefined && (0, ms_1.default)(timeout) === 0) {
|
231894
|
+
output.log(`Successfully requested promote of ${chalk_1.default.bold(project.name)} to ${deployment.url} (${deployment.id})`);
|
231895
|
+
output.log(`To check promote status, run ${(0, pkg_name_1.getCommandName)('promote')}.`);
|
231896
|
+
return 0;
|
231897
|
+
}
|
231898
|
+
// check the status
|
231899
|
+
return await (0, status_1.default)({
|
231900
|
+
client,
|
231901
|
+
contextName,
|
231902
|
+
deployment,
|
231903
|
+
project,
|
231904
|
+
timeout,
|
231905
|
+
});
|
231906
|
+
}
|
231907
|
+
exports.default = requestPromote;
|
231908
|
+
|
231909
|
+
|
231910
|
+
/***/ }),
|
231911
|
+
|
231912
|
+
/***/ 48821:
|
231913
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
231914
|
+
|
231915
|
+
"use strict";
|
231916
|
+
|
231917
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
231918
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
231919
|
+
};
|
231920
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
231921
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
231922
|
+
const elapsed_1 = __importDefault(__webpack_require__(14099));
|
231923
|
+
const format_date_1 = __importDefault(__webpack_require__(738));
|
231924
|
+
const get_deployment_1 = __importDefault(__webpack_require__(84249));
|
231925
|
+
const pkg_name_1 = __webpack_require__(79000);
|
231926
|
+
const get_project_by_id_or_name_1 = __importDefault(__webpack_require__(6729));
|
231927
|
+
const get_scope_1 = __importDefault(__webpack_require__(60324));
|
231928
|
+
const ms_1 = __importDefault(__webpack_require__(21378));
|
231929
|
+
const errors_ts_1 = __webpack_require__(39240);
|
231930
|
+
const render_alias_status_1 = __importDefault(__webpack_require__(33688));
|
231931
|
+
const sleep_1 = __importDefault(__webpack_require__(89507));
|
231932
|
+
/**
|
231933
|
+
* Continuously checks a deployment status until it has succeeded, failed, or
|
231934
|
+
* taken longer than the timeout (default 3 minutes).
|
231935
|
+
*
|
231936
|
+
* @param {Client} client - The Vercel client instance
|
231937
|
+
* @param {string} [contextName] - The scope name; if not specified, it will be
|
231938
|
+
* extracted from the `client`
|
231939
|
+
* @param {Deployment} [deployment] - Info about the deployment which is used
|
231940
|
+
* to display different output following a promotion request
|
231941
|
+
* @param {Project} project - Project info instance
|
231942
|
+
* @param {string} [timeout] - Milliseconds to poll for succeeded/failed state
|
231943
|
+
* @returns {Promise<number>} Resolves an exit code; 0 on success
|
231944
|
+
*/
|
231945
|
+
async function promoteStatus({ client, contextName, deployment, project, timeout = '3m', }) {
|
231946
|
+
const { output } = client;
|
231947
|
+
const recentThreshold = Date.now() - (0, ms_1.default)('3m');
|
231948
|
+
const promoteTimeout = Date.now() + (0, ms_1.default)(timeout);
|
231949
|
+
let counter = 0;
|
231950
|
+
let spinnerMessage = deployment
|
231951
|
+
? 'Promote in progress'
|
231952
|
+
: `Checking promotion status of ${project.name}`;
|
231953
|
+
if (!contextName) {
|
231954
|
+
({ contextName } = await (0, get_scope_1.default)(client));
|
231955
|
+
}
|
231956
|
+
try {
|
231957
|
+
output.spinner(`${spinnerMessage}…`);
|
231958
|
+
// continuously loop until the promotion has explicitly succeeded, failed,
|
231959
|
+
// or timed out
|
231960
|
+
for (;;) {
|
231961
|
+
const projectCheck = await (0, get_project_by_id_or_name_1.default)(client, project.id, project.accountId, true);
|
231962
|
+
if (projectCheck instanceof errors_ts_1.ProjectNotFound) {
|
231963
|
+
throw projectCheck;
|
231964
|
+
}
|
231965
|
+
const { jobStatus, requestedAt, toDeploymentId, type, } = projectCheck.lastAliasRequest ?? {};
|
231966
|
+
if (!jobStatus ||
|
231967
|
+
(jobStatus !== 'in-progress' && jobStatus !== 'pending')) {
|
231968
|
+
output.stopSpinner();
|
231969
|
+
output.log(`${spinnerMessage}…`);
|
231970
|
+
}
|
231971
|
+
if (!jobStatus ||
|
231972
|
+
!requestedAt ||
|
231973
|
+
!toDeploymentId ||
|
231974
|
+
requestedAt < recentThreshold) {
|
231975
|
+
output.log('No deployment promotion in progress');
|
231976
|
+
return 0;
|
231977
|
+
}
|
231978
|
+
if (jobStatus === 'skipped' && type === 'promote') {
|
231979
|
+
output.log('Promote deployment was skipped');
|
231980
|
+
return 0;
|
231981
|
+
}
|
231982
|
+
if (jobStatus === 'succeeded') {
|
231983
|
+
return await renderJobSucceeded({
|
231984
|
+
client,
|
231985
|
+
contextName,
|
231986
|
+
performingPromote: !!deployment,
|
231987
|
+
requestedAt,
|
231988
|
+
project,
|
231989
|
+
toDeploymentId,
|
231990
|
+
});
|
231991
|
+
}
|
231992
|
+
if (jobStatus === 'failed') {
|
231993
|
+
return await renderJobFailed({
|
231994
|
+
client,
|
231995
|
+
contextName,
|
231996
|
+
deployment,
|
231997
|
+
project,
|
231998
|
+
toDeploymentId,
|
231999
|
+
});
|
232000
|
+
}
|
232001
|
+
// lastly, if we're not pending/in-progress, then we don't know what
|
232002
|
+
// the status is, so bail
|
232003
|
+
if (jobStatus !== 'pending' && jobStatus !== 'in-progress') {
|
232004
|
+
output.log(`Unknown promote deployment status "${jobStatus}"`);
|
232005
|
+
return 1;
|
232006
|
+
}
|
232007
|
+
// check if we have been running for too long
|
232008
|
+
if (requestedAt < recentThreshold || Date.now() >= promoteTimeout) {
|
232009
|
+
output.log(`The promotion exceeded its deadline - rerun ${chalk_1.default.bold(`${(0, pkg_name_1.getPkgName)()} promote ${toDeploymentId}`)} to try again`);
|
232010
|
+
return 1;
|
232011
|
+
}
|
232012
|
+
// if we've done our first poll and not rolling back, then print the
|
232013
|
+
// requested at date/time
|
232014
|
+
if (counter++ === 0 && !deployment) {
|
232015
|
+
spinnerMessage += ` requested at ${(0, format_date_1.default)(requestedAt)}`;
|
232016
|
+
}
|
232017
|
+
output.spinner(`${spinnerMessage}…`);
|
232018
|
+
await (0, sleep_1.default)(250);
|
232019
|
+
}
|
232020
|
+
}
|
232021
|
+
finally {
|
232022
|
+
output.stopSpinner();
|
232023
|
+
}
|
232024
|
+
}
|
232025
|
+
exports.default = promoteStatus;
|
232026
|
+
async function renderJobFailed({ client, contextName, deployment, project, toDeploymentId, }) {
|
232027
|
+
const { output } = client;
|
232028
|
+
try {
|
232029
|
+
const name = (deployment || (await (0, get_deployment_1.default)(client, contextName, toDeploymentId)))?.url;
|
232030
|
+
output.error(`Failed to remap all aliases to the requested deployment ${name} (${toDeploymentId})`);
|
232031
|
+
}
|
232032
|
+
catch (e) {
|
232033
|
+
output.error(`Failed to remap all aliases to the requested deployment ${toDeploymentId}`);
|
232034
|
+
}
|
232035
|
+
// aliases are paginated, so continuously loop until all of them have been
|
232036
|
+
// fetched
|
232037
|
+
let nextTimestamp;
|
232038
|
+
for (;;) {
|
232039
|
+
let url = `/v9/projects/${project.id}/promote/aliases?failedOnly=true&limit=20`;
|
232040
|
+
if (nextTimestamp) {
|
232041
|
+
url += `&until=${nextTimestamp}`;
|
232042
|
+
}
|
232043
|
+
const { aliases, pagination } = await client.fetch(url);
|
232044
|
+
for (const { alias, status } of aliases) {
|
232045
|
+
output.log(` ${(0, render_alias_status_1.default)(status).padEnd(11)} ${alias.alias} (${alias.deploymentId})`);
|
232046
|
+
}
|
232047
|
+
if (pagination?.next) {
|
232048
|
+
nextTimestamp = pagination.next;
|
232049
|
+
}
|
232050
|
+
else {
|
232051
|
+
break;
|
232052
|
+
}
|
232053
|
+
}
|
232054
|
+
return 1;
|
232055
|
+
}
|
232056
|
+
async function renderJobSucceeded({ client, contextName, performingPromote, project, requestedAt, toDeploymentId, }) {
|
232057
|
+
const { output } = client;
|
232058
|
+
// attempt to get the new deployment url
|
232059
|
+
let deploymentInfo = '';
|
232060
|
+
try {
|
232061
|
+
const deployment = await (0, get_deployment_1.default)(client, contextName, toDeploymentId);
|
232062
|
+
deploymentInfo = `${chalk_1.default.bold(deployment.url)} (${toDeploymentId})`;
|
232063
|
+
}
|
232064
|
+
catch (err) {
|
232065
|
+
output.debug(`Failed to get deployment url for ${toDeploymentId}: ${err?.toString() || err}`);
|
232066
|
+
deploymentInfo = chalk_1.default.bold(toDeploymentId);
|
232067
|
+
}
|
232068
|
+
const duration = performingPromote ? (0, elapsed_1.default)(Date.now() - requestedAt) : '';
|
232069
|
+
output.log(`Success! ${chalk_1.default.bold(project.name)} was promoted to ${deploymentInfo} ${duration}`);
|
232070
|
+
return 0;
|
232071
|
+
}
|
232072
|
+
|
232073
|
+
|
232074
|
+
/***/ }),
|
232075
|
+
|
232076
|
+
/***/ 65158:
|
232077
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
232078
|
+
|
232079
|
+
"use strict";
|
232080
|
+
|
232081
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
232082
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
232083
|
+
};
|
232084
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
232085
|
+
exports.parseEnvironment = void 0;
|
232086
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
232087
|
+
const path_1 = __webpack_require__(85622);
|
232088
|
+
const emoji_1 = __webpack_require__(35172);
|
232089
|
+
const get_args_1 = __importDefault(__webpack_require__(2505));
|
232090
|
+
const logo_1 = __importDefault(__webpack_require__(66669));
|
232091
|
+
const stamp_1 = __importDefault(__webpack_require__(49079));
|
232092
|
+
const pkg_name_1 = __webpack_require__(79000);
|
232093
|
+
const link_1 = __webpack_require__(49347);
|
232094
|
+
const project_settings_1 = __webpack_require__(61440);
|
232095
|
+
const pull_1 = __importDefault(__webpack_require__(80800));
|
232096
|
+
const env_target_1 = __webpack_require__(20229);
|
232097
|
+
const ensure_link_1 = __webpack_require__(65382);
|
232098
|
+
const help = () => {
|
232099
|
+
return console.log(`
|
232100
|
+
${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()} pull`)} [project-path]
|
232101
|
+
|
232102
|
+
${chalk_1.default.dim('Options:')}
|
232103
|
+
|
232104
|
+
-h, --help Output usage information
|
232105
|
+
-A ${chalk_1.default.bold.underline('FILE')}, --local-config=${chalk_1.default.bold.underline('FILE')} Path to the local ${'`vercel.json`'} file
|
232106
|
+
-Q ${chalk_1.default.bold.underline('DIR')}, --global-config=${chalk_1.default.bold.underline('DIR')} Path to the global ${'`.vercel`'} directory
|
232107
|
+
-d, --debug Debug mode [off]
|
232108
|
+
--no-color No color mode [off]
|
232109
|
+
--environment [environment] Deployment environment [development]
|
232110
|
+
-y, --yes Skip questions when setting up new project using default scope and settings
|
232111
|
+
|
232112
|
+
${chalk_1.default.dim('Examples:')}
|
232113
|
+
|
232114
|
+
${chalk_1.default.gray('–')} Pull the latest Environment Variables and Project Settings from the cloud
|
232115
|
+
and stores them in \`.vercel/.env.\${target}.local\` and \`.vercel/project.json\` respectively.
|
232116
|
+
|
232117
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} pull`)}
|
232118
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} pull ./path-to-project`)}
|
232119
|
+
|
232120
|
+
${chalk_1.default.gray('–')} Pull for a specific environment
|
232121
|
+
|
232122
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} pull --environment=${(0, env_target_1.getEnvTargetPlaceholder)()}`)}
|
232123
|
+
|
232124
|
+
${chalk_1.default.gray('If you want to download environment variables to a specific file, use `vercel env pull` instead.')}
|
232125
|
+
`);
|
232126
|
+
};
|
232127
|
+
function processArgs(client) {
|
232128
|
+
return (0, get_args_1.default)(client.argv.slice(2), {
|
232129
|
+
'--yes': Boolean,
|
232130
|
+
'--environment': String,
|
232131
|
+
'--git-branch': String,
|
232132
|
+
'--debug': Boolean,
|
232133
|
+
'-d': '--debug',
|
232134
|
+
'-y': '--yes',
|
232135
|
+
});
|
232136
|
+
}
|
232137
|
+
function parseArgs(client) {
|
232138
|
+
const argv = processArgs(client);
|
232139
|
+
if (argv['--help']) {
|
232140
|
+
help();
|
232141
|
+
return 2;
|
232142
|
+
}
|
232143
|
+
return argv;
|
232144
|
+
}
|
232145
|
+
async function pullAllEnvFiles(environment, client, project, argv, cwd) {
|
232146
|
+
const environmentFile = `.env.${environment}.local`;
|
232147
|
+
return (0, pull_1.default)(client, project, environment, argv, [(0, path_1.join)('.vercel', environmentFile)], client.output, cwd, 'vercel-cli:pull');
|
232148
|
+
}
|
232149
|
+
function parseEnvironment(environment = 'development') {
|
232150
|
+
if (!(0, env_target_1.isValidEnvTarget)(environment)) {
|
232151
|
+
throw new Error(`environment "${environment}" not supported; must be one of ${(0, env_target_1.getEnvTargetPlaceholder)()}`);
|
232152
|
+
}
|
232153
|
+
return environment;
|
232154
|
+
}
|
232155
|
+
exports.parseEnvironment = parseEnvironment;
|
232156
|
+
async function main(client) {
|
232157
|
+
const argv = parseArgs(client);
|
232158
|
+
if (typeof argv === 'number') {
|
232159
|
+
return argv;
|
232160
|
+
}
|
232161
|
+
const cwd = argv._[1] || process.cwd();
|
232162
|
+
const autoConfirm = Boolean(argv['--yes']);
|
232163
|
+
const environment = parseEnvironment(argv['--environment'] || undefined);
|
232164
|
+
const link = await (0, ensure_link_1.ensureLink)('pull', client, cwd, { autoConfirm });
|
232165
|
+
if (typeof link === 'number') {
|
232166
|
+
return link;
|
232167
|
+
}
|
232168
|
+
const { project, org } = link;
|
232169
|
+
client.config.currentTeam = org.type === 'team' ? org.id : undefined;
|
232170
|
+
const pullResultCode = await pullAllEnvFiles(environment, client, project, argv, cwd);
|
232171
|
+
if (pullResultCode !== 0) {
|
232172
|
+
return pullResultCode;
|
232173
|
+
}
|
232174
|
+
client.output.print('\n');
|
232175
|
+
client.output.log('Downloading project settings');
|
232176
|
+
await (0, project_settings_1.writeProjectSettings)(cwd, project, org);
|
232177
|
+
const settingsStamp = (0, stamp_1.default)();
|
232178
|
+
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`);
|
232179
|
+
return 0;
|
232180
|
+
}
|
232181
|
+
exports.default = main;
|
232182
|
+
|
232183
|
+
|
232184
|
+
/***/ }),
|
232185
|
+
|
232186
|
+
/***/ 29281:
|
232187
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
232188
|
+
|
232189
|
+
"use strict";
|
232190
|
+
|
232191
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
232192
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
232193
|
+
};
|
232194
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
232195
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
232196
|
+
const client_1 = __webpack_require__(40521);
|
232197
|
+
const emoji_1 = __webpack_require__(35172);
|
232198
|
+
const get_args_1 = __importDefault(__webpack_require__(2505));
|
232199
|
+
const pkg_name_1 = __webpack_require__(79000);
|
232200
|
+
const get_deployment_by_id_or_url_1 = __webpack_require__(47662);
|
232201
|
+
const get_scope_1 = __importDefault(__webpack_require__(60324));
|
232202
|
+
const handle_error_1 = __importDefault(__webpack_require__(64377));
|
232203
|
+
const error_utils_1 = __webpack_require__(39799);
|
232204
|
+
const logo_1 = __importDefault(__webpack_require__(66669));
|
232205
|
+
const util_1 = __importDefault(__webpack_require__(4058));
|
232206
|
+
const print_deployment_status_1 = __webpack_require__(27951);
|
232207
|
+
const stamp_1 = __importDefault(__webpack_require__(49079));
|
232208
|
+
const ua_1 = __importDefault(__webpack_require__(36308));
|
232209
|
+
const help = () => {
|
232210
|
+
console.log(`
|
232211
|
+
${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()} redeploy`)} [deploymentId|deploymentName]
|
232212
|
+
|
232213
|
+
Rebuild and deploy a previous deployment.
|
232214
|
+
|
232215
|
+
${chalk_1.default.dim('Options:')}
|
232216
|
+
|
232217
|
+
-h, --help Output usage information
|
232218
|
+
-A ${chalk_1.default.bold.underline('FILE')}, --local-config=${chalk_1.default.bold.underline('FILE')} Path to the local ${'`vercel.json`'} file
|
232219
|
+
-Q ${chalk_1.default.bold.underline('DIR')}, --global-config=${chalk_1.default.bold.underline('DIR')} Path to the global ${'`.vercel`'} directory
|
232220
|
+
-d, --debug Debug mode [off]
|
232221
|
+
--no-color No color mode [off]
|
232222
|
+
--no-wait Don't wait for the redeploy to finish
|
232223
|
+
-t ${chalk_1.default.bold.underline('TOKEN')}, --token=${chalk_1.default.bold.underline('TOKEN')} Login token
|
232224
|
+
-y, --yes Skip questions when setting up new project using default scope and settings
|
232225
|
+
|
232226
|
+
${chalk_1.default.dim('Examples:')}
|
232227
|
+
|
232228
|
+
${chalk_1.default.gray('–')} Rebuild and deploy an existing deployment using id or url
|
232229
|
+
|
232230
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} redeploy my-deployment.vercel.app`)}
|
232231
|
+
|
232232
|
+
${chalk_1.default.gray('–')} Write Deployment URL to a file
|
232233
|
+
|
232234
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} redeploy my-deployment.vercel.app > deployment-url.txt`)}
|
232235
|
+
`);
|
232236
|
+
};
|
232237
|
+
/**
|
232238
|
+
* `vc redeploy` command
|
232239
|
+
* @param {Client} client
|
232240
|
+
* @returns {Promise<number>} Resolves an exit code; 0 on success
|
232241
|
+
*/
|
232242
|
+
exports.default = async (client) => {
|
232243
|
+
let argv;
|
232244
|
+
try {
|
232245
|
+
argv = (0, get_args_1.default)(client.argv.slice(2), {
|
232246
|
+
'--no-wait': Boolean,
|
232247
|
+
'--yes': Boolean,
|
232248
|
+
'-y': '--yes',
|
232249
|
+
});
|
232250
|
+
}
|
232251
|
+
catch (err) {
|
232252
|
+
(0, handle_error_1.default)(err);
|
232253
|
+
return 1;
|
232254
|
+
}
|
232255
|
+
if (argv['--help'] || argv._[0] === 'help') {
|
232256
|
+
help();
|
232257
|
+
return 2;
|
232258
|
+
}
|
232259
|
+
const { output } = client;
|
232260
|
+
const deployIdOrUrl = argv._[1];
|
232261
|
+
if (!deployIdOrUrl) {
|
232262
|
+
output.error(`Missing required deployment id or url: ${(0, pkg_name_1.getCommandName)(`redeploy <deployment-id-or-url>`)}`);
|
232263
|
+
return 1;
|
232264
|
+
}
|
232265
|
+
const { contextName } = await (0, get_scope_1.default)(client);
|
232266
|
+
const noWait = !!argv['--no-wait'];
|
232267
|
+
try {
|
232268
|
+
const fromDeployment = await (0, get_deployment_by_id_or_url_1.getDeploymentByIdOrURL)({
|
232269
|
+
client,
|
232270
|
+
contextName,
|
232271
|
+
deployIdOrUrl,
|
232272
|
+
});
|
232273
|
+
const deployStamp = (0, stamp_1.default)();
|
232274
|
+
output.spinner(`Redeploying project ${fromDeployment.id}`, 0);
|
232275
|
+
let deployment = await client.fetch(`/v13/deployments?forceNew=1`, {
|
232276
|
+
body: {
|
232277
|
+
deploymentId: fromDeployment.id,
|
232278
|
+
meta: {
|
232279
|
+
action: 'redeploy',
|
232280
|
+
},
|
232281
|
+
name: fromDeployment.name,
|
232282
|
+
target: fromDeployment.target || 'production',
|
232283
|
+
},
|
232284
|
+
method: 'POST',
|
232285
|
+
});
|
232286
|
+
output.stopSpinner();
|
232287
|
+
output.print(`${(0, emoji_1.prependEmoji)(`Inspect: ${chalk_1.default.bold(deployment.inspectorUrl)} ${deployStamp()}`, (0, emoji_1.emoji)('inspect'))}\n`);
|
232288
|
+
if (!client.stdout.isTTY) {
|
232289
|
+
client.stdout.write(`https://${deployment.url}`);
|
232290
|
+
}
|
232291
|
+
if (!noWait) {
|
232292
|
+
output.spinner(deployment.readyState === 'QUEUED' ? 'Queued' : 'Building', 0);
|
232293
|
+
if (deployment.readyState === 'READY' && deployment.aliasAssigned) {
|
232294
|
+
output.spinner('Completing', 0);
|
232295
|
+
}
|
232296
|
+
else {
|
232297
|
+
try {
|
232298
|
+
const clientOptions = {
|
232299
|
+
agent: client.agent,
|
232300
|
+
apiUrl: client.apiUrl,
|
232301
|
+
debug: client.output.debugEnabled,
|
232302
|
+
path: '',
|
232303
|
+
teamId: fromDeployment.team?.id,
|
232304
|
+
token: client.authConfig.token,
|
232305
|
+
userAgent: ua_1.default,
|
232306
|
+
};
|
232307
|
+
for await (const event of (0, client_1.checkDeploymentStatus)(deployment, clientOptions)) {
|
232308
|
+
if (event.type === 'building') {
|
232309
|
+
output.spinner('Building', 0);
|
232310
|
+
}
|
232311
|
+
else if (event.type === 'ready' &&
|
232312
|
+
(event.payload.checksState
|
232313
|
+
? event.payload.checksState === 'completed'
|
232314
|
+
: true)) {
|
232315
|
+
output.spinner('Completing', 0);
|
232316
|
+
}
|
232317
|
+
else if (event.type === 'checks-running') {
|
232318
|
+
output.spinner('Running Checks', 0);
|
232319
|
+
}
|
232320
|
+
else if (event.type === 'alias-assigned' ||
|
232321
|
+
event.type === 'checks-conclusion-failed') {
|
232322
|
+
output.stopSpinner();
|
232323
|
+
deployment = event.payload;
|
232324
|
+
break;
|
232325
|
+
}
|
232326
|
+
else if (event.type === 'canceled') {
|
232327
|
+
output.stopSpinner();
|
232328
|
+
output.print('The deployment has been canceled.\n');
|
232329
|
+
return 1;
|
232330
|
+
}
|
232331
|
+
else if (event.type === 'error') {
|
232332
|
+
output.stopSpinner();
|
232333
|
+
const now = new util_1.default({
|
232334
|
+
client,
|
232335
|
+
currentTeam: fromDeployment.team?.id,
|
232336
|
+
});
|
232337
|
+
const error = await now.handleDeploymentError(event.payload, {
|
232338
|
+
env: {},
|
232339
|
+
});
|
232031
232340
|
throw error;
|
232032
232341
|
}
|
232033
232342
|
}
|
@@ -232297,7 +232606,7 @@ function deploymentsAndProjects(deployments, projects, conjunction = 'and') {
|
|
232297
232606
|
|
232298
232607
|
/***/ }),
|
232299
232608
|
|
232300
|
-
/***/
|
232609
|
+
/***/ 78339:
|
232301
232610
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
232302
232611
|
|
232303
232612
|
"use strict";
|
@@ -232307,18 +232616,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
232307
232616
|
};
|
232308
232617
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
232309
232618
|
const chalk_1 = __importDefault(__webpack_require__(90877));
|
232310
|
-
const ensure_link_1 = __webpack_require__(65382);
|
232311
232619
|
const get_args_1 = __importDefault(__webpack_require__(2505));
|
232620
|
+
const get_project_by_cwd_or_link_1 = __importDefault(__webpack_require__(90675));
|
232312
232621
|
const pkg_name_1 = __webpack_require__(79000);
|
232313
232622
|
const handle_error_1 = __importDefault(__webpack_require__(64377));
|
232623
|
+
const error_utils_1 = __webpack_require__(39799);
|
232314
232624
|
const logo_1 = __importDefault(__webpack_require__(66669));
|
232315
232625
|
const ms_1 = __importDefault(__webpack_require__(21378));
|
232316
|
-
const request_rollback_1 = __importDefault(__webpack_require__(
|
232317
|
-
const status_1 = __importDefault(__webpack_require__(
|
232318
|
-
const validate_paths_1 = __importDefault(__webpack_require__(33922));
|
232626
|
+
const request_rollback_1 = __importDefault(__webpack_require__(30964));
|
232627
|
+
const status_1 = __importDefault(__webpack_require__(16097));
|
232319
232628
|
const help = () => {
|
232320
232629
|
console.log(`
|
232321
|
-
${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()} rollback`)} [
|
232630
|
+
${chalk_1.default.bold(`${logo_1.default} ${(0, pkg_name_1.getPkgName)()} rollback`)} [deployment id/url]
|
232322
232631
|
|
232323
232632
|
Quickly revert back to a previous deployment.
|
232324
232633
|
|
@@ -232339,6 +232648,7 @@ const help = () => {
|
|
232339
232648
|
|
232340
232649
|
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} rollback`)}
|
232341
232650
|
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} rollback status`)}
|
232651
|
+
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} rollback status <project>`)}
|
232342
232652
|
${chalk_1.default.cyan(`$ ${(0, pkg_name_1.getPkgName)()} rollback status --timeout 30s`)}
|
232343
232653
|
|
232344
232654
|
${chalk_1.default.gray('–')} Rollback a deployment using id or url
|
@@ -232355,56 +232665,276 @@ exports.default = async (client) => {
|
|
232355
232665
|
let argv;
|
232356
232666
|
try {
|
232357
232667
|
argv = (0, get_args_1.default)(client.argv.slice(2), {
|
232358
|
-
'--debug': Boolean,
|
232359
|
-
'-d': '--debug',
|
232360
232668
|
'--timeout': String,
|
232361
232669
|
'--yes': Boolean,
|
232362
232670
|
'-y': '--yes',
|
232363
232671
|
});
|
232364
232672
|
}
|
232365
|
-
catch (err) {
|
232366
|
-
(0, handle_error_1.default)(err);
|
232367
|
-
return 1;
|
232673
|
+
catch (err) {
|
232674
|
+
(0, handle_error_1.default)(err);
|
232675
|
+
return 1;
|
232676
|
+
}
|
232677
|
+
if (argv['--help'] || argv._[0] === 'help') {
|
232678
|
+
help();
|
232679
|
+
return 2;
|
232680
|
+
}
|
232681
|
+
// validate the timeout
|
232682
|
+
let timeout = argv['--timeout'];
|
232683
|
+
if (timeout && (0, ms_1.default)(timeout) === undefined) {
|
232684
|
+
client.output.error(`Invalid timeout "${timeout}"`);
|
232685
|
+
return 1;
|
232686
|
+
}
|
232687
|
+
const actionOrDeployId = argv._[1] || 'status';
|
232688
|
+
try {
|
232689
|
+
if (actionOrDeployId === 'status') {
|
232690
|
+
const project = await (0, get_project_by_cwd_or_link_1.default)({
|
232691
|
+
autoConfirm: Boolean(argv['--yes']),
|
232692
|
+
client,
|
232693
|
+
commandName: 'promote',
|
232694
|
+
cwd: client.cwd,
|
232695
|
+
projectNameOrId: argv._[2],
|
232696
|
+
});
|
232697
|
+
return await (0, status_1.default)({
|
232698
|
+
client,
|
232699
|
+
project,
|
232700
|
+
timeout,
|
232701
|
+
});
|
232702
|
+
}
|
232703
|
+
return await (0, request_rollback_1.default)({
|
232704
|
+
client,
|
232705
|
+
deployId: actionOrDeployId,
|
232706
|
+
timeout,
|
232707
|
+
});
|
232708
|
+
}
|
232709
|
+
catch (err) {
|
232710
|
+
if ((0, error_utils_1.isErrnoException)(err)) {
|
232711
|
+
if (err.code === 'ERR_CANCELED') {
|
232712
|
+
return 0;
|
232713
|
+
}
|
232714
|
+
if (err.code === 'ERR_INVALID_CWD' || err.code === 'ERR_LINK_PROJECT') {
|
232715
|
+
// do not show the message
|
232716
|
+
return 1;
|
232717
|
+
}
|
232718
|
+
}
|
232719
|
+
client.output.prettyError(err);
|
232720
|
+
return 1;
|
232721
|
+
}
|
232722
|
+
};
|
232723
|
+
|
232724
|
+
|
232725
|
+
/***/ }),
|
232726
|
+
|
232727
|
+
/***/ 30964:
|
232728
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
232729
|
+
|
232730
|
+
"use strict";
|
232731
|
+
|
232732
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
232733
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
232734
|
+
};
|
232735
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
232736
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
232737
|
+
const pkg_name_1 = __webpack_require__(79000);
|
232738
|
+
const get_project_by_deployment_1 = __importDefault(__webpack_require__(67231));
|
232739
|
+
const ms_1 = __importDefault(__webpack_require__(21378));
|
232740
|
+
const status_1 = __importDefault(__webpack_require__(16097));
|
232741
|
+
/**
|
232742
|
+
* Requests a rollback and waits for it complete.
|
232743
|
+
* @param {Client} client - The Vercel client instance
|
232744
|
+
* @param {string} deployIdOrUrl - The deployment name or id to rollback
|
232745
|
+
* @param {string} [timeout] - Time to poll for succeeded/failed state
|
232746
|
+
* @returns {Promise<number>} Resolves an exit code; 0 on success
|
232747
|
+
*/
|
232748
|
+
async function requestRollback({ client, deployId, timeout, }) {
|
232749
|
+
const { output } = client;
|
232750
|
+
const { contextName, deployment, project } = await (0, get_project_by_deployment_1.default)({
|
232751
|
+
client,
|
232752
|
+
deployId,
|
232753
|
+
output: client.output,
|
232754
|
+
});
|
232755
|
+
// create the rollback
|
232756
|
+
await client.fetch(`/v9/projects/${project.id}/rollback/${deployment.id}`, {
|
232757
|
+
body: {},
|
232758
|
+
method: 'POST',
|
232759
|
+
});
|
232760
|
+
if (timeout !== undefined && (0, ms_1.default)(timeout) === 0) {
|
232761
|
+
output.log(`Successfully requested rollback of ${chalk_1.default.bold(project.name)} to ${deployment.url} (${deployment.id})`);
|
232762
|
+
output.log(`To check rollback status, run ${(0, pkg_name_1.getCommandName)('rollback')}.`);
|
232763
|
+
return 0;
|
232764
|
+
}
|
232765
|
+
// check the status
|
232766
|
+
return await (0, status_1.default)({
|
232767
|
+
client,
|
232768
|
+
contextName,
|
232769
|
+
deployment,
|
232770
|
+
project,
|
232771
|
+
timeout,
|
232772
|
+
});
|
232773
|
+
}
|
232774
|
+
exports.default = requestRollback;
|
232775
|
+
|
232776
|
+
|
232777
|
+
/***/ }),
|
232778
|
+
|
232779
|
+
/***/ 16097:
|
232780
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
232781
|
+
|
232782
|
+
"use strict";
|
232783
|
+
|
232784
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
232785
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
232786
|
+
};
|
232787
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
232788
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
232789
|
+
const elapsed_1 = __importDefault(__webpack_require__(14099));
|
232790
|
+
const format_date_1 = __importDefault(__webpack_require__(738));
|
232791
|
+
const get_deployment_1 = __importDefault(__webpack_require__(84249));
|
232792
|
+
const pkg_name_1 = __webpack_require__(79000);
|
232793
|
+
const get_project_by_id_or_name_1 = __importDefault(__webpack_require__(6729));
|
232794
|
+
const get_scope_1 = __importDefault(__webpack_require__(60324));
|
232795
|
+
const ms_1 = __importDefault(__webpack_require__(21378));
|
232796
|
+
const errors_ts_1 = __webpack_require__(39240);
|
232797
|
+
const render_alias_status_1 = __importDefault(__webpack_require__(33688));
|
232798
|
+
const sleep_1 = __importDefault(__webpack_require__(89507));
|
232799
|
+
/**
|
232800
|
+
* Continuously checks a deployment status until it has succeeded, failed, or
|
232801
|
+
* taken longer than the timeout (default 3 minutes).
|
232802
|
+
* @param {Client} client - The Vercel client instance
|
232803
|
+
* @param {string} [contextName] - The scope name; if not specified, it will be
|
232804
|
+
* extracted from the `client`
|
232805
|
+
* @param {Deployment} [deployment] - Info about the deployment which is used
|
232806
|
+
* to display different output following a rollback request
|
232807
|
+
* @param {Project} project - Project info instance
|
232808
|
+
* @param {string} [timeout] - Milliseconds to poll for succeeded/failed state
|
232809
|
+
* @returns {Promise<number>} Resolves an exit code; 0 on success
|
232810
|
+
*/
|
232811
|
+
async function rollbackStatus({ client, contextName, deployment, project, timeout = '3m', }) {
|
232812
|
+
const { output } = client;
|
232813
|
+
const recentThreshold = Date.now() - (0, ms_1.default)('3m');
|
232814
|
+
const rollbackTimeout = Date.now() + (0, ms_1.default)(timeout);
|
232815
|
+
let counter = 0;
|
232816
|
+
let spinnerMessage = deployment
|
232817
|
+
? 'Rollback in progress'
|
232818
|
+
: `Checking rollback status of ${project.name}`;
|
232819
|
+
if (!contextName) {
|
232820
|
+
({ contextName } = await (0, get_scope_1.default)(client));
|
232821
|
+
}
|
232822
|
+
try {
|
232823
|
+
output.spinner(`${spinnerMessage}…`);
|
232824
|
+
// continuously loop until the rollback has explicitly succeeded, failed,
|
232825
|
+
// or timed out
|
232826
|
+
for (;;) {
|
232827
|
+
const projectCheck = await (0, get_project_by_id_or_name_1.default)(client, project.id, project.accountId, true);
|
232828
|
+
if (projectCheck instanceof errors_ts_1.ProjectNotFound) {
|
232829
|
+
throw projectCheck;
|
232830
|
+
}
|
232831
|
+
const { jobStatus, requestedAt, toDeploymentId, type, } = projectCheck.lastAliasRequest ?? {};
|
232832
|
+
if (!jobStatus ||
|
232833
|
+
(jobStatus !== 'in-progress' && jobStatus !== 'pending')) {
|
232834
|
+
output.stopSpinner();
|
232835
|
+
output.log(`${spinnerMessage}…`);
|
232836
|
+
}
|
232837
|
+
if (!jobStatus ||
|
232838
|
+
!requestedAt ||
|
232839
|
+
!toDeploymentId ||
|
232840
|
+
requestedAt < recentThreshold) {
|
232841
|
+
output.log('No deployment rollback in progress');
|
232842
|
+
return 0;
|
232843
|
+
}
|
232844
|
+
if (jobStatus === 'skipped' && type === 'rollback') {
|
232845
|
+
output.log('Rollback was skipped');
|
232846
|
+
return 0;
|
232847
|
+
}
|
232848
|
+
if (jobStatus === 'succeeded') {
|
232849
|
+
return await renderJobSucceeded({
|
232850
|
+
client,
|
232851
|
+
contextName,
|
232852
|
+
performingRollback: !!deployment,
|
232853
|
+
requestedAt,
|
232854
|
+
project,
|
232855
|
+
toDeploymentId,
|
232856
|
+
});
|
232857
|
+
}
|
232858
|
+
if (jobStatus === 'failed') {
|
232859
|
+
return await renderJobFailed({
|
232860
|
+
client,
|
232861
|
+
contextName,
|
232862
|
+
deployment,
|
232863
|
+
project,
|
232864
|
+
toDeploymentId,
|
232865
|
+
});
|
232866
|
+
}
|
232867
|
+
// lastly, if we're not pending/in-progress, then we don't know what
|
232868
|
+
// the status is, so bail
|
232869
|
+
if (jobStatus !== 'pending' && jobStatus !== 'in-progress') {
|
232870
|
+
output.log(`Unknown rollback status "${jobStatus}"`);
|
232871
|
+
return 1;
|
232872
|
+
}
|
232873
|
+
// check if we have been running for too long
|
232874
|
+
if (requestedAt < recentThreshold || Date.now() >= rollbackTimeout) {
|
232875
|
+
output.log(`The rollback exceeded its deadline - rerun ${chalk_1.default.bold(`${(0, pkg_name_1.getPkgName)()} rollback ${toDeploymentId}`)} to try again`);
|
232876
|
+
return 1;
|
232877
|
+
}
|
232878
|
+
// if we've done our first poll and not rolling back, then print the
|
232879
|
+
// requested at date/time
|
232880
|
+
if (counter++ === 0 && !deployment) {
|
232881
|
+
spinnerMessage += ` requested at ${(0, format_date_1.default)(requestedAt)}`;
|
232882
|
+
}
|
232883
|
+
output.spinner(`${spinnerMessage}…`);
|
232884
|
+
await (0, sleep_1.default)(250);
|
232885
|
+
}
|
232886
|
+
}
|
232887
|
+
finally {
|
232888
|
+
output.stopSpinner();
|
232368
232889
|
}
|
232369
|
-
|
232370
|
-
|
232371
|
-
|
232890
|
+
}
|
232891
|
+
exports.default = rollbackStatus;
|
232892
|
+
async function renderJobFailed({ client, contextName, deployment, project, toDeploymentId, }) {
|
232893
|
+
const { output } = client;
|
232894
|
+
try {
|
232895
|
+
const name = (deployment || (await (0, get_deployment_1.default)(client, contextName, toDeploymentId)))?.url;
|
232896
|
+
output.error(`Failed to remap all aliases to the requested deployment ${name} (${toDeploymentId})`);
|
232372
232897
|
}
|
232373
|
-
|
232374
|
-
|
232375
|
-
const pathValidation = await (0, validate_paths_1.default)(client, [cwd]);
|
232376
|
-
if (!pathValidation.valid) {
|
232377
|
-
return pathValidation.exitCode;
|
232898
|
+
catch (e) {
|
232899
|
+
output.error(`Failed to remap all aliases to the requested deployment ${toDeploymentId}`);
|
232378
232900
|
}
|
232379
|
-
//
|
232380
|
-
|
232381
|
-
|
232382
|
-
|
232383
|
-
|
232384
|
-
|
232901
|
+
// aliases are paginated, so continuously loop until all of them have been
|
232902
|
+
// fetched
|
232903
|
+
let nextTimestamp;
|
232904
|
+
for (;;) {
|
232905
|
+
let url = `/v9/projects/${project.id}/rollback/aliases?failedOnly=true&limit=20`;
|
232906
|
+
if (nextTimestamp) {
|
232907
|
+
url += `&until=${nextTimestamp}`;
|
232908
|
+
}
|
232909
|
+
const { aliases, pagination } = await client.fetch(url);
|
232910
|
+
for (const { alias, status } of aliases) {
|
232911
|
+
output.log(` ${(0, render_alias_status_1.default)(status).padEnd(11)} ${alias.alias} (${alias.deploymentId})`);
|
232912
|
+
}
|
232913
|
+
if (pagination?.next) {
|
232914
|
+
nextTimestamp = pagination.next;
|
232915
|
+
}
|
232916
|
+
else {
|
232917
|
+
break;
|
232918
|
+
}
|
232385
232919
|
}
|
232386
|
-
|
232387
|
-
|
232388
|
-
|
232389
|
-
|
232390
|
-
|
232920
|
+
return 1;
|
232921
|
+
}
|
232922
|
+
async function renderJobSucceeded({ client, contextName, performingRollback, project, requestedAt, toDeploymentId, }) {
|
232923
|
+
const { output } = client;
|
232924
|
+
// attempt to get the new deployment url
|
232925
|
+
let deploymentInfo = '';
|
232926
|
+
try {
|
232927
|
+
const deployment = await (0, get_deployment_1.default)(client, contextName, toDeploymentId);
|
232928
|
+
deploymentInfo = `${chalk_1.default.bold(deployment.url)} (${toDeploymentId})`;
|
232391
232929
|
}
|
232392
|
-
|
232393
|
-
|
232394
|
-
|
232395
|
-
return await (0, status_1.default)({
|
232396
|
-
client,
|
232397
|
-
project,
|
232398
|
-
timeout,
|
232399
|
-
});
|
232930
|
+
catch (err) {
|
232931
|
+
output.debug(`Failed to get deployment url for ${toDeploymentId}: ${err?.toString() || err}`);
|
232932
|
+
deploymentInfo = chalk_1.default.bold(toDeploymentId);
|
232400
232933
|
}
|
232401
|
-
|
232402
|
-
|
232403
|
-
|
232404
|
-
|
232405
|
-
timeout,
|
232406
|
-
});
|
232407
|
-
};
|
232934
|
+
const duration = performingRollback ? (0, elapsed_1.default)(Date.now() - requestedAt) : '';
|
232935
|
+
output.log(`Success! ${chalk_1.default.bold(project.name)} was rolled back to ${deploymentInfo} ${duration}`);
|
232936
|
+
return 0;
|
232937
|
+
}
|
232408
232938
|
|
232409
232939
|
|
232410
232940
|
/***/ }),
|
@@ -233228,11 +233758,6 @@ const main = async () => {
|
|
233228
233758
|
output.prettyError(localConfig);
|
233229
233759
|
return 1;
|
233230
233760
|
}
|
233231
|
-
let cwd = argv['--cwd'];
|
233232
|
-
if (cwd) {
|
233233
|
-
process.chdir(cwd);
|
233234
|
-
}
|
233235
|
-
cwd = process.cwd();
|
233236
233761
|
// The second argument to the command can be:
|
233237
233762
|
//
|
233238
233763
|
// * a path to deploy (as in: `vercel path/`)
|
@@ -233334,6 +233859,11 @@ const main = async () => {
|
|
233334
233859
|
localConfigPath,
|
233335
233860
|
argv: process.argv,
|
233336
233861
|
});
|
233862
|
+
// The `--cwd` flag is respected for all sub-commands
|
233863
|
+
if (argv['--cwd']) {
|
233864
|
+
client.cwd = argv['--cwd'];
|
233865
|
+
}
|
233866
|
+
const { cwd } = client;
|
233337
233867
|
// Gets populated to the subcommand name when a built-in is
|
233338
233868
|
// provided, otherwise it remains undefined for an extension
|
233339
233869
|
let subcommand = undefined;
|
@@ -233573,6 +234103,9 @@ const main = async () => {
|
|
233573
234103
|
case 'project':
|
233574
234104
|
func = __webpack_require__(80860).default;
|
233575
234105
|
break;
|
234106
|
+
case 'promote':
|
234107
|
+
func = __webpack_require__(62435).default;
|
234108
|
+
break;
|
233576
234109
|
case 'pull':
|
233577
234110
|
func = __webpack_require__(65158).default;
|
233578
234111
|
break;
|
@@ -233583,7 +234116,7 @@ const main = async () => {
|
|
233583
234116
|
func = __webpack_require__(5445).default;
|
233584
234117
|
break;
|
233585
234118
|
case 'rollback':
|
233586
|
-
func = __webpack_require__(
|
234119
|
+
func = __webpack_require__(78339).default;
|
233587
234120
|
break;
|
233588
234121
|
case 'secrets':
|
233589
234122
|
func = __webpack_require__(5200)/* .default */ .Z;
|
@@ -234039,6 +234572,38 @@ async function removeAliasById(client, id) {
|
|
234039
234572
|
exports.default = removeAliasById;
|
234040
234573
|
|
234041
234574
|
|
234575
|
+
/***/ }),
|
234576
|
+
|
234577
|
+
/***/ 33688:
|
234578
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
234579
|
+
|
234580
|
+
"use strict";
|
234581
|
+
|
234582
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
234583
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
234584
|
+
};
|
234585
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
234586
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
234587
|
+
/**
|
234588
|
+
* Stylize the alias status label.
|
234589
|
+
* @param {AliasStatus} status - The status label
|
234590
|
+
* @returns {string}
|
234591
|
+
*/
|
234592
|
+
function renderAliasStatus(status) {
|
234593
|
+
if (status === 'completed') {
|
234594
|
+
return chalk_1.default.green(status);
|
234595
|
+
}
|
234596
|
+
if (status === 'failed') {
|
234597
|
+
return chalk_1.default.red(status);
|
234598
|
+
}
|
234599
|
+
if (status === 'skipped') {
|
234600
|
+
return chalk_1.default.gray(status);
|
234601
|
+
}
|
234602
|
+
return chalk_1.default.yellow(status);
|
234603
|
+
}
|
234604
|
+
exports.default = renderAliasStatus;
|
234605
|
+
|
234606
|
+
|
234042
234607
|
/***/ }),
|
234043
234608
|
|
234044
234609
|
/***/ 73396:
|
@@ -235906,6 +236471,12 @@ class Client extends events_1.EventEmitter {
|
|
235906
236471
|
output: this.stderr,
|
235907
236472
|
});
|
235908
236473
|
}
|
236474
|
+
get cwd() {
|
236475
|
+
return process.cwd();
|
236476
|
+
}
|
236477
|
+
set cwd(v) {
|
236478
|
+
process.chdir(v);
|
236479
|
+
}
|
235909
236480
|
}
|
235910
236481
|
exports.default = Client;
|
235911
236482
|
|
@@ -236387,9 +236958,9 @@ const ERRORS_TS = __importStar(__webpack_require__(39240));
|
|
236387
236958
|
const ERRORS = __importStar(__webpack_require__(74148));
|
236388
236959
|
const now_error_1 = __webpack_require__(22216);
|
236389
236960
|
const map_cert_error_1 = __importDefault(__webpack_require__(72812));
|
236390
|
-
async function createDeploy(client, now, contextName,
|
236961
|
+
async function createDeploy(client, now, contextName, path, createArgs, org, isSettingUpProject, cwd, archive) {
|
236391
236962
|
try {
|
236392
|
-
return await now.create(
|
236963
|
+
return await now.create(path, createArgs, org, isSettingUpProject, cwd, archive);
|
236393
236964
|
}
|
236394
236965
|
catch (err) {
|
236395
236966
|
if (ERRORS_TS.isAPIError(err)) {
|
@@ -236444,7 +237015,7 @@ async function createDeploy(client, now, contextName, paths, createArgs, org, is
|
|
236444
237015
|
if (result instanceof now_error_1.NowError) {
|
236445
237016
|
return result;
|
236446
237017
|
}
|
236447
|
-
return createDeploy(client, now, contextName,
|
237018
|
+
return createDeploy(client, now, contextName, path, createArgs, org, isSettingUpProject, cwd);
|
236448
237019
|
}
|
236449
237020
|
if (err.code === 'not_found') {
|
236450
237021
|
throw new ERRORS_TS.DeploymentNotFound({ context: contextName });
|
@@ -236911,8 +237482,9 @@ function printInspectUrl(output, inspectorUrl, deployStamp) {
|
|
236911
237482
|
output.print((0, emoji_1.prependEmoji)(`Inspect: ${chalk_1.default.bold(inspectorUrl)} ${deployStamp()}`, (0, emoji_1.emoji)('inspect')) + `\n`);
|
236912
237483
|
}
|
236913
237484
|
async function processDeployment({ org, cwd, projectName, isSettingUpProject, archive, skipAutoDetectionConfirmation, noWait, agent, ...args }) {
|
236914
|
-
let { now,
|
236915
|
-
const
|
237485
|
+
let { now, path, requestBody, deployStamp, force, withCache, quiet, prebuilt, rootDirectory, } = args;
|
237486
|
+
const client = now._client;
|
237487
|
+
const { output } = client;
|
236916
237488
|
const { env = {} } = requestBody;
|
236917
237489
|
const token = now._token;
|
236918
237490
|
if (!token) {
|
@@ -236924,7 +237496,7 @@ async function processDeployment({ org, cwd, projectName, isSettingUpProject, ar
|
|
236924
237496
|
token,
|
236925
237497
|
debug: now._debug,
|
236926
237498
|
userAgent: ua_1.default,
|
236927
|
-
path
|
237499
|
+
path,
|
236928
237500
|
force,
|
236929
237501
|
withCache,
|
236930
237502
|
prebuilt,
|
@@ -236947,7 +237519,7 @@ async function processDeployment({ org, cwd, projectName, isSettingUpProject, ar
|
|
236947
237519
|
}
|
236948
237520
|
if (event.type === 'file-count') {
|
236949
237521
|
const { total, missing, uploads } = event.payload;
|
236950
|
-
debug(`Total files ${total.size}, ${missing.length} changed`);
|
237522
|
+
output.debug(`Total files ${total.size}, ${missing.length} changed`);
|
236951
237523
|
const missingSize = missing
|
236952
237524
|
.map((sha) => total.get(sha).data.length)
|
236953
237525
|
.reduce((a, b) => a + b, 0);
|
@@ -236980,10 +237552,10 @@ async function processDeployment({ org, cwd, projectName, isSettingUpProject, ar
|
|
236980
237552
|
updateProgress();
|
236981
237553
|
}
|
236982
237554
|
if (event.type === 'file-uploaded') {
|
236983
|
-
debug(`Uploaded: ${event.payload.file.names.join(' ')} (${(0, bytes_1.default)(event.payload.file.data.length)})`);
|
237555
|
+
output.debug(`Uploaded: ${event.payload.file.names.join(' ')} (${(0, bytes_1.default)(event.payload.file.data.length)})`);
|
236984
237556
|
}
|
236985
237557
|
if (event.type === 'created') {
|
236986
|
-
await (0, link_1.linkFolderToProject)(
|
237558
|
+
await (0, link_1.linkFolderToProject)(client, cwd, {
|
236987
237559
|
orgId: org.id,
|
236988
237560
|
projectId: event.payload.projectId,
|
236989
237561
|
}, projectName, org.slug);
|
@@ -243897,11 +244469,11 @@ class Now extends events_1.default {
|
|
243897
244469
|
get _debug() {
|
243898
244470
|
return this._client.output.isDebugEnabled();
|
243899
244471
|
}
|
243900
|
-
async create(
|
244472
|
+
async create(path, {
|
243901
244473
|
// Legacy
|
243902
244474
|
nowConfig: nowConfig = {},
|
243903
244475
|
// Latest
|
243904
|
-
name, project, prebuilt = false, rootDirectory, wantsPublic, meta, gitMetadata, regions, quiet = false, env, build, forceNew = false, withCache = false, target = null, deployStamp, projectSettings, skipAutoDetectionConfirmation, noWait, autoAssignCustomDomains, }, org, isSettingUpProject,
|
244476
|
+
name, project, prebuilt = false, rootDirectory, wantsPublic, meta, gitMetadata, regions, quiet = false, env, build, forceNew = false, withCache = false, target = null, deployStamp, projectSettings, skipAutoDetectionConfirmation, noWait, autoAssignCustomDomains, }, org, isSettingUpProject, cwd, archive) {
|
243905
244477
|
let hashes = {};
|
243906
244478
|
const uploadStamp = (0, stamp_1.default)();
|
243907
244479
|
let requestBody = {
|
@@ -243924,9 +244496,8 @@ class Now extends events_1.default {
|
|
243924
244496
|
delete requestBody.github;
|
243925
244497
|
const deployment = await (0, process_deployment_1.default)({
|
243926
244498
|
now: this,
|
243927
|
-
output: this._output,
|
243928
244499
|
agent: this._client.agent,
|
243929
|
-
|
244500
|
+
path,
|
243930
244501
|
requestBody,
|
243931
244502
|
uploadStamp,
|
243932
244503
|
deployStamp,
|
@@ -245465,7 +246036,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
245465
246036
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
245466
246037
|
};
|
245467
246038
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
245468
|
-
exports.findProjectFromPath = exports.traverseUpDirectories = exports.findRepoRoot = exports.ensureRepoLink = exports.getRepoLink = void 0;
|
246039
|
+
exports.findProjectFromPath = exports.findProjectsFromPath = exports.traverseUpDirectories = exports.findRepoRoot = exports.ensureRepoLink = exports.getRepoLink = void 0;
|
245469
246040
|
const chalk_1 = __importDefault(__webpack_require__(90877));
|
245470
246041
|
const pluralize_1 = __importDefault(__webpack_require__(43669));
|
245471
246042
|
const os_1 = __webpack_require__(12087);
|
@@ -245604,8 +246175,20 @@ async function findRepoRoot(start) {
|
|
245604
246175
|
// this isn't the repo we're looking for. Bail.
|
245605
246176
|
break;
|
245606
246177
|
}
|
246178
|
+
// if `.vercel/repo.json` exists (already linked),
|
246179
|
+
// then consider this the repo root
|
246180
|
+
const repoConfigPath = (0, path_1.join)(current, link_1.VERCEL_DIR, link_1.VERCEL_DIR_REPO);
|
246181
|
+
let stat = await (0, fs_extra_1.lstat)(repoConfigPath).catch(err => {
|
246182
|
+
if (err.code !== 'ENOENT')
|
246183
|
+
throw err;
|
246184
|
+
});
|
246185
|
+
if (stat) {
|
246186
|
+
return current;
|
246187
|
+
}
|
246188
|
+
// if `.git/config` exists (unlinked),
|
246189
|
+
// then consider this the repo root
|
245607
246190
|
const gitConfigPath = (0, path_1.join)(current, '.git/config');
|
245608
|
-
|
246191
|
+
stat = await (0, fs_extra_1.lstat)(gitConfigPath).catch(err => {
|
245609
246192
|
if (err.code !== 'ENOENT')
|
245610
246193
|
throw err;
|
245611
246194
|
});
|
@@ -245631,16 +246214,16 @@ function sortByDirectory(a, b) {
|
|
245631
246214
|
return bParts.length - aParts.length;
|
245632
246215
|
}
|
245633
246216
|
/**
|
245634
|
-
* Finds the matching
|
246217
|
+
* Finds the matching Projects from an array of Project links
|
245635
246218
|
* where the provided relative path is within the Project's
|
245636
246219
|
* root directory.
|
245637
246220
|
*/
|
245638
|
-
function
|
246221
|
+
function findProjectsFromPath(projects, path) {
|
245639
246222
|
const normalizedPath = (0, build_utils_1.normalizePath)(path);
|
245640
246223
|
return projects
|
245641
246224
|
.slice()
|
245642
246225
|
.sort(sortByDirectory)
|
245643
|
-
.
|
246226
|
+
.filter(project => {
|
245644
246227
|
if (project.directory === '.') {
|
245645
246228
|
// Project has no "Root Directory" setting, so any path is valid
|
245646
246229
|
return true;
|
@@ -245649,6 +246232,13 @@ function findProjectFromPath(projects, path) {
|
|
245649
246232
|
normalizedPath.startsWith(`${project.directory}/`));
|
245650
246233
|
});
|
245651
246234
|
}
|
246235
|
+
exports.findProjectsFromPath = findProjectsFromPath;
|
246236
|
+
/**
|
246237
|
+
* TODO: remove
|
246238
|
+
*/
|
246239
|
+
function findProjectFromPath(projects, path) {
|
246240
|
+
return findProjectsFromPath(projects, path)[0];
|
246241
|
+
}
|
245652
246242
|
exports.findProjectFromPath = findProjectFromPath;
|
245653
246243
|
|
245654
246244
|
|
@@ -245740,7 +246330,7 @@ async function setupAndLink(client, path, { autoConfirm = false, forceDelete = f
|
|
245740
246330
|
}
|
245741
246331
|
else {
|
245742
246332
|
const project = projectOrNewProjectName;
|
245743
|
-
await (0, link_1.linkFolderToProject)(
|
246333
|
+
await (0, link_1.linkFolderToProject)(client, path, {
|
245744
246334
|
projectId: project.id,
|
245745
246335
|
orgId: org.id,
|
245746
246336
|
}, project.name, org.slug, successEmoji);
|
@@ -245792,7 +246382,7 @@ async function setupAndLink(client, path, { autoConfirm = false, forceDelete = f
|
|
245792
246382
|
},
|
245793
246383
|
autoAssignCustomDomains: true,
|
245794
246384
|
};
|
245795
|
-
const deployment = await (0, create_deploy_1.default)(client, now, config.currentTeam || 'current user',
|
246385
|
+
const deployment = await (0, create_deploy_1.default)(client, now, config.currentTeam || 'current user', sourcePath, createArgs, org, true, path);
|
245796
246386
|
if (!deployment ||
|
245797
246387
|
!('code' in deployment) ||
|
245798
246388
|
deployment.code !== 'missing_project_settings') {
|
@@ -245815,7 +246405,7 @@ async function setupAndLink(client, path, { autoConfirm = false, forceDelete = f
|
|
245815
246405
|
const project = await (0, create_project_1.default)(client, newProjectName);
|
245816
246406
|
await (0, update_project_1.default)(client, project.id, settings);
|
245817
246407
|
Object.assign(project, settings);
|
245818
|
-
await (0, link_1.linkFolderToProject)(
|
246408
|
+
await (0, link_1.linkFolderToProject)(client, path, {
|
245819
246409
|
projectId: project.id,
|
245820
246410
|
orgId: org.id,
|
245821
246411
|
}, project.name, org.slug, successEmoji);
|
@@ -247729,6 +248319,118 @@ async function findProjectsForDomain(client, domainName) {
|
|
247729
248319
|
exports.findProjectsForDomain = findProjectsForDomain;
|
247730
248320
|
|
247731
248321
|
|
248322
|
+
/***/ }),
|
248323
|
+
|
248324
|
+
/***/ 90675:
|
248325
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
248326
|
+
|
248327
|
+
"use strict";
|
248328
|
+
|
248329
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
248330
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
248331
|
+
};
|
248332
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
248333
|
+
const errors_ts_1 = __webpack_require__(39240);
|
248334
|
+
const ensure_link_1 = __webpack_require__(65382);
|
248335
|
+
const get_project_by_id_or_name_1 = __importDefault(__webpack_require__(6729));
|
248336
|
+
async function getProjectByCwdOrLink({ autoConfirm, client, commandName, cwd, projectNameOrId, }) {
|
248337
|
+
if (projectNameOrId) {
|
248338
|
+
const project = await (0, get_project_by_id_or_name_1.default)(client, projectNameOrId);
|
248339
|
+
if (project instanceof errors_ts_1.ProjectNotFound) {
|
248340
|
+
throw project;
|
248341
|
+
}
|
248342
|
+
return project;
|
248343
|
+
}
|
248344
|
+
// ensure the current directory is a linked project
|
248345
|
+
const linkedProject = await (0, ensure_link_1.ensureLink)(commandName, client, cwd, {
|
248346
|
+
autoConfirm,
|
248347
|
+
});
|
248348
|
+
if (typeof linkedProject === 'number') {
|
248349
|
+
const err = new Error('Link project error');
|
248350
|
+
err.code = 'ERR_LINK_PROJECT';
|
248351
|
+
throw err;
|
248352
|
+
}
|
248353
|
+
return linkedProject.project;
|
248354
|
+
}
|
248355
|
+
exports.default = getProjectByCwdOrLink;
|
248356
|
+
|
248357
|
+
|
248358
|
+
/***/ }),
|
248359
|
+
|
248360
|
+
/***/ 67231:
|
248361
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
248362
|
+
|
248363
|
+
"use strict";
|
248364
|
+
|
248365
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
248366
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
248367
|
+
};
|
248368
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
248369
|
+
const chalk_1 = __importDefault(__webpack_require__(90877));
|
248370
|
+
const get_deployment_1 = __importDefault(__webpack_require__(84249));
|
248371
|
+
const get_project_by_id_or_name_1 = __importDefault(__webpack_require__(6729));
|
248372
|
+
const get_scope_1 = __importDefault(__webpack_require__(60324));
|
248373
|
+
const get_team_by_id_1 = __importDefault(__webpack_require__(94949));
|
248374
|
+
const is_valid_name_1 = __webpack_require__(64476);
|
248375
|
+
const errors_ts_1 = __webpack_require__(39240);
|
248376
|
+
async function getProjectByDeployment({ client, deployId, output, }) {
|
248377
|
+
const { config } = client;
|
248378
|
+
const { contextName } = await (0, get_scope_1.default)(client);
|
248379
|
+
if (!(0, is_valid_name_1.isValidName)(deployId)) {
|
248380
|
+
throw new Error(`The provided argument "${deployId}" is not a valid deployment ID or URL`);
|
248381
|
+
}
|
248382
|
+
let deployment;
|
248383
|
+
let team;
|
248384
|
+
try {
|
248385
|
+
output?.spinner(`Fetching deployment "${deployId}" in ${chalk_1.default.bold(contextName)}…`);
|
248386
|
+
const [teamResult, deploymentResult] = await Promise.allSettled([
|
248387
|
+
config.currentTeam ? (0, get_team_by_id_1.default)(client, config.currentTeam) : undefined,
|
248388
|
+
(0, get_deployment_1.default)(client, contextName, deployId),
|
248389
|
+
]);
|
248390
|
+
if (teamResult.status === 'rejected') {
|
248391
|
+
throw new Error(`Failed to retrieve team information: ${teamResult.reason}`);
|
248392
|
+
}
|
248393
|
+
if (deploymentResult.status === 'rejected') {
|
248394
|
+
throw new Error(deploymentResult.reason);
|
248395
|
+
}
|
248396
|
+
team = teamResult.value;
|
248397
|
+
deployment = deploymentResult.value;
|
248398
|
+
// re-render the spinner text
|
248399
|
+
output?.log(`Fetching deployment "${deployId}" in ${chalk_1.default.bold(contextName)}…`);
|
248400
|
+
if (deployment.team?.id) {
|
248401
|
+
if (!team || deployment.team.id !== team.id) {
|
248402
|
+
const err = new Error(team
|
248403
|
+
? `Deployment doesn't belong to current team ${chalk_1.default.bold(contextName)}`
|
248404
|
+
: `Deployment belongs to a different team`);
|
248405
|
+
err.code = 'ERR_INVALID_TEAM';
|
248406
|
+
throw err;
|
248407
|
+
}
|
248408
|
+
}
|
248409
|
+
if (team) {
|
248410
|
+
const err = new Error(`Deployment doesn't belong to current team ${chalk_1.default.bold(contextName)}`);
|
248411
|
+
err.code = 'ERR_INVALID_TEAM';
|
248412
|
+
throw err;
|
248413
|
+
}
|
248414
|
+
if (!deployment.projectId) {
|
248415
|
+
throw new Error('Deployment is not associated to a project');
|
248416
|
+
}
|
248417
|
+
const project = await (0, get_project_by_id_or_name_1.default)(client, deployment.projectId);
|
248418
|
+
if (project instanceof errors_ts_1.ProjectNotFound) {
|
248419
|
+
throw project;
|
248420
|
+
}
|
248421
|
+
return {
|
248422
|
+
contextName,
|
248423
|
+
deployment,
|
248424
|
+
project,
|
248425
|
+
};
|
248426
|
+
}
|
248427
|
+
finally {
|
248428
|
+
output?.stopSpinner();
|
248429
|
+
}
|
248430
|
+
}
|
248431
|
+
exports.default = getProjectByDeployment;
|
248432
|
+
|
248433
|
+
|
247732
248434
|
/***/ }),
|
247733
248435
|
|
247734
248436
|
/***/ 6729:
|
@@ -247738,9 +248440,10 @@ exports.findProjectsForDomain = findProjectsForDomain;
|
|
247738
248440
|
|
247739
248441
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
247740
248442
|
const errors_ts_1 = __webpack_require__(39240);
|
247741
|
-
async function getProjectByNameOrId(client, projectNameOrId, accountId) {
|
248443
|
+
async function getProjectByNameOrId(client, projectNameOrId, accountId, includeRollbackInfo) {
|
247742
248444
|
try {
|
247743
|
-
const
|
248445
|
+
const qs = includeRollbackInfo ? '?rollbackInfo=true' : '';
|
248446
|
+
const project = await client.fetch(`/v9/projects/${encodeURIComponent(projectNameOrId)}${qs}`, { accountId });
|
247744
248447
|
return project;
|
247745
248448
|
}
|
247746
248449
|
catch (err) {
|
@@ -247822,34 +248525,38 @@ function getVercelDirectory(cwd) {
|
|
247822
248525
|
return existingDirs[0] || possibleDirs[0];
|
247823
248526
|
}
|
247824
248527
|
exports.getVercelDirectory = getVercelDirectory;
|
247825
|
-
async function
|
247826
|
-
|
247827
|
-
|
247828
|
-
|
247829
|
-
|
247830
|
-
|
247831
|
-
|
247832
|
-
// Try the repo linking style (`${repoRoot}/.vercel/repo.json`)
|
247833
|
-
return getLinkFromRepo(path);
|
247834
|
-
}
|
247835
|
-
async function getLinkFromRepo(path) {
|
247836
|
-
const repoRoot = await (0, repo_1.findRepoRoot)(path);
|
247837
|
-
if (!repoRoot) {
|
248528
|
+
async function getProjectLink(client, path) {
|
248529
|
+
return ((await getProjectLinkFromRepoLink(client, path)) ||
|
248530
|
+
(await getLinkFromDir(getVercelDirectory(path))));
|
248531
|
+
}
|
248532
|
+
async function getProjectLinkFromRepoLink(client, path) {
|
248533
|
+
const repoLink = await (0, repo_1.getRepoLink)(path);
|
248534
|
+
if (!repoLink?.repoConfig) {
|
247838
248535
|
return null;
|
247839
248536
|
}
|
247840
|
-
|
247841
|
-
|
247842
|
-
|
247843
|
-
|
247844
|
-
const project = (0, repo_1.findProjectFromPath)(repoJson.projects, (0, path_1.relative)(repoRoot, path));
|
247845
|
-
if (project) {
|
247846
|
-
return { orgId: repoJson.orgId, projectId: project.id };
|
247847
|
-
}
|
248537
|
+
const projects = (0, repo_1.findProjectsFromPath)(repoLink.repoConfig.projects, (0, path_1.relative)(repoLink.rootPath, path));
|
248538
|
+
let project;
|
248539
|
+
if (projects.length === 1) {
|
248540
|
+
project = projects[0];
|
247848
248541
|
}
|
247849
|
-
|
247850
|
-
|
247851
|
-
|
247852
|
-
|
248542
|
+
else {
|
248543
|
+
const { p } = await client.prompt({
|
248544
|
+
name: 'p',
|
248545
|
+
type: 'list',
|
248546
|
+
message: `Please select a Project:`,
|
248547
|
+
choices: repoLink.repoConfig.projects.map(p => ({
|
248548
|
+
value: p,
|
248549
|
+
name: p.name,
|
248550
|
+
})),
|
248551
|
+
});
|
248552
|
+
project = p;
|
248553
|
+
}
|
248554
|
+
if (project) {
|
248555
|
+
return {
|
248556
|
+
orgId: repoLink.repoConfig.orgId,
|
248557
|
+
projectId: project.id,
|
248558
|
+
repoRoot: repoLink.rootPath,
|
248559
|
+
};
|
247853
248560
|
}
|
247854
248561
|
return null;
|
247855
248562
|
}
|
@@ -247890,7 +248597,30 @@ async function getOrgById(client, orgId) {
|
|
247890
248597
|
return null;
|
247891
248598
|
return { type: 'user', id: orgId, slug: user.username };
|
247892
248599
|
}
|
247893
|
-
async function
|
248600
|
+
async function hasProjectLink(projectLink, path) {
|
248601
|
+
// "linked" via env vars?
|
248602
|
+
const VERCEL_ORG_ID = (0, build_utils_1.getPlatformEnv)('ORG_ID');
|
248603
|
+
const VERCEL_PROJECT_ID = (0, build_utils_1.getPlatformEnv)('PROJECT_ID');
|
248604
|
+
if (VERCEL_ORG_ID === projectLink.orgId &&
|
248605
|
+
VERCEL_PROJECT_ID === projectLink.projectId) {
|
248606
|
+
return true;
|
248607
|
+
}
|
248608
|
+
// linked via `repo.json`?
|
248609
|
+
const repoLink = await (0, repo_1.getRepoLink)(path);
|
248610
|
+
if (repoLink?.repoConfig?.orgId === projectLink.orgId &&
|
248611
|
+
repoLink.repoConfig.projects.find(p => p.id === projectLink.projectId)) {
|
248612
|
+
return true;
|
248613
|
+
}
|
248614
|
+
// if the project is already linked, we skip linking
|
248615
|
+
const link = await getLinkFromDir(getVercelDirectory(path));
|
248616
|
+
if (link &&
|
248617
|
+
link.orgId === projectLink.orgId &&
|
248618
|
+
link.projectId === projectLink.projectId) {
|
248619
|
+
return true;
|
248620
|
+
}
|
248621
|
+
return false;
|
248622
|
+
}
|
248623
|
+
async function getLinkedProject(client, path = client.cwd) {
|
247894
248624
|
const { output } = client;
|
247895
248625
|
const VERCEL_ORG_ID = (0, build_utils_1.getPlatformEnv)('ORG_ID');
|
247896
248626
|
const VERCEL_PROJECT_ID = (0, build_utils_1.getPlatformEnv)('PROJECT_ID');
|
@@ -247901,7 +248631,7 @@ async function getLinkedProject(client, path = process.cwd()) {
|
|
247901
248631
|
}
|
247902
248632
|
const link = VERCEL_ORG_ID && VERCEL_PROJECT_ID
|
247903
248633
|
? { orgId: VERCEL_ORG_ID, projectId: VERCEL_PROJECT_ID }
|
247904
|
-
: await
|
248634
|
+
: await getProjectLink(client, path);
|
247905
248635
|
if (!link) {
|
247906
248636
|
return { status: 'not_linked', org: null, project: null };
|
247907
248637
|
}
|
@@ -247945,21 +248675,12 @@ async function getLinkedProject(client, path = process.cwd()) {
|
|
247945
248675
|
output.print((0, emoji_1.prependEmoji)('Your Project was either deleted, transferred to a new Team, or you don’t have access to it anymore.\n', (0, emoji_1.emoji)('warning')));
|
247946
248676
|
return { status: 'not_linked', org: null, project: null };
|
247947
248677
|
}
|
247948
|
-
return { status: 'linked', org, project };
|
248678
|
+
return { status: 'linked', org, project, repoRoot: link.repoRoot };
|
247949
248679
|
}
|
247950
248680
|
exports.getLinkedProject = getLinkedProject;
|
247951
|
-
async function linkFolderToProject(
|
247952
|
-
const VERCEL_ORG_ID = (0, build_utils_1.getPlatformEnv)('ORG_ID');
|
247953
|
-
const VERCEL_PROJECT_ID = (0, build_utils_1.getPlatformEnv)('PROJECT_ID');
|
247954
|
-
// if defined, skip linking
|
247955
|
-
if (VERCEL_ORG_ID || VERCEL_PROJECT_ID) {
|
247956
|
-
return;
|
247957
|
-
}
|
248681
|
+
async function linkFolderToProject(client, path, projectLink, projectName, orgSlug, successEmoji = 'link') {
|
247958
248682
|
// if the project is already linked, we skip linking
|
247959
|
-
|
247960
|
-
if (link &&
|
247961
|
-
link.orgId === projectLink.orgId &&
|
247962
|
-
link.projectId === projectLink.projectId) {
|
248683
|
+
if (await hasProjectLink(projectLink, path)) {
|
247963
248684
|
return;
|
247964
248685
|
}
|
247965
248686
|
try {
|
@@ -247977,7 +248698,7 @@ async function linkFolderToProject(output, path, projectLink, projectName, orgSl
|
|
247977
248698
|
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'));
|
247978
248699
|
// update .gitignore
|
247979
248700
|
const isGitIgnoreUpdated = await (0, add_to_gitignore_1.addToGitIgnore)(path);
|
247980
|
-
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');
|
248701
|
+
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');
|
247981
248702
|
}
|
247982
248703
|
exports.linkFolderToProject = linkFolderToProject;
|
247983
248704
|
|
@@ -248332,260 +249053,6 @@ async function responseError(res, fallbackMessage = null, parsedBody = {}) {
|
|
248332
249053
|
exports.default = responseError;
|
248333
249054
|
|
248334
249055
|
|
248335
|
-
/***/ }),
|
248336
|
-
|
248337
|
-
/***/ 8644:
|
248338
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
248339
|
-
|
248340
|
-
"use strict";
|
248341
|
-
|
248342
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
248343
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
248344
|
-
};
|
248345
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
248346
|
-
const chalk_1 = __importDefault(__webpack_require__(90877));
|
248347
|
-
/**
|
248348
|
-
* Stylize the alias status label.
|
248349
|
-
* @param {AliasStatus} status - The status label
|
248350
|
-
* @returns {string}
|
248351
|
-
*/
|
248352
|
-
function renderAliasStatus(status) {
|
248353
|
-
if (status === 'completed') {
|
248354
|
-
return chalk_1.default.green(status);
|
248355
|
-
}
|
248356
|
-
if (status === 'failed') {
|
248357
|
-
return chalk_1.default.red(status);
|
248358
|
-
}
|
248359
|
-
if (status === 'skipped') {
|
248360
|
-
return chalk_1.default.gray(status);
|
248361
|
-
}
|
248362
|
-
return chalk_1.default.yellow(status);
|
248363
|
-
}
|
248364
|
-
exports.default = renderAliasStatus;
|
248365
|
-
|
248366
|
-
|
248367
|
-
/***/ }),
|
248368
|
-
|
248369
|
-
/***/ 58601:
|
248370
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
248371
|
-
|
248372
|
-
"use strict";
|
248373
|
-
|
248374
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
248375
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
248376
|
-
};
|
248377
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
248378
|
-
const chalk_1 = __importDefault(__webpack_require__(90877));
|
248379
|
-
const pkg_name_1 = __webpack_require__(79000);
|
248380
|
-
const get_deployment_by_id_or_url_1 = __webpack_require__(47662);
|
248381
|
-
const get_scope_1 = __importDefault(__webpack_require__(60324));
|
248382
|
-
const error_utils_1 = __webpack_require__(39799);
|
248383
|
-
const ms_1 = __importDefault(__webpack_require__(21378));
|
248384
|
-
const status_1 = __importDefault(__webpack_require__(87181));
|
248385
|
-
/**
|
248386
|
-
* Requests a rollback and waits for it complete.
|
248387
|
-
* @param {Client} client - The Vercel client instance
|
248388
|
-
* @param {string} deployIdOrUrl - The deployment name or id to rollback
|
248389
|
-
* @param {Project} project - Project info instance
|
248390
|
-
* @param {string} [timeout] - Time to poll for succeeded/failed state
|
248391
|
-
* @returns {Promise<number>} Resolves an exit code; 0 on success
|
248392
|
-
*/
|
248393
|
-
async function requestRollback({ client, deployIdOrUrl, project, timeout, }) {
|
248394
|
-
const { output } = client;
|
248395
|
-
const { contextName } = await (0, get_scope_1.default)(client);
|
248396
|
-
try {
|
248397
|
-
const deployment = await (0, get_deployment_by_id_or_url_1.getDeploymentByIdOrURL)({
|
248398
|
-
client,
|
248399
|
-
contextName,
|
248400
|
-
deployIdOrUrl,
|
248401
|
-
});
|
248402
|
-
// create the rollback
|
248403
|
-
await client.fetch(`/v9/projects/${project.id}/rollback/${deployment.id}`, {
|
248404
|
-
body: {},
|
248405
|
-
method: 'POST',
|
248406
|
-
});
|
248407
|
-
if (timeout !== undefined && (0, ms_1.default)(timeout) === 0) {
|
248408
|
-
output.log(`Successfully requested rollback of ${chalk_1.default.bold(project.name)} to ${deployment.url} (${deployment.id})`);
|
248409
|
-
output.log(`To check rollback status, run ${(0, pkg_name_1.getCommandName)('rollback')}.`);
|
248410
|
-
return 0;
|
248411
|
-
}
|
248412
|
-
// check the status
|
248413
|
-
return await (0, status_1.default)({
|
248414
|
-
client,
|
248415
|
-
contextName,
|
248416
|
-
deployment,
|
248417
|
-
project,
|
248418
|
-
timeout,
|
248419
|
-
});
|
248420
|
-
}
|
248421
|
-
catch (err) {
|
248422
|
-
output.prettyError(err);
|
248423
|
-
if ((0, error_utils_1.isErrnoException)(err) && err.code === 'ERR_INVALID_TEAM') {
|
248424
|
-
output.error(`Use ${chalk_1.default.bold('vc switch')} to change your current team`);
|
248425
|
-
}
|
248426
|
-
return 1;
|
248427
|
-
}
|
248428
|
-
}
|
248429
|
-
exports.default = requestRollback;
|
248430
|
-
|
248431
|
-
|
248432
|
-
/***/ }),
|
248433
|
-
|
248434
|
-
/***/ 87181:
|
248435
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
248436
|
-
|
248437
|
-
"use strict";
|
248438
|
-
|
248439
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
248440
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
248441
|
-
};
|
248442
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
248443
|
-
const chalk_1 = __importDefault(__webpack_require__(90877));
|
248444
|
-
const elapsed_1 = __importDefault(__webpack_require__(14099));
|
248445
|
-
const format_date_1 = __importDefault(__webpack_require__(738));
|
248446
|
-
const get_deployment_1 = __importDefault(__webpack_require__(84249));
|
248447
|
-
const get_scope_1 = __importDefault(__webpack_require__(60324));
|
248448
|
-
const ms_1 = __importDefault(__webpack_require__(21378));
|
248449
|
-
const render_alias_status_1 = __importDefault(__webpack_require__(8644));
|
248450
|
-
const sleep_1 = __importDefault(__webpack_require__(89507));
|
248451
|
-
/**
|
248452
|
-
* Continuously checks a deployment status until it has succeeded, failed, or
|
248453
|
-
* taken longer than the timeout (default 3 minutes).
|
248454
|
-
* @param {Client} client - The Vercel client instance
|
248455
|
-
* @param {string} [contextName] - The scope name; if not specified, it will be
|
248456
|
-
* extracted from the `client`
|
248457
|
-
* @param {Deployment} [deployment] - Info about the deployment which is used
|
248458
|
-
* to display different output following a rollback request
|
248459
|
-
* @param {Project} project - Project info instance
|
248460
|
-
* @param {string} [timeout] - Milliseconds to poll for succeeded/failed state
|
248461
|
-
* @returns {Promise<number>} Resolves an exit code; 0 on success
|
248462
|
-
*/
|
248463
|
-
async function rollbackStatus({ client, contextName, deployment, project, timeout = '3m', }) {
|
248464
|
-
const { output } = client;
|
248465
|
-
const recentThreshold = Date.now() - (0, ms_1.default)('3m');
|
248466
|
-
const rollbackTimeout = Date.now() + (0, ms_1.default)(timeout);
|
248467
|
-
let counter = 0;
|
248468
|
-
let spinnerMessage = deployment
|
248469
|
-
? 'Rollback in progress'
|
248470
|
-
: `Checking rollback status of ${project.name}`;
|
248471
|
-
const check = async () => {
|
248472
|
-
const { lastRollbackTarget } = await client.fetch(`/v9/projects/${project.id}?rollbackInfo=true`);
|
248473
|
-
return lastRollbackTarget;
|
248474
|
-
};
|
248475
|
-
if (!contextName) {
|
248476
|
-
({ contextName } = await (0, get_scope_1.default)(client));
|
248477
|
-
}
|
248478
|
-
try {
|
248479
|
-
output.spinner(`${spinnerMessage}…`);
|
248480
|
-
// continuously loop until the rollback has explicitly succeeded, failed,
|
248481
|
-
// or timed out
|
248482
|
-
for (;;) {
|
248483
|
-
const { jobStatus, requestedAt, toDeploymentId } = (await check()) ?? {};
|
248484
|
-
if (!jobStatus ||
|
248485
|
-
(jobStatus !== 'in-progress' && jobStatus !== 'pending')) {
|
248486
|
-
output.stopSpinner();
|
248487
|
-
output.log(`${spinnerMessage}…`);
|
248488
|
-
}
|
248489
|
-
if (!jobStatus || requestedAt < recentThreshold) {
|
248490
|
-
output.log('No deployment rollback in progress');
|
248491
|
-
return 0;
|
248492
|
-
}
|
248493
|
-
if (jobStatus === 'skipped') {
|
248494
|
-
output.log('Rollback was skipped');
|
248495
|
-
return 0;
|
248496
|
-
}
|
248497
|
-
if (jobStatus === 'succeeded') {
|
248498
|
-
return await renderJobSucceeded({
|
248499
|
-
client,
|
248500
|
-
contextName,
|
248501
|
-
performingRollback: !!deployment,
|
248502
|
-
requestedAt,
|
248503
|
-
project,
|
248504
|
-
toDeploymentId,
|
248505
|
-
});
|
248506
|
-
}
|
248507
|
-
if (jobStatus === 'failed') {
|
248508
|
-
return await renderJobFailed({
|
248509
|
-
client,
|
248510
|
-
contextName,
|
248511
|
-
deployment,
|
248512
|
-
project,
|
248513
|
-
toDeploymentId,
|
248514
|
-
});
|
248515
|
-
}
|
248516
|
-
// lastly, if we're not pending/in-progress, then we don't know what
|
248517
|
-
// the status is, so bail
|
248518
|
-
if (jobStatus !== 'pending' && jobStatus !== 'in-progress') {
|
248519
|
-
output.log(`Unknown rollback status "${jobStatus}"`);
|
248520
|
-
return 1;
|
248521
|
-
}
|
248522
|
-
// check if we have been running for too long
|
248523
|
-
if (requestedAt < recentThreshold || Date.now() >= rollbackTimeout) {
|
248524
|
-
output.log(`The rollback exceeded its deadline - rerun ${chalk_1.default.bold(`vercel rollback ${toDeploymentId}`)} to try again`);
|
248525
|
-
return 1;
|
248526
|
-
}
|
248527
|
-
// if we've done our first poll and not rolling back, then print the
|
248528
|
-
// requested at date/time
|
248529
|
-
if (counter++ === 0 && !deployment) {
|
248530
|
-
spinnerMessage += ` requested at ${(0, format_date_1.default)(requestedAt)}`;
|
248531
|
-
}
|
248532
|
-
output.spinner(`${spinnerMessage}…`);
|
248533
|
-
await (0, sleep_1.default)(250);
|
248534
|
-
}
|
248535
|
-
}
|
248536
|
-
finally {
|
248537
|
-
output.stopSpinner();
|
248538
|
-
}
|
248539
|
-
}
|
248540
|
-
exports.default = rollbackStatus;
|
248541
|
-
async function renderJobFailed({ client, contextName, deployment, project, toDeploymentId, }) {
|
248542
|
-
const { output } = client;
|
248543
|
-
try {
|
248544
|
-
const name = (deployment || (await (0, get_deployment_1.default)(client, contextName, toDeploymentId)))?.url;
|
248545
|
-
output.error(`Failed to remap all aliases to the requested deployment ${name} (${toDeploymentId})`);
|
248546
|
-
}
|
248547
|
-
catch (e) {
|
248548
|
-
output.error(`Failed to remap all aliases to the requested deployment ${toDeploymentId}`);
|
248549
|
-
}
|
248550
|
-
// aliases are paginated, so continuously loop until all of them have been
|
248551
|
-
// fetched
|
248552
|
-
let nextTimestamp;
|
248553
|
-
for (;;) {
|
248554
|
-
let url = `/v9/projects/${project.id}/rollback/aliases?failedOnly=true&limit=20`;
|
248555
|
-
if (nextTimestamp) {
|
248556
|
-
url += `&until=${nextTimestamp}`;
|
248557
|
-
}
|
248558
|
-
const { aliases, pagination } = await client.fetch(url);
|
248559
|
-
for (const { alias, status } of aliases) {
|
248560
|
-
output.log(` ${(0, render_alias_status_1.default)(status).padEnd(11)} ${alias.alias} (${alias.deploymentId})`);
|
248561
|
-
}
|
248562
|
-
if (pagination?.next) {
|
248563
|
-
nextTimestamp = pagination.next;
|
248564
|
-
}
|
248565
|
-
else {
|
248566
|
-
break;
|
248567
|
-
}
|
248568
|
-
}
|
248569
|
-
return 1;
|
248570
|
-
}
|
248571
|
-
async function renderJobSucceeded({ client, contextName, performingRollback, project, requestedAt, toDeploymentId, }) {
|
248572
|
-
const { output } = client;
|
248573
|
-
// attempt to get the new deployment url
|
248574
|
-
let deploymentInfo = '';
|
248575
|
-
try {
|
248576
|
-
const deployment = await (0, get_deployment_1.default)(client, contextName, toDeploymentId);
|
248577
|
-
deploymentInfo = `${chalk_1.default.bold(deployment.url)} (${toDeploymentId})`;
|
248578
|
-
}
|
248579
|
-
catch (err) {
|
248580
|
-
output.debug(`Failed to get deployment url for ${toDeploymentId}: ${err?.toString() || err}`);
|
248581
|
-
deploymentInfo = chalk_1.default.bold(toDeploymentId);
|
248582
|
-
}
|
248583
|
-
const duration = performingRollback ? (0, elapsed_1.default)(Date.now() - requestedAt) : '';
|
248584
|
-
output.log(`Success! ${chalk_1.default.bold(project.name)} was rolled back to ${deploymentInfo} ${duration}`);
|
248585
|
-
return 0;
|
248586
|
-
}
|
248587
|
-
|
248588
|
-
|
248589
249056
|
/***/ }),
|
248590
249057
|
|
248591
249058
|
/***/ 89507:
|
@@ -249035,18 +249502,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
249035
249502
|
};
|
249036
249503
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
249037
249504
|
exports.validateRootDirectory = void 0;
|
249038
|
-
const
|
249039
|
-
const util_1 = __webpack_require__(31669);
|
249505
|
+
const fs_extra_1 = __webpack_require__(36365);
|
249040
249506
|
const chalk_1 = __importDefault(__webpack_require__(90877));
|
249041
249507
|
const os_1 = __webpack_require__(12087);
|
249042
249508
|
const confirm_1 = __importDefault(__webpack_require__(59320));
|
249043
249509
|
const humanize_path_1 = __importDefault(__webpack_require__(33234));
|
249044
|
-
const stat = (0, util_1.promisify)(fs_1.lstat);
|
249045
249510
|
/**
|
249046
249511
|
* A helper function to validate the `rootDirectory` input.
|
249047
249512
|
*/
|
249048
249513
|
async function validateRootDirectory(output, cwd, path, errorSuffix) {
|
249049
|
-
const pathStat = await
|
249514
|
+
const pathStat = await (0, fs_extra_1.lstat)(path).catch(() => null);
|
249050
249515
|
const suffix = errorSuffix ? ` ${errorSuffix}` : '';
|
249051
249516
|
if (!pathStat) {
|
249052
249517
|
output.error(`The provided path ${chalk_1.default.cyan(`“${(0, humanize_path_1.default)(path)}”`)} does not exist.${suffix}`);
|
@@ -249072,7 +249537,7 @@ async function validatePaths(client, paths) {
|
|
249072
249537
|
}
|
249073
249538
|
const path = paths[0];
|
249074
249539
|
// can only deploy a directory
|
249075
|
-
const pathStat = await
|
249540
|
+
const pathStat = await (0, fs_extra_1.lstat)(path).catch(() => null);
|
249076
249541
|
if (!pathStat) {
|
249077
249542
|
output.error(`Could not find ${chalk_1.default.cyan(`“${(0, humanize_path_1.default)(path)}”`)}`);
|
249078
249543
|
return { valid: false, exitCode: 1 };
|
@@ -249455,7 +249920,7 @@ module.exports = JSON.parse("[[[0,44],\"disallowed_STD3_valid\"],[[45,46],\"vali
|
|
249455
249920
|
/***/ ((module) => {
|
249456
249921
|
|
249457
249922
|
"use strict";
|
249458
|
-
module.exports = JSON.parse("{\"name\":\"@vercel/client\",\"version\":\"12.6.
|
249923
|
+
module.exports = JSON.parse("{\"name\":\"@vercel/client\",\"version\":\"12.6.1\",\"main\":\"dist/index.js\",\"typings\":\"dist/index.d.ts\",\"homepage\":\"https://vercel.com\",\"license\":\"Apache-2.0\",\"files\":[\"dist\"],\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/vercel/vercel.git\",\"directory\":\"packages/client\"},\"scripts\":{\"build\":\"tsc\",\"test-e2e\":\"pnpm test tests/create-deployment.test.ts tests/create-legacy-deployment.test.ts tests/paths.test.ts\",\"test\":\"jest --env node --verbose --runInBand --bail\",\"test-unit\":\"pnpm test tests/unit.*test.*\"},\"engines\":{\"node\":\">= 14\"},\"devDependencies\":{\"@types/async-retry\":\"1.4.5\",\"@types/fs-extra\":\"7.0.0\",\"@types/jest\":\"27.4.1\",\"@types/minimatch\":\"3.0.5\",\"@types/ms\":\"0.7.30\",\"@types/node\":\"14.18.33\",\"@types/node-fetch\":\"2.5.4\",\"@types/recursive-readdir\":\"2.2.0\",\"@types/tar-fs\":\"1.16.1\",\"typescript\":\"4.9.5\"},\"dependencies\":{\"@vercel/build-utils\":\"6.7.4\",\"@vercel/routing-utils\":\"2.2.1\",\"@zeit/fetch\":\"5.2.0\",\"async-retry\":\"1.2.3\",\"async-sema\":\"3.0.0\",\"fs-extra\":\"8.0.1\",\"ignore\":\"4.0.6\",\"minimatch\":\"5.0.1\",\"ms\":\"2.1.2\",\"node-fetch\":\"2.6.7\",\"querystring\":\"^0.2.0\",\"sleep-promise\":\"8.0.1\",\"tar-fs\":\"1.16.3\"}}");
|
249459
249924
|
|
249460
249925
|
/***/ }),
|
249461
249926
|
|