From 9d360162397cc01de0ff867d45cc376e00575d87 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Wed, 23 May 2018 11:21:16 -0500 Subject: [PATCH] fix(Effects): Added defaults for ng-add schematic --- modules/effects/schematics/ng-add/index.spec.ts | 10 ++++------ modules/effects/schematics/ng-add/index.ts | 6 +++--- modules/effects/schematics/ng-add/schema.json | 9 +++------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/effects/schematics/ng-add/index.spec.ts b/modules/effects/schematics/ng-add/index.spec.ts index 53ebc7d659..fe93cd0270 100644 --- a/modules/effects/schematics/ng-add/index.spec.ts +++ b/modules/effects/schematics/ng-add/index.spec.ts @@ -22,7 +22,7 @@ describe('Effect ng-add Schematic', () => { skipPackageJson: false, project: 'bar', spec: true, - module: undefined, + module: 'app', flat: false, group: false, }; @@ -66,14 +66,12 @@ describe('Effect ng-add Schematic', () => { ).toBeGreaterThanOrEqual(0); }); - it('should not be provided by default', () => { + it('should be provided by default', () => { const options = { ...defaultOptions }; const tree = schematicRunner.runSchematic('ng-add', options, appTree); const content = tree.readContent(`${projectPath}/src/app/app.module.ts`); - expect(content).not.toMatch( - /import { FooEffects } from '.\/foo\/foo.effects'/ - ); + expect(content).toMatch(/import { FooEffects } from '.\/foo\/foo.effects'/); }); it('should import into a specified module', () => { @@ -112,7 +110,7 @@ describe('Effect ng-add Schematic', () => { }); it('should register the root effect in the provided module', () => { - const options = { ...defaultOptions, module: 'app.module.ts' }; + const options = { ...defaultOptions }; const tree = schematicRunner.runSchematic('ng-add', options, appTree); const content = tree.readContent(`${projectPath}/src/app/app.module.ts`); diff --git a/modules/effects/schematics/ng-add/index.ts b/modules/effects/schematics/ng-add/index.ts index 6766636fb4..d63ce28aee 100644 --- a/modules/effects/schematics/ng-add/index.ts +++ b/modules/effects/schematics/ng-add/index.ts @@ -136,9 +136,6 @@ export default function(options: RootEffectOptions): Rule { ]); return chain([ - options && options.skipPackageJson - ? noop() - : addNgRxEffectsToPackageJson(), branchAndMerge( chain([ filter( @@ -150,6 +147,9 @@ export default function(options: RootEffectOptions): Rule { mergeWith(templateSource), ]) ), + options && options.skipPackageJson + ? noop() + : addNgRxEffectsToPackageJson(), ])(host, context); }; } diff --git a/modules/effects/schematics/ng-add/schema.json b/modules/effects/schematics/ng-add/schema.json index d22ac93d1d..5becb4469b 100644 --- a/modules/effects/schematics/ng-add/schema.json +++ b/modules/effects/schematics/ng-add/schema.json @@ -7,10 +7,7 @@ "name": { "description": "The name of the effect.", "type": "string", - "$default": { - "$source": "argv", - "index": 0 - } + "default": "App" }, "skipPackageJson": { "type": "boolean", @@ -21,7 +18,7 @@ "path": { "type": "string", "format": "path", - "description": "The path to create the component.", + "description": "The path to create the effect.", "visible": false }, "flat": { @@ -36,7 +33,7 @@ }, "module": { "type": "string", - "default": "", + "default": "app", "description": "Allows specification of the declaring module.", "alias": "m", "subtype": "filepath"