This repository was archived by the owner on Apr 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +111
-0
lines changed
packages/schematics/angular Expand file tree Collapse file tree 6 files changed +111
-0
lines changed Original file line number Diff line number Diff line change 1919 "factory" : " ./enum" ,
2020 "description" : " Create an enumeration." ,
2121 "schema" : " ./enum/schema.json"
22+ },
23+ "module" : {
24+ "factory" : " ./module" ,
25+ "description" : " Create an Angular module." ,
26+ "schema" : " ./module/schema.json"
2227 }
2328 }
2429}
Original file line number Diff line number Diff line change 1+ import { NgModule } from '@angular/core' ;
2+ import { Routes , RouterModule } from '@angular/router' ;
3+
4+ const routes : Routes = [ ] ;
5+
6+ @NgModule ( {
7+ imports : [ RouterModule . forChild ( routes ) ] ,
8+ exports : [ RouterModule ]
9+ } )
10+ export class < %= classify ( name ) % > RoutingModule { }
Original file line number Diff line number Diff line change 1+ import { < %= classify ( name ) % > Module } from './<%= dasherize(name) %>.module' ;
2+
3+ describe ( '<%= classify(name) %>Module' , ( ) => {
4+ let < %= camelize ( name ) % > Module : < %= classify ( name ) % > Module ;
5+
6+ beforeEach ( ( ) => {
7+ < %= camelize ( name ) % > Module = new < %= classify ( name ) % > Module ( ) ;
8+ } ) ;
9+
10+ it ( 'should create an instance' , ( ) => {
11+ expect ( < %= camelize ( name ) % > Module ) . toBeTruthy ( ) ;
12+ } ) ;
13+ } ) ;
Original file line number Diff line number Diff line change 1+ import { NgModule } from '@angular/core' ;
2+ import { CommonModule } from '@angular/common' ; < % if ( routing ) { % >
3+
4+ import { < %= classify ( name ) % > RoutingModule } from './<%= dasherizedModuleName %>-routing.module' ; < % } % >
5+
6+ @NgModule ( {
7+ imports : [
8+ CommonModule < % if ( routing ) { % > ,
9+ < %= classify ( name ) % > RoutingModule < % } % >
10+ ] ,
11+ declarations : [ ]
12+ } )
13+ export class < %= classify ( name ) % > Module { }
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright Google Inc. All Rights Reserved.
4+ *
5+ * Use of this source code is governed by an MIT-style license that can be
6+ * found in the LICENSE file at https://angular.io/license
7+ */
8+
9+ import {
10+ Rule ,
11+ apply ,
12+ branchAndMerge ,
13+ chain ,
14+ filter ,
15+ mergeWith ,
16+ move ,
17+ noop ,
18+ template ,
19+ url
20+ } from '@angular-devkit/schematics' ;
21+ import * as stringUtils from '../strings' ;
22+
23+
24+ export default function ( options : any ) : Rule {
25+ const templateSource = apply ( url ( './files' ) , [
26+ options . spec ? noop ( ) : filter ( path => ! path . endsWith ( '.spec.ts' ) ) ,
27+ options . routing ? noop ( ) : filter ( path => ! path . endsWith ( '-routing.module.ts' ) ) ,
28+ template ( {
29+ ...stringUtils ,
30+ ...options
31+ } ) ,
32+ move ( options . sourceDir )
33+ ] ) ;
34+
35+ return chain ( [
36+ branchAndMerge ( chain ( [
37+ mergeWith ( templateSource )
38+ ] ) )
39+ ] ) ;
40+ }
Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " http://json-schema.org/schema" ,
3+ "id" : " SchematicsAngularModule" ,
4+ "title" : " Angular Module Options Schema" ,
5+ "type" : " object" ,
6+ "properties" : {
7+ "name" : {
8+ "type" : " string"
9+ },
10+ "path" : {
11+ "type" : " string" ,
12+ "default" : " app"
13+ },
14+ "sourceDir" : {
15+ "type" : " string" ,
16+ "default" : " src"
17+ },
18+ "routing" : {
19+ "type" : " boolean" ,
20+ "default" : false
21+ },
22+ "spec" : {
23+ "type" : " boolean" ,
24+ "default" : true
25+ }
26+ },
27+ "required" : [
28+ " name"
29+ ]
30+ }
You can’t perform that action at this time.
0 commit comments