Skip to content

test(gen): use npm scripts for lint/test #2676

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 7 commits into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions src/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
});
});

Expand All @@ -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();
});
});

Expand All @@ -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();
});
});

Expand All @@ -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();
});
});

Expand Down Expand Up @@ -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');
});
});

Expand Down Expand Up @@ -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');
});
});

Expand Down Expand Up @@ -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();
});
});

Expand Down Expand Up @@ -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');
});
});

Expand All @@ -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() {
Expand All @@ -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();
});
});

Expand Down Expand Up @@ -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');
});
});

Expand Down Expand Up @@ -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();
});
});

Expand Down
5 changes: 4 additions & 1 deletion templates/app/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion templates/app/client/app/app.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions templates/app/client/components/auth(auth)/auth.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions templates/app/client/components/auth(auth)/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type UserType = {
_id?: string;
name?: string;
email?: string;
}
};

function handleError(err) {
return Observable.throw(err.json() || 'Server error');
Expand All @@ -30,22 +30,22 @@ export class UserService {

query(): Observable<UserType[]> {
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<UserType> {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import { Component } from '@angular/core';
export class OauthButtonsComponent {
loginOauth(provider) {
window.location.href = `/auth/${provider}`;
};
}
}
3 changes: 1 addition & 2 deletions templates/app/client/tslint.json(ts)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"rules": {
"class-name": true,
"curly": true,
"curly": false,
"eofline": true,
"forin": true,
"indent": [true, "spaces"],
Expand Down Expand Up @@ -50,7 +50,6 @@
}],
"variable-name": false,
"whitespace": [true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
Expand Down
2 changes: 1 addition & 1 deletion templates/app/server/config/seed(models).js
Original file line number Diff line number Diff line change
Expand Up @@ -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([{<% } %>
Expand Down
4 changes: 0 additions & 4 deletions templates/app/server/sqldb(sequelize)/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/**
* Sequelize initialization module
*/

'use strict';

import path from 'path';
import config from '../config/environment';
import Sequelize from 'sequelize';

Expand Down