mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 12:57:47 +00:00
[cli] Explicitly use vc project vs. vc projects (#8113)
This is a follow-up to #8091 which: - Makes `vc project` the default command, with `vc projects` aliased to `vc project` (previously it was not clear in the code which one was the "real" command) - Makes some helper names for `ls` more specific ### 📋 Checklist <!-- Please keep your PR as a Draft until the checklist is complete --> #### Tests - [ ] The code changed/added as part of this PR has been covered with tests - [ ] All tests pass locally with `yarn test-unit` #### Code Review - [ ] This PR has a concise title and thorough description useful to a reviewer - [ ] Issue from task tracker has a link to this PR
This commit is contained in:
@@ -25,8 +25,8 @@ export default new Map([
|
||||
['logout', 'logout'],
|
||||
['logs', 'logs'],
|
||||
['ls', 'list'],
|
||||
['project', 'projects'],
|
||||
['projects', 'projects'],
|
||||
['project', 'project'],
|
||||
['projects', 'project'],
|
||||
['pull', 'pull'],
|
||||
['remove', 'remove'],
|
||||
['rm', 'remove'],
|
||||
|
||||
@@ -653,7 +653,7 @@ const main = async () => {
|
||||
case 'logout':
|
||||
func = require('./commands/logout').default;
|
||||
break;
|
||||
case 'projects':
|
||||
case 'project':
|
||||
func = require('./commands/project').default;
|
||||
break;
|
||||
case 'pull':
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export function getDataFromIntro(output: string): {
|
||||
export function pluckIdentifiersFromDeploymentList(output: string): {
|
||||
project: string | undefined;
|
||||
org: string | undefined;
|
||||
} {
|
||||
@@ -11,7 +11,7 @@ export function getDataFromIntro(output: string): {
|
||||
};
|
||||
}
|
||||
|
||||
export function parseTable(output: string): string[] {
|
||||
export function parseSpacedTableRow(output: string): string[] {
|
||||
return output
|
||||
.trim()
|
||||
.replace(/ {1} +/g, ',')
|
||||
|
||||
9
packages/cli/test/integration.js
vendored
9
packages/cli/test/integration.js
vendored
@@ -1323,12 +1323,7 @@ test('[vc projects] should create a project successfully', async t => {
|
||||
Math.random().toString(36).split('.')[1]
|
||||
}`;
|
||||
|
||||
const vc = execa(binaryPath, [
|
||||
'projects',
|
||||
'add',
|
||||
projectName,
|
||||
...defaultArgs,
|
||||
]);
|
||||
const vc = execa(binaryPath, ['project', 'add', projectName, ...defaultArgs]);
|
||||
|
||||
await waitForPrompt(vc, chunk =>
|
||||
chunk.includes(`Success! Project ${projectName} added`)
|
||||
@@ -1339,7 +1334,7 @@ test('[vc projects] should create a project successfully', async t => {
|
||||
|
||||
// creating the same project again should succeed
|
||||
const vc2 = execa(binaryPath, [
|
||||
'projects',
|
||||
'project',
|
||||
'add',
|
||||
projectName,
|
||||
...defaultArgs,
|
||||
|
||||
@@ -6,7 +6,10 @@ import { useTeams } from '../../mocks/team';
|
||||
import { defaultProject, useProject } from '../../mocks/project';
|
||||
import { useDeployment } from '../../mocks/deployment';
|
||||
import { readOutputStream } from '../../helpers/read-output-stream';
|
||||
import { parseTable, getDataFromIntro } from '../../helpers/parse-table';
|
||||
import {
|
||||
parseSpacedTableRow,
|
||||
pluckIdentifiersFromDeploymentList,
|
||||
} from '../../helpers/parse-table';
|
||||
|
||||
const fixture = (name: string) =>
|
||||
join(__dirname, '../../fixtures/unit/commands/list', name);
|
||||
@@ -34,9 +37,9 @@ describe('list', () => {
|
||||
|
||||
const output = await readOutputStream(client);
|
||||
|
||||
const { org } = getDataFromIntro(output.split('\n')[0]);
|
||||
const header: string[] = parseTable(output.split('\n')[2]);
|
||||
const data: string[] = parseTable(output.split('\n')[3]);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[2]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
data.splice(2, 1);
|
||||
|
||||
expect(org).toEqual(team[0].slug);
|
||||
@@ -76,9 +79,9 @@ describe('list', () => {
|
||||
|
||||
const output = await readOutputStream(client);
|
||||
|
||||
const { org } = getDataFromIntro(output.split('\n')[0]);
|
||||
const header: string[] = parseTable(output.split('\n')[2]);
|
||||
const data: string[] = parseTable(output.split('\n')[3]);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[2]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
data.splice(2, 1);
|
||||
|
||||
expect(org).toEqual(teamSlug);
|
||||
|
||||
@@ -5,9 +5,12 @@ import { defaultProject, useProject } from '../../mocks/project';
|
||||
import { client } from '../../mocks/client';
|
||||
import { Project } from '../../../src/types';
|
||||
import { readOutputStream } from '../../helpers/read-output-stream';
|
||||
import { getDataFromIntro, parseTable } from '../../helpers/parse-table';
|
||||
import {
|
||||
pluckIdentifiersFromDeploymentList,
|
||||
parseSpacedTableRow,
|
||||
} from '../../helpers/parse-table';
|
||||
|
||||
describe('projects', () => {
|
||||
describe('project', () => {
|
||||
describe('list', () => {
|
||||
it('should list deployments under a user', async () => {
|
||||
const user = useUser();
|
||||
@@ -19,9 +22,9 @@ describe('projects', () => {
|
||||
await projects(client);
|
||||
|
||||
const output = await readOutputStream(client, 2);
|
||||
const { org } = getDataFromIntro(output.split('\n')[0]);
|
||||
const header: string[] = parseTable(output.split('\n')[2]);
|
||||
const data: string[] = parseTable(output.split('\n')[3]);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[2]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
data.pop();
|
||||
|
||||
expect(org).toEqual(user.username);
|
||||
@@ -40,9 +43,9 @@ describe('projects', () => {
|
||||
await projects(client);
|
||||
|
||||
const output = await readOutputStream(client, 2);
|
||||
const { org } = getDataFromIntro(output.split('\n')[0]);
|
||||
const header: string[] = parseTable(output.split('\n')[2]);
|
||||
const data: string[] = parseTable(output.split('\n')[3]);
|
||||
const { org } = pluckIdentifiersFromDeploymentList(output.split('\n')[0]);
|
||||
const header: string[] = parseSpacedTableRow(output.split('\n')[2]);
|
||||
const data: string[] = parseSpacedTableRow(output.split('\n')[3]);
|
||||
data.pop();
|
||||
|
||||
expect(org).toEqual(team[0].slug);
|
||||
|
||||
Reference in New Issue
Block a user