This is an automated email from the ASF dual-hosted git repository. marat pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
commit 3448b53ee83f3170d3a6a78011bd3b6dcc9f2c5b Author: Marat Gubaidullin <marat.gubaidul...@gmail.com> AuthorDate: Tue Dec 13 12:53:44 2022 -0500 fix #560 --- karavan-vscode/icons/dark/rocket.svg | 69 +++++++++++++++++++++++++++ karavan-vscode/icons/dark/wand.svg | 85 ++++++++++++++++++++++++++++++++++ karavan-vscode/icons/light/rocket.svg | 1 + karavan-vscode/icons/light/wand.svg | 1 + karavan-vscode/icons/run-jbang.png | Bin 0 -> 11967 bytes karavan-vscode/package.json | 48 ++++++++++++++----- karavan-vscode/src/designerView.ts | 22 +-------- karavan-vscode/src/exec.ts | 12 +++++ karavan-vscode/src/extension.ts | 25 ++++++---- karavan-vscode/src/jbang.ts | 9 ++-- karavan-vscode/src/maven.ts | 1 + 11 files changed, 226 insertions(+), 47 deletions(-) diff --git a/karavan-vscode/icons/dark/rocket.svg b/karavan-vscode/icons/dark/rocket.svg new file mode 100644 index 0000000..c2d6a73 --- /dev/null +++ b/karavan-vscode/icons/dark/rocket.svg @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + width="32px" + height="32px" + viewBox="0 0 32 32" + id="icon" + version="1.1" + sodipodi:docname="rocket-svgrepo-com.svg" + inkscape:version="1.1.2 (b8e25be8, 2022-02-05)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> + <sodipodi:namedview + id="namedview836" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + showgrid="false" + inkscape:zoom="22.46875" + inkscape:cx="0.89012517" + inkscape:cy="16.534075" + inkscape:window-width="2049" + inkscape:window-height="969" + inkscape:window-x="78" + inkscape:window-y="25" + inkscape:window-maximized="0" + inkscape:current-layer="icon" /> + <defs + id="defs826"> + <style + id="style824">.cls-1{fill:none;}</style> + </defs> + <title + id="title828">rocket</title> + <rect + x="6.34" + y="19" + width="11.31" + height="2" + transform="translate(-10.63 14.34) rotate(-45)" + id="rect830" + style="fill:#c5c5c5;fill-opacity:1" /> + <path + d="M17,30a1,1,0,0,1-.37-.07,1,1,0,0,1-.62-.79l-1-7,2-.28.75,5.27L21,24.52V17a1,1,0,0,1,.29-.71l4.07-4.07A8.94,8.94,0,0,0,28,5.86V4H26.14a8.94,8.94,0,0,0-6.36,2.64l-4.07,4.07A1,1,0,0,1,15,11H7.48L4.87,14.26l5.27.75-.28,2-7-1a1,1,0,0,1-.79-.62,1,1,0,0,1,.15-1l4-5A1,1,0,0,1,7,9h7.59l3.77-3.78A10.92,10.92,0,0,1,26.14,2H28a2,2,0,0,1,2,2V5.86a10.92,10.92,0,0,1-3.22,7.78L23,17.41V25a1,1,0,0,1-.38.78l-5,4A1,1,0,0,1,17,30Z" + id="path832" + style="fill:#c5c5c5;fill-opacity:1" /> + <rect + id="_Transparent_Rectangle_" + data-name="<Transparent Rectangle>" + class="cls-1" + width="32" + height="32" /> + <metadata + id="metadata918"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:title>rocket</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> +</svg> diff --git a/karavan-vscode/icons/dark/wand.svg b/karavan-vscode/icons/dark/wand.svg new file mode 100644 index 0000000..699be39 --- /dev/null +++ b/karavan-vscode/icons/dark/wand.svg @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + width="32px" + height="32px" + viewBox="0 0 32 32" + id="icon" + version="1.1" + sodipodi:docname="wand.svg" + inkscape:version="1.1.2 (b8e25be8, 2022-02-05)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"> + <sodipodi:namedview + id="namedview840" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + showgrid="false" + inkscape:zoom="22.46875" + inkscape:cx="9.8581363" + inkscape:cy="16.534075" + inkscape:window-width="2077" + inkscape:window-height="969" + inkscape:window-x="74" + inkscape:window-y="25" + inkscape:window-maximized="0" + inkscape:current-layer="icon" /> + <defs + id="defs826"> + <style + id="style824">.cls-1{fill:none;}</style> + </defs> + <title + id="title828">magic-wand</title> + <path + d="M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5ZM25.4131,28l-11-10.999L17,14.4141l11,11Z" + id="path830" + style="fill:#c5c5c5;fill-opacity:1" /> + <rect + x="2.5858" + y="14.5858" + width="2.8284" + height="2.8284" + transform="translate(-10.1421 7.5147) rotate(-45)" + id="rect832" + style="fill:#c5c5c5;fill-opacity:1" /> + <rect + x="14.5858" + y="2.5858" + width="2.8284" + height="2.8284" + transform="translate(1.8579 12.4853) rotate(-45)" + id="rect834" + style="fill:#c5c5c5;fill-opacity:1" /> + <rect + x="2.5858" + y="2.5858" + width="2.8284" + height="2.8284" + transform="translate(-1.6569 4) rotate(-45)" + id="rect836" + style="fill:#c5c5c5;fill-opacity:1" /> + <rect + id="_Transparent_Rectangle_" + data-name="<Transparent Rectangle>" + class="cls-1" + width="32" + height="32" /> + <metadata + id="metadata922"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:title>magic-wand</dc:title> + </cc:Work> + </rdf:RDF> + </metadata> +</svg> diff --git a/karavan-vscode/icons/light/rocket.svg b/karavan-vscode/icons/light/rocket.svg new file mode 100644 index 0000000..2d3b022 --- /dev/null +++ b/karavan-vscode/icons/light/rocket.svg @@ -0,0 +1 @@ +<svg width="32px" height="32px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>rocket</title><rect x="6.34" y="19" width="11.31" height="2" transform="translate(-10.63 14.34) rotate(-45)"/><path d="M17,30a1,1,0,0,1-.37-.07,1,1,0,0,1-.62-.79l-1-7,2-.28.75,5.27L21,24.52V17a1,1,0,0,1,.29-.71l4.07-4.07A8.94,8.94,0,0,0,28,5.86V4H26.14a8.94,8.94,0,0,0-6.36,2.64l-4.07,4.07A1,1,0,0,1,15,11H7.48L4.87,14.26l5.27.75-.28,2-7-1a1, [...] \ No newline at end of file diff --git a/karavan-vscode/icons/light/wand.svg b/karavan-vscode/icons/light/wand.svg new file mode 100644 index 0000000..2afc839 --- /dev/null +++ b/karavan-vscode/icons/light/wand.svg @@ -0,0 +1 @@ +<svg width="32px" height="32px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>magic-wand--filled</title><path d="M29.4141,24,12,6.5859a2.0476,2.0476,0,0,0-2.8281,0l-2.586,2.586a2.0021,2.0021,0,0,0,0,2.8281L23.999,29.4141a2.0024,2.0024,0,0,0,2.8281,0l2.587-2.5865a1.9993,1.9993,0,0,0,0-2.8281ZM8,10.5859,10.5859,8l5,5-2.5866,2.5869-5-5Z"/><rect x="2.5858" y="14.5858" width="2.8284" height="2.8284" transform="translate(- [...] \ No newline at end of file diff --git a/karavan-vscode/icons/run-jbang.png b/karavan-vscode/icons/run-jbang.png new file mode 100644 index 0000000..32cbce4 Binary files /dev/null and b/karavan-vscode/icons/run-jbang.png differ diff --git a/karavan-vscode/package.json b/karavan-vscode/package.json index 72e3d35..a97e674 100644 --- a/karavan-vscode/package.json +++ b/karavan-vscode/package.json @@ -45,7 +45,8 @@ "onCommand:karavan.deploy", "onCommand:karavan.open", "onCommand:karavan.open-file", - "onCommand:karavan.jbang-run-project", + "onCommand:karavan.run-project-jbang", + "onCommand:karavan.run-project-runtime", "onCommand:karavan.jbang-export", "onCommand:karavan.generate-rest", "onCommand:karavan.download-image", @@ -314,8 +315,8 @@ "command": "karavan.open", "title": "Karavan: Open", "icon": { - "light": "./icons/karavan.svg", - "dark": "./icons/karavan.svg" + "light": "./icons/light/wand.svg", + "dark": "./icons/dark/wand.svg" } }, { @@ -323,8 +324,16 @@ "title": "Karavan: Open editor" }, { - "command": "karavan.jbang-run-project", - "title": "Karavan: Run", + "command": "karavan.run-project-jbang", + "title": "Karavan: Jbang run", + "icon": { + "light": "./icons/light/rocket.svg", + "dark": "./icons/dark/rocket.svg" + } + }, + { + "command": "karavan.run-project-runtime", + "title": "Karavan: Runtime run", "icon": "$(run)" }, { @@ -391,7 +400,12 @@ "group": "karavan@4" }, { - "command": "karavan.jbang-run-project", + "command": "karavan.run-project-jbang", + "when": "explorerResourceIsFolder || explorerResourceIsRoot", + "group": "karavan@5" + }, + { + "command": "karavan.run-project-runtime", "when": "explorerResourceIsFolder || explorerResourceIsRoot", "group": "karavan@6" }, @@ -418,32 +432,42 @@ "group": "navigation@1" }, { - "command": "karavan.jbang-run-project", + "command": "karavan.run-project-jbang", "when": "resourceFilename =~ /.camel.yaml$/ || karavan:loaded", - "group": "navigation@2" + "group": "navigation@4" + }, + { + "command": "karavan.run-project-runtime", + "when": "resourceFilename =~ /.camel.yaml$/ || karavan:loaded", + "group": "navigation@5" }, { "command": "karavan.download-image", "when": "karavan:loaded", - "group": "navigation@3" + "group": "navigation@10" } ], "view/title": [ { - "command": "karavan.jbang-run-project", + "command": "karavan.run-project-jbang", "when": "view == integrations", "group": "navigation@1" }, { - "command": "karavan.deploy", + "command": "karavan.run-project-runtime", "when": "view == integrations", "group": "navigation@2" }, { - "command": "karavan.jbang-export", + "command": "karavan.deploy", "when": "view == integrations", "group": "navigation@3" }, + { + "command": "karavan.jbang-export", + "when": "view == integrations", + "group": "navigation@4" + }, { "command": "integrations.refresh", "when": "view == integrations", diff --git a/karavan-vscode/src/designerView.ts b/karavan-vscode/src/designerView.ts index 8aaf4fe..541ce27 100644 --- a/karavan-vscode/src/designerView.ts +++ b/karavan-vscode/src/designerView.ts @@ -24,14 +24,12 @@ import { getWebviewContent } from "./webviewContent"; const KARAVAN_LOADED = "karavan:loaded"; const KARAVAN_PANELS: Map<string, WebviewPanel> = new Map<string, WebviewPanel>(); -const extension = '.properties'; export class DesignerView { constructor(private context: ExtensionContext, private rootPath?: string) { } - karavanOpen(fullPath: string, tab?: string) { utils.readFile(path.resolve(fullPath)).then(readData => { const yaml = Buffer.from(readData).toString('utf8'); @@ -47,25 +45,6 @@ export class DesignerView { }) } - jbangRun(fullPath: string) { - if (fullPath.startsWith('webview-panel/webview')) { - const filename = this.getFilenameFromWebView(); - jbang.camelJbangRun(filename); - } else { - utils.readFile(path.resolve(fullPath)).then(readData => { - const yaml = Buffer.from(readData).toString('utf8'); - const relativePath = utils.getRalativePath(fullPath); - const filename = path.basename(fullPath); - const integration = utils.parceYaml(filename, yaml); - if (integration[0] && utils.getRoot() !== undefined) { - jbang.camelJbangRun(relativePath); - } else { - window.showErrorMessage("File is not Camel Integration!") - } - }); - } - } - getFilenameFromWebView() { const filename = Array.from(KARAVAN_PANELS.entries()).filter(({ 1: v }) => v.active).map(([k]) => k)[0]; if (filename && utils.getRoot() !== undefined) { @@ -145,6 +124,7 @@ export class DesignerView { // Handle close event panel.onDidDispose(() => { KARAVAN_PANELS.delete(relativePath); + commands.executeCommand("setContext", KARAVAN_LOADED, false); }, null, this.context.subscriptions); // Handle reopen diff --git a/karavan-vscode/src/exec.ts b/karavan-vscode/src/exec.ts index afc7b29..ef1fce4 100644 --- a/karavan-vscode/src/exec.ts +++ b/karavan-vscode/src/exec.ts @@ -14,6 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import * as utils from "./utils"; +import * as jbang from "./jbang"; import * as shell from 'shelljs'; import { window, Terminal, ThemeIcon } from "vscode"; @@ -40,4 +42,14 @@ export function execTerminalCommand(terminalId: string, command: string, env?: { TERMINALS.set(terminalId, terminal); terminal.show(); terminal.sendText(command); +} + +export async function runWithRuntime(fullPath: string, run?: boolean) { + let command = jbang.createExportCommand(fullPath); + if (run) { + const runtime = await utils.getRuntime(); + const mvn = runtime === 'quarkus' ? "quarkus:dev" : "spring-boot:run"; + command = command.concat(" && mvn clean ").concat(mvn).concat(" -f ").concat(fullPath); + } + execTerminalCommand("runtime-run", command); } \ No newline at end of file diff --git a/karavan-vscode/src/extension.ts b/karavan-vscode/src/extension.ts index 63a579e..4184276 100644 --- a/karavan-vscode/src/extension.ts +++ b/karavan-vscode/src/extension.ts @@ -22,6 +22,7 @@ import { selectFileName, inputFileName, OpenApiView, OpenApiItem } from "./opena import * as path from "path"; import * as jbang from "./jbang"; import * as utils from "./utils"; +import * as exec from "./exec"; const KARAVAN_LOADED = "karavan:loaded"; @@ -99,7 +100,7 @@ export function activate(context: ExtensionContext) { // Export project const exportCommand = commands.registerCommand("karavan.jbang-export", (...args: any[]) => { - exportProject(rootPath); + exportAndRunProject(rootPath); }); context.subscriptions.push(exportCommand); @@ -109,18 +110,24 @@ export function activate(context: ExtensionContext) { }); context.subscriptions.push(deployCommand); - // Run project - const runProjectCommand = commands.registerCommand("karavan.jbang-run-project", (...args: any[]) => { + // Run project with jbang + const runJbang = commands.registerCommand("karavan.run-project-jbang", (...args: any[]) => { + jbang.camelJbangRun(); + }); + context.subscriptions.push(runJbang); + + // Run project with runtime + const runRuntime = commands.registerCommand("karavan.run-project-runtime", (...args: any[]) => { utils.getProperties(rootPath).then(properties => { if (properties.length > 0){ - exportProject(rootPath, true); + exportAndRunProject(rootPath, true); } else { window.showErrorMessage("No runtime configured! Create application!") } }) }); - context.subscriptions.push(runProjectCommand); + context.subscriptions.push(runRuntime); // Generate REST API from OpenAPI specification command const generateOptions = ["Create new CRD", "Create new YAML", "Add to existing file"]; @@ -149,14 +156,14 @@ export function activate(context: ExtensionContext) { } /** - * export into folder + * export into folder and optionally run */ -export async function exportProject(rootPath?: string, run?: boolean) { +export async function exportAndRunProject(rootPath?: string, run?: boolean) { utils.getExportFolder() .then(folder => { if (folder){ const fullPath = rootPath + path.sep + folder; - jbang.camelJbangExport(fullPath, run); + exec.runWithRuntime(fullPath, run); } else { window.showInputBox({ title: "Export project", @@ -173,7 +180,7 @@ export async function exportProject(rootPath?: string, run?: boolean) { }).then(folder => { if (folder && rootPath) { const fullPath = rootPath + path.sep + folder; - jbang.camelJbangExport(fullPath, run); + exec.runWithRuntime(fullPath, run); } }); } diff --git a/karavan-vscode/src/jbang.ts b/karavan-vscode/src/jbang.ts index 12db2ef..49d48eb 100644 --- a/karavan-vscode/src/jbang.ts +++ b/karavan-vscode/src/jbang.ts @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { workspace, window, ThemeIcon } from "vscode"; +import { workspace, window } from "vscode"; import * as path from "path"; import * as shell from 'shelljs'; import * as utils from "./utils"; @@ -49,16 +49,15 @@ function prepareCommand(command: string): string { return "jbang -Dcamel.jbang.version=" + version + " camel@apache/camel " + command; } -export function camelJbangRun(filename?: string) { +export function camelJbangRun() { const maxMessages: number = workspace.getConfiguration().get("camel.maxMessages") || -1; const kameletsPath: string | undefined = workspace.getConfiguration().get("Karavan.kameletsPath"); const dev: boolean = workspace.getConfiguration().get("camel.dev") || false; - const cmd = (filename ? "run " + filename : "run * ") + const cmd = "run * " + (maxMessages > -1 ? " --max-messages=" + maxMessages : "") + (kameletsPath && kameletsPath.trim().length > 0 ? " --local-kamelet-dir=" + kameletsPath : ""); const command = prepareCommand(cmd) + (dev === true ? " --dev" : ""); - const terminalId = "run_" + filename; - exec.execTerminalCommand(terminalId, command); + exec.execTerminalCommand("jbang-run", command); } export async function camelJbangExport(fullPath: string, run?: boolean) { diff --git a/karavan-vscode/src/maven.ts b/karavan-vscode/src/maven.ts index ebb801e..f0738e2 100644 --- a/karavan-vscode/src/maven.ts +++ b/karavan-vscode/src/maven.ts @@ -27,3 +27,4 @@ export function createPackageAndDeployCommand(directory: string) { + " -Dquarkus.container-image.build=false -Dquarkus.container-image.push=false" } +