Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use deploy directory even when not deploying #1722

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/api/CompileTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,28 @@ export namespace CompileTools {
const environment = chosenAction.environment || `ile`;

let workspaceId: number | undefined = undefined;
if (workspaceFolder && chosenAction.type === `file` && chosenAction.deployFirst) {

const deployResult = await DeployTools.launchDeploy(workspaceFolder.index, method);
if (deployResult !== undefined) {
workspaceId = deployResult.workspaceId;
remoteCwd = deployResult.remoteDirectory;
// If we are running an Action for a local file, we need a deploy directory even if they are not
// deploying the file. This is because we need to know the relative path of the file to the deploy directory.
if (workspaceFolder && chosenAction.type === `file`) {
if (chosenAction.deployFirst) {
const deployResult = await DeployTools.launchDeploy(workspaceFolder.index, method);
if (deployResult !== undefined) {
workspaceId = deployResult.workspaceId;
remoteCwd = deployResult.remoteDirectory;
} else {
vscode.window.showWarningMessage(`Action "${chosenAction.name}" was cancelled.`);
return false;
}
} else {
vscode.window.showWarningMessage(`Action "${chosenAction.name}" was cancelled.`);
return false;
workspaceId = workspaceFolder.index;
const deployPath = DeployTools.getRemoteDeployDirectory(workspaceFolder);
if (deployPath) {
remoteCwd = deployPath;
} else {
vscode.window.showWarningMessage(`No deploy directory setup for this workspace. Cancelling Action.`);
return false;
}
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/api/local/deployTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export namespace DeployTools {
}
}

export function getRemoteDeployDirectory(workspaceFolder: WorkspaceFolder): string|undefined {
const storage = instance.getStorage();
const existingPaths = storage?.getDeployment();
return existingPaths ? existingPaths[workspaceFolder.uri.fsPath] : undefined;
}

/**
* Deploy a workspace to a remote IFS location.
* @param workspaceIndex if no index is provided, a prompt will be shown to pick one if there are multiple workspaces,
Expand All @@ -50,10 +56,7 @@ export namespace DeployTools {
export async function launchDeploy(workspaceIndex?: number, method?: DeploymentMethod): Promise<{remoteDirectory: string, workspaceId: number} | undefined> {
const folder = await Deployment.getWorkspaceFolder(workspaceIndex);
if (folder) {
const storage = instance.getStorage();

const existingPaths = storage?.getDeployment();
const remotePath = existingPaths ? existingPaths[folder.uri.fsPath] : '';
const remotePath = getRemoteDeployDirectory(folder);

if (remotePath) {
if (!method) {
Expand Down