From 92d9ce83ff122a37ece8fdba4230f61bc5dcf17b Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Fri, 10 Jun 2016 14:10:30 -0700 Subject: [PATCH] chore(ignored/boilerplate files): cleanup --- .gitignore | 4 ++-- gulpfile.js | 37 +++++++++++++++++++++++--------- public/docs/_examples/.gitignore | 18 ++++++---------- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 6ed64fc3f2..9e91bc6a33 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ pubspec.lock .DS_Store **/*.iml .idea +.vscode **/js/latest/api **/ts/latest/api **/dart/latest/api @@ -21,8 +22,7 @@ _.* public/docs/xref-*.* _zip-output www -npm-debug.log -npm-debug.log.* +npm-debug*.log* *.plnkr.html plnkr.html *plnkr.no-link.html diff --git a/gulpfile.js b/gulpfile.js index 2adac97a80..096c59b8a1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -89,6 +89,16 @@ var _exampleProtractorBoilerplateFiles = [ 'tsconfig.json' ]; +function isDartPath(path) { + // Testing via indexOf() for now. If we need to match only paths with folders + // named 'dart' vs 'dart*' then try: path.match('/dart(/|$)') != null; + return path.indexOf('/dart') > -1; +} + +function excludeDartPaths(paths) { + return paths.filter(function (p) { return !isDartPath(p); }); +} + /** * Run Protractor End-to-End Specs for Doc Samples * Alias for 'run-e2e-tests' @@ -165,7 +175,6 @@ function runE2e() { // with the corresponding apps that they should run under. Then run // each app/spec collection sequentially. function findAndRunE2eTests(filter, outputFile) { - // create an output file with header. var lang = (argv.lang || '(ts|js)').toLowerCase(); if (lang === 'all') { lang = '(ts|js|dart)'; } @@ -203,8 +212,7 @@ function findAndRunE2eTests(filter, outputFile) { var status = { passed: [], failed: [] }; return examplePaths.reduce(function (promise, examplePath) { return promise.then(function () { - var isDart = examplePath.indexOf('/dart') > -1; - var runTests = isDart ? runE2eDartTests : runE2eTsTests; + var runTests = isDartPath(examplePath) ? runE2eDartTests : runE2eTsTests; return runTests(examplePath, outputFile).then(function(ok) { var arr = ok ? status.passed : status.failed; arr.push(examplePath); @@ -375,7 +383,7 @@ gulp.task('add-example-boilerplate', function() { }); realPath = path.join(EXAMPLES_PATH, '/typings'); - var typingsPaths = getTypingsPaths(EXAMPLES_PATH); + var typingsPaths = excludeDartPaths(getTypingsPaths(EXAMPLES_PATH)); typingsPaths.forEach(function(linkPath) { gutil.log("symlinking " + linkPath + ' -> ' + realPath) fsUtils.addSymlink(realPath, linkPath); @@ -398,16 +406,18 @@ function copyExampleBoilerplate() { var sourceFiles = _exampleBoilerplateFiles.map(function(fn) { return path.join(EXAMPLES_PATH, fn); }); - var examplePaths = getExamplePaths(EXAMPLES_PATH); + var examplePaths = excludeDartPaths(getExamplePaths(EXAMPLES_PATH)); var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles.map(function(fn){ return path.join(EXAMPLES_PATH, fn); }); var dartExampleWebPaths = getDartExampleWebPaths(EXAMPLES_PATH); - return copyFiles(sourceFiles, examplePaths) + // Make boilerplate files read-only to avoid that they be edited by mistake. + var destFileMode = '444'; + return copyFiles(sourceFiles, examplePaths, destFileMode) .then(function() { - return copyFiles(dartWebSourceFiles, dartExampleWebPaths); + return copyFiles(dartWebSourceFiles, dartExampleWebPaths, destFileMode); }) // copy certain files from _examples/_protractor dir to each subdir that contains an e2e-spec file. .then(function() { @@ -415,7 +425,7 @@ function copyExampleBoilerplate() { _exampleProtractorBoilerplateFiles .map(function(name) {return path.join(EXAMPLES_PROTRACTOR_PATH, name);});; var e2eSpecPaths = getE2eSpecPaths(EXAMPLES_PATH); - return copyFiles(protractorSourceFiles, e2eSpecPaths); + return copyFiles(protractorSourceFiles, e2eSpecPaths, destFileMode); }); } @@ -789,16 +799,23 @@ function showHideExampleNodeModules(showOrHide) { } } - +// Copies fileNames into destPaths, setting the mode of the +// files at the destination as optional_destFileMode if given. // returns a promise -function copyFiles(fileNames, destPaths) { +function copyFiles(fileNames, destPaths, optional_destFileMode) { var copy = Q.denodeify(fsExtra.copy); + var chmod = Q.denodeify(fsExtra.chmod); var copyPromises = []; destPaths.forEach(function(destPath) { fileNames.forEach(function(fileName) { var baseName = path.basename(fileName); var destName = path.join(destPath, baseName); var p = copy(fileName, destName, { clobber: true}); + if(optional_destFileMode !== undefined) { + p = p.then(function () { + return chmod(destName, optional_destFileMode); + }); + } copyPromises.push(p); }); }); diff --git a/public/docs/_examples/.gitignore b/public/docs/_examples/.gitignore index 449fd35581..768c5e9d97 100644 --- a/public/docs/_examples/.gitignore +++ b/public/docs/_examples/.gitignore @@ -1,23 +1,17 @@ +# _exampleBoilerplateFiles .editorconfig -.idea -.vscode -styles.css -typings -typings.json -node_modules -jspm_packages -*.js.map -package.json karma.conf.js karma-test-shim.js +package.json +*/**/styles.css +systemjs.config.js tsconfig.json tslint.json +typings.json wallaby.js -npm-debug*. + protractor.config.js -systemjs.config.js _test-output -_temp **/ts/**/*.js **/ts-snippets/**/*.js *.d.ts