Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterPhilip committed Mar 2, 2020
2 parents 8944eab + 36d88aa commit 537869f
Show file tree
Hide file tree
Showing 48 changed files with 7,678 additions and 13,567 deletions.
59 changes: 59 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"ignorePatterns": [
"./**",
"build/",
"coverage/",
"platform/",
"providers.js",
"src/assets/js/**",
"test/"
],
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"no-unused-vars": [
1,
{
"args": "none",
"ignoreRestSiblings": true,
"varsIgnorePattern": "Provider"
}
],
"quotes": [
"error",
"double",
{
"allowTemplateLiterals": true
}
],
"semi": [
"error",
"always"
],
"no-unsafe-finally": [
1
]
},
"globals": {
"chrome": "readonly",
"BaseProvider": "writeable"
}
};
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ platform/

# Ignore built CSS files
.sass-cache/
src/**/*.css
src/**/*.css

# Editor Configs
.vscode
.idea
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "12.10.0"
- "12.16.0"
after_success:
- "./node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls"
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
Expand Down
25 changes: 15 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ Find an issue? That's not good! Here's a list of information that we needed when

### Installing locally

To do any work, fork the original repository, and clone it locally. Then, install via [NPM](https://www.npmjs.com/):
To do any work, fork the original repository, and clone it locally. Then, install via [yarn](https://yarnpkg.com/):
```
$ npm install
$ yarn install
```

The installation process will download and install all of the requirements needed to build and develop Omnibug, as well
as run an initial build so you can immediately start using the development version.

Once installed on your machine, you can install as a developer / local version in Chrome and Firefox. You only need to
install them once within the respective browser. If you make any updates to the codebase (e.g. `npm run build`), you will
install them once within the respective browser. If you make any updates to the codebase (e.g. `yarn run build`), you will
need to click the refresh button within the browser's extension page. This prevents you from seeing the omnibug.io/installed
page multiple times.

Expand All @@ -62,24 +62,29 @@ To install the local version in Firefox, go to the [about:addons](Add-ons Manage
From there, select "[Debug Add-ons](about:debugging#addons)", and then select "Load Temporary Add-on" and point to the `/platform/firefox/manifest.json`
file. Learn more at [Mozilla's docs](https://developer.mozilla.org/en-US/Add-ons/WebExtensions).

##### Edge
To install the local version in Edge, go to the [edge://extensions/](Extensions) settings, then be sure "Developer Mode"
is checked. Once developer mode is enabled, select "Load unpacked extension..." and point to the `/platform/chromium/manifest.json`
file. Learn more at [Microsoft's docs](https://docs.microsoft.com/en-us/microsoft-edge/extensions-chromium/).


### Coding Styles

Honestly, our code style is kind of all over the place! It's something that will eventually be cleaned up, but here are
some basic guidelines:
We use [ESLint](https://eslint.org/) to ensure a consistent code style. Here are some basic guidelines though:

* Since we only support the latest few versions of Chrome and Firefox, we can safely use most of the ES6 features. Please
consider using these instead of outdated methods, as the ES6 version will provider a cleaner and faster code base.
* Use 4 spaces for 1 tab
* Any function, method, or class should have be declared on a it's own line
* Opening / closing brackets should be on it's own line, lining up with the name.
* A [JSDoc comment](http://usejsdoc.org/) should be included for each function, method, or class
* Use double quotes where possible
* Use double quotes or template syntax (backticks) where possible
* if / else statements should (_always_) have opening & closing brackets inline
* Run `yarn run lint` to view issues, and `yarn run lint:fix` to fix them. When you build, ESLint will run in the background and fail the build
if there are errors

### Adding a Provider

A provider is simply a marketing technology that exists in Omnibug. This could be a tool for analytics , re-marketing,
A provider is simply a marketing technology that exists in Omnibug. This could be a tool for analytics, re-marketing,
UX-testing, etc. You can find a full list of providers in [our source code](https://github.com/MisterPhilip/omnibug/tree/master/src/providers).
It is recommended to review a few existing providers to understand how providers can be setup.

Expand Down Expand Up @@ -297,7 +302,7 @@ All providers should have a test suite included with their pull request. The fol

Testing is done via [AVA](https://github.com/avajs/ava) and can be executed by running the following command:
```
$ npm run test
$ yarn run test
```

This will run the build process to build the providers and core Omnibug classes, and then show the result of the test suite.
Expand All @@ -310,7 +315,7 @@ test coverage across the providers and core classes.
Since each browser requires slightly different manifests & some need polyfills, [Grunt](https://gruntjs.com/) takes care
of building browser-specific code from the generic code base. To build for all browsers:
```
$ npm run build
$ yarn run build
```

This will output to the `/platform/$BROWSER` folders, as well as output a `.zip` for distribution in the `/build/$BROWSER` folders.
Expand Down
100 changes: 27 additions & 73 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/* globals module, require */
module.exports = function (grunt) {
const sass = require("node-sass");

module.exports = function (grunt) {

grunt.config.init({
"extension": {
"beta": {
"name": "Omnibug (Beta)",
"version": "0.9.6",
"storageKey": "omnibug-beta",
"feedbackUrl": "https://omnibug.io/beta-feedback",
"feedbackUrl": "https://github.com/MisterPhilip/omnibug/issues",
"analyticsID": "UA-114343677-3"
},
"production": {
"name": "Omnibug",
"version": "1.13.2",
"version": "1.14.0",
"storageKey": "omnibug",
"feedbackUrl": "https://omnibug.io/feedback",
"feedbackUrl": "https://github.com/MisterPhilip/omnibug/issues",
"analyticsID": "UA-114343677-2"
}
},
Expand Down Expand Up @@ -69,71 +71,21 @@ module.exports = function (grunt) {
},
}
},
"jshint": {
"options": {
"bitwise": true,
"camelcase": false,
"curly": true,
"eqeqeq": true,
"esversion": 6,
"forin": true,
"immed": true,
"indent": 4,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": true,
"regexp": true,
"undef": true,
"unused": true,
"strict": false,
"trailing": true,
"white": false,
"laxcomma": true,
"nonstandard": true,
"browser": true,
"maxparams": 3,
"maxdepth": 4,
"maxstatements": 50,
"maxerr": 200,
"globals": {
"browser": true,
"console": true,
"OmnibugProvider": true,
"BaseProvider": true
},
"reporter": require("jshint-html-reporter"),
"reporterOutput": "build/jshint/index.html"
},
"all": [
"Gruntfile.js",
"src/providers/*.js",
"src/libs/*.js",
"src/options/*.js",
"src/devtools/*.js",
"src/*.js"
],
"build": [
"Gruntfile.js"
],
"source": [
"src/*.js"
],
"providers": [
"src/providers/*.js"
]
},
"pkg": grunt.file.readJSON("package.json"),
"sass": {
"options": {
"implementation": sass,
"sourceMap": false
},
"dist": {
"files": {
"src/devtools/panel.css": "src/devtools/panel.scss",
"src/options/options.css": "src/options/options.scss"
}
}
},
"eslint": {
"target": ["src/"]
}
});

Expand All @@ -142,9 +94,9 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks("grunt-text-replace");
grunt.loadNpmTasks("grunt-sass");
grunt.loadNpmTasks("grunt-eslint");

grunt.registerTask("build-beta", "Build the beta version", (browsers = "") => {
let allowedBrowsers = ["chrome", "firefox"];
Expand Down Expand Up @@ -238,7 +190,7 @@ module.exports = function (grunt) {
grunt.registerTask("build-copy", "Copy over the source files to the build directory", function (browser) {
grunt.config.requires(browser);
let options = grunt.config(browser),
filesToCopy = ["eventPage.js", "providers.js", "options/*.*", "devtools/*.*", "assets/**", "libs/*.*", "!libs/OmnibugTracker.*", "popup/*.*", "!**/*.scss", "!assets/styles/**"],
filesToCopy = ["eventPage.js", "providers.js", "options/*.*", "devtools/*.*", "assets/**", "libs/*.*", "!libs/OmnibugTracker.*", "popup/*.*", "pages/**", "!**/*.scss", "!assets/styles/**"],
trackingLib = {
expand: true,
cwd: "src/libs/",
Expand Down Expand Up @@ -298,6 +250,10 @@ module.exports = function (grunt) {
"overwrite": true,
"usePrefix": false,
"replacements": [
{
"from": "##YEAR##",
"to": (new Date).getFullYear()
},
{
"from": "##OMNIBUG_VERSION##",
"to": extensionOptions.version
Expand Down Expand Up @@ -408,8 +364,7 @@ module.exports = function (grunt) {
"banner": "const { URL } = require(\"url\");\n" +
"const URLSearchParams = require(\"@ungap/url-search-params\");\n",
"process": function (source, filepath) {
var className = filepath.replace("./src/providers/", "").split(".")[0],
exportString = "";
var className = filepath.replace("./src/providers/", "").split(".")[0];
if (className === "OmnibugProvider") {
source = `const BaseProvider = require("./BaseProvider.js").default;\n` + source;
source = source.replace("var OmnibugProvider", "export var OmnibugProvider");
Expand All @@ -421,7 +376,6 @@ module.exports = function (grunt) {
}
source = source.replace(`class ${className}`, `export default class ${className}`);
return source;
// return source + "\n" + exportString + `module.exports = ${className};`
}
},
"files": {}
Expand All @@ -432,7 +386,7 @@ module.exports = function (grunt) {
concat = grunt.config.get("concat.providers-test-individual");

concat["files"][`./test/source/providers/${className}.js`] = fileName;
grunt.config.set('concat.providers-test-individual', concat);
grunt.config.set("concat.providers-test-individual", concat);
});

const sourceBasePath = "./src/providers/",
Expand Down Expand Up @@ -514,8 +468,8 @@ module.exports = function (grunt) {
/*
* Add aliases
*/
grunt.registerTask("default", ["build-production"]);
grunt.registerTask("build", ["build-production"]);
grunt.registerTask("production", ["build-production"]);
grunt.registerTask("beta", ["build-beta"]);
grunt.registerTask("default", ["eslint", "build-production"]);
grunt.registerTask("build", ["eslint", "build-production"]);
grunt.registerTask("production", ["eslint", "build-production"]);
grunt.registerTask("beta", ["eslint", "build-beta"]);
};

0 comments on commit 537869f

Please sign in to comment.