-
Notifications
You must be signed in to change notification settings - Fork 81
Add an option to generate a minimal project with Yeoman #1967
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
base: main
Are you sure you want to change the base?
Conversation
We are open to suggestions and changes. We made choices based on our needs, but we are unsure what would be preferred here. I'm mainly thinking about the CLI, which might not be necessary for a minimal project, and the commented code, which could be considered unnecessary. |
packages/generator-langium/templates/packages/cli-minimal/src/generator.ts
Outdated
Show resolved
Hide resolved
I need some help please. I'm looking into this pipeline issue, but I don't understand how to resolve it. On my branch merged with an up-to-date
|
@JMazat It seems like you merged |
842b90b
to
c08be17
Compare
c08be17
to
815f9bd
Compare
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.
Aside from #1967 (comment) and my comment (see below), I think this looks quite good. We can always iterate on that after merge.
815f9bd
to
a0f5e59
Compare
The `.js` extension is no longer imposed when generating a file. Now, the `destination` parameter is required and indicates where to generate the file, and with what exension. The `filePath` parameter is renamed as `source` to better fit the new behaviour and make the code more readable.
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.
Great! Just two details below.
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.
Thanks - cli-example/src/generator.ts
and cli-example/src/main.ts
need the new variable for the entry rule name, too.
This PR introduces in
generator-langium
, the ability to generate a minimal project instead of the current example "Hello World" project.The aim of this PR is to skip the tedious process of removing from the currently generated project, anything that is irrelevant to the target language. This speeds up the setup process and avoids the need for error-prone refactoring.
This is the intended fix for ticket: #1764.
What is new
We added questions to be able to choose between the minimal and example projects, without changing the current default behaviour:
Default:
Yes
Default:
Model
This is only shown if the user answered
No
to the above question.This lets the user choose their own
entry
name and skip the refactoring that's currently needed.The generated minimal project is a cleaned-up, de-contextualised version of the example project. It contains TODOs throughout the files to guide the user and provide useful resources, and it should compile as it is.
We can also find commented (non-compiling) code that can be used to quickly implement features and tests that are often needed.
If the user adds the CLI project, a minimal CLI project will also be generated.
How it's done
We decided to keep it simple and use what had already been done as much as possible.
The templates
language
andcli
have been renamed tolanguage-example
andcli-example
. Separate folders,language-minimal
andcli-minimal
, contain the base files needed to generate the minimal projects. As no files are shared between these projects, they can be maintained independently and used with the current implementation.Programmatically we simply change the source folders to be copied based on the user's answers. We have added a new tag
<%= EntryName %>
inlanguage-minimal
that is replaced by the chosenentry
name.