Skip to content

Commit 8698158

Browse files
authored
Merge pull request #2676 from angular-fullstack/test/canary-use-npm-scripts
test(gen): use npm scripts for lint/test
2 parents b81639f + 59a6a36 commit 8698158

File tree

9 files changed

+39
-41
lines changed

9 files changed

+39
-41
lines changed

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

+22-22
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ describe('angular-fullstack:app', function() {
7272
});
7373

7474
it('passes lint', function() {
75-
return runCmd('gulp lint:scripts').should.be.fulfilled();
75+
return runCmd('npm run lint').should.be.fulfilled();
7676
});
7777

7878
it('passes client tests', function() {
79-
return runCmd('gulp test:client').should.be.fulfilled();
79+
return runCmd('npm run test:client').should.be.fulfilled();
8080
});
8181

8282
it('passes server tests', function() {
83-
return runCmd('gulp test:server').should.be.fulfilled();
83+
return runCmd('npm run test:server').should.be.fulfilled();
8484
});
8585

8686
describe('with a generated endpoint', function() {
@@ -91,7 +91,7 @@ describe('angular-fullstack:app', function() {
9191
});
9292

9393
it('should run server tests successfully', function() {
94-
return runCmd('gulp test:server').should.be.fulfilled();
94+
return runCmd('npm run test:server').should.be.fulfilled();
9595
});
9696
});
9797

@@ -103,7 +103,7 @@ describe('angular-fullstack:app', function() {
103103
});
104104

105105
it('should run server tests successfully', function() {
106-
return runCmd('gulp test:server').should.be.fulfilled();
106+
return runCmd('npm run test:server').should.be.fulfilled();
107107
});
108108
});
109109

@@ -115,7 +115,7 @@ describe('angular-fullstack:app', function() {
115115
});
116116

117117
it('should run server tests successfully', function() {
118-
return runCmd('gulp test:server').should.be.fulfilled();
118+
return runCmd('npm run test:server').should.be.fulfilled();
119119
});
120120
});
121121

@@ -127,7 +127,7 @@ describe('angular-fullstack:app', function() {
127127
});
128128

129129
it('should run server tests successfully', function() {
130-
return runCmd('gulp test:server').should.be.fulfilled();
130+
return runCmd('npm run test:server').should.be.fulfilled();
131131
});
132132
});
133133

@@ -159,9 +159,9 @@ describe('angular-fullstack:app', function() {
159159
}
160160
}).then(_dir => {
161161
dir = _dir;
162-
lintResult = runCmd('gulp lint:scripts');
163-
clientTestResult = runCmd('gulp test:client');
164-
serverTestResult = runCmd('gulp test:server');
162+
lintResult = runCmd('npm run lint');
163+
clientTestResult = runCmd('npm run test:client');
164+
serverTestResult = runCmd('npm run test:server');
165165
});
166166
});
167167

@@ -207,9 +207,9 @@ describe('angular-fullstack:app', function() {
207207
before(function() {
208208
return runGen(testOptions).then(_dir => {
209209
dir = _dir;
210-
lintResult = runCmd('gulp lint:scripts');
211-
clientTestResult = runCmd('gulp test:client');
212-
serverTestResult = runCmd('gulp test:server');
210+
lintResult = runCmd('npm run lint');
211+
clientTestResult = runCmd('npm run test:client');
212+
serverTestResult = runCmd('npm run test:server');
213213
});
214214
});
215215

@@ -239,7 +239,7 @@ describe('angular-fullstack:app', function() {
239239
});
240240

241241
it('should run server tests successfully', function() {
242-
return runCmd('gulp test:server').should.be.fulfilled();
242+
return runCmd('npm run test:server').should.be.fulfilled();
243243
});
244244
});
245245

