Skip to content

feat(page): add --create-module option #220

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion schematics/page/index.ts
Original file line number Diff line number Diff line change
@@ -163,6 +163,7 @@ export default function(options: PageOptions): Rule {

const templateSource = apply(url('./files'), [
options.spec ? noop() : filter(p => !p.endsWith('.spec.ts')),
options.createModule ? noop() : filter(p => !p.endsWith('.module.ts')),

Choose a reason for hiding this comment

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

It would be nice if we could add some unit tests to validate these changes and keep align with existing behavior. :)

template({
...strings,
'if-flat': (s: string) => options.flat ? '' : s,
@@ -173,7 +174,7 @@ export default function(options: PageOptions): Rule {

return chain([
branchAndMerge(chain([
addRouteToNgModule(options),
options.createModule ? addRouteToNgModule(options) : noop(),
mergeWith(templateSource),
])),
])(host, context);
1 change: 1 addition & 0 deletions schematics/page/schema.d.ts
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ export interface Schema {
spec?: boolean;
flat?: boolean;
selector?: string;
createModule?: boolean;
module?: string;
routePath?: string;
}
5 changes: 5 additions & 0 deletions schematics/page/schema.json
Original file line number Diff line number Diff line change
@@ -59,6 +59,11 @@
"format": "html-selector",
"description": "The selector to use for the page"
},
"createModule": {
"type": "boolean",
"description": "Allows creating an NgModule for the page",
"default": true

Choose a reason for hiding this comment

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

I think default should set to be false so that we can keep existing changes without breaking it.

},
"module": {
"type": "string",
"description": "Allows specification of the declaring module",