Skip to content

Commit

Permalink
Merge pull request #209 from duckduckgo/develop
Browse files Browse the repository at this point in the history
version 2018-4-20
  • Loading branch information
jdorweiler authored Apr 20, 2018
2 parents d600e35 + 913c029 commit 823bacd
Show file tree
Hide file tree
Showing 82 changed files with 12,450 additions and 1,048 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ shared/js/tldjs.js
build/firefox
build/chrome
build/safari
package-lock.json
test/background.js
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- 8.11.1
before_script:
- npm install -g grunt-cli
106 changes: 96 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = function(grunt) {
const through = require('through2')
require('load-grunt-tasks')(grunt)
grunt.loadNpmTasks('grunt-execute')
grunt.loadNpmTasks('grunt-karma')

var values = require('object.values');

if(!Object.values) {
Expand All @@ -9,13 +12,15 @@ module.exports = function(grunt) {

let browser = grunt.option('browser')
let buildType = grunt.option('type')
let buildPath = `build/${browser}/${buildType}`

if(!(browser && buildType)) {
console.error("Missing browser or build type: --browser=<browser-name> --type=<dev,release>")
process.exit(1)
}

let buildPath = `build/${browser}/${buildType}`


/* These are files common to all browsers. To add or override any of these files
* see the browserMap object below */
let baseFileMap = {
Expand All @@ -30,6 +35,10 @@ module.exports = function(grunt) {
backgroundTest: {
'<%= dirs.test %>/background.js': ['<%= dirs.src.js %>/background/background.es6.js', '<%= dirs.test %>/requireHelper.js']
},
unitTest: {
'<%= dirs.unitTest.build %>/background.js': ['<%= dirs.unitTest.background %>/**/*.js'],
'<%= dirs.unitTest.build %>/ui.js': ['<%= dirs.src.js %>/ui/base/index.es6.js', '<%= dirs.unitTest.ui %>/**/*.js']
},
sass: {
'<%= dirs.public.css %>/noatb.css': ['<%= dirs.src.scss %>/noatb.scss'],
'<%= dirs.public.css %>/base.css': ['<%= dirs.src.scss %>/base/base.scss'],
Expand All @@ -50,6 +59,25 @@ module.exports = function(grunt) {
background: ['<%= dirs.src.js %>/background/**/*.js','<%= dirs.data %>/*.js']
}

let karmaOps = {
configFile: 'karma.conf.js',
basePath: 'build/test/',
files: ['background.js','ui.js']
}

// override some options to allow the devs
// to open the test page manually and debug
if (grunt.option('test-debug')) {
Object.assign(karmaOps, {
// don't kill the process when first test is run
singleRun: false,
// INFO outputs the url/port for the test page
logLevel: 'INFO',
// don't run headless chrome tests
browsers: []
})
}

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
dirs: {
Expand All @@ -64,21 +92,52 @@ module.exports = function(grunt) {
js: `${buildPath}/public/js`,
css: `${buildPath}/public/css`
},
test: 'test'
test: 'test',
unitTest: {
background: `unit-test/background`,
ui: `unit-test/ui`,
build: `build/test`
}
},

browserify: {
options: {
browserifyOptions: {
debug: buildType === 'dev'
},
transform: [
['babelify'],
[(file) => {
return through( function(buf, enc, next) {
let requireName = browser
if(browser === 'duckduckgo.safariextension') {
requireName = 'safari'
}
else if (browser === 'firefox') {
requireName = 'chrome'
}
this.push(buf.toString('utf8').replace(/\$BROWSER/g, requireName))
next()
})
}]
]
},
ui: {
options: { transform: ['babelify'] },
files: baseFileMap.ui
},
background: {
options: { transform: ['babelify'] },
files: baseFileMap.background
},
backgroundTest: {
options: { transform: ['babelify'] },
files: baseFileMap.backgroundTest
},
unitTest: {
options: {
browserifyOptions: {
debug: true
}
},
files: baseFileMap.unitTest
}
},

Expand All @@ -99,7 +158,10 @@ module.exports = function(grunt) {

// used by watch to copy shared/js to build dir
exec: {
copyjs: `cp shared/js/*.js build/${browser}/${buildType}/js/ && rm build/${browser}/${buildType}/js/*.es6.js`
copyjs: `cp shared/js/*.js build/${browser}/${buildType}/js/ && rm build/${browser}/${buildType}/js/*.es6.js`,
tmpSafari: `mv build/${browser}/${buildType} build/${browser}/tmp && mkdir -p build/${browser}/${buildType}/`,
mvSafari: `mv build/${browser}/tmp build/${browser}/${buildType}/ && mv build/${browser}/${buildType}/tmp build/${browser}/${buildType}/${browser}`,
mvWatchSafari: `rsync -ar build/${browser}/${buildType}/public build/${browser}/${buildType}/${browser}/ && rm -rf build/${browser}/${buildType}/public`
},

watch: {
Expand All @@ -109,21 +171,45 @@ module.exports = function(grunt) {
},
ui: {
files: watch.ui,
tasks: ['browserify:ui']
tasks: ['browserify:ui', 'watchSafari']

},
backgroundES6JS: {
files: watch.background,
tasks: ['browserify:background']
tasks: ['browserify:background', 'watchSafari']
},
backgroundJS: {
files: ['<%= dirs.src.js %>/*.js'],
tasks: ['exec:copyjs']
tasks: ['exec:copyjs', 'watchSafari']
}
},

karma: {
unit: {
options: karmaOps
}
}
})

grunt.registerTask('build', 'Build project(s)css, templates, js', ['sass', 'browserify:ui', 'browserify:background', 'execute:preProcessLists'])
// sets up safari directory structure so that it can be loaded in extension builder
// duckduckgo.safariextension -> build type -> duckduckgo.safariextension -> build files
grunt.registerTask('safari', 'Move Safari build', (() => {
if (browser === 'duckduckgo.safariextension') {
console.log("Moving Safari build")
grunt.task.run('exec:tmpSafari')
grunt.task.run('exec:mvSafari')
}
}))

// moves generated files from watch into the correct build directory
grunt.registerTask('watchSafari', 'Moves Safari files after watch', (() => {
if (browser === 'duckduckgo.safariextension') {
grunt.task.run('exec:mvWatchSafari')
}
}))

grunt.registerTask('build', 'Build project(s)css, templates, js', ['sass', 'browserify:ui', 'browserify:background', 'execute:preProcessLists', 'safari'])
grunt.registerTask('dev', 'Build and watch files for development', ['build', 'watch'])
grunt.registerTask('test','Build and run tests', ['browserify:unitTest','karma'])
grunt.registerTask('default', 'build')
}
2 changes: 1 addition & 1 deletion browsers/chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"default_locale": "en",
"version": "2018.4.17",
"version": "2018.4.20",
"icons": {
"16": "img/icon_16.png",
"48": "img/icon_48.png",
Expand Down
Binary file added browsers/duckduckgo.safariextension/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions browsers/duckduckgo.safariextension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Author</key>
<string>DuckDuckGo</string>
<key>Builder Version</key>
<string>13604.5.6</string>
<key>CFBundleDisplayName</key>
<string>DuckDuckGo Privacy Essentials</string>
<key>CFBundleIdentifier</key>
<string>com.duckduckgo.safari</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>2018.4.20</string>
<key>CFBundleVersion</key>
<string>45</string>
<key>Chrome</key>
<dict>
<key>Database Quota</key>
<integer>104857600</integer>
<key>Global Page</key>
<string>html/background.html</string>
<key>Popovers</key>
<array>
<dict>
<key>Filename</key>
<string>html/popup.html</string>
<key>Height</key>
<integer>600</integer>
<key>Identifier</key>
<string>popup</string>
<key>Width</key>
<integer>300</integer>
</dict>
</array>
<key>Toolbar Items</key>
<array>
<dict>
<key>Identifier</key>
<string>popup_button</string>
<key>Image</key>
<string>img/[email protected]</string>
<key>Label</key>
<string>DuckDuckGo</string>
<key>Palette Label</key>
<string>DuckDuckGo</string>
<key>Popover</key>
<string>popup</string>
<key>Tool Tip</key>
<string>DuckDuckGo</string>
</dict>
</array>
</dict>
<key>Content</key>
<dict>
<key>Scripts</key>
<dict>
<key>Start</key>
<array>
<string>public/js/content-scripts/on-install.js</string>
<string>public/js/content-scripts/content-script.js</string>
</array>
</dict>
<key>Stylesheets</key>
<array>
<string>public/css/noatb.css</string>
</array>
</dict>
<key>Description</key>
<string>Privacy, simplified. Protect your data as you search and browse the web.</string>
<key>DeveloperIdentifier</key>
<string>HKE973VLUW</string>
<key>ExtensionInfoDictionaryVersion</key>
<string>1.0</string>
<key>Permissions</key>
<dict>
<key>Website Access</key>
<dict>
<key>Include Secure Pages</key>
<true/>
<key>Level</key>
<string>All</string>
</dict>
</dict>
<key>Update Manifest URL</key>
<string>http://duckduckgo.com/extensions/duckduckgo.plist</string>
<key>Website</key>
<string>http://duckduckgo.com</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions browsers/duckduckgo.safariextension/Settings.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>DefaultValue</key>
<true/>
<key>Key</key>
<string>default_search_engine</string>
<key>Title</key>
<string>Make DuckDuckGo the default search engine</string>
<key>Type</key>
<string>CheckBox</string>
</dict>
</array>
</plist>
23 changes: 23 additions & 0 deletions browsers/duckduckgo.safariextension/duckduckgo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Extension Updates</key>
<array>
<dict>
<key>CFBundleIdentifier</key>
<string>com.duckduckgo.safari</string>
<key>Developer Identifier</key>
<string>HKE973VLUW</string>
<key>CFBundleVersion</key>
<string>39</string>
<key>CFBundleShortVersionString</key>
<string>1.9.0</string>
<key>URL</key>
<string>http://duckduckgo.com/extensions/duckduckgo.safariextz</string>
<key>Update From Gallery</key>
<true/>
</dict>
</array>
</dict>
</plist>
2 changes: 1 addition & 1 deletion browsers/firefox/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"strict_min_version": "57.0"
}
},
"version": "2018.4.17",
"version": "2018.4.20",
"description": "Privacy, simplified. Protect your data as you search and browse: tracker blocking, smarter encryption, private search, and more.",
"icons": {
"16": "img/icon_16.png",
Expand Down
25 changes: 25 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = function(config) {
process.env.CHROME_BIN = require('puppeteer').executablePath()

let configuration = {
basePath: '',
frameworks: ['jasmine','source-map-support'],
singleRun: true,
files: [],
logLevel: config.LOG_ERROR,
browsers: ['ChromeHeadless'],
reporters: ['dots'],
customLaunchers: {
Chrome_travis_ci: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
}
}

if(process.env.TRAVIS){
configuration.browsers = ['Chrome_travis_ci'];
}

config.set(configuration)
};
Loading

0 comments on commit 823bacd

Please sign in to comment.