@@ -281,8 +281,8 @@ describe('angular-fullstack:app', function() {
281281
before(function() {
282282
return runGen(testOptions).then(_dir => {
283283
dir = _dir;
284-
lintResult = runCmd('gulp lint:scripts');
285-
clientTestResult = runCmd('gulp test:client');
284+
lintResult = runCmd('npm run lint');
285+
clientTestResult = runCmd('npm run test:client');
286286
});
287287
});
288288

@@ -301,7 +301,7 @@ describe('angular-fullstack:app', function() {
301301
});
302302

303303
it.skip('should run server tests successfully', function() {
304-
return runCmd('gulp test:server').should.be.fulfilled();
304+
return runCmd('npm run test:server').should.be.fulfilled();
305305
});
306306

307307
describe.skip('with a generated endpoint', function() {
@@ -312,7 +312,7 @@ describe('angular-fullstack:app', function() {
312312
});
313313

314314
it('should run server tests successfully', function() {
315-
return runCmd('gulp test:server').should.be.fulfilled();
315+
return runCmd('npm run test:server').should.be.fulfilled();
316316
});
317317
});
318318

@@ -353,9 +353,9 @@ describe('angular-fullstack:app', function() {
353353
before(function() {
354354
return runGen(testOptions, {options: {devPort: '9005'}}).then(_dir => {
355355
dir = _dir;
356-
lintResult = runCmd('gulp lint:scripts');
357-
clientTestResult = runCmd('gulp test:client');
358-
serverTestResult = runCmd('gulp test:server');
356+
lintResult = runCmd('npm run lint');
357+
clientTestResult = runCmd('npm run test:client');
358+
serverTestResult = runCmd('npm run test:server');
359359
});
360360
});
361361

@@ -385,7 +385,7 @@ describe('angular-fullstack:app', function() {
385385
});
386386

387387
it('should run server tests successfully', function() {
388-
return runCmd('gulp test:server').should.be.fulfilled();
388+
return runCmd('npm run test:server').should.be.fulfilled();
389389
});
390390
});
391391

Diff for: templates/app/_package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"babel-plugin-istanbul": "^4.1.4",
121121
"babel-preset-env": "^1.6.1",
122122
"babel-preset-es2015": "^6.6.0",
123+
"cross-env": "^5.1.1",
123124
"eslint": "^2.12.0",
124125
"del": "^3.0.0",
125126
"gulp": "^3.9.1",
@@ -216,10 +217,12 @@
216217
"scripts": {
217218
"postinstall": "gulp copy:fonts:dev",
218219
"lint": "npm run lint:client && npm run lint:server",
219-
"lint:client": "eslint ./client/**/*.<%= scriptExt %> -c ./client/.eslintrc --ignore-pattern *.spec.<%= scriptExt %>",
220+
"lint:client": <% if(filters.babel) { _%>"eslint ./client/**/*.<%= scriptExt %> -c ./client/.eslintrc --ignore-pattern *.spec.<%= scriptExt %>"<%_ } else { _%>
221+
"tslint --format verbose ./client/{**/**,**}/*.ts"<%_ } %>,
220222
"lint:server": "eslint ./server/**/*.js -c ./server/.eslintrc --ignore-pattern *.spec.js --ignore-pattern *.integration.js",
221223
"test": "gulp test",
222224
"test:client": "karma start ./karma.conf.js --single-run",
225+
"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",
223226
"test:e2e": "gulp webpack:dev && protractor ./protractor.conf.js",
224227
<%_ if(filters.flow) { -%>
225228
"flow": "flow",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ let providers: Provider[] = [{
4848
if(constants.env === 'development') {
4949
@Injectable()
5050
class HttpOptions extends BaseRequestOptions {
51-
merge(options: RequestOptionsArgs):RequestOptions {
51+
merge(options: RequestOptionsArgs): RequestOptions {
5252
options.url = `http://localhost:9000${options.url}`;
5353
return super.merge(options);
5454
}

Diff for: templates/app/client/components/auth(auth)/auth.service.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import constants from '../../app/app.constants';
88

99
// @flow
1010
class User {
11-
_id: string = '';
12-
name: string = '';
13-
email: string = '';
14-
role: string = '';
11+
_id = '';
12+
name = '';
13+
email = '';
14+
role = '';
1515
$promise = undefined;
1616
}
1717

Diff for: templates/app/client/components/auth(auth)/user.service.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type UserType = {
1313
_id?: string;
1414
name?: string;
1515
email?: string;
16-
}
16+
};
1717

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

3131
query(): Observable<UserType[]> {
3232
return this.AuthHttp.get('/api/users/')
33-
.map((res:Response) => res.json())
33+
.map((res: Response) => res.json())
3434
.catch(handleError);
3535
}
3636
get(user<% if(filters.ts) { %>: UserType<% } %> = {id: 'me'}): Observable<UserType> {
3737
return this.AuthHttp.get(`/api/users/${user.id || user._id}`)
38-
.map((res:Response) => res.json())
38+
.map((res: Response) => res.json())
3939
.catch(handleError);
4040
}
4141
create(user: UserType) {
4242
return this.AuthHttp.post('/api/users/', user)
43-
.map((res:Response) => res.json())
43+
.map((res: Response) => res.json())
4444
.catch(handleError);
4545
}
4646
changePassword(user, oldPassword, newPassword) {
4747
return this.AuthHttp.put(`/api/users/${user.id || user._id}/password`, {oldPassword, newPassword})
48-
.map((res:Response) => res.json())
48+
.map((res: Response) => res.json())
4949
.catch(handleError);
5050
}
5151
remove(user) {

Diff for: templates/app/client/components/oauth-buttons(oauth)/oauth-buttons.component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import { Component } from '@angular/core';
88
export class OauthButtonsComponent {
99
loginOauth(provider) {
1010
window.location.href = `/auth/${provider}`;
11-
};
11+
}
1212
}

Diff for: templates/app/client/tslint.json(ts)

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"rules": {
33
"class-name": true,
4-
"curly": true,
4+
"curly": false,
55
"eofline": true,
66
"forin": true,
77
"indent": [true, "spaces"],
@@ -50,7 +50,6 @@
5050
}],
5151
"variable-name": false,
5252
"whitespace": [true,
53-
"check-branch",
5453
"check-decl",
5554
"check-operator",
5655
"check-separator",

Diff for: templates/app/server/config/seed(models).js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function seedDatabaseIfNeeded() {
1919

2020
let promises = [];
2121

22-
let thingPromise = <% if(filters.mongooseModels) { %>Thing.find({}).remove()<% } if(filters.sequelizeModels) { %>return Thing.destroy({ where: {} })<% } %>
22+
let thingPromise = <% if(filters.mongooseModels) { %>Thing.find({}).remove()<% } if(filters.sequelizeModels) { %>Thing.destroy({ where: {} })<% } %>
2323
.then(() => {
2424
<% if(filters.mongooseModels) { %>return Thing.create({<% }
2525
if(filters.sequelizeModels) { %>return Thing.bulkCreate([{<% } %>

Diff for: templates/app/server/sqldb(sequelize)/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
/**
22
* Sequelize initialization module
33
*/
4-
5-
'use strict';
6-
7-
import path from 'path';
84
import config from '../config/environment';
95
import Sequelize from 'sequelize';
106

0 commit comments

Comments
 (0)