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

Generate Code from TypeSpec in VSCode #5312

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ca3249a
emit sdk
chunyu3 Nov 18, 2024
b8468b6
add emitter configuration in extension setting
chunyu3 Nov 20, 2024
f0c4b89
add output dir configuration and options configuration
chunyu3 Nov 22, 2024
4691431
remove unused code
chunyu3 Nov 22, 2024
539bee9
update emitter configuration
chunyu3 Nov 24, 2024
7779481
resolve tsp command
chunyu3 Nov 26, 2024
05bbef7
define promised exec
chunyu3 Nov 26, 2024
41a8796
remove doEmit to emit.ts
chunyu3 Dec 2, 2024
31ee9e2
change to single language generation each run
chunyu3 Dec 3, 2024
6d604d8
select language box
chunyu3 Dec 6, 2024
406e7f9
remove unused code
chunyu3 Dec 6, 2024
a143f0a
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 6, 2024
a93c8b8
add validation of typespec project selection input box
chunyu3 Dec 8, 2024
4ba9a3a
transfer logs from spawn
chunyu3 Dec 8, 2024
ca87267
transport log out when execute command
chunyu3 Dec 9, 2024
a14b47e
validate the typespec project
chunyu3 Dec 9, 2024
5534466
remove executeCommand
chunyu3 Dec 9, 2024
92790d6
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 10, 2024
3a9886c
update pnpm-lock
chunyu3 Dec 10, 2024
7fec5be
add change log
chunyu3 Dec 10, 2024
bddc07b
resolve lint
chunyu3 Dec 10, 2024
8c36463
set package name instead of output dir
chunyu3 Dec 10, 2024
3b820b8
add emit code command
chunyu3 Dec 11, 2024
b3d794b
integrate server code and openapi generation
chunyu3 Dec 12, 2024
c5e28e1
remove unused interface
chunyu3 Dec 12, 2024
8b5ec56
refine the label text
chunyu3 Dec 12, 2024
3c333d9
add icon for start file
chunyu3 Dec 12, 2024
dfcc1fb
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 16, 2024
64af9ad
check dependency and resolve dependency conflict
chunyu3 Dec 17, 2024
416a8ce
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 17, 2024
21536fe
format
chunyu3 Dec 17, 2024
b592c14
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 17, 2024
c883353
remove unused code
chunyu3 Dec 17, 2024
6931980
refine text
chunyu3 Dec 18, 2024
0c8c284
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 18, 2024
86372ee
change the package install options
chunyu3 Dec 18, 2024
b121717
resolve comments
chunyu3 Dec 18, 2024
758ff38
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 18, 2024
7129527
remove options parameter
chunyu3 Dec 18, 2024
e96e073
refine text
chunyu3 Dec 18, 2024
9105874
remove dependency auto-install
chunyu3 Dec 18, 2024
6f49c5f
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 19, 2024
bae77bb
Merge branch 'generateSDK' of https://github.com/chunyu3/typespec int…
chunyu3 Dec 19, 2024
f70e9d0
resolve comments
chunyu3 Dec 19, 2024
e836b52
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 20, 2024
97d57de
Merge branch 'main' of https://github.com/microsoft/typespec into gen…
chunyu3 Dec 23, 2024
8dc67ec
resolve comments
chunyu3 Dec 24, 2024
ee763ab
add progress for long running operations
chunyu3 Dec 24, 2024
792ec1c
remove emit to vscode-cmd folder
chunyu3 Dec 24, 2024
95dcef6
Merge branch 'main' into generateSDK
chunyu3 Dec 24, 2024
99c9ad0
refine the logger call
chunyu3 Dec 24, 2024
b2e27ca
submit comment every time
chunyu3 Dec 24, 2024
3b52923
revert try-it comment update
chunyu3 Dec 24, 2024
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
7 changes: 7 additions & 0 deletions .chronus/changes/generateSDK-2024-11-10-10-45-35.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- typespec-vscode
---

