Skip to content

Commit

Permalink
Create project using the --template when using action server 0.10.0 o…
Browse files Browse the repository at this point in the history
…nwards
  • Loading branch information
el-mike authored May 20, 2024
1 parent f625187 commit 7e4d06b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 38 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
New in 1.22.2 (2024-05-20)
-----------------------------

- If `Action Server 0.10.0` onwards is being used, creates a project using the `--template minimal`.
- In the new project, if the project is not empty and the user agreed to proceed, create the contents even if it means overriding what's there.

New in 1.22.1 (2024-05-04)
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion sema4ai-code/vscode-client/src/actionServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const getInternalActionServerLocation = async (tmpFlag: string = "") => {
return path.join(await getInternalActionServerDirLocation(), binName);
};

const getActionServerVersion = async (actionServerLocation: string): Promise<string | undefined> => {
export const getActionServerVersion = async (actionServerLocation: string): Promise<string | undefined> => {
let result: ExecFileReturn;
const maxTimes = 4;
let lastError = undefined;
Expand Down
33 changes: 0 additions & 33 deletions sema4ai-code/vscode-client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,38 +330,6 @@ class CommandRegistry {
}
}

async function verifyRobotFrameworkInstalled() {
// No longer check whether robotframweork-lsp is installed.
// if (!roboConfig.getVerifylsp()) {
// return;
// }
// const ROBOT_EXTENSION_ID = "robocorp.robotframework-lsp";
// let found = true;
// try {
// let extension = extensions.getExtension(ROBOT_EXTENSION_ID);
// if (!extension) {
// found = false;
// }
// } catch (error) {
// found = false;
// }
// if (!found) {
// // It seems it's not installed, install?
// let install = "Install";
// let dontAsk = "Don't ask again";
// let chosen = await window.showInformationMessage(
// "It seems that the Robot Framework Language Server extension is not installed to work with .robot Files.",
// install,
// dontAsk
// );
// if (chosen == install) {
// await commands.executeCommand("workbench.extensions.search", ROBOT_EXTENSION_ID);
// } else if (chosen == dontAsk) {
// roboConfig.setVerifylsp(false);
// }
// }
}

async function cloudLoginShowConfirmationAndRefresh() {
let loggedIn = await cloudLogin();
if (loggedIn) {
Expand Down Expand Up @@ -870,7 +838,6 @@ export async function doActivate(context: ExtensionContext, C: CommandRegistry)
// regardless of it -- as it may call robot.resolveInterpreter, it may need to activate the language
// server extension, which in turn requires robocorp code to be activated already).
installWorkspaceWatcher(context);
verifyRobotFrameworkInstalled();
}

export function deactivate(): Thenable<void> | undefined {
Expand Down
23 changes: 19 additions & 4 deletions sema4ai-code/vscode-client/src/robo/actionPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as roboCommands from "../robocorpCommands";
import { ActionResult, IActionInfo, LocalRobotMetadataInfo } from "../protocols";
import {
areThereRobotsInWorkspace,
compareVersions,
isActionPackage,
isDirectoryAPackageDirectory,
verifyIfPathOkToCreatePackage,
Expand All @@ -14,7 +15,7 @@ import { fileExists, makeDirs } from "../files";
import { QuickPickItemWithAction, askForWs, showSelectOneQuickPick } from "../ask";
import * as path from "path";
import { OUTPUT_CHANNEL, logError } from "../channel";
import { downloadOrGetActionServerLocation } from "../actionServer";
import { downloadOrGetActionServerLocation, getActionServerVersion } from "../actionServer";
import { createEnvWithRobocorpHome, getRobocorpHome } from "../rcc";
import { execFilePromise } from "../subprocess";

Expand Down Expand Up @@ -226,6 +227,8 @@ export async function createActionPackage() {
return;
}

const actionServerVersionPromise: Promise<string | undefined> = getActionServerVersion(actionServerLocation);

if (await isDirectoryAPackageDirectory(ws.uri)) {
return;
}
Expand Down Expand Up @@ -294,11 +297,23 @@ export async function createActionPackage() {
const robocorpHome = await getRobocorpHome();
const env = createEnvWithRobocorpHome(robocorpHome);

const cwd = dirname(targetDir);
const useName = path.basename(targetDir);
await makeDirs(targetDir);

try {
await execFilePromise(actionServerLocation, ["new", "--name", useName], { "env": env, "cwd": cwd });
const actionServerVersion: string | undefined = await actionServerVersionPromise;
if (actionServerVersion === undefined) {
const msg = "Cannot do `new` command (it was not possible to get the action server version).";
OUTPUT_CHANNEL.appendLine(msg);
window.showErrorMessage(msg);
return;
}
let cmdline = ["new", "--name", ".", "--template", "minimal"];
const compare = compareVersions("0.10.0", actionServerVersion);
if (compare > 0) {
// old version installed (no --template available).
cmdline = ["new", "--name", "."];
}
await execFilePromise(actionServerLocation, cmdline, { "env": env, "cwd": targetDir });
try {
commands.executeCommand("workbench.files.action.refreshFilesExplorer");
} catch (error) {
Expand Down

0 comments on commit 7e4d06b

Please sign in to comment.