[cli] Refactor vc project (#8091)

Since the `vc project` command is about to be expanded with 2 new subcommands, I think it makes sense to do a little bit of refactoring. The current `vc project` command is all in one file, with the logic for subcommands nested within if statements. I think the structure of `vc project` should look more like `vc env`, which is consistent with how commands with subcommands look throughout the rest of the codebase.

This PR moves the logic for the `project` subcommands into their own files.

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [x] The code changed/added as part of this PR has been covered with tests
- [x] 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:
Matthew Stanciu
2022-07-07 18:34:13 -07:00
committed by GitHub
parent 1a6f3c0270
commit 037633b3f1
12 changed files with 514 additions and 344 deletions

View File

@@ -0,0 +1,19 @@
export function getDataFromIntro(output: string): {
project: string | undefined;
org: string | undefined;
} {
const project = output.match(/(?<=Deployments for )(.*)(?= under)/);
const org = output.match(/(?<=under )(.*)(?= \[)/);
return {
project: project?.[0],
org: org?.[0],
};
}
export function parseTable(output: string): string[] {
return output
.trim()
.replace(/ {1} +/g, ',')
.split(',');
}