fix(remix): update app generator with valid package.json without Prettier (#29218)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
If you don't have Prettier installed, then `nx g @nx/remix:app
apps/myapp` will generate a `package.json` with trailing comma, and `npm
install` fails.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
`package.json` should be valid without Prettier.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jack Hsu 2024-12-05 10:27:53 -05:00 committed by GitHub
parent 625d8f3095
commit f89fca98f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 4 deletions

View File

@ -316,8 +316,10 @@ describe('Remix Application', () => {
}); });
describe('TS solution setup', () => { describe('TS solution setup', () => {
it('should add project references when using TS solution', async () => { let tree: Tree;
const tree = createTreeWithEmptyWorkspace();
beforeEach(() => {
tree = createTreeWithEmptyWorkspace();
updateJson(tree, 'package.json', (json) => { updateJson(tree, 'package.json', (json) => {
json.workspaces = ['packages/*', 'apps/*']; json.workspaces = ['packages/*', 'apps/*'];
return json; return json;
@ -333,7 +335,9 @@ describe('Remix Application', () => {
files: [], files: [],
references: [], references: [],
}); });
});
it('should add project references when using TS solution', async () => {
await applicationGenerator(tree, { await applicationGenerator(tree, {
directory: 'myapp', directory: 'myapp',
e2eTestRunner: 'playwright', e2eTestRunner: 'playwright',
@ -523,6 +527,20 @@ describe('Remix Application', () => {
} }
`); `);
}); });
it('should generate valid package.json without formatting', async () => {
await applicationGenerator(tree, {
directory: 'myapp',
e2eTestRunner: 'playwright',
unitTestRunner: 'jest',
addPlugin: true,
skipFormat: true,
});
expect(() =>
JSON.parse(tree.read('myapp/package.json', 'utf-8'))
).not.toThrow();
});
}); });
}); });

View File

@ -24,8 +24,7 @@
<%_ if (name !== projectName) { _%> <%_ if (name !== projectName) { _%>
"name": "<%= name %>",<%_ } _%> "name": "<%= name %>",<%_ } _%>
"projectType": "application", "projectType": "application",
"sourceRoot": "<%- projectRoot %>", "sourceRoot": "<%- projectRoot %>"<%_ if (parsedTags?.length) { _%>,
<%_ if (parsedTags?.length) { _%>
"tags": <%- JSON.stringify(parsedTags) %> "tags": <%- JSON.stringify(parsedTags) %>
<%_ } _%> <%_ } _%>
}<% } %> }<% } %>