Compare commits

...

2 Commits

Author SHA1 Message Date
Austin Merrick
2cb82abc5f Add changeset 2024-05-23 10:14:18 -07:00
Austin Merrick
8316491018 Refactor vc git to new utils 2024-05-23 10:00:00 -07:00
3 changed files with 22 additions and 18 deletions

View File

@@ -0,0 +1,2 @@
---
---

View File

@@ -32,7 +32,10 @@ export const gitCommand: Command = {
examples: [],
},
],
options: [],
options: [
{ name: 'yes', type: Boolean, shorthand: 'y', deprecated: false },
{ name: 'confirm', type: Boolean, shorthand: 'c', deprecated: true },
],
examples: [
{
name: 'Connect your Vercel Project to your Git repository defined in your local .git config',

View File

@@ -1,12 +1,13 @@
import Client from '../../util/client';
import { ensureLink } from '../../util/link/ensure-link';
import getArgs from '../../util/get-args';
import { parseArguments } from '../../util/get-args';
import getInvalidSubcommand from '../../util/get-invalid-subcommand';
import handleError from '../../util/handle-error';
import connect from './connect';
import disconnect from './disconnect';
import { help } from '../help';
import { gitCommand } from './command';
import { getFlagsSpecification } from '../../util/get-flags-specification';
const COMMAND_CONFIG = {
connect: ['connect'],
@@ -14,33 +15,31 @@ const COMMAND_CONFIG = {
};
export default async function main(client: Client) {
let argv: any;
const { cwd, output } = client;
let subcommand: string | string[];
const flagsSpecification = getFlagsSpecification(gitCommand.options);
let parsedArgs;
try {
argv = getArgs(client.argv.slice(2), {
'--yes': Boolean,
'-y': '--yes',
// deprecated
'-c': '--yes',
'--confirm': '--yes',
});
parsedArgs = parseArguments(client.argv.slice(2), flagsSpecification);
if ('--confirm' in parsedArgs.flags) {
output.warn('`--confirm` is deprecated, please use `--yes` instead');
parsedArgs.flags['--yes'] = parsedArgs.flags['--confirm'];
}
} catch (error) {
handleError(error);
return 1;
}
if (argv['--help']) {
if (parsedArgs.flags['--help']) {
client.output.print(help(gitCommand, { columns: client.stderr.columns }));
return 2;
}
argv._ = argv._.slice(1);
subcommand = argv._[0];
const args = argv._.slice(1);
const autoConfirm = Boolean(argv['--yes']);
const { cwd, output } = client;
parsedArgs.args = parsedArgs.args.slice(1);
subcommand = parsedArgs.args[0];
const args = parsedArgs.args.slice(1);
const autoConfirm = Boolean(parsedArgs.flags['--yes']);
const linkedProject = await ensureLink('git', client, cwd, { autoConfirm });
if (typeof linkedProject === 'number') {
@@ -52,7 +51,7 @@ export default async function main(client: Client) {
switch (subcommand) {
case 'connect':
return await connect(client, argv, args, project, org);
return await connect(client, parsedArgs.flags, args, project, org);
case 'disconnect':
return await disconnect(client, args, project, org);
default: