diff --git a/.circleci/config.yml b/.circleci/config.yml index 16bdd5b317e..ca6713bb587 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: build: docker: # specify the version you desire here - - image: circleci/node:7.10 + - image: circleci/node:8.9.0 # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images diff --git a/.eslintrc.js b/.eslintrc.js index 02ff81614c7..56e4808f985 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,6 @@ + +const allowedModules = require("./allowedModules"); + module.exports = { "env": { "browser": true, @@ -11,6 +14,9 @@ module.exports = { } }, "extends": "standard", + "plugins": [ + "prebid" + ], "globals": { "$$PREBID_GLOBAL$$": false }, @@ -31,5 +37,11 @@ module.exports = { "no-throw-literal": "off", "no-undef": "off", "no-useless-escape": "off", - } + }, + "overrides": Object.keys(allowedModules).map((key) => ({ + "files": key + "/**/*.js", + "rules": { + "prebid/validate-imports": ["error", allowedModules[key]] + } + })) }; diff --git a/.gitignore b/.gitignore index 88e849a35ad..c0452b7b3d0 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,9 @@ build/coverage/ .idea/ # if you remove the above rule, at least ignore the following: +# VS Code +.vscode/ + # User-specific stuff: # .idea/workspace.xml # .idea/tasks.xml diff --git a/.nvmrc b/.nvmrc index 4fedf1d20e1..fa97ecedc28 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -7.0 +8.9 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b82b249fa36..9c00a2bf51a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ commit your changes, and [open a pull request](https://help.github.com/articles/ master branch. Pull requests must have 80% code coverage before beign considered for merge. -Additional details about the process can be found [here](./pr_review.md). +Additional details about the process can be found [here](./PR_REVIEW.md). ## Issues [prebid.org](http://prebid.org/) contains documentation that may help answer questions you have about using Prebid.js. diff --git a/PR_REVIEW.md b/PR_REVIEW.md index d5799472377..4ad8b8ec372 100644 --- a/PR_REVIEW.md +++ b/PR_REVIEW.md @@ -14,6 +14,11 @@ For modules and core platform updates, the initial reviewer should request an ad - Review for obvious errors or bad coding practice / use best judgement here. - If the change is a new feature / change to core prebid.js - review the change with a Tech Lead on the project and make sure they agree with the nature of change. - If the change results in needing updates to docs (such as public API change, module interface etc), add a label for "needs docs" and inform the submitter they must submit a docs PR to update the appropriate area of Prebid.org **before the PR can merge**. Help them with finding where the docs are located on prebid.org if needed. + - Below are some examples of bidder specific updates that should require docs update (in their dev-docs/bidders/bidder.md file): + - Add support for GDPR consentManagement module > add `gdpr_supported: true` + - Add support for userId module > add `userId: pubCommon, digitrust, newProviderHere` + - Add support for video and/or native mediaTypes > add `media_types: video, native` + - Add support for COPPA > add `coppa_supported: true` - If all above is good, add a `LGTM` comment and request 1 additional core member to review. - Once there is 2 `LGTM` on the PR, merge to master - Ask the submitter to add a PR for documentation if applicable. diff --git a/README.md b/README.md index 62c835f8eb3..be07a27ddc1 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ module.exports = { } ``` -Or for Babel 6 and/or Node v8.6.0 and less: +Or for Babel 6: ```javascript // you must manually install and specify the presets and plugins yourself options: { @@ -112,11 +112,11 @@ prebid.requestBids({ $ cd Prebid.js $ npm install -*Note:* You need to have `NodeJS` 6.x or greater installed. +*Note:* You need to have `NodeJS` 8.9.x or greater installed. -*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To compily with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in it's setup. +*Note:* In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To comply with gulp's recommended setup for 4.0, you'll need to have `gulp-cli` installed globally prior to running the general `npm install`. This shouldn't impact any other projects you may work on that use an earlier version of gulp in its setup. -If you have a previous version of `gulp` installed globally, you'll need to remove it before installing `gulp-cli`. You can check if this is installed by running `gulp -v` and seeing the version that's listed in the `CLI` field of the output. If you have the `gulp` package installd globally, it's likely the same version that you'll see in the `Local` field. If you already have `gulp-cli` installed, it should be a lower major version (it's at version `2.0.1` at the time of the transition). +If you have a previous version of `gulp` installed globally, you'll need to remove it before installing `gulp-cli`. You can check if this is installed by running `gulp -v` and seeing the version that's listed in the `CLI` field of the output. If you have the `gulp` package installed globally, it's likely the same version that you'll see in the `Local` field. If you already have `gulp-cli` installed, it should be a lower major version (it's at version `2.0.1` at the time of the transition). To remove the old package, you can use the command: `npm rm gulp -g` @@ -207,10 +207,20 @@ gulp test-coverage gulp view-coverage ``` -For end-to-end testing, edit the example file `./integrationExamples/gpt/pbjs_example_gpt.html`: +For Prebid.org members with access to BrowserStack, additional end-to-end testing can be done with: -1. Change `{id}` values appropriately to set up ad units and bidders -2. Set the path to Prebid.js in your example file as shown below (see `pbs.src`). +```bash +gulp e2e-test --host=test.localhost +``` + +To run these tests, the following items are required: +- setup an alias of localhost in your `hosts` file (eg `127.0.0.1 test.localhost`); note - you can use any alias. Use this alias in the command-line argument above. +- access to [BrowserStack](https://www.browserstack.com/) account. Assign the following variables in your bash_profile: +```bash +export BROWSERSTACK_USERNAME='YourUserNameHere' +export BROWSERSTACK_ACCESS_KEY='YourAccessKeyHere' +``` +You can get these BrowserStack values from your profile page. For development: diff --git a/allowedModules.js b/allowedModules.js new file mode 100644 index 00000000000..e66b8e24098 --- /dev/null +++ b/allowedModules.js @@ -0,0 +1,24 @@ + +const sharedWhiteList = [ + "core-js/library/fn/array/find", // no ie11 + "core-js/library/fn/array/includes", // no ie11 + "core-js/library/fn/set", // ie11 supports Set but not Set#values + "core-js/library/fn/string/includes", // no ie11 + "core-js/library/fn/number/is-integer", // no ie11, + "core-js/library/fn/array/from" // no ie11 +]; + +module.exports = { + 'modules': [ + ...sharedWhiteList, + 'jsencrypt', + 'crypto-js' + ], + 'src': [ + ...sharedWhiteList, + 'fun-hooks/no-eval', + 'just-clone', + 'dlv', + 'dset' + ] +}; diff --git a/browsers.json b/browsers.json index 703bf44d41d..9042d7d0627 100644 --- a/browsers.json +++ b/browsers.json @@ -1,9 +1,17 @@ { - "bs_ie_14_windows_10": { + "bs_edge_17_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "edge", - "browser_version": "14.0", + "browser_version": "17.0", + "device": null, + "os": "Windows" + }, + "bs_edge_16_windows_10": { + "base": "BrowserStack", + "os_version": "10", + "browser": "edge", + "browser_version": "16.0", "device": null, "os": "Windows" }, @@ -15,52 +23,52 @@ "device": null, "os": "Windows" }, - "bs_chrome_62_windows_10": { + "bs_chrome_74_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "chrome", - "browser_version": "62.0", + "browser_version": "74.0", "device": null, "os": "Windows" }, - "bs_chrome_61_windows_10": { + "bs_chrome_75_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "chrome", - "browser_version": "61.0", + "browser_version": "75.0", "device": null, "os": "Windows" }, - "bs_firefox_58_windows_10": { + "bs_firefox_66_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "firefox", - "browser_version": "58.0", + "browser_version": "66.0", "device": null, "os": "Windows" }, - "bs_firefox_57_windows_10": { + "bs_firefox_67_windows_10": { "base": "BrowserStack", "os_version": "10", "browser": "firefox", - "browser_version": "57.0", + "browser_version": "67.0", "device": null, "os": "Windows" }, - "bs_safari_9.1_mac_elcapitan": { + "bs_safari_11_mac_high_sierra": { "base": "BrowserStack", - "os_version": "El Capitan", + "os_version": "High Sierra", "browser": "safari", - "browser_version": "9.1", + "browser_version": "11.1", "device": null, "os": "OS X" }, - "bs_safari_8_mac_yosemite": { + "bs_safari_12_mac_mojave": { "base": "BrowserStack", - "os_version": "Yosemite", + "os_version": "Mojave", "browser": "safari", - "browser_version": "8.0", + "browser_version": "12.0", "device": null, "os": "OS X" } -} \ No newline at end of file +} diff --git a/gulpHelpers.js b/gulpHelpers.js index 33169da3773..84f01b4e966 100644 --- a/gulpHelpers.js +++ b/gulpHelpers.js @@ -3,17 +3,16 @@ const fs = require('fs.extra'); const path = require('path'); const argv = require('yargs').argv; const MANIFEST = 'package.json'; -const exec = require('child_process').exec; const through = require('through2'); const _ = require('lodash'); const gutil = require('gulp-util'); +const submodules = require('./modules/.submodules.json'); const MODULE_PATH = './modules'; const BUILD_PATH = './build/dist'; const DEV_PATH = './build/dev'; const ANALYTICS_PATH = '../analytics'; - // get only subdirectories that contain package.json with 'main' property function isModuleDirectory(filePath) { try { @@ -22,8 +21,7 @@ function isModuleDirectory(filePath) { const module = require(manifestPath); return module && module.main; } - } - catch (error) {} + } catch (error) {} } module.exports = { @@ -38,11 +36,13 @@ module.exports = { jsonifyHTML: function (str) { console.log(arguments); return str.replace(/\n/g, '') - .replace(/<\//g, '<\\/') - .replace(/\/>/g, '\\/>'); + .replace(/<\//g, '<\\/') + .replace(/\/>/g, '\\/>'); }, getArgModules() { - var modules = (argv.modules || '').split(',').filter(module => !!module); + var modules = (argv.modules || '') + .split(',') + .filter(module => !!module); try { if (modules.length === 1 && path.extname(modules[0]).toLowerCase() === '.json') { @@ -52,13 +52,22 @@ module.exports = { fs.readFileSync(moduleFile, 'utf8') ); } - } catch(e) { + } catch (e) { throw new gutil.PluginError({ plugin: 'modules', message: 'failed reading: ' + argv.modules }); } + Object.keys(submodules).forEach(parentModule => { + if ( + !modules.includes(parentModule) && + modules.some(module => submodules[parentModule].includes(module)) + ) { + modules.unshift(parentModule); + } + }); + return modules; }, getModules: _.memoize(function(externalModules) { @@ -72,19 +81,22 @@ module.exports = { var moduleName = file.split(new RegExp('[.\\' + path.sep + ']'))[0]; var modulePath = path.join(absoluteModulePath, file); if (fs.lstatSync(modulePath).isDirectory()) { - modulePath = path.join(modulePath, "index.js") + modulePath = path.join(modulePath, 'index.js') } memo[modulePath] = moduleName; return memo; }, {}); - } catch(err) { + } catch (err) { internalModules = {}; } return Object.assign(externalModules.reduce((memo, module) => { try { - var modulePath = require.resolve(module); + // prefer internal project modules before looking at project dependencies + var modulePath = require.resolve(module, {paths: ['./modules']}); + if (modulePath === '') modulePath = require.resolve(module); + memo[modulePath] = module; - } catch(err) { + } catch (err) { // do something } return memo; @@ -93,7 +105,7 @@ module.exports = { getBuiltModules: function(dev, externalModules) { var modules = this.getModuleNames(externalModules); - if(Array.isArray(externalModules)) { + if (Array.isArray(externalModules)) { modules = _.intersection(modules, externalModules); } return modules.map(name => path.join(__dirname, dev ? DEV_PATH : BUILD_PATH, name + '.js')); @@ -128,7 +140,7 @@ module.exports = { * Returns an array of source files for inclusion in build process */ getAnalyticsSources: function() { - if (!argv.analytics) {return [];} // empty arrays won't affect a standard build + if (!argv.analytics) { return []; } // empty arrays won't affect a standard build const directoryContents = fs.readdirSync(ANALYTICS_PATH); return directoryContents @@ -155,62 +167,5 @@ module.exports = { } return options; - }, - - createEnd2EndTestReport : function(targetDestinationDir) { - var browsers = require('./browsers.json'); - var env = []; - var input = 'bs'; - for(var key in browsers) { - if(key.substring(0, input.length) === input && browsers[key].browser !== 'iphone') { - env.push(key); - } - } - - //create new directory structure - fs.rmrfSync(targetDestinationDir); - env.forEach(item => { - fs.mkdirpSync(targetDestinationDir + '/' + item); - }); - - //move xml files to newly created directory - var walker = fs.walk('./build/coverage/e2e/reports'); - walker.on("file", function (root, stat, next) { - env.forEach(item => { - if(stat.name.search(item) !== -1) { - var src = root + '/' + stat.name; - var dest = targetDestinationDir + '/' + item + '/' + stat.name; - fs.copy(src, dest, {replace: true}, function(err) { - if(err) { - throw err; - } - }); - } - }); - next(); - }); - - //run junit-viewer to read xml and create html - env.forEach(item => { - //junit-viewer --results="./custom-reports/chrome51" --save="./chrome.html" - var cmd = 'junit-viewer --results="' + targetDestinationDir + '/' + item + '" --save="' + targetDestinationDir + '/' + item +'.html"'; - exec(cmd); - }); - - //create e2e-results.html - var html = '
+ This sample shows the simplest integration path for using DigiTrust ID with Prebid. + You can use DigiTrust ID without integrating the entire DigiTrust suite. +
+ + + ++ This sample shows the simplest integration path for using DigiTrust ID with Prebid. + You can use DigiTrust ID without integrating the entire DigiTrust suite. +
+ + +