From bd91013836c8194cb031b6c81825f460b779d6aa Mon Sep 17 00:00:00 2001 From: Nadav Shatz Date: Mon, 16 Dec 2019 19:52:29 +0200 Subject: [PATCH] Upgrade addon --- .eslintignore | 20 ++++ .eslintrc.js | 51 ++++++++- .gitignore | 24 +++-- .npmignore | 47 ++++---- .template-lintrc.js | 5 + .travis.yml | 48 +++++---- LICENSE.md | 2 +- README.md | 36 +++++-- config/ember-try.js | 124 +++++++++++----------- config/environment.js | 1 - ember-cli-build.js | 1 - index.js | 3 +- package.json | 62 ++++++----- testem.js | 12 ++- tests/.eslintrc.js | 5 - tests/dummy/app/app.js | 12 +-- tests/dummy/app/router.js | 10 +- tests/dummy/config/environment.js | 4 +- tests/dummy/config/optional-features.json | 3 + tests/dummy/config/targets.js | 23 ++-- tests/dummy/public/crossdomain.xml | 15 --- tests/helpers/.gitkeep | 0 tests/helpers/destroy-app.js | 5 - tests/helpers/module-for-acceptance.js | 21 ---- tests/helpers/start-app.js | 16 --- tests/test-helper.js | 3 +- 26 files changed, 305 insertions(+), 248 deletions(-) create mode 100644 .eslintignore create mode 100644 .template-lintrc.js delete mode 100644 tests/.eslintrc.js create mode 100644 tests/dummy/config/optional-features.json delete mode 100644 tests/dummy/public/crossdomain.xml create mode 100644 tests/helpers/.gitkeep delete mode 100644 tests/helpers/destroy-app.js delete mode 100644 tests/helpers/module-for-acceptance.js delete mode 100644 tests/helpers/start-app.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..72df373 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,20 @@ +# unconventional js +/blueprints/*/files/ +/vendor/ + +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ +/node_modules/ + +# misc +/coverage/ +!.* + +# ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/package.json.ember-try diff --git a/.eslintrc.js b/.eslintrc.js index 2873e2f..c4b7c41 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,13 +1,56 @@ module.exports = { root: true, + parser: 'babel-eslint', parserOptions: { - ecmaVersion: 2017, - sourceType: 'module' + ecmaVersion: 2018, + sourceType: 'module', + ecmaFeatures: { + legacyDecorators: true + } }, - extends: 'eslint:recommended', + plugins: [ + 'ember' + ], + extends: [ + 'eslint:recommended', + 'plugin:ember/recommended' + ], env: { browser: true }, rules: { - } + 'ember/no-jquery': 'error' + }, + overrides: [ + // node files + { + files: [ + '.eslintrc.js', + '.template-lintrc.js', + 'ember-cli-build.js', + 'index.js', + 'testem.js', + 'blueprints/*/index.js', + 'config/**/*.js', + 'tests/dummy/config/**/*.js' + ], + excludedFiles: [ + 'addon/**', + 'addon-test-support/**', + 'app/**', + 'tests/dummy/app/**' + ], + parserOptions: { + sourceType: 'script' + }, + env: { + browser: false, + node: true + }, + plugins: ['node'], + rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { + // add your custom rules and overrides for node files here + }) + } + ] }; diff --git a/.gitignore b/.gitignore index 8fa39a6..c40a1b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,25 @@ # See https://help.github.com/ignore-files/ for more about ignoring files. # compiled output -/dist -/tmp +/dist/ +/tmp/ # dependencies -/node_modules -/bower_components +/bower_components/ +/node_modules/ # misc +/.env* +/.pnp* /.sass-cache /connect.lock -/coverage/* +/coverage/ /libpeerconnection.log -npm-debug.log* -yarn-error.log -testem.log +/npm-debug.log* +/testem.log +/yarn-error.log # ember-try -.node_modules.ember-try/ -bower.json.ember-try -package.json.ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/package.json.ember-try diff --git a/.npmignore b/.npmignore index e07b078..81cd0a6 100644 --- a/.npmignore +++ b/.npmignore @@ -1,21 +1,32 @@ -/bower_components +# compiled output +/dist/ +/tmp/ + +# dependencies +/bower_components/ + +# misc +/.bowerrc +/.editorconfig +/.ember-cli.js +/.env* +/.eslintignore +/.eslintrc.js +/.git/ +/.gitignore +/.template-lintrc.js +/.travis.yml +/.watchmanconfig +/bower.json /config/ember-try.js -/dist -/tests -/tmp -**/.gitkeep -.bowerrc -.editorconfig -.ember-cli -.gitignore -.eslintrc.js -.watchmanconfig -.travis.yml -bower.json -ember-cli-build.js -testem.js +/CONTRIBUTING.md +/ember-cli-build.js +/testem.js +/tests/ +/yarn.lock +.gitkeep # ember-try -.node_modules.ember-try/ -bower.json.ember-try -package.json.ember-try +/.node_modules.ember-try/ +/bower.json.ember-try +/package.json.ember-try diff --git a/.template-lintrc.js b/.template-lintrc.js new file mode 100644 index 0000000..b45e96f --- /dev/null +++ b/.template-lintrc.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + extends: 'recommended' +}; diff --git a/.travis.yml b/.travis.yml index 38b4be7..4fe1962 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: node_js node_js: # we recommend testing addons with the same minimum supported node version as Ember CLI # so that your addon works for all apps - - "4" + - "8" sudo: false dist: trusty @@ -19,27 +19,33 @@ env: global: # See https://git.io/vdao3 for details. - JOBS=1 - matrix: + +branches: + only: + - master + # npm version tags + - /^v\d+\.\d+\.\d+/ + +jobs: + fail_fast: true + + include: + # runs linting and tests with current locked deps + + - stage: "Tests" + name: "Tests" + script: + - npm run lint:hbs + - npm run lint:js + - npm test + # we recommend new addons test the current and previous LTS # as well as latest stable release (bonus points to beta/canary) - - EMBER_TRY_SCENARIO=ember-lts-2.12 - - EMBER_TRY_SCENARIO=ember-lts-2.16 - - EMBER_TRY_SCENARIO=ember-release - - EMBER_TRY_SCENARIO=ember-beta - - EMBER_TRY_SCENARIO=ember-canary - - EMBER_TRY_SCENARIO=ember-default - -matrix: - fast_finish: true - allow_failures: - - env: EMBER_TRY_SCENARIO=ember-canary - -before_install: - - npm config set spin false - - npm install -g npm@4 - - npm --version + - stage: "Additional Tests" + env: EMBER_TRY_SCENARIO=ember-lts-3.4 + - env: EMBER_TRY_SCENARIO=ember-lts-3.8 + - env: EMBER_TRY_SCENARIO=ember-release + - env: EMBER_TRY_SCENARIO=ember-default-with-jquery script: - # Usually, it's ok to finish the test scenario without reverting - # to the addon's original dependency state, skipping "cleanup". - - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup + - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO diff --git a/LICENSE.md b/LICENSE.md index 0d5e3ef..f8d1edb 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 +Copyright (c) 2019 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 22a5e5f..81ac1d6 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,35 @@ -# Ember-cli-heap [![Ember Observer Score](https://emberobserver.com/badges/ember-cli-heap.svg)](https://emberobserver.com/addons/ember-cli-heap) +ember-cli-heap +============================================================================== + +[![Ember Observer Score](https://emberobserver.com/badges/ember-cli-heap.svg)](https://emberobserver.com/addons/ember-cli-heap) This ember-cli addon injects heap analytics into index.html. More info on heap at https://heapanalytics.com -## Installation -`ember install ember-cli-heap` -## Configuration +Compatibility +------------------------------------------------------------------------------ +* Ember.js v3.4 or above +* Ember CLI v2.13 or above +* Node.js v8 or above -This plugin uses the ember-cli project's configuration as defined in `config/environment.js`. +Installation +------------------------------------------------------------------------------ +`ember install ember-cli-heap` -Add your heap projectId to `config/environment.js` and you're good to go. +Configuration +------------------------------------------------------------------------------ +This plugin uses the ember-cli project's configuration as defined in `config/environment.js`. ```js // environment.js - ENV.heap = { projectId: 'xxxxxx' } ``` -## Disabling per environment +Add your heap projectId to `config/environment.js` and you're good to go. + You can disable injecting heap into different environments by setting the development param to true: @@ -39,7 +48,8 @@ if (environment === 'test') { This is completely unofficial and is not related to Heap Analytics in any way. -## Contributing +Contributing +------------------------------------------------------------------------------ 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) @@ -47,5 +57,11 @@ This is completely unofficial and is not related to Heap Analytics in any way. 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request -## About Tailor Brands +License +------------------------------------------------------------------------------ + +This project is licensed under the [MIT License](LICENSE.md). + +About Tailor Brands +------------------------------------------------------------------------------ [Check us out!](https://www.tailorbrands.com) diff --git a/config/ember-try.js b/config/ember-try.js index 3eea72b..b2a6651 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -1,75 +1,73 @@ -/* eslint-env node */ -module.exports = { - scenarios: [ - { - name: 'ember-lts-2.12', - npm: { - devDependencies: { - 'ember-source': '~2.12.0' +'use strict'; + +const getChannelURL = require('ember-source-channel-url'); + +module.exports = async function() { + return { + scenarios: [ + { + name: 'ember-lts-3.4', + npm: { + devDependencies: { + 'ember-source': '~3.4.0' + } } - } - }, - { - name: 'ember-lts-2.16', - npm: { - devDependencies: { - 'ember-source': '~2.16.0' - } - } - }, - { - name: 'ember-release', - bower: { - dependencies: { - 'ember': 'components/ember#release' - }, - resolutions: { - 'ember': 'release' + }, + { + name: 'ember-lts-3.8', + npm: { + devDependencies: { + 'ember-source': '~3.8.0' + } } }, - npm: { - devDependencies: { - 'ember-source': null + { + name: 'ember-release', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('release') + } } - } - }, - { - name: 'ember-beta', - bower: { - dependencies: { - 'ember': 'components/ember#beta' - }, - resolutions: { - 'ember': 'beta' + }, + { + name: 'ember-beta', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('beta') + } } }, - npm: { - devDependencies: { - 'ember-source': null + { + name: 'ember-canary', + npm: { + devDependencies: { + 'ember-source': await getChannelURL('canary') + } } - } - }, - { - name: 'ember-canary', - bower: { - dependencies: { - 'ember': 'components/ember#canary' - }, - resolutions: { - 'ember': 'canary' + }, + // The default `.travis.yml` runs this scenario via `npm test`, + // not via `ember try`. It's still included here so that running + // `ember try:each` manually or from a customized CI config will run it + // along with all the other scenarios. + { + name: 'ember-default', + npm: { + devDependencies: {} } }, - npm: { - devDependencies: { - 'ember-source': null + { + name: 'ember-default-with-jquery', + env: { + EMBER_OPTIONAL_FEATURES: JSON.stringify({ + 'jquery-integration': true + }) + }, + npm: { + devDependencies: { + '@ember/jquery': '^0.5.1' + } } } - }, - { - name: 'ember-default', - npm: { - devDependencies: {} - } - } - ] + ] + }; }; diff --git a/config/environment.js b/config/environment.js index 012a412..0dfaed4 100644 --- a/config/environment.js +++ b/config/environment.js @@ -1,4 +1,3 @@ -/* eslint-env node */ 'use strict'; module.exports = function(/* environment, appConfig */) { diff --git a/ember-cli-build.js b/ember-cli-build.js index 156e23f..dc5a39e 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -1,4 +1,3 @@ -/* eslint-env node */ 'use strict'; const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); diff --git a/index.js b/index.js index b140ded..757e2e3 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,7 @@ -/* eslint-env node */ 'use strict'; module.exports = { - name: 'ember-cli-heap', + name: require('./package').name, contentFor: function(type, config) { if (type === 'head-footer' && config.heap && !config.heap.development && config.heap.projectId) { diff --git a/package.json b/package.json index 98470fc..f41c848 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-heap", - "version": "2.0.1", + "version": "3.0.0", "description": "An Ember CLI Addon to add support for Heap Analytics", "keywords": [ "ember-addon", @@ -9,46 +9,56 @@ "analytics", "tracking" ], + "repository": { + "type": "git", + "url": "https://github.com/TailorBrands/ember-cli-heap.git" + }, "license": "MIT", - "author": "Nadav Shatz ", + "author": "Tailor Brands ", "directories": { "doc": "doc", "test": "tests" }, - "repository": { - "type": "git", - "url": "https://github.com/TailorBrands/ember-cli-heap.git" - }, "scripts": { "build": "ember build", + "lint:hbs": "ember-template-lint .", + "lint:js": "eslint .", "start": "ember serve", - "test": "ember try:each" + "test": "ember test", + "test:all": "ember try:each" }, "dependencies": { - "ember-cli-babel": "^6.6.0" + "ember-cli-babel": "^7.11.1", + "ember-cli-htmlbars": "^4.0.5" }, "devDependencies": { - "broccoli-asset-rev": "^2.4.5", - "ember-ajax": "^3.0.0", - "ember-cli": "~2.17.1", - "ember-cli-dependency-checker": "^2.0.0", - "ember-cli-eslint": "^4.2.1", - "ember-cli-htmlbars": "^2.0.1", - "ember-cli-htmlbars-inline-precompile": "^1.0.0", - "ember-cli-inject-live-reload": "^1.4.1", - "ember-cli-qunit": "^4.1.1", - "ember-cli-shims": "^1.2.0", - "ember-cli-sri": "^2.1.0", - "ember-cli-uglify": "^2.0.0", - "ember-disable-prototype-extensions": "^1.1.2", + "@ember/optional-features": "^1.0.0", + "babel-eslint": "^10.0.3", + "broccoli-asset-rev": "^3.0.0", + "ember-auto-import": "^1.5.2", + "ember-cli": "~3.14.0", + "ember-cli-dependency-checker": "^3.1.0", + "ember-cli-eslint": "^5.1.0", + "ember-cli-inject-live-reload": "^2.0.1", + "ember-cli-sri": "^2.1.1", + "ember-cli-template-lint": "^1.0.0-beta.3", + "ember-cli-uglify": "^3.0.0", + "ember-disable-prototype-extensions": "^1.1.3", "ember-export-application-global": "^2.0.0", - "ember-load-initializers": "^1.0.0", - "ember-resolver": "^4.0.0", - "ember-source": "~2.17.0", - "loader.js": "^4.2.3" + "ember-load-initializers": "^2.1.0", + "ember-maybe-import-regenerator": "^0.1.6", + "ember-qunit": "^4.5.1", + "ember-resolver": "^5.3.0", + "ember-source": "~3.14.1", + "ember-source-channel-url": "^2.0.1", + "ember-try": "^1.2.1", + "eslint-plugin-ember": "^7.1.0", + "eslint-plugin-node": "^10.0.0", + "loader.js": "^4.7.0", + "qunit-dom": "^0.9.0" }, "engines": { - "node": "^4.5 || 6.* || >= 7.*" + "node": "8.* || >= 10.*" }, "bugs": { "url": "https://github.com/TailorBrands/ember-cli-heap/issues" diff --git a/testem.js b/testem.js index 63d1edf..367f565 100644 --- a/testem.js +++ b/testem.js @@ -1,4 +1,3 @@ -/* eslint-env node */ module.exports = { test_page: 'tests/index.html?hidepassed', disable_watching: true, @@ -10,13 +9,16 @@ module.exports = { ], browser_args: { Chrome: { - mode: 'ci', - args: [ - '--disable-gpu', + ci: [ + // --no-sandbox is needed when running Chrome inside a container + process.env.CI ? '--no-sandbox' : null, '--headless', + '--disable-dev-shm-usage', + '--disable-software-rasterizer', + '--mute-audio', '--remote-debugging-port=0', '--window-size=1440,900' - ] + ].filter(Boolean) } } }; diff --git a/tests/.eslintrc.js b/tests/.eslintrc.js deleted file mode 100644 index fbf2555..0000000 --- a/tests/.eslintrc.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - env: { - embertest: true - } -}; diff --git a/tests/dummy/app/app.js b/tests/dummy/app/app.js index b3b2bd6..8df91db 100644 --- a/tests/dummy/app/app.js +++ b/tests/dummy/app/app.js @@ -3,12 +3,10 @@ import Resolver from './resolver'; import loadInitializers from 'ember-load-initializers'; import config from './config/environment'; -const App = Application.extend({ - modulePrefix: config.modulePrefix, - podModulePrefix: config.podModulePrefix, - Resolver -}); +export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; +} loadInitializers(App, config.modulePrefix); - -export default App; diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index d0bb009..224ca42 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -1,12 +1,10 @@ import EmberRouter from '@ember/routing/router'; import config from './config/environment'; -const Router = EmberRouter.extend({ - location: config.locationType, - rootURL: config.rootURL -}); +export default class Router extends EmberRouter { + location = config.locationType; + rootURL = config.rootURL; +} Router.map(function() { }); - -export default Router; diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js index 1d54915..9f23936 100644 --- a/tests/dummy/config/environment.js +++ b/tests/dummy/config/environment.js @@ -1,4 +1,3 @@ -/* eslint-env node */ 'use strict'; module.exports = function(environment) { @@ -10,7 +9,7 @@ module.exports = function(environment) { EmberENV: { FEATURES: { // Here you can enable experimental features on an ember canary build - // e.g. 'with-controller': true + // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true }, EXTEND_PROTOTYPES: { // Prevent Ember Data from overriding Date.parse. @@ -41,6 +40,7 @@ module.exports = function(environment) { ENV.APP.LOG_VIEW_LOOKUPS = false; ENV.APP.rootElement = '#ember-testing'; + ENV.APP.autoboot = false; } if (environment === 'production') { diff --git a/tests/dummy/config/optional-features.json b/tests/dummy/config/optional-features.json new file mode 100644 index 0000000..b190262 --- /dev/null +++ b/tests/dummy/config/optional-features.json @@ -0,0 +1,3 @@ +{ + "jquery-integration": false +} diff --git a/tests/dummy/config/targets.js b/tests/dummy/config/targets.js index df7664c..8ffae36 100644 --- a/tests/dummy/config/targets.js +++ b/tests/dummy/config/targets.js @@ -1,9 +1,18 @@ -/* eslint-env node */ +'use strict'; + +const browsers = [ + 'last 1 Chrome versions', + 'last 1 Firefox versions', + 'last 1 Safari versions' +]; + +const isCI = !!process.env.CI; +const isProduction = process.env.EMBER_ENV === 'production'; + +if (isCI || isProduction) { + browsers.push('ie 11'); +} + module.exports = { - browsers: [ - 'ie 9', - 'last 1 Chrome versions', - 'last 1 Firefox versions', - 'last 1 Safari versions' - ] + browsers }; diff --git a/tests/dummy/public/crossdomain.xml b/tests/dummy/public/crossdomain.xml deleted file mode 100644 index 0c16a7a..0000000 --- a/tests/dummy/public/crossdomain.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/tests/helpers/.gitkeep b/tests/helpers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/helpers/destroy-app.js b/tests/helpers/destroy-app.js deleted file mode 100644 index e7f983b..0000000 --- a/tests/helpers/destroy-app.js +++ /dev/null @@ -1,5 +0,0 @@ -import { run } from '@ember/runloop'; - -export default function destroyApp(application) { - run(application, 'destroy'); -} diff --git a/tests/helpers/module-for-acceptance.js b/tests/helpers/module-for-acceptance.js deleted file mode 100644 index 90a93ba..0000000 --- a/tests/helpers/module-for-acceptance.js +++ /dev/null @@ -1,21 +0,0 @@ -import { module } from 'qunit'; -import { resolve } from 'rsvp'; -import startApp from '../helpers/start-app'; -import destroyApp from '../helpers/destroy-app'; - -export default function(name, options = {}) { - module(name, { - beforeEach() { - this.application = startApp(); - - if (options.beforeEach) { - return options.beforeEach.apply(this, arguments); - } - }, - - afterEach() { - let afterEach = options.afterEach && options.afterEach.apply(this, arguments); - return resolve(afterEach).then(() => destroyApp(this.application)); - } - }); -} diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js deleted file mode 100644 index 681aa01..0000000 --- a/tests/helpers/start-app.js +++ /dev/null @@ -1,16 +0,0 @@ -import Application from '../../app'; -import config from '../../config/environment'; -import { merge } from '@ember/polyfills'; -import { run } from '@ember/runloop'; - -export default function startApp(attrs) { - let attributes = merge({}, config.APP); - attributes = merge(attributes, attrs); // use defaults, but you can override; - - return run(() => { - let application = Application.create(attributes); - application.setupForTesting(); - application.injectTestHelpers(); - return application; - }); -} diff --git a/tests/test-helper.js b/tests/test-helper.js index edc8122..0382a84 100644 --- a/tests/test-helper.js +++ b/tests/test-helper.js @@ -1,7 +1,8 @@ import Application from '../app'; +import config from '../config/environment'; import { setApplication } from '@ember/test-helpers'; import { start } from 'ember-qunit'; -setApplication(Application.create({ autoboot: false })); +setApplication(Application.create(config.APP)); start();