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

Basic support for multi-folder deployment creation, selection and deployment #1943

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sagerb
Copy link
Collaborator

@sagerb sagerb commented Jul 10, 2024

Intent

Resolves #1852

Type of Change

    • Bug Fix
    • New Feature
    • Breaking Change
    • Documentation
    • Refactor
    • Tooling

Approach

The changes needed to implement this proved to be pretty much as expected.

  1. Needed to take into account projectDir when selecting or matching configurations and deployments
  2. Needed to update API calls to be recursive
  3. Needed to update new deployment process to be able to create unique names per the project directory
  4. File watchers needed to watch recursively
  5. Needed to pass in projectDir when calling deploy api

Automated Tests

Directions for Reviewers

Unfortunately, there were a number of changes required to maintain functionality once changes were started. It would be best to walk through the individual commits, to understand what is being done.

recursive inspection, create deployment and configuration within dir …

Update watcher patterns to be recursive

Recursive API calls, integrate projectDir and switch to deploymentSel…

Deploy with projectDir parameter (and update deployment tooltip)

Fix codicons path issue (underscore was lost during search/replace)

Checklist

@sagerb sagerb changed the base branch from main to sagerb-refactor-underscore-private-names July 10, 2024 21:54
export const POSIT_FOLDER = ".posit";
export const PUBLISH_FOLDER = ".posit/publish";
export const PUBLISH_DEPLOYMENTS_FOLDER = ".posit/publish/deployments";
export const POSIT_FOLDER = "**/.posit";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of our file watcher patterns need now to glob downward into subdirectories.

@@ -267,7 +267,7 @@ export async function newDeployment(

let entryPointListItems: QuickPickItemWithIndex[] = [];
let inspectionResults: ConfigurationInspectionResult[] = [];
let contentRecordNames: string[] = [];
let contentRecordNames = new Map<string, string[]>();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch to a Map here so we can have easy filtering of configurations which are applicable to a projectDir where the entrypoints and deployment is being created.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be helpful in other inputs to have a util class for names to add them, use the projectDir to gather them and all that. Something to consider if we repeat the logic elsewhere.

@@ -367,6 +369,7 @@ export async function newDeployment(
iconPath: new ThemeIcon("file"),
label: config.entrypoint,
description: `(${contentTypeStrings[config.type]})`,
detail: result.projectDir,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We needed to indicate the location of the entrypoints, so now I'm using the second line to hold the workingDir

}
existingList.push(contentRecord.deploymentName);
contentRecordNames.set(contentRecord.projectDir, existingList);
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Populate the map to be keyed by a projectDir and then contain an array of entrypoints.

return;
}
selectedInspectionResult.configuration.title = state.data.title;

Copy link
Collaborator Author

@sagerb sagerb Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same logic above as exists in original, just moved around a bit.

);
if (!existingNames) {
existingNames = [];
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

easy use of our Map

@@ -71,15 +72,15 @@ export type RefreshContentRecordDataMsg = AnyHostToWebviewMessage<
HostToWebviewMessageType.REFRESH_CONTENTRECORD_DATA,
{
contentRecords: (ContentRecord | PreContentRecord)[];
selectedContentRecordName?: string | null;
deploymentSelected: DeploymentSelector | null;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch to a DeploymentSelector object, which allows us to select the exact combination of deployment and config. It is unique across all locations within a set of directories, since it contains the actual deployment path on disk.

@@ -89,6 +89,7 @@ export type DeployMsg = AnyWebviewToHostMessage<
deploymentName: string;
credentialName: string;
configurationName: string;
projectDir: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New parameter needed to deploy!

};

export type DeploymentNames = {
export type DeploymentSelector = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces use of DeploymentNames (and HomeViewState)

@@ -354,7 +357,7 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable {
private async refreshConfigurationData() {
try {
const api = await useApi();
const response = await api.configurations.getAll();
const response = await api.configurations.getAll({ recursive: true });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recursively refreshing everytime.. We probably can figure out a more targeted approach, but lets do that in another PR as an optimization.

Base automatically changed from sagerb-refactor-underscore-private-names to main July 10, 2024 22:15
@sagerb sagerb self-assigned this Jul 10, 2024
@sagerb sagerb marked this pull request as ready for review July 10, 2024 22:20
@sagerb sagerb marked this pull request as draft July 11, 2024 15:23
Copy link
Collaborator

@dotNomad dotNomad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a couple concerns, but overall this is looking great - we can address as follow-ups if need be.

Comment on lines -82 to +83
selectedConfigurationName?: string | null;
deploymentSelected: DeploymentSelector | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this no longer optional?

function updateSelectedConfigurationByName(name: string) {
function updateSelectedConfigurationByName(
name: string,
projectDir?: string,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this should be optional to avoid us changing a selected configuration incorrectly.

Comment on lines +127 to +130
// skip saving the selection if we have not yet
// selected a content record. This is probably an init
// sequence.
if (selectedContentRecord.value) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit confused by this change. Wouldn't we want this to update if the deployment selected was deleted for example?

@@ -430,36 +433,49 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable {
});
}

private getSelectionState(): HomeViewState {
const state = this.context.workspaceState.get<HomeViewState>(
private getSelectionState(): DeploymentSelector | null {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this still be HomeViewState since that type is DeploymentSelector | null anyway?

@@ -675,20 +701,16 @@ export class HomeViewProvider implements WebviewViewProvider, Disposable {
}

private async propogateDeploymentSelection(
configurationName?: string,
deploymentName?: string,
documentSelector: DeploymentSelector | null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this feels like it should be named deploymentSelector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List recursive options for deployments and entrypoints
3 participants