Skip to content

Commit 7e921b5

Browse files
authored
Merge pull request #1971 from angular-fullstack/webpack
Webpack
2 parents 7538bca + 869acf1 commit 7e921b5

File tree

82 files changed

+1708
-1031
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1708
-1031
lines changed

Diff for: circle.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ machine:
33
node:
44
version: 5.11.1
55
post:
6-
- npm install -g gulp-cli grunt-cli bower
6+
- npm install -g gulp-cli
77

88
## Customize checkout
99
checkout:
@@ -17,6 +17,9 @@ dependencies:
1717
# builds. If you need to, you can add custom paths to cache:
1818
cache_directories:
1919
- "test/fixtures/node_modules"
20+
post:
21+
- wget https://saucelabs.com/downloads/sc-latest-linux.tar.gz
22+
- tar -xzf sc-latest-linux.tar.gz
2023

2124
## Custom notifications
2225
#notify:
@@ -25,3 +28,12 @@ notify:
2528
# A list of hook hashes, containing the url field
2629
# gitter hook
2730
- url: https://webhooks.gitter.im/e/ac3980c61cb722b9e789
31+
32+
test:
33+
pre:
34+
- cd sc-*-linux && ./bin/sc --user $SAUCE_USERNAME --api-key $SAUCE_ACCESS_KEY --readyfile ~/sauce_is_ready:
35+
background: true
36+
# Wait for tunnel to be ready
37+
- while [ ! -e ~/sauce_is_ready ]; do sleep 1; done
38+
post:
39+
- killall --wait sc # wait for Sauce Connect to close the tunnel

Diff for: gulpfile.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const transpile = lazypipe()
3535
.pipe(babel);
3636

3737
gulp.task('clean', () => {
38-
return del(['generators/**/*', './test/(**|!fixtures/node_modules|!fixtures/bower_components)/*']);
38+
return del(['generators/**/*', './test/(**|!fixtures/node_modules)/*']);
3939
});
4040

