chore: Partition example shredder to do one directory at a time
also exclude /dist/ folder and exclude _examples from jade shredder closes #1661
This commit is contained in:
parent
c50954d5b8
commit
49a7bc3860
12
gulpfile.js
12
gulpfile.js
|
@ -615,7 +615,13 @@ gulp.task('_harp-compile', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('_shred-devguide-examples', ['_shred-clean-devguide', '_copy-example-boilerplate'], function() {
|
gulp.task('_shred-devguide-examples', ['_shred-clean-devguide', '_copy-example-boilerplate'], function() {
|
||||||
return docShredder.shred( _devguideShredOptions);
|
// Split big shredding task into partials 2016-06-14
|
||||||
|
var examplePaths = globby.sync(EXAMPLES_PATH+'/*/', {ignore: ['/node_modules', 'typings/', '_protractor/']});
|
||||||
|
var promise = Promise.resolve(true);
|
||||||
|
examplePaths.forEach(function (examplePath) {
|
||||||
|
promise = promise.then(() => docShredder.shredSingleExampleDir(_devguideShredOptions, examplePath));
|
||||||
|
});
|
||||||
|
return promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('_shred-devguide-shared-jade', ['_shred-clean-devguide-shared-jade', '_copy-example-boilerplate'], function() {
|
gulp.task('_shred-devguide-shared-jade', ['_shred-clean-devguide-shared-jade', '_copy-example-boilerplate'], function() {
|
||||||
|
@ -978,7 +984,7 @@ function devGuideExamplesWatch(shredOptions, postShredAction) {
|
||||||
// removed this version because gulp.watch has the same glob issue that dgeni has.
|
// removed this version because gulp.watch has the same glob issue that dgeni has.
|
||||||
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
|
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
|
||||||
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
|
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
|
||||||
var ignoreThese = [ '**/node_modules/**', '**/_fragments/**',
|
var ignoreThese = [ '**/node_modules/**', '**/_fragments/**', '**/dist/**', '**/typings/**',
|
||||||
'**/dart/.pub/**', '**/dart/build/**', '**/dart/packages/**'];
|
'**/dart/.pub/**', '**/dart/build/**', '**/dart/packages/**'];
|
||||||
var files = globby.sync( [includePattern], { ignore: ignoreThese });
|
var files = globby.sync( [includePattern], { ignore: ignoreThese });
|
||||||
gulp.watch([files], {readDelay: 500}, function (event, done) {
|
gulp.watch([files], {readDelay: 500}, function (event, done) {
|
||||||
|
@ -994,7 +1000,7 @@ function devGuideSharedJadeWatch(shredOptions, postShredAction) {
|
||||||
// removed this version because gulp.watch has the same glob issue that dgeni has.
|
// removed this version because gulp.watch has the same glob issue that dgeni has.
|
||||||
// var excludePattern = '!' + path.join(shredOptions.jadeDir, '**/node_modules/**/*.*');
|
// var excludePattern = '!' + path.join(shredOptions.jadeDir, '**/node_modules/**/*.*');
|
||||||
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
|
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
|
||||||
var files = globby.sync( [includePattern], { ignore: [ '**/node_modules/**', '**/_fragments/**']});
|
var files = globby.sync( [includePattern], { ignore: [ '**/node_modules/**', '**/_examples/**', '**/_fragments/**']});
|
||||||
gulp.watch([files], {readDelay: 500}, function (event, done) {
|
gulp.watch([files], {readDelay: 500}, function (event, done) {
|
||||||
gutil.log('Dev Guide jade file changed')
|
gutil.log('Dev Guide jade file changed')
|
||||||
gutil.log('Event type: ' + event.type); // added, changed, or deleted
|
gutil.log('Event type: ' + event.type); // added, changed, or deleted
|
||||||
|
|
|
@ -4,6 +4,7 @@ var del = require('del');
|
||||||
var Dgeni = require('dgeni');
|
var Dgeni = require('dgeni');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var globby = require('globby');
|
var globby = require('globby');
|
||||||
|
var ignoreDirs = ['**/node_modules/**', '**/dist/**', '**/typings/**'];
|
||||||
|
|
||||||
var shred = function(shredOptions) {
|
var shred = function(shredOptions) {
|
||||||
try {
|
try {
|
||||||
|
@ -22,6 +23,23 @@ var shred = function(shredOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var shredSingleExampleDir = function(shredOptions, fileDir) {
|
||||||
|
shredOptions = resolveShredOptions(shredOptions);
|
||||||
|
var relativePath = path.relative(shredOptions.examplesDir, fileDir);
|
||||||
|
var examplesDir = path.join(shredOptions.examplesDir, relativePath);
|
||||||
|
var fragmentsDir = path.join(shredOptions.fragmentsDir, relativePath);
|
||||||
|
var options = {
|
||||||
|
includeSubdirs: true,
|
||||||
|
examplesDir: examplesDir,
|
||||||
|
fragmentsDir: fragmentsDir
|
||||||
|
}
|
||||||
|
var cleanPath = path.join(fragmentsDir, '*.*')
|
||||||
|
return del([ cleanPath, '!**/*.ovr.*']).then(function(paths) {
|
||||||
|
// console.log('Deleted files/folders:\n', paths.join('\n'));
|
||||||
|
return shred(options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var shredSingleDir = function(shredOptions, filePath) {
|
var shredSingleDir = function(shredOptions, filePath) {
|
||||||
shredOptions = resolveShredOptions(shredOptions);
|
shredOptions = resolveShredOptions(shredOptions);
|
||||||
var fileDir = path.dirname(filePath);
|
var fileDir = path.dirname(filePath);
|
||||||
|
@ -72,6 +90,7 @@ var buildShredMap = function(shredMapOptions) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
shred: shred,
|
shred: shred,
|
||||||
|
shredSingleExampleDir: shredSingleExampleDir,
|
||||||
shredSingleDir: shredSingleDir,
|
shredSingleDir: shredSingleDir,
|
||||||
shredSingleJadeDir: shredSingleJadeDir,
|
shredSingleJadeDir: shredSingleJadeDir,
|
||||||
buildShredMap: buildShredMap
|
buildShredMap: buildShredMap
|
||||||
|
@ -107,13 +126,14 @@ function createShredExamplePackage(shredOptions) {
|
||||||
|
|
||||||
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
|
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
|
||||||
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
|
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
|
||||||
var nmPattern = '**/node_modules/**';
|
var includeFiles = globby.sync( includeFiles, { ignore: ignoreDirs } );
|
||||||
var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } );
|
|
||||||
|
console.log(`Shredding ${includeFiles.length} files inside ${shredOptions.examplesDir}`);
|
||||||
|
|
||||||
readFilesProcessor.sourceFiles = [ {
|
readFilesProcessor.sourceFiles = [ {
|
||||||
// Process all candidate files in `src` and its subfolders ...
|
// Process all candidate files in `src` and its subfolders ...
|
||||||
include: includeFiles ,
|
include: includeFiles ,
|
||||||
exclude: [ '**/node_modules/**', '**/typings/**', '**/packages/**', '**/build/**'],
|
exclude: [ '**/node_modules/**', '**/dist/**', '**/typings/**', '**/packages/**', '**/build/**'],
|
||||||
// When calculating the relative path to these files use this as the base path.
|
// When calculating the relative path to these files use this as the base path.
|
||||||
// So `src/foo/bar.js` will have relative path of `foo/bar.js`
|
// So `src/foo/bar.js` will have relative path of `foo/bar.js`
|
||||||
basePath: options.examplesDir
|
basePath: options.examplesDir
|
||||||
|
@ -159,8 +179,7 @@ function createShredJadePackage(shredOptions) {
|
||||||
|
|
||||||
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
|
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
|
||||||
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
|
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
|
||||||
var nmPattern = '**/node_modules/**';
|
var includeFiles = globby.sync( includeFiles, { ignore: ignoreDirs } );
|
||||||
var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } );
|
|
||||||
|
|
||||||
readFilesProcessor.sourceFiles = [ {
|
readFilesProcessor.sourceFiles = [ {
|
||||||
// Process all candidate files in `src` and its subfolders ...
|
// Process all candidate files in `src` and its subfolders ...
|
||||||
|
@ -212,8 +231,7 @@ var createShredMapPackage = function(mapOptions) {
|
||||||
|
|
||||||
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
|
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
|
||||||
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
|
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
|
||||||
var nmPattern = '**/node_modules/**';
|
var includeFiles = globby.sync( includeFiles, { ignore: ignoreDirs } );
|
||||||
var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } );
|
|
||||||
|
|
||||||
|
|
||||||
readFilesProcessor.sourceFiles = [ {
|
readFilesProcessor.sourceFiles = [ {
|
||||||
|
|
Loading…
Reference in New Issue