You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2022/11/19 02:03:33 UTC
[camel-karavan] 01/12: Export folder from properties or input field
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 b35c2f2d8af3cf2a0abb8fa66584e71ac94b1d7f
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Fri Nov 18 14:47:19 2022 -0500
Export folder from properties or input field
---
karavan-vscode/src/designerView.ts | 2 +-
karavan-vscode/src/extension.ts | 80 ++++++++++++++++++++++++++------------
karavan-vscode/src/jbang.ts | 10 +++--
3 files changed, 63 insertions(+), 29 deletions(-)
diff --git a/karavan-vscode/src/designerView.ts b/karavan-vscode/src/designerView.ts
index c16b373..1be8c9d 100644
--- a/karavan-vscode/src/designerView.ts
+++ b/karavan-vscode/src/designerView.ts
@@ -91,7 +91,7 @@ export class DesignerView {
const i = Integration.createNew(name);
i.type = type;
const yaml = CamelDefinitionYaml.integrationToYaml(i);
- const filename = name.toLocaleLowerCase().endsWith('.yaml') ? name : name + '.yaml';
+ const filename = name.toLocaleLowerCase().endsWith('.camel.yaml') ? name : name.split('.')[0] + '.camel.yaml';
const relativePath = (this.rootPath ? rootPath?.replace(this.rootPath, "") : rootPath) + path.sep + filename;
const fullPath = (rootPath ? rootPath : this.rootPath) + path.sep + filename;
utils.save(relativePath, yaml);
diff --git a/karavan-vscode/src/extension.ts b/karavan-vscode/src/extension.ts
index c7b5bfb..b816b0b 100644
--- a/karavan-vscode/src/extension.ts
+++ b/karavan-vscode/src/extension.ts
@@ -54,18 +54,18 @@ export function activate(context: ExtensionContext) {
</body>
</html>`
- .replace(
- "styleUri",
- Uri.joinPath(context.extensionUri, "/dist/main.css")
- .with({ scheme: "vscode-resource" })
- .toString()
- )
- .replace(
- "scriptUri",
- Uri.joinPath(context.extensionUri, "/dist/webview.js")
- .with({ scheme: "vscode-resource" })
- .toString()
- );
+ .replace(
+ "styleUri",
+ Uri.joinPath(context.extensionUri, "/dist/main.css")
+ .with({ scheme: "vscode-resource" })
+ .toString()
+ )
+ .replace(
+ "scriptUri",
+ Uri.joinPath(context.extensionUri, "/dist/webview.js")
+ .with({ scheme: "vscode-resource" })
+ .toString()
+ );
const rootPath = (workspace.workspaceFolders && (workspace.workspaceFolders.length > 0))
? workspace.workspaceFolders[0].uri.fsPath : undefined;
@@ -103,36 +103,36 @@ export function activate(context: ExtensionContext) {
// Create application
const applicationCommand = commands.registerCommand("karavan.create-application", (...args: any[]) => {
- if (rootPath){
+ if (rootPath) {
const defaultRuntime: string = workspace.getConfiguration().get("camel.runtimes") || '';
const deployTarget: string = workspace.getConfiguration().get("camel.deployTarget") || 'openshift';
- const runtimeOptions: QuickPickItem [] = [
- {label: "quarkus", picked: "quarkus" === defaultRuntime},
- {label: "spring-boot", picked: "spring-boot" === defaultRuntime}
+ const runtimeOptions: QuickPickItem[] = [
+ { label: "quarkus", picked: "quarkus" === defaultRuntime },
+ { label: "spring-boot", picked: "spring-boot" === defaultRuntime }
];
- const deployOptions: QuickPickItem [] = [
- {label: "openshift", picked: "openshift" === deployTarget},
- {label: "kubernetes", picked: "kubernetes" === deployTarget},
- {label: "none", picked: "none" === deployTarget}
+ const deployOptions: QuickPickItem[] = [
+ { label: "openshift", picked: "openshift" === deployTarget },
+ { label: "kubernetes", picked: "kubernetes" === deployTarget },
+ { label: "none", picked: "none" === deployTarget }
];
utils.hasApplicationProperties(rootPath).then(hasAP => {
- if (hasAP){
+ if (hasAP) {
window.showInformationMessage("Folder already contains application.properties");
} else {
window.showQuickPick(runtimeOptions, { title: "Select Runtime", canPickMany: false }).then((runtime) => {
window.showQuickPick(deployOptions, { title: "Select Deploy Target", canPickMany: false }).then((target) => {
- if (runtime && target) inputExportGav(runtime.label, target.label)
+ if (runtime && target) inputExportGav(runtime.label, target.label)
})
})
}
})
- }
+ }
});
context.subscriptions.push(applicationCommand);
// Export project
const exportCommand = commands.registerCommand("karavan.jbang-export", (...args: any[]) => {
- jbang.camelJbangExport();
+ exportProject(rootPath);
});
context.subscriptions.push(exportCommand);
@@ -178,6 +178,38 @@ export function activate(context: ExtensionContext) {
});
}
+/**
+ * export into folder
+ */
+export async function exportProject(rootPath?: string) {
+ utils.getExportFolder()
+ .then(folder => {
+ if (folder){
+ jbang.camelJbangExport();
+ } else {
+ window.showInputBox({
+ title: "Export project",
+ ignoreFocusOut: true,
+ prompt: "Export folder name",
+ value: ".export",
+ validateInput: (text: string): string | undefined => {
+ if (!text || text.length === 0) {
+ return 'Name should not be empty';
+ } else {
+ return undefined;
+ }
+ }
+ }).then(folder => {
+ if (folder && rootPath) {
+ const fullPath = rootPath + path.sep + folder;
+ jbang.camelJbangExport(fullPath);
+ }
+ });
+ }
+ }).catch(error => {
+ console.log(error);
+ })
+}
/**
* export with gav
diff --git a/karavan-vscode/src/jbang.ts b/karavan-vscode/src/jbang.ts
index e2baa92..456d46b 100644
--- a/karavan-vscode/src/jbang.ts
+++ b/karavan-vscode/src/jbang.ts
@@ -94,8 +94,8 @@ export function camelJbangRun(filename?: string) {
terminal.sendText(command);
}
-export function camelJbangExport() {
- const command = createExportCommand();
+export function camelJbangExport(fullPath?: string) {
+ const command = createExportCommand(fullPath);
const terminalId = "export";
const existTerminal = TERMINALS.get(terminalId);
if (existTerminal) existTerminal.dispose();
@@ -105,9 +105,11 @@ export function camelJbangExport() {
terminal.sendText(command);
}
-export function createExportCommand() {
+export function createExportCommand(fullPath?: string) {
const kameletsPath: string | undefined = workspace.getConfiguration().get("Karavan.kameletsPath");
- const cmd = "export --fresh " + (kameletsPath && kameletsPath.trim().length > 0 ? " --local-kamelet-dir=" + kameletsPath : "");
+ const cmd = "export --fresh "
+ + (fullPath ? " --directory=" + fullPath : '')
+ + (kameletsPath && kameletsPath.trim().length > 0 ? " --local-kamelet-dir=" + kameletsPath : "");
return prepareCommand(cmd);
}