[vscode-spring-cli] prepare to fetch data from CLI. Polish commands: boot, project, project-catalog

This commit is contained in:
aboyko
2024-01-19 15:21:49 -05:00
parent 9ad22afdef
commit 9195ad08e4
9 changed files with 420 additions and 241 deletions

View File

@@ -5,15 +5,15 @@ import { CLI } from "./extension";
export async function handleProjectAdd() {
try {
const currentProjectNames = (await CLI.projectList()).map(p => p.name);
const currentProjectNamesPromise = CLI.projectList().then(projects => projects.map(p => p.name));
const name = await enterText({
title: "Name",
prompt: "Enter Name:",
validate: v => {
validate: async v => {
if (!/^\S+$/.test(v)) {
return "Invalid Project Catalog Name";
}
if (currentProjectNames.includes(v)) {
if ((await currentProjectNamesPromise).includes(v)) {
return "Name alreasy exists"
}
}
@@ -22,7 +22,7 @@ export async function handleProjectAdd() {
title: "URL",
prompt: "Enter URL:",
placeholder: "https://github.com/my-org/my-project",
validate: v => {
validate: async v => {
try {
Uri.parse(v, true);
} catch (error) {
@@ -39,6 +39,14 @@ export async function handleProjectAdd() {
prompt: "Enter Tags as strings separated by spaces and/or commas",
placeholder: "java, spring, eureka, config"
})).split(/(,)?\s+/);
if (name && url) {
return CLI.projectAdd({
name,
url,
description,
tags
});
}
} catch (error) {
// Ignore error - must have been cancelled
}
@@ -46,7 +54,8 @@ export async function handleProjectAdd() {
}
export async function handleProjectRemove() {
const name = (await window.showQuickPick(CLI.projectList().then(ps => ps.map(mapProjectToQuickPick)), {
const deferred = CLI.projectList().then(ps => ps.map(mapProjectToQuickPick));
const name = (await window.showQuickPick(deferred, {
canPickMany: false,
ignoreFocusOut: true,
}))?.label;