Skip to content

Commit 528701b

Browse files
committed
feat: introduce --sample flag for ng new --shared
1 parent 0249f06 commit 528701b

28 files changed

+198
-54
lines changed

src/ng-new/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const parseToSharedOptions = (options: NgNewOptions): SharedOptions => {
3737
sourceDir: options.sourceDir || 'src',
3838
prefix: options.prefix,
3939
style: options.style,
40-
theme: options.theme
40+
theme: options.theme,
41+
sample: options.sample,
4142
};
4243
}
4344

src/ng-new/schema.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ export interface Schema {
2727
* Specifies whether the new application has webpack set up.
2828
*/
2929
webpack: boolean;
30+
/**
31+
* Specifies whether a sample master detail should be generated.
32+
*/
33+
sample: boolean;
3034
}

src/ng-new/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
"type": "boolean",
4848
"description": "Specifies whether the new application has webpack set up.",
4949
"default": true
50+
},
51+
"sample": {
52+
"type": "boolean",
53+
"description": "Specifies whether a sample master detail should be generated.",
54+
"default": false
5055
}
5156
},
5257
"required": [
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { NgModule } from '@angular/core';
22
import { NativeScriptRouterModule } from 'nativescript-angular/router';
3-
import { ROUTES } from './app.routes';
3+
import { routes } from './app.routes';
44

55
@NgModule({
6-
imports: [NativeScriptRouterModule.forRoot(ROUTES)],
6+
imports: [NativeScriptRouterModule.forRoot(routes)],
77
exports: [NativeScriptRouterModule]
88
})
99
export class AppRoutingModule { }
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { NgModule } from '@angular/core';
2-
import { Routes, RouterModule } from '@angular/router';
3-
import { ROUTES } from './app.routes';
2+
import { RouterModule } from '@angular/router';
3+
import { routes } from './app.routes';
44

55
@NgModule({
6-
imports: [RouterModule.forRoot(ROUTES)],
6+
imports: [RouterModule.forRoot(routes)],
77
exports: [RouterModule]
88
})
99
export class AppRoutingModule { }

src/ng-new/shared/_files/__sourcedir__/app/app.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ import { Component } from '@angular/core';
66
styleUrls: ['./app.component.<%= style %>']
77
})
88
export class AppComponent {
9-
title = '<%= name %>';
109
}

src/ng-new/shared/_files/__sourcedir__/app/app.module.tns.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
33

44
import { AppRoutingModule } from './app-routing.module';
55
import { AppComponent } from './app.component';
6-
7-
import { BarcelonaModule } from './barcelona/barcelona.module';
6+
import { HomeComponent } from './home/home.component';
7+
<% if (sample) { %>
8+
import { BarcelonaModule } from './barcelona/barcelona.module';<% } %>
89

910
// Uncomment and add to NgModule imports if you need to use two-way binding
1011
// import { NativeScriptFormsModule } from "nativescript-angular/forms";
@@ -13,21 +14,17 @@ import { BarcelonaModule } from './barcelona/barcelona.module';
1314
// import { NativeScriptHttpClientModule } from 'nativescript-angular/http-client';
1415

1516
@NgModule({
16-
bootstrap: [
17-
AppComponent
17+
declarations: [
18+
AppComponent,
19+
HomeComponent,
1820
],
1921
imports: [
2022
NativeScriptModule,
21-
AppRoutingModule,
22-
BarcelonaModule
23-
],
24-
declarations: [
25-
AppComponent
26-
],
27-
providers: [
23+
AppRoutingModule,<% if (sample) { %>
24+
BarcelonaModule,<% } %>
2825
],
29-
schemas: [
30-
NO_ERRORS_SCHEMA
31-
]
26+
providers: [],
27+
bootstrap: [AppComponent],
28+
schemas: [NO_ERRORS_SCHEMA]
3229
})
3330
export class AppModule { }

src/ng-new/shared/_files/__sourcedir__/app/app.module.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ import { BrowserModule } from '@angular/platform-browser';
33

44
import { AppRoutingModule } from './app-routing.module';
55
import { AppComponent } from './app.component';
6-
import { BarcelonaModule } from './barcelona/barcelona.module';
6+
import { HomeComponent } from './home/home.component';
7+
<% if (sample) { %>
8+
import { BarcelonaModule } from './barcelona/barcelona.module';<% } %>
79

810
@NgModule({
911
declarations: [
1012
AppComponent,
13+
HomeComponent,
1114
],
1215
imports: [
1316
BrowserModule,
14-
AppRoutingModule,
15-
BarcelonaModule
17+
AppRoutingModule,<% if (sample) { %>
18+
BarcelonaModule,<% } %>
1619
],
1720
providers: [],
1821
bootstrap: [AppComponent]
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { Routes } from '@angular/router';
22

3-
export const ROUTES: Routes = [
4-
{ path: '', redirectTo: '/players', pathMatch: 'full' },
3+
import { HomeComponent } from './home/home.component';
4+
5+
export const routes: Routes = [
6+
{
7+
path: '',
8+
redirectTo: <% if (sample) { %>'/players'<% } else { %>'/home'<% } %>,
9+
pathMatch: 'full',
10+
},
11+
{
12+
path: 'home',
13+
component: HomeComponent,
14+
},
515
];

src/ng-new/shared/_files/__sourcedir__/app/home/home.component.__style__

Whitespace-only changes.

0 commit comments

Comments
 (0)