├── .bowerrc ├── .editorconfig ├── .ember-cli ├── .eslintignore ├── .eslintrc.js ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── .npmignore ├── .prettierignore ├── .prettierrc.js ├── .template-lintrc.js ├── .travis.yml ├── .watchmanconfig ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── build_success_example.png ├── config ├── build-notifications.js ├── ember-try.js └── environment.js ├── ember-cli-build.js ├── ember-logo.png ├── example.png ├── index.js ├── lib ├── config.js ├── merge.js ├── notifier.js └── total-time.js ├── node-tests ├── fixtures │ └── config │ │ └── build-notifications.js └── unit │ ├── .gitkeep │ ├── config-test.js │ ├── notifier-test.js │ └── total-time-test.js ├── package.json ├── testem.js ├── tests ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── .gitkeep │ │ ├── resolver.js │ │ ├── router.js │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ └── templates │ │ │ ├── application.hbs │ │ │ └── components │ │ │ └── .gitkeep │ ├── config │ │ ├── ember-cli-update.json │ │ ├── ember-try.js │ │ ├── environment.js │ │ ├── optional-features.json │ │ └── targets.js │ └── public │ │ ├── crossdomain.xml │ │ └── robots.txt ├── helpers │ ├── index.js │ ├── resolver.js │ └── start-app.js ├── index.html └── test-helper.js └── yarn.lock /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.hbs] 16 | insert_final_newline = false 17 | 18 | [*.{diff,md}] 19 | trim_trailing_whitespace = false 20 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false, 9 | 10 | /** 11 | Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript 12 | rather than JavaScript by default, when a TypeScript version of a given blueprint is available. 13 | */ 14 | "isTypeScriptProject": false 15 | } 16 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | /node_modules/ 12 | 13 | # misc 14 | /coverage/ 15 | !.* 16 | .*/ 17 | .eslintcache 18 | 19 | # ember-try 20 | /.node_modules.ember-try/ 21 | /bower.json.ember-try 22 | /npm-shrinkwrap.json.ember-try 23 | /package.json.ember-try 24 | /package-lock.json.ember-try 25 | /yarn.lock.ember-try 26 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | ecmaVersion: 2018, 8 | sourceType: 'module', 9 | ecmaFeatures: { 10 | legacyDecorators: true, 11 | }, 12 | }, 13 | plugins: ['ember'], 14 | extends: [ 15 | 'eslint:recommended', 16 | 'plugin:ember/recommended', 17 | 'plugin:prettier/recommended', 18 | ], 19 | env: { 20 | browser: true, 21 | }, 22 | rules: {}, 23 | overrides: [ 24 | // node files 25 | { 26 | files: [ 27 | './.eslintrc.js', 28 | './.prettierrc.js', 29 | './.template-lintrc.js', 30 | './ember-cli-build.js', 31 | './index.js', 32 | './testem.js', 33 | './blueprints/*/index.js', 34 | './config/**/*.js', 35 | './tests/dummy/config/**/*.js', 36 | 'node-tests/**/*.js', 37 | 'lib/**/*.js', 38 | ], 39 | parserOptions: { 40 | sourceType: 'script', 41 | }, 42 | env: { 43 | browser: false, 44 | node: true, 45 | }, 46 | plugins: ['node'], 47 | extends: ['plugin:node/recommended'], 48 | }, 49 | { 50 | files: ['./config/ember-try.js', 'node-tests/**/*.js'], 51 | env: { 52 | node: true, 53 | }, 54 | plugins: ['mocha'], 55 | extends: ['plugin:mocha/recommended', 'plugin:node/recommended'], 56 | rules: { 57 | 'node/no-unpublished-require': 'off', 58 | }, 59 | }, 60 | { 61 | // test files 62 | files: ['tests/**/*-test.{js,ts}'], 63 | extends: ['plugin:qunit/recommended'], 64 | }, 65 | ], 66 | }; 67 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | day: "friday" 13 | open-pull-requests-limit: 10 14 | 15 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | pull_request: {} 9 | 10 | concurrency: 11 | group: ci-${{ github.head_ref || github.ref }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | test: 16 | name: "Tests" 17 | runs-on: ubuntu-latest 18 | timeout-minutes: 10 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | - name: Install Node 23 | uses: actions/setup-node@v3 24 | with: 25 | node-version: 14.x 26 | cache: yarn 27 | - name: Install Dependencies 28 | run: yarn install --frozen-lockfile 29 | - name: Lint 30 | run: yarn lint 31 | - name: Run Tests 32 | run: yarn test:node 33 | 34 | floating: 35 | name: "Floating Dependencies" 36 | runs-on: ubuntu-latest 37 | timeout-minutes: 10 38 | 39 | steps: 40 | - uses: actions/checkout@v3 41 | - uses: actions/setup-node@v3 42 | with: 43 | node-version: 14.x 44 | cache: yarn 45 | - name: Install Dependencies 46 | run: yarn install --no-lockfile 47 | - name: Run Tests 48 | run: yarn test:node 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist/ 5 | /tmp/ 6 | 7 | # dependencies 8 | /bower_components/ 9 | /node_modules/ 10 | 11 | # misc 12 | /.env* 13 | /.pnp* 14 | /.sass-cache 15 | /.eslintcache 16 | /connect.lock 17 | /coverage/ 18 | /libpeerconnection.log 19 | /npm-debug.log* 20 | /testem.log 21 | /yarn-error.log 22 | 23 | # ember-try 24 | /.node_modules.ember-try/ 25 | /bower.json.ember-try 26 | /npm-shrinkwrap.json.ember-try 27 | /package.json.ember-try 28 | /package-lock.json.ember-try 29 | /yarn.lock.ember-try 30 | 31 | # broccoli-debug 32 | /DEBUG/ 33 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist/ 3 | /tmp/ 4 | 5 | # dependencies 6 | /bower_components/ 7 | 8 | # misc 9 | /.bowerrc 10 | /.editorconfig 11 | /.ember-cli 12 | /.env* 13 | /.eslintcache 14 | /.eslintignore 15 | /.eslintrc.js 16 | /.git/ 17 | /.github/ 18 | /.gitignore 19 | /.prettierignore 20 | /.prettierrc.js 21 | /.template-lintrc.js 22 | /.travis.yml 23 | /.watchmanconfig 24 | /bower.json 25 | /CONTRIBUTING.md 26 | /ember-cli-build.js 27 | /testem.js 28 | /tests/ 29 | /yarn-error.log 30 | /yarn.lock 31 | .gitkeep 32 | 33 | # ember-try 34 | /.node_modules.ember-try/ 35 | /bower.json.ember-try 36 | /npm-shrinkwrap.json.ember-try 37 | /package.json.ember-try 38 | /package-lock.json.ember-try 39 | /yarn.lock.ember-try 40 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | /node_modules/ 12 | 13 | # misc 14 | /coverage/ 15 | !.* 16 | .eslintcache 17 | .lint-todo/ 18 | 19 | # ember-try 20 | /.node_modules.ember-try/ 21 | /bower.json.ember-try 22 | /npm-shrinkwrap.json.ember-try 23 | /package.json.ember-try 24 | /package-lock.json.ember-try 25 | /yarn.lock.ember-try 26 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | singleQuote: true, 5 | }; 6 | -------------------------------------------------------------------------------- /.template-lintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'recommended', 5 | }; 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | # we recommend testing addons with the same minimum supported node version as Ember CLI 5 | # so that your addon works for all apps 6 | - "12" 7 | 8 | dist: xenial 9 | 10 | addons: 11 | chrome: stable 12 | 13 | cache: 14 | yarn: true 15 | 16 | env: 17 | global: 18 | # See https://git.io/vdao3 for details. 19 | - JOBS=1 20 | 21 | jobs: 22 | fast_finish: true 23 | allow_failures: 24 | - env: EMBER_TRY_SCENARIO=ember-canary 25 | 26 | include: 27 | # runs linting and tests with current locked deps 28 | - stage: "Tests" 29 | name: "Tests" 30 | script: 31 | - yarn lint 32 | - yarn test:ember 33 | 34 | - stage: "Additional Tests" 35 | name: "Floating Dependencies" 36 | install: 37 | - yarn install --no-lockfile --non-interactive 38 | script: 39 | - yarn test:ember 40 | 41 | # we recommend new addons test the current and previous LTS 42 | # as well as latest stable release (bonus points to beta/canary) 43 | - env: EMBER_TRY_SCENARIO=ember-lts-3.24 44 | - env: EMBER_TRY_SCENARIO=ember-lts-3.28 45 | - env: EMBER_TRY_SCENARIO=ember-release 46 | - env: EMBER_TRY_SCENARIO=ember-beta 47 | - env: EMBER_TRY_SCENARIO=ember-canary 48 | - env: EMBER_TRY_SCENARIO=ember-default-with-jquery 49 | - env: EMBER_TRY_SCENARIO=ember-classic 50 | - env: EMBER_TRY_SCENARIO=embroider-safe 51 | - env: EMBER_TRY_SCENARIO=embroider-optimized 52 | 53 | before_install: 54 | - curl -o- -L https://yarnpkg.com/install.sh | bash 55 | - export PATH=$HOME/.yarn/bin:$PATH 56 | 57 | script: 58 | - yarn run nodetest 59 | - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO 60 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How To Contribute 2 | 3 | ## Installation 4 | 5 | * `git clone ` 6 | * `cd ember-cli-build-notifications` 7 | * `yarn install` 8 | 9 | ## Linting 10 | 11 | * `yarn lint` 12 | * `yarn lint:fix` 13 | 14 | ## Running tests 15 | 16 | * `ember test` – Runs the test suite on the current Ember version 17 | * `ember test --server` – Runs the test suite in "watch mode" 18 | * `ember try:each` – Runs the test suite against multiple Ember versions 19 | * `yarn nodetest` – Runs the node test suite 20 | 21 | ## Running the dummy application 22 | 23 | * `ember serve` 24 | * Visit the dummy application at [http://localhost:4200](http://localhost:4200). 25 | 26 | For more information on using ember-cli, visit [https://cli.emberjs.com/release/](https://cli.emberjs.com/release/). 27 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ember-cli-build-notifications 2 | 3 | [![npm version](https://badge.fury.io/js/ember-cli-build-notifications.svg)](https://badge.fury.io/js/ember-cli-build-notifications) 4 | [![Build Status](https://travis-ci.org/pdud/ember-cli-build-notifications.svg?branch=master)](https://travis-ci.org/pdud/ember-cli-build-notifications) 5 | [![Ember Observer Score](https://emberobserver.com/badges/ember-cli-build-notifications.svg)](https://emberobserver.com/addons/ember-cli-build-notifications) 6 | 7 | This addon adds support for Linux, Mac OS X and Windows alerts when ember-cli has a buildError and postBuild (when the build is successful). 8 | 9 | ![image](example.png) 10 | ![image](build_success_example.png) 11 | 12 | ## Compatibility 13 | 14 | * Ember.js v3.28 or above 15 | * Ember CLI v3.28 or above 16 | * Node.js v14 or above 17 | 18 | 19 | ## Installation 20 | 21 | ``` 22 | ember install ember-cli-build-notifications 23 | ``` 24 | 25 | 26 | ## Usage 27 | 28 | | Config Options | Ember CLI Build Event | Default | 29 | | -------------- |:----------------------|:-------:| 30 | | buildError | buildError | true | 31 | | buildSuccess | postBuild | false | 32 | 33 | To override defaults, add the following to the config file `{app-name}/config/build-notifications.js`: 34 | 35 | ```javascript 36 | module.exports = { 37 | buildError: { 38 | notify: true, 39 | notificationOptions: { 40 | sound: true 41 | } 42 | }, 43 | buildSuccess: { 44 | notify: true, 45 | notificationOptions: { 46 | sound: true 47 | } 48 | } 49 | }; 50 | ``` 51 | 52 | The `notificationOptions` settings are passed directly into node-notifier, see their [docs](https://github.com/mikaelbr/node-notifier#all-notification-options-with-their-defaults) for a full list of available settings 53 | 54 | ### Requirements 55 | 56 | - **Mac OS X**: >= 10.8 or Growl if earlier. 57 | - **Linux**: notify-osd installed (Ubuntu should have this by default) 58 | - **Windows**: >= 8, task bar balloon if earlier or Growl if that is installed. 59 | - **General Fallback**: Growl 60 | 61 | Powered by [mikaelbr/node-notifier](https://github.com/mikaelbr/node-notifier) and it's [dependencies](https://github.com/mikaelbr/node-notifier#thanks-to-oss). 62 | 63 | ## Contributing 64 | 65 | See the [Contributing](CONTRIBUTING.md) guide for details. 66 | 67 | ## Acknowledgment 68 | 69 | * Made possible by: [https://github.com/ember-cli/ember-cli/pull/2832](https://github.com/ember-cli/ember-cli/pull/2832) 70 | * Inspired by: [https://github.com/dylang/grunt-notify](https://github.com/dylang/grunt-notify) 71 | * Mocha setup from: [https://github.com/rwjblue/ember-cli-divshot](https://github.com/rwjblue/ember-cli-divshot) 72 | 73 | ## License 74 | 75 | This project is licensed under the [MIT License](LICENSE.md). 76 | -------------------------------------------------------------------------------- /build_success_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/build_success_example.png -------------------------------------------------------------------------------- /config/build-notifications.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | buildError: { 5 | notify: true, 6 | }, 7 | buildSuccess: { 8 | notify: true, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); 5 | 6 | module.exports = async function () { 7 | return { 8 | useYarn: true, 9 | scenarios: [ 10 | { 11 | name: 'ember-lts-3.24', 12 | npm: { 13 | devDependencies: { 14 | 'ember-source': '~3.24.3', 15 | }, 16 | }, 17 | }, 18 | { 19 | name: 'ember-lts-3.28', 20 | npm: { 21 | devDependencies: { 22 | 'ember-source': '~3.28.0', 23 | }, 24 | }, 25 | }, 26 | { 27 | name: 'ember-release', 28 | npm: { 29 | devDependencies: { 30 | 'ember-source': await getChannelURL('release'), 31 | }, 32 | }, 33 | }, 34 | { 35 | name: 'ember-beta', 36 | npm: { 37 | devDependencies: { 38 | 'ember-source': await getChannelURL('beta'), 39 | }, 40 | }, 41 | }, 42 | { 43 | name: 'ember-canary', 44 | npm: { 45 | devDependencies: { 46 | 'ember-source': await getChannelURL('canary'), 47 | }, 48 | }, 49 | }, 50 | { 51 | name: 'ember-classic', 52 | env: { 53 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 54 | 'application-template-wrapper': true, 55 | 'default-async-observers': false, 56 | 'template-only-glimmer-components': false, 57 | }), 58 | }, 59 | npm: { 60 | devDependencies: { 61 | 'ember-source': '~3.28.0', 62 | }, 63 | ember: { 64 | edition: 'classic', 65 | }, 66 | }, 67 | }, 68 | embroiderSafe(), 69 | embroiderOptimized(), 70 | ], 71 | }; 72 | }; 73 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function (/* environment, appConfig */) { 4 | return {}; 5 | }; 6 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function (defaults) { 6 | const app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | const { maybeEmbroider } = require('@embroider/test-setup'); 18 | return maybeEmbroider(app, { 19 | skipBabel: [ 20 | { 21 | package: 'qunit', 22 | }, 23 | ], 24 | }); 25 | }; 26 | -------------------------------------------------------------------------------- /ember-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/ember-logo.png -------------------------------------------------------------------------------- /example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/example.png -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const notifier = require('./lib/notifier'); 4 | const Config = require('./lib/config'); 5 | 6 | module.exports = { 7 | name: require('./package').name, 8 | 9 | buildError(error) { 10 | const config = Config.load(this.project.root); 11 | 12 | if (config.buildError.notify) { 13 | notifier.buildError(error, config.buildError); 14 | } 15 | }, 16 | 17 | postBuild(results) { 18 | const config = Config.load(this.project.root); 19 | 20 | if (config.buildSuccess.notify) { 21 | notifier.buildSuccess(results, config.buildSuccess); 22 | } 23 | }, 24 | }; 25 | -------------------------------------------------------------------------------- /lib/config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const merge = require('./merge'); 6 | 7 | const defaults = { 8 | buildError: { 9 | notify: true, 10 | notificationOptions: {}, 11 | }, 12 | 13 | buildSuccess: { 14 | notify: false, 15 | notificationOptions: {}, 16 | }, 17 | }; 18 | 19 | module.exports = class Config { 20 | static load(root) { 21 | const configPath = 'config/build-notifications.js'; 22 | let config = {}; 23 | 24 | if (root && fs.existsSync(path.join(root, configPath))) { 25 | config = require(path.join(root, configPath)); 26 | } 27 | 28 | return new Config(merge(defaults, config)); 29 | } 30 | 31 | constructor(attrs) { 32 | this.buildError = attrs.buildError; 33 | this.buildSuccess = attrs.buildSuccess; 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /lib/merge.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function merge(defaults, attrs) { 4 | for (let key in attrs) { 5 | if (Object.prototype.hasOwnProperty.call(attrs, key)) { 6 | if (typeof attrs[key] === 'object') { 7 | defaults[key] = merge(defaults[key], attrs[key]); 8 | } else { 9 | defaults[key] = attrs[key]; 10 | } 11 | } 12 | } 13 | 14 | return defaults; 15 | }; 16 | -------------------------------------------------------------------------------- /lib/notifier.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const nodeNotifier = require('node-notifier'); 4 | const path = require('path'); 5 | const merge = require('./merge'); 6 | const totalTime = require('./total-time'); 7 | const notificationGroup = 'ember-cli-build-notifications'; 8 | 9 | module.exports = { 10 | buildSuccess(results, options) { 11 | const notifier = (options && options.notifier) || nodeNotifier; 12 | let notificationOptions = { 13 | title: 'Build Succeeded', 14 | message: 'Build Time: ' + totalTime(results), 15 | appIcon: path.resolve(__dirname, '..', 'ember-logo.png'), 16 | group: notificationGroup, 17 | }; 18 | 19 | if (options && options.notificationOptions) { 20 | notificationOptions = merge( 21 | notificationOptions, 22 | options.notificationOptions 23 | ); 24 | } 25 | 26 | return notifier.notify(notificationOptions); 27 | }, 28 | 29 | buildError(error, options) { 30 | const notifier = (options && options.notifier) || nodeNotifier; 31 | let notificationOptions = { 32 | title: 'Build Failed', 33 | subtitle: error.file, 34 | message: error.toString(), 35 | appIcon: path.resolve(__dirname, '..', 'ember-logo.png'), 36 | group: notificationGroup, 37 | }; 38 | 39 | if (options && options.notificationOptions) { 40 | notificationOptions = merge( 41 | notificationOptions, 42 | options.notificationOptions 43 | ); 44 | } 45 | 46 | return notifier.notify(notificationOptions); 47 | }, 48 | }; 49 | -------------------------------------------------------------------------------- /lib/total-time.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const graph = require('heimdalljs-graph'); 4 | 5 | // https://github.com/ember-cli/ember-cli/blob/v3.2.0-beta.1/lib/models/instrumentation.js#L262,L292 6 | const totalTimeFromTree = function (tree) { 7 | let totalTime = 0; 8 | let nodeItr; 9 | let node; 10 | let statName; 11 | let statValue; 12 | let statsItr; 13 | let nextNode; 14 | let nextStat; 15 | 16 | for (nodeItr = tree.dfsIterator(); ; ) { 17 | nextNode = nodeItr.next(); 18 | if (nextNode.done) { 19 | break; 20 | } 21 | 22 | node = nextNode.value; 23 | 24 | for (statsItr = node.statsIterator(); ; ) { 25 | nextStat = statsItr.next(); 26 | if (nextStat.done) { 27 | break; 28 | } 29 | 30 | statName = nextStat.value[0]; 31 | statValue = nextStat.value[1]; 32 | 33 | if (statName === 'time.self') { 34 | totalTime += statValue; 35 | } 36 | } 37 | } 38 | 39 | return totalTime; 40 | }; 41 | 42 | module.exports = function totalTime(results) { 43 | let buildTime = results.totalTime; 44 | 45 | if (!results.totalTime && results.graph && results.graph.__heimdall__) { 46 | let buildTree = graph.loadFromNode(results.graph.__heimdall__); 47 | buildTime = totalTimeFromTree(buildTree); 48 | } 49 | 50 | if (buildTime) { 51 | return Math.round(buildTime / 1e6) + 'ms'; 52 | } else { 53 | return 'unavailable'; 54 | } 55 | }; 56 | -------------------------------------------------------------------------------- /node-tests/fixtures/config/build-notifications.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | buildError: { 5 | notify: false, 6 | }, 7 | buildSuccess: { 8 | notify: true, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /node-tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/node-tests/unit/.gitkeep -------------------------------------------------------------------------------- /node-tests/unit/config-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Config = require('../../lib/config'); 4 | const path = require('path'); 5 | const expect = require('chai').expect; 6 | 7 | describe('load', function () { 8 | it('initializes with defaults', function () { 9 | const config = Config.load(); 10 | 11 | expect(config.buildError.notify).to.eq(true); 12 | expect(config.buildSuccess.notify).to.eq(false); 13 | }); 14 | 15 | it('allows settings in config to take precedence', function () { 16 | const config = Config.load(path.join(__dirname, '..', 'fixtures')); 17 | 18 | expect(config.buildError.notify).to.eq(false); 19 | expect(config.buildSuccess.notify).to.eq(true); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /node-tests/unit/notifier-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const notifier = require('../../lib/notifier'); 4 | const expect = require('chai').expect; 5 | 6 | describe('notifier', function () { 7 | const fakeNodeNotifier = { 8 | name: 'fakeNodeNotifier', 9 | notify(options) { 10 | return options; 11 | }, 12 | }; 13 | 14 | describe('buildError', function () { 15 | it('sends the correct options to node-notifier', function () { 16 | notifier.nodeNotifier = fakeNodeNotifier; 17 | const error = { 18 | file: 'application.hbs', 19 | toString() { 20 | return 'Something went wrong'; 21 | }, 22 | }; 23 | 24 | const notification = notifier.buildError(error, { 25 | notifier: fakeNodeNotifier, 26 | notificationOptions: { 27 | sound: true, 28 | }, 29 | }); 30 | 31 | expect(notification.title).to.equal('Build Failed'); 32 | expect(notification.subtitle).to.equal(error.file); 33 | expect(notification.message).to.equal(error.toString()); 34 | expect(notification.appIcon).to.include('ember-logo.png'); 35 | expect(notification.sound).to.equal(true); 36 | }); 37 | 38 | it('allows settings in config to take precedence', function () { 39 | notifier.nodeNotifier = fakeNodeNotifier; 40 | const error = { 41 | file: 'application.hbs', 42 | toString() { 43 | return 'Something went wrong'; 44 | }, 45 | }; 46 | 47 | const notification = notifier.buildError(error, { 48 | notifier: fakeNodeNotifier, 49 | notificationOptions: { 50 | subtitle: 'Test String', 51 | }, 52 | }); 53 | 54 | expect(notification.title).to.equal('Build Failed'); 55 | expect(notification.subtitle).to.equal('Test String'); 56 | }); 57 | }); 58 | 59 | describe('buildSuccess', function () { 60 | it('sends the correct options to node-notifier', function () { 61 | notifier.nodeNotifier = fakeNodeNotifier; 62 | const results = { 63 | totalTime: 121000000, 64 | }; 65 | 66 | const notification = notifier.buildSuccess(results, { 67 | notifier: fakeNodeNotifier, 68 | notificationOptions: { 69 | sound: true, 70 | }, 71 | }); 72 | 73 | expect(notification.title).to.equal('Build Succeeded'); 74 | expect(notification.message).to.equal('Build Time: 121ms'); 75 | expect(notification.appIcon).to.include('ember-logo.png'); 76 | expect(notification.sound).to.equal(true); 77 | }); 78 | 79 | it('allows settings in config to take precedence', function () { 80 | notifier.nodeNotifier = fakeNodeNotifier; 81 | const results = { 82 | totalTime: 121000000, 83 | }; 84 | const notification = notifier.buildSuccess(results, { 85 | notifier: fakeNodeNotifier, 86 | notificationOptions: { 87 | message: 'Test String', 88 | }, 89 | }); 90 | 91 | expect(notification.title).to.equal('Build Succeeded'); 92 | expect(notification.message).to.equal('Test String'); 93 | }); 94 | }); 95 | }); 96 | -------------------------------------------------------------------------------- /node-tests/unit/total-time-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const totalTime = require('../../lib/total-time'); 4 | const expect = require('chai').expect; 5 | const Heimdall = require('heimdalljs/heimdall'); 6 | 7 | describe('totalTime', function () { 8 | context('totalTime present', function () { 9 | it('returns the totalTime', function () { 10 | const results = { 11 | totalTime: 121000000, 12 | }; 13 | 14 | expect(totalTime(results)).to.equal('121ms'); 15 | }); 16 | }); 17 | 18 | context('totalTime not present, graph.__heimdall__ present', function () { 19 | it('uses graph.__heimdall__ to calculate the buildTime', function () { 20 | let heimdall = new Heimdall(); 21 | let root; 22 | let a1 = heimdall.start({ 23 | name: 'a1', 24 | broccoliNode: true, 25 | broccoliCachedNode: false, 26 | }); 27 | root = heimdall.current; 28 | let b1 = heimdall.start({ name: 'b1' }); 29 | let c1 = heimdall.start({ 30 | name: 'c1', 31 | broccoliNode: true, 32 | broccoliCachedNode: true, 33 | }); 34 | c1.stop(); 35 | let c2 = heimdall.start({ 36 | name: 'c2', 37 | broccoliNode: true, 38 | broccoliCachedNode: false, 39 | }); 40 | c2.stop(); 41 | b1.stop(); 42 | a1.stop(); 43 | 44 | const results = { 45 | graph: { 46 | __heimdall__: root, 47 | }, 48 | }; 49 | 50 | expect(parseInt(totalTime(results).replace(/\D/g, ''))).to.be.within( 51 | 0, 52 | 200 53 | ); 54 | }); 55 | }); 56 | 57 | context('totalTime not present, graph.__heimdall__ not present', function () { 58 | it('returns "unavailable"', function () { 59 | const results = {}; 60 | 61 | expect(totalTime(results)).to.equal('unavailable'); 62 | }); 63 | }); 64 | }); 65 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-build-notifications", 3 | "version": "2.0.0", 4 | "description": "Notifications when ember-cli has a buildError", 5 | "keywords": [ 6 | "ember-addon" 7 | ], 8 | "repository": "https://github.com/pdud/ember-cli-build-notifications", 9 | "license": "MIT", 10 | "author": "", 11 | "directories": { 12 | "doc": "doc", 13 | "test": "tests" 14 | }, 15 | "scripts": { 16 | "build": "ember build --environment=production", 17 | "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", 18 | "lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"", 19 | "lint:hbs": "ember-template-lint .", 20 | "lint:hbs:fix": "ember-template-lint . --fix", 21 | "lint:js": "eslint . --cache", 22 | "lint:js:fix": "eslint . --fix", 23 | "start": "ember serve", 24 | "test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"", 25 | "test:ember": "ember test", 26 | "test:ember-compatibility": "ember try:each", 27 | "test:node": "mocha node-tests --recursive --timeout 5000" 28 | }, 29 | "dependencies": { 30 | "ember-cli-babel": "^7.26.11", 31 | "heimdalljs-graph": "^1.0.0", 32 | "node-notifier": "^10.0.0", 33 | "ember-cli-htmlbars": "^6.1.1" 34 | }, 35 | "devDependencies": { 36 | "@ember/optional-features": "^2.0.0", 37 | "@ember/test-helpers": "^2.8.1", 38 | "@embroider/test-setup": "^2.0.2", 39 | "@glimmer/component": "^1.1.2", 40 | "@glimmer/tracking": "^1.1.2", 41 | "babel-eslint": "^10.1.0", 42 | "broccoli-asset-rev": "^3.0.0", 43 | "chai": "^4.3.6", 44 | "concurrently": "^7.6.0", 45 | "ember-auto-import": "^2.5.0", 46 | "ember-cli": "~4.10.0", 47 | "ember-cli-dependency-checker": "^3.3.1", 48 | "ember-cli-inject-live-reload": "^2.1.0", 49 | "ember-cli-sri": "^2.1.1", 50 | "ember-cli-terser": "^4.0.2", 51 | "ember-load-initializers": "^2.1.2", 52 | "ember-page-title": "^7.0.0", 53 | "ember-qunit": "^6.0.0", 54 | "ember-resolver": "^9.0.1", 55 | "ember-source": "~4.11.0", 56 | "ember-source-channel-url": "^3.0.0", 57 | "ember-template-lint": "^5.2.0", 58 | "ember-try": "^2.0.0", 59 | "ember-welcome-page": "^6.2.0", 60 | "eslint": "^7.32.0", 61 | "eslint-config-prettier": "^8.5.0", 62 | "eslint-plugin-ember": "^11.2.1", 63 | "eslint-plugin-mocha": "^10.1.0", 64 | "eslint-plugin-node": "^11.1.0", 65 | "eslint-plugin-prettier": "^4.2.1", 66 | "eslint-plugin-qunit": "^7.3.4", 67 | "heimdalljs": "^0.2.6", 68 | "loader.js": "^4.7.0", 69 | "mocha": "^10.2.0", 70 | "prettier": "^2.8.1", 71 | "qunit": "^2.19.3", 72 | "qunit-dom": "^2.0.0", 73 | "webpack": "^5.75.0" 74 | }, 75 | "peerDependencies": { 76 | "ember-source": "^3.28.0 || ^4.0.0" 77 | }, 78 | "engines": { 79 | "node": "14.* || 16.* || >= 18" 80 | }, 81 | "ember": { 82 | "edition": "octane" 83 | }, 84 | "ember-addon": { 85 | "configPath": "tests/dummy/config" 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | test_page: 'tests/index.html?hidepassed', 5 | disable_watching: true, 6 | launch_in_ci: ['Chrome'], 7 | launch_in_dev: ['Chrome'], 8 | browser_start_timeout: 120, 9 | browser_args: { 10 | Chrome: { 11 | ci: [ 12 | // --no-sandbox is needed when running Chrome inside a container 13 | process.env.CI ? '--no-sandbox' : null, 14 | '--headless', 15 | '--disable-dev-shm-usage', 16 | '--disable-software-rasterizer', 17 | '--mute-audio', 18 | '--remote-debugging-port=0', 19 | '--window-size=1440,900', 20 | ].filter(Boolean), 21 | }, 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from 'ember-resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from 'dummy/config/environment'; 5 | 6 | export default class App extends Application { 7 | modulePrefix = config.modulePrefix; 8 | podModulePrefix = config.podModulePrefix; 9 | Resolver = Resolver; 10 | } 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/tests/dummy/app/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/tests/dummy/app/controllers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dummy 6 | 7 | 8 | 9 | {{content-for "head"}} 10 | 11 | 12 | 13 | 14 | {{content-for "head-footer"}} 15 | 16 | 17 | {{content-for "body"}} 18 | 19 | 20 | 21 | 22 | {{content-for "body-footer"}} 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/tests/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from 'dummy/config/environment'; 3 | 4 | export default class Router extends EmberRouter { 5 | location = config.locationType; 6 | rootURL = config.rootURL; 7 | } 8 | 9 | Router.map(function () {}); 10 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/tests/dummy/app/styles/app.css -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 | {{page-title "Dummy"}} 2 | 3 | {{!-- The following component displays Ember's default welcome message. --}} 4 | 5 | {{!-- Feel free to remove this! --}} 6 | 7 | {{outlet}} 8 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdud/ember-cli-build-notifications/e44f0eb85f612ed0e925922cdfb1a8360bfd1c8c/tests/dummy/app/templates/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/config/ember-cli-update.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0.0", 3 | "packages": [ 4 | { 5 | "name": "ember-cli", 6 | "version": "4.9.2", 7 | "blueprints": [ 8 | { 9 | "name": "addon", 10 | "outputRepo": "https://github.com/ember-cli/ember-addon-output", 11 | "codemodsSource": "ember-addon-codemods-manifest@1", 12 | "isBaseBlueprint": true, 13 | "options": [ 14 | "--welcome", 15 | "--yarn", 16 | "--ci-provider=github" 17 | ] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /tests/dummy/config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); 5 | 6 | module.exports = async function () { 7 | return { 8 | useYarn: true, 9 | scenarios: [ 10 | { 11 | name: 'ember-lts-3.28', 12 | npm: { 13 | devDependencies: { 14 | 'ember-source': '~3.28.0', 15 | }, 16 | }, 17 | }, 18 | { 19 | name: 'ember-lts-4.4', 20 | npm: { 21 | devDependencies: { 22 | 'ember-source': '~4.4.0', 23 | }, 24 | }, 25 | }, 26 | { 27 | name: 'ember-release', 28 | npm: { 29 | devDependencies: { 30 | 'ember-source': await getChannelURL('release'), 31 | }, 32 | }, 33 | }, 34 | { 35 | name: 'ember-beta', 36 | npm: { 37 | devDependencies: { 38 | 'ember-source': await getChannelURL('beta'), 39 | }, 40 | }, 41 | }, 42 | { 43 | name: 'ember-canary', 44 | npm: { 45 | devDependencies: { 46 | 'ember-source': await getChannelURL('canary'), 47 | }, 48 | }, 49 | }, 50 | { 51 | name: 'ember-classic', 52 | env: { 53 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 54 | 'application-template-wrapper': true, 55 | 'default-async-observers': false, 56 | 'template-only-glimmer-components': false, 57 | }), 58 | }, 59 | npm: { 60 | devDependencies: { 61 | 'ember-source': '~3.28.0', 62 | }, 63 | ember: { 64 | edition: 'classic', 65 | }, 66 | }, 67 | }, 68 | embroiderSafe(), 69 | embroiderOptimized(), 70 | ], 71 | }; 72 | }; 73 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function (environment) { 4 | const ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'history', 9 | EmberENV: { 10 | EXTEND_PROTOTYPES: false, 11 | FEATURES: { 12 | // Here you can enable experimental features on an ember canary build 13 | // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true 14 | }, 15 | }, 16 | 17 | APP: { 18 | // Here you can pass flags/options to your application instance 19 | // when it is created 20 | }, 21 | }; 22 | 23 | if (environment === 'development') { 24 | // ENV.APP.LOG_RESOLVER = true; 25 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 26 | // ENV.APP.LOG_TRANSITIONS = true; 27 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 28 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 29 | } 30 | 31 | if (environment === 'test') { 32 | // Testem prefers this... 33 | ENV.locationType = 'none'; 34 | 35 | // keep test console output quieter 36 | ENV.APP.LOG_ACTIVE_GENERATION = false; 37 | ENV.APP.LOG_VIEW_LOOKUPS = false; 38 | 39 | ENV.APP.rootElement = '#ember-testing'; 40 | ENV.APP.autoboot = false; 41 | } 42 | 43 | if (environment === 'production') { 44 | // here you can enable a production-specific feature 45 | } 46 | 47 | return ENV; 48 | }; 49 | -------------------------------------------------------------------------------- /tests/dummy/config/optional-features.json: -------------------------------------------------------------------------------- 1 | { 2 | "application-template-wrapper": false, 3 | "default-async-observers": true, 4 | "jquery-integration": false, 5 | "template-only-glimmer-components": true 6 | } 7 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const browsers = [ 4 | 'last 1 Chrome versions', 5 | 'last 1 Firefox versions', 6 | 'last 1 Safari versions', 7 | ]; 8 | 9 | module.exports = { 10 | browsers, 11 | }; 12 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/index.js: -------------------------------------------------------------------------------- 1 | import { 2 | setupApplicationTest as upstreamSetupApplicationTest, 3 | setupRenderingTest as upstreamSetupRenderingTest, 4 | setupTest as upstreamSetupTest, 5 | } from 'ember-qunit'; 6 | 7 | // This file exists to provide wrappers around ember-qunit's / ember-mocha's 8 | // test setup functions. This way, you can easily extend the setup that is 9 | // needed per test type. 10 | 11 | function setupApplicationTest(hooks, options) { 12 | upstreamSetupApplicationTest(hooks, options); 13 | 14 | // Additional setup for application tests can be done here. 15 | // 16 | // For example, if you need an authenticated session for each 17 | // application test, you could do: 18 | // 19 | // hooks.beforeEach(async function () { 20 | // await authenticateSession(); // ember-simple-auth 21 | // }); 22 | // 23 | // This is also a good place to call test setup functions coming 24 | // from other addons: 25 | // 26 | // setupIntl(hooks); // ember-intl 27 | // setupMirage(hooks); // ember-cli-mirage 28 | } 29 | 30 | function setupRenderingTest(hooks, options) { 31 | upstreamSetupRenderingTest(hooks, options); 32 | 33 | // Additional setup for rendering tests can be done here. 34 | } 35 | 36 | function setupTest(hooks, options) { 37 | upstreamSetupTest(hooks, options); 38 | 39 | // Additional setup for unit tests can be done here. 40 | } 41 | 42 | export { setupApplicationTest, setupRenderingTest, setupTest }; 43 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember/resolver'; 2 | import config from '../../config/environment'; 3 | 4 | var resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix, 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Application from '../../app'; 2 | import config from '../../config/environment'; 3 | import { merge } from '@ember/polyfills'; 4 | import { run } from '@ember/runloop'; 5 | 6 | export default function startApp(attrs) { 7 | let attributes = merge({}, config.APP); 8 | attributes = merge(attributes, attrs); // use defaults, but you can override; 9 | 10 | const application = run(() => { 11 | const application = Application.create(attributes); 12 | application.setupForTesting(); 13 | application.injectTestHelpers(); 14 | return application; 15 | }); 16 | 17 | return application; 18 | } 19 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dummy Tests 6 | 7 | 8 | 9 | {{content-for "head"}} 10 | {{content-for "test-head"}} 11 | 12 | 13 | 14 | 15 | 16 | {{content-for "head-footer"}} 17 | {{content-for "test-head-footer"}} 18 | 19 | 20 | {{content-for "body"}} 21 | {{content-for "test-body"}} 22 | 23 |
24 |
25 |
26 |
27 |
28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | {{content-for "body-footer"}} 37 | {{content-for "test-body-footer"}} 38 | 39 | 40 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from 'dummy/app'; 2 | import config from 'dummy/config/environment'; 3 | import * as QUnit from 'qunit'; 4 | import { setApplication } from '@ember/test-helpers'; 5 | import { setup } from 'qunit-dom'; 6 | import { start } from 'ember-qunit'; 7 | 8 | setApplication(Application.create(config.APP)); 9 | 10 | setup(QUnit.assert); 11 | 12 | start(); 13 | --------------------------------------------------------------------------------