Skip to content

Commit 5fca882

Browse files
authored
Merge pull request #2655 from angular-fullstack/feat/awk34-dev
Various canary features / fixes
2 parents 96086d1 + ad585d3 commit 5fca882

29 files changed

+139
-179
lines changed

Diff for: src/generators/app/USAGE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Description:
2-
Creates a Full-Stack AngularJS + Node app
2+
Creates a Full-Stack Angular + Node app
33

44
Example:
55
yo angular-fullstack

Diff for: src/generators/app/index.js

+32-30
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class Generator extends Base {
158158
}, {
159159
type: 'confirm',
160160
name: 'flow',
161-
default: false,
161+
default: true,
162162
message: 'Would you like to use Flow types with Babel?',
163163
when: answers => answers.transpiler === 'babel'
164164
}, {
@@ -466,35 +466,37 @@ export class Generator extends Base {
466466
const codeshiftStream = tap(function(file, t) {
467467
var contents = file.contents.toString();
468468

469-
// remove `implements Foo` from class declarations
470-
contents = jscodeshift(contents)
471-
.find(jscodeshift.ClassDeclaration)
472-
.forEach(path => {
473-
path.value.implements = null;
474-
})
475-
.toSource();
476-
477-
// remove any type annotations
478-
contents = jscodeshift(contents)
479-
.find(jscodeshift.TypeAnnotation)
480-
.remove()
481-
.toSource();
482-
contents = jscodeshift(contents)
483-
.find(jscodeshift.GenericTypeAnnotation)
484-
.remove()
485-
.toSource();
486-
487-
// remove any `type Foo = { .. }` declarations
488-
contents = jscodeshift(contents)
489-
.find(jscodeshift.TypeAlias)
490-
.remove()
491-
.toSource();
492-
493-
// remove any flow directive comments
494-
contents = jscodeshift(contents)
495-
.find(jscodeshift.Comment, path => path.type === 'CommentLine' && path.value.includes('@flow'))
496-
.forEach(path => path.prune())
497-
.toSource();
469+
if(!flow) {
470+
// remove `implements Foo` from class declarations
471+
contents = jscodeshift(contents)
472+
.find(jscodeshift.ClassDeclaration)
473+
.forEach(path => {
474+
path.value.implements = null;
475+
})
476+
.toSource();
477+
478+
// remove any type annotations
479+
contents = jscodeshift(contents)
480+
.find(jscodeshift.TypeAnnotation)
481+
.remove()
482+
.toSource();
483+
contents = jscodeshift(contents)
484+
.find(jscodeshift.GenericTypeAnnotation)
485+
.remove()
486+
.toSource();
487+
488+
// remove any `type Foo = { .. }` declarations
489+
contents = jscodeshift(contents)
490+
.find(jscodeshift.TypeAlias)
491+
.remove()
492+
.toSource();
493+
494+
// remove any flow directive comments
495+
contents = jscodeshift(contents)
496+
.find(jscodeshift.Comment, path => path.type === 'CommentLine' && path.value.includes('@flow'))
497+
.forEach(path => path.prune())
498+
.toSource();
499+
}
498500

499501
file.contents = new Buffer(contents);
500502
});

Diff for: src/test/fixtures/.yo-rc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"filters": {
1616
"js": true,
1717
"babel": true,
18-
"flow": false,
18+
"flow": true,
1919
"html": true,
2020
"sass": true,
2121
"ngroute": true,

Diff for: src/test/get-expected-files.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export function app(options) {
9090
'.babelrc',
9191
'.buildignore',
9292
'.editorconfig',
93+
'.eslintignore',
9394
'.eslintrc',
9495
'.gitattributes',
9596
'.gitignore',
@@ -156,7 +157,6 @@ export function app(options) {
156157
if (options.auth) {
157158
files = files.concat([
158159
'client/app/account/account.module.' + script,
159-
'client/app/account/account.routes.' + script,
160160
'client/app/account/login/login.' + markup,
161161
'client/app/account/login/login.component.' + script,
162162
'client/app/account/settings/settings.' + markup,
@@ -167,7 +167,6 @@ export function app(options) {
167167
'client/app/admin/admin.' + stylesheet,
168168
'client/app/admin/admin.component.' + script,
169169
'client/app/admin/admin.module.' + script,
170-
'client/app/admin/admin.routes.' + script,
171170
'client/components/auth/auth.module.' + script,
172171
'client/components/auth/auth.service.' + script,
173172
'client/components/auth/interceptor.service.' + script,

Diff for: src/test/main.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
const defaultOptions = {
1818
buildtool: 'gulp',
1919
transpiler: 'babel',
20+
flow: true,
2021
markup: 'html',
2122
stylesheet: 'sass',
2223
router: 'ngroute',
@@ -263,6 +264,7 @@ describe('angular-fullstack:app', function() {
263264
var testOptions = {
264265
buildtool: 'gulp',
265266
transpiler: 'babel',
267+
flow: true,
266268
markup: 'pug',
267269
stylesheet: 'css',
268270
router: 'ngroute',

Diff for: templates/app/.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
client/components/socket/primus.js

Diff for: templates/app/_package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.0",
44
"main": "server/index.js",
55
"dependencies": {
6+
"compression": "^1.7.1",
67
"core-js": "^2.4.1",
78
"cors": "^2.8.1",
89
"express": "^4.13.3",
@@ -45,8 +46,7 @@
4546
"primus": "^7.0.1",
4647
"primus-emit": "^1.0.0",
4748
"uws": "^8.14.1",<% } %>
48-
"serve-favicon": "^2.3.0",
49-
"shrink-ray": "^0.1.3"
49+
"serve-favicon": "^2.3.0"
5050
},
5151
"devDependencies": {
5252
<%# CLIENT %>
@@ -213,6 +213,9 @@
213213
"npm": "^3.9.5"
214214
},
215215
"scripts": {
216+
"lint": "npm run lint:client && npm run lint:server",
217+
"lint:client": "eslint ./client/**/*.<%= scriptExt %> -c ./client/.eslintrc --ignore-pattern *.spec.<%= scriptExt %>",
218+
"lint:server": "eslint ./server/**/*.js -c ./server/.eslintrc --ignore-pattern *.spec.js --ignore-pattern *.integration.js",
216219
"test": "gulp test",
217220
"test:client": "karma start ./karma.conf.js --single-run",
218221
<%_ if(filters.flow) { -%>

Diff for: templates/app/client/.eslintrc(babel)

+6
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@
33
"env": {
44
"browser": true,
55
"commonjs": true
6+
},
7+
"globals": {
8+
"process": true
9+
},
10+
"rules": {
11+
"no-process-env": 0
612
}
713
}

Diff for: templates/app/client/app/account(auth)/account.module.js

-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import { RouterModule, Routes } from '@angular/router';<% } %>
88
<%_ if(filters.oauth) { -%>
99
import { DirectivesModule } from '../../components/directives.module';<% } %>
1010

11-
<%_ if(filters.uirouter) { -%>
12-
import { STATES } from './account.routes';<% } %>
13-
1411
import { LoginComponent } from './login/login.component';
1512
import { SettingsComponent } from './settings/settings.component';
1613
import { SignupComponent } from './signup/signup.component';
@@ -19,7 +16,6 @@ import { SignupComponent } from './signup/signup.component';
1916
const accountRoutes: Routes = [{
2017
path: 'login',
2118
component: LoginComponent,
22-
//data: { title: 'Home' }
2319
}, {
2420
path: 'settings',
2521
component: SettingsComponent,

Diff for: templates/app/client/app/account(auth)/account.routes.js

-42
This file was deleted.

Diff for: templates/app/client/app/account(auth)/settings/settings.component.js

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export class SettingsComponent {
3838
}
3939

4040
changePassword(form) {
41+
if(form.invalid) return;
42+
4143
this.submitted = true;
4244

4345
return this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)

Diff for: templates/app/client/app/account(auth)/signup/signup.component.js

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export class SignupComponent {
4747
}
4848

4949
register(form) {
50+
if(form.invalid) return;
51+
5052
this.submitted = true;
5153

5254
return this.AuthService.createUser({

Diff for: templates/app/client/app/admin(auth)/admin.module.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { NgModule } from '@angular/core';
2-
import { BrowserModule } from '@angular/platform-browser';
3-
<%_ if(filters.uirouter) { %>
4-
import { UIRouterModule } from 'ui-router-ng2';<% } %>
5-
<%_ if(filters.ngroute) { %>
2+
import { BrowserModule } from '@angular/platform-browser';<% if(filters.uirouter) { %>
3+
import { UIRouterModule } from 'ui-router-ng2';<% } %><% if(filters.ngroute) { %>
64
import { RouterModule, Routes } from '@angular/router';<% } %>
7-
5+
import { AuthGuard } from '../../components/auth/auth-guard.service';
86
import { AdminComponent } from './admin.component';
97

108
<%_ if(filters.uirouter) { -%>
@@ -13,6 +11,7 @@ import { STATES } from './admin.routes';<% } %>
1311
const adminRoutes: Routes = [{
1412
path: 'admin',
1513
component: AdminComponent,
14+
canActivate: [AuthGuard],
1615
}];<% } %>
1716

1817
@NgModule({

Diff for: templates/app/client/app/admin(auth)/admin.routes.js

-9
This file was deleted.

Diff for: templates/app/client/app/app.module.js

+17-29
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import {
22
NgModule,
3-
ErrorHandler,
43
Injectable,
5-
ApplicationRef,
6-
Provider,
4+
ApplicationRef,<% if(filters.ts || filters.flow) { %>
5+
Provider,<% } %>
76
} from '@angular/core';
87
import { BrowserModule } from '@angular/platform-browser';
98
import {
109
Http,
1110
HttpModule,
12-
BaseRequestOptions,
11+
BaseRequestOptions,<% if(filters.ts || filters.flow) { %>
1312
RequestOptions,
14-
RequestOptionsArgs,
13+
RequestOptionsArgs,<% } %>
1514
} from '@angular/http';
1615
import {
1716
removeNgStyles,
@@ -22,14 +21,13 @@ import {
2221
import { UIRouterModule } from 'ui-router-ng2';<% } %>
2322
<%_ if (filters.ngroute) { -%>
2423
import { RouterModule, Routes } from '@angular/router';<% } %>
25-
import { provideAuth, AuthHttp, AuthConfig } from 'angular2-jwt';
24+
import { AuthHttp, AuthConfig } from 'angular2-jwt';
2625

2726
import { AppComponent } from './app.component';
2827
import { MainModule } from './main/main.module';
29-
// import { MainComponent } from './main/main.component';
30-
import { DirectivesModule } from '../components/directives.module';
28+
import { DirectivesModule } from '../components/directives.module';<% if(filters.auth) { %>
3129
import { AccountModule } from './account/account.module';
32-
import { AdminModule } from './admin/admin.module';
30+
import { AdminModule } from './admin/admin.module';<% } %>
3331

3432
import constants from './app.constants';
3533

@@ -50,7 +48,7 @@ let providers: Provider[] = [{
5048
if(constants.env === 'development') {
5149
@Injectable()
5250
class HttpOptions extends BaseRequestOptions {
53-
merge(options/*:RequestOptionsArgs*/)/*:RequestOptions*/ {
51+
merge(options: RequestOptionsArgs):RequestOptions {
5452
options.url = `http://localhost:9000${options.url}`;
5553
return super.merge(options);
5654
}
@@ -59,20 +57,10 @@ if(constants.env === 'development') {
5957
providers.push({ provide: RequestOptions, useClass: HttpOptions });
6058
}
6159

62-
const appRoutes: Routes = [
63-
//{ path: 'crisis-center', component: CrisisListComponent },
64-
//{ path: 'hero/:id', component: HeroDetailComponent },
65-
// {
66-
// path: 'home',
67-
// component: MainComponent,
68-
// data: { title: 'Home' }
69-
// },
70-
{ path: '',
71-
redirectTo: '/home',
72-
pathMatch: 'full'
73-
},
74-
//{ path: '**', component: PageNotFoundComponent }
75-
];
60+
const appRoutes: Routes = [{ path: '',
61+
redirectTo: '/home',
62+
pathMatch: 'full'
63+
}];
7664

7765
@NgModule({
7866
providers,
@@ -84,9 +72,9 @@ const appRoutes: Routes = [
8472
<%_ if (filters.ngroute) { -%>
8573
RouterModule.forRoot(appRoutes, { enableTracing: process.env.NODE_ENV === 'development' }),<% } %>
8674
MainModule,
87-
DirectivesModule,
75+
DirectivesModule,<% if(filters.auth) { %>
8876
AccountModule,
89-
AdminModule,
77+
AdminModule,<% } %>
9078
],
9179
declarations: [
9280
AppComponent,
@@ -110,8 +98,8 @@ export class AppModule {
11098
}
11199
// change detection
112100
this.appRef.tick();
113-
delete store.state;
114-
delete store.restoreInputValues;
101+
Reflect.deleteProperty(store, 'state');
102+
Reflect.deleteProperty(store, 'restoreInputValues');
115103
}
116104

117105
hmrOnDestroy(store) {
@@ -131,7 +119,7 @@ export class AppModule {
131119
hmrAfterDestroy(store) {
132120
// display new elements
133121
store.disposeOldHosts()
134-
delete store.disposeOldHosts;
122+
Reflect.deleteProperty(store, 'disposeOldHosts');
135123
// anything you need done the component is removed
136124
}
137125
}

0 commit comments

Comments
 (0)