⏳ Connecting SFTP...
- ✔️ Successfully pinged SFTP server!
- SFTP synchronization is not used.
- ❌ Failed to establish SFTP connection!
+ ✔️ Successfully pinged SFTP server!
+ ⓘ SFTP synchronization is not used.
+ ❌ Failed to establish SFTP connection!
@@ -168,7 +168,7 @@
🖥️ Server Setup
+ placeholder="Ex. /tmp/XXXX">
Project path on server specifies the path to the project's copy on the server host.
May point to a directory shared by the client and server. In this case, SFTP synchronization
must be disabled by leaving the SFTP port field empty.
diff --git a/vscode-plugin/media/wizardHTML.js b/vscode-plugin/media/wizardHTML.js
index 479ab253..94728141 100644
--- a/vscode-plugin/media/wizardHTML.js
+++ b/vscode-plugin/media/wizardHTML.js
@@ -171,7 +171,7 @@ function showTab(tabIndex) {
showElement(currentTabElement, true);
// Show previous button if necessary
- showElement(prevButton, tabIndex === 0);
+ showElement(prevButton, tabIndex !== 0);
// Set nextButton title according to tab number
if (tabIndex === tabElements.length - 1) {
diff --git a/vscode-plugin/src/wizard/wizard.ts b/vscode-plugin/src/wizard/wizard.ts
index e055562f..0451814f 100644
--- a/vscode-plugin/src/wizard/wizard.ts
+++ b/vscode-plugin/src/wizard/wizard.ts
@@ -26,7 +26,6 @@ function getNonce(): string {
}
export class UtbotWizardPanel {
-
public static currentPanel: UtbotWizardPanel | undefined;
private disposables: vs.Disposable[] = [];
private static PING_TIMEOUT_MS = 5000;
@@ -124,6 +123,7 @@ export class UtbotWizardPanel {
});
}
+ private static GENERATED = "This file is automatically generated by UnitTestBot.";
private async setupSFTP(
activate: boolean,
host: string,
@@ -142,9 +142,21 @@ export class UtbotWizardPanel {
const workspaceFolder = workspaceFolderUrl.fsPath;
const sftpConfigPath = pathUtils.fsJoin(workspaceFolder, '.vscode', 'sftp.json');
try {
+ // backup config: sftp.json -> sftp.json.old if we have user's version
+ if (fs.existsSync(sftpConfigPath)) {
+ const configContentOld = fs.readFileSync(sftpConfigPath, {encoding:'utf8', flag:'r'});
+ // checks, that the configuration was not created by UTBot
+ if (!configContentOld.includes(UtbotWizardPanel.GENERATED)) {
+ const oldConfigPath = sftpConfigPath + ".old";
+ console.log(`Back up ".vscode/${sftpConfigPath}" to ".vscode/${oldConfigPath}"`);
+ fs.writeFileSync(oldConfigPath, configContentOld);
+ }
+ }
+
if (activate) {
- const configContent =
+ const configContent =
`{
+ "//comment": "${UtbotWizardPanel.GENERATED}",
"name": "UTBot Server",
"host": "${host}",
"protocol": "sftp",
@@ -159,10 +171,11 @@ export class UtbotWizardPanel {
if (!fs.existsSync(sftpConfigPath)) {
fs.writeFileSync(sftpConfigPath, ' ');
}
+
const doc = await vs.workspace.openTextDocument(sftpConfigPath);
const editor = await vs.window.showTextDocument(doc, {preview: true, preserveFocus: false});
// we need to generate the `onDidSaveTextDocument` event
- // it is the only event that is processed by SFTP pluging to change the preload configuration
+ // it is the only event that is processed by SFTP plugin to change the preload configuration
void editor.edit( builder => {
builder.delete(new vs.Range(0, 0, 10000, 10000));
builder.insert(new vs.Position(0, 0), configContent);
@@ -170,12 +183,12 @@ export class UtbotWizardPanel {
.then( () => {
void editor.document.save().then( saved => {
if (saved) {
- messages.showWarningMessage(`New configuration ".vscode/sftp.json" was saved!`);
+ messages.showInfoMessage(`New configuration ".vscode/sftp.json" was saved!`);
}
void vs.commands.executeCommand('workbench.action.closeActiveEditor');
const postponedSync = (): void => {
void vs.commands.executeCommand("sftp.sync.localToRemote", workspaceFolderUrl).then(
- () => messages.showWarningMessage(`Project copy was created on UTBot Server at "${remotePath}"`),
+ () => messages.showInfoMessage(`Project copy was created on UTBot Server at "${remotePath}"`),
(err) => messages.showWarningMessage(`Project copy was not created on UTBot Server at "${remotePath}" with error ` + err)
);
};