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

Remove experimental flag for JSONRPC command group #14368

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 0 additions & 3 deletions docs/experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,5 @@ Should be enabled in tandem with `assertions` experimental feature flag for expe
### `publish-provider` CLI Command
Command that allows the publishing of providers to container registries. For more information, see [Using the Publish Provider Command](./experimental/publish-provider-command.md).

### `jsonrpc` CLI Command
Command that launches the CLI in a JSONRPC server mode. Useful for invoking the CLI programatically to consume structured output, and to avoid cold-start delays when compiling multiple files. For more information, see [Using the JSONRPC Command](./experimental/jsonrpc-command.md).

### Deployment Pane
The Deployment Pane is a UI panel in VSCode that allows you to connect to your Azure subscription and execute validate, deploy & whatif operations and get instant feedback without leaving the editor. For more information, see [Using the Deployment Pane](./experimental/deploy-ui.md).
2 changes: 1 addition & 1 deletion src/Bicep.Cli.IntegrationTests/JsonRpcCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ await Task.WhenAll(
{
var result = await Bicep(registerAction, cts.Token, "jsonrpc", "--pipe", pipeName);
result.ExitCode.Should().Be(0);
result.Stderr.Should().EqualIgnoringNewlines("The 'jsonrpc' CLI command group is an experimental feature. Experimental features should be enabled for testing purposes only, as there are no guarantees about the quality or stability of these features. Do not enable these settings for any production usage, or your production environment may be subject to breaking.\n");
result.Stderr.Should().Be("");
result.Stdout.Should().Be("");
}),
Task.Run(async () =>
Expand Down
2 changes: 0 additions & 2 deletions src/Bicep.Cli/Commands/JsonRpcCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public JsonRpcCommand(BicepCompiler compiler, IOContext io)

public async Task<int> RunAsync(JsonRpcArguments args, CancellationToken cancellationToken)
{
await io.Error.WriteLineAsync("The 'jsonrpc' CLI command group is an experimental feature. Experimental features should be enabled for testing purposes only, as there are no guarantees about the quality or stability of these features. Do not enable these settings for any production usage, or your production environment may be subject to breaking.");

if (args.Pipe is { } pipeName)
{
if (pipeName.StartsWith(@"\\.\pipe\"))
Expand Down
12 changes: 12 additions & 0 deletions src/Bicep.Cli/Commands/RootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,18 @@ bicep build-params params.bicepparam --outfile otherParams.json
bicep build-params params.bicepparam --no-restore
bicep build-params params.bicepparam --diagnostics-format sarif

{exeName} jsonrpc [options]
Runs a JSONRPC server for interacting with Bicep programatically.

Options:
--pipe <name> Runs the JSONRPC server using a named pipe.
--socket <dir> Runs the JSONRPC server on a specific port.
--stdio Runs the JSONRPC server over stdin/stdout.

Examples:
bicep jsonrpc --pipe /path/to/pipe.sock
bicep jsonrpc --stdio

"; // this newline is intentional

io.Output.Write(output);
Expand Down
5 changes: 5 additions & 0 deletions src/Bicep.Cli/Rpc/CliJsonRpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public CliJsonRpcServer(BicepCompiler compiler)
this.compiler = compiler;
}

/// <inheritdoc/>
public async Task<VersionResponse> Version(VersionRequest request, CancellationToken cancellationToken)
{
await Task.Yield();
Expand All @@ -44,6 +45,7 @@ public async Task<VersionResponse> Version(VersionRequest request, CancellationT
ThisAssembly.AssemblyInformationalVersion.Split('+')[0]);
}

/// <inheritdoc/>
public async Task<CompileResponse> Compile(CompileRequest request, CancellationToken cancellationToken)
{
var model = await GetSemanticModel(compiler, request.Path);
Expand All @@ -58,6 +60,7 @@ public async Task<CompileResponse> Compile(CompileRequest request, CancellationT
return new(success, diagnostics, success ? writer.ToString() : null);
}

/// <inheritdoc/>
public async Task<CompileParamsResponse> CompileParams(CompileParamsRequest request, CancellationToken cancellationToken)
{
var model = await GetSemanticModel(compiler, request.Path);
Expand All @@ -81,6 +84,7 @@ public async Task<CompileParamsResponse> CompileParams(CompileParamsRequest requ
paramsResult.TemplateSpecId);
}

/// <inheritdoc/>
public async Task<GetFileReferencesResponse> GetFileReferences(GetFileReferencesRequest request, CancellationToken cancellationToken)
{
var model = await GetSemanticModel(compiler, request.Path);
Expand All @@ -101,6 +105,7 @@ public async Task<GetFileReferencesResponse> GetFileReferences(GetFileReferences
[.. fileUris.Select(x => x.LocalPath).OrderBy(x => x)]);
}

/// <inheritdoc/>
public async Task<GetMetadataResponse> GetMetadata(GetMetadataRequest request, CancellationToken cancellationToken)
{
var model = await GetSemanticModel(compiler, request.Path);
Expand Down
24 changes: 24 additions & 0 deletions src/Bicep.Cli/Rpc/ICliJsonRpcProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,47 @@ public record Edge(
string Target);
}

/// <summary>
/// The definition for the Bicep CLI JSONRPC interface.
/// </summary>
/// <remarks>
/// As of Bicep 0.29, this interface is no longer "experimental". Please consider carefully whether you are making a change that may break backwards compatibility.
/// </remarks>
public interface ICliJsonRpcProtocol
{
/// <summary>
/// Returns the version of the Bicep CLI.
/// </summary>
[JsonRpcMethod("bicep/version", UseSingleObjectParameterDeserialization = true)]
Task<VersionResponse> Version(VersionRequest request, CancellationToken cancellationToken);

/// <summary>
/// Compiles a specified .bicep file.
/// </summary>
[JsonRpcMethod("bicep/compile", UseSingleObjectParameterDeserialization = true)]
Task<CompileResponse> Compile(CompileRequest request, CancellationToken cancellationToken);

/// <summary>
/// Compiles a specified .bicepparam file.
/// </summary>
[JsonRpcMethod("bicep/compileParams", UseSingleObjectParameterDeserialization = true)]
Task<CompileParamsResponse> CompileParams(CompileParamsRequest request, CancellationToken cancellationToken);

/// <summary>
/// Returns metadata about a specified .bicep file.
/// </summary>
[JsonRpcMethod("bicep/getMetadata", UseSingleObjectParameterDeserialization = true)]
Task<GetMetadataResponse> GetMetadata(GetMetadataRequest request, CancellationToken cancellationToken);

/// <summary>
/// Returns the deployment graph for a specified .bicep file.
/// </summary>
[JsonRpcMethod("bicep/getDeploymentGraph", UseSingleObjectParameterDeserialization = true)]
Task<GetDeploymentGraphResponse> GetDeploymentGraph(GetDeploymentGraphRequest request, CancellationToken cancellationToken);

/// <summary>
/// Gets the full list of file paths that are referenced by a compilation. Useful to determine a set of files to watch for changes.
/// </summary>
[JsonRpcMethod("bicep/getFileReferences", UseSingleObjectParameterDeserialization = true)]
Task<GetFileReferencesResponse> GetFileReferences(GetFileReferencesRequest request, CancellationToken cancellationToken);
}
Loading