From 678750b98fc77be127f45fa92df8ca4ce41357a3 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Mon, 27 May 2019 14:00:19 -0400 Subject: [PATCH] fix(nx): set generated app to default app if none is set --- packages/node/src/schematics/application/application.spec.ts | 2 ++ packages/node/src/schematics/application/application.ts | 2 ++ packages/react/src/schematics/application/application.spec.ts | 1 + packages/react/src/schematics/application/application.ts | 3 +++ packages/web/src/schematics/application/application.spec.ts | 1 + packages/web/src/schematics/application/application.ts | 3 +++ 6 files changed, 12 insertions(+) diff --git a/packages/node/src/schematics/application/application.spec.ts b/packages/node/src/schematics/application/application.spec.ts index 8532d7c9d2b0d..6b519ff1e605f 100644 --- a/packages/node/src/schematics/application/application.spec.ts +++ b/packages/node/src/schematics/application/application.spec.ts @@ -53,6 +53,7 @@ describe('app', () => { }) ); expect(angularJson.projects['my-node-app-e2e']).toBeUndefined(); + expect(angularJson.defaultProject).toEqual('my-node-app'); }); it('should update nx.json', async () => { @@ -110,6 +111,7 @@ describe('app', () => { 'apps/my-dir/my-node-app' ); expect(angularJson.projects['my-dir-my-node-app-e2e']).toBeUndefined(); + expect(angularJson.defaultProject).toEqual('my-dir-my-node-app'); }); it('should update nx.json', async () => { diff --git a/packages/node/src/schematics/application/application.ts b/packages/node/src/schematics/application/application.ts index 540b02223519e..17717e20123af 100644 --- a/packages/node/src/schematics/application/application.ts +++ b/packages/node/src/schematics/application/application.ts @@ -96,6 +96,8 @@ function updateAngularJson(options: NormalizedSchema): Rule { project.architect.lint = getLintConfig(project); angularJson.projects[options.name] = project; + angularJson.defaultProject = angularJson.defaultProject || options.name; + return angularJson; }); } diff --git a/packages/react/src/schematics/application/application.spec.ts b/packages/react/src/schematics/application/application.spec.ts index c13157627a472..e18352857feef 100644 --- a/packages/react/src/schematics/application/application.spec.ts +++ b/packages/react/src/schematics/application/application.spec.ts @@ -21,6 +21,7 @@ describe('app', () => { expect(angularJson.projects['my-app-e2e'].root).toEqual( 'apps/my-app-e2e' ); + expect(angularJson.defaultProject).toEqual('my-app'); }); it('should update nx.json', async () => { diff --git a/packages/react/src/schematics/application/application.ts b/packages/react/src/schematics/application/application.ts index 02d6ea28a0323..97f051cca7ddf 100644 --- a/packages/react/src/schematics/application/application.ts +++ b/packages/react/src/schematics/application/application.ts @@ -182,6 +182,9 @@ function addProject(options: NormalizedSchema): Rule { schematics: {}, architect }; + + json.defaultProject = json.defaultProject || options.projectName; + return json; }); } diff --git a/packages/web/src/schematics/application/application.spec.ts b/packages/web/src/schematics/application/application.spec.ts index 3ffce0c504715..3a3c64a58aa80 100644 --- a/packages/web/src/schematics/application/application.spec.ts +++ b/packages/web/src/schematics/application/application.spec.ts @@ -21,6 +21,7 @@ describe('app', () => { expect(angularJson.projects['my-app-e2e'].root).toEqual( 'apps/my-app-e2e' ); + expect(angularJson.defaultProject).toEqual('my-app'); }); it('should update nx.json', async () => { diff --git a/packages/web/src/schematics/application/application.ts b/packages/web/src/schematics/application/application.ts index 8089290ce4348..89e10dc1ef449 100644 --- a/packages/web/src/schematics/application/application.ts +++ b/packages/web/src/schematics/application/application.ts @@ -139,6 +139,9 @@ function addProject(options: NormalizedSchema): Rule { schematics: {}, architect }; + + json.defaultProject = json.defaultProject || options.projectName; + return json; }); }