diff --git a/src/test/main.test.js b/src/test/main.test.js index 985bdb620..c12d07dde 100644 --- a/src/test/main.test.js +++ b/src/test/main.test.js @@ -72,15 +72,15 @@ describe('angular-fullstack:app', function() { }); it('passes lint', function() { - return runCmd('gulp lint:scripts').should.be.fulfilled(); + return runCmd('npm run lint').should.be.fulfilled(); }); it('passes client tests', function() { - return runCmd('gulp test:client').should.be.fulfilled(); + return runCmd('npm run test:client').should.be.fulfilled(); }); it('passes server tests', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); describe('with a generated endpoint', function() { @@ -91,7 +91,7 @@ describe('angular-fullstack:app', function() { }); it('should run server tests successfully', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); }); @@ -103,7 +103,7 @@ describe('angular-fullstack:app', function() { }); it('should run server tests successfully', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); }); @@ -115,7 +115,7 @@ describe('angular-fullstack:app', function() { }); it('should run server tests successfully', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); }); @@ -127,7 +127,7 @@ describe('angular-fullstack:app', function() { }); it('should run server tests successfully', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); }); @@ -159,9 +159,9 @@ describe('angular-fullstack:app', function() { } }).then(_dir => { dir = _dir; - lintResult = runCmd('gulp lint:scripts'); - clientTestResult = runCmd('gulp test:client'); - serverTestResult = runCmd('gulp test:server'); + lintResult = runCmd('npm run lint'); + clientTestResult = runCmd('npm run test:client'); + serverTestResult = runCmd('npm run test:server'); }); }); @@ -207,9 +207,9 @@ describe('angular-fullstack:app', function() { before(function() { return runGen(testOptions).then(_dir => { dir = _dir; - lintResult = runCmd('gulp lint:scripts'); - clientTestResult = runCmd('gulp test:client'); - serverTestResult = runCmd('gulp test:server'); + lintResult = runCmd('npm run lint'); + clientTestResult = runCmd('npm run test:client'); + serverTestResult = runCmd('npm run test:server'); }); }); @@ -239,7 +239,7 @@ describe('angular-fullstack:app', function() { }); it('should run server tests successfully', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); }); @@ -281,8 +281,8 @@ describe('angular-fullstack:app', function() { before(function() { return runGen(testOptions).then(_dir => { dir = _dir; - lintResult = runCmd('gulp lint:scripts'); - clientTestResult = runCmd('gulp test:client'); + lintResult = runCmd('npm run lint'); + clientTestResult = runCmd('npm run test:client'); }); }); @@ -301,7 +301,7 @@ describe('angular-fullstack:app', function() { }); it.skip('should run server tests successfully', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); describe.skip('with a generated endpoint', function() { @@ -312,7 +312,7 @@ describe('angular-fullstack:app', function() { }); it('should run server tests successfully', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); }); @@ -353,9 +353,9 @@ describe('angular-fullstack:app', function() { before(function() { return runGen(testOptions, {options: {devPort: '9005'}}).then(_dir => { dir = _dir; - lintResult = runCmd('gulp lint:scripts'); - clientTestResult = runCmd('gulp test:client'); - serverTestResult = runCmd('gulp test:server'); + lintResult = runCmd('npm run lint'); + clientTestResult = runCmd('npm run test:client'); + serverTestResult = runCmd('npm run test:server'); }); }); @@ -385,7 +385,7 @@ describe('angular-fullstack:app', function() { }); it('should run server tests successfully', function() { - return runCmd('gulp test:server').should.be.fulfilled(); + return runCmd('npm run test:server').should.be.fulfilled(); }); }); diff --git a/templates/app/_package.json b/templates/app/_package.json index 46ef89b3b..2e6cf33fa 100644 --- a/templates/app/_package.json +++ b/templates/app/_package.json @@ -120,6 +120,7 @@ "babel-plugin-istanbul": "^4.1.4", "babel-preset-env": "^1.6.1", "babel-preset-es2015": "^6.6.0", + "cross-env": "^5.1.1", "eslint": "^2.12.0", "del": "^3.0.0", "gulp": "^3.9.1", @@ -216,10 +217,12 @@ "scripts": { "postinstall": "gulp copy:fonts:dev", "lint": "npm run lint:client && npm run lint:server", - "lint:client": "eslint ./client/**/*.<%= scriptExt %> -c ./client/.eslintrc --ignore-pattern *.spec.<%= scriptExt %>", + "lint:client": <% if(filters.babel) { _%>"eslint ./client/**/*.<%= scriptExt %> -c ./client/.eslintrc --ignore-pattern *.spec.<%= scriptExt %>"<%_ } else { _%> +"tslint --format verbose ./client/{**/**,**}/*.ts"<%_ } %>, "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", + "test:server": "cross-env NODE_ENV=test ./node_modules/.bin/mocha --reporter spec --timeout 5000 --require ./mocha.conf.js ./server/**/*.{spec,integration}.js mocha.global.js", "test:e2e": "gulp webpack:dev && protractor ./protractor.conf.js", <%_ if(filters.flow) { -%> "flow": "flow", diff --git a/templates/app/client/app/app.module.js b/templates/app/client/app/app.module.js index b6e687191..e14e834f4 100644 --- a/templates/app/client/app/app.module.js +++ b/templates/app/client/app/app.module.js @@ -48,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); } diff --git a/templates/app/client/components/auth(auth)/auth.service.js b/templates/app/client/components/auth(auth)/auth.service.js index 8b14f933c..477810d64 100644 --- a/templates/app/client/components/auth(auth)/auth.service.js +++ b/templates/app/client/components/auth(auth)/auth.service.js @@ -8,10 +8,10 @@ import constants from '../../app/app.constants'; // @flow class User { - _id: string = ''; - name: string = ''; - email: string = ''; - role: string = ''; + _id = ''; + name = ''; + email = ''; + role = ''; $promise = undefined; } diff --git a/templates/app/client/components/auth(auth)/user.service.js b/templates/app/client/components/auth(auth)/user.service.js index 68c2f59c6..2fea4287a 100644 --- a/templates/app/client/components/auth(auth)/user.service.js +++ b/templates/app/client/components/auth(auth)/user.service.js @@ -13,7 +13,7 @@ type UserType = { _id?: string; name?: string; email?: string; -} +}; function handleError(err) { return Observable.throw(err.json() || 'Server error'); @@ -30,22 +30,22 @@ export class UserService { query(): Observable { return this.AuthHttp.get('/api/users/') - .map((res:Response) => res.json()) + .map((res: Response) => res.json()) .catch(handleError); } get(user<% if(filters.ts) { %>: UserType<% } %> = {id: 'me'}): Observable { return this.AuthHttp.get(`/api/users/${user.id || user._id}`) - .map((res:Response) => res.json()) + .map((res: Response) => res.json()) .catch(handleError); } create(user: UserType) { return this.AuthHttp.post('/api/users/', user) - .map((res:Response) => res.json()) + .map((res: Response) => res.json()) .catch(handleError); } changePassword(user, oldPassword, newPassword) { return this.AuthHttp.put(`/api/users/${user.id || user._id}/password`, {oldPassword, newPassword}) - .map((res:Response) => res.json()) + .map((res: Response) => res.json()) .catch(handleError); } remove(user) { diff --git a/templates/app/client/components/oauth-buttons(oauth)/oauth-buttons.component.js b/templates/app/client/components/oauth-buttons(oauth)/oauth-buttons.component.js index 997e3d76b..95fe92372 100644 --- a/templates/app/client/components/oauth-buttons(oauth)/oauth-buttons.component.js +++ b/templates/app/client/components/oauth-buttons(oauth)/oauth-buttons.component.js @@ -8,5 +8,5 @@ import { Component } from '@angular/core'; export class OauthButtonsComponent { loginOauth(provider) { window.location.href = `/auth/${provider}`; - }; + } } diff --git a/templates/app/client/tslint.json(ts) b/templates/app/client/tslint.json(ts) index 01bfb35a0..4495b1571 100644 --- a/templates/app/client/tslint.json(ts) +++ b/templates/app/client/tslint.json(ts) @@ -1,7 +1,7 @@ { "rules": { "class-name": true, - "curly": true, + "curly": false, "eofline": true, "forin": true, "indent": [true, "spaces"], @@ -50,7 +50,6 @@ }], "variable-name": false, "whitespace": [true, - "check-branch", "check-decl", "check-operator", "check-separator", diff --git a/templates/app/server/config/seed(models).js b/templates/app/server/config/seed(models).js index dcbd1e7de..17ad9210e 100644 --- a/templates/app/server/config/seed(models).js +++ b/templates/app/server/config/seed(models).js @@ -19,7 +19,7 @@ export default function seedDatabaseIfNeeded() { let promises = []; - let thingPromise = <% if(filters.mongooseModels) { %>Thing.find({}).remove()<% } if(filters.sequelizeModels) { %>return Thing.destroy({ where: {} })<% } %> + let thingPromise = <% if(filters.mongooseModels) { %>Thing.find({}).remove()<% } if(filters.sequelizeModels) { %>Thing.destroy({ where: {} })<% } %> .then(() => { <% if(filters.mongooseModels) { %>return Thing.create({<% } if(filters.sequelizeModels) { %>return Thing.bulkCreate([{<% } %> diff --git a/templates/app/server/sqldb(sequelize)/index.js b/templates/app/server/sqldb(sequelize)/index.js index e2ac848fb..51d3317be 100644 --- a/templates/app/server/sqldb(sequelize)/index.js +++ b/templates/app/server/sqldb(sequelize)/index.js @@ -1,10 +1,6 @@ /** * Sequelize initialization module */ - -'use strict'; - -import path from 'path'; import config from '../config/environment'; import Sequelize from 'sequelize';