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

Added a config file generation feature #82

Merged
merged 6 commits into from
Oct 18, 2019
Merged

Conversation

NSeydoux
Copy link
Contributor

Resolves #75

The artifact generator now can receive two main commands: generate (to generate artifacts), and init, to initialize a default config file. A lot of code moved around in index.js, but actually the previous functionalities are preserved under the node index generate command, which required some refactoring. Using yargs commands prepares for the addition of new functionalities, such as starting/stopping the daemon (see #74)

The artifact generator now can receive two main commands: generate (to generate artifacts), and init, to initialize a default config file.
.gitignore Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
Copy link
Contributor

@pmcb55 pmcb55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a number of small tidy ups.

- Fixed grammatical mistakes in the template
- Removed FIXME comments
- Added comment at the top of the template to give details about generation. This required moving some code from ArtifactGenerator.js to App.js to prevent redundancy
@NSeydoux NSeydoux requested a review from pmcb55 October 11, 2019 12:40
The generator successfully does nothing when running on a freshly generated yaml file.
src/App.js Outdated Show resolved Hide resolved
src/App.test.js Outdated Show resolved Hide resolved
artifactVersion: '1.0.0',
moduleNamePrefix: '@lit/generated-vocab-',
});
await expect(artifactGenerator.generate()).rejects.toThrow(NoVocabularyProvidedError);
Copy link
Contributor

@pmcb55 pmcb55 Oct 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the error class, and just check that the exception message contained the name of the file and the string 'No vocabularies found'.
Shouldn't this assertion also contain a helpful text message on failure too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand what you mean in your last sentence. I added comments, but I did not find a way to add a comment displayed in case of failure to expect(...) as we do it in JUnit. I might lack understanding of the test framework: what is the relation between Jest and Jasmine ? Because it seems that the function .withContext(), provided by Jasmine, would do the trick, but it is not documented in jest.

Copy link
Contributor

@pmcb55 pmcb55 Oct 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the answer here: https://stackoverflow.com/questions/45678706/how-to-provide-chai-expect-with-custom-error-message-for-mocha-unit-test (i.e. optional message param to expect()).
Ah wait, seems that was a Chai feature, and Jest doesn't support it the same way. Hhhmmmm.... let me look into it more.
I haven't been doing it (i.e. adding a descriptive error message), but for all new code, I think we should add one (as we're now doing for Java).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be a known issue with Jest: jestjs/jest#3293
Seems adding 'https://github.com/mattphillips/jest-expect-message' will work, and make it work like Chai (and JUnit) - so maybe add a ticket to add that later (i.e. on the Wishlist!).

- Removed commented out blocks
- Improved English in some comments
@NSeydoux NSeydoux requested a review from pmcb55 October 17, 2019 15:29
Copy link
Contributor

@pmcb55 pmcb55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor test assertion tidy-up, otherwise LGTM.

- Only invoke generate once
- Use a constant instead of copying the file name
@NSeydoux NSeydoux merged commit fc78daf into develop Oct 18, 2019
@NSeydoux NSeydoux deleted the feature/75_yaml-init branch October 18, 2019 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[2pt] Add a YAML file generator to the CLI
2 participants