4141
gulp.task('babel', () => {
@@ -113,10 +113,7 @@ function updateFixtures(target) {
113113
const dest = __dirname + (deps ? '/angular-fullstack-deps/' : '/test/fixtures/');
114114
const appName = deps ? 'angular-fullstack-deps' : 'tempApp';
115115

116-
return Promise.all([
117-
processJson('templates/app/_package.json', dest + 'package.json', {appName, genVer, private: !deps, test: test}),
118-
processJson('templates/app/_bower.json', dest + 'bower.json', {appName, genVer, private: !deps, test: test})
119-
]);
116+
return processJson('templates/app/_package.json', dest + 'package.json', {appName, genVer, private: !deps, test: test});
120117
}
121118

122119
gulp.task('updateFixtures', cb => {
@@ -143,16 +140,13 @@ function execAsync(cmd, opt) {
143140
}
144141

145142
gulp.task('installFixtures', function() {
146-
gutil.log('installing npm & bower dependencies for generated app');
143+
gutil.log('installing npm dependencies for generated app');
147144
let progress = setInterval(() => {
148145
process.stdout.write('.');
149146
}, 1 * 1000);
150147
shell.cd('test/fixtures');
151148

152-
return Promise.all([
153-
execAsync('npm install --quiet', {cwd: '../fixtures'}),
154-
execAsync('bower install', {cwd: '../fixtures'})
155-
]).then(() => {
149+
execAsync('npm install --quiet', {cwd: '../fixtures'}).then(() => {
156150
process.stdout.write('\n');
157151
if(!process.env.SAUCE_USERNAME) {
158152
gutil.log('running npm run-script update-webdriver');

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-angular-fullstack",
3-
"version": "3.7.5",
3+
"version": "4.0.0-beta",
44
"description": "Yeoman generator for creating MEAN stack applications, using MongoDB, Express, AngularJS, and Node",
55
"keywords": [
66
"yeoman-generator",
@@ -45,6 +45,7 @@
4545
"gulp-babel": "^6.1.2",
4646
"gulp-beautify": "^2.0.0",
4747
"gulp-filter": "^4.0.0",
48+
"gulp-tap": "^0.1.3",
4849
"insight": "~0.8.1",
4950
"lodash": "^4.13.1",
5051
"semver": "^5.1.0",

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

+63-19
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ import insight from '../insight-init';
1111
import {exec} from 'child_process';
1212
import babelStream from 'gulp-babel';
1313
import beaufityStream from 'gulp-beautify';
14+
import tap from 'gulp-tap';
1415
import filter from 'gulp-filter';
1516
import semver from 'semver';
1617

1718
export class Generator extends Base {
1819
constructor(...args) {
1920
super(...args);
2021

22+
this.env.alias('angular-fullstack', 'afs');
23+
this.env.alias('afs', 'angular-fullstack');
24+
2125
this.argument('name', { type: String, required: false });
2226

2327
this.option('skip-install', {
@@ -126,12 +130,12 @@ export class Generator extends Base {
126130
}[val];
127131
}
128132
}, {
129-
// TODO: enable once Babel setup supports Flow
130-
// type: 'confirm',
131-
// name: 'flow',
132-
// message: 'Would you like to use Flow types with Babel?',
133-
// when: answers => answers.transpiler === 'babel'
134-
// }, {
133+
type: 'confirm',
134+
name: 'flow',
135+
default: false,
136+
message: 'Would you like to use Flow types with Babel?',
137+
when: answers => answers.transpiler === 'babel'
138+
}, {
135139
type: 'list',
136140
name: 'markup',
137141
message: 'What would you like to write markup with?',
@@ -449,24 +453,32 @@ export class Generator extends Base {
449453
]);
450454
*/
451455

456+
const flow = this.filters.flow;
457+
452458
let babelPlugins = [
453459
'babel-plugin-syntax-flow',
454460
'babel-plugin-syntax-class-properties'
455461
];
456462

457-
// TODO: enable once Babel setup supports Flow
458-
// if(this.filters.babel && !this.filters.flow) {
463+
if(this.filters.babel && !flow) {
459464
babelPlugins.push('babel-plugin-transform-flow-strip-types');
460-
// }
465+
}
461466

462-
const jsFilter = filter(['client/**/*.js'], {restore: true});
467+
let jsFilter = filter(['client/**/*.js'], {restore: true});
463468
this.registerTransformStream([
464469
jsFilter,
465470
babelStream({
466471
plugins: babelPlugins.map(require.resolve),
467472
/* Babel get's confused about these if you're using an `npm link`ed
468473
generator-angular-fullstack, thus the `require.resolve` */
469-
// retainLines: true,
474+
shouldPrintComment(commentContents) {
475+
if(flow) {
476+
return true;
477+
} else {
478+
// strip `// @flow` comments if not using flow
479+
return !(/@flow/.test(commentContents));
480+
}
481+
},
470482
babelrc: false // don't grab the generator's `.babelrc`
471483
}),
472484
beaufityStream({
@@ -493,6 +505,42 @@ export class Generator extends Base {
493505
jsFilter.restore
494506
]);
495507

508+
/**
509+
* TypeScript doesn't play nicely with things that don't have a default export
510+
*/
511+
if(this.filters.ts) {
512+
const modulesToFix = [
513+
['angular', 'angular'],
514+
['ngCookies', 'angular-cookies'],
515+
['ngResource', 'angular-resource'],
516+
['ngSanitize', 'angular-sanitize'],
517+
['uiRouter', 'angular-ui-router'],
518+
['uiBootstrap', 'angular-ui-bootstrap'],
519+
['ngMessages', 'angular-messages'],
520+
['io', 'socket.io-client']
521+
];
522+
function replacer(contents) {
523+
modulesToFix.forEach(([moduleName, importName]) => {
524+
contents = contents.replace(
525+
`import ${moduleName} from '${importName}'`,
526+
`const ${moduleName} = require('${importName}')`
527+
);
528+
});
529+
return contents;
530+
}
531+
532+
let tsFilter = filter(['client/**/*.ts'], {restore: true});
533+
this.registerTransformStream([
534+
tsFilter,
535+
tap(function(file, t) {
536+
var contents = file.contents.toString();
537+
contents = replacer(contents);
538+
file.contents = new Buffer(contents);
539+
}),
540+
tsFilter.restore
541+
]);
542+
}
543+
496544
let self = this;
497545
this.sourceRoot(path.join(__dirname, '../../templates/app'));
498546
this.processDirectory('.', '.');
@@ -515,14 +563,10 @@ export class Generator extends Base {
515563
};
516564
}
517565

518-
get install() {
519-
return {
520-
installDeps: function() {
521-
this.installDependencies({
522-
skipInstall: this.options['skip-install']
523-
});
524-
}
525-
};
566+
install() {
567+
if(!this.options['skip-install']) {
568+
this.spawnCommand('npm', ['install']);
569+
}
526570
}
527571

528572
get end() {

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

+3-7
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ function runEndpointGen(name, opt={}) {
5353
dir = _dir;
5454

5555
// symlink our dependency directories
56-
return Promise.all([
57-
fs.mkdirAsync(dir + '/client').then(() => {
58-
return fs.symlinkAsync(__dirname + '/fixtures/bower_components', dir + '/client/bower_components');
59-
}),
60-
fs.symlinkAsync(__dirname + '/fixtures/node_modules', dir + '/node_modules')
61-
]).then(done);
56+
return fs.symlinkAsync(__dirname + '/fixtures/node_modules', dir + '/node_modules')
57+
.then(done);
6258
})
6359
.withOptions(options)
6460
.withArguments([name])
@@ -250,4 +246,4 @@ describe('angular-fullstack:endpoint', function() {
250246
return jshintDir(dir, 'foo-bar').should.be.fulfilled();
251247
});
252248
});
253-
});
249+
});

Diff for: src/test/fixtures/.bowerrc

-3
This file was deleted.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"models": true,
2727
"mongooseModels": true,
2828
"mongoose": true,
29-
"grunt": true,
29+
"gulp": true,
3030
"mocha": true,
3131
"jasmine": false,
3232
"expect": true

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

+29-16
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,22 @@ export function app(options) {
4949
'client/.htaccess',
5050
'client/favicon.ico',
5151
'client/robots.txt',
52-
'client/index.html',
52+
'client/_index.html',
53+
`client/polyfills.${script}`,
5354
'client/app/app.' + script,
55+
'client/app/app.config.' + script,
5456
'client/app/app.' + stylesheet,
55-
'client/app/main/main.' + script,
57+
'client/app/main/main.component.' + script,
58+
'client/app/main/main.component.spec.' + script,
59+
'client/app/main/main.routes.' + script,
5660
'client/app/main/main.' + markup,
5761
'client/app/main/main.' + stylesheet,
58-
'client/app/main/main.controller.' + script,
59-
'client/app/main/main.controller.spec.' + script,
6062
'client/assets/images/yeoman.png',
6163
'client/components/footer/footer.' + stylesheet,
6264
'client/components/footer/footer.' + markup,
63-
'client/components/footer/footer.directive.' + script,
65+
'client/components/footer/footer.component.' + script,
6466
'client/components/navbar/navbar.' + markup,
65-
'client/components/navbar/navbar.controller.' + script,
66-
'client/components/navbar/navbar.directive.' + script,
67+
'client/components/navbar/navbar.component.' + script,
6768
'client/components/util/util.module.' + script,
6869
'client/components/util/util.service.' + script,
6970
'server/.jshintrc',
@@ -89,21 +90,25 @@ export function app(options) {
8990
'e2e/main/main.spec.js',
9091
'e2e/components/navbar/navbar.po.js',
9192
'.babelrc',
92-
'.bowerrc',
9393
'.buildignore',
9494
'.editorconfig',
9595
'.gitattributes',
9696
'.gitignore',
9797
'.travis.yml',
9898
'.jscsrc',
9999
'.yo-rc.json',
100-
'Gruntfile.js',
100+
'gulpfile.babel.js',
101101
'package.json',
102-
'bower.json',
103102
'karma.conf.js',
104103
'mocha.conf.js',
104+
'mocha.global.js',
105105
'protractor.conf.js',
106-
'README.md'
106+
'README.md',
107+
'spec.js',
108+
'webpack.build.js',
109+
'webpack.dev.js',
110+
'webpack.test.js',
111+
'webpack.make.js'
107112
]);
108113

109114
/* TypeScript */
@@ -120,6 +125,11 @@ export function app(options) {
120125
]);
121126
}
122127

128+
/* Flow */
129+
if(options.flow) {
130+
files.push('.flowconfig');
131+
}
132+
123133
/* Ui-Router */
124134
if (options.router === 'uirouter') {
125135
files = files.concat([
@@ -155,18 +165,22 @@ export function app(options) {
155165
/* Authentication */
156166
if (options.auth) {
157167
files = files.concat([
158-
'client/app/account/account.' + script,
168+
'client/app/account/index.' + script,
169+
'client/app/account/account.routes.' + script,
159170
'client/app/account/login/login.' + markup,
171+
'client/app/account/login/index.' + script,
160172
'client/app/account/login/login.controller.' + script,
161173
'client/app/account/settings/settings.' + markup,
174+
'client/app/account/settings/index.' + script,
162175
'client/app/account/settings/settings.controller.' + script,
163176
'client/app/account/signup/signup.' + markup,
177+
'client/app/account/signup/index.' + script,
164178
'client/app/account/signup/signup.controller.' + script,
179+
'client/app/admin/index.' + script,
165180
'client/app/admin/admin.' + markup,
166181
'client/app/admin/admin.' + stylesheet,
167-
'client/app/admin/admin.module.' + script,
168-
'client/app/admin/admin.router.' + script,
169182
'client/app/admin/admin.controller.' + script,
183+
'client/app/admin/admin.routes.' + script,
170184
'client/components/auth/auth.module.' + script,
171185
'client/components/auth/auth.service.' + script,
172186
'client/components/auth/interceptor.service.' + script,
@@ -200,11 +214,10 @@ export function app(options) {
200214

201215

202216
files = files.concat([
217+
'client/components/oauth-buttons/index.' + script,
203218
'client/components/oauth-buttons/oauth-buttons.' + stylesheet,
204219
'client/components/oauth-buttons/oauth-buttons.' + markup,
205-
'client/components/oauth-buttons/oauth-buttons.controller.' + script,
206220
'client/components/oauth-buttons/oauth-buttons.controller.spec.' + script,
207-
'client/components/oauth-buttons/oauth-buttons.directive.' + script,
208221
'client/components/oauth-buttons/oauth-buttons.directive.spec.' + script,
209222
'e2e/components/oauth-buttons/oauth-buttons.po.js'
210223
]);

0 commit comments

Comments
 (0)