Skip to content

Commit

Permalink
Merge pull request #2307 from posit-dev/sagerb-optimize-entrypoint-se…
Browse files Browse the repository at this point in the history
…lection

Updates to New Deployment Multi-Stepper
  • Loading branch information
sagerb authored Sep 30, 2024
2 parents 80beb95 + 6ee316a commit 9f05744
Show file tree
Hide file tree
Showing 8 changed files with 396 additions and 874 deletions.
34 changes: 33 additions & 1 deletion extensions/vscode/src/api/types/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ export type ConfigurationInspectionResult = {
projectDir: string;
};

export const areInspectionResultsSimilarEnough = (
inspect1: ConfigurationInspectionResult,
inspect2: ConfigurationInspectionResult,
) => {
// Not comparing ALL attributes, just enough to maintain uniqueness and
// confidence that this is a "similar" inspection result
return (
inspect1.projectDir === inspect2.projectDir &&
inspect1.configuration.entrypoint === inspect2.configuration.entrypoint &&
inspect1.configuration.type === inspect2.configuration.type
);
};

export function isConfigurationError(
cfg: Configuration | ConfigurationError,
): cfg is ConfigurationError {
Expand All @@ -49,6 +62,24 @@ export enum ContentType {
UNKNOWN = "unknown",
}

export const allValidContentTypes: ContentType[] = [
ContentType.HTML,
ContentType.JUPYTER_NOTEBOOK,
ContentType.JUPYTER_VOILA,
ContentType.PYTHON_BOKEH,
ContentType.PYTHON_DASH,
ContentType.PYTHON_FASTAPI,
ContentType.PYTHON_FLASK,
ContentType.PYTHON_SHINY,
ContentType.PYTHON_STREAMLIT,
ContentType.QUARTO_SHINY,
ContentType.QUARTO,
ContentType.R_PLUMBER,
ContentType.R_SHINY,
ContentType.RMD_SHINY,
ContentType.RMD,
];

export const contentTypeStrings = {
[ContentType.HTML]: "serve pre-rendered HTML",
[ContentType.JUPYTER_NOTEBOOK]: "render with Jupyter nbconvert",
Expand All @@ -66,7 +97,8 @@ export const contentTypeStrings = {
[ContentType.RMD_SHINY]:
"render with rmarkdown/knitr and run embedded Shiny app",
[ContentType.RMD]: "render with rmarkdown/knitr",
[ContentType.UNKNOWN]: "unknown content type; cannot deploy this item",
[ContentType.UNKNOWN]:
"unknown content type; manual selection needed to deploy",
};

export type ConfigurationDetails = {
Expand Down
12 changes: 12 additions & 0 deletions extensions/vscode/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ export const DEPLOYMENTS_PATTERN = "**/.posit/publish/deployments/*.toml";
export const DEFAULT_PYTHON_PACKAGE_FILE = "requirements.txt";
export const DEFAULT_R_PACKAGE_FILE = "renv.lock";

// pulled from /internal/services/api/get_entrypoints.go
// should all be lowercase!
export const ENTRYPOINT_FILE_EXTENSIONS = [
".htm",
".html",
".ipynb",
".py",
".qmd",
".r",
".rmd",
];

const baseCommands = {
InitProject: "posit.publisher.init-project",
ShowOutputChannel: "posit.publisher.showOutputChannel",
Expand Down
17 changes: 16 additions & 1 deletion extensions/vscode/src/multiStepInputs/multiStepHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (C) 2024 by Posit Software, PBC.

import { ConfigurationInspectionResult } from "src/api";
import {
QuickPickItem,
window,
Expand All @@ -21,19 +22,33 @@ export function isQuickPickItem(d: QuickPickItem | string): d is QuickPickItem {
}

export type QuickPickItemWithIndex = QuickPickItem & { index: number };
export type QuickPickItemWithInspectionResult = QuickPickItem & {
inspectionResult?: ConfigurationInspectionResult;
};

export function isQuickPickItemWithIndex(
d: QuickPickItem | string,
): d is QuickPickItemWithIndex {
return (d as QuickPickItemWithIndex).index !== undefined;
}

export function isQuickPickItemWithInspectionResult(
d: QuickPickItem | string,
): d is QuickPickItemWithInspectionResult {
return (
(d as QuickPickItemWithInspectionResult).inspectionResult !== undefined
);
}

export interface MultiStepState {
title: string;
step: number;
lastStep: number;
totalSteps: number;
data: Record<string, QuickPickItem | string | undefined>;
data: Record<
string,
QuickPickItem | QuickPickItemWithInspectionResult | string | undefined
>;
promptStepNumbers: Record<string, number>;
}

Expand Down
Loading

0 comments on commit 9f05744

Please sign in to comment.