Skip to content
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

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions desktop/internal/core/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,40 @@ func (c *Client) PlanRunConfiguration(ctx context.Context, manifest json.RawMess
return *result.Plan, nil
}

// BeforeLaunchTaskPlanRequest asks for the command of a plugin task step, with
// Task and WorkingDirectory as `runConfig.beforeLaunch` returned the step. Core
// runs it with the instance whose root holds the working directory.
type BeforeLaunchTaskPlanRequest struct {
Task RunTaskReference `json:"task"`
WorkingDirectory string `json:"workingDirectory"`
Instances []RunTypeInstance `json:"instances"`
PluginDirectory string `json:"pluginDirectory,omitempty"`
WorkspaceStateDirectory string `json:"workspaceStateDirectory,omitempty"`
}

// PlanBeforeLaunchTask plans a task step of a Before Launch list
// (`build.beforeLaunchTaskPlan`): the command plan of the chosen instance, whose
// Root names it, run to completion at the step's working directory.
func (c *Client) PlanBeforeLaunchTask(ctx context.Context, manifest json.RawMessage, buildSystemID, workspaceRoot string, request BeforeLaunchTaskPlanRequest) (BuildPlan, error) {
const command = "build.beforeLaunchTaskPlan"
var result buildOutcome
if err := c.Execute(ctx, command, struct {
Manifest json.RawMessage `json:"manifest"`
BuildSystemID string `json:"buildSystemID"`
WorkspaceRoot string `json:"workspaceRoot"`
Request BeforeLaunchTaskPlanRequest `json:"request"`
}{manifest, buildSystemID, workspaceRoot, request}, &result); err != nil {
return BuildPlan{}, err
}
if err := result.failure(command); err != nil {
return BuildPlan{}, err
}
if result.Plan == nil {
return BuildPlan{}, newParseError(command, "before-launch task plan returned no plan", "")
}
return *result.Plan, nil
}

