-
Notifications
You must be signed in to change notification settings - Fork 226
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
Template for setting up an emitter #2736
Template for setting up an emitter #2736
Conversation
Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status): Website: https://tspwebsitepr.z22.web.core.windows.net/prs/2736/ |
…rin/typespec into feature/library-init
You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/2736/ Check the website changes at https://tspwebsitepr.z22.web.core.windows.net/prs/2736/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to get this in. Can we update the doc for getting started with an emitter to reference the steps necessary?
import { EmitContext, emitFile, resolvePath } from "@typespec/compiler"; | ||
|
||
export async function $onEmit(context: EmitContext) { | ||
if (!context.program.compilerOptions.noEmit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might it be worth putting something super simple here with the emitter framework, like just printing out model names or some such?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure I really wanted people to try to use the emitter framework today as there is still a lot of issues with it.
I might take a stab during the holidays at solving all those issues Travis and I got when using it and after I think we could setup the boilperplate for the emitter framework usage.
} from "@typespec/compiler/testing"; | ||
import { TestLibrary } from "../src/testing/index.js"; | ||
|
||
export async function createMyTestHost() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find these names to be a little awkward with "my" in them, could maybe template in the emitter name in place of "my"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that would be great but I think our template engine right now doesn’t have this capability to change casing. I can do a follow up pr that does
Add a new template for scaffolding an emitter
emitter-ts
template setup the following:Change to the init area
--template
cli option to allow selecting the template without a prompt.Added e2e test for templates
Scafold the template and then run commands like
npm install
,npm run build
,npm run test
, etc. to make sure everything is done correctly.This is quite costly so might be worth separating in a different step