in karavan-vscode/src/extension.ts [31:174]
export function activate(context: ExtensionContext) {
const rootPath = (workspace.workspaceFolders && (workspace.workspaceFolders.length > 0))
? workspace.workspaceFolders[0].uri.fsPath : undefined;
// Register views
const designer = new DesignerView(context, rootPath);
const integrationView = new IntegrationView(designer, rootPath);
window.registerTreeDataProvider('integrations', integrationView);
commands.registerCommand('integrations.refresh', () => integrationView.refresh());
const openapiView = new OpenApiView(designer, rootPath);
window.registerTreeDataProvider('openapi', openapiView);
commands.registerCommand('openapi.refresh', () => openapiView.refresh());
const helpView = new HelpView(context);
window.registerTreeDataProvider('help', helpView);
commands.registerCommand('karavan.openKnowledgebase', () => helpView.openKaravanWebView("knowledgebase"));
const topologyView = new TopologyView(context);
const topologyCommand = commands.registerCommand("karavan.topology", (...args: any[]) => {
topologyView.openKaravanWebView(args[0]?.fsPath);
});
context.subscriptions.push(topologyCommand);
// Create new Integration command
const createYaml = commands.registerCommand("karavan.create-yaml", (...args: any[]) => {
designer.createIntegration("plain", args[0]?.fsPath)
});
context.subscriptions.push(createYaml);
// Create new Kamelet command
const createKamelet = commands.registerCommand("karavan.create-kamelet", (...args: any[]) => {
designer.createIntegration("kamelet", args[0]?.fsPath)
});
context.subscriptions.push(createKamelet);
// Open integration in designer command
const open = commands.registerCommand("karavan.open", (...args: any[]) => {
designer.karavanOpen(args[0].fsPath, args[0].tab);
});
context.subscriptions.push(open);
// Open integration in editor command
const openFile = commands.registerCommand("karavan.open-file", (...args: any[]) => {
let uri = Uri.file(args[0].fsPath);
window.showTextDocument(uri, { preserveFocus: false, preview: false });
});
context.subscriptions.push(openFile);
// Create application
const applicationCommand = commands.registerCommand("karavan.create-application", async (...args: any[]) => {
if (rootPath) {
const defaultRuntime: string = workspace.getConfiguration().get("camel.runtimes") || '';
const deployTarget: string = workspace.getConfiguration().get("camel.deployTarget") || 'openshift';
const runtimeOptions: QuickPickItem[] = [
{ label: "camel-main", picked: "camel-main" === defaultRuntime },
{ 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 hasAP = await utils.hasApplicationProperties(rootPath);
let createApp = !hasAP;
if (hasAP) {
const replaceOptions: QuickPickItem[] = [
{ label: "Replace", picked: false },
{ label: "Cancel", picked: true }
];
const replace = await window.showQuickPick(replaceOptions, {title: "Application already exists!", canPickMany: false });
createApp = replace?.label === replaceOptions.at(0)?.label;
}
if (createApp){
window.showQuickPick(runtimeOptions, { title: "Select Runtime", canPickMany: false }).then((runtime) => {
window.showQuickPick(deployOptions, { title: "Select Deploy Target", canPickMany: false }).then((target) => {
if (runtime && target) utils.createApplication(runtime.label, target.label)
})
})
}
}
});
context.subscriptions.push(applicationCommand);
// Export project
const exportCommand = commands.registerCommand("karavan.jbang-export", (...args: any[]) => {
exportAndRunProject(rootPath);
});
context.subscriptions.push(exportCommand);
// Deploy project
const deployCommand = commands.registerCommand("karavan.deploy", (...args: any[]) => {
exec.camelDeploy(rootPath + path.sep + ".export");
});
context.subscriptions.push(deployCommand);
// 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){
exportAndRunProject(rootPath, true);
} else {
window.showErrorMessage("No runtime configured! Create application!")
}
})
});
context.subscriptions.push(runRuntime);
// Generate REST API from OpenAPI specification command
const generateOptions = ["Create new Integration", "Add to existing Integration"];
const generateRest = commands.registerCommand('karavan.generate-rest', async (...args: any[]) => {
const openApi: OpenApiItem = args[0];
window.showQuickPick(generateOptions, { title: "Select REST Generator options", canPickMany: false }).then((value) => {
switch (value) {
case generateOptions[0]: inputFileName(rootPath, openApi); break;
case generateOptions[1]: selectFileName(rootPath, openApi); break;
}
})
});
context.subscriptions.push(generateRest);
// Download Image command
const downloadImageCommand = commands.registerCommand("karavan.download-image", (...args: any[]) => {
designer.downloadImage(args[0].fsPath);
});
context.subscriptions.push(downloadImageCommand);
// Create issue command
commands.registerCommand('karavan.reportIssue', () => {
env.openExternal(Uri.parse('https://github.com/apache/camel-karavan/issues/new?title=[VS+Code]New+report&template=issue_template.md'));
});
}