From 383738afaf453bcfe265922a24913e9b69d120b3 Mon Sep 17 00:00:00 2001 From: Michael Prentice Date: Sat, 13 Jan 2018 04:30:55 -0500 Subject: [PATCH] build: configure ESLint coverage for gulp, scripts, docs, config configure parts of the repo for ES5 (src, docs/app/js) configure parts of the repo for ES6 (scripts, gulp, config) remove unused committers.json clean up ESLint errors --- .eslintignore | 15 +++ .eslintrc.json | 61 ++++++++-- .gitignore | 2 + committers.json | 1 - config/build.config.js | 4 +- config/karma-ci.conf.js | 8 +- config/karma-docs.conf.js | 12 +- config/karma-sauce.conf.js | 8 +- config/karma.conf.js | 14 ++- config/ngModuleData.js | 15 ++- docs/app/js/anchor.js | 2 +- docs/app/js/app.js | 22 ++-- docs/app/js/scripts.js | 6 +- docs/config/index.js | 15 +-- docs/config/processors/buildConfig.js | 18 ++- docs/config/processors/componentsData.js | 41 +++---- docs/config/processors/content.js | 6 +- docs/config/processors/indexPage.js | 4 +- docs/gulpfile.js | 73 +++++------ docs/spec/codepen.spec.js | 12 +- docs/spec/demo.spec.js | 2 +- gulp/config.js | 7 +- gulp/const.js | 15 +-- gulp/tasks/build-all-modules.js | 25 ++-- gulp/tasks/build-contributors.js | 24 +--- gulp/tasks/build-demo.js | 2 +- gulp/tasks/build-js.js | 2 +- gulp/tasks/build-module-demo.js | 32 ++--- gulp/tasks/build-scss.js | 48 ++++---- gulp/tasks/changelog.js | 42 +++---- gulp/tasks/ddescribe-iit.js | 56 ++++----- gulp/tasks/docs.js | 4 +- gulp/tasks/jshint.js | 6 +- gulp/tasks/karma-fast.js | 20 +-- gulp/tasks/karma-sauce.js | 6 +- gulp/tasks/karma-watch.js | 13 +- gulp/tasks/karma.js | 15 +-- gulp/tasks/server.js | 10 +- gulp/tasks/site.js | 4 +- gulp/tasks/watch-demo.js | 12 +- gulp/tasks/watch.js | 2 +- gulp/util.js | 97 ++++++++------- gulpfile.js | 4 +- package.json | 2 +- release.js | 101 ++++++++-------- scripts/find-max-version.js | 26 ++-- scripts/gulp-utils.js | 148 +++++++++++------------ updateVersionPicker.js | 37 ++---- 48 files changed, 551 insertions(+), 550 deletions(-) create mode 100644 .eslintignore delete mode 100644 committers.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..450bd80fce --- /dev/null +++ b/.eslintignore @@ -0,0 +1,15 @@ +# Ignore miscellaneous folders +.github/ +.idea/ +node_modules/ +dist/ +tmp/ +bower-material/ +code.material.angularjs.org/ + +# Ignore certain project files +# TODO Remove test/ at some point when the files there are fit for linting +test/ +src/core/services/compiler/compiler.spec.js +docs/config/template/*.js +docs/app/js/highlight.pack.js diff --git a/.eslintrc.json b/.eslintrc.json index 18e0d149b8..4e2192b372 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { "extends": "eslint:recommended", "parserOptions": { - "ecmaVersion": 8 + "ecmaVersion": 8 }, "rules": { "accessor-pairs": "error", @@ -10,7 +10,10 @@ "array-callback-return": "error", "array-element-newline": "off", "arrow-body-style": "error", - "arrow-parens": "error", + "arrow-parens": [ + "error", + "as-needed" + ], "arrow-spacing": "error", "block-scoped-var": "off", "block-spacing": "off", @@ -42,7 +45,7 @@ "func-style": "off", "generator-star-spacing": "error", "getter-return": "error", - "global-require": "error", + "global-require": "off", "guard-for-in": "off", "handle-callback-err": "error", "id-blacklist": "error", @@ -78,6 +81,9 @@ "no-caller": "error", "no-catch-shadow": "error", "no-confusing-arrow": "error", + "no-console": [ + "off" + ], "no-constant-condition": [ "error", { @@ -85,7 +91,7 @@ } ], "no-continue": "off", - "no-div-regex": "error", + "no-div-regex": "off", "no-duplicate-imports": "error", "no-else-return": "off", "no-empty-function": "off", @@ -138,7 +144,7 @@ "no-param-reassign": "off", "no-path-concat": "error", "no-plusplus": "off", - "no-process-env": "error", + "no-process-env": "off", "no-process-exit": "error", "no-proto": "error", "no-prototype-builtins": "off", @@ -155,7 +161,7 @@ "no-shadow": "off", "no-shadow-restricted-names": "error", "no-spaced-func": "off", - "no-sync": "error", + "no-sync": "off", "no-tabs": "off", "no-template-curly-in-string": "error", "no-ternary": "off", @@ -240,15 +246,50 @@ "no-unexpected-multiline": "off" }, "env": { - "browser": true + "node": true }, "globals": { - "angular": true, - "CryptoJS": true + "angular": true }, "overrides": [ { - "files": ["**/*.spec.js"], + "files": [ + "docs/app/js/**/*", + "src/**/*" + ], + "parserOptions": { + "ecmaVersion": 5 + }, + "env": { + "browser": true + }, + "rules": { + "arrow-parens": "error", + "global-require": "error", + "no-console": [ + "error" + ], + "no-process-env": "error", + "no-sync": "error" + }, + "globals": { + "angular": true, + "CryptoJS": true, + "hljs": true + } + }, + { + "files": [ + "scripts/**/*" + ], + "rules": { + "no-process-env": "off" + } + }, + { + "files": [ + "**/*.spec.js" + ], "env": { "jasmine": true }, diff --git a/.gitignore b/.gitignore index 788ad7d38c..b6ddbd89cb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ dist .nvmrc tmp/ .editorconfig +bower-material/ +code.material.angularjs.org/ diff --git a/committers.json b/committers.json deleted file mode 100644 index 859b0f7531..0000000000 --- a/committers.json +++ /dev/null @@ -1 +0,0 @@ -{"imageSize":117,"total":115,"contributors":[[{"url":"https://api.github.com/users/247GradLabs","login":"247GradLabs","avatar_url":"https://avatars.githubusercontent.com/u/19302650?v=3&s=117","html_url":"https://github.com/247GradLabs","contributions":1},{"url":"https://api.github.com/users/Aaron-Hartwig","login":"Aaron-Hartwig","avatar_url":"https://avatars.githubusercontent.com/u/5115774?v=3&s=117","html_url":"https://github.com/Aaron-Hartwig","contributions":1},{"url":"https://api.github.com/users/AaronBuxbaum","login":"AaronBuxbaum","avatar_url":"https://avatars.githubusercontent.com/u/5578581?v=3&s=117","html_url":"https://github.com/AaronBuxbaum","contributions":1},{"url":"https://api.github.com/users/ademuri","login":"ademuri","avatar_url":"https://avatars.githubusercontent.com/u/3051618?v=3&s=117","html_url":"https://github.com/ademuri","contributions":1},{"url":"https://api.github.com/users/AdriVanHoudt","login":"AdriVanHoudt","avatar_url":"https://avatars.githubusercontent.com/u/2361826?v=3&s=117","html_url":"https://github.com/AdriVanHoudt","contributions":2},{"url":"https://api.github.com/users/albuquerquev","login":"albuquerquev","avatar_url":"https://avatars.githubusercontent.com/u/19099?v=3&s=117","html_url":"https://github.com/albuquerquev","contributions":1}],[{"url":"https://api.github.com/users/alex-chuev","login":"alex-chuev","avatar_url":"https://avatars.githubusercontent.com/u/6698071?v=3&s=117","html_url":"https://github.com/alex-chuev","contributions":1},{"url":"https://api.github.com/users/amitport","login":"amitport","avatar_url":"https://avatars.githubusercontent.com/u/1131991?v=3&s=117","html_url":"https://github.com/amitport","contributions":2},{"url":"https://api.github.com/users/andresgottlieb","login":"andresgottlieb","avatar_url":"https://avatars.githubusercontent.com/u/1126905?v=3&s=117","html_url":"https://github.com/andresgottlieb","contributions":1},{"url":"https://api.github.com/users/aortyl","login":"aortyl","avatar_url":"https://avatars.githubusercontent.com/u/10928389?v=3&s=117","html_url":"https://github.com/aortyl","contributions":1},{"url":"https://api.github.com/users/areologist","login":"areologist","avatar_url":"https://avatars.githubusercontent.com/u/4918688?v=3&s=117","html_url":"https://github.com/areologist","contributions":1},{"url":"https://api.github.com/users/barryvdh","login":"barryvdh","avatar_url":"https://avatars.githubusercontent.com/u/973269?v=3&s=117","html_url":"https://github.com/barryvdh","contributions":2}],[{"url":"https://api.github.com/users/BevanR","login":"BevanR","avatar_url":"https://avatars.githubusercontent.com/u/325176?v=3&s=117","html_url":"https://github.com/BevanR","contributions":2},{"url":"https://api.github.com/users/bradrich","login":"bradrich","avatar_url":"https://avatars.githubusercontent.com/u/3429878?v=3&s=117","html_url":"https://github.com/bradrich","contributions":5},{"url":"https://api.github.com/users/bubersson","login":"bubersson","avatar_url":"https://avatars.githubusercontent.com/u/982922?v=3&s=117","html_url":"https://github.com/bubersson","contributions":1},{"url":"https://api.github.com/users/bvahdat","login":"bvahdat","avatar_url":"https://avatars.githubusercontent.com/u/3122177?v=3&s=117","html_url":"https://github.com/bvahdat","contributions":2},{"url":"https://api.github.com/users/cah-alexsukhodolsky","login":"cah-alexsukhodolsky","avatar_url":"https://avatars.githubusercontent.com/u/12052245?v=3&s=117","html_url":"https://github.com/cah-alexsukhodolsky","contributions":1},{"url":"https://api.github.com/users/chrisconover","login":"chrisconover","avatar_url":"https://avatars.githubusercontent.com/u/694311?v=3&s=117","html_url":"https://github.com/chrisconover","contributions":1}],[{"url":"https://api.github.com/users/chrisguerrero","login":"chrisguerrero","avatar_url":"https://avatars.githubusercontent.com/u/3720304?v=3&s=117","html_url":"https://github.com/chrisguerrero","contributions":2},{"url":"https://api.github.com/users/clshortfuse","login":"clshortfuse","avatar_url":"https://avatars.githubusercontent.com/u/9271155?v=3&s=117","html_url":"https://github.com/clshortfuse","contributions":17},{"url":"https://api.github.com/users/code-tree","login":"code-tree","avatar_url":"https://avatars.githubusercontent.com/u/11289719?v=3&s=117","html_url":"https://github.com/code-tree","contributions":3},{"url":"https://api.github.com/users/crisbeto","login":"crisbeto","avatar_url":"https://avatars.githubusercontent.com/u/4450522?v=3&s=117","html_url":"https://github.com/crisbeto","contributions":114},{"url":"https://api.github.com/users/cssensei","login":"cssensei","avatar_url":"https://avatars.githubusercontent.com/u/1344020?v=3&s=117","html_url":"https://github.com/cssensei","contributions":1},{"url":"https://api.github.com/users/cyx8808","login":"cyx8808","avatar_url":"https://avatars.githubusercontent.com/u/9927197?v=3&s=117","html_url":"https://github.com/cyx8808","contributions":1}],[{"url":"https://api.github.com/users/daniel-nagy","login":"daniel-nagy","avatar_url":"https://avatars.githubusercontent.com/u/1622446?v=3&s=117","html_url":"https://github.com/daniel-nagy","contributions":3},{"url":"https://api.github.com/users/danjarvis","login":"danjarvis","avatar_url":"https://avatars.githubusercontent.com/u/116640?v=3&s=117","html_url":"https://github.com/danjarvis","contributions":1},{"url":"https://api.github.com/users/danlevan","login":"danlevan","avatar_url":"https://avatars.githubusercontent.com/u/297050?v=3&s=117","html_url":"https://github.com/danlevan","contributions":2},{"url":"https://api.github.com/users/DannyBurnett","login":"DannyBurnett","avatar_url":"https://avatars.githubusercontent.com/u/8415547?v=3&s=117","html_url":"https://github.com/DannyBurnett","contributions":1},{"url":"https://api.github.com/users/dansanderson","login":"dansanderson","avatar_url":"https://avatars.githubusercontent.com/u/408973?v=3&s=117","html_url":"https://github.com/dansanderson","contributions":3},{"url":"https://api.github.com/users/david-gang","login":"david-gang","avatar_url":"https://avatars.githubusercontent.com/u/1292882?v=3&s=117","html_url":"https://github.com/david-gang","contributions":4}],[{"url":"https://api.github.com/users/david-meza","login":"david-meza","avatar_url":"https://avatars.githubusercontent.com/u/11840636?v=3&s=117","html_url":"https://github.com/david-meza","contributions":1},{"url":"https://api.github.com/users/davidenke","login":"davidenke","avatar_url":"https://avatars.githubusercontent.com/u/275960?v=3&s=117","html_url":"https://github.com/davidenke","contributions":1},{"url":"https://api.github.com/users/DavidFrahm","login":"DavidFrahm","avatar_url":"https://avatars.githubusercontent.com/u/889791?v=3&s=117","html_url":"https://github.com/DavidFrahm","contributions":1},{"url":"https://api.github.com/users/dentych","login":"dentych","avatar_url":"https://avatars.githubusercontent.com/u/2256372?v=3&s=117","html_url":"https://github.com/dentych","contributions":1},{"url":"https://api.github.com/users/DerekLouie","login":"DerekLouie","avatar_url":"https://avatars.githubusercontent.com/u/709204?v=3&s=117","html_url":"https://github.com/DerekLouie","contributions":8},{"url":"https://api.github.com/users/DevVersion","login":"DevVersion","avatar_url":"https://avatars.githubusercontent.com/u/4987015?v=3&s=117","html_url":"https://github.com/DevVersion","contributions":211}],[{"url":"https://api.github.com/users/dirkharbinson","login":"dirkharbinson","avatar_url":"https://avatars.githubusercontent.com/u/6855986?v=3&s=117","html_url":"https://github.com/dirkharbinson","contributions":1},{"url":"https://api.github.com/users/Djulia","login":"Djulia","avatar_url":"https://avatars.githubusercontent.com/u/3987507?v=3&s=117","html_url":"https://github.com/Djulia","contributions":1},{"url":"https://api.github.com/users/EladBezalel","login":"EladBezalel","avatar_url":"https://avatars.githubusercontent.com/u/6004537?v=3&s=117","html_url":"https://github.com/EladBezalel","contributions":110},{"url":"https://api.github.com/users/Emeegeemee","login":"Emeegeemee","avatar_url":"https://avatars.githubusercontent.com/u/4241156?v=3&s=117","html_url":"https://github.com/Emeegeemee","contributions":2},{"url":"https://api.github.com/users/epelc","login":"epelc","avatar_url":"https://avatars.githubusercontent.com/u/5204642?v=3&s=117","html_url":"https://github.com/epelc","contributions":10},{"url":"https://api.github.com/users/ericgundrum","login":"ericgundrum","avatar_url":"https://avatars.githubusercontent.com/u/1779578?v=3&s=117","html_url":"https://github.com/ericgundrum","contributions":2}],[{"url":"https://api.github.com/users/ErinCoughlan","login":"ErinCoughlan","avatar_url":"https://avatars.githubusercontent.com/u/2660421?v=3&s=117","html_url":"https://github.com/ErinCoughlan","contributions":21},{"url":"https://api.github.com/users/fhernandezn","login":"fhernandezn","avatar_url":"https://avatars.githubusercontent.com/u/12898908?v=3&s=117","html_url":"https://github.com/fhernandezn","contributions":1},{"url":"https://api.github.com/users/gkalpak","login":"gkalpak","avatar_url":"https://avatars.githubusercontent.com/u/8604205?v=3&s=117","html_url":"https://github.com/gkalpak","contributions":22},{"url":"https://api.github.com/users/gmoothart","login":"gmoothart","avatar_url":"https://avatars.githubusercontent.com/u/3227?v=3&s=117","html_url":"https://github.com/gmoothart","contributions":5},{"url":"https://api.github.com/users/hosseinkhaledi","login":"hosseinkhaledi","avatar_url":"https://avatars.githubusercontent.com/u/5648887?v=3&s=117","html_url":"https://github.com/hosseinkhaledi","contributions":1},{"url":"https://api.github.com/users/ilovett","login":"ilovett","avatar_url":"https://avatars.githubusercontent.com/u/1776100?v=3&s=117","html_url":"https://github.com/ilovett","contributions":1}],[{"url":"https://api.github.com/users/IPRIT","login":"IPRIT","avatar_url":"https://avatars.githubusercontent.com/u/1553519?v=3&s=117","html_url":"https://github.com/IPRIT","contributions":1},{"url":"https://api.github.com/users/isaaclyman","login":"isaaclyman","avatar_url":"https://avatars.githubusercontent.com/u/9139369?v=3&s=117","html_url":"https://github.com/isaaclyman","contributions":5},{"url":"https://api.github.com/users/ivoviz","login":"ivoviz","avatar_url":"https://avatars.githubusercontent.com/u/1143746?v=3&s=117","html_url":"https://github.com/ivoviz","contributions":1},{"url":"https://api.github.com/users/JA44","login":"JA44","avatar_url":"https://avatars.githubusercontent.com/u/1987280?v=3&s=117","html_url":"https://github.com/JA44","contributions":1},{"url":"https://api.github.com/users/jadjoubran","login":"jadjoubran","avatar_url":"https://avatars.githubusercontent.com/u/2265232?v=3&s=117","html_url":"https://github.com/jadjoubran","contributions":3},{"url":"https://api.github.com/users/jamesfer","login":"jamesfer","avatar_url":"https://avatars.githubusercontent.com/u/7485167?v=3&s=117","html_url":"https://github.com/jamesfer","contributions":1}],[{"url":"https://api.github.com/users/jayeshanandani","login":"jayeshanandani","avatar_url":"https://avatars.githubusercontent.com/u/3860787?v=3&s=117","html_url":"https://github.com/jayeshanandani","contributions":1},{"url":"https://api.github.com/users/jelbourn","login":"jelbourn","avatar_url":"https://avatars.githubusercontent.com/u/838736?v=3&s=117","html_url":"https://github.com/jelbourn","contributions":146},{"url":"https://api.github.com/users/jshoudy11","login":"jshoudy11","avatar_url":"https://avatars.githubusercontent.com/u/17074023?v=3&s=117","html_url":"https://github.com/jshoudy11","contributions":1},{"url":"https://api.github.com/users/JSMike","login":"JSMike","avatar_url":"https://avatars.githubusercontent.com/u/4580828?v=3&s=117","html_url":"https://github.com/JSMike","contributions":1},{"url":"https://api.github.com/users/jsr6720","login":"jsr6720","avatar_url":"https://avatars.githubusercontent.com/u/502432?v=3&s=117","html_url":"https://github.com/jsr6720","contributions":2},{"url":"https://api.github.com/users/julienmartin","login":"julienmartin","avatar_url":"https://avatars.githubusercontent.com/u/1759785?v=3&s=117","html_url":"https://github.com/julienmartin","contributions":2}],[{"url":"https://api.github.com/users/KarenParker","login":"KarenParker","avatar_url":"https://avatars.githubusercontent.com/u/16341592?v=3&s=117","html_url":"https://github.com/KarenParker","contributions":7},{"url":"https://api.github.com/users/keenondrums","login":"keenondrums","avatar_url":"https://avatars.githubusercontent.com/u/12794628?v=3&s=117","html_url":"https://github.com/keenondrums","contributions":1},{"url":"https://api.github.com/users/kseamon","login":"kseamon","avatar_url":"https://avatars.githubusercontent.com/u/923677?v=3&s=117","html_url":"https://github.com/kseamon","contributions":19},{"url":"https://api.github.com/users/kwypchlo","login":"kwypchlo","avatar_url":"https://avatars.githubusercontent.com/u/3755029?v=3&s=117","html_url":"https://github.com/kwypchlo","contributions":1},{"url":"https://api.github.com/users/leocaseiro","login":"leocaseiro","avatar_url":"https://avatars.githubusercontent.com/u/940070?v=3&s=117","html_url":"https://github.com/leocaseiro","contributions":1},{"url":"https://api.github.com/users/levindixon","login":"levindixon","avatar_url":"https://avatars.githubusercontent.com/u/1746081?v=3&s=117","html_url":"https://github.com/levindixon","contributions":1}],[{"url":"https://api.github.com/users/marcysutton","login":"marcysutton","avatar_url":"https://avatars.githubusercontent.com/u/1045233?v=3&s=117","html_url":"https://github.com/marcysutton","contributions":5},{"url":"https://api.github.com/users/martineckardt","login":"martineckardt","avatar_url":"https://avatars.githubusercontent.com/u/10773395?v=3&s=117","html_url":"https://github.com/martineckardt","contributions":1},{"url":"https://api.github.com/users/matsko","login":"matsko","avatar_url":"https://avatars.githubusercontent.com/u/93018?v=3&s=117","html_url":"https://github.com/matsko","contributions":11},{"url":"https://api.github.com/users/MattCatz","login":"MattCatz","avatar_url":"https://avatars.githubusercontent.com/u/14895427?v=3&s=117","html_url":"https://github.com/MattCatz","contributions":1},{"url":"https://api.github.com/users/meatherly","login":"meatherly","avatar_url":"https://avatars.githubusercontent.com/u/1327960?v=3&s=117","html_url":"https://github.com/meatherly","contributions":1},{"url":"https://api.github.com/users/mertdeg2","login":"mertdeg2","avatar_url":"https://avatars.githubusercontent.com/u/16231118?v=3&s=117","html_url":"https://github.com/mertdeg2","contributions":2}],[{"url":"https://api.github.com/users/mgilson","login":"mgilson","avatar_url":"https://avatars.githubusercontent.com/u/5216702?v=3&s=117","html_url":"https://github.com/mgilson","contributions":3},{"url":"https://api.github.com/users/mhansen","login":"mhansen","avatar_url":"https://avatars.githubusercontent.com/u/105529?v=3&s=117","html_url":"https://github.com/mhansen","contributions":1},{"url":"https://api.github.com/users/mkowalchuk","login":"mkowalchuk","avatar_url":"https://avatars.githubusercontent.com/u/1266924?v=3&s=117","html_url":"https://github.com/mkowalchuk","contributions":1},{"url":"https://api.github.com/users/montgomery1944","login":"montgomery1944","avatar_url":"https://avatars.githubusercontent.com/u/5021862?v=3&s=117","html_url":"https://github.com/montgomery1944","contributions":1},{"url":"https://api.github.com/users/naomiblack","login":"naomiblack","avatar_url":"https://avatars.githubusercontent.com/u/2286589?v=3&s=117","html_url":"https://github.com/naomiblack","contributions":20},{"url":"https://api.github.com/users/neko1235","login":"neko1235","avatar_url":"https://avatars.githubusercontent.com/u/13606126?v=3&s=117","html_url":"https://github.com/neko1235","contributions":1}],[{"url":"https://api.github.com/users/Nickproger","login":"Nickproger","avatar_url":"https://avatars.githubusercontent.com/u/1409078?v=3&s=117","html_url":"https://github.com/Nickproger","contributions":1},{"url":"https://api.github.com/users/nissoh","login":"nissoh","avatar_url":"https://avatars.githubusercontent.com/u/1410797?v=3&s=117","html_url":"https://github.com/nissoh","contributions":1},{"url":"https://api.github.com/users/ofirmgr","login":"ofirmgr","avatar_url":"https://avatars.githubusercontent.com/u/9841636?v=3&s=117","html_url":"https://github.com/ofirmgr","contributions":1},{"url":"https://api.github.com/users/oliversalzburg","login":"oliversalzburg","avatar_url":"https://avatars.githubusercontent.com/u/1658949?v=3&s=117","html_url":"https://github.com/oliversalzburg","contributions":1},{"url":"https://api.github.com/users/OzzieOrca","login":"OzzieOrca","avatar_url":"https://avatars.githubusercontent.com/u/756501?v=3&s=117","html_url":"https://github.com/OzzieOrca","contributions":1},{"url":"https://api.github.com/users/paullang","login":"paullang","avatar_url":"https://avatars.githubusercontent.com/u/1221447?v=3&s=117","html_url":"https://github.com/paullang","contributions":1}],[{"url":"https://api.github.com/users/pdore-netfore","login":"pdore-netfore","avatar_url":"https://avatars.githubusercontent.com/u/12851337?v=3&s=117","html_url":"https://github.com/pdore-netfore","contributions":2},{"url":"https://api.github.com/users/petebacondarwin","login":"petebacondarwin","avatar_url":"https://avatars.githubusercontent.com/u/15655?v=3&s=117","html_url":"https://github.com/petebacondarwin","contributions":9},{"url":"https://api.github.com/users/philippbosch","login":"philippbosch","avatar_url":"https://avatars.githubusercontent.com/u/57509?v=3&s=117","html_url":"https://github.com/philippbosch","contributions":1},{"url":"https://api.github.com/users/pra85","login":"pra85","avatar_url":"https://avatars.githubusercontent.com/u/829526?v=3&s=117","html_url":"https://github.com/pra85","contributions":1},{"url":"https://api.github.com/users/programmist","login":"programmist","avatar_url":"https://avatars.githubusercontent.com/u/527082?v=3&s=117","html_url":"https://github.com/programmist","contributions":11},{"url":"https://api.github.com/users/remcohaszing","login":"remcohaszing","avatar_url":"https://avatars.githubusercontent.com/u/779047?v=3&s=117","html_url":"https://github.com/remcohaszing","contributions":2}],[{"url":"https://api.github.com/users/robertmesserle","login":"robertmesserle","avatar_url":"https://avatars.githubusercontent.com/u/571363?v=3&s=117","html_url":"https://github.com/robertmesserle","contributions":709},{"url":"https://api.github.com/users/rschmukler","login":"rschmukler","avatar_url":"https://avatars.githubusercontent.com/u/651740?v=3&s=117","html_url":"https://github.com/rschmukler","contributions":374},{"url":"https://api.github.com/users/snaumets","login":"snaumets","avatar_url":"https://avatars.githubusercontent.com/u/5865234?v=3&s=117","html_url":"https://github.com/snaumets","contributions":1},{"url":"https://api.github.com/users/solojavier","login":"solojavier","avatar_url":"https://avatars.githubusercontent.com/u/1088010?v=3&s=117","html_url":"https://github.com/solojavier","contributions":1},{"url":"https://api.github.com/users/soooooot","login":"soooooot","avatar_url":"https://avatars.githubusercontent.com/u/1481589?v=3&s=117","html_url":"https://github.com/soooooot","contributions":2},{"url":"https://api.github.com/users/soul-wish","login":"soul-wish","avatar_url":"https://avatars.githubusercontent.com/u/1968098?v=3&s=117","html_url":"https://github.com/soul-wish","contributions":1}],[{"url":"https://api.github.com/users/SpikesCafe-google","login":"SpikesCafe-google","avatar_url":"https://avatars.githubusercontent.com/u/16656302?v=3&s=117","html_url":"https://github.com/SpikesCafe-google","contributions":1},{"url":"https://api.github.com/users/Splaktar","login":"Splaktar","avatar_url":"https://avatars.githubusercontent.com/u/3506071?v=3&s=117","html_url":"https://github.com/Splaktar","contributions":18},{"url":"https://api.github.com/users/sryzycki","login":"sryzycki","avatar_url":"https://avatars.githubusercontent.com/u/4108644?v=3&s=117","html_url":"https://github.com/sryzycki","contributions":1},{"url":"https://api.github.com/users/StefanFeederle","login":"StefanFeederle","avatar_url":"https://avatars.githubusercontent.com/u/11903965?v=3&s=117","html_url":"https://github.com/StefanFeederle","contributions":1},{"url":"https://api.github.com/users/ThomasBurleson","login":"ThomasBurleson","avatar_url":"https://avatars.githubusercontent.com/u/210413?v=3&s=117","html_url":"https://github.com/ThomasBurleson","contributions":850},{"url":"https://api.github.com/users/tihuan","login":"tihuan","avatar_url":"https://avatars.githubusercontent.com/u/6309723?v=3&s=117","html_url":"https://github.com/tihuan","contributions":1}],[{"url":"https://api.github.com/users/timlevett","login":"timlevett","avatar_url":"https://avatars.githubusercontent.com/u/3534544?v=3&s=117","html_url":"https://github.com/timlevett","contributions":1},{"url":"https://api.github.com/users/tirana","login":"tirana","avatar_url":"https://avatars.githubusercontent.com/u/5245919?v=3&s=117","html_url":"https://github.com/tirana","contributions":1},{"url":"https://api.github.com/users/topherfangio","login":"topherfangio","avatar_url":"https://avatars.githubusercontent.com/u/54370?v=3&s=117","html_url":"https://github.com/topherfangio","contributions":146},{"url":"https://api.github.com/users/trainerbill","login":"trainerbill","avatar_url":"https://avatars.githubusercontent.com/u/3578259?v=3&s=117","html_url":"https://github.com/trainerbill","contributions":1},{"url":"https://api.github.com/users/VictorCoding","login":"VictorCoding","avatar_url":"https://avatars.githubusercontent.com/u/6878222?v=3&s=117","html_url":"https://github.com/VictorCoding","contributions":1},{"url":"https://api.github.com/users/voyti","login":"voyti","avatar_url":"https://avatars.githubusercontent.com/u/6819634?v=3&s=117","html_url":"https://github.com/voyti","contributions":1}],[{"url":"https://api.github.com/users/webmaxru","login":"webmaxru","avatar_url":"https://avatars.githubusercontent.com/u/1560278?v=3&s=117","html_url":"https://github.com/webmaxru","contributions":1},{"url":"https://api.github.com/users/whitneyit","login":"whitneyit","avatar_url":"https://avatars.githubusercontent.com/u/995120?v=3&s=117","html_url":"https://github.com/whitneyit","contributions":1},{"url":"https://api.github.com/users/x87","login":"x87","avatar_url":"https://avatars.githubusercontent.com/u/5698288?v=3&s=117","html_url":"https://github.com/x87","contributions":1},{"url":"https://api.github.com/users/xenit-raven","login":"xenit-raven","avatar_url":"https://avatars.githubusercontent.com/u/10155219?v=3&s=117","html_url":"https://github.com/xenit-raven","contributions":2},{"url":"https://api.github.com/users/zacyu","login":"zacyu","avatar_url":"https://avatars.githubusercontent.com/u/1730305?v=3&s=117","html_url":"https://github.com/zacyu","contributions":1},{"url":"https://api.github.com/users/zbjornson","login":"zbjornson","avatar_url":"https://avatars.githubusercontent.com/u/469365?v=3&s=117","html_url":"https://github.com/zbjornson","contributions":1}],[{"url":"https://api.github.com/users/zeitiger","login":"zeitiger","avatar_url":"https://avatars.githubusercontent.com/u/656302?v=3&s=117","html_url":"https://github.com/zeitiger","contributions":1}]]} diff --git a/config/build.config.js b/config/build.config.js index 298a9887db..b77e3258f1 100644 --- a/config/build.config.js +++ b/config/build.config.js @@ -1,6 +1,4 @@ -var pkg = require('../package.json'); -var fs = require('fs'); -var versionFile = __dirname + '/../dist/commit'; +const pkg = require('../package.json'); module.exports = { ngVersion: '1.5.5', diff --git a/config/karma-ci.conf.js b/config/karma-ci.conf.js index 30e6234458..490909c9ef 100644 --- a/config/karma-ci.conf.js +++ b/config/karma-ci.conf.js @@ -1,4 +1,4 @@ -var baseKarma = require('./karma.conf.js'); +const baseKarma = require('./karma.conf.js'); module.exports = function(config) { baseKarma(config); @@ -6,7 +6,7 @@ module.exports = function(config) { // Override defaults with custom CI settings config.set({ colors: false, - singleRun:true, + singleRun: true, autoWatch: false, logLevel: config.LOG_DEBUG, @@ -17,7 +17,7 @@ module.exports = function(config) { client: { // Do not clear the context as this can cause reload failures with Jasmine - clearContext:false + clearContext: false }, // This is the new content for your travis-ci configuration test @@ -30,7 +30,7 @@ module.exports = function(config) { } }); - var browsers = process.env.TRAVIS ? ['Chrome_travis_ci'] : []; + const browsers = process.env.TRAVIS ? ['Chrome_travis_ci'] : []; config.browsers = browsers.concat(config.browsers); }; diff --git a/config/karma-docs.conf.js b/config/karma-docs.conf.js index 06d5e4e7a8..7016cb4a00 100644 --- a/config/karma-docs.conf.js +++ b/config/karma-docs.conf.js @@ -1,14 +1,14 @@ +const path = require('path'); + // Used for running unit tests against the docs site // Unit tests can be run using gulp docs-karma module.exports = function(config) { - var UNCOMPILED_SRC = [ + // releaseMode is a custom configuration option. + const testSrc = [ 'docs/spec/**/*.spec.js' ]; - - // releaseMode is a custom configuration option. - var testSrc = UNCOMPILED_SRC; - var dependencies = process.env.KARMA_TEST_JQUERY ? + let dependencies = process.env.KARMA_TEST_JQUERY ? ['node_modules/jquery/dist/jquery.js'] : []; dependencies = dependencies.concat([ @@ -26,7 +26,7 @@ module.exports = function(config) { config.set({ - basePath: __dirname + '/..', + basePath: path.join(__dirname, '/..'), frameworks: ['jasmine'], files: dependencies.concat(testSrc), diff --git a/config/karma-sauce.conf.js b/config/karma-sauce.conf.js index d0045c8a62..da94b6c46a 100644 --- a/config/karma-sauce.conf.js +++ b/config/karma-sauce.conf.js @@ -1,8 +1,8 @@ -var baseKarma = require('./karma.conf.js'); +const baseKarma = require('./karma.conf.js'); +const sauceBrowsers = require('./sauce-browsers.json'); if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) { - console.log('Environment variables SAUCE_USERNAME and SAUCE_ACCESS_KEY must be set to run saucelabs with Karma.'); - process.exit(1); + throw new Error('Environment variables SAUCE_USERNAME and SAUCE_ACCESS_KEY must be set to run saucelabs with Karma.'); } process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join(''); @@ -17,7 +17,7 @@ module.exports = function(config) { // Those pre-configured browsers will always run in the CI Release Mode to confirm, that all // previous jobs have passed. browsers: ['SL_CHROME'], //, 'SL_FIREFOX', 'SL_IE11'], - customLaunchers: require('./sauce-browsers.json'), + customLaunchers: sauceBrowsers, captureTimeout: 180 * 1000, browserDisconnectTimeout: 180 * 1000, diff --git a/config/karma.conf.js b/config/karma.conf.js index bfb5914833..c86675a0c8 100644 --- a/config/karma.conf.js +++ b/config/karma.conf.js @@ -1,7 +1,9 @@ +const sauceBrowsers = require('./sauce-browsers.json'); +const path = require('path'); module.exports = function(config) { - var UNCOMPILED_SRC = [ + const UNCOMPILED_SRC = [ // To enabled use of `gulp karma-watch`, // don't use the dist/angular-material.js @@ -23,13 +25,13 @@ module.exports = function(config) { 'src/**/*.spec.js' ]; - var COMPILED_SRC = [ + const COMPILED_SRC = [ 'dist/angular-material.min.css', 'dist/angular-material.min.js', // Minified source 'src/**/*.spec.js' ]; - var dependencies = process.env.KARMA_TEST_JQUERY ? ['node_modules/jquery/dist/jquery.js'] : []; + let dependencies = process.env.KARMA_TEST_JQUERY ? ['node_modules/jquery/dist/jquery.js'] : []; dependencies = dependencies.concat([ 'node_modules/angular/angular.js', 'node_modules/angular-animate/angular-animate.js', @@ -42,14 +44,14 @@ module.exports = function(config) { 'test/angular-material-spec.js' ]); - var testSrc = process.env.KARMA_TEST_COMPRESSED ? COMPILED_SRC : UNCOMPILED_SRC; + const testSrc = process.env.KARMA_TEST_COMPRESSED ? COMPILED_SRC : UNCOMPILED_SRC; config.set({ - basePath: __dirname + '/..', + basePath: path.join(__dirname, '/..'), frameworks: ['jasmine'], files: dependencies.concat(testSrc), - customLaunchers: require('./sauce-browsers.json'), + customLaunchers: sauceBrowsers, browserDisconnectTimeout:500, diff --git a/config/ngModuleData.js b/config/ngModuleData.js index 366c7ab24d..a5e22b4e36 100644 --- a/config/ngModuleData.js +++ b/config/ngModuleData.js @@ -12,8 +12,8 @@ // Define patterns for AngularJS Module definitions -var MATERIAL_ONLY = /\.module\(['|"](material\.[a-zA-Z\-\.]*)['|"]\s*,(\s*\[([^\]]*)\])/; -var ANY = /\.module\(('[^']*'|"[^"]*")\s*,(?:\s*\[([^\]]+)\])?/; +const MATERIAL_ONLY = /\.module\(['|"](material\.[a-zA-Z\-.]*)['|"]\s*,(\s*\[([^\]]*)])/; +const ANY = /\.module\(('[^']*'|"[^"]*")\s*,(?:\s*\[([^\]]+)])?/; /** * Find module definition s that match the module definition pattern @@ -21,10 +21,10 @@ var ANY = /\.module\(('[^']*'|"[^"]*")\s*,(?:\s*\[([^\]]+)\])?/; function buildScanner(pattern) { return function findPatternIn(content) { - var dependencies; - var match = pattern.exec(content || ''); - var moduleName = match ? match[1].replace(/\'/gi,'') : null; - var depsMatch = match && match[2] && match[2].trim(); + let dependencies; + const match = pattern.exec(content || ''); + const moduleName = match ? match[1].replace(/'/gi,'') : null; + const depsMatch = match && match[2] && match[2].trim(); if (depsMatch) { dependencies = depsMatch.split(/\s*,\s*/).map(function(dep) { @@ -38,11 +38,10 @@ function buildScanner(pattern) { module : moduleName || '', dependencies : dependencies || [ ] } : null; - } + }; } module.exports = { material : buildScanner( MATERIAL_ONLY ), any : buildScanner( ANY ) }; - diff --git a/docs/app/js/anchor.js b/docs/app/js/anchor.js index 5c610be2bd..9f5b8dae1f 100644 --- a/docs/app/js/anchor.js +++ b/docs/app/js/anchor.js @@ -9,7 +9,7 @@ function MdAnchorDirective($mdUtil, $compile) { /** @const @type {RegExp} */ - var unsafeCharRegex = /[&\s+$,:;=?@"#{}|^~[`%!'\].\/()*\\]/g; + var unsafeCharRegex = /[&\s+$,:;=?@"#{}|^~[`%!'\]./()*\\]/g; return { restrict: 'E', diff --git a/docs/app/js/app.js b/docs/app/js/app.js index 95a32d4edd..c3da5885c5 100644 --- a/docs/app/js/app.js +++ b/docs/app/js/app.js @@ -272,28 +272,28 @@ function(SERVICES, COMPONENTS, DEMOS, PAGES, $location, $rootScope, $http, $wind name: 'Introduction', id: 'layoutIntro', url: 'layout/introduction' - } - ,{ + }, + { name: 'Layout Containers', id: 'layoutContainers', url: 'layout/container' - } - ,{ + }, + { name: 'Layout Children', id: 'layoutGrid', url: 'layout/children' - } - ,{ + }, + { name: 'Child Alignment', id: 'layoutAlign', url: 'layout/alignment' - } - ,{ + }, + { name: 'Extra Options', id: 'layoutOptions', url: 'layout/options' - } - ,{ + }, + { name: 'Troubleshooting', id: 'layoutTips', url: 'layout/tips' @@ -398,7 +398,7 @@ function(SERVICES, COMPONENTS, DEMOS, PAGES, $location, $rootScope, $http, $wind function getVersionIdFromPath () { var path = $window.location.pathname; if (path.length < 2) path = 'HEAD'; - return path.match(/[^\/]+/)[0].toLowerCase(); + return path.match(/[^/]+/)[0].toLowerCase(); } }); diff --git a/docs/app/js/scripts.js b/docs/app/js/scripts.js index 28bcfd690b..f6e8d1e7ac 100644 --- a/docs/app/js/scripts.js +++ b/docs/app/js/scripts.js @@ -17,10 +17,10 @@ function allAngularScripts() { return scripts.map(fullPathToScript); - }; + } function fullPathToScript(script) { return "https://ajax.googleapis.com/ajax/libs/angularjs/" + BUILDCONFIG.ngVersion + "/" + script; - }; - }; + } + } })(); diff --git a/docs/config/index.js b/docs/config/index.js index fc8ec9b606..f6563324de 100644 --- a/docs/config/index.js +++ b/docs/config/index.js @@ -1,11 +1,8 @@ -var _ = require('lodash'); -var path = require('canonical-path'); -var buildConfig = require('../../config/build.config'); +const path = require('canonical-path'); +const Package = require('dgeni').Package; -var projectPath = path.resolve(__dirname, '../..'); -var packagePath = __dirname; - -var Package = require('dgeni').Package; +const projectPath = path.resolve(__dirname, '../..'); +const packagePath = __dirname; module.exports = new Package('angular-md', [ require('dgeni-packages/ngdoc'), @@ -42,7 +39,7 @@ module.exports = new Package('angular-md', [ computeIdsProcessor.idTemplates.push({ docTypes: ['content'], - idTemplate: 'content-${fileInfo.relativePath.replace("/","-")}', + idTemplate: { getId: ({ fileInfo }) => `content-${fileInfo.relativePath.replace("/","-")}` }, getAliases: function(doc) { return [doc.id]; } }); @@ -50,7 +47,7 @@ module.exports = new Package('angular-md', [ computePathsProcessor.pathTemplates.push({ docTypes: ['content'], getPath: function(doc) { - var docPath = path.dirname(doc.fileInfo.relativePath); + let docPath = path.dirname(doc.fileInfo.relativePath); if ( doc.fileInfo.baseName !== 'index' ) { docPath = path.join(docPath, doc.fileInfo.baseName); } diff --git a/docs/config/processors/buildConfig.js b/docs/config/processors/buildConfig.js index 90cd4b48b2..ddae61466c 100644 --- a/docs/config/processors/buildConfig.js +++ b/docs/config/processors/buildConfig.js @@ -1,8 +1,8 @@ -var buildConfig = require('../../../config/build.config'); -var q = require('q'); -var exec = require('child_process').exec; +const buildConfig = require('../../../config/build.config'); +const q = require('q'); +const exec = require('child_process').exec; -module.exports = function buildConfigProcessor(log) { +module.exports = function buildConfigProcessor() { return { $runBefore: ['rendering-docs'], $runAfter: ['indexPageProcessor'], @@ -25,13 +25,12 @@ module.exports = function buildConfigProcessor(log) { /** * Git the SHA associated with the most recent commit on origin/master - * @param deferred * @returns {*} */ function getSHA() { - var deferred = q.defer(); + const deferred = q.defer(); - exec('git rev-parse HEAD', function(error, stdout, stderr) { + exec('git rev-parse HEAD', function(error, stdout) { buildConfig.commit = stdout && stdout.toString().trim(); deferred.resolve(buildConfig.commit); }); @@ -41,13 +40,12 @@ module.exports = function buildConfigProcessor(log) { /** * Get the commit date for the most recent commit on origin/master - * @param deferred * @returns {*} */ function getCommitDate() { - var deferred = q.defer(); + const deferred = q.defer(); - exec('git show -s --format=%ci HEAD', function(error, stdout, stderr) { + exec('git show -s --format=%ci HEAD', function(error, stdout) { buildConfig.date = stdout && stdout.toString().trim(); deferred.resolve(buildConfig.date); }); diff --git a/docs/config/processors/componentsData.js b/docs/config/processors/componentsData.js index ce3abd373e..3238f809ba 100644 --- a/docs/config/processors/componentsData.js +++ b/docs/config/processors/componentsData.js @@ -1,16 +1,16 @@ -var _ = require('lodash'); -var buildConfig = require('../../../config/build.config.js'); +const _ = require('lodash'); +const buildConfig = require('../../../config/build.config.js'); // We don't need to publish all of a doc's data to the app, that will // add many kilobytes of loading overhead. function publicDocData(doc, extraData) { - var options = _.assign(extraData || {}, { hasDemo: (doc.docType === 'directive') }); + const options = _.assign(extraData || {}, { hasDemo: (doc.docType === 'directive') }); // This RegEx always retrieves the last source descriptor. // For example it retrieves from `/opt/material/src/core/services/ripple/ripple.js` the following // source descriptor: `src/core/`. // This is needed because components are not only located in `src/components`. - var descriptor = doc.fileInfo.filePath.toString().match(/src\/.*?\//g).pop(); + let descriptor = doc.fileInfo.filePath.toString().match(/src\/.*?\//g).pop(); if (descriptor) { descriptor = descriptor.substring(descriptor.indexOf('/') + 1, descriptor.lastIndexOf('/')); } @@ -19,20 +19,19 @@ function publicDocData(doc, extraData) { } function coreServiceData(doc, extraData) { - var options = _.assign(extraData || {}, { hasDemo: false }); + const options = _.assign(extraData || {}, { hasDemo: false }); return buildDocData(doc, options, 'core'); } function buildDocData(doc, extraData, descriptor) { - var module = 'material.' + descriptor; - var githubBaseUrl = buildConfig.repository + '/blob/master/src/' + descriptor + '/'; - var jsName = doc.module.split(module + '.').pop(); + const module = 'material.' + descriptor; + const githubBaseUrl = buildConfig.repository + '/blob/master/src/' + descriptor + '/'; - var basePathFromProjectRoot = 'src/' + descriptor + '/'; - var filePath = doc.fileInfo.filePath; - var indexOfBasePath = filePath.indexOf(basePathFromProjectRoot); - var path = filePath.substr(indexOfBasePath + basePathFromProjectRoot.length, filePath.length); + const basePathFromProjectRoot = 'src/' + descriptor + '/'; + const filePath = doc.fileInfo.filePath; + const indexOfBasePath = filePath.indexOf(basePathFromProjectRoot); + const path = filePath.substr(indexOfBasePath + basePathFromProjectRoot.length, filePath.length); return _.assign({ name: doc.name, @@ -46,7 +45,7 @@ function buildDocData(doc, extraData, descriptor) { }, extraData); } -module.exports = function componentsGenerateProcessor(log, moduleMap) { +module.exports = function componentsGenerateProcessor() { return { $runAfter: ['paths-computed'], $runBefore: ['rendering-docs'], @@ -55,7 +54,7 @@ module.exports = function componentsGenerateProcessor(log, moduleMap) { function process(docs) { - var components = _(docs) + const components = _(docs) .filter(function(doc) { // We are not interested in docs that are not in a module // We are only interested in pages that are not landing pages @@ -65,11 +64,11 @@ module.exports = function componentsGenerateProcessor(log, moduleMap) { .groupBy('module') .map(function(moduleDocs, moduleName) { - var moduleDoc = _.find(docs, { + const moduleDoc = _.find(docs, { docType: 'module', name: moduleName }); - if (!moduleDoc) return; + if (!moduleDoc) return undefined; return publicDocData(moduleDoc, { docs: moduleDocs @@ -84,12 +83,12 @@ module.exports = function componentsGenerateProcessor(log, moduleMap) { .filter() //remove null items .value(); - var EXPOSED_CORE_SERVICES = '$mdMedia'; + const EXPOSED_CORE_SERVICES = '$mdMedia'; - var services = _(docs).filter(function(doc) { - return doc.docType == 'service' && - doc.module == 'material.core' && - EXPOSED_CORE_SERVICES.indexOf(doc.name) != -1; + const services = _(docs).filter(function(doc) { + return doc.docType === 'service' && + doc.module === 'material.core' && + EXPOSED_CORE_SERVICES.indexOf(doc.name) !== -1; }).map(coreServiceData).value(); docs.push({ diff --git a/docs/config/processors/content.js b/docs/config/processors/content.js index 7a8e6c3041..6fffa9db46 100644 --- a/docs/config/processors/content.js +++ b/docs/config/processors/content.js @@ -1,11 +1,11 @@ -var _ = require('lodash'); +const _ = require('lodash'); -module.exports = function contentProcessor(templateFinder) { +module.exports = function contentProcessor() { return { $runAfter: ['paths-computed'], $runBefore: ['rendering-docs'], $process: function(docs) { - var contentDocs = _(docs) + const contentDocs = _(docs) .filter(function(doc) { return doc.docType === 'content'; }) diff --git a/docs/config/processors/indexPage.js b/docs/config/processors/indexPage.js index ba34f8f55b..f0737c6ee7 100644 --- a/docs/config/processors/indexPage.js +++ b/docs/config/processors/indexPage.js @@ -1,6 +1,6 @@ -var buildConfig = require('../../../config/build.config'); +const buildConfig = require('../../../config/build.config'); -module.exports = function indexPageProcessor(log) { +module.exports = function indexPageProcessor() { return { $runAfter: ['componentsGenerateProcessor'], $runBefore: ['rendering-docs'], diff --git a/docs/gulpfile.js b/docs/gulpfile.js index 872be9f19f..3c39e7efc2 100644 --- a/docs/gulpfile.js +++ b/docs/gulpfile.js @@ -1,28 +1,28 @@ -var gulp = require('gulp'); -var Dgeni = require('dgeni'); -var _ = require('lodash'); -var concat = require('gulp-concat'); -var fs = require('fs'); -var gulpif = require('gulp-if'); -var lazypipe = require('lazypipe'); -var mkdirp = require('mkdirp'); -var ngHtml2js = require('gulp-ng-html2js'); -var path = require('path'); -var sass = require('gulp-sass'); -var through2 = require('through2'); -var uglify = require('gulp-uglify'); -var utils = require('../scripts/gulp-utils.js'); -var karma = require('karma').server; -var argv = require('minimist')(process.argv.slice(2)); -var gutil = require('gulp-util'); -var series = require('stream-series'); - -var config = { +const gulp = require('gulp'); +const Dgeni = require('dgeni'); +const _ = require('lodash'); +const concat = require('gulp-concat'); +const fs = require('fs'); +const gulpif = require('gulp-if'); +const lazypipe = require('lazypipe'); +const mkdirp = require('mkdirp'); +const ngHtml2js = require('gulp-ng-html2js'); +const path = require('path'); +const sass = require('gulp-sass'); +const through2 = require('through2'); +const uglify = require('gulp-uglify'); +const utils = require('../scripts/gulp-utils.js'); +const karma = require('karma').server; +const argv = require('minimist')(process.argv.slice(2)); +const gutil = require('gulp-util'); +const series = require('stream-series'); + +const config = { demoFolder: 'demo-partials' }; gulp.task('demos', function() { - var demos = []; + const demos = []; return generateDemos() .pipe(through2.obj(function(demo, enc, next) { // Don't include file contents into the docs app, @@ -34,10 +34,10 @@ gulp.task('demos', function() { demos.push(demo); next(); }, function(done) { - var demoIndex = _(demos) + const demoIndex = _(demos) .groupBy('moduleName') .map(function(moduleDemos, moduleName) { - var componentName = moduleName.split('.').pop(); + const componentName = moduleName.split('.').pop(); return { name: componentName, moduleName: moduleName, @@ -48,8 +48,8 @@ gulp.task('demos', function() { }) .value(); - var dest = path.resolve(__dirname, '../dist/docs/js'); - var file = "angular.module('docsApp').constant('DEMOS', " + + const dest = path.resolve(__dirname, '../dist/docs/js'); + const file = "angular.module('docsApp').constant('DEMOS', " + JSON.stringify(demoIndex, null, 2) + ");"; mkdirp.sync(dest); fs.writeFileSync(dest + '/demo-data.js', file); @@ -61,10 +61,10 @@ gulp.task('demos', function() { function generateDemos() { return gulp.src('src/{components,services}/*/') .pipe(through2.obj(function(folder, enc, next) { - var self = this; - var split = folder.path.split(path.sep); - var name = split.pop(); - var moduleName = 'material.' + split.pop() + '.' + name; + const self = this; + const split = folder.path.split(path.sep); + const name = split.pop(); + const moduleName = 'material.' + split.pop() + '.' + name; utils.copyDemoAssets(name, 'src/components/', 'dist/docs/demo-partials/'); @@ -82,7 +82,7 @@ function generateDemos() { function transformCss(demoId) { return lazypipe() .pipe(through2.obj, function(file, enc, next) { - file.contents = new Buffer( + file.contents = Buffer.from( '.' + demoId + ' {\n' + file.contents.toString() + '\n}' ); next(null, file); @@ -94,7 +94,7 @@ function generateDemos() { } gulp.task('docs-generate', ['build'], function() { - var dgeni = new Dgeni([ + const dgeni = new Dgeni([ require('./config') ]); return dgeni.generate(); @@ -117,8 +117,8 @@ gulp.task('docs-js-dependencies', ['build'], function() { }); gulp.task('docs-js', ['docs-app', 'docs-html2js', 'demos', 'build', 'docs-js-dependencies'], function() { - var preLoadJs = ['docs/app/js/preload.js']; - if (process.argv.indexOf('--jquery') != -1) { + const preLoadJs = ['docs/app/js/preload.js']; + if (process.argv.indexOf('--jquery') !== -1) { preLoadJs.push('node_modules/jquery/dist/jquery.js'); } @@ -168,16 +168,17 @@ gulp.task('docs-html2js', function() { }); gulp.task('docs-karma', ['docs-js'], function(done) { - var karmaConfig = { + const karmaConfig = { singleRun: true, autoWatch: false, browsers: argv.browsers ? argv.browsers.trim().split(',') : ['Chrome'], - configFile: __dirname + '/../config/karma-docs.conf.js' + configFile: path.join(__dirname, '/../config/karma-docs.conf.js') }; karma.start(karmaConfig, function(exitCode) { - if (exitCode != 0) { + if (exitCode !== 0) { gutil.log(gutil.colors.red("Karma exited with the following exit code: " + exitCode)); + // eslint-disable-next-line no-process-exit process.exit(exitCode); } done(); diff --git a/docs/spec/codepen.spec.js b/docs/spec/codepen.spec.js index 4f8a8f7b2d..882ebcf3c9 100644 --- a/docs/spec/codepen.spec.js +++ b/docs/spec/codepen.spec.js @@ -1,6 +1,6 @@ describe('CodepenDataAdapter', function() { - var codepenDataAdapter, demo, data, externalScripts; + let codepenDataAdapter, demo, data, externalScripts; beforeEach(module('docsApp')); beforeEach(inject(function(_codepenDataAdapter_) { @@ -52,7 +52,7 @@ describe('CodepenDataAdapter', function() { it('includes the external js files, including the asset cache required to serve svgs to codepen', function() { - var expected = [ + const expected = [ 'http://some-url-to-external-js-files-required-for-codepen', 'http://localhost:8080/angular-material.js', 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js' @@ -79,7 +79,7 @@ describe('CodepenDataAdapter', function() { describe('when html templates are included in the demo', function() { - var template, $script; + let template, script; beforeEach(function() { template = { name: 'template-name', @@ -134,7 +134,7 @@ describe('CodepenDataAdapter', function() { describe('when the module definition in the js file is formatted in different ways', function() { it('handles second argument on a new line', function() { - var script = "angular.module('test',\n \ + const script = "angular.module('test',\n \ []);"; demo.files.js = [{ contents: script }]; @@ -143,7 +143,7 @@ describe('CodepenDataAdapter', function() { }); it('handles dependencies on new lines', function() { - var script = "angular.module('test', [\n \ + const script = "angular.module('test', [\n \ 'Dep1',\n \ 'Dep2',\n \ ]);"; @@ -154,7 +154,7 @@ describe('CodepenDataAdapter', function() { }); it('handles module on a new line', function() { - var script = "angular\n\ + const script = "angular\n\ .module('test', [\n \ 'Dep1',\n \ 'Dep2',\n \ diff --git a/docs/spec/demo.spec.js b/docs/spec/demo.spec.js index e72d087d7e..63f8f8dfb4 100644 --- a/docs/spec/demo.spec.js +++ b/docs/spec/demo.spec.js @@ -74,5 +74,5 @@ describe('docsDemo', function() { $httpBackend.expectGET('img/icons/ic_visibility_24px.svg'); $httpBackend.whenGET('img/icons/codepen-logo.svg').respond(''); $httpBackend.expectGET('img/icons/codepen-logo.svg'); - }; + } }); diff --git a/gulp/config.js b/gulp/config.js index 40c26d2bdd..fc04d9bfdd 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -1,5 +1,6 @@ -var args = require('minimist')(process.argv.slice(2)); -var VERSION = args.version || require('../package.json').version; +const argsVersion = require('minimist')(process.argv.slice(2)).version; +const currentVersion = require('../package.json').version; +const VERSION = argsVersion || currentVersion; module.exports = { banner: @@ -30,8 +31,6 @@ module.exports = { 'src/core/style/structure.scss', 'src/core/style/typography.scss', 'src/core/style/layout.scss', - - // TODO(crisbeto): can be removed once mdPanel is in the core. 'src/components/panel/*.scss' ], scssLayoutFiles: [ diff --git a/gulp/const.js b/gulp/const.js index 9fdf322ee1..2006392552 100644 --- a/gulp/const.js +++ b/gulp/const.js @@ -1,17 +1,18 @@ -var config = require('./config'); -var path = require('path'); -var args = require('minimist')(process.argv.slice(2)); -var utils = require('../scripts/gulp-utils.js'); +const config = require('./config'); +const path = require('path'); +const args = require('minimist')(process.argv.slice(2)); +const utils = require('../scripts/gulp-utils.js'); +const version = require('../package.json').version; -exports.ROOT = path.normalize(__dirname + '/..'); -exports.VERSION = args.version || require('../package.json').version; +exports.ROOT = path.normalize(path.join(__dirname, '/..')); +exports.VERSION = args.version || version; exports.LR_PORT = args.port || args.p || 8080; exports.IS_DEV = args.dev; exports.SHA = args.sha; exports.BUILD_MODE = getBuildMode(); function getBuildMode () { - var mode = (args.module || args.m || args.c) ? 'demos' : args.mode; + const mode = (args.module || args.m || args.c) ? 'demos' : args.mode; switch (mode) { case 'closure': return { name: 'closure', diff --git a/gulp/tasks/build-all-modules.js b/gulp/tasks/build-all-modules.js index 5f13b82dc5..7c51deb19f 100644 --- a/gulp/tasks/build-all-modules.js +++ b/gulp/tasks/build-all-modules.js @@ -1,27 +1,24 @@ -var BUILD_MODE = require('../const').BUILD_MODE; +const BUILD_MODE = require('../const').BUILD_MODE; -var gulp = require('gulp'); -var path = require('path'); -var through2 = require('through2'); -var series = require('stream-series'); -var util = require('../util'); -var gulpif = require('gulp-if'); -var utils = require('../../scripts/gulp-utils.js'); +const gulp = require('gulp'); +const path = require('path'); +const through2 = require('through2'); +const series = require('stream-series'); +const util = require('../util'); exports.task = function() { - var isRelease = process.argv.indexOf('--release') != -1; + const isRelease = process.argv.indexOf('--release') !== -1; return gulp.src(['src/core/', 'src/components/*' ]) .pipe(through2.obj(function(folder, enc, next) { - var moduleId = folder.path.indexOf('components') > -1 + const moduleId = folder.path.indexOf('components') > -1 ? 'material.components.' + path.basename(folder.path) : 'material.' + path.basename(folder.path); - var stream = isRelease ? + const stream = isRelease ? series( util.buildModule(moduleId, { minify: true, useBower: BUILD_MODE.useBower }), - util.buildModule(moduleId) - ) : util.buildModule(moduleId); + util.buildModule(moduleId, {}) + ) : util.buildModule(moduleId, {}); stream.on('end', function() { next(); }); })) .pipe(BUILD_MODE.transform()); - }; diff --git a/gulp/tasks/build-contributors.js b/gulp/tasks/build-contributors.js index 407bf075eb..88b96172ae 100644 --- a/gulp/tasks/build-contributors.js +++ b/gulp/tasks/build-contributors.js @@ -1,16 +1,15 @@ +const child_process = require('child_process'); +const os = require('os'); + (function () { 'use strict'; - var colors = require('colors'); - var child_process = require('child_process'); - var os = require('os'); - /** * Note 'githubcontrib' may require an application-scoped access token defined as * GITHUB_API_TOKEN in your ENV. */ exports.task = function () { - var appPath = 'dist/docs'; + const appPath = 'dist/docs'; child_process.execSync('rm -f ' + appPath + '/contributors.json'); @@ -35,22 +34,11 @@ return cmd.map(function (cmd) { return exec(cmd, userOptions); }); } try { - var options = { } ; - for (var key in userOptions) options[ key ] = userOptions[ key ]; + const options = { } ; + for (const key in userOptions) options[ key ] = userOptions[ key ]; return child_process.execSync(cmd + ' 2> /dev/null', options).toString().trim(); } catch (err) { return err; } } - - /** outputs done text when a task is completed */ - function done () { - log('done'.green); - } - - /** outputs to the terminal with string variable replacement */ - function log (msg) { - console.log(msg || ''); - } - })(); diff --git a/gulp/tasks/build-demo.js b/gulp/tasks/build-demo.js index dcb8d84e34..67850a7a5a 100644 --- a/gulp/tasks/build-demo.js +++ b/gulp/tasks/build-demo.js @@ -1,4 +1,4 @@ -var util = require('../util'); +const util = require('../util'); exports.dependencies = ['build', 'build-module-demo']; diff --git a/gulp/tasks/build-js.js b/gulp/tasks/build-js.js index 8a1485e10e..dafc1cb144 100644 --- a/gulp/tasks/build-js.js +++ b/gulp/tasks/build-js.js @@ -1,4 +1,4 @@ -var util = require('../util'); +const util = require('../util'); exports.task = function() { return util.buildJs(true); diff --git a/gulp/tasks/build-module-demo.js b/gulp/tasks/build-module-demo.js index 5620e5984f..997feb189a 100644 --- a/gulp/tasks/build-module-demo.js +++ b/gulp/tasks/build-module-demo.js @@ -1,23 +1,23 @@ -var BUILD_MODE = require('../const').BUILD_MODE; -var ROOT = require('../const').ROOT; +const BUILD_MODE = require('../const').BUILD_MODE; +const ROOT = require('../const').ROOT; -var gulp = require('gulp'); -var gutil = require('gulp-util'); -var fs = require('fs'); -var path = require('path'); -var through2 = require('through2'); -var lazypipe = require('lazypipe'); -var sass = require('gulp-sass'); -var gulpif = require('gulp-if'); -var _ = require('lodash'); +const gulp = require('gulp'); +const gutil = require('gulp-util'); +const fs = require('fs'); +const path = require('path'); +const through2 = require('through2'); +const lazypipe = require('lazypipe'); +const sass = require('gulp-sass'); +const gulpif = require('gulp-if'); +const _ = require('lodash'); -var util = require('../util'); -var utils = require('../../scripts/gulp-utils.js'); +const util = require('../util'); +const utils = require('../../scripts/gulp-utils.js'); exports.task = function() { - var mod = util.readModuleArg(); - var name = mod.split('.').pop(); - var demoIndexTemplate = fs.readFileSync( + const mod = util.readModuleArg(); + const name = mod.split('.').pop(); + const demoIndexTemplate = fs.readFileSync( ROOT + '/docs/config/template/demo-index.template.html', 'utf8' ).toString(); diff --git a/gulp/tasks/build-scss.js b/gulp/tasks/build-scss.js index d592990eff..55909533ca 100644 --- a/gulp/tasks/build-scss.js +++ b/gulp/tasks/build-scss.js @@ -1,37 +1,31 @@ -var config = require('../config'); -var gulp = require('gulp'); -var gutil = require('gulp-util'); -var fs = require('fs'); -var path = require('path'); -var rename = require('gulp-rename'); -var filter = require('gulp-filter'); -var concat = require('gulp-concat'); -var series = require('stream-series'); -var util = require('../util'); -var sassUtils = require('../../scripts/gulp-utils'); -var sass = require('gulp-sass'); -var insert = require('gulp-insert'); -var addsrc = require('gulp-add-src'); -var gulpif = require('gulp-if'); -var minifyCss = util.minifyCss; -var args = util.args; -var IS_DEV = require('../const').IS_DEV; +const config = require('../config'); +const gulp = require('gulp'); +const gutil = require('gulp-util'); +const rename = require('gulp-rename'); +const filter = require('gulp-filter'); +const concat = require('gulp-concat'); +const series = require('stream-series'); +const util = require('../util'); +const sassUtils = require('../../scripts/gulp-utils'); +const sass = require('gulp-sass'); +const insert = require('gulp-insert'); +const gulpif = require('gulp-if'); +const minifyCss = util.minifyCss; +const args = util.args; +const IS_DEV = require('../const').IS_DEV; exports.task = function() { - var streams = []; - var modules = args['modules'], - overrides = args['override'], + const streams = []; + const modules = args.modules, + overrides = args.override, dest = args['output-dir'] || config.outputDir, - filename = args['filename'] || 'angular-material', - baseFiles = config.scssBaseFiles, - layoutDest= dest + 'layouts/', - scssPipe = null; + layoutDest= dest + 'layouts/'; gutil.log("Building css files..."); // create SCSS file for distribution streams.push( - scssPipe = gulp.src(getPaths()) + gulp.src(getPaths()) .pipe(util.filterNonCodeFiles()) .pipe(filter(['**', '!**/*.css'])) .pipe(filter(['**', '!**/*-theme.scss'])) @@ -106,7 +100,7 @@ exports.task = function() { function getPaths () { - var paths = config.scssBaseFiles.slice(); + const paths = config.scssBaseFiles.slice(); if ( modules ) { paths.push.apply(paths, modules.split(',').map(function (module) { return 'src/components/' + module + '/*.scss'; diff --git a/gulp/tasks/changelog.js b/gulp/tasks/changelog.js index 3b2a9f6f0d..c13aa42869 100644 --- a/gulp/tasks/changelog.js +++ b/gulp/tasks/changelog.js @@ -1,20 +1,20 @@ -var fs = require('fs'); -var changelog = require('conventional-changelog'); -var ROOT = require('../const').ROOT; -var SHA = require('../const').SHA; -var VERSION = require('../const').VERSION; -var addStream = require('add-stream'); -var path = require('path'); -var spawnSync = require('child_process').spawnSync; -var chalk = require('gulp-util').colors; -var log = require('gulp-util').log; +const fs = require('fs'); +const changelog = require('conventional-changelog'); +const ROOT = require('../const').ROOT; +const SHA = require('../const').SHA; +const VERSION = require('../const').VERSION; +const addStream = require('add-stream'); +const path = require('path'); +const spawnSync = require('child_process').spawnSync; +const chalk = require('gulp-util').colors; +const log = require('gulp-util').log; exports.task = function () { - var changelogPath = path.join(ROOT, 'CHANGELOG.md'); - var inputStream = fs.createReadStream(changelogPath); - var previousTag = getLatestTag(); - var currentTag = 'v' + VERSION; + const changelogPath = path.join(ROOT, 'CHANGELOG.md'); + const inputStream = fs.createReadStream(changelogPath); + const previousTag = getLatestTag(); + const currentTag = 'v' + VERSION; /* Validate different fork points for the changelog generation */ if (previousTag.name === currentTag && !SHA) { @@ -22,18 +22,18 @@ exports.task = function () { } else if (SHA) { log('Generating changelog from commit ' + getShortSha(SHA) + '...'); } else { - var shortSha = getShortSha(previousTag.sha); + const shortSha = getShortSha(previousTag.sha); log('Generating changelog from tag ' + previousTag.name + ' (' + shortSha + ')'); } - var contextOptions = { + const contextOptions = { version: VERSION, previousTag: previousTag.name, currentTag: currentTag }; /* Create our changelog and append the current changelog stream. */ - var changelogStream = changelog({ preset: 'angular' }, contextOptions, { + const changelogStream = changelog({ preset: 'angular' }, contextOptions, { from: SHA || previousTag.sha }).pipe(addStream(inputStream)); @@ -50,13 +50,13 @@ exports.task = function () { * @returns {{sha: string, name: string}} */ function getLatestTag() { - var tagSha = spawnSync('git', ['rev-list', '--tags', '--max-count=1']).stdout.toString().trim(); - var tagName = spawnSync('git', ['describe', '--tags', tagSha]).stdout.toString().trim(); + const tagSha = spawnSync('git', ['rev-list', '--tags', '--max-count=1']).stdout.toString().trim(); + const tagName = spawnSync('git', ['describe', '--tags', tagSha]).stdout.toString().trim(); return { sha: tagSha, name: tagName - } + }; } /** @@ -65,4 +65,4 @@ function getLatestTag() { */ function getShortSha(sha) { return sha.substring(0, 7); -} \ No newline at end of file +} diff --git a/gulp/tasks/ddescribe-iit.js b/gulp/tasks/ddescribe-iit.js index a3d4b9b26c..f8aaf248e0 100644 --- a/gulp/tasks/ddescribe-iit.js +++ b/gulp/tasks/ddescribe-iit.js @@ -1,15 +1,9 @@ -var BUILD_MODE = require('../const').BUILD_MODE; +const gulp = require('gulp'); +const PluginError = require('gulp-util').PluginError; +const path = require('path'); +const through2 = require('through2'); -var gulp = require('gulp'); -var PluginError = require('gulp-util').PluginError; -var path = require('path'); -var through2 = require('through2'); -var series = require('stream-series'); -var util = require('../util'); -var gulpif = require('gulp-if'); -var utils = require('../../scripts/gulp-utils.js'); - -var kDisallowedFunctions = [ +const kDisallowedFunctions = [ // Allow xit/xdescribe --- disabling tests is okay 'fit', 'iit', @@ -22,18 +16,18 @@ var kDisallowedFunctions = [ ]; function disallowedIndex(largeString, disallowedString) { - var notFunctionName = '[^A-Za-z0-9$_]'; - var regex = new RegExp('(^|' + notFunctionName + ')(' + disallowedString + ')' + notFunctionName + '*\\(', 'gm'); - var match = regex.exec(largeString); + const notFunctionName = '[^A-Za-z0-9$_]'; + const regex = new RegExp('(^|' + notFunctionName + ')(' + disallowedString + ')' + notFunctionName + '*\\(', 'gm'); + const match = regex.exec(largeString); // Return the match accounting for the first submatch length. return match != null ? match.index + match[1].length : -1; } function checkFile(fileContents, disallowed) { - var res = void 0; + let res = void 0; if (Array.isArray(disallowed)) { disallowed.forEach(function(str) { - var index = disallowedIndex(fileContents, str); + const index = disallowedIndex(fileContents, str); if (index !== -1) { res = res || []; res.push({ @@ -48,10 +42,10 @@ function checkFile(fileContents, disallowed) { } exports.task = function() { - var failures = void 0; + let failures = void 0; return gulp.src(['src/**/*.spec.js', 'test/**/*-spec.js' ]) .pipe(through2.obj(function(file, enc, next) { - var errors = checkFile(file.contents.toString(), kDisallowedFunctions); + const errors = checkFile(file.contents.toString(), kDisallowedFunctions); if (errors) { failures = failures || []; failures.push({ @@ -63,25 +57,23 @@ exports.task = function() { next(); }, function(callback) { if (failures) { - var indented = true; this.emit('error', new PluginError('ddescribe-iit', { message: '\n' + failures.map(function(failure) { - var filename = path.relative(process.cwd(), failure.file.path); - var lines = failure.contents.split('\n'); - var start = 0; - var starts = lines.map(function(line) { var s = start; start += line.length + 1; return s; }); + const filename = path.relative(process.cwd(), failure.file.path); + const lines = failure.contents.split('\n'); + let start = 0; + const starts = lines.map(function(line) { const s = start; start += line.length + 1; return s; }); return failure.errors.map(function(error) { - var line = lines[error.line - 1]; - var start = starts[error.line - 1]; - var col = (error.index - start); - var msg = ' `' + error.str + '` found at ' +filename + ':' + error.line + ':' + (col+1) + '\n' + - ' ' + line + '\n' + - ' ' + repeat(' ', col) + repeat('^', error.str.length); - return msg; + const line = lines[error.line - 1]; + const start = starts[error.line - 1]; + const col = (error.index - start); + return ' `' + error.str + '` found at ' +filename + ':' + error.line + ':' + (col+1) + '\n' + + ' ' + line + '\n' + + ' ' + repeat(' ', col) + repeat('^', error.str.length); function repeat(c, len) { - var s = ''; + let s = ''; if (len > 0) { - for (var i = 0; i < len; ++i) { + for (let i = 0; i < len; ++i) { s += c; } } diff --git a/gulp/tasks/docs.js b/gulp/tasks/docs.js index 7a6b23dc2d..d27613158d 100644 --- a/gulp/tasks/docs.js +++ b/gulp/tasks/docs.js @@ -1,5 +1,5 @@ -var gulp = require('gulp'); -var connect = require('gulp-connect'); +const gulp = require('gulp'); +const connect = require('gulp-connect'); exports.dependencies = ['docs-js', 'docs-css', 'docs-demo-scripts', 'build-contributors']; diff --git a/gulp/tasks/jshint.js b/gulp/tasks/jshint.js index a4d63be780..cafa3ca923 100644 --- a/gulp/tasks/jshint.js +++ b/gulp/tasks/jshint.js @@ -1,6 +1,6 @@ -var config = require('../config'); -var gulp = require('gulp'); -var jshint = require('gulp-jshint'); +const config = require('../config'); +const gulp = require('gulp'); +const jshint = require('gulp-jshint'); exports.task = function() { return gulp.src(config.jsFiles) diff --git a/gulp/tasks/karma-fast.js b/gulp/tasks/karma-fast.js index 548cece442..a3e75db5fa 100644 --- a/gulp/tasks/karma-fast.js +++ b/gulp/tasks/karma-fast.js @@ -1,22 +1,21 @@ -var gutil = require('gulp-util'); -var karma = require('karma').server; -var util = require('../util'); -var ROOT = require('../const').ROOT; -var Server = require('karma').Server; -var karmaConfig = { +const gutil = require('gulp-util'); +const util = require('../util'); +const ROOT = require('../const').ROOT; +const Server = require('karma').Server; +const karmaConfig = { logLevel: 'warn', singleRun: true, autoWatch: false, configFile: ROOT + '/config/karma.conf.js' }; -var args = util.args; +const args = util.args; // NOTE: `karma-fast` does NOT pre-make a full build of JS and CSS // exports.dependencies = ['build']; exports.task = function (done) { - var errorCount = 0; + let errorCount = 0; if ( args.browsers ) { karmaConfig.browsers = args.browsers.trim().split(','); @@ -30,7 +29,7 @@ exports.task = function (done) { gutil.log('Running unit tests on unminified source.'); - karma = new Server(karmaConfig, captureError(clearEnv,clearEnv)); + const karma = new Server(karmaConfig, captureError(clearEnv,clearEnv)); karma.start(); @@ -38,6 +37,7 @@ exports.task = function (done) { process.env.KARMA_TEST_COMPRESSED = undefined; process.env.KARMA_TEST_JQUERY = undefined; + // eslint-disable-next-line no-process-exit if (errorCount > 0) { process.exit(errorCount); } done(); } @@ -53,7 +53,7 @@ exports.task = function (done) { */ function captureError(next,done) { return function(exitCode) { - if (exitCode != 0) { + if (exitCode !== 0) { gutil.log(gutil.colors.red("Karma exited with the following exit code: " + exitCode)); errorCount++; } diff --git a/gulp/tasks/karma-sauce.js b/gulp/tasks/karma-sauce.js index a68f609acb..44284880eb 100644 --- a/gulp/tasks/karma-sauce.js +++ b/gulp/tasks/karma-sauce.js @@ -1,8 +1,8 @@ -var Server = require('karma').Server; -var ROOT = require('../const').ROOT; +const Server = require('karma').Server; +const ROOT = require('../const').ROOT; exports.task = function(done) { - var srv = new Server({ + const srv = new Server({ logLevel: 'warn', configFile: ROOT + '/config/karma-sauce.conf.js' }, done); diff --git a/gulp/tasks/karma-watch.js b/gulp/tasks/karma-watch.js index b679831b4d..1031382794 100644 --- a/gulp/tasks/karma-watch.js +++ b/gulp/tasks/karma-watch.js @@ -1,8 +1,7 @@ -var karma = require('karma').server; -var ROOT = require('../const').ROOT; -var args = require('../util').args; -var Server = require('karma').Server; -var config = { +const ROOT = require('../const').ROOT; +const args = require('../util').args; +const Server = require('karma').Server; +const config = { singleRun: false, autoWatch: true, configFile: ROOT + '/config/karma.conf.js', @@ -13,6 +12,6 @@ var config = { exports.dependencies = ['build']; exports.task = function(done) { - var server = new Server(config, done); - server. start(); + const server = new Server(config, done); + server.start(); }; diff --git a/gulp/tasks/karma.js b/gulp/tasks/karma.js index 8e9d8c2116..f495586f03 100644 --- a/gulp/tasks/karma.js +++ b/gulp/tasks/karma.js @@ -1,10 +1,10 @@ -var gutil = require('gulp-util'); -var util = require('../util'); -var ROOT = require('../const').ROOT; -var args = util.args; -var Server = require('karma').Server; +const gutil = require('gulp-util'); +const util = require('../util'); +const ROOT = require('../const').ROOT; +const args = util.args; +const Server = require('karma').Server; -var karmaConfig = { +const karmaConfig = { logLevel: 'warn', configFile: ROOT + '/config/karma.conf.js' }; @@ -19,9 +19,10 @@ exports.task = function (done) { gutil.log(gutil.colors.blue('Running unit tests on unminified source.')); - var karma = new Server(karmaConfig, function(exitCode){ + const karma = new Server(karmaConfig, function(exitCode){ // Immediately exit the process if Karma reported errors, because due to // potential still running tunnel-browsers gulp won't exit properly. + // eslint-disable-next-line no-process-exit exitCode === 0 ? done() : process.exit(exitCode); }); karma.start(); diff --git a/gulp/tasks/server.js b/gulp/tasks/server.js index 39cfc648bf..6a5c290b83 100644 --- a/gulp/tasks/server.js +++ b/gulp/tasks/server.js @@ -1,10 +1,10 @@ -var gulp = require('gulp'); -var webserver = require('gulp-webserver'); -var LR_PORT = require('../const').LR_PORT; -var util = require('../util'); +const gulp = require('gulp'); +const webserver = require('gulp-webserver'); +const LR_PORT = require('../const').LR_PORT; +const util = require('../util'); exports.task = function() { - var openUrl = false; + let openUrl = false; if (typeof util.args.o === 'string' || typeof util.args.o === 'boolean') { diff --git a/gulp/tasks/site.js b/gulp/tasks/site.js index 6e9690de16..7ba92c71ba 100644 --- a/gulp/tasks/site.js +++ b/gulp/tasks/site.js @@ -1,5 +1,5 @@ -var connect = require('gulp-connect'); -var LR_PORT = require('../const').LR_PORT; +const connect = require('gulp-connect'); +const LR_PORT = require('../const').LR_PORT; exports.task = function () { connect.server({ diff --git a/gulp/tasks/watch-demo.js b/gulp/tasks/watch-demo.js index 4abed83d2d..a7bfa996ba 100644 --- a/gulp/tasks/watch-demo.js +++ b/gulp/tasks/watch-demo.js @@ -1,13 +1,13 @@ -var gulp = require('gulp'); -var gutil = require('gulp-util'); -var util = require('../util'); +const gulp = require('gulp'); +const gutil = require('gulp-util'); +const util = require('../util'); exports.dependencies = ['build-demo']; exports.task = function() { - var module = util.readModuleArg(); - var name = module.split('.').pop(); - var dir = "/dist/demos/"+name.trim(); + const module = util.readModuleArg(); + const name = module.split('.').pop(); + const dir = "/dist/demos/"+name.trim(); gutil.log('\n', '-- Rebuilding', dir, 'when source files change...\n', '--', gutil.colors.green('Hint:'), 'Run', diff --git a/gulp/tasks/watch.js b/gulp/tasks/watch.js index 8b19d9cadb..415ff063dd 100644 --- a/gulp/tasks/watch.js +++ b/gulp/tasks/watch.js @@ -1,4 +1,4 @@ -var gulp = require('gulp'); +const gulp = require('gulp'); exports.dependencies = ['docs']; diff --git a/gulp/util.js b/gulp/util.js index 880118cb4c..2620f20573 100644 --- a/gulp/util.js +++ b/gulp/util.js @@ -1,31 +1,31 @@ -var config = require('./config'); -var gulp = require('gulp'); -var gutil = require('gulp-util'); -var frep = require('gulp-frep'); -var fs = require('fs'); -var args = require('minimist')(process.argv.slice(2)); -var path = require('path'); -var rename = require('gulp-rename'); -var filter = require('gulp-filter'); -var concat = require('gulp-concat'); -var series = require('stream-series'); -var lazypipe = require('lazypipe'); -var glob = require('glob').sync; -var uglify = require('gulp-uglify'); -var sass = require('gulp-sass'); -var plumber = require('gulp-plumber'); -var ngAnnotate = require('gulp-ng-annotate'); -var insert = require('gulp-insert'); -var gulpif = require('gulp-if'); -var nano = require('gulp-cssnano'); -var postcss = require('postcss'); -var _ = require('lodash'); -var constants = require('./const'); -var VERSION = constants.VERSION; -var BUILD_MODE = constants.BUILD_MODE; -var IS_DEV = constants.IS_DEV; -var ROOT = constants.ROOT; -var utils = require('../scripts/gulp-utils.js'); +const config = require('./config'); +const gulp = require('gulp'); +const gutil = require('gulp-util'); +const frep = require('gulp-frep'); +const fs = require('fs'); +const args = require('minimist')(process.argv.slice(2)); +const path = require('path'); +const rename = require('gulp-rename'); +const filter = require('gulp-filter'); +const concat = require('gulp-concat'); +const series = require('stream-series'); +const lazypipe = require('lazypipe'); +const glob = require('glob').sync; +const uglify = require('gulp-uglify'); +const sass = require('gulp-sass'); +const plumber = require('gulp-plumber'); +const ngAnnotate = require('gulp-ng-annotate'); +const insert = require('gulp-insert'); +const gulpif = require('gulp-if'); +const nano = require('gulp-cssnano'); +const postcss = require('postcss'); +const _ = require('lodash'); +const constants = require('./const'); +const VERSION = constants.VERSION; +const BUILD_MODE = constants.BUILD_MODE; +const IS_DEV = constants.IS_DEV; +const ROOT = constants.ROOT; +const utils = require('../scripts/gulp-utils.js'); exports.buildJs = buildJs; exports.autoprefix = utils.autoprefix; @@ -39,21 +39,20 @@ exports.args = args; /** * Builds the entire component library javascript. - * @param {boolean} isRelease Whether to build in release mode. */ function buildJs () { - var jsFiles = config.jsBaseFiles.concat([path.join(config.paths, '*.js')]); + const jsFiles = config.jsBaseFiles.concat([path.join(config.paths, '*.js')]); gutil.log("building js files..."); - var jsBuildStream = gulp.src( jsFiles ) + const jsBuildStream = gulp.src( jsFiles ) .pipe(filterNonCodeFiles()) .pipe(utils.buildNgMaterialDefinition()) .pipe(plumber()) .pipe(ngAnnotate()) .pipe(utils.addJsWrapper(true)); - var jsProcess = series(jsBuildStream, themeBuildStream() ) + const jsProcess = series(jsBuildStream, themeBuildStream() ) .pipe(concat('angular-material.js')) .pipe(BUILD_MODE.transform()) .pipe(insert.prepend(config.banner)) @@ -73,7 +72,7 @@ function buildJs () { } function minifyCss(extraOptions) { - var options = { + const options = { autoprefixer: false, reduceTransforms: false, svgo: false, @@ -83,6 +82,10 @@ function minifyCss(extraOptions) { return nano(_.assign(options, extraOptions)); } +/** + * @param module {string} + * @param opts {{isRelease, minify, useBower}} + */ function buildModule(module, opts) { opts = opts || {}; if ( module.indexOf(".") < 0) { @@ -90,10 +93,10 @@ function buildModule(module, opts) { } gutil.log('Building ' + module + (opts.isRelease && ' minified' || '') + ' ...'); - var name = module.split('.').pop(); + const name = module.split('.').pop(); utils.copyDemoAssets(name, 'src/components/', 'dist/demos/'); - var stream = utils.filesForModule(module) + let stream = utils.filesForModule(module) .pipe(filterNonCodeFiles()) .pipe(filterLayoutAttrFiles()) .pipe(gulpif('*.scss', buildModuleStyles(name))) @@ -111,12 +114,12 @@ function buildModule(module, opts) { .pipe(gulp.dest(BUILD_MODE.outputDir + name)); function splitStream (stream) { - var js = series(stream, themeBuildStream()) + const js = series(stream, themeBuildStream()) .pipe(filter('**/*.js')) .pipe(concat('core.js')); - var css = stream - .pipe(filter(['**/*.css', '!**/ie_fixes.css'])) + const css = stream + .pipe(filter(['**/*.css', '!**/ie_fixes.css'])); return series(js, css); } @@ -145,9 +148,9 @@ function buildModule(module, opts) { } function buildModuleJs(name) { - var patterns = [ + const patterns = [ { - pattern: /\@ngInject/g, + pattern: /@ngInject/g, replacement: 'ngInject' }, { @@ -168,12 +171,12 @@ function buildModule(module, opts) { function buildModuleStyles(name) { - var files = []; + let files = []; config.themeBaseFiles.forEach(function(fileGlob) { files = files.concat(glob(fileGlob, { cwd: ROOT })); }); - var baseStyles = files.map(function(fileName) { + const baseStyles = files.map(function(fileName) { return fs.readFileSync(fileName, 'utf8').toString(); }).join('\n'); @@ -192,13 +195,13 @@ function buildModule(module, opts) { } function readModuleArg() { - var module = args.c ? 'material.components.' + args.c : (args.module || args.m); + const module = args.c ? 'material.components.' + args.c : (args.module || args.m); if (!module) { gutil.log('\nProvide a component argument via `-c`:', '\nExample: -c toast'); gutil.log('\nOr provide a module argument via `--module` or `-m`.', '\nExample: --module=material.components.toast or -m material.components.dialog'); - process.exit(1); + throw new Error("Unable to read module arguments."); } return module; } @@ -233,11 +236,11 @@ function themeBuildStream() { // Removes duplicated CSS properties. function dedupeCss() { - var prefixRegex = /-(webkit|moz|ms|o)-.+/; + const prefixRegex = /-(webkit|moz|ms|o)-.+/; return insert.transform(function(contents) { // Parse the CSS into an AST. - var parsed = postcss.parse(contents); + const parsed = postcss.parse(contents); // Walk through all the rules, skipping comments, media queries etc. parsed.walk(function(rule) { @@ -247,7 +250,7 @@ function dedupeCss() { // Walk all of the properties within a rule. rule.walk(function(prop) { // Check if there's a similar property that comes after the current one. - var hasDuplicate = validateProp(prop) && _.find(rule.nodes, function(otherProp) { + const hasDuplicate = validateProp(prop) && _.find(rule.nodes, function(otherProp) { return prop !== otherProp && prop.prop === otherProp.prop && validateProp(otherProp); }); diff --git a/gulpfile.js b/gulpfile.js index 9d9aea4bb5..3f6fb8437f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,5 @@ -var gulp = require('gulp'); -var fs = require('fs'); +const gulp = require('gulp'); +const fs = require('fs'); //-- include docs gulpfile (should eventually be factored out) require('./docs/gulpfile'); diff --git a/package.json b/package.json index 27c1a01034..cb43084901 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,6 @@ "docs:watch": "gulp watch site --dev", "test:fast": "gulp karma-fast", "test:full": "gulp karma", - "lint": "eslint src" + "lint": "eslint ." } } diff --git a/release.js b/release.js index cf9dad7546..d951b7410a 100644 --- a/release.js +++ b/release.js @@ -1,26 +1,27 @@ +/* eslint-disable no-fallthrough */ (function () { 'use strict'; - var colors = require('colors'); - var strip = require('cli-color/strip'); - var fs = require('fs'); - var prompt = require('prompt-sync'); - var child_process = require('child_process'); - var pkg = require('./package.json'); - var oldVersion = pkg.version; - var abortCmds = [ 'git reset --hard', 'git checkout staging', 'rm abort push' ]; - var pushCmds = [ 'rm abort push' ]; - var cleanupCmds = []; - var defaultOptions = { encoding: 'utf-8' }; - var origin = 'git@github.com:angular/material.git'; - var lineWidth = 80; - var lastMajorVer = JSON.parse(exec('curl https://material.angularjs.org/docs.json')).latest; - var newVersion; - var dryRun; + const colors = require('colors'); + const strip = require('cli-color/strip'); + const fs = require('fs'); + const path = require('path'); + const prompt = require('prompt-sync'); + const child_process = require('child_process'); + const pkg = require('./package.json'); + let oldVersion = pkg.version; + const abortCmds = [ 'git reset --hard', 'git checkout staging', 'rm abort push' ]; + const pushCmds = [ 'rm abort push' ]; + const cleanupCmds = []; + const defaultOptions = { encoding: 'utf-8' }; + const origin = 'git@github.com:angular/material.git'; + const lineWidth = 80; + const lastMajorVer = JSON.parse(exec('curl https://material.angularjs.org/docs.json')).latest; + let newVersion; header(); write(`Is this a dry-run? ${"[yes/no]".cyan} `); - dryRun = prompt() !== 'no'; + const dryRun = prompt() !== 'no'; if (dryRun) { write(`What would you like the old version to be? (default: ${oldVersion.cyan}) `); @@ -67,7 +68,7 @@ return true; } function err (msg) { - var str = 'Error: ' + msg; + const str = 'Error: ' + msg; log(str.red); } } @@ -76,7 +77,7 @@ function checkoutVersionBranch () { exec(`git branch -q -D release/${newVersion}`); exec(`git checkout -q -b release/${newVersion}`); - abortCmds.push('git co master'); + abortCmds.push('git checkout master'); abortCmds.push(`git branch -D release/${newVersion}`); } @@ -112,14 +113,15 @@ /** prompts the user for the new version */ function getNewVersion () { header(); - var options = getVersionOptions(oldVersion), key, type, version; + const options = getVersionOptions(oldVersion); + let key, version; log(`The current version is ${oldVersion.cyan}.`); log(''); log('What should the next version be?'); for (key in options) { log((+key + 1) + ') ' + options[ key ].cyan); } log(''); write('Please select a new version: '); - type = prompt(); + const type = prompt(); if (options[ type - 1 ]) version = options[ type - 1 ]; else if (type.match(/^\d+\.\d+\.\d+(-rc\.?\d+)?$/)) version = type; @@ -136,7 +138,7 @@ : [ increment(version, 'patch'), addRC(increment(version, 'minor')) ]; function increment (versionString, type) { - var version = parseVersion(versionString); + const version = parseVersion(versionString); if (version.rc) { switch (type) { case 'minor': version.rc = 0; break; @@ -153,7 +155,7 @@ return getVersionString(version); function parseVersion (version) { - var parts = version.split(/\-rc\.|\./g); + const parts = version.split(/-rc\.|\./g); return { string: version, major: parts[ 0 ], @@ -164,7 +166,7 @@ } function getVersionString (version) { - var str = version.major + '.' + version.minor + '.' + version.patch; + let str = version.major + '.' + version.minor + '.' + version.patch; if (version.rc) str += '-rc.' + version.rc; return str; } @@ -211,9 +213,9 @@ /** updates the version for bower-material in package.json and bower.json */ function updateBowerVersion () { start('Updating bower version...'); - var options = { cwd: './bower-material' }, - bower = require(options.cwd + '/bower.json'), - pkg = require(options.cwd + '/package.json'); + const options = { cwd: './bower-material' }; + const bower = require(options.cwd + '/bower.json'), + pkg = require(options.cwd + '/package.json'); //-- update versions in config files bower.version = pkg.version = newVersion; fs.writeFileSync(options.cwd + '/package.json', JSON.stringify(pkg, null, 2)); @@ -257,7 +259,7 @@ /** builds the website for the new version */ function updateSite () { start('Adding new version of the docs site...'); - var options = { cwd: './code.material.angularjs.org' }; + const options = { cwd: './code.material.angularjs.org' }; writeDocsJson(); //-- build files for bower @@ -295,9 +297,9 @@ function updateFirebaseJson () { fs.writeFileSync(options.cwd + '/firebase.json', getFirebaseJson()); function getFirebaseJson () { - var json = require(options.cwd + '/firebase.json'); + const json = require(options.cwd + '/firebase.json'); json.hosting.rewrites = json.hosting.rewrites || []; - var rewrites = json.hosting.rewrites; + const rewrites = json.hosting.rewrites; switch (rewrites.length) { case 0: @@ -318,7 +320,7 @@ } function writeDocsJson () { - var config = require(options.cwd + '/docs.json'); + const config = require(options.cwd + '/docs.json'); config.versions.unshift(newVersion); //-- only set to default if not a release candidate @@ -330,22 +332,21 @@ /** replaces localhost file paths with public URLs */ function replaceFilePaths () { //-- handle docs.js - var path = __dirname + '/dist/docs/docs.js'; - var file = fs.readFileSync(path); - var contents = file.toString() + const filePath = path.join(__dirname, '/dist/docs/docs.js'); + const file = fs.readFileSync(filePath); + const contents = file.toString() .replace(/http:\/\/localhost:8080\/angular-material/g, 'https://cdn.gitcdn.link/cdn/angular/bower-material/v' + newVersion + '/angular-material') .replace(/http:\/\/localhost:8080\/docs.css/g, 'https://material.angularjs.org/' + newVersion + '/docs.css'); - fs.writeFileSync(path, contents); - + fs.writeFileSync(filePath, contents); } /** replaces base href in index.html for new version as well as latest */ function replaceBaseHref (folder) { //-- handle index.html - var path = __dirname + '/code.material.angularjs.org/' + folder + '/index.html'; - var file = fs.readFileSync(path); - var contents = file.toString().replace(/base href="\//g, 'base href="/' + folder + '/'); - fs.writeFileSync(path, contents); + const filePath = path.join(__dirname, '/code.material.angularjs.org/', folder, '/index.html'); + const file = fs.readFileSync(filePath); + const contents = file.toString().replace(/base href="\//g, 'base href="/' + folder + '/'); + fs.writeFileSync(filePath, contents); } /** copies the changelog back over to master branch */ @@ -355,7 +356,7 @@ 'git checkout master', `git pull --rebase ${origin} master --strategy=theirs`, `git checkout release/${newVersion} -- CHANGELOG.md`, - `node -e "var newVersion = '${newVersion}'; ${stringifyFunction(buildCommand)}"`, + `node -e "const newVersion = '${newVersion}'; ${stringifyFunction(buildCommand)}"`, 'git add CHANGELOG.md', 'git add package.json', `git commit -m "update version number in package.json to ${newVersion}"`, @@ -365,7 +366,7 @@ function buildCommand () { require('fs').writeFileSync('package.json', JSON.stringify(getUpdatedJson(), null, 2)); function getUpdatedJson () { - var json = require('./package.json'); + const json = require('./package.json'); json.version = newVersion; return json; } @@ -393,8 +394,8 @@ /** outputs a centered message in the terminal */ function center (msg) { msg = ' ' + msg.trim() + ' '; - var length = msg.length; - var spaces = Math.floor((lineWidth - length) / 2); + const length = msg.length; + const spaces = Math.floor((lineWidth - length) / 2); return Array(spaces + 1).join('-') + msg.green + Array(lineWidth - msg.length - spaces + 1).join('-'); } @@ -409,8 +410,8 @@ return cmd.map(function (cmd) { return exec(cmd, userOptions); }); } try { - var options = Object.create(defaultOptions); - for (var key in userOptions) options[ key ] = userOptions[ key ]; + const options = Object.create(defaultOptions); + for (const key in userOptions) options[ key ] = userOptions[ key ]; return child_process.execSync(cmd + ' 2> /dev/null', options).toString().trim(); } catch (err) { return err; @@ -422,10 +423,12 @@ return '\n# ' + msg + '\n'; } - /** prints the left side of a task while it is being performed */ + /** + * prints the left side of a task while it is being performed + */ function start (msg) { - var msgLength = strip(msg).length, - diff = lineWidth - 4 - msgLength; + const msgLength = strip(msg).length, + diff = lineWidth - 4 - msgLength; write(msg + Array(diff + 1).join(' ')); } diff --git a/scripts/find-max-version.js b/scripts/find-max-version.js index 26270f0acf..670b5abde2 100755 --- a/scripts/find-max-version.js +++ b/scripts/find-max-version.js @@ -8,16 +8,16 @@ // command which is required to parse the // collection of tags so that we can figure out // the max version for the provided branch value -var exec = require('child_process').exec; +const exec = require('child_process').exec; // this is the provided input value which could // be a general branch like `1.3` or a specific // version like `1.4.6`. -var version = process.argv[2]; +const version = process.argv[2]; if (!version) return; exec("git --git-dir ./tmp/angular.js/.git tag", function(error, output) { - var v = findMaxVersion(version, output); + const v = findMaxVersion(version, output); if (v) { // drop the `v` prefix from the version // `v1.3.5` => `1.3.5` @@ -29,14 +29,14 @@ exec("git --git-dir ./tmp/angular.js/.git tag", function(error, output) { }); function findMaxVersion(branch, output) { - var lines; - var highestVersion; - var majorBranch; + let lines; + let highestVersion; + let majorBranch; // these weights are used to figure out which // releases are more important than others // (e.g. 1.3.0 > 1.3.0.beta.2) - var WEIGHTS = { + const WEIGHTS = { 'beta': 10, 'rc': 1000, 'stable': 1000000 @@ -53,15 +53,15 @@ function findMaxVersion(branch, output) { lines = output.split("\n"); } - var versionRegex = new RegExp('^v' + majorBranch + '.(\\d+)(?:-(beta|rc).(\\d+))?'); + const versionRegex = new RegExp('^v' + majorBranch + '.(\\d+)(?:-(beta|rc).(\\d+))?'); - for (var i = lines.length - 1; i >= 0; i--) { - var line = lines[i]; - var result = line.match(versionRegex); + for (let i = lines.length - 1; i >= 0; i--) { + const line = lines[i]; + const result = line.match(versionRegex); if (result && result.length > 0) { // stable releases have a higher weight than beta/RC versions // so we want to include - var weight = result[1] * WEIGHTS.stable; + let weight = result[1] * WEIGHTS.stable; if (result[2]) { // something like "1.3.0-beta.2" will have a weight @@ -72,7 +72,7 @@ function findMaxVersion(branch, output) { // like "beta.0" // // so 1.3.0-beta.0 => 10 and 1.3.0-rc.0 => 1000 - var multiplier = WEIGHTS[result[2]]; + const multiplier = WEIGHTS[result[2]]; weight += multiplier * (result[3] + 1); } else { // this adds an extra 1 as well so that diff --git a/scripts/gulp-utils.js b/scripts/gulp-utils.js index 9a79763c9e..ea7ed5cf61 100644 --- a/scripts/gulp-utils.js +++ b/scripts/gulp-utils.js @@ -1,14 +1,11 @@ -var gulp = require('gulp'); -var filter = require('gulp-filter'); -var through2 = require('through2'); -var lazypipe = require('lazypipe'); -var gutil = require('gulp-util'); -var autoprefixer = require('gulp-autoprefixer'); -var Buffer = require('buffer').Buffer; -var fs = require('fs'); - -var path = require('path'); -var findModule = require('../config/ngModuleData.js'); +const gulp = require('gulp'); +const through2 = require('through2'); +const gutil = require('gulp-util'); +const autoprefixer = require('gulp-autoprefixer'); +const Buffer = require('buffer').Buffer; +const fs = require('fs'); +const path = require('path'); +const findModule = require('../config/ngModuleData.js'); exports.humanizeCamelCase = function(str) { switch (str) { @@ -32,12 +29,12 @@ exports.copyDemoAssets = function(component, srcDir, distDir) { .pipe(through2.obj( copyAssetsFor )); function copyAssetsFor( demo, enc, next){ - var demoID = component + "/" + path.basename(demo.path); - var demoDir = demo.path + "/**/*"; + const demoID = component + "/" + path.basename(demo.path); + const demoDir = demo.path + "/**/*"; - var notJS = '!' + demoDir + '.js'; - var notCSS = '!' + demoDir + '.css'; - var notHTML= '!' + demoDir + '.html'; + const notJS = '!' + demoDir + '.js'; + const notCSS = '!' + demoDir + '.css'; + const notHTML= '!' + demoDir + '.html'; gulp.src([demoDir, notJS, notCSS, notHTML]) .pipe(gulp.dest(distDir + demoID)); @@ -47,18 +44,16 @@ exports.copyDemoAssets = function(component, srcDir, distDir) { }; // Gives back a pipe with an array of the parsed data from all of the module's demos -// @param moduleName modulename to parse +// @param moduleName module name to parse // @param fileTasks: tasks to run on the files found in the demo's folder // Emits demo objects exports.readModuleDemos = function(moduleName, fileTasks) { - var name = moduleName.split('.').pop(); + const name = moduleName.split('.').pop(); return gulp.src('src/{components,services}/' + name + '/demo*/') .pipe(through2.obj(function(demoFolder, enc, next) { - var demoId = name + path.basename(demoFolder.path); - var srcPath = demoFolder.path.substring(demoFolder.path.indexOf('src/') + 4); - var split = srcPath.split('/'); + const demoId = name + path.basename(demoFolder.path); - var demo = { + const demo = { ngModule: '', id: demoId, css:[], html:[], js:[] @@ -75,14 +70,14 @@ exports.readModuleDemos = function(moduleName, fileTasks) { demo.index = toDemoObject(file); } else { - var fileType = path.extname(file.path).substring(1); - if (fileType == 'js') { + const fileType = path.extname(file.path).substring(1); + if (fileType === 'js') { demo.ngModule = demo.ngModule || findModule.any(file.contents.toString()); } demo[fileType] && demo[fileType].push(toDemoObject(file)); } cb(); - }, function(done) { + }, function() { next(null, demo); })); @@ -98,7 +93,7 @@ exports.readModuleDemos = function(moduleName, fileTasks) { })); }; -var pathsForModules = {}; +const pathsForModules = {}; exports.pathsForModule = function(name) { return pathsForModules[name] || lookupPath(); @@ -106,16 +101,16 @@ exports.pathsForModule = function(name) { function lookupPath() { gulp.src('src/{services,components,core}/**/*') .pipe(through2.obj(function(file, enc, next) { - var module = findModule.any(file.contents); - if (module && module.name == name) { - var modulePath = file.path.split(path.sep).slice(0, -1).join(path.sep); + const module = findModule.any(file.contents); + if (module && module.name === name) { + const modulePath = file.path.split(path.sep).slice(0, -1).join(path.sep); pathsForModules[name] = modulePath + '/**'; } next(); })); return pathsForModules[name]; } -} +}; exports.filesForModule = function(name) { if (pathsForModules[name]) { @@ -123,11 +118,11 @@ exports.filesForModule = function(name) { } else { return gulp.src('src/{services,components,core}/**/*') .pipe(through2.obj(function(file, enc, next) { - var module = findModule.any(file.contents); - if (module && (module.name == name)) { - var modulePath = file.path.split(path.sep).slice(0, -1).join(path.sep); + const module = findModule.any(file.contents); + if (module && (module.name === name)) { + const modulePath = file.path.split(path.sep).slice(0, -1).join(path.sep); pathsForModules[name] = modulePath + '/**'; - var self = this; + const self = this; srcFiles(pathsForModules[name]).on('data', function(data) { self.push(data); }); @@ -146,18 +141,18 @@ exports.filesForModule = function(name) { }; exports.appendToFile = function(filePath) { - var bufferedContents; + let bufferedContents; return through2.obj(function(file, enc, next) { bufferedContents = file.contents.toString('utf8') + '\n'; next(); }, function(done) { - var existing = fs.readFileSync(filePath, 'utf8'); + const existing = fs.readFileSync(filePath, 'utf8'); bufferedContents = existing + '\n' + bufferedContents; - var outputFile = new gutil.File({ + const outputFile = new gutil.File({ cwd: process.cwd(), base: path.dirname(filePath), path: filePath, - contents: new Buffer(bufferedContents) + contents: Buffer.from(bufferedContents) }); this.push(outputFile); done(); @@ -165,23 +160,22 @@ exports.appendToFile = function(filePath) { }; exports.buildNgMaterialDefinition = function() { - var srcBuffer = []; - var modulesSeen = []; - var count = 0; + let srcBuffer = []; + const modulesSeen = []; return through2.obj(function(file, enc, next) { - var module = findModule.material(file.contents); + const module = findModule.material(file.contents); if (module) modulesSeen.push(module.name); srcBuffer.push(file); next(); }, function(done) { - var self = this; - var requiredLibs = ['ng', 'ngAnimate', 'ngAria']; - var dependencies = JSON.stringify(requiredLibs.concat(modulesSeen)); - var ngMaterialModule = "angular.module('ngMaterial', " + dependencies + ');'; - var angularFile = new gutil.File({ + const self = this; + const requiredLibs = ['ng', 'ngAnimate', 'ngAria']; + const dependencies = JSON.stringify(requiredLibs.concat(modulesSeen)); + const ngMaterialModule = "angular.module('ngMaterial', " + dependencies + ');'; + const angularFile = new gutil.File({ base: process.cwd(), path: process.cwd() + '/ngMaterial.js', - contents: new Buffer(ngMaterialModule) + contents: Buffer.from(ngMaterialModule) }); // Elevate ngMaterial module registration to first in queue @@ -203,13 +197,13 @@ function moduleNameToClosureName(name) { } exports.addJsWrapper = function(enforce) { return through2.obj(function(file, enc, next) { - var module = findModule.any(file.contents); + const module = findModule.any(file.contents); if (!!enforce || module) { - file.contents = new Buffer([ - !!enforce ? '(function(){' : '(function( window, angular, undefined ){', + file.contents = Buffer.from([ + enforce ? '(function(){' : '(function( window, angular, undefined ){', '"use strict";\n', file.contents.toString(), - !!enforce ? '})();' : '})(window, window.angular);' + enforce ? '})();' : '})(window, window.angular);' ].join('\n')); } this.push(file); @@ -218,15 +212,15 @@ exports.addJsWrapper = function(enforce) { }; exports.addClosurePrefixes = function() { return through2.obj(function(file, enc, next) { - var module = findModule.any(file.contents); + const module = findModule.any(file.contents); if (module) { - var closureModuleName = moduleNameToClosureName(module.name); - var requires = (module.dependencies || []).sort().map(function(dep) { - if (dep.indexOf(module.name) === 0 || /material\..+/g.test(dep) == false) return ''; + const closureModuleName = moduleNameToClosureName(module.name); + const requires = (module.dependencies || []).sort().map(function(dep) { + if (dep.indexOf(module.name) === 0 || /material\..+/g.test(dep) === false) return ''; return 'goog.require(\'' + moduleNameToClosureName(dep) + '\');'; }).join('\n'); - file.contents = new Buffer([ + file.contents = Buffer.from([ 'goog.provide(\'' + closureModuleName + '\');', requires, file.contents.toString(), @@ -241,22 +235,22 @@ exports.addClosurePrefixes = function() { exports.buildModuleBower = function(name, version) { return through2.obj(function(file, enc, next) { this.push(file); - var module = findModule.any(file.contents); + const module = findModule.any(file.contents); if (module) { - var bowerDeps = {}; + const bowerDeps = {}; (module.dependencies || []).forEach(function(dep) { - var convertedName = 'angular-material-' + dep.split('.').pop(); + const convertedName = 'angular-material-' + dep.split('.').pop(); bowerDeps[convertedName] = version; }); - var bowerContents = JSON.stringify({ + const bowerContents = JSON.stringify({ name: 'angular-material-' + name, version: version, dependencies: bowerDeps }, null, 2); - var bowerFile = new gutil.File({ + const bowerFile = new gutil.File({ base: file.base, path: file.base + '/bower.json', - contents: new Buffer(bowerContents) + contents: Buffer.from(bowerContents) }); this.push(bowerFile); } @@ -266,25 +260,25 @@ exports.buildModuleBower = function(name, version) { exports.hoistScssVariables = function() { return through2.obj(function(file, enc, next) { - var contents = file.contents.toString().split('\n'); - var lastVariableLine = -1; + const contents = file.contents.toString().split('\n'); + let lastVariableLine = -1; - var openCount = 0; - var closeCount = 0; - var openBlock = false; + let openCount = 0; + let closeCount = 0; + let openBlock = false; - for( var currentLine = 0; currentLine < contents.length; ++currentLine) { - var line = contents[currentLine]; + for(let currentLine = 0; currentLine < contents.length; ++currentLine) { + const line = contents[currentLine]; if (openBlock || /^\s*\$/.test(line) && !/^\s+/.test(line)) { openCount += (line.match(/\(/g) || []).length; closeCount += (line.match(/\)/g) || []).length; - openBlock = openCount != closeCount; - var variable = contents.splice(currentLine, 1)[0]; + openBlock = openCount !== closeCount; + const variable = contents.splice(currentLine, 1)[0]; contents.splice(++lastVariableLine, 0, variable); } } - file.contents = new Buffer(contents.join('\n')); + file.contents = Buffer.from(contents.join('\n')); this.push(file); next(); }); @@ -293,13 +287,13 @@ exports.hoistScssVariables = function() { exports.cssToNgConstant = function(ngModule, factoryName) { return through2.obj(function(file, enc, next) { - var template = '(function(){ \nangular.module("%1").constant("%2", "%3"); \n})();\n\n'; - var output = file.contents.toString().replace(/\n/g, '').replace(/\"/g,'\\"'); + const template = '(function(){ \nangular.module("%1").constant("%2", "%3"); \n})();\n\n'; + const output = file.contents.toString().replace(/\n/g, '').replace(/"/g,'\\"'); - var jsFile = new gutil.File({ + const jsFile = new gutil.File({ base: file.base, path: file.path.replace('css', 'js'), - contents: new Buffer( + contents: Buffer.from( template.replace('%1', ngModule) .replace('%2', factoryName) .replace('%3', output) diff --git a/updateVersionPicker.js b/updateVersionPicker.js index 0b3b0dec35..c06c70641d 100644 --- a/updateVersionPicker.js +++ b/updateVersionPicker.js @@ -1,11 +1,8 @@ (function () { 'use strict'; - var strip = require('cli-color/strip'); - var fs = require('fs'); - var prompt = require('prompt-sync'); - var child_process = require('child_process'); - var defaultOptions = { encoding: 'utf-8' }; + const child_process = require('child_process'); + const defaultOptions = { encoding: 'utf-8' }; exec([ 'git checkout master', @@ -13,7 +10,7 @@ 'git clone https://github.com/angular/code.material.angularjs.org.git --depth=1 /tmp/ngcode' ]); - var docs = require('/tmp/ngcode/docs.json'); + const docs = require('/tmp/ngcode/docs.json'); docs.versions.forEach(function (version) { exec([ @@ -39,7 +36,7 @@ exec([ 'ls', 'rm -rf latest', - 'cp -r {{docs.latest}} latest', + `cp -r ${docs.latest} latest`, 'git add -A', 'git commit -m "updating version picker for old releases"', 'git push' @@ -47,35 +44,17 @@ //-- utility methods - function fill(str) { - return str.replace(/\{\{[^\}]+\}\}/g, function (match) { - return eval(match.substr(2, match.length - 4)); - }); - } - - function done () { - log('done'.green); - } - function exec (cmd, userOptions) { if (cmd instanceof Array) { return cmd.map(function (cmd) { return exec(cmd, userOptions); }); } try { - var options = Object.create(defaultOptions); - for (var key in userOptions) options[key] = userOptions[key]; - log('\n--------\n' + fill(cmd)); - return log(child_process.execSync(fill(cmd), options).trim()); + const options = Object.create(defaultOptions); + for (const key in userOptions) options[key] = userOptions[key]; + console.log(`\n--------\n ${cmd}`); + return console.log(child_process.execSync(cmd, options).trim()); } catch (err) { return err; } } - - function log (msg) { - console.log(fill(msg)); - } - - function write (msg) { - process.stdout.write(fill(msg)); - } })();