integrate client SDK generation
8 changes: 8 additions & 0 deletions packages/typespec-vscode/icons/client.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/typespec-vscode/icons/dotnet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/typespec-vscode/icons/java.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/typespec-vscode/icons/javascript.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions packages/typespec-vscode/icons/openapi3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/typespec-vscode/icons/python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions packages/typespec-vscode/icons/schema.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions packages/typespec-vscode/icons/server.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions packages/typespec-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,79 @@
],
"default": "off",
"description": "Define whether/how the TypeSpec language server should send traces to client. For the traces to show properly in vscode Output, make sure 'Log Level' is also set to 'Trace' so that they won't be filtered at client side, which can be set through 'Developer: Set Log Level...' command."
},
"typespec.generateCode.emitters": {
"scope": "window",
"type": "array",
"items": {
"type": "object",
"properties": {
"language": {
"type": "string",
"enum": [
"DotNet",
"Java",
"JavaScript",
"Python",
"Go",
"OpenAPI3",
"ProtoBuf",
"JsonSchema"
],
"description": "Define the language the emitter will emit."
},
"package": {
"type": "string",
"description": "Define the emitter package.\n\nExample (with version): @typespec/[email protected]\n\nExample (without version): @typespec/http-client-csharp"
},
"kind": {
"type": "string",
"enum": [
"client",
"server",
"schema"
],
"description": "Define the emitter kind."
}
}
},
"default": [
{
"language": "DotNet",
"package": "@typespec/http-client-csharp",
"kind": "client"
},
{
"language": "Java",
"package": "@typespec/http-client-java",
"kind": "client"
},
{
"language": "JavaScript",
"package": "@azure-tools/typespec-ts",
"kind": "client"
},
{
"language": "Python",
"package": "@typespec/http-client-python",
"kind": "client"
},
{
"language": "DotNet",
"package": "@typespec/http-server-csharp",
"kind": "server"
},
{
"language": "JavaScript",
"package": "@typespec/http-server-javascript",
"kind": "server"
},
{
"language": "OpenAPI3",
"package": "@typespec/openapi3",
"kind": "schema"
}
]
}
}
}
Expand Down Expand Up @@ -141,6 +214,11 @@
"title": "Show Output Channel",
"category": "TypeSpec"
},
{
"command": "typespec.generateCode",
"title": "Generate from TypeSpec",
"category": "TypeSpec"
},
{
"command": "typespec.createProject",
"title": "Create TypeSpec Project",
Expand All @@ -152,6 +230,22 @@
"category": "TypeSpec"
}
],
"menus": {
"explorer/context": [
{
"command": "typespec.generateCode",
"when": "explorerResourceIsFolder || resourceLangId == typespec",
"group": "code_generation"
}
],
"editor/context": [
{
"command": "typespec.generateCode",
"when": "resourceLangId == typespec",
"group": "code_generation"
}
]
},
"semanticTokenScopes": [
{
"scopes": {
Expand Down
1 change: 1 addition & 0 deletions packages/typespec-vscode/src/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const StartFileName = "main.tsp";
chunyu3 marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions packages/typespec-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
SettingName,
} from "./types.js";
import { createTypeSpecProject } from "./vscode-cmd/create-tsp-project.js";
import { emitCode } from "./vscode-cmd/emit-code/emit-code.js";
import { installCompilerGlobally } from "./vscode-cmd/install-tsp-compiler.js";

let client: TspLanguageClient | undefined;
Expand Down Expand Up @@ -44,6 +45,20 @@ export async function activate(context: ExtensionContext) {
}),
);

/* emit command. */
context.subscriptions.push(
commands.registerCommand(CommandName.GenerateCode, async (uri: vscode.Uri) => {
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Window,
title: "Generate from TypeSpec...",
cancellable: false,
},
async () => await emitCode(context, uri),
);
}),
);

context.subscriptions.push(
commands.registerCommand(
CommandName.RestartServer,
Expand Down
Loading
Loading