Skip to content

Various canary features / fixes #2655

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

Merged
merged 11 commits into from
Oct 17, 2017
2 changes: 1 addition & 1 deletion src/generators/app/USAGE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Description:
Creates a Full-Stack AngularJS + Node app
Creates a Full-Stack Angular + Node app

Example:
yo angular-fullstack
Expand Down
62 changes: 32 additions & 30 deletions src/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class Generator extends Base {
}, {
type: 'confirm',
name: 'flow',
default: false,
default: true,
message: 'Would you like to use Flow types with Babel?',
when: answers => answers.transpiler === 'babel'
}, {
Expand Down Expand Up @@ -466,35 +466,37 @@ export class Generator extends Base {
const codeshiftStream = tap(function(file, t) {
var contents = file.contents.toString();

// remove `implements Foo` from class declarations
contents = jscodeshift(contents)
.find(jscodeshift.ClassDeclaration)
.forEach(path => {
path.value.implements = null;
})
.toSource();

// remove any type annotations
contents = jscodeshift(contents)
.find(jscodeshift.TypeAnnotation)
.remove()
.toSource();
contents = jscodeshift(contents)
.find(jscodeshift.GenericTypeAnnotation)
.remove()
.toSource();

// remove any `type Foo = { .. }` declarations
contents = jscodeshift(contents)
.find(jscodeshift.TypeAlias)
.remove()
.toSource();

// remove any flow directive comments
contents = jscodeshift(contents)
.find(jscodeshift.Comment, path => path.type === 'CommentLine' && path.value.includes('@flow'))
.forEach(path => path.prune())
.toSource();
if(!flow) {
// remove `implements Foo` from class declarations
contents = jscodeshift(contents)
.find(jscodeshift.ClassDeclaration)
.forEach(path => {
path.value.implements = null;
})
.toSource();

// remove any type annotations
contents = jscodeshift(contents)
.find(jscodeshift.TypeAnnotation)
.remove()
.toSource();
contents = jscodeshift(contents)
.find(jscodeshift.GenericTypeAnnotation)
.remove()
.toSource();

// remove any `type Foo = { .. }` declarations
contents = jscodeshift(contents)
.find(jscodeshift.TypeAlias)
.remove()
.toSource();

// remove any flow directive comments
contents = jscodeshift(contents)
.find(jscodeshift.Comment, path => path.type === 'CommentLine' && path.value.includes('@flow'))
.forEach(path => path.prune())
.toSource();
}

file.contents = new Buffer(contents);
});
Expand Down
2 changes: 1 addition & 1 deletion src/test/fixtures/.yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"filters": {
"js": true,
"babel": true,
"flow": false,
"flow": true,
"html": true,
"sass": true,
"ngroute": true,
Expand Down
3 changes: 1 addition & 2 deletions src/test/get-expected-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export function app(options) {
'.babelrc',
'.buildignore',
'.editorconfig',
'.eslintignore',
'.eslintrc',
'.gitattributes',
'.gitignore',
Expand Down Expand Up @@ -156,7 +157,6 @@ export function app(options) {
if (options.auth) {
files = files.concat([
'client/app/account/account.module.' + script,
'client/app/account/account.routes.' + script,
'client/app/account/login/login.' + markup,
'client/app/account/login/login.component.' + script,
'client/app/account/settings/settings.' + markup,
Expand All @@ -167,7 +167,6 @@ export function app(options) {
'client/app/admin/admin.' + stylesheet,
'client/app/admin/admin.component.' + script,
'client/app/admin/admin.module.' + script,
'client/app/admin/admin.routes.' + script,
'client/components/auth/auth.module.' + script,
'client/components/auth/auth.service.' + script,
'client/components/auth/interceptor.service.' + script,
Expand Down
2 changes: 2 additions & 0 deletions src/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
const defaultOptions = {
buildtool: 'gulp',
transpiler: 'babel',
flow: true,
markup: 'html',
stylesheet: 'sass',
router: 'ngroute',
Expand Down Expand Up @@ -263,6 +264,7 @@ describe('angular-fullstack:app', function() {
var testOptions = {
buildtool: 'gulp',
transpiler: 'babel',
flow: true,
markup: 'pug',
stylesheet: 'css',
router: 'ngroute',
Expand Down
1 change: 1 addition & 0 deletions templates/app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client/components/socket/primus.js
7 changes: 5 additions & 2 deletions templates/app/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"main": "server/index.js",
"dependencies": {
"compression": "^1.7.1",
"core-js": "^2.4.1",
"cors": "^2.8.1",
"express": "^4.13.3",
Expand Down Expand Up @@ -45,8 +46,7 @@
"primus": "^7.0.1",
"primus-emit": "^1.0.0",
"uws": "^8.14.1",<% } %>
"serve-favicon": "^2.3.0",
"shrink-ray": "^0.1.3"
"serve-favicon": "^2.3.0"
},
"devDependencies": {
<%# CLIENT %>
Expand Down Expand Up @@ -213,6 +213,9 @@
"npm": "^3.9.5"
},
"scripts": {
"lint": "npm run lint:client && npm run lint:server",
"lint:client": "eslint ./client/**/*.<%= scriptExt %> -c ./client/.eslintrc --ignore-pattern *.spec.<%= scriptExt %>",
"lint:server": "eslint ./server/**/*.js -c ./server/.eslintrc --ignore-pattern *.spec.js --ignore-pattern *.integration.js",
"test": "gulp test",
"test:client": "karma start ./karma.conf.js --single-run",
<%_ if(filters.flow) { -%>
Expand Down
6 changes: 6 additions & 0 deletions templates/app/client/.eslintrc(babel)
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@
"env": {
"browser": true,
"commonjs": true
},
"globals": {
"process": true
},
"rules": {
"no-process-env": 0
}
}
4 changes: 0 additions & 4 deletions templates/app/client/app/account(auth)/account.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import { RouterModule, Routes } from '@angular/router';<% } %>
<%_ if(filters.oauth) { -%>
import { DirectivesModule } from '../../components/directives.module';<% } %>

<%_ if(filters.uirouter) { -%>
import { STATES } from './account.routes';<% } %>

import { LoginComponent } from './login/login.component';
import { SettingsComponent } from './settings/settings.component';
import { SignupComponent } from './signup/signup.component';
Expand All @@ -19,7 +16,6 @@ import { SignupComponent } from './signup/signup.component';
const accountRoutes: Routes = [{
path: 'login',
component: LoginComponent,
//data: { title: 'Home' }
}, {
path: 'settings',
component: SettingsComponent,
Expand Down
42 changes: 0 additions & 42 deletions templates/app/client/app/account(auth)/account.routes.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class SettingsComponent {
}

changePassword(form) {
if(form.invalid) return;

this.submitted = true;

return this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export class SignupComponent {
}

register(form) {
if(form.invalid) return;

this.submitted = true;

return this.AuthService.createUser({
Expand Down
9 changes: 4 additions & 5 deletions templates/app/client/app/admin(auth)/admin.module.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
<%_ if(filters.uirouter) { %>
import { UIRouterModule } from 'ui-router-ng2';<% } %>
<%_ if(filters.ngroute) { %>
import { BrowserModule } from '@angular/platform-browser';<% if(filters.uirouter) { %>
import { UIRouterModule } from 'ui-router-ng2';<% } %><% if(filters.ngroute) { %>
import { RouterModule, Routes } from '@angular/router';<% } %>

import { AuthGuard } from '../../components/auth/auth-guard.service';
import { AdminComponent } from './admin.component';

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

@NgModule({
Expand Down
9 changes: 0 additions & 9 deletions templates/app/client/app/admin(auth)/admin.routes.js

This file was deleted.

46 changes: 17 additions & 29 deletions templates/app/client/app/app.module.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import {
NgModule,
ErrorHandler,
Injectable,
ApplicationRef,
Provider,
ApplicationRef,<% if(filters.ts || filters.flow) { %>
Provider,<% } %>
} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {
Http,
HttpModule,
BaseRequestOptions,
BaseRequestOptions,<% if(filters.ts || filters.flow) { %>
RequestOptions,
RequestOptionsArgs,
RequestOptionsArgs,<% } %>
} from '@angular/http';
import {
removeNgStyles,
Expand All @@ -22,14 +21,13 @@ import {
import { UIRouterModule } from 'ui-router-ng2';<% } %>
<%_ if (filters.ngroute) { -%>
import { RouterModule, Routes } from '@angular/router';<% } %>
import { provideAuth, AuthHttp, AuthConfig } from 'angular2-jwt';
import { AuthHttp, AuthConfig } from 'angular2-jwt';

import { AppComponent } from './app.component';
import { MainModule } from './main/main.module';
// import { MainComponent } from './main/main.component';
import { DirectivesModule } from '../components/directives.module';
import { DirectivesModule } from '../components/directives.module';<% if(filters.auth) { %>
import { AccountModule } from './account/account.module';
import { AdminModule } from './admin/admin.module';
import { AdminModule } from './admin/admin.module';<% } %>

import constants from './app.constants';

Expand All @@ -50,7 +48,7 @@ let providers: Provider[] = [{
if(constants.env === 'development') {
@Injectable()
class HttpOptions extends BaseRequestOptions {
merge(options/*:RequestOptionsArgs*/)/*:RequestOptions*/ {
merge(options: RequestOptionsArgs):RequestOptions {
options.url = `http://localhost:9000${options.url}`;
return super.merge(options);
}
Expand All @@ -59,20 +57,10 @@ if(constants.env === 'development') {
providers.push({ provide: RequestOptions, useClass: HttpOptions });
}

const appRoutes: Routes = [
//{ path: 'crisis-center', component: CrisisListComponent },
//{ path: 'hero/:id', component: HeroDetailComponent },
// {
// path: 'home',
// component: MainComponent,
// data: { title: 'Home' }
// },
{ path: '',
redirectTo: '/home',
pathMatch: 'full'
},
//{ path: '**', component: PageNotFoundComponent }
];
const appRoutes: Routes = [{ path: '',
redirectTo: '/home',
pathMatch: 'full'
}];

@NgModule({
providers,
Expand All @@ -84,9 +72,9 @@ const appRoutes: Routes = [
<%_ if (filters.ngroute) { -%>
RouterModule.forRoot(appRoutes, { enableTracing: process.env.NODE_ENV === 'development' }),<% } %>
MainModule,
DirectivesModule,
DirectivesModule,<% if(filters.auth) { %>
AccountModule,
AdminModule,
AdminModule,<% } %>
],
declarations: [
AppComponent,
Expand All @@ -110,8 +98,8 @@ export class AppModule {
}
// change detection
this.appRef.tick();
delete store.state;
delete store.restoreInputValues;
Reflect.deleteProperty(store, 'state');
Reflect.deleteProperty(store, 'restoreInputValues');
}

hmrOnDestroy(store) {
Expand All @@ -131,7 +119,7 @@ export class AppModule {
hmrAfterDestroy(store) {
// display new elements
store.disposeOldHosts()
delete store.disposeOldHosts;
Reflect.deleteProperty(store, 'disposeOldHosts');
// anything you need done the component is removed
}
}
Loading