From f89fca98f3083a7a724d54b79d1f38536d61f6ac Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Thu, 5 Dec 2024 10:27:53 -0500 Subject: [PATCH] fix(remix): update app generator with valid package.json without Prettier (#29218) ## Current Behavior 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 `package.json` should be valid without Prettier. ## Related Issue(s) Fixes # --- .../application/application.impl.spec.ts | 22 +++++++++++++++++-- .../files/ts-solution/package.json__tmpl__ | 3 +-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/remix/src/generators/application/application.impl.spec.ts b/packages/remix/src/generators/application/application.impl.spec.ts index 47feaf0a0b..cc510d65b8 100644 --- a/packages/remix/src/generators/application/application.impl.spec.ts +++ b/packages/remix/src/generators/application/application.impl.spec.ts @@ -316,8 +316,10 @@ describe('Remix Application', () => { }); describe('TS solution setup', () => { - it('should add project references when using TS solution', async () => { - const tree = createTreeWithEmptyWorkspace(); + let tree: Tree; + + beforeEach(() => { + tree = createTreeWithEmptyWorkspace(); updateJson(tree, 'package.json', (json) => { json.workspaces = ['packages/*', 'apps/*']; return json; @@ -333,7 +335,9 @@ describe('Remix Application', () => { files: [], references: [], }); + }); + it('should add project references when using TS solution', async () => { await applicationGenerator(tree, { directory: 'myapp', 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(); + }); }); }); diff --git a/packages/remix/src/generators/application/files/ts-solution/package.json__tmpl__ b/packages/remix/src/generators/application/files/ts-solution/package.json__tmpl__ index 06b3362f5c..594f4bd31a 100644 --- a/packages/remix/src/generators/application/files/ts-solution/package.json__tmpl__ +++ b/packages/remix/src/generators/application/files/ts-solution/package.json__tmpl__ @@ -24,8 +24,7 @@ <%_ if (name !== projectName) { _%> "name": "<%= name %>",<%_ } _%> "projectType": "application", - "sourceRoot": "<%- projectRoot %>", - <%_ if (parsedTags?.length) { _%> + "sourceRoot": "<%- projectRoot %>"<%_ if (parsedTags?.length) { _%>, "tags": <%- JSON.stringify(parsedTags) %> <%_ } _%> }<% } %>