diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index eeee2be1c..6e79bca60 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -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'], diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index d458974dd..3492b95ce 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -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': diff --git a/packages/cli/test/helpers/parse-table.ts b/packages/cli/test/helpers/parse-table.ts index 008b15995..723f23ad7 100644 --- a/packages/cli/test/helpers/parse-table.ts +++ b/packages/cli/test/helpers/parse-table.ts @@ -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, ',') diff --git a/packages/cli/test/integration.js b/packages/cli/test/integration.js index 3b6e4dd9d..60e764ddd 100644 --- a/packages/cli/test/integration.js +++ b/packages/cli/test/integration.js @@ -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, diff --git a/packages/cli/test/unit/commands/list.test.ts b/packages/cli/test/unit/commands/list.test.ts index 5ea35e748..6a186535c 100644 --- a/packages/cli/test/unit/commands/list.test.ts +++ b/packages/cli/test/unit/commands/list.test.ts @@ -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); diff --git a/packages/cli/test/unit/commands/project.test.ts b/packages/cli/test/unit/commands/project.test.ts index 8c711cc6e..682e2a5cc 100644 --- a/packages/cli/test/unit/commands/project.test.ts +++ b/packages/cli/test/unit/commands/project.test.ts @@ -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);