├── app └── .gitkeep ├── addon └── .gitkeep ├── vendor └── .gitkeep ├── tests ├── unit │ └── .gitkeep ├── integration │ └── .gitkeep ├── dummy │ ├── app │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── models │ │ │ └── .gitkeep │ │ ├── routes │ │ │ ├── .gitkeep │ │ │ └── application.js │ │ ├── styles │ │ │ └── app.css │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── templates │ │ │ ├── components │ │ │ │ └── .gitkeep │ │ │ └── application.hbs │ │ ├── resolver.js │ │ ├── router.js │ │ ├── app.js │ │ └── index.html │ ├── public │ │ ├── robots.txt │ │ └── crossdomain.xml │ └── config │ │ ├── targets.js │ │ └── environment.js ├── test-helper.js ├── acceptance │ └── pretender-test.js ├── .jshintrc └── index.html ├── .watchmanconfig ├── .bowerrc ├── config ├── environment.js └── ember-try.js ├── .eslintignore ├── .ember-cli ├── .npmignore ├── .editorconfig ├── .gitignore ├── ember-cli-build.js ├── .jshintrc ├── testem.js ├── LICENSE.md ├── .eslintrc.js ├── .travis.yml ├── README.md ├── RELEASE.md ├── package.json ├── CHANGELOG.md └── index.js /app/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /addon/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/integration/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/components/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 | {{model.status}} 2 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(/* environment, appConfig */) { 4 | return { }; 5 | }; 6 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | 12 | # misc 13 | /coverage/ 14 | 15 | # ember-try 16 | /.node_modules.ember-try/ 17 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from '../app'; 2 | import config from '../config/environment'; 3 | import { setApplication } from '@ember/test-helpers'; 4 | import { start } from 'ember-qunit'; 5 | 6 | setApplication(Application.create(config.APP)); 7 | 8 | start(); 9 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/application.js: -------------------------------------------------------------------------------- 1 | import Route from '@ember/routing/route'; 2 | import { inject as service } from '@ember/service'; 3 | 4 | export default Route.extend({ 5 | ajax: service(), 6 | 7 | model() { 8 | return this.get('ajax').request('/test-pretender'); 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from './config/environment'; 3 | 4 | const Router = EmberRouter.extend({ 5 | location: config.locationType, 6 | rootURL: config.rootURL 7 | }); 8 | 9 | Router.map(function() { 10 | }); 11 | 12 | export default Router; 13 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /bower_components 2 | /config/ember-try.js 3 | /dist 4 | /tests 5 | /tmp 6 | **/.gitkeep 7 | .bowerrc 8 | .editorconfig 9 | .ember-cli 10 | .eslintrc.js 11 | .gitignore 12 | .watchmanconfig 13 | .travis.yml 14 | bower.json 15 | ember-cli-build.js 16 | testem.js 17 | yarn.lock 18 | 19 | # ember-try 20 | .node_modules.ember-try/ 21 | bower.json.ember-try 22 | package.json.ember-try 23 | -------------------------------------------------------------------------------- /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 | const isCI = !!process.env.CI; 10 | const isProduction = process.env.EMBER_ENV === 'production'; 11 | 12 | if (isCI || isProduction) { 13 | browsers.push('ie 11'); 14 | } 15 | 16 | module.exports = { 17 | browsers 18 | }; 19 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | const App = Application.extend({ 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix, 9 | Resolver 10 | }); 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | 14 | export default App; 15 | -------------------------------------------------------------------------------- /.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 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.hbs] 17 | insert_final_newline = false 18 | 19 | [*.{diff,md}] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.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 | /.sass-cache 13 | /connect.lock 14 | /coverage/ 15 | /libpeerconnection.log 16 | /npm-debug.log* 17 | /testem.log 18 | /yarn-error.log 19 | 20 | # ember-try 21 | /.node_modules.ember-try/ 22 | /bower.json.ember-try 23 | /package.json.ember-try 24 | -------------------------------------------------------------------------------- /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 | let 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 | return app.toTree(); 18 | }; 19 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "-Promise" 6 | ], 7 | "browser": true, 8 | "boss": true, 9 | "curly": true, 10 | "debug": false, 11 | "devel": true, 12 | "eqeqeq": true, 13 | "evil": true, 14 | "forin": false, 15 | "immed": false, 16 | "laxbreak": false, 17 | "newcap": true, 18 | "noarg": true, 19 | "noempty": false, 20 | "nonew": false, 21 | "nomen": false, 22 | "onevar": false, 23 | "plusplus": false, 24 | "regexp": false, 25 | "undef": true, 26 | "sub": true, 27 | "strict": false, 28 | "white": false, 29 | "eqnull": true, 30 | "esversion": 6, 31 | "unused": true 32 | } 33 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | test_page: 'tests/index.html?hidepassed', 3 | disable_watching: true, 4 | launch_in_ci: [ 5 | 'Chrome' 6 | ], 7 | launch_in_dev: [ 8 | 'Chrome' 9 | ], 10 | browser_args: { 11 | Chrome: { 12 | ci: [ 13 | // --no-sandbox is needed when running Chrome inside a container 14 | process.env.CI ? '--no-sandbox' : null, 15 | '--headless', 16 | '--disable-gpu', 17 | '--disable-dev-shm-usage', 18 | '--disable-software-rasterizer', 19 | '--mute-audio', 20 | '--remote-debugging-port=0', 21 | '--window-size=1440,900' 22 | ].filter(Boolean) 23 | } 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /tests/acceptance/pretender-test.js: -------------------------------------------------------------------------------- 1 | import { module, test } from 'qunit'; 2 | import { visit, currentURL } from '@ember/test-helpers'; 3 | import { setupApplicationTest } from 'ember-qunit'; 4 | 5 | import Pretender from 'pretender'; 6 | 7 | module('Acceptance | pretender', function(hooks) { 8 | setupApplicationTest(hooks); 9 | 10 | test('visiting /', async function(assert) { 11 | let server = new Pretender(); 12 | 13 | server.get('/test-pretender', () => [200, {"Content-Type": "application/json"}, JSON.stringify({ status: 'ok' })]); 14 | 15 | await visit('/'); 16 | assert.equal(currentURL(), '/'); 17 | assert.equal(this.element.querySelector('#status').textContent, 'ok'); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "location", 6 | "setTimeout", 7 | "$", 8 | "-Promise", 9 | "define", 10 | "console", 11 | "visit", 12 | "exists", 13 | "fillIn", 14 | "click", 15 | "keyEvent", 16 | "triggerEvent", 17 | "find", 18 | "findWithAssert", 19 | "wait", 20 | "DS", 21 | "andThen", 22 | "currentURL", 23 | "currentPath", 24 | "currentRouteName" 25 | ], 26 | "node": false, 27 | "browser": false, 28 | "boss": true, 29 | "curly": true, 30 | "debug": false, 31 | "devel": false, 32 | "eqeqeq": true, 33 | "evil": true, 34 | "forin": false, 35 | "immed": false, 36 | "laxbreak": false, 37 | "newcap": true, 38 | "noarg": true, 39 | "noempty": false, 40 | "nonew": false, 41 | "nomen": false, 42 | "onevar": false, 43 | "plusplus": false, 44 | "regexp": false, 45 | "undef": true, 46 | "sub": true, 47 | "strict": false, 48 | "white": false, 49 | "eqnull": true, 50 | "esversion": 6, 51 | "unused": true 52 | } 53 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 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 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for "body-footer"}} 31 | {{content-for "test-body-footer"}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | ecmaVersion: 2017, 5 | sourceType: 'module' 6 | }, 7 | plugins: [ 8 | 'ember' 9 | ], 10 | extends: [ 11 | 'eslint:recommended', 12 | 'plugin:ember/recommended' 13 | ], 14 | env: { 15 | browser: true 16 | }, 17 | rules: { 18 | }, 19 | overrides: [ 20 | // node files 21 | { 22 | files: [ 23 | 'ember-cli-build.js', 24 | 'index.js', 25 | 'testem.js', 26 | 'blueprints/*/index.js', 27 | 'config/**/*.js', 28 | 'tests/dummy/config/**/*.js' 29 | ], 30 | excludedFiles: [ 31 | 'addon/**', 32 | 'addon-test-support/**', 33 | 'app/**', 34 | 'tests/dummy/app/**' 35 | ], 36 | parserOptions: { 37 | sourceType: 'script', 38 | ecmaVersion: 2015 39 | }, 40 | env: { 41 | browser: false, 42 | node: true 43 | }, 44 | plugins: ['node'], 45 | rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { 46 | // add your custom rules and overrides for node files here 47 | }) 48 | } 49 | ] 50 | }; 51 | -------------------------------------------------------------------------------- /.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 | - "10" 7 | 8 | sudo: false 9 | dist: trusty 10 | 11 | addons: 12 | chrome: stable 13 | 14 | cache: 15 | yarn: true 16 | 17 | env: 18 | global: 19 | # See https://git.io/vdao3 for details. 20 | - JOBS=1 21 | matrix: 22 | # we recommend new addons test the current and previous LTS 23 | # as well as latest stable release (bonus points to beta/canary) 24 | - EMBER_TRY_SCENARIO=ember-lts-2.12 25 | - EMBER_TRY_SCENARIO=ember-lts-2.16 26 | - EMBER_TRY_SCENARIO=ember-lts-2.18 27 | - EMBER_TRY_SCENARIO=ember-release 28 | - EMBER_TRY_SCENARIO=ember-beta 29 | - EMBER_TRY_SCENARIO=ember-canary 30 | - EMBER_TRY_SCENARIO=ember-default 31 | 32 | matrix: 33 | fast_finish: true 34 | allow_failures: 35 | - env: EMBER_TRY_SCENARIO=ember-canary 36 | 37 | before_install: 38 | - curl -o- -L https://yarnpkg.com/install.sh | bash 39 | - export PATH=$HOME/.yarn/bin:$PATH 40 | 41 | install: 42 | - yarn install --no-lockfile --non-interactive 43 | 44 | script: 45 | - yarn lint:js 46 | # Usually, it's ok to finish the test scenario without reverting 47 | # to the addon's original dependency state, skipping "cleanup". 48 | - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup 49 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function(environment) { 4 | let ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | }, 14 | EXTEND_PROTOTYPES: { 15 | // Prevent Ember Data from overriding Date.parse. 16 | Date: false 17 | } 18 | }, 19 | 20 | APP: { 21 | // Here you can pass flags/options to your application instance 22 | // when it is created 23 | } 24 | }; 25 | 26 | if (environment === 'development') { 27 | // ENV.APP.LOG_RESOLVER = true; 28 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 29 | // ENV.APP.LOG_TRANSITIONS = true; 30 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 31 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 32 | } 33 | 34 | if (environment === 'test') { 35 | // Testem prefers this... 36 | ENV.locationType = 'none'; 37 | 38 | // keep test console output quieter 39 | ENV.APP.LOG_ACTIVE_GENERATION = false; 40 | ENV.APP.LOG_VIEW_LOOKUPS = false; 41 | 42 | ENV.APP.rootElement = '#ember-testing'; 43 | ENV.APP.autoboot = false; 44 | } 45 | 46 | if (environment === 'production') { 47 | // here you can enable a production-specific feature 48 | } 49 | 50 | return ENV; 51 | }; 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ember-cli-pretender 2 | =================== 3 | 4 | Simple wrapper for pretender.js, this project removes the need for the 5 | developer to know which files need to be imported. 6 | 7 | NOTE: Please use [pretender](https://github.com/pretenderjs/pretender) directly instead. Use [ember-auto-import](https://github.com/ef4/ember-auto-import) to import pretender without the need for ember-cli-pretender to add it via app.imports. 8 | 9 | Usage 10 | ===== 11 | 12 | ```sh 13 | ember install ember-cli-pretender 14 | ``` 15 | 16 | You can then import Pretender in your tests: 17 | 18 | ```javascript 19 | import Pretender from 'pretender'; 20 | ``` 21 | 22 | see: [pretenderjs/pretender](https://github.com/pretenderjs/pretender) for pretender 23 | docs 24 | 25 | Configuration 26 | ===== 27 | 28 | By default `pretender.enabled` will be set to `app.tests`. This means that pretender will only be available as an import when your app includes your test suite. 29 | 30 | If you'd like to include Pretender into production builds as well, you can set `pretender.enabled` to `true` in your `ember-cli-build.js` or `Brocfile.js`: 31 | 32 | ```javascript 33 | var app = new EmberApp({ 34 | pretender: { 35 | enabled: true 36 | } 37 | }); 38 | ``` 39 | 40 | You can also opt out of including the fetch polyfill, if you do not need to run your tests in older browsers: 41 | 42 | ```javascript 43 | var app = new EmberApp({ 44 | pretender: { 45 | includeFetchPolyfill: false 46 | } 47 | }); 48 | ``` 49 | 50 | Nested Addon Usage Caveat 51 | ===== 52 | 53 | To publish an addon that exports functionality driven by ember-cli-pretender, 54 | note that ember-cli-pretender must be listed in the `dependencies` for NPM 55 | and not the `devDependencies`. 56 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | 5 | module.exports = function() { 6 | return Promise.all([ 7 | getChannelURL('release'), 8 | getChannelURL('beta'), 9 | getChannelURL('canary') 10 | ]).then((urls) => { 11 | return { 12 | useYarn: true, 13 | scenarios: [ 14 | { 15 | name: 'ember-lts-2.12', 16 | npm: { 17 | devDependencies: { 18 | 'ember-source': '~2.12.0' 19 | } 20 | } 21 | }, 22 | { 23 | name: 'ember-lts-2.16', 24 | npm: { 25 | devDependencies: { 26 | 'ember-source': '~2.16.0' 27 | } 28 | } 29 | }, 30 | { 31 | name: 'ember-lts-2.18', 32 | npm: { 33 | devDependencies: { 34 | 'ember-source': '~2.18.0' 35 | } 36 | } 37 | }, 38 | { 39 | name: 'ember-release', 40 | npm: { 41 | devDependencies: { 42 | 'ember-source': urls[0] 43 | } 44 | } 45 | }, 46 | { 47 | name: 'ember-beta', 48 | npm: { 49 | devDependencies: { 50 | 'ember-source': urls[1] 51 | } 52 | } 53 | }, 54 | { 55 | name: 'ember-canary', 56 | npm: { 57 | devDependencies: { 58 | 'ember-source': urls[2] 59 | } 60 | } 61 | }, 62 | { 63 | name: 'ember-default', 64 | npm: { 65 | devDependencies: {} 66 | } 67 | } 68 | ] 69 | }; 70 | }); 71 | }; 72 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Release Process 2 | 3 | Releases are mostly automated using 4 | [release-it](https://github.com/release-it/release-it/) and 5 | [lerna-changelog](https://github.com/lerna/lerna-changelog/). 6 | 7 | ## Preparation 8 | 9 | Since the majority of the actual release process is automated, the primary 10 | remaining task prior to releasing is confirming that all pull requests that 11 | have been merged since the last release have been labeled with the appropriate 12 | `lerna-changelog` labels and the titles have been updated to ensure they 13 | represent something that would make sense to our users. Some great information 14 | on why this is important can be found at 15 | [keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall 16 | guiding principle here is that changelogs are for humans, not machines. 17 | 18 | When reviewing merged PR's the labels to be used are: 19 | 20 | * breaking - Used when the PR is considered a breaking change. 21 | * enhancement - Used when the PR adds a new feature or enhancement. 22 | * bug - Used when the PR fixes a bug included in a previous release. 23 | * documentation - Used when the PR adds or updates documentation. 24 | * internal - Used for internal changes that still require a mention in the 25 | changelog/release notes. 26 | 27 | ## Release 28 | 29 | Once the prep work is completed, the actual release is straight forward: 30 | 31 | * First, ensure that you have installed your projects dependencies: 32 | 33 | ```sh 34 | yarn install 35 | ``` 36 | 37 | * Second, ensure that you have obtained a 38 | [GitHub personal access token][generate-token] with the `repo` scope (no 39 | other permissions are needed). Make sure the token is available as the 40 | `GITHUB_AUTH` environment variable. 41 | 42 | For instance: 43 | 44 | ```bash 45 | export GITHUB_AUTH=abc123def456 46 | ``` 47 | 48 | [generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable 49 | 50 | * And last (but not least 😁) do your release. 51 | 52 | ```sh 53 | npx release-it 54 | ``` 55 | 56 | [release-it](https://github.com/release-it/release-it/) manages the actual 57 | release process. It will prompt you to to choose the version number after which 58 | you will have the chance to hand tweak the changelog to be used (for the 59 | `CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging, 60 | pushing the tag and commits, etc. 61 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-pretender", 3 | "version": "4.0.0", 4 | "description": "Include Pretender into an ember-cli application.", 5 | "keywords": [ 6 | "ember-addon" 7 | ], 8 | "homepage": "https://github.com/rwjblue/ember-cli-pretender", 9 | "bugs": { 10 | "url": "https://github.com/rwjblue/ember-cli-pretender/issues" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/rwjblue/ember-cli-pretender.git" 15 | }, 16 | "license": "MIT", 17 | "author": "Robert Jackson", 18 | "main": "index.js", 19 | "directories": { 20 | "doc": "doc", 21 | "test": "tests" 22 | }, 23 | "scripts": { 24 | "build": "ember build", 25 | "changelog": "lerna-changelog", 26 | "lint:js": "eslint .", 27 | "start": "ember serve", 28 | "test": "ember test", 29 | "test:all": "ember try:each" 30 | }, 31 | "dependencies": { 32 | "abortcontroller-polyfill": "^1.5.0", 33 | "broccoli-funnel": "^3.0.3", 34 | "broccoli-merge-trees": "^4.2.0", 35 | "chalk": "^4.1.0", 36 | "ember-cli-babel": "^7.22.1", 37 | "fake-xml-http-request": "^2.1.1", 38 | "pretender": "^3.4.3", 39 | "route-recognizer": "^0.3.4", 40 | "whatwg-fetch": "^3.4.1" 41 | }, 42 | "devDependencies": { 43 | "broccoli-asset-rev": "^2.7.0", 44 | "ember-ajax": "^3.0.0", 45 | "ember-cli": "~3.2.0", 46 | "ember-cli-dependency-checker": "^2.0.0", 47 | "ember-cli-eslint": "^4.2.1", 48 | "ember-cli-htmlbars": "^2.0.1", 49 | "ember-cli-htmlbars-inline-precompile": "^1.0.0", 50 | "ember-cli-inject-live-reload": "^1.4.1", 51 | "ember-cli-qunit": "^4.3.2", 52 | "ember-cli-shims": "^1.2.0", 53 | "ember-cli-sri": "^2.1.0", 54 | "ember-cli-uglify": "^2.0.0", 55 | "ember-disable-prototype-extensions": "^1.1.2", 56 | "ember-export-application-global": "^2.0.0", 57 | "ember-load-initializers": "^1.1.0", 58 | "ember-maybe-import-regenerator": "^0.1.6", 59 | "ember-resolver": "^4.0.0", 60 | "ember-source": "~3.2.0", 61 | "ember-source-channel-url": "^1.0.1", 62 | "ember-try": "^0.2.23", 63 | "eslint-plugin-ember": "^5.0.0", 64 | "eslint-plugin-node": "^6.0.1", 65 | "lerna-changelog": "^0.8.2", 66 | "loader.js": "^4.2.3", 67 | "qunit-dom": "^0.6.2", 68 | "release-it": "^14.0.2", 69 | "release-it-lerna-changelog": "^2.4.0" 70 | }, 71 | "engines": { 72 | "node": "10.* || >= 12.*" 73 | }, 74 | "publishConfig": { 75 | "registry": "https://registry.npmjs.org" 76 | }, 77 | "ember-addon": { 78 | "configPath": "tests/dummy/config" 79 | }, 80 | "release-it": { 81 | "plugins": { 82 | "release-it-lerna-changelog": { 83 | "infile": "CHANGELOG.md", 84 | "launchEditor": true 85 | } 86 | }, 87 | "git": { 88 | "tagName": "v${version}" 89 | }, 90 | "github": { 91 | "release": true, 92 | "tokenRef": "GITHUB_AUTH" 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v4.0.0 (2020-10-09) 2 | 3 | #### :boom: Breaking Change 4 | * [#73](https://github.com/rwjblue/ember-cli-pretender/pull/73) Drop Node < 10 support; Upgrade ember-cli-babel to v7 ([@nlfurniss](https://github.com/nlfurniss)) 5 | 6 | #### Committers: 1 7 | - Nathaniel Furniss ([@nlfurniss](https://github.com/nlfurniss)) 8 | 9 | 10 | ## v3.2.0 (2019-11-04) 11 | 12 | #### :rocket: Enhancement 13 | * [#70](https://github.com/rwjblue/ember-cli-pretender/pull/70) Update Pretender version (^3.0.1) ([@givanse](https://github.com/givanse)) 14 | 15 | #### :memo: Documentation 16 | * [#72](https://github.com/rwjblue/ember-cli-pretender/pull/72) ember-auto-import: Warn when it is a dependency ([@dcyriller](https://github.com/dcyriller)) 17 | 18 | #### Committers: 2 19 | - Cyrille David ([@dcyriller](https://github.com/dcyriller)) 20 | - Gastón I. Silva ([@givanse](https://github.com/givanse)) 21 | 22 | ## v3.1.1 (2019-02-06) 23 | 24 | #### :bug: Bug Fix 25 | * [#69](https://github.com/rwjblue/ember-cli-pretender/pull/69) Search for official version whatwg-fetch ([@xg-wang](https://github.com/xg-wang)) 26 | 27 | #### Committers: 1 28 | - Thomas Wang ([@xg-wang](https://github.com/xg-wang)) 29 | 30 | ## v3.1.0 (2019-01-18) 31 | 32 | #### :rocket: Enhancement 33 | * [#67](https://github.com/rwjblue/ember-cli-pretender/pull/67) Allow opt-out of fetch polyfill ([@mydea](https://github.com/mydea)) 34 | 35 | #### :bug: Bug Fix 36 | * [#68](https://github.com/rwjblue/ember-cli-pretender/pull/68) Replace `resolve.sync()` with `require.resolve()` ([@Turbo87](https://github.com/Turbo87)) 37 | 38 | #### :house: Internal 39 | * [#65](https://github.com/rwjblue/ember-cli-pretender/pull/65) Switch fetch polyfill to official version ([@nlfurniss](https://github.com/nlfurniss)) 40 | 41 | #### Committers: 3 42 | - Francesco Novy ([@mydea](https://github.com/mydea)) 43 | - Nathaniel Furniss ([@nlfurniss](https://github.com/nlfurniss)) 44 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 45 | 46 | 47 | ## v3.0.0 (2018-07-18) 48 | 49 | #### :boom: Breaking Change 50 | * [#62](https://github.com/rwjblue/ember-cli-pretender/pull/62) Update dependencies ([@xg-wang](https://github.com/xg-wang)) 51 | 52 | #### Committers: 1 53 | - Thomas Wang ([@xg-wang](https://github.com/xg-wang)) 54 | 55 | ## 1.0.0 56 | 57 | * Remove `pretender` module shim (this is now provided by pretender itself). 58 | 59 | ## 0.7.0 60 | 61 | * Remove bower requirement (consume `pretender` from NPM instead). 62 | * Update to pretender `^1.0.0`. 63 | 64 | ## 0.6.0 65 | 66 | * Update to pretender 0.12.0. 67 | 68 | ## 0.5.0 69 | 70 | * Bump pretender to 0.10 71 | * Fix typo in option name to en/disable pretender 72 | 73 | ## 0.4.0 74 | 75 | * Bump Pretender version to 0.9.0. 76 | 77 | ## 0.2.3 78 | 79 | * Fix shim to add list of export modules. 80 | 81 | ## 0.2.2 82 | 83 | * Add shim file to allow `import Pretender from 'pretender';`. 84 | * Fix repo URL's (rjackson -> rwjblue). 85 | 86 | ## 0.2.1 87 | 88 | * Remove hard-coded list of files to include (in package.json). 89 | 90 | ## 0.2.0 91 | 92 | * Remove vendored code (instead, install via bower in postinstall hook). 93 | * Export a POJO (allows us to inherit from ember-cli's Addon model). 94 | * Add repo url to package.json. 95 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var path = require('path'); 3 | var Funnel = require('broccoli-funnel'); 4 | var MergeTrees = require('broccoli-merge-trees'); 5 | 6 | module.exports = { 7 | name: 'ember-cli-pretender', 8 | 9 | _findPretenderPaths: function() { 10 | if (!this._pretenderPath) { 11 | this._pretenderPath = require.resolve('pretender'); 12 | this._pretenderDir = path.dirname(this._pretenderPath); 13 | this._routeRecognizerPath = require.resolve('route-recognizer'); 14 | this._fakeRequestPath = require.resolve('fake-xml-http-request'); 15 | this._abortControllerPath = require.resolve('abortcontroller-polyfill/dist/abortcontroller-polyfill-only.js'); 16 | this._whatwgFetchPath = require.resolve('whatwg-fetch/dist/fetch.umd.js'); 17 | } 18 | }, 19 | 20 | _autoimportInfo() { 21 | let chalk = require("chalk"); 22 | let info = chalk.yellow(` 23 | INFORMATION (ember-cli-pretender) 24 | ${chalk.inverse( 25 | "ember-auto-import" 26 | )} seems to be in your package dependencies. 27 | As a result, you don't need pretender to be wrapped anymore. 28 | You can install ${chalk.bold("pretender")} and remove ${chalk.bold( 29 | "ember-cli-pretender" 30 | )}. 31 | `); 32 | // eslint-disable-next-line no-console 33 | console.log(info); 34 | }, 35 | 36 | init() { 37 | this._super.init && this._super.init.apply(this, arguments); 38 | if (this.parent.dependencies()["ember-auto-import"]) { 39 | this._autoimportInfo(); 40 | } 41 | }, 42 | 43 | treeForVendor: function(tree) { 44 | this._findPretenderPaths(); 45 | 46 | var pretenderTree = new Funnel(this._pretenderDir, { 47 | files: [path.basename(this._pretenderPath)], 48 | destDir: '/pretender', 49 | }); 50 | 51 | var routeRecognizerFilename = path.basename(this._routeRecognizerPath); 52 | var routeRecognizerTree = new Funnel(path.dirname(this._routeRecognizerPath), { 53 | files: [routeRecognizerFilename, routeRecognizerFilename + '.map'], 54 | destDir: '/route-recognizer', 55 | }); 56 | 57 | var fakeRequestTree = new Funnel(path.dirname(this._fakeRequestPath), { 58 | files: [path.basename(this._fakeRequestPath)], 59 | destDir: '/fake-xml-http-request', 60 | }); 61 | 62 | var abortControllerTree = new Funnel(path.dirname(this._abortControllerPath), { 63 | files: [path.basename(this._abortControllerPath)], 64 | destDir: '/abortcontroller-polyfill', 65 | }); 66 | 67 | var whatwgFetchTree = new Funnel(path.dirname(this._whatwgFetchPath), { 68 | files: [path.basename(this._whatwgFetchPath)], 69 | destDir: '/whatwg-fetch', 70 | }); 71 | 72 | var trees = [ 73 | tree, 74 | pretenderTree, 75 | routeRecognizerTree, 76 | fakeRequestTree, 77 | abortControllerTree, 78 | whatwgFetchTree 79 | // tree is not always defined, so filter out if empty 80 | ].filter(Boolean); 81 | 82 | return new MergeTrees(trees, { 83 | annotation: 'ember-cli-pretender: treeForVendor' 84 | }); 85 | }, 86 | 87 | included: function included() { 88 | var app = this._findApp(); 89 | this.app = app; 90 | 91 | var opts = app.options.pretender || { enabled: app.tests }; 92 | if (opts.enabled) { 93 | this._findPretenderPaths(); 94 | 95 | app.import('vendor/fake-xml-http-request/' + path.basename(this._fakeRequestPath)); 96 | app.import('vendor/route-recognizer/' + path.basename(this._routeRecognizerPath)); 97 | 98 | var includeFetchPolyfill = opts.includeFetchPolyfill || typeof opts.includeFetchPolyfill === 'undefined'; 99 | if (includeFetchPolyfill) { 100 | app.import('vendor/abortcontroller-polyfill/' + path.basename(this._abortControllerPath)); 101 | app.import('vendor/whatwg-fetch/' + path.basename(this._whatwgFetchPath)); 102 | } 103 | 104 | app.import('vendor/pretender/' + path.basename(this._pretenderPath)); 105 | } 106 | }, 107 | 108 | _findApp() { 109 | if (typeof this._findHost === 'function') { 110 | return this._findHost(); 111 | } else { 112 | // Otherwise, we'll use this implementation borrowed from the _findHost() 113 | // method in ember-cli. 114 | // Keep iterating upward until we don't have a grandparent. 115 | // Has to do this grandparent check because at some point we hit the project. 116 | let app; 117 | let current = this; 118 | do { 119 | app = current.app || this; 120 | } while (current.parent && current.parent.parent && (current = current.parent)); 121 | 122 | return app; 123 | } 124 | }, 125 | }; 126 | --------------------------------------------------------------------------------