Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwal-pai77 committed Mar 5, 2024
1 parent aafb14c commit 8c61bd9
Show file tree
Hide file tree
Showing 11 changed files with 1,381 additions and 6 deletions.
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@
"title": "Data Export",
"category": "Couchbase"
},
{
"command": "vscode-couchbase.tools.mdbExport",
"title": "MongoDb Migrate",
"category": "Couchbase"
},
{
"command": "vscode-couchbase.tools.dataImport",
"title": "Data Import",
Expand Down Expand Up @@ -809,6 +814,10 @@
"command": "vscode-couchbase.tools.dataExport",
"when": "false"
},
{
"command": "vscode-couchbase.tools.mdbExport",
"when": "false"
},
{
"command": "vscode-couchbase.tools.dataImport",
"when": "false"
Expand Down Expand Up @@ -993,6 +1002,10 @@
"command": "vscode-couchbase.tools.dataExport",
"group": "navigation"
},
{
"command": "vscode-couchbase.tools.mdbExport",
"group": "navigation"
},
{
"command": "vscode-couchbase.tools.dataImport",
"group": "navigation"
Expand Down Expand Up @@ -1051,4 +1064,4 @@
}
]
}
}
}
1 change: 1 addition & 0 deletions src/commands/extensionCommands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export namespace Commands {
export const refreshClusterOverview: string = "vscode-couchbase.refreshClusterOverview";
export const checkAndCreatePrimaryIndex: string = "vscode-couchbase.checkAndCreatePrimaryIndex";
export const dataExport: string = "vscode-couchbase.tools.dataExport";
export const mdbExport: string = "vscode-couchbase.tools.mdbExport";
export const dataImport: string = "vscode-couchbase.tools.dataImport";
export const ddlExport: string = "vscode-couchbase.tools.DDLExport";
export const couchbaseIqViewsCommand: string = "couchbase-iq";
Expand Down
6 changes: 3 additions & 3 deletions src/commands/tools/dataImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1154,15 +1154,15 @@ export class DataImport {
}
});
} catch (err) {
logger.error(`Failed to open data export webview`);
logger.error(`Failed to open data import webview`);
logger.debug(err);
vscode.window.showErrorMessage(
"Failed to open data export webview: " + err
"Failed to open data import webview: " + err
);
}

currentPanel.onDidDispose(() => {
Memory.state.update(Constants.DATA_EXPORT_WEBVIEW, null);
Memory.state.update(Constants.DATA_IMPORT_WEBVIEW, null);
});
};
}
10 changes: 10 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { clearDocumentFilter } from "./commands/documents/clearDocumentFilter";
import { getClusterOverviewData } from "./util/OverviewClusterUtils/getOverviewClusterData";
import { checkAndCreatePrimaryIndex } from "./commands/indexes/checkAndCreatePrimaryIndex";
import { dataExport } from "./pages/Tools/DataExport/dataExport";
import {mdbExport} from "./pages/Tools/MDBExport/MDBExport";
import { DataImport } from "./commands/tools/dataImport";
import { ddlExport } from "./commands/tools/ddlExport/ddlExport";
import { CouchbaseIqWebviewProvider } from "./commands/iq/couchbaseIqWebviewProvider";
Expand Down Expand Up @@ -512,6 +513,15 @@ export function activate(context: vscode.ExtensionContext) {
)
);

subscriptions.push(
vscode.commands.registerCommand(
Commands.mdbExport,
async () => {
await mdbExport(context);
}
)
);

subscriptions.push(
vscode.commands.registerCommand(
Commands.dataImport,
Expand Down
73 changes: 72 additions & 1 deletion src/handlers/handleCLIDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ class DependenciesDownloader {
private readonly TOOL_SHELL = "shell";
private readonly TOOL_IMPORT_EXPORT = "import_export";
private readonly ALL_TOOLS = "all_tools";
private readonly TOOL_MDB_MIGRATE = "cb_migrate";

private getToolInstallPath(toolKey: string): string {
if (toolKey === this.TOOL_SHELL) {
return "cbshell";
} else if (toolKey === this.TOOL_IMPORT_EXPORT) {
return "cbimport_export";
} else if (toolKey === this.TOOL_MDB_MIGRATE) {
return "cbmigrate";
} else if (toolKey === this.ALL_TOOLS) {
return "cbtools";
} else {
Expand All @@ -49,6 +52,10 @@ class DependenciesDownloader {
CBToolsType.CB_EXPORT,
path.join(pathPrefix, "cbexport" + suffix)
);
} else if (toolKey === this.TOOL_MDB_MIGRATE) {
map.set(
CBToolsType.CB_MIGRATE,"cbmigrate" + suffix
);
} else if (toolKey === this.ALL_TOOLS) {
map.set(
CBToolsType.CBC_PILLOW_FIGHT,
Expand All @@ -62,7 +69,7 @@ class DependenciesDownloader {
throw new Error("Not implemented yet");
}

return map;
return map;
}

private getToolSpec(url: string, toolKey: string, os: string): ToolSpec {
Expand Down Expand Up @@ -99,6 +106,14 @@ class DependenciesDownloader {
OSUtil.MACOS_64
)
);
map.set(
this.TOOL_MDB_MIGRATE,
this.getToolSpec(
"https://intellij-plugin-dependencies.s3.us-east-2.amazonaws.com/cbmigrate/cbmigrate_0.0.1-beta_darwin_amd64.zip",
this.TOOL_MDB_MIGRATE,
OSUtil.MACOS_64
)
);
} else if (os === OSUtil.MACOS_ARM) {
map.set(
this.TOOL_SHELL,
Expand All @@ -124,6 +139,14 @@ class DependenciesDownloader {
OSUtil.MACOS_ARM
)
);
map.set(
this.TOOL_MDB_MIGRATE,
this.getToolSpec(
"https://intellij-plugin-dependencies.s3.us-east-2.amazonaws.com/cbmigrate/cbmigrate_0.0.1-beta_darwin_arm64.zip",
this.TOOL_MDB_MIGRATE,
OSUtil.MACOS_64
)
);
} else if (os === OSUtil.WINDOWS_64) {
map.set(
this.TOOL_SHELL,
Expand All @@ -149,6 +172,14 @@ class DependenciesDownloader {
OSUtil.WINDOWS_64
)
);
map.set(
this.TOOL_MDB_MIGRATE,
this.getToolSpec(
"https://intellij-plugin-dependencies.s3.us-east-2.amazonaws.com/cbmigrate/cbmigrate_0.0.1-beta_windows_amd64.zip",
this.TOOL_MDB_MIGRATE,
OSUtil.MACOS_64
)
);
} else if (os === OSUtil.WINDOWS_ARM) {
map.set(
this.TOOL_SHELL,
Expand Down Expand Up @@ -199,6 +230,14 @@ class DependenciesDownloader {
OSUtil.LINUX_64
)
);
map.set(
this.TOOL_MDB_MIGRATE,
this.getToolSpec(
"https://intellij-plugin-dependencies.s3.us-east-2.amazonaws.com/cbmigrate/cbmigrate_0.0.1-beta_linux_amd64.zip",
this.TOOL_MDB_MIGRATE,
OSUtil.MACOS_64
)
);
} else if (os === OSUtil.LINUX_ARM) {
map.set(
this.TOOL_SHELL,
Expand All @@ -216,6 +255,14 @@ class DependenciesDownloader {
OSUtil.LINUX_ARM
)
);
map.set(
this.TOOL_MDB_MIGRATE,
this.getToolSpec(
"https://intellij-plugin-dependencies.s3.us-east-2.amazonaws.com/cbmigrate/cbmigrate_0.0.1-beta_linux_arm64.zip",
this.TOOL_MDB_MIGRATE,
OSUtil.MACOS_64
)
);
} else {
throw new Error("OS not supported.");
}
Expand Down Expand Up @@ -252,6 +299,30 @@ class DependenciesDownloader {
logger.debug("CBShell is already installed");
this.setToolActive(ToolStatus.AVAILABLE, shellPath, shell);
}

const cbMigrate = downloads.get(this.TOOL_MDB_MIGRATE);
if (cbMigrate === undefined) {
return;
}
const cbMigratePath = path.join(toolsPath, cbMigrate.getInstallationPath());
const cbMigrateTool = CBTools.getTool(CBToolsType.CB_MIGRATE);
const cbMigrateStatus = cbMigrateTool.status;
const cbMigrateDownloadsMap = downloads.get(this.TOOL_SHELL);
if (cbMigrateDownloadsMap === undefined) {
return;
}
if (
cbMigrateStatus === ToolStatus.NOT_AVAILABLE &&
!this.isInstalled(toolsPath, cbMigrateDownloadsMap, CBToolsType.CB_MIGRATE)
) {
// Avoiding 2 threads to install the same thing at the same time
logger.info("Downloading CB Migrate..");
cbMigrateTool.status = ToolStatus.DOWNLOADING;
this.downloadAndUnzip(cbMigratePath, cbMigrate);
} else {
logger.debug("CBMigrate is already installed");
this.setToolActive(ToolStatus.AVAILABLE, cbMigratePath, cbMigrate);
}
const cbImport: ToolSpec | undefined = downloads.get(
this.TOOL_IMPORT_EXPORT
);
Expand Down
Loading

0 comments on commit 8c61bd9

Please sign in to comment.