// DecodeBuildModel turns static/command output or a provider result into the
// normalized model.
func (c *Client) DecodeBuildModel(ctx context.Context, manifest json.RawMessage, buildSystemID string, request BuildDecodeModelRequest) (BuildModel, error) {
Expand Down
148 changes: 134 additions & 14 deletions desktop/internal/core/run_before_launch.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package core

import "context"
import (
"bytes"
"context"
"encoding/json"
"errors"
)

// RunBeforeLaunch is what `runConfig.beforeLaunch` answers: Status "ok" with the
// steps to run in order and, when a project file names them, the Confirmation to
Expand All @@ -12,12 +17,15 @@ type RunBeforeLaunch struct {
Refusal *RunBeforeLaunchRefusal `json:"refusal"`
}

// RunBeforeLaunchItem is one run to start before the configuration: its ID, its
// name and a line naming what it starts, shown in the confirmation.
// RunBeforeLaunchItem is one step to start before the configuration: a run (its
// ConfigurationID) or a plugin Task with the WorkingDirectory it runs in, with the
// step's name and a line naming what it starts, shown in the confirmation.
type RunBeforeLaunchItem struct {
ConfigurationID string `json:"configurationId"`
Name string `json:"name"`
Summary string `json:"summary"`
ConfigurationID string `json:"configurationId,omitempty"`
Task *RunTaskReference `json:"task,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
Name string `json:"name"`
Summary string `json:"summary"`
}

// RunBeforeLaunchConfirmation identifies a list of steps a project file names; the
Expand All @@ -27,18 +35,130 @@ type RunBeforeLaunchConfirmation struct {
}

// RunBeforeLaunchRefusal is why the steps cannot run: Code is notFound,
// notAllowed, unavailable, cycle or tooLong, about step ConfigurationID.
// notAllowed, unavailable, cycle, tooLong, taskNotDeclared or invalidTaskValues,
// about step ConfigurationID, or for a task the configuration whose list names it
// with the Task set.
type RunBeforeLaunchRefusal struct {
Code string `json:"code"`
ConfigurationID string `json:"configurationId"`
Code string `json:"code"`
ConfigurationID string `json:"configurationId"`
Task *RunTypeKey `json:"task,omitempty"`
}

// RunBeforeLaunch expands the built-in process runs configurationID starts first.
func (c *Client) RunBeforeLaunch(ctx context.Context, root, configurationID string) (RunBeforeLaunch, error) {
// RunTaskReference is a plugin task step as a configuration saves it: the kind a
// plugin declares and the values of its fields by declared field ID, kept raw so
// the host sends them back unchanged.
type RunTaskReference struct {
RunTypeKey
Values json.RawMessage `json:"values,omitempty"`
}

// RunTaskStep is a task step of a `beforeLaunch` editor value: the saved Task, its
// Name and Summary, and the form Values of its fields by `field:<id>`. Missing says
// no installed plugin declares it; the editor shows and keeps it, without values.
type RunTaskStep struct {
Task RunTaskReference `json:"task"`
Name string `json:"name"`
Summary string `json:"summary"`
Values map[string]json.RawMessage `json:"values,omitempty"`
Missing bool `json:"missing,omitempty"`
}

// RunBeforeLaunchEntry is one item of a `beforeLaunch` editor value: the ID of a
// configuration to run, or a plugin Task. Its JSON is the ID string or the task
// object, as Core sends and takes them.
type RunBeforeLaunchEntry struct {
ConfigurationID string
Task *RunTaskStep
}

// MarshalJSON writes the configuration ID, or the task object.
func (e RunBeforeLaunchEntry) MarshalJSON() ([]byte, error) {
if e.Task != nil {
return json.Marshal(e.Task)
}
return json.Marshal(e.ConfigurationID)
}

// UnmarshalJSON reads a configuration ID string or a task object.
func (e *RunBeforeLaunchEntry) UnmarshalJSON(data []byte) error {
data = bytes.TrimSpace(data)
switch {
case len(data) > 0 && data[0] == '"':
*e = RunBeforeLaunchEntry{}
return json.Unmarshal(data, &e.ConfigurationID)
case len(data) > 0 && data[0] == '{':
var task RunTaskStep
if err := json.Unmarshal(data, &task); err != nil {
return err
}
*e = RunBeforeLaunchEntry{Task: &task}
return nil
}
return errors.New("a beforeLaunch item is a configuration ID or a task")
}

// RunTaskKind is a kind of task step installed plugins declare, as a `beforeLaunch`
// editor field offers it: its RunType, translated DisplayName, Description and
// Icon, and the Fields and default Values of its own form, keyed `field:<id>`.
type RunTaskKind struct {
RunType RunTypeKey `json:"runType"`
DisplayName string `json:"displayName"`
Description string `json:"description,omitempty"`
Icon *RunTypeIcon `json:"icon,omitempty"`
Fields []RunEditorField `json:"fields"`
Values map[string]json.RawMessage `json:"values"`
}

// RunBeforeLaunch expands the built-in process runs and plugin tasks
// configurationID starts first. Plugins are the enabled plugins that declare
// tasks; without them every task step is refused as taskNotDeclared.
func (c *Client) RunBeforeLaunch(ctx context.Context, root, configurationID string, plugins *RunTypePlugins) (RunBeforeLaunch, error) {
var result RunBeforeLaunch
err := c.Execute(ctx, "runConfig.beforeLaunch", struct {
Root string `json:"root"`
ConfigurationID string `json:"configurationId"`
}{root, configurationID}, &result)
Root string `json:"root"`
ConfigurationID string `json:"configurationId"`
RunTypePlugins *RunTypePlugins `json:"runTypePlugins,omitempty"`
}{root, configurationID, plugins}, &result)
return result, err
}

// RunTaskCheck is what `runConfig.checkBeforeLaunchTask` answers: Status "ok" with
// the Step to put in the editor value, or "invalid" with field Errors.
type RunTaskCheck struct {
Status string `json:"status"`
Step *RunTaskStep `json:"step"`
Errors []RunFieldError `json:"errors"`
}

// CheckBeforeLaunchTask checks the form values of a task step being added or
// edited. Nothing is written; the step is saved with the configuration.
func (c *Client) CheckBeforeLaunchTask(ctx context.Context, root string, runType RunTypeKey, values map[string]json.RawMessage, plugins *RunTypePlugins) (RunTaskCheck, error) {
var result RunTaskCheck
err := c.Execute(ctx, "runConfig.checkBeforeLaunchTask", struct {
Root string `json:"root"`
RunType RunTypeKey `json:"runType"`
Values map[string]json.RawMessage `json:"values,omitempty"`
RunTypePlugins *RunTypePlugins `json:"runTypePlugins,omitempty"`
}{root, runType, values, plugins}, &result)
return result, err
}

// RunBeforeLaunchField is the `beforeLaunch` editor field of a saved configuration:
// the runs a step may name, the task kinds plugins declare and the effective list.
type RunBeforeLaunchField struct {
Candidates []RunConfigurationName `json:"candidates"`
Tasks []RunTaskKind `json:"tasks"`
Value []RunBeforeLaunchEntry `json:"value"`
}

// BeforeLaunchField reads the `beforeLaunch` field of the saved configurationID for
// an editor that does not use `runConfig.editorForm`, such as that of a build run.
func (c *Client) BeforeLaunchField(ctx context.Context, root, configurationID string, plugins *RunTypePlugins) (RunBeforeLaunchField, error) {
var result RunBeforeLaunchField
err := c.Execute(ctx, "runConfig.beforeLaunchField", struct {
Root string `json:"root"`
ConfigurationID string `json:"configurationId"`
RunTypePlugins *RunTypePlugins `json:"runTypePlugins,omitempty"`
}{root, configurationID, plugins}, &result)
return result, err
}
19 changes: 12 additions & 7 deletions desktop/internal/core/run_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ type RunConfiguration struct {
// Availability is set when the saved configuration cannot run, such as when
// the plugin it needs is not installed. The host shows it and never starts it.
Availability *RunAvailability `json:"availability,omitempty"`
// BeforeLaunch names the built-in process runs started, in order, before this one.
// BeforeLaunch names the built-in process runs and plugin tasks started, in order,
// before this one.
BeforeLaunch []RunBeforeLaunchStep `json:"beforeLaunch,omitempty"`
// AllowMultipleInstances lets a new run start beside one still running instead of
// stopping it first.
AllowMultipleInstances bool `json:"allowMultipleInstances,omitempty"`
}

// RunBeforeLaunchStep is one step of a configuration's beforeLaunch: the built-in
// process run to start first.
// RunBeforeLaunchStep is one saved step of a configuration's beforeLaunch: the
// built-in process run to start first, or a plugin Task.
type RunBeforeLaunchStep struct {
Configuration string `json:"configuration"`
Configuration string `json:"configuration,omitempty"`
Task *RunTaskReference `json:"task,omitempty"`
}

// RunPluginDependency is the plugin a configuration needs: its ID, and what the
Expand Down Expand Up @@ -298,9 +300,12 @@ type RunOptionsEdit struct {
Environment map[string]string `json:"environment"`
// ProviderRunOptions replaces the build provider choices of the selected layer when set.
ProviderRunOptions json.RawMessage `json:"providerRunOptions,omitempty"`
// BeforeLaunch replaces the steps of the selected layer when set; an empty list
// removes them (and in the local layer hides the project's).
BeforeLaunch *[]string `json:"beforeLaunch,omitempty"`
// BeforeLaunch replaces the steps of the selected layer when set, in the shape of
// the editor field's value; an empty list removes them (and in the local layer
// hides the project's).
BeforeLaunch *[]RunBeforeLaunchEntry `json:"beforeLaunch,omitempty"`
// RunTypePlugins are the enabled plugins, so Core can check the task steps.
RunTypePlugins *RunTypePlugins `json:"runTypePlugins,omitempty"`
// Plugins is the enabled plugin list of ResolveRunConfigurations, so a plugin
// document Core writes records the installed plugin.
Plugins []RunInstalledPlugin `json:"plugins,omitempty"`
Expand Down
4 changes: 3 additions & 1 deletion desktop/internal/core/run_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ type RunEditorField struct {
Description string `json:"description,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
OptionLabels map[string]string `json:"optionLabels,omitempty"`
// Candidates are the configurations a beforeLaunch field may name.
// Candidates are the configurations a beforeLaunch field may name, and Tasks the
// kinds of plugin task it may add.
Candidates []RunConfigurationName `json:"candidates,omitempty"`
Tasks []RunTaskKind `json:"tasks,omitempty"`
}

// RunConfigurationName is a run configuration's ID and name.
Expand Down
3 changes: 3 additions & 0 deletions desktop/internal/fileicons/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ client's NOTICE.txt records the source paths and revisions of the restored icons
platform/icons/src/fileTypes/custom.svg; lock is expui/general/locked; readme is
expui/status/info; nodejs is
plugins/kotlin/base/resources/resources/org/jetbrains/kotlin/idea/icons/expui/wizard/nodejs.
go.svg is the exception: expui/fileTypes/ has no Go icon, and the restored file is byte for
byte platform/icons/src/language/go_dark.svg (revision
b3667546dadaf462cc8812e6de88be6d3e76558b).
- folder.svg and excludeRoot.svg: platform/icons/src/expui/nodes/ (revision
e8d21e84ee23f99ae7237fbb4530ff2e7c3b47c5).
- svg/tree/treechevronDown.svg and treechevronRight.svg (and their _dark variants): the previous
Expand Down
Loading
Loading