From 16c36cc51bef563964ba583191df92a336916d5a Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 09:58:07 -0700 Subject: [PATCH 01/45] ci - publish dist as artifact --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75819fc6e..a983f77c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -98,6 +98,9 @@ jobs: key: build-cache-{{ .Revision }} paths: - dist + - store_artifacts: + path: dist/chrome + # destination: build prep-scss: docker: From 5834c13769a4c84fc89f2c4bd2480f3fe58b5100 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 13:37:02 -0700 Subject: [PATCH 02/45] ui - change window title 'MetaMask Plugin' to 'MetaMask' --- app/home.html | 2 +- app/popup.html | 2 +- test/e2e/metamask.spec.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/home.html b/app/home.html index cfb4b00a0..730215d1a 100644 --- a/app/home.html +++ b/app/home.html @@ -3,7 +3,7 @@ - MetaMask Plugin + MetaMask
diff --git a/app/popup.html b/app/popup.html index bf09b97ca..148d266d3 100644 --- a/app/popup.html +++ b/app/popup.html @@ -3,7 +3,7 @@ - MetaMask Plugin + MetaMask
diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index c73ba2b41..e81e0a8df 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -33,7 +33,7 @@ describe('Metamask popup page', function () { it('should match title', async () => { const title = await driver.getTitle() - assert.equal(title, 'MetaMask Plugin', 'title matches MetaMask Plugin') + assert.equal(title, 'MetaMask', 'title matches MetaMask') }) it('should show privacy notice', async () => { From 5815de33fbef617625d8350ec8e88aa4dbff6156 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 14:04:33 -0700 Subject: [PATCH 03/45] build - rename 'popup.js' to 'ui.js' --- app/home.html | 2 +- app/notification.html | 2 +- app/popup.html | 2 +- app/scripts/{popup.js => ui.js} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename app/scripts/{popup.js => ui.js} (100%) diff --git a/app/home.html b/app/home.html index 730215d1a..bb8e936a3 100644 --- a/app/home.html +++ b/app/home.html @@ -7,6 +7,6 @@
- + diff --git a/app/notification.html b/app/notification.html index f10cbbf41..2255ca2c1 100644 --- a/app/notification.html +++ b/app/notification.html @@ -11,6 +11,6 @@
- + diff --git a/app/popup.html b/app/popup.html index 148d266d3..109487d3e 100644 --- a/app/popup.html +++ b/app/popup.html @@ -7,6 +7,6 @@
- + diff --git a/app/scripts/popup.js b/app/scripts/ui.js similarity index 100% rename from app/scripts/popup.js rename to app/scripts/ui.js From 53895f19e01146e23702eec52172b4f29cd6f20a Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 14:05:54 -0700 Subject: [PATCH 04/45] ci - upload mascara build as artifact --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a983f77c0..2c75aada9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,8 +99,7 @@ jobs: paths: - dist - store_artifacts: - path: dist/chrome - # destination: build + path: dist/mascara prep-scss: docker: From bdf99269e275590b31347322961e773ad980b812 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 14:06:59 -0700 Subject: [PATCH 05/45] mascara - move file locations to match extension structure --- mascara/server/index.js | 8 ++++---- mascara/src/proxy.js | 2 +- mascara/src/ui.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mascara/server/index.js b/mascara/server/index.js index 6fb1287cc..0f9b047a7 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -20,16 +20,16 @@ function createMetamascaraServer () { server.use(compression()) // ui window - serveBundle(server, '/ui.js', uiBundle) + serveBundle(server, '/scripts/ui.js', uiBundle) server.use(express.static(path.join(__dirname, '/../ui/'), { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') })) server.use(express.static(path.join(__dirname, '/../../dist/chrome'))) // metamascara serveBundle(server, '/metamascara.js', metamascaraBundle) // proxy - serveBundle(server, '/proxy/proxy.js', proxyBundle) - server.use('/proxy/', express.static(path.join(__dirname, '/../proxy'))) + serveBundle(server, '/scripts/proxy.js', proxyBundle) + server.use('/', express.static(path.join(__dirname, '/../proxy'))) // background - serveBundle(server, '/background.js', backgroundBuild) + serveBundle(server, '/scripts/background.js', backgroundBuild) return server diff --git a/mascara/src/proxy.js b/mascara/src/proxy.js index 54c5d5cf4..3958f7d50 100644 --- a/mascara/src/proxy.js +++ b/mascara/src/proxy.js @@ -4,7 +4,7 @@ const SwStream = require('sw-stream/lib/sw-stream.js') const intervalDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000 const background = new SWcontroller({ - fileName: '/background.js', + fileName: './scripts/background.js', letBeIdle: false, wakeUpInterval: 30000, intervalDelay, diff --git a/mascara/src/ui.js b/mascara/src/ui.js index b272a2e06..21e5f32a9 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -20,7 +20,7 @@ window.METAMASK_PLATFORM_TYPE = 'mascara' const intervalDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000 const background = new SWcontroller({ - fileName: '/background.js', + fileName: './scripts/background.js', letBeIdle: false, intervalDelay, wakeUpInterval: 20000, From 4f915cf2d817cf4dadea581c90a98841b81c156d Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 14:07:32 -0700 Subject: [PATCH 06/45] build - refactor build task generators + add mascara to standard build phase --- gulpfile.js | 200 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 115 insertions(+), 85 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f57ea6206..2c000f576 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,6 +32,15 @@ var babel = require('gulp-babel') var disableDebugTools = gutil.env.disableDebugTools var debug = gutil.env.debug +const commonPlatforms = [ + // browser extensions + 'firefox', + 'chrome', + 'edge', + 'opera', + // browser webapp + 'mascara', +] // browser reload @@ -46,58 +55,28 @@ gulp.task('dev:reload', function() { gulp.task('copy:locales', copyTask({ source: './app/_locales/', - destinations: [ - './dist/firefox/_locales', - './dist/chrome/_locales', - './dist/edge/_locales', - './dist/opera/_locales', - ] + destinations: commonPlatforms.map(platform => `./dist/${platform}/_locales`), })) gulp.task('copy:images', copyTask({ source: './app/images/', - destinations: [ - './dist/firefox/images', - './dist/chrome/images', - './dist/edge/images', - './dist/opera/images', - ], + destinations: commonPlatforms.map(platform => `./dist/${platform}/images`), })) gulp.task('copy:contractImages', copyTask({ source: './node_modules/eth-contract-metadata/images/', - destinations: [ - './dist/firefox/images/contract', - './dist/chrome/images/contract', - './dist/edge/images/contract', - './dist/opera/images/contract', - ], + destinations: commonPlatforms.map(platform => `./dist/${platform}/images/contract`), })) gulp.task('copy:fonts', copyTask({ source: './app/fonts/', - destinations: [ - './dist/firefox/fonts', - './dist/chrome/fonts', - './dist/edge/fonts', - './dist/opera/fonts', - ], + destinations: commonPlatforms.map(platform => `./dist/${platform}/fonts`), })) gulp.task('copy:reload', copyTask({ source: './app/scripts/', - destinations: [ - './dist/firefox/scripts', - './dist/chrome/scripts', - './dist/edge/scripts', - './dist/opera/scripts', - ], + destinations: commonPlatforms.map(platform => `./dist/${platform}/scripts`), pattern: '/chromereload.js', })) gulp.task('copy:root', copyTask({ source: './app/', - destinations: [ - './dist/firefox', - './dist/chrome', - './dist/edge', - './dist/opera', - ], + destinations: commonPlatforms.map(platform => `./dist/${platform}`), pattern: '/*', })) @@ -208,7 +187,7 @@ const jsFiles = [ 'inpage', 'contentscript', 'background', - 'popup', + 'ui', ] // scss compilation and autoprefixing tasks @@ -230,7 +209,7 @@ gulp.task('lint-scss', function() { .src('ui/app/css/itcss/**/*.scss') .pipe(gulpStylelint({ reporters: [ - {formatter: 'string', console: true} + { formatter: 'string', console: true } ], fix: true, })); @@ -243,32 +222,51 @@ gulp.task('fmt-scss', function () { }); // bundle tasks +createTasksForBuildJsExtension({ jsFiles, taskPrefix: 'dev:js', bundleTaskOpts: { isBuild: false } }) +createTasksForBuildJsExtension({ jsFiles, taskPrefix: 'build:js:extension', bundleTaskOpts: { isBuild: true } }) +createTasksForBuildJsMascara({ taskPrefix: 'build:js:mascara' }) -var jsDevStrings = jsFiles.map(jsFile => `dev:js:${jsFile}`) -var jsBuildStrings = jsFiles.map(jsFile => `build:js:${jsFile}`) +function createTasksForBuildJsExtension({ jsFiles, taskPrefix, bundleTaskOpts }) { + // inpage must be built before all other scripts: + const rootDir = './app/scripts' + const nonInpageFiles = jsFiles.filter(file => file !== 'inpage') + const buildPhase1 = ['inpage'] + const buildPhase2 = nonInpageFiles + const destinations = [ + './dist/firefox/scripts', + './dist/chrome/scripts', + './dist/edge/scripts', + './dist/opera/scripts', + ] + createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, buildPhase1, buildPhase2 }) +} -jsFiles.forEach((jsFile) => { - gulp.task(`dev:js:${jsFile}`, bundleTask({ - watch: true, - label: jsFile, - filename: `${jsFile}.js`, - isBuild: false - })) - gulp.task(`build:js:${jsFile}`, bundleTask({ - watch: false, - label: jsFile, - filename: `${jsFile}.js`, - isBuild: true - })) -}) +function createTasksForBuildJsMascara({ taskPrefix, bundleTaskOpts }) { + // inpage must be built before all other scripts: + const rootDir = './mascara/src/' + const jsFiles = ['ui', 'proxy', 'background'] + const destinations = ['./dist/mascara/scripts'] + createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, buildPhase1: jsFiles }) +} -// inpage must be built before all other scripts: -const firstDevString = jsDevStrings.shift() -gulp.task('dev:js', gulp.series(firstDevString, gulp.parallel(...jsDevStrings))) +function createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, buildPhase1 = [], buildPhase2 = [] }) { + // bundle task for each file + jsFiles.forEach((jsFile) => { + gulp.task(`${taskPrefix}:${jsFile}`, bundleTask(Object.assign({ + watch: false, + label: jsFile, + filename: `${jsFile}.js`, + filepath: `${rootDir}/${jsFile}.js`, + destinations, + }, bundleTaskOpts))) + }) + // compose into larger task + const subtasks = [] + subtasks.push(gulp.parallel(buildPhase1.map(file => `${taskPrefix}:${file}`))) + if (buildPhase2.length) subtasks.push(gulp.parallel(buildPhase2.map(file => `${taskPrefix}:${file}`))) -// inpage must be built before all other scripts: -const firstBuildString = jsBuildStrings.shift() -gulp.task('build:js', gulp.series(firstBuildString, gulp.parallel(...jsBuildStrings))) + gulp.task(taskPrefix, gulp.series(subtasks)) +} // disc bundle analyzer tasks @@ -278,7 +276,6 @@ jsFiles.forEach((jsFile) => { gulp.task('disc', gulp.parallel(jsFiles.map(jsFile => `disc:${jsFile}`))) - // clean dist @@ -295,16 +292,44 @@ gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox', 'zip:edge', 'zip:ope // set env var for production gulp.task('apply-prod-environment', function(done) { - process.env.NODE_ENV = 'production' - done() + process.env.NODE_ENV = 'production' + done() }); // high level tasks -gulp.task('dev', gulp.series('build:scss', 'dev:js', 'copy', gulp.parallel('watch:scss', 'copy:watch', 'dev:reload'))) +gulp.task('dev', + gulp.series( + 'build:scss', + 'dev:js', + 'copy', + gulp.parallel( + 'watch:scss', + 'copy:watch', + 'dev:reload' + ) + ) +) -gulp.task('build', gulp.series('clean', 'build:scss', gulp.parallel('build:js', 'copy'))) -gulp.task('dist', gulp.series('apply-prod-environment', 'build', 'zip')) +gulp.task('build', + gulp.series( + 'clean', + 'build:scss', + gulp.parallel( + 'build:js:extension', + 'build:js:mascara', + 'copy' + ) + ) +) + +gulp.task('dist', + gulp.series( + 'apply-prod-environment', + 'build', + 'zip' + ) +) // task generators @@ -337,7 +362,7 @@ function zipTask(target) { function generateBundler(opts, performBundle) { const browserifyOpts = assign({}, watchify.args, { - entries: ['./app/scripts/'+opts.filename], + entries: [opts.filepath], plugin: 'browserify-derequire', debug: true, fullPaths: debug, @@ -384,19 +409,21 @@ function bundleTask(opts) { return performBundle function performBundle(){ - return ( - bundler.bundle() + let buildStream = bundler.bundle() - // handle errors - .on('error', (err) => { - beep() - if (opts.watch) { - console.warn(err.stack) - } else { - throw err - } - }) + // handle errors + buildStream.on('error', (err) => { + beep() + if (opts.watch) { + console.warn(err.stack) + } else { + throw err + } + }) + + // process bundles + buildStream = buildStream // convert bundle stream to gulp vinyl stream .pipe(source(opts.filename)) // inject variables into bundle @@ -412,15 +439,18 @@ function bundleTask(opts) { }))) // writes .map file .pipe(sourcemaps.write(debug ? './' : '../../sourcemaps')) - // write completed bundles - .pipe(gulp.dest('./dist/firefox/scripts')) - .pipe(gulp.dest('./dist/chrome/scripts')) - .pipe(gulp.dest('./dist/edge/scripts')) - .pipe(gulp.dest('./dist/opera/scripts')) - // finally, trigger live reload + + // write completed bundles + opts.destinations.forEach((dest) => { + buildStream = buildStream.pipe(gulp.dest(dest)) + }) + + // finally, trigger live reload + buildStream = buildStream .pipe(gulpif(debug, livereload())) - ) + return buildStream + } } From f7b4c9621fde7840fcdc0583c3cfde97b5e81cd8 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 14:42:58 -0700 Subject: [PATCH 07/45] ui - css - use relative path for fonts --- ui/app/css/itcss/settings/typography.scss | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ui/app/css/itcss/settings/typography.scss b/ui/app/css/itcss/settings/typography.scss index 8a56d9c6c..18c444c8a 100644 --- a/ui/app/css/itcss/settings/typography.scss +++ b/ui/app/css/itcss/settings/typography.scss @@ -1,4 +1,4 @@ -@import url('/fonts/Font_Awesome/font-awesome.min.css'); +@import url('./fonts/Font_Awesome/font-awesome.min.css'); @font-face { font-family: 'Roboto'; @@ -338,8 +338,8 @@ @font-face { font-family: 'Montserrat Regular'; - src: url('/fonts/Montserrat/Montserrat-Regular.woff') format('woff'); - src: url('/fonts/Montserrat/Montserrat-Regular.ttf') format('truetype'); + src: url('./fonts/Montserrat/Montserrat-Regular.woff') format('woff'); + src: url('./fonts/Montserrat/Montserrat-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-size: 'small'; @@ -347,59 +347,59 @@ @font-face { font-family: 'Montserrat Bold'; - src: url('/fonts/Montserrat/Montserrat-Bold.woff') format('woff'); - src: url('/fonts/Montserrat/Montserrat-Bold.ttf') format('truetype'); + src: url('./fonts/Montserrat/Montserrat-Bold.woff') format('woff'); + src: url('./fonts/Montserrat/Montserrat-Bold.ttf') format('truetype'); font-weight: 400; font-style: normal; } @font-face { font-family: 'Montserrat Light'; - src: url('/fonts/Montserrat/Montserrat-Light.woff') format('woff'); - src: url('/fonts/Montserrat/Montserrat-Light.ttf') format('truetype'); + src: url('./fonts/Montserrat/Montserrat-Light.woff') format('woff'); + src: url('./fonts/Montserrat/Montserrat-Light.ttf') format('truetype'); font-weight: 400; font-style: normal; } @font-face { font-family: 'Montserrat UltraLight'; - src: url('/fonts/Montserrat/Montserrat-UltraLight.woff') format('woff'); - src: url('/fonts/Montserrat/Montserrat-UltraLight.ttf') format('truetype'); + src: url('./fonts/Montserrat/Montserrat-UltraLight.woff') format('woff'); + src: url('./fonts/Montserrat/Montserrat-UltraLight.ttf') format('truetype'); font-weight: 400; font-style: normal; } @font-face { font-family: 'DIN OT'; - src: url('/fonts/DIN_OT/DINOT-2.otf') format('opentype'); + src: url('./fonts/DIN_OT/DINOT-2.otf') format('opentype'); font-weight: 400; font-style: normal; } @font-face { font-family: 'DIN OT Light'; - src: url('/fonts/DIN_OT/DINOT-2.otf') format('opentype'); + src: url('./fonts/DIN_OT/DINOT-2.otf') format('opentype'); font-weight: 200; font-style: normal; } @font-face { font-family: 'DIN NEXT'; - src: url('/fonts/DIN Next/DIN Next W01 Regular.otf') format('opentype'); + src: url('./fonts/DIN Next/DIN Next W01 Regular.otf') format('opentype'); font-weight: 400; font-style: normal; } @font-face { font-family: 'DIN NEXT Light'; - src: url('/fonts/DIN Next/DIN Next W10 Light.otf') format('opentype'); + src: url('./fonts/DIN Next/DIN Next W10 Light.otf') format('opentype'); font-weight: 400; font-style: normal; } @font-face { font-family: 'Lato'; - src: url('/fonts/Lato/Lato-Regular.ttf') format('truetype'); + src: url('./fonts/Lato/Lato-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; } From d06c6bb4cac9a616067e294c8ddefac572b66441 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 17:38:28 -0700 Subject: [PATCH 08/45] ci - announce QA build to GitHub pull request --- .circleci/config.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2c75aada9..ac05e747c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -100,6 +100,18 @@ jobs: - dist - store_artifacts: path: dist/mascara + - run: + name: build:announce + command: | + CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" + SHORT_SHA1=$(echo $CIRCLE_SHA1 | cut -c 1-7) + QA_BUILD_URL="https://$CIRCLE_BUILD_NUM-42009758-gh.circle-artifacts.com/0/home/circleci/project/dist/mascara/home.html" + COMMENT_BODY="[Try QA Build for $SHORT_SHA1]($QA_BUILD_URL)" + JSON_PAYLOAD="{\"body\":\"$COMMENT_BODY\"}" + POST_COMMENT_URI="https://api.github.com/repos/metamask/metamask-extension/issues/$CIRCLE_PR_NUMBER/comments" + echo "Announcement:\n$COMMENT_BODY" + echo "Posting to $POST_COMMENT_URI" + curl -d "$JSON_PAYLOAD" -H "Authorization: token $GITHUB_COMMENT_TOKEN" $POST_COMMENT_URI prep-scss: docker: From f35356a89a0f2b0eb670394667e9650ab92f03ed Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 18:07:02 -0700 Subject: [PATCH 09/45] mascara - html - fix script locations --- mascara/proxy/index.html | 4 ++-- mascara/ui/index.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mascara/proxy/index.html b/mascara/proxy/index.html index b83fc41af..0dff83f18 100644 --- a/mascara/proxy/index.html +++ b/mascara/proxy/index.html @@ -15,6 +15,6 @@ Hello! I am the MetaMask iframe. - + - \ No newline at end of file + diff --git a/mascara/ui/index.html b/mascara/ui/index.html index eac8e4898..dbc445891 100644 --- a/mascara/ui/index.html +++ b/mascara/ui/index.html @@ -7,6 +7,6 @@
- + - \ No newline at end of file + From cbfee0ac7e9ac705ba1a8b5bffa2c5ed4511b70d Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 18:07:38 -0700 Subject: [PATCH 10/45] mascara - server - server bundles before static assets + serve dist/mascara instead of chrome --- mascara/server/index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mascara/server/index.js b/mascara/server/index.js index 0f9b047a7..2ad8af242 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -15,22 +15,21 @@ function createMetamascaraServer () { const uiBundle = createBundle(path.join(__dirname, '/../src/ui.js')) const backgroundBuild = createBundle(path.join(__dirname, '/../src/background.js')) - // serve bundles + // setup server const server = express() server.use(compression()) - // ui window - serveBundle(server, '/scripts/ui.js', uiBundle) - server.use(express.static(path.join(__dirname, '/../ui/'), { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') })) - server.use(express.static(path.join(__dirname, '/../../dist/chrome'))) - // metamascara + // serve bundles serveBundle(server, '/metamascara.js', metamascaraBundle) - // proxy + serveBundle(server, '/scripts/ui.js', uiBundle) serveBundle(server, '/scripts/proxy.js', proxyBundle) - server.use('/', express.static(path.join(__dirname, '/../proxy'))) - // background serveBundle(server, '/scripts/background.js', backgroundBuild) + // serve assets + server.use(express.static(path.join(__dirname, '/../ui/'), { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') })) + server.use(express.static(path.join(__dirname, '/../../dist/mascara'))) + server.use(express.static(path.join(__dirname, '/../proxy'))) + return server } From 98f240064902f69b063b022eada56deacc9f1b35 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 19:56:44 -0700 Subject: [PATCH 11/45] build - refactor copy tasks --- gulpfile.js | 72 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 2c000f576..2b8627f14 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -27,19 +27,23 @@ var gulpStylelint = require('gulp-stylelint') var stylefmt = require('gulp-stylefmt') var uglify = require('gulp-uglify-es').default var babel = require('gulp-babel') +var debug = require('gulp-debug') var disableDebugTools = gutil.env.disableDebugTools -var debug = gutil.env.debug +var debugMode = gutil.env.debug -const commonPlatforms = [ - // browser extensions +const browserPlatforms = [ 'firefox', 'chrome', 'edge', 'opera', +] +const commonPlatforms = [ // browser webapp 'mascara', + // browser extensions + ...browserPlatforms ] // browser reload @@ -51,7 +55,7 @@ gulp.task('dev:reload', function() { }) -// copy static +// copy universal gulp.task('copy:locales', copyTask({ source: './app/_locales/', @@ -74,11 +78,21 @@ gulp.task('copy:reload', copyTask({ destinations: commonPlatforms.map(platform => `./dist/${platform}/scripts`), pattern: '/chromereload.js', })) -gulp.task('copy:root', copyTask({ + +// copy extension + +gulp.task('copy:manifest', copyTask({ source: './app/', - destinations: commonPlatforms.map(platform => `./dist/${platform}`), - pattern: '/*', + destinations: browserPlatforms.map(platform => `./dist/${platform}`), + pattern: '/*.json', })) +gulp.task('copy:html', copyTask({ + source: './app/', + destinations: browserPlatforms.map(platform => `./dist/${platform}`), + pattern: '/*.html', +})) + +// manifest tinkering gulp.task('manifest:chrome', function() { return gulp.src('./dist/chrome/manifest.json') @@ -113,7 +127,7 @@ gulp.task('manifest:production', function() { ],{base: './dist/'}) // Exclude chromereload script in production: - .pipe(gulpif(!debug,jsoneditor(function(json) { + .pipe(gulpif(!debugMode,jsoneditor(function(json) { json.background.scripts = json.background.scripts.filter((script) => { return !script.includes('chromereload') }) @@ -123,21 +137,27 @@ gulp.task('manifest:production', function() { .pipe(gulp.dest('./dist/', { overwrite: true })) }) -const staticFiles = [ - 'locales', - 'images', - 'fonts', - 'root' +const copyTaskNames = [ + 'copy:locales', + 'copy:images', + 'copy:fonts', + 'copy:manifest', + 'copy:html', + 'copy:contractImages', ] -var copyStrings = staticFiles.map(staticFile => `copy:${staticFile}`) -copyStrings.push('copy:contractImages') - -if (debug) { - copyStrings.push('copy:reload') +if (debugMode) { + copyTaskNames.push('copy:reload') } -gulp.task('copy', gulp.series(gulp.parallel(...copyStrings), 'manifest:production', 'manifest:chrome', 'manifest:opera')) +gulp.task('copy', + gulp.series( + gulp.parallel(...copyTaskNames), + 'manifest:production', + 'manifest:chrome', + 'manifest:opera' + ) +) gulp.task('copy:watch', function(){ gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy')) }) @@ -245,7 +265,7 @@ function createTasksForBuildJsMascara({ taskPrefix, bundleTaskOpts }) { // inpage must be built before all other scripts: const rootDir = './mascara/src/' const jsFiles = ['ui', 'proxy', 'background'] - const destinations = ['./dist/mascara/scripts'] + const destinations = ['./dist/mascara'] createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, buildPhase1: jsFiles }) } @@ -342,11 +362,11 @@ function copyTask(opts){ return performCopy function performCopy(){ - let stream = gulp.src(source + pattern, { base: source }) + let stream = gulp.src(source + pattern, { base: source }).pipe(debug({ title: source })) destinations.forEach(function(destination) { stream = stream.pipe(gulp.dest(destination)) }) - stream.pipe(gulpif(debug,livereload())) + stream.pipe(gulpif(debugMode,livereload())) return stream } @@ -365,7 +385,7 @@ function generateBundler(opts, performBundle) { entries: [opts.filepath], plugin: 'browserify-derequire', debug: true, - fullPaths: debug, + fullPaths: debugMode, }) let bundler = browserify(browserifyOpts) @@ -427,7 +447,7 @@ function bundleTask(opts) { // convert bundle stream to gulp vinyl stream .pipe(source(opts.filename)) // inject variables into bundle - .pipe(replace('\'GULP_METAMASK_DEBUG\'', debug)) + .pipe(replace('\'GULP_METAMASK_DEBUG\'', debugMode)) // buffer file contents (?) .pipe(buffer()) // sourcemaps @@ -438,7 +458,7 @@ function bundleTask(opts) { mangle: { reserved: [ 'MetamaskInpageProvider' ] }, }))) // writes .map file - .pipe(sourcemaps.write(debug ? './' : '../../sourcemaps')) + .pipe(sourcemaps.write(debugMode ? './' : '../../sourcemaps')) // write completed bundles opts.destinations.forEach((dest) => { @@ -447,7 +467,7 @@ function bundleTask(opts) { // finally, trigger live reload buildStream = buildStream - .pipe(gulpif(debug, livereload())) + .pipe(gulpif(debugMode, livereload())) return buildStream From 91e8ea205e1902dbefecaf2d764e7bb40847e5b5 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 19:58:06 -0700 Subject: [PATCH 12/45] build - remove deprecated deps task --- gulpfile.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 2b8627f14..a094356ac 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -162,18 +162,6 @@ gulp.task('copy:watch', function(){ gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy')) }) -// record deps - -gulp.task('deps', function (cb) { - exec('npm ls', (err, stdoutOutput, stderrOutput) => { - if (err) return cb(err) - const browsers = ['firefox','chrome','edge','opera'] - asyncEach(browsers, (target, done) => { - fs.writeFile(`./dist/${target}/deps.txt`, stdoutOutput, done) - }, cb) - }) -}) - // lint js gulp.task('lint', function () { From 909cbca7a63d2f328121c55d5eb032f4c0778605 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 19:59:24 -0700 Subject: [PATCH 13/45] build - remove copy debug --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index a094356ac..739da162e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -350,7 +350,7 @@ function copyTask(opts){ return performCopy function performCopy(){ - let stream = gulp.src(source + pattern, { base: source }).pipe(debug({ title: source })) + let stream = gulp.src(source + pattern, { base: source }) destinations.forEach(function(destination) { stream = stream.pipe(gulp.dest(destination)) }) From e5c6c93c29f1747fa20d7d9fbace97c634442185 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 20:13:47 -0700 Subject: [PATCH 14/45] build - fix mascara sourcemaps dest --- gulpfile.js | 91 ++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 739da162e..719a5c339 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,37 +1,37 @@ -var watchify = require('watchify') -var browserify = require('browserify') -var disc = require('disc') -var gulp = require('gulp') -var source = require('vinyl-source-stream') -var buffer = require('vinyl-buffer') -var gutil = require('gulp-util') -var watch = require('gulp-watch') -var sourcemaps = require('gulp-sourcemaps') -var jsoneditor = require('gulp-json-editor') -var zip = require('gulp-zip') -var assign = require('lodash.assign') -var livereload = require('gulp-livereload') -var del = require('del') -var eslint = require('gulp-eslint') -var fs = require('fs') -var path = require('path') -var manifest = require('./app/manifest.json') -var gulpif = require('gulp-if') -var replace = require('gulp-replace') -var mkdirp = require('mkdirp') -var asyncEach = require('async/each') -var exec = require('child_process').exec -var sass = require('gulp-sass') -var autoprefixer = require('gulp-autoprefixer') -var gulpStylelint = require('gulp-stylelint') -var stylefmt = require('gulp-stylefmt') -var uglify = require('gulp-uglify-es').default -var babel = require('gulp-babel') -var debug = require('gulp-debug') +const watchify = require('watchify') +const browserify = require('browserify') +const disc = require('disc') +const gulp = require('gulp') +const source = require('vinyl-source-stream') +const buffer = require('vinyl-buffer') +const gutil = require('gulp-util') +const watch = require('gulp-watch') +const sourcemaps = require('gulp-sourcemaps') +const jsoneditor = require('gulp-json-editor') +const zip = require('gulp-zip') +const assign = require('lodash.assign') +const livereload = require('gulp-livereload') +const del = require('del') +const eslint = require('gulp-eslint') +const fs = require('fs') +const path = require('path') +const manifest = require('./app/manifest.json') +const gulpif = require('gulp-if') +const replace = require('gulp-replace') +const mkdirp = require('mkdirp') +const asyncEach = require('async/each') +const exec = require('child_process').exec +const sass = require('gulp-sass') +const autoprefixer = require('gulp-autoprefixer') +const gulpStylelint = require('gulp-stylelint') +const stylefmt = require('gulp-stylefmt') +const uglify = require('gulp-uglify-es').default +const babel = require('gulp-babel') +const debug = require('gulp-debug') -var disableDebugTools = gutil.env.disableDebugTools -var debugMode = gutil.env.debug +const disableDebugTools = gutil.env.disableDebugTools +const debugMode = gutil.env.debug const browserPlatforms = [ 'firefox', @@ -240,13 +240,9 @@ function createTasksForBuildJsExtension({ jsFiles, taskPrefix, bundleTaskOpts }) const nonInpageFiles = jsFiles.filter(file => file !== 'inpage') const buildPhase1 = ['inpage'] const buildPhase2 = nonInpageFiles - const destinations = [ - './dist/firefox/scripts', - './dist/chrome/scripts', - './dist/edge/scripts', - './dist/opera/scripts', - ] - createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, buildPhase1, buildPhase2 }) + const destinations = browserPlatforms.map(platform => `./dist/${platform}/scripts`) + bundleTaskOpts.sourceMapDir = bundleTaskOpts.sourceMapDir || (debugMode ? './' : '../../sourcemaps') + createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, sourceMapDir, buildPhase1, buildPhase2 }) } function createTasksForBuildJsMascara({ taskPrefix, bundleTaskOpts }) { @@ -254,10 +250,11 @@ function createTasksForBuildJsMascara({ taskPrefix, bundleTaskOpts }) { const rootDir = './mascara/src/' const jsFiles = ['ui', 'proxy', 'background'] const destinations = ['./dist/mascara'] - createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, buildPhase1: jsFiles }) + bundleTaskOpts.sourceMapDir = bundleTaskOpts.sourceMapDir || (debugMode ? './' : '../sourcemaps') + createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, sourceMapDir, buildPhase1: jsFiles }) } -function createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, buildPhase1 = [], buildPhase2 = [] }) { +function createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, sourceMapDir, buildPhase1 = [], buildPhase2 = [] }) { // bundle task for each file jsFiles.forEach((jsFile) => { gulp.task(`${taskPrefix}:${jsFile}`, bundleTask(Object.assign({ @@ -298,7 +295,7 @@ gulp.task('zip:edge', zipTask('edge')) gulp.task('zip:opera', zipTask('opera')) gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox', 'zip:edge', 'zip:opera')) -// set env var for production +// set env for production gulp.task('apply-prod-environment', function(done) { process.env.NODE_ENV = 'production' done() @@ -342,10 +339,10 @@ gulp.task('dist', // task generators function copyTask(opts){ - var source = opts.source - var destination = opts.destination - var destinations = opts.destinations || [ destination ] - var pattern = opts.pattern || '/**/*' + const source = opts.source + const destination = opts.destination + const destinations = opts.destinations || [ destination ] + const pattern = opts.pattern || '/**/*' return performCopy @@ -446,7 +443,7 @@ function bundleTask(opts) { mangle: { reserved: [ 'MetamaskInpageProvider' ] }, }))) // writes .map file - .pipe(sourcemaps.write(debugMode ? './' : '../../sourcemaps')) + .pipe(sourcemaps.write(opts.sourceMapDir)) // write completed bundles opts.destinations.forEach((dest) => { From 18acdfe6b3fecf5e681d584898ef8399c62b0fa5 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 20:41:56 -0700 Subject: [PATCH 15/45] build - refactor js build process --- gulpfile.js | 109 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 719a5c339..740b1a296 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -183,21 +183,6 @@ gulp.task('lint:fix', function () { .pipe(eslint.failAfterError()) }); -/* -gulp.task('default', ['lint'], function () { - // This will only run if the lint task is successful... -}); -*/ - -// build js - -const jsFiles = [ - 'inpage', - 'contentscript', - 'background', - 'ui', -] - // scss compilation and autoprefixing tasks gulp.task('build:scss', function () { @@ -229,33 +214,53 @@ gulp.task('fmt-scss', function () { .pipe(gulp.dest('ui/app/css/itcss')); }); +// build js + +const buildJsFiles = [ + 'inpage', + 'contentscript', + 'background', + 'ui', +] + // bundle tasks -createTasksForBuildJsExtension({ jsFiles, taskPrefix: 'dev:js', bundleTaskOpts: { isBuild: false } }) -createTasksForBuildJsExtension({ jsFiles, taskPrefix: 'build:js:extension', bundleTaskOpts: { isBuild: true } }) +createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'dev:js', devMode: true }) +createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'build:js:extension' }) createTasksForBuildJsMascara({ taskPrefix: 'build:js:mascara' }) -function createTasksForBuildJsExtension({ jsFiles, taskPrefix, bundleTaskOpts }) { +function createTasksForBuildJsExtension({ buildJsFiles, taskPrefix, devMode, bundleTaskOpts = {} }) { // inpage must be built before all other scripts: const rootDir = './app/scripts' - const nonInpageFiles = jsFiles.filter(file => file !== 'inpage') + const nonInpageFiles = buildJsFiles.filter(file => file !== 'inpage') const buildPhase1 = ['inpage'] const buildPhase2 = nonInpageFiles const destinations = browserPlatforms.map(platform => `./dist/${platform}/scripts`) - bundleTaskOpts.sourceMapDir = bundleTaskOpts.sourceMapDir || (debugMode ? './' : '../../sourcemaps') - createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, sourceMapDir, buildPhase1, buildPhase2 }) + bundleTaskOpts = Object.assign({ + buildSourceMaps: true, + sourceMapDir: devMode ? './' : '../../sourcemaps', + minifyBuild: !devMode, + buildWithFullPaths: devMode, + }, bundleTaskOpts) + createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1, buildPhase2 }) } -function createTasksForBuildJsMascara({ taskPrefix, bundleTaskOpts }) { +function createTasksForBuildJsMascara({ taskPrefix, devMode, bundleTaskOpts = {} }) { // inpage must be built before all other scripts: const rootDir = './mascara/src/' - const jsFiles = ['ui', 'proxy', 'background'] + const buildPhase1 = ['ui', 'proxy', 'background'] const destinations = ['./dist/mascara'] - bundleTaskOpts.sourceMapDir = bundleTaskOpts.sourceMapDir || (debugMode ? './' : '../sourcemaps') - createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, sourceMapDir, buildPhase1: jsFiles }) + bundleTaskOpts = Object.assign({ + buildSourceMaps: true, + sourceMapDir: './', + minifyBuild: !devMode, + buildWithFullPaths: devMode, + }, bundleTaskOpts) + createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1 }) } -function createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, destinations, sourceMapDir, buildPhase1 = [], buildPhase2 = [] }) { +function createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1 = [], buildPhase2 = [] }) { // bundle task for each file + const jsFiles = [].concat(buildPhase1, buildPhase2) jsFiles.forEach((jsFile) => { gulp.task(`${taskPrefix}:${jsFile}`, bundleTask(Object.assign({ watch: false, @@ -275,15 +280,14 @@ function createTasksForBuildJs({ rootDir, jsFiles, taskPrefix, bundleTaskOpts, d // disc bundle analyzer tasks -jsFiles.forEach((jsFile) => { - gulp.task(`disc:${jsFile}`, discTask({ label: jsFile, filename: `${jsFile}.js` })) +buildJsFiles.forEach((jsFile) => { + gulp.task(`disc:${jsFile}`, discTask({ label: jsFile, filename: `${jsFile}.js` })) }) -gulp.task('disc', gulp.parallel(jsFiles.map(jsFile => `disc:${jsFile}`))) +gulp.task('disc', gulp.parallel(buildJsFiles.map(jsFile => `disc:${jsFile}`))) // clean dist - gulp.task('clean', function clean() { return del(['./dist/*']) }) @@ -369,8 +373,8 @@ function generateBundler(opts, performBundle) { const browserifyOpts = assign({}, watchify.args, { entries: [opts.filepath], plugin: 'browserify-derequire', - debug: true, - fullPaths: debugMode, + debug: opts.buildSourceMaps, + fullPaths: opts.buildWithFullPaths, }) let bundler = browserify(browserifyOpts) @@ -385,6 +389,10 @@ function generateBundler(opts, performBundle) { } function discTask(opts) { + opts = Object.assign({ + buildWithFullPaths: true, + }, opts) + const bundler = generateBundler(opts, performBundle) // output build logs to terminal bundler.on('log', gutil.log) @@ -393,9 +401,9 @@ function discTask(opts) { function performBundle(){ // start "disc" build - let discDir = path.join(__dirname, 'disc') + const discDir = path.join(__dirname, 'disc') mkdirp.sync(discDir) - let discPath = path.join(discDir, `${opts.label}.html`) + const discPath = path.join(discDir, `${opts.label}.html`) return ( bundler.bundle() @@ -435,15 +443,30 @@ function bundleTask(opts) { .pipe(replace('\'GULP_METAMASK_DEBUG\'', debugMode)) // buffer file contents (?) .pipe(buffer()) - // sourcemaps - // loads map from browserify file - .pipe(sourcemaps.init({ loadMaps: true })) - // Minification - .pipe(gulpif(opts.isBuild, uglify({ - mangle: { reserved: [ 'MetamaskInpageProvider' ] }, - }))) - // writes .map file - .pipe(sourcemaps.write(opts.sourceMapDir)) + + + // Initialize Source Maps + if (opts.buildSourceMaps) { + buildStream = buildStream + // loads map from browserify file + .pipe(sourcemaps.init({ loadMaps: true })) + } + + // Minification + if (opts.minifyBuild) { + buildStream = buildStream + .pipe(uglify({ + mangle: { + reserved: [ 'MetamaskInpageProvider' ] + }, + })) + } + + // Finalize Source Maps (writes .map file) + if (opts.buildSourceMaps) { + buildStream = buildStream + .pipe(sourcemaps.write(opts.sourceMapDir)) + } // write completed bundles opts.destinations.forEach((dest) => { From b88119c23851144448771e8a6de97e48fb96b2b0 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 20:54:59 -0700 Subject: [PATCH 16/45] build - mascara - copy proxy html --- gulpfile.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 740b1a296..68618dfb4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -78,6 +78,11 @@ gulp.task('copy:reload', copyTask({ destinations: commonPlatforms.map(platform => `./dist/${platform}/scripts`), pattern: '/chromereload.js', })) +gulp.task('copy:html', copyTask({ + source: './app/', + destinations: commonPlatforms.map(platform => `./dist/${platform}`), + pattern: '/*.html', +})) // copy extension @@ -86,10 +91,13 @@ gulp.task('copy:manifest', copyTask({ destinations: browserPlatforms.map(platform => `./dist/${platform}`), pattern: '/*.json', })) -gulp.task('copy:html', copyTask({ - source: './app/', - destinations: browserPlatforms.map(platform => `./dist/${platform}`), - pattern: '/*.html', + +// copy mascara + +gulp.task('copy:html:mascara', copyTask({ + source: './mascara/', + destinations: [`./dist/mascara/`], + pattern: 'proxy/index.html', })) // manifest tinkering @@ -143,6 +151,7 @@ const copyTaskNames = [ 'copy:fonts', 'copy:manifest', 'copy:html', + 'copy:html:mascara', 'copy:contractImages', ] From 253abd60fca5a6efb1a2e0ecbe305989a852ec32 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 21:29:57 -0700 Subject: [PATCH 17/45] build - extension - move js files to toplevel --- app/home.html | 2 +- app/manifest.json | 10 +++++----- app/notification.html | 2 +- app/popup.html | 2 +- app/scripts/contentscript.js | 6 +++--- gulpfile.js | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/home.html b/app/home.html index bb8e936a3..4fad0f993 100644 --- a/app/home.html +++ b/app/home.html @@ -7,6 +7,6 @@
- + diff --git a/app/manifest.json b/app/manifest.json index a20f9b976..1982b4820 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -27,8 +27,8 @@ "default_locale": "en", "background": { "scripts": [ - "scripts/chromereload.js", - "scripts/background.js" + "chromereload.js", + "background.js" ], "persistent": true }, @@ -48,7 +48,7 @@ "https://*/*" ], "js": [ - "scripts/contentscript.js" + "contentscript.js" ], "run_at": "document_start", "all_frames": true @@ -62,11 +62,11 @@ "https://*.infura.io/" ], "web_accessible_resources": [ - "scripts/inpage.js" + "inpage.js" ], "externally_connectable": { "matches": [ "https://metamask.io/*" ] } -} \ No newline at end of file +} diff --git a/app/notification.html b/app/notification.html index 2255ca2c1..457ba7137 100644 --- a/app/notification.html +++ b/app/notification.html @@ -11,6 +11,6 @@
- + diff --git a/app/popup.html b/app/popup.html index 109487d3e..3acfd8c55 100644 --- a/app/popup.html +++ b/app/popup.html @@ -7,6 +7,6 @@
- + diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index 7abbc60e7..2098fae27 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -7,8 +7,8 @@ const ObjectMultiplex = require('obj-multiplex') const extension = require('extensionizer') const PortStream = require('./lib/port-stream.js') -const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'scripts', 'inpage.js')).toString() -const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('scripts/inpage.js') + '\n' +const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'inpage.js')).toString() +const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('inpage.js') + '\n' const inpageBundle = inpageContent + inpageSuffix // Eventually this streaming injection could be replaced with: @@ -96,7 +96,7 @@ function logStreamDisconnectWarning (remoteLabel, err) { } function shouldInjectWeb3 () { - return doctypeCheck() && suffixCheck() + return doctypeCheck() && suffixCheck() && documentElementCheck() && !blacklistedDomainCheck() } diff --git a/gulpfile.js b/gulpfile.js index 68618dfb4..cd523a107 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -75,7 +75,7 @@ gulp.task('copy:fonts', copyTask({ })) gulp.task('copy:reload', copyTask({ source: './app/scripts/', - destinations: commonPlatforms.map(platform => `./dist/${platform}/scripts`), + destinations: commonPlatforms.map(platform => `./dist/${platform}`), pattern: '/chromereload.js', })) gulp.task('copy:html', copyTask({ @@ -243,10 +243,10 @@ function createTasksForBuildJsExtension({ buildJsFiles, taskPrefix, devMode, bun const nonInpageFiles = buildJsFiles.filter(file => file !== 'inpage') const buildPhase1 = ['inpage'] const buildPhase2 = nonInpageFiles - const destinations = browserPlatforms.map(platform => `./dist/${platform}/scripts`) + const destinations = browserPlatforms.map(platform => `./dist/${platform}`) bundleTaskOpts = Object.assign({ buildSourceMaps: true, - sourceMapDir: devMode ? './' : '../../sourcemaps', + sourceMapDir: devMode ? './' : '../sourcemaps', minifyBuild: !devMode, buildWithFullPaths: devMode, }, bundleTaskOpts) From c9a47923042ca01c1968cf72e6d43d19890f4cd5 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 21:33:04 -0700 Subject: [PATCH 18/45] mascara - use sw-controller and other cleanups --- mascara/server/index.js | 3 ++- mascara/src/background.js | 16 +++++++----- mascara/src/proxy.js | 12 ++++----- mascara/src/ui.js | 54 +++++++++++++++++++++------------------ package.json | 5 ++-- 5 files changed, 50 insertions(+), 40 deletions(-) diff --git a/mascara/server/index.js b/mascara/server/index.js index 2ad8af242..2bc2441d0 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -23,7 +23,8 @@ function createMetamascaraServer () { serveBundle(server, '/metamascara.js', metamascaraBundle) serveBundle(server, '/scripts/ui.js', uiBundle) serveBundle(server, '/scripts/proxy.js', proxyBundle) - serveBundle(server, '/scripts/background.js', backgroundBuild) + // the serviceworker must be served from the root of the app + serveBundle(server, '/background.js', backgroundBuild) // serve assets server.use(express.static(path.join(__dirname, '/../ui/'), { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') })) diff --git a/mascara/src/background.js b/mascara/src/background.js index 8aa1d8fe2..40a684f3d 100644 --- a/mascara/src/background.js +++ b/mascara/src/background.js @@ -30,15 +30,19 @@ global.addEventListener('activate', function (event) { log.debug('inside:open') - -// // state persistence +// state persistence const dbController = new DbController({ key: STORAGE_KEY, }) -loadStateFromPersistence() -.then((initState) => setupController(initState)) -.then(() => log.debug('MetaMask initialization complete.')) -.catch((err) => console.error('WHILE SETTING UP:', err)) + +start().catch(log.error) + +async function start() { + log.debug('MetaMask initializing...') + const initState = await loadStateFromPersistence() + await setupController(initState) + log.debug('MetaMask initialization complete.') +} // // State and Persistence diff --git a/mascara/src/proxy.js b/mascara/src/proxy.js index 3958f7d50..80b4dc516 100644 --- a/mascara/src/proxy.js +++ b/mascara/src/proxy.js @@ -1,13 +1,13 @@ const createParentStream = require('iframe-stream').ParentStream -const SWcontroller = require('client-sw-ready-event/lib/sw-client.js') +const SwController = require('sw-controller') const SwStream = require('sw-stream/lib/sw-stream.js') -const intervalDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000 -const background = new SWcontroller({ +const keepAliveDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000 +const background = new SwController({ fileName: './scripts/background.js', - letBeIdle: false, - wakeUpInterval: 30000, - intervalDelay, + keepAlive: true, + keepAliveInterval: 30000, + keepAliveDelay, }) const pageStream = createParentStream() diff --git a/mascara/src/ui.js b/mascara/src/ui.js index 21e5f32a9..f35a11fc4 100644 --- a/mascara/src/ui.js +++ b/mascara/src/ui.js @@ -1,6 +1,6 @@ const injectCss = require('inject-css') -const SWcontroller = require('client-sw-ready-event/lib/sw-client.js') -const SwStream = require('sw-stream/lib/sw-stream.js') +const SwController = require('sw-controller') +const SwStream = require('sw-stream') const MetaMaskUiCss = require('../../ui/css') const MetamascaraPlatform = require('../../app/scripts/platforms/window') const startPopup = require('../../app/scripts/popup-core') @@ -8,27 +8,44 @@ const startPopup = require('../../app/scripts/popup-core') // create platform global global.platform = new MetamascaraPlatform() - var css = MetaMaskUiCss() injectCss(css) const container = document.getElementById('app-content') -var name = 'popup' +const name = 'popup' window.METAMASK_UI_TYPE = name window.METAMASK_PLATFORM_TYPE = 'mascara' -const intervalDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000 +const keepAliveDelay = Math.floor(Math.random() * (30000 - 1000)) + 1000 -const background = new SWcontroller({ - fileName: './scripts/background.js', - letBeIdle: false, - intervalDelay, - wakeUpInterval: 20000, +const swController = new SwController({ + fileName: './background.js', + keepAlive: true, + keepAliveDelay, + keepAliveInterval: 20000, }) + +swController.once('updatefound', windowReload) +swController.once('ready', async () => { + try { + swController.removeListener('updatefound', windowReload) + console.log('swController ready') + await timeout(1000) + console.log('connecting to app') + await connectApp() + console.log('app connected') + } catch (err) { + console.error(err) + } +}) + +console.log('starting service worker') +swController.startWorker() + // Setup listener for when the service worker is read -const connectApp = function (readSw) { +function connectApp() { const connectionStream = SwStream({ - serviceWorker: background.controller, + serviceWorker: swController.getWorker(), context: name, }) return new Promise((resolve, reject) => { @@ -43,19 +60,6 @@ const connectApp = function (readSw) { }) }) } -background.on('ready', async (sw) => { - try { - background.removeListener('updatefound', connectApp) - await timeout(1000) - await connectApp(sw) - console.log('hello from cb ready event!') - } catch (e) { - console.error(e) - } -}) -background.on('updatefound', windowReload) - -background.startWorker() function windowReload () { if (window.METAMASK_SKIP_RELOAD) return diff --git a/package.json b/package.json index 6cd8f7f4e..228f8b801 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "browserify-derequire": "^0.9.4", "browserify-unibabel": "^3.0.0", "classnames": "^2.2.5", - "client-sw-ready-event": "^3.3.0", "clone": "^2.1.1", "copy-to-clipboard": "^3.0.8", "debounce": "^1.0.0", @@ -118,6 +117,7 @@ "fuse.js": "^3.2.0", "gulp": "github:gulpjs/gulp#4.0", "gulp-autoprefixer": "^5.0.0", + "gulp-debug": "^3.2.0", "gulp-eslint": "^4.0.0", "gulp-sass": "^3.1.0", "hat": "0.0.3", @@ -180,7 +180,8 @@ "semaphore": "^1.0.5", "semver": "^5.4.1", "shallow-copy": "0.0.1", - "sw-stream": "^2.0.0", + "sw-controller": "^1.0.3", + "sw-stream": "^2.0.2", "textarea-caret": "^3.0.1", "through2": "^2.0.3", "valid-url": "^1.0.9", From 42d0b5f0ed7f3781d5551bc0b6af1e5f5c912ca5 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 21:35:59 -0700 Subject: [PATCH 19/45] deps - update pakage-lock --- package-lock.json | 107 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 97 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index f0f76919a..af80459af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3125,11 +3125,6 @@ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" }, - "client-sw-ready-event": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/client-sw-ready-event/-/client-sw-ready-event-3.4.0.tgz", - "integrity": "sha1-/0hkYXaQVed0hXDxrvECuGdbZtA=" - }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", @@ -8192,6 +8187,11 @@ "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, + "get-own-enumerable-property-symbols": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-2.0.1.tgz", + "integrity": "sha512-TtY/sbOemiMKPRUDDanGCSgBYe7Mf0vbRsWnBZ+9yghpZ1MvcpSpuZFjHdEeY/LZjZy0vdLjS77L6HosisFiug==" + }, "get-stdin": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-3.0.2.tgz", @@ -8628,6 +8628,52 @@ } } }, + "gulp-debug": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/gulp-debug/-/gulp-debug-3.2.0.tgz", + "integrity": "sha512-2LZzP+ydczqz1rhqq/NYxvVvYTmOa0IgBl2B1sQTdkQgku9ayOUM/KHuGPjF4QA5aO1VcG+Sskw7iCcRUqHKkA==", + "requires": { + "chalk": "2.3.2", + "fancy-log": "1.3.2", + "plur": "2.1.2", + "stringify-object": "3.2.2", + "through2": "2.0.3", + "tildify": "1.2.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz", + "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", + "requires": { + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.3.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "supports-color": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", + "requires": { + "has-flag": "3.0.0" + } + } + } + }, "gulp-eslint": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-4.0.0.tgz", @@ -10374,8 +10420,7 @@ "irregular-plurals": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-1.4.0.tgz", - "integrity": "sha1-LKmwM2UREYVUEvFr5dd8YqRYp2Y=", - "dev": true + "integrity": "sha1-LKmwM2UREYVUEvFr5dd8YqRYp2Y=" }, "is-absolute": { "version": "1.0.0", @@ -10603,6 +10648,11 @@ "integrity": "sha1-8mWrian0RQNO9q/xWo8AsA9VF5k=", "dev": true }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" + }, "is-odd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-1.0.0.tgz", @@ -10695,8 +10745,7 @@ "is-regexp": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", - "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", - "dev": true + "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=" }, "is-relative": { "version": "1.0.0", @@ -16675,7 +16724,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/plur/-/plur-2.1.2.tgz", "integrity": "sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo=", - "dev": true, "requires": { "irregular-plurals": "1.4.0" } @@ -19727,6 +19775,16 @@ "safe-buffer": "5.1.1" } }, + "stringify-object": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.2.2.tgz", + "integrity": "sha512-O696NF21oLiDy8PhpWu8AEqoZHw++QW6mUv0UvKZe8gWSdSvMXkiLufK7OmnP27Dro4GU5kb9U7JIO0mBuCRQg==", + "requires": { + "get-own-enumerable-property-symbols": "2.0.1", + "is-obj": "1.0.1", + "is-regexp": "1.0.0" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", @@ -20333,6 +20391,27 @@ "integrity": "sha1-WPcc7jvVGbWdSyqEO2x95krAR2Q=", "dev": true }, + "sw-controller": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sw-controller/-/sw-controller-1.0.3.tgz", + "integrity": "sha512-q+rS4v7kj1MPDxFRyl8GAICw/BbQzewd5HhVDNIPLnyvKtcpxi26fVXReUeUMRl4CRL/fX56PvKKqxtKhAaMpg==", + "requires": { + "babel-preset-es2015": "6.24.1", + "babel-runtime": "6.26.0", + "babelify": "7.3.0" + }, + "dependencies": { + "babelify": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/babelify/-/babelify-7.3.0.tgz", + "integrity": "sha1-qlau3nBn/XvVSWZu4W3ChQh+iOU=", + "requires": { + "babel-core": "6.26.0", + "object-assign": "4.1.1" + } + } + } + }, "sw-stream": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/sw-stream/-/sw-stream-2.0.2.tgz", @@ -20797,6 +20876,14 @@ "dev": true, "optional": true }, + "tildify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", + "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", + "requires": { + "os-homedir": "1.0.2" + } + }, "time-stamp": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", From fbdf497487e7d5b653d6eb36e92d917e935a6935 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 21:40:20 -0700 Subject: [PATCH 20/45] mascara - fix proxy html script link --- mascara/proxy/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mascara/proxy/index.html b/mascara/proxy/index.html index 0dff83f18..4e167db72 100644 --- a/mascara/proxy/index.html +++ b/mascara/proxy/index.html @@ -15,6 +15,6 @@ Hello! I am the MetaMask iframe. - + From 8760dc6bdac3e20a426853bc3f26b4b74a7bde95 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 21:53:08 -0700 Subject: [PATCH 21/45] ui - use relative url for i18n-helper fetching locales --- ui/i18n-helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js index 3ce24ddfb..db2fd2dc4 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -27,7 +27,7 @@ const getMessage = (locale, key, substitutions) => { function fetchLocale (localeName) { return new Promise((resolve, reject) => { - return fetch(`/_locales/${localeName}/messages.json`) + return fetch(`./_locales/${localeName}/messages.json`) .then(response => response.json()) .then( locale => resolve(locale), From cf82e766d4c08ee874e0c077d73186b5b134669f Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 22:21:49 -0700 Subject: [PATCH 22/45] ui - fix relative url for deposit-ether-modal --- ui/app/components/modals/deposit-ether-modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/components/modals/deposit-ether-modal.js b/ui/app/components/modals/deposit-ether-modal.js index e38899d04..5af484af1 100644 --- a/ui/app/components/modals/deposit-ether-modal.js +++ b/ui/app/components/modals/deposit-ether-modal.js @@ -144,7 +144,7 @@ DepositEtherModal.prototype.render = function () { this.renderRow({ logo: h('img.deposit-ether-modal__logo', { - src: '../../../images/deposit-eth.svg', + src: './images/deposit-eth.svg', }), title: DIRECT_DEPOSIT_ROW_TITLE, text: DIRECT_DEPOSIT_ROW_TEXT, From 10609493c5a23a930dd8f7bda0435e576fd24815 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 22:30:35 -0700 Subject: [PATCH 23/45] ui - use relative location for images --- old-ui/app/app.js | 2 +- ui/app/app.js | 2 +- ui/app/components/modals/deposit-ether-modal.js | 4 ++-- ui/app/components/sender-to-recipient.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/old-ui/app/app.js b/old-ui/app/app.js index c79ac633a..e9ab185f3 100644 --- a/old-ui/app/app.js +++ b/old-ui/app/app.js @@ -171,7 +171,7 @@ App.prototype.renderAppBar = function () { h('img', { height: 24, width: 24, - src: '/images/icon-128.png', + src: './images/icon-128.png', }), h(NetworkIndicator, { diff --git a/ui/app/app.js b/ui/app/app.js index d23238bab..d658cf809 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -288,7 +288,7 @@ App.prototype.renderAppBar = function () { h('img.metafox-icon', { height: 42, width: 42, - src: '/images/metamask-fox.svg', + src: './images/metamask-fox.svg', }), // metamask name diff --git a/ui/app/components/modals/deposit-ether-modal.js b/ui/app/components/modals/deposit-ether-modal.js index 5af484af1..30be1d450 100644 --- a/ui/app/components/modals/deposit-ether-modal.js +++ b/ui/app/components/modals/deposit-ether-modal.js @@ -165,7 +165,7 @@ DepositEtherModal.prototype.render = function () { this.renderRow({ logo: h('div.deposit-ether-modal__logo', { style: { - backgroundImage: 'url(\'../../../images/coinbase logo.png\')', + backgroundImage: 'url(\'./images/coinbase logo.png\')', height: '40px', }, }), @@ -179,7 +179,7 @@ DepositEtherModal.prototype.render = function () { this.renderRow({ logo: h('div.deposit-ether-modal__logo', { style: { - backgroundImage: 'url(\'../../../images/shapeshift logo.png\')', + backgroundImage: 'url(\'./images/shapeshift logo.png\')', }, }), title: SHAPESHIFT_ROW_TITLE, diff --git a/ui/app/components/sender-to-recipient.js b/ui/app/components/sender-to-recipient.js index 4c3881668..299616612 100644 --- a/ui/app/components/sender-to-recipient.js +++ b/ui/app/components/sender-to-recipient.js @@ -46,7 +46,7 @@ class SenderToRecipient extends Component { h('img', { height: 15, width: 15, - src: '/images/arrow-right.svg', + src: './images/arrow-right.svg', }), ]), ]), From f9b680b09f3de33865371bb8430f1d62b5b19a1c Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 22:39:45 -0700 Subject: [PATCH 24/45] ui - identicon - use relative link for ether logo --- ui/app/components/identicon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js index 6b2a1b428..96bb89f5f 100644 --- a/ui/app/components/identicon.js +++ b/ui/app/components/identicon.js @@ -47,7 +47,7 @@ IdenticonComponent.prototype.render = function () { ) : ( h('img.balance-icon', { - src: '../images/eth_logo.svg', + src: './images/eth_logo.svg', style: { height: diameter, width: diameter, From 86c7c6746d64e8c9a32010520d49fc34c5e2edba Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 23:11:07 -0700 Subject: [PATCH 25/45] build - refactor copy and copy:watch (renamed to copy:dev) --- gulpfile.js | 106 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index cd523a107..d6892cc7e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -54,51 +54,65 @@ gulp.task('dev:reload', function() { }) }) - // copy universal -gulp.task('copy:locales', copyTask({ +const copyTaskNames = [] +const copyDevTaskNames = [] + +createCopyTasks('locales', { source: './app/_locales/', destinations: commonPlatforms.map(platform => `./dist/${platform}/_locales`), -})) -gulp.task('copy:images', copyTask({ +}) +createCopyTasks('images', { source: './app/images/', destinations: commonPlatforms.map(platform => `./dist/${platform}/images`), -})) -gulp.task('copy:contractImages', copyTask({ - source: './node_modules/eth-contract-metadata/images/', +}) +createCopyTasks('contractImages', { + source: `${require.resolve('eth-contract-metadata')}/images/`, destinations: commonPlatforms.map(platform => `./dist/${platform}/images/contract`), -})) -gulp.task('copy:fonts', copyTask({ +}) +createCopyTasks('fonts', { source: './app/fonts/', destinations: commonPlatforms.map(platform => `./dist/${platform}/fonts`), -})) -gulp.task('copy:reload', copyTask({ +}) +createCopyTasks('reload', { + devOnly: true, source: './app/scripts/', - destinations: commonPlatforms.map(platform => `./dist/${platform}`), pattern: '/chromereload.js', -})) -gulp.task('copy:html', copyTask({ - source: './app/', destinations: commonPlatforms.map(platform => `./dist/${platform}`), +}) +createCopyTasks('html', { + source: './app/', pattern: '/*.html', -})) + destinations: commonPlatforms.map(platform => `./dist/${platform}`), +}) // copy extension -gulp.task('copy:manifest', copyTask({ +createCopyTasks('manifest', { source: './app/', - destinations: browserPlatforms.map(platform => `./dist/${platform}`), pattern: '/*.json', -})) + destinations: browserPlatforms.map(platform => `./dist/${platform}`), +}) // copy mascara -gulp.task('copy:html:mascara', copyTask({ +createCopyTasks('html:mascara', { source: './mascara/', - destinations: [`./dist/mascara/`], pattern: 'proxy/index.html', -})) + destinations: [`./dist/mascara/`], +}) + +function createCopyTasks(label, opts) { + if (!opts.devOnly) { + const copyTaskName = `copy:${label}` + copyTask(copyTaskName, opts) + copyTaskNames.push(copyTaskName) + } + const copyDevTaskName = `copy:dev:${label}` + copyTask(copyDevTaskName, Object.assign({ devMode: true }, opts)) + copyDevTaskNames.push(copyDevTaskName) +} // manifest tinkering @@ -145,20 +159,6 @@ gulp.task('manifest:production', function() { .pipe(gulp.dest('./dist/', { overwrite: true })) }) -const copyTaskNames = [ - 'copy:locales', - 'copy:images', - 'copy:fonts', - 'copy:manifest', - 'copy:html', - 'copy:html:mascara', - 'copy:contractImages', -] - -if (debugMode) { - copyTaskNames.push('copy:reload') -} - gulp.task('copy', gulp.series( gulp.parallel(...copyTaskNames), @@ -167,9 +167,14 @@ gulp.task('copy', 'manifest:opera' ) ) -gulp.task('copy:watch', function(){ - gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy')) -}) + +gulp.task('copy:dev', + gulp.series( + gulp.parallel(...copyDevTaskNames), + 'manifest:chrome', + 'manifest:opera' + ) +) // lint js @@ -323,7 +328,7 @@ gulp.task('dev', 'copy', gulp.parallel( 'watch:scss', - 'copy:watch', + 'copy:dev', 'dev:reload' ) ) @@ -351,20 +356,33 @@ gulp.task('dist', // task generators -function copyTask(opts){ +function copyTask(taskName, opts){ const source = opts.source const destination = opts.destination const destinations = opts.destinations || [ destination ] const pattern = opts.pattern || '/**/*' + const devMode = opts.devMode - return performCopy + return gulp.task(taskName, performCopy) function performCopy(){ - let stream = gulp.src(source + pattern, { base: source }) + // stream from source + let stream + if (devMode) { + stream = watch(source + pattern, { base: source }) + } else { + stream = gulp.src(source + pattern, { base: source }) + } + + // copy to destinations destinations.forEach(function(destination) { stream = stream.pipe(gulp.dest(destination)) }) - stream.pipe(gulpif(debugMode,livereload())) + + // trigger reload + if (devMode) { + stream.pipe(livereload()) + } return stream } From ac4cb3444df5753da6e10f607466e232afa538a2 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 23:11:41 -0700 Subject: [PATCH 26/45] ui - add guard against unset locale --- ui/app/settings.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/app/settings.js b/ui/app/settings.js index 8764dcafe..171264ed4 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -108,11 +108,12 @@ class Settings extends Component { renderCurrentLocale () { const { updateCurrentLocale, currentLocale } = this.props const currentLocaleMeta = locales.find(locale => locale.code === currentLocale) + const currentLocaleName = currentLocaleMeta ? currentLocaleMeta.name || '' return h('div.settings__content-row', [ h('div.settings__content-item', [ h('span', 'Current Language'), - h('span.settings__content-description', `${currentLocaleMeta.name}`), + h('span.settings__content-description', `${currentLocaleName}`), ]), h('div.settings__content-item', [ h('div.settings__content-item-col', [ From d2874cf89aa389b3b16f432781be731f88737f21 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 23:12:41 -0700 Subject: [PATCH 27/45] deps - update package-lock --- package-lock.json | 312 +++++++++++++++++++++++++++++++++------------- package.json | 2 +- 2 files changed, 226 insertions(+), 88 deletions(-) diff --git a/package-lock.json b/package-lock.json index af80459af..504f2f1d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9250,7 +9250,7 @@ "dev": true, "requires": { "anymatch": "1.3.2", - "chokidar": "2.0.1", + "chokidar": "2.0.3", "glob-parent": "3.1.0", "gulp-util": "3.0.8", "object-assign": "4.1.1", @@ -9274,9 +9274,9 @@ "dev": true }, "braces": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.0.tgz", - "integrity": "sha512-P4O8UQRdGiMLWSizsApmXVQDBS6KCt7dSexgLKBmH5Hr1CZq7vsnscFh8oR1sP1ab1Zj0uCHCEzZeV6SfUf3rA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.1.tgz", + "integrity": "sha512-SO5lYHA3vO6gz66erVvedSCkp7AKWdv6VcQ2N4ysXfPxdAlxAMMAdwegGGcv1Bqwm7naF1hNdk5d6AAIEHV2nQ==", "dev": true, "requires": { "arr-flatten": "1.1.0", @@ -9285,22 +9285,43 @@ "extend-shallow": "2.0.1", "fill-range": "4.0.0", "isobject": "3.0.1", + "kind-of": "6.0.2", "repeat-element": "1.1.2", "snapdragon": "0.8.1", "snapdragon-node": "2.1.1", "split-string": "3.1.0", - "to-regex": "3.0.1" + "to-regex": "3.0.2" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } } }, "chokidar": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.1.tgz", - "integrity": "sha512-rv5iP8ENhpqvDWr677rAXcB+SMoPQ1urd4ch79+PhM4lQwbATdJUQK69t0lJIKNB+VXpqxt5V1gvqs59XEPKnw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.3.tgz", + "integrity": "sha512-zW8iXYZtXMx4kux/nuZVXjkLP+CyIK5Al5FHnj1OgTKGZfp4Oy6/ymtMSKFv3GD8DviEmUPmJg9eFdJ/JzudMg==", "dev": true, "requires": { "anymatch": "2.0.0", "async-each": "1.0.1", - "braces": "2.3.0", + "braces": "2.3.1", "fsevents": "1.1.3", "glob-parent": "3.1.0", "inherits": "2.0.3", @@ -9309,7 +9330,7 @@ "normalize-path": "2.1.1", "path-is-absolute": "1.0.1", "readdirp": "2.1.0", - "upath": "1.0.0" + "upath": "1.0.4" }, "dependencies": { "anymatch": { @@ -9318,12 +9339,22 @@ "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", "dev": true, "requires": { - "micromatch": "3.1.5", + "micromatch": "3.1.10", "normalize-path": "2.1.1" } } } }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "1.0.2", + "isobject": "3.0.1" + } + }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -9336,7 +9367,7 @@ "posix-character-classes": "0.1.1", "regex-not": "1.0.0", "snapdragon": "0.8.1", - "to-regex": "3.0.1" + "to-regex": "3.0.2" }, "dependencies": { "define-property": { @@ -9347,6 +9378,53 @@ "requires": { "is-descriptor": "0.1.6" } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" + } + }, + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "1.0.0", + "is-extendable": "1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } } } }, @@ -9363,7 +9441,27 @@ "fragment-cache": "0.2.1", "regex-not": "1.0.0", "snapdragon": "0.8.1", - "to-regex": "3.0.1" + "to-regex": "3.0.2" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "1.0.2" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } } }, "fill-range": { @@ -9376,6 +9474,17 @@ "is-number": "3.0.0", "repeat-string": "1.6.1", "to-regex-range": "2.1.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "0.1.1" + } + } } }, "glob-parent": { @@ -9439,25 +9548,6 @@ } } }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -9506,24 +9596,48 @@ "dev": true }, "micromatch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.5.tgz", - "integrity": "sha512-ykttrLPQrz1PUJcXjwsTUjGoPJ64StIGNE2lGVD1c9CuguJ+L7/navsE8IcDNndOoCMvYV0qc/exfVbMHkUhvA==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { "arr-diff": "4.0.0", "array-unique": "0.3.2", - "braces": "2.3.0", - "define-property": "1.0.0", - "extend-shallow": "2.0.1", + "braces": "2.3.1", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", "extglob": "2.0.4", "fragment-cache": "0.2.1", "kind-of": "6.0.2", - "nanomatch": "1.2.7", + "nanomatch": "1.2.9", "object.pick": "1.3.0", "regex-not": "1.0.0", "snapdragon": "0.8.1", - "to-regex": "3.0.1" + "to-regex": "3.0.2" + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "2.0.2", + "extend-shallow": "3.0.2", + "regex-not": "1.0.2", + "safe-regex": "1.1.0" + }, + "dependencies": { + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "3.0.2", + "safe-regex": "1.1.0" + } + } } } } @@ -10654,22 +10768,19 @@ "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" }, "is-odd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-1.0.0.tgz", - "integrity": "sha1-O4qTLrAos3dcObsJ6RdnrM22kIg=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", + "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", "dev": true, "requires": { - "is-number": "3.0.0" + "is-number": "4.0.0" }, "dependencies": { "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - } + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true } } }, @@ -13638,18 +13749,19 @@ "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=" }, "nanomatch": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.7.tgz", - "integrity": "sha512-/5ldsnyurvEw7wNpxLFgjVvBLMta43niEYOy0CJ4ntcYSbx6bugRUTQeFb4BR/WanEL1o3aQgHuVLHQaB6tOqg==", + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", + "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", "dev": true, "requires": { "arr-diff": "4.0.0", "array-unique": "0.3.2", - "define-property": "1.0.0", - "extend-shallow": "2.0.1", + "define-property": "2.0.2", + "extend-shallow": "3.0.2", "fragment-cache": "0.2.1", - "is-odd": "1.0.0", - "kind-of": "5.1.0", + "is-odd": "2.0.0", + "is-windows": "1.0.2", + "kind-of": "6.0.2", "object.pick": "1.3.0", "regex-not": "1.0.0", "snapdragon": "0.8.1", @@ -13668,10 +13780,45 @@ "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true }, + "define-property": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "1.0.2", + "isobject": "3.0.1" + } + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "1.0.0", + "is-extendable": "1.0.1" + } + }, + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true } } @@ -18382,6 +18529,15 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "0.1.15" + } + }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", @@ -21331,12 +21487,6 @@ "integrity": "sha1-YaajIBBiKvoHljvzJSA88SI51gQ=", "dev": true }, - "underscore.string": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", - "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", - "dev": true - }, "undertaker": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.0.tgz", @@ -21497,22 +21647,10 @@ } }, "upath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.0.0.tgz", - "integrity": "sha1-tHBrlGHKhHOt+JEz0jVonKF/NlY=", - "dev": true, - "requires": { - "lodash": "3.10.1", - "underscore.string": "2.3.3" - }, - "dependencies": { - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - } - } + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.0.4.tgz", + "integrity": "sha512-d4SJySNBXDaQp+DPrziv3xGS6w3d2Xt69FijJr86zMPBy23JEloMCEOUBBzuN7xCtjLCnmB9tI/z7SBCahHBOw==", + "dev": true }, "urix": { "version": "0.1.0", @@ -21800,9 +21938,9 @@ }, "dependencies": { "clone": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", - "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", "dev": true }, "clone-stats": { @@ -21829,7 +21967,7 @@ "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", "dev": true, "requires": { - "clone": "1.0.3", + "clone": "1.0.4", "clone-stats": "0.0.1", "replace-ext": "0.0.1" } diff --git a/package.json b/package.json index 228f8b801..21cc2678d 100644 --- a/package.json +++ b/package.json @@ -259,8 +259,8 @@ "react-addons-test-utils": "^15.5.1", "react-test-renderer": "^15.6.2", "react-testutils-additions": "^15.2.0", - "selenium-webdriver": "^3.5.0", "redux-test-utils": "^0.2.2", + "selenium-webdriver": "^3.5.0", "sinon": "^5.0.0", "stylelint-config-standard": "^18.2.0", "tape": "^4.5.1", From 28306cc453477c318de99a38abfc3daa976dd173 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 23:15:00 -0700 Subject: [PATCH 28/45] ci - artifacts - simplify result path --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index ac05e747c..d82ab3bc7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -100,6 +100,7 @@ jobs: - dist - store_artifacts: path: dist/mascara + destination: build - run: name: build:announce command: | From 085e7d7dec1cdd05069db1fb7afa797c6be2f6ad Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 23:19:07 -0700 Subject: [PATCH 29/45] ui - fix typo in settings --- ui/app/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/settings.js b/ui/app/settings.js index 171264ed4..ec24172e8 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -108,7 +108,7 @@ class Settings extends Component { renderCurrentLocale () { const { updateCurrentLocale, currentLocale } = this.props const currentLocaleMeta = locales.find(locale => locale.code === currentLocale) - const currentLocaleName = currentLocaleMeta ? currentLocaleMeta.name || '' + const currentLocaleName = currentLocaleMeta ? currentLocaleMeta.name : '' return h('div.settings__content-row', [ h('div.settings__content-item', [ From 399381f9d255ff45a824f3c00494dcec63d90076 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 23:26:58 -0700 Subject: [PATCH 30/45] ci - upload whole dist + fix announce mascara url --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d82ab3bc7..fb274d0d6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,14 +99,14 @@ jobs: paths: - dist - store_artifacts: - path: dist/mascara - destination: build + path: dist + destination: builds - run: name: build:announce command: | CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" SHORT_SHA1=$(echo $CIRCLE_SHA1 | cut -c 1-7) - QA_BUILD_URL="https://$CIRCLE_BUILD_NUM-42009758-gh.circle-artifacts.com/0/home/circleci/project/dist/mascara/home.html" + QA_BUILD_URL="https://$CIRCLE_BUILD_NUM-42009758-gh.circle-artifacts.com/0/builds/mascara/home.html" COMMENT_BODY="[Try QA Build for $SHORT_SHA1]($QA_BUILD_URL)" JSON_PAYLOAD="{\"body\":\"$COMMENT_BODY\"}" POST_COMMENT_URI="https://api.github.com/repos/metamask/metamask-extension/issues/$CIRCLE_PR_NUMBER/comments" From e7f655ec6da79035179323a9ebe63a93677b1649 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 23:45:33 -0700 Subject: [PATCH 31/45] npm scripts - simplify and speed up dist builds --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 21cc2678d..2dd63c1d1 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,7 @@ "mock": "beefy development/mock-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", "watch": "mocha watch --recursive \"test/unit/**/*.js\"", "mascara": "gulp build && cross-env METAMASK_DEBUG=true node ./mascara/example/server", - "dist": "npm run dist:clear && npm install && gulp dist", - "dist:clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/eth-phishing-detect", + "dist": "gulp dist", "test": "npm run test:unit && npm run test:integration && npm run lint", "test:unit": "cross-env METAMASK_ENV=test mocha --exit --require babel-core/register --require test/helper.js --recursive \"test/unit/**/*.js\"", "test:single": "cross-env METAMASK_ENV=test mocha --require test/helper.js", From 93ac72801afb318c6003e4d8ff2f22af06356ac8 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 28 Mar 2018 23:47:11 -0700 Subject: [PATCH 32/45] ci - artifacts - upload extension builds, dont upload extension source --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fb274d0d6..0173b8b3d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,7 +99,10 @@ jobs: paths: - dist - store_artifacts: - path: dist + path: dist/mascara + destination: builds/mascara + - store_artifacts: + path: builds destination: builds - run: name: build:announce From ec608cb1b0bca09ddeb33f6c54146b3ab90925a8 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 00:17:14 -0700 Subject: [PATCH 33/45] ci - build:announce - link all builds --- .circleci/config.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0173b8b3d..5e84fb783 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -109,8 +109,15 @@ jobs: command: | CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" SHORT_SHA1=$(echo $CIRCLE_SHA1 | cut -c 1-7) - QA_BUILD_URL="https://$CIRCLE_BUILD_NUM-42009758-gh.circle-artifacts.com/0/builds/mascara/home.html" - COMMENT_BODY="[Try QA Build for $SHORT_SHA1]($QA_BUILD_URL)" + BUILD_LINK_BASE="https://$CIRCLE_BUILD_NUM-42009758-gh.circle-artifacts.com/0/builds" + MASCARA="BUILD_LINK_BASE/mascara/home.html" + CHROME="BUILD_LINK_BASE/chrome.zip" + FIREFOX="BUILD_LINK_BASE/firefox.zip" + OPERA="BUILD_LINK_BASE/opera.zip" + EDGE="BUILD_LINK_BASE/edge.zip" + COMMENT_MAIN="Builds ready [$SHORT_SHA1]: [mascara][mascara], [chrome][chrome], [firefox][firefox], [edge][edge], [opera][opera]" + COMMENT_LINKS="[mascara]:$MASCARA\n[chrome]:$CHROME\n[firefox]:$FIREFOX\n[opera]:$OPERA\n[edge]:$EDGE\n" + COMMENT_BODY="$COMMENT_MAIN\n\n$COMMENT_LINKS" JSON_PAYLOAD="{\"body\":\"$COMMENT_BODY\"}" POST_COMMENT_URI="https://api.github.com/repos/metamask/metamask-extension/issues/$CIRCLE_PR_NUMBER/comments" echo "Announcement:\n$COMMENT_BODY" From 001595b2b9e0a06b3e16033143128620ead544bc Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 00:24:50 -0700 Subject: [PATCH 34/45] ci - build:announce - fix link --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5e84fb783..fa694dcff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -110,11 +110,11 @@ jobs: CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" SHORT_SHA1=$(echo $CIRCLE_SHA1 | cut -c 1-7) BUILD_LINK_BASE="https://$CIRCLE_BUILD_NUM-42009758-gh.circle-artifacts.com/0/builds" - MASCARA="BUILD_LINK_BASE/mascara/home.html" - CHROME="BUILD_LINK_BASE/chrome.zip" - FIREFOX="BUILD_LINK_BASE/firefox.zip" - OPERA="BUILD_LINK_BASE/opera.zip" - EDGE="BUILD_LINK_BASE/edge.zip" + MASCARA="$BUILD_LINK_BASE/mascara/home.html" + CHROME="$BUILD_LINK_BASE/chrome.zip" + FIREFOX="$BUILD_LINK_BASE/firefox.zip" + OPERA="$BUILD_LINK_BASE/opera.zip" + EDGE="$BUILD_LINK_BASE/edge.zip" COMMENT_MAIN="Builds ready [$SHORT_SHA1]: [mascara][mascara], [chrome][chrome], [firefox][firefox], [edge][edge], [opera][opera]" COMMENT_LINKS="[mascara]:$MASCARA\n[chrome]:$CHROME\n[firefox]:$FIREFOX\n[opera]:$OPERA\n[edge]:$EDGE\n" COMMENT_BODY="$COMMENT_MAIN\n\n$COMMENT_LINKS" From 93c123c6f52b28b525658492ce93fbcc30fc1e7c Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 00:34:01 -0700 Subject: [PATCH 35/45] ci - build:announce - fix links to extension builds --- .circleci/config.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fa694dcff..bb14d2a3a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -110,11 +110,12 @@ jobs: CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" SHORT_SHA1=$(echo $CIRCLE_SHA1 | cut -c 1-7) BUILD_LINK_BASE="https://$CIRCLE_BUILD_NUM-42009758-gh.circle-artifacts.com/0/builds" + VERSION=$(node -p 'require("./dist/chrome/manifest.json").version') MASCARA="$BUILD_LINK_BASE/mascara/home.html" - CHROME="$BUILD_LINK_BASE/chrome.zip" - FIREFOX="$BUILD_LINK_BASE/firefox.zip" - OPERA="$BUILD_LINK_BASE/opera.zip" - EDGE="$BUILD_LINK_BASE/edge.zip" + CHROME="$BUILD_LINK_BASE/metamask-chrome-$VERSION.zip" + FIREFOX="$BUILD_LINK_BASE/metamask-firefox-$VERSION.zip" + OPERA="$BUILD_LINK_BASE/metamask-opera-$VERSION.zip" + EDGE="$BUILD_LINK_BASE/metamask-edge-$VERSION.zip" COMMENT_MAIN="Builds ready [$SHORT_SHA1]: [mascara][mascara], [chrome][chrome], [firefox][firefox], [edge][edge], [opera][opera]" COMMENT_LINKS="[mascara]:$MASCARA\n[chrome]:$CHROME\n[firefox]:$FIREFOX\n[opera]:$OPERA\n[edge]:$EDGE\n" COMMENT_BODY="$COMMENT_MAIN\n\n$COMMENT_LINKS" From 7067f636274cc00254661bb28ae371c975664e3d Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 17:34:30 -0700 Subject: [PATCH 36/45] build - dev - run js tasks in parallel and set watch flag --- gulpfile.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index d6892cc7e..de3d5be11 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -254,6 +254,7 @@ function createTasksForBuildJsExtension({ buildJsFiles, taskPrefix, devMode, bun sourceMapDir: devMode ? './' : '../sourcemaps', minifyBuild: !devMode, buildWithFullPaths: devMode, + watch: devMode, }, bundleTaskOpts) createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1, buildPhase2 }) } @@ -268,6 +269,7 @@ function createTasksForBuildJsMascara({ taskPrefix, devMode, bundleTaskOpts = {} sourceMapDir: './', minifyBuild: !devMode, buildWithFullPaths: devMode, + watch: devMode, }, bundleTaskOpts) createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinations, buildPhase1 }) } @@ -277,7 +279,6 @@ function createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinatio const jsFiles = [].concat(buildPhase1, buildPhase2) jsFiles.forEach((jsFile) => { gulp.task(`${taskPrefix}:${jsFile}`, bundleTask(Object.assign({ - watch: false, label: jsFile, filename: `${jsFile}.js`, filepath: `${rootDir}/${jsFile}.js`, @@ -289,7 +290,7 @@ function createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinatio subtasks.push(gulp.parallel(buildPhase1.map(file => `${taskPrefix}:${file}`))) if (buildPhase2.length) subtasks.push(gulp.parallel(buildPhase2.map(file => `${taskPrefix}:${file}`))) - gulp.task(taskPrefix, gulp.series(subtasks)) + gulp.task(taskPrefix, gulp.parallel(subtasks)) } // disc bundle analyzer tasks @@ -324,9 +325,9 @@ gulp.task('apply-prod-environment', function(done) { gulp.task('dev', gulp.series( 'build:scss', - 'dev:js', 'copy', gulp.parallel( + 'dev:js', 'watch:scss', 'copy:dev', 'dev:reload' From 77d4a9a2bbd28c633cb6731cdbce47d3f79972a7 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 17:37:49 -0700 Subject: [PATCH 37/45] build - dev - fix js build order --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index de3d5be11..0c16eb18e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -290,7 +290,7 @@ function createTasksForBuildJs({ rootDir, taskPrefix, bundleTaskOpts, destinatio subtasks.push(gulp.parallel(buildPhase1.map(file => `${taskPrefix}:${file}`))) if (buildPhase2.length) subtasks.push(gulp.parallel(buildPhase2.map(file => `${taskPrefix}:${file}`))) - gulp.task(taskPrefix, gulp.parallel(subtasks)) + gulp.task(taskPrefix, gulp.series(subtasks)) } // disc bundle analyzer tasks From 4606a23c3fbfbbbd93ea59f3ca3e2e06766d3a04 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 21:28:35 -0700 Subject: [PATCH 38/45] build - refactor scss compilation into single config --- gulpfile.js | 81 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 0c16eb18e..4a4ab8ee0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -109,7 +109,7 @@ function createCopyTasks(label, opts) { copyTask(copyTaskName, opts) copyTaskNames.push(copyTaskName) } - const copyDevTaskName = `copy:dev:${label}` + const copyDevTaskName = `dev:copy:${label}` copyTask(copyDevTaskName, Object.assign({ devMode: true }, opts)) copyDevTaskNames.push(copyDevTaskName) } @@ -168,7 +168,7 @@ gulp.task('copy', ) ) -gulp.task('copy:dev', +gulp.task('dev:copy', gulp.series( gulp.parallel(...copyDevTaskNames), 'manifest:chrome', @@ -199,17 +199,50 @@ gulp.task('lint:fix', function () { // scss compilation and autoprefixing tasks -gulp.task('build:scss', function () { - return gulp.src('ui/app/css/index.scss') - .pipe(sourcemaps.init()) - .pipe(sass().on('error', sass.logError)) - .pipe(sourcemaps.write()) - .pipe(autoprefixer()) - .pipe(gulp.dest('ui/app/css/output')) -}) -gulp.task('watch:scss', function() { - gulp.watch(['ui/app/css/**/*.scss'], gulp.series(['build:scss'])) -}) +// gulp.task('build:scss', function () { +// return gulp.src('ui/app/css/index.scss') +// .pipe(sourcemaps.init()) +// .pipe(sass().on('error', sass.logError)) +// .pipe(sourcemaps.write()) +// .pipe(autoprefixer()) +// .pipe(gulp.dest('ui/app/css/output')) +// }) +// gulp.task('dev:scss', function() { +// gulp.watch(['ui/app/css/**/*.scss'], gulp.parallel(['build:scss'])) +// }) + + + +gulp.task('build:scss', createScssBuildTask({ + src: 'ui/app/css/index.scss', + dest: 'ui/app/css/output', + devMode: false, +})) + +gulp.task('dev:scss', createScssBuildTask({ + src: 'ui/app/css/index.scss', + dest: 'ui/app/css/output', + devMode: true, + pattern: 'ui/app/css/**/*.scss', +})) + +function createScssBuildTask({ src, dest, devMode, pattern }) { + return function () { + if (devMode) { + watch(pattern, buildScss) + } + return buildScss() + } + + function buildScss() { + return gulp.src(src) + .pipe(sourcemaps.init()) + .pipe(sass().on('error', sass.logError)) + .pipe(sourcemaps.write()) + .pipe(autoprefixer()) + .pipe(gulp.dest(dest)) + } +} gulp.task('lint-scss', function() { return gulp @@ -321,15 +354,27 @@ gulp.task('apply-prod-environment', function(done) { }); // high level tasks +// +// gulp.task('dev', +// gulp.series( +// 'build:scss', +// 'copy', +// gulp.parallel( +// 'dev:js', +// 'dev:scss', +// 'dev:copy', +// 'dev:reload' +// ) +// ) +// ) gulp.task('dev', gulp.series( - 'build:scss', - 'copy', + 'clean', + 'dev:scss', gulp.parallel( 'dev:js', - 'watch:scss', - 'copy:dev', + 'dev:copy', 'dev:reload' ) ) @@ -341,7 +386,7 @@ gulp.task('build', 'build:scss', gulp.parallel( 'build:js:extension', - 'build:js:mascara', + // 'build:js:mascara', 'copy' ) ) From b2d0e9871c5004458ef9be4a83d08df8a39e6e48 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 21:53:38 -0700 Subject: [PATCH 39/45] build - fix copy devMode --- gulpfile.js | 63 ++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 4a4ab8ee0..c2e18395c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -114,6 +114,37 @@ function createCopyTasks(label, opts) { copyDevTaskNames.push(copyDevTaskName) } +function copyTask(taskName, opts){ + const source = opts.source + const destination = opts.destination + const destinations = opts.destinations || [destination] + const pattern = opts.pattern || '/**/*' + const devMode = opts.devMode + + return gulp.task(taskName, function () { + if (devMode) { + watch(source + pattern, (event) => { + livereload.changed(event.path) + performCopy() + }) + } + + return performCopy() + }) + + function performCopy() { + // stream from source + let stream = gulp.src(source + pattern, { base: source }) + + // copy to destinations + destinations.forEach(function(destination) { + stream = stream.pipe(gulp.dest(destination)) + }) + + return stream + } +} + // manifest tinkering gulp.task('manifest:chrome', function() { @@ -402,38 +433,6 @@ gulp.task('dist', // task generators -function copyTask(taskName, opts){ - const source = opts.source - const destination = opts.destination - const destinations = opts.destinations || [ destination ] - const pattern = opts.pattern || '/**/*' - const devMode = opts.devMode - - return gulp.task(taskName, performCopy) - - function performCopy(){ - // stream from source - let stream - if (devMode) { - stream = watch(source + pattern, { base: source }) - } else { - stream = gulp.src(source + pattern, { base: source }) - } - - // copy to destinations - destinations.forEach(function(destination) { - stream = stream.pipe(gulp.dest(destination)) - }) - - // trigger reload - if (devMode) { - stream.pipe(livereload()) - } - - return stream - } -} - function zipTask(target) { return () => { return gulp.src(`dist/${target}/**`) From 7b9b890aa94557c4665be00da8c0f2e24ba4ea1a Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 22:19:15 -0700 Subject: [PATCH 40/45] build - fix scss + js reload --- gulpfile.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index c2e18395c..5e7b5dc03 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -28,7 +28,8 @@ const stylefmt = require('gulp-stylefmt') const uglify = require('gulp-uglify-es').default const babel = require('gulp-babel') const debug = require('gulp-debug') - +const pify = require('pify') +const endOfStream = pify(require('end-of-stream')) const disableDebugTools = gutil.env.disableDebugTools const debugMode = gutil.env.debug @@ -260,7 +261,11 @@ gulp.task('dev:scss', createScssBuildTask({ function createScssBuildTask({ src, dest, devMode, pattern }) { return function () { if (devMode) { - watch(pattern, buildScss) + watch(pattern, async (event) => { + const stream = buildScss() + await endOfStream(stream) + livereload.changed(event.path) + }) } return buildScss() } @@ -454,7 +459,11 @@ function generateBundler(opts, performBundle) { if (opts.watch) { bundler = watchify(bundler) // on any file update, re-runs the bundler - bundler.on('update', performBundle) + bundler.on('update', async (ids) => { + const stream = performBundle() + await endOfStream(stream) + livereload.changed(`${ids}`) + }) } return bundler @@ -494,7 +503,6 @@ function bundleTask(opts) { return performBundle function performBundle(){ - let buildStream = bundler.bundle() // handle errors @@ -545,10 +553,6 @@ function bundleTask(opts) { buildStream = buildStream.pipe(gulp.dest(dest)) }) - // finally, trigger live reload - buildStream = buildStream - .pipe(gulpif(debugMode, livereload())) - return buildStream } From edd70bd13e514013073f75ff005bddf6f6a568a9 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 22:20:24 -0700 Subject: [PATCH 41/45] build - cleanup commented code --- gulpfile.js | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5e7b5dc03..910441e4d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -231,20 +231,6 @@ gulp.task('lint:fix', function () { // scss compilation and autoprefixing tasks -// gulp.task('build:scss', function () { -// return gulp.src('ui/app/css/index.scss') -// .pipe(sourcemaps.init()) -// .pipe(sass().on('error', sass.logError)) -// .pipe(sourcemaps.write()) -// .pipe(autoprefixer()) -// .pipe(gulp.dest('ui/app/css/output')) -// }) -// gulp.task('dev:scss', function() { -// gulp.watch(['ui/app/css/**/*.scss'], gulp.parallel(['build:scss'])) -// }) - - - gulp.task('build:scss', createScssBuildTask({ src: 'ui/app/css/index.scss', dest: 'ui/app/css/output', @@ -390,19 +376,6 @@ gulp.task('apply-prod-environment', function(done) { }); // high level tasks -// -// gulp.task('dev', -// gulp.series( -// 'build:scss', -// 'copy', -// gulp.parallel( -// 'dev:js', -// 'dev:scss', -// 'dev:copy', -// 'dev:reload' -// ) -// ) -// ) gulp.task('dev', gulp.series( From 433bb0f01ae3631774191f8ed802eb7f2f04a552 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 22:34:59 -0700 Subject: [PATCH 42/45] build - split primary tasks into metamask + extension * dev + build --- gulpfile.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 910441e4d..647abb6d2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -69,7 +69,7 @@ createCopyTasks('images', { destinations: commonPlatforms.map(platform => `./dist/${platform}/images`), }) createCopyTasks('contractImages', { - source: `${require.resolve('eth-contract-metadata')}/images/`, + source: './node_modules/eth-contract-metadata/images/', destinations: commonPlatforms.map(platform => `./dist/${platform}/images/contract`), }) createCopyTasks('fonts', { @@ -293,9 +293,10 @@ const buildJsFiles = [ ] // bundle tasks -createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'dev:js', devMode: true }) -createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'build:js:extension' }) -createTasksForBuildJsMascara({ taskPrefix: 'build:js:mascara' }) +createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'dev:extension:js', devMode: true }) +createTasksForBuildJsExtension({ buildJsFiles, taskPrefix: 'build:extension:js' }) +createTasksForBuildJsMascara({ taskPrefix: 'build:mascara:js' }) +createTasksForBuildJsMascara({ taskPrefix: 'dev:mascara:js', devMode: true }) function createTasksForBuildJsExtension({ buildJsFiles, taskPrefix, devMode, bundleTaskOpts = {} }) { // inpage must be built before all other scripts: @@ -382,7 +383,32 @@ gulp.task('dev', 'clean', 'dev:scss', gulp.parallel( - 'dev:js', + 'dev:extension:js', + 'dev:mascara:js', + 'dev:copy', + 'dev:reload' + ) + ) +) + +gulp.task('dev:extension', + gulp.series( + 'clean', + 'dev:scss', + gulp.parallel( + 'dev:extension:js', + 'dev:copy', + 'dev:reload' + ) + ) +) + +gulp.task('dev:mascara', + gulp.series( + 'clean', + 'dev:scss', + gulp.parallel( + 'dev:mascara:js', 'dev:copy', 'dev:reload' ) @@ -394,8 +420,30 @@ gulp.task('build', 'clean', 'build:scss', gulp.parallel( - 'build:js:extension', - // 'build:js:mascara', + 'build:extension:js', + 'build:mascara:js', + 'copy' + ) + ) +) + +gulp.task('build:extension', + gulp.series( + 'clean', + 'build:scss', + gulp.parallel( + 'build:extension:js', + 'copy' + ) + ) +) + +gulp.task('build:mascara', + gulp.series( + 'clean', + 'build:scss', + gulp.parallel( + 'build:mascara:js', 'copy' ) ) From 8277c662deffea3c01496fc7d07ed3e9a9a97a50 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 22:58:26 -0700 Subject: [PATCH 43/45] npm scripts - rewrite default scripts to new task names --- package.json | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 2dd63c1d1..a852395b3 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,8 @@ "public": false, "private": true, "scripts": { - "start": "npm run dev", - "dev": "gulp dev --debug", - "ui": "npm run test:flat:build:states && beefy development/ui-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", - "mock": "beefy development/mock-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", - "watch": "mocha watch --recursive \"test/unit/**/*.js\"", - "mascara": "gulp build && cross-env METAMASK_DEBUG=true node ./mascara/example/server", + "start": "gulp dev:extension", + "mascara": "gulp dev:mascara & cross-env METAMASK_DEBUG=true node ./mascara/example/server", "dist": "gulp dist", "test": "npm run test:unit && npm run test:integration && npm run lint", "test:unit": "cross-env METAMASK_ENV=test mocha --exit --require babel-core/register --require test/helper.js --recursive \"test/unit/**/*.js\"", @@ -40,6 +36,9 @@ "sentry:upload:maps": "sentry-cli releases --org 'metamask' --project 'metamask' files $RELEASE upload-sourcemaps ./dist/sourcemaps/ --url-prefix 'sourcemaps' --rewrite", "lint": "gulp lint", "lint:fix": "gulp lint:fix", + "ui": "npm run test:flat:build:states && beefy development/ui-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", + "mock": "beefy development/mock-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", + "watch": "mocha watch --recursive \"test/unit/**/*.js\"", "disc": "gulp disc --debug", "announce": "node development/announcer.js", "version:bump": "node development/run-version-bump.js", From 99e618d3f2fed0504e9dcc4647b8492440617162 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 23:06:01 -0700 Subject: [PATCH 44/45] mascara - server - serve bundles from dist --- gulpfile.js | 2 +- mascara/server/index.js | 13 ------------- mascara/src/{mascara.js => metamascara.js} | 0 3 files changed, 1 insertion(+), 14 deletions(-) rename mascara/src/{mascara.js => metamascara.js} (100%) diff --git a/gulpfile.js b/gulpfile.js index 647abb6d2..3ca0c65de 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -318,7 +318,7 @@ function createTasksForBuildJsExtension({ buildJsFiles, taskPrefix, devMode, bun function createTasksForBuildJsMascara({ taskPrefix, devMode, bundleTaskOpts = {} }) { // inpage must be built before all other scripts: const rootDir = './mascara/src/' - const buildPhase1 = ['ui', 'proxy', 'background'] + const buildPhase1 = ['ui', 'proxy', 'background', 'metamascara'] const destinations = ['./dist/mascara'] bundleTaskOpts = Object.assign({ buildSourceMaps: true, diff --git a/mascara/server/index.js b/mascara/server/index.js index 2bc2441d0..2f3a7a5ff 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -9,23 +9,10 @@ module.exports = createMetamascaraServer function createMetamascaraServer () { - // start bundlers - const metamascaraBundle = createBundle(path.join(__dirname, '/../src/mascara.js')) - const proxyBundle = createBundle(path.join(__dirname, '/../src/proxy.js')) - const uiBundle = createBundle(path.join(__dirname, '/../src/ui.js')) - const backgroundBuild = createBundle(path.join(__dirname, '/../src/background.js')) - // setup server const server = express() server.use(compression()) - // serve bundles - serveBundle(server, '/metamascara.js', metamascaraBundle) - serveBundle(server, '/scripts/ui.js', uiBundle) - serveBundle(server, '/scripts/proxy.js', proxyBundle) - // the serviceworker must be served from the root of the app - serveBundle(server, '/background.js', backgroundBuild) - // serve assets server.use(express.static(path.join(__dirname, '/../ui/'), { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') })) server.use(express.static(path.join(__dirname, '/../../dist/mascara'))) diff --git a/mascara/src/mascara.js b/mascara/src/metamascara.js similarity index 100% rename from mascara/src/mascara.js rename to mascara/src/metamascara.js From 89e6baa3ba07cc46dcc62886fbe3f1906649ae77 Mon Sep 17 00:00:00 2001 From: kumavis Date: Thu, 29 Mar 2018 23:09:31 -0700 Subject: [PATCH 45/45] clean - mascara - remove unused code --- mascara/server/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/mascara/server/index.js b/mascara/server/index.js index 2f3a7a5ff..a30120438 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -1,7 +1,5 @@ const path = require('path') const express = require('express') -const createBundle = require('./util').createBundle -const serveBundle = require('./util').serveBundle const compression = require('compression') module.exports = createMetamascaraServer