├── vendor └── .gitkeep ├── tests ├── unit │ └── .gitkeep ├── integration │ └── .gitkeep ├── dummy │ ├── app │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── models │ │ │ └── .gitkeep │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── 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 ├── .eslintrc.js ├── helpers │ ├── destroy-app.js │ ├── resolver.js │ ├── start-app.js │ └── module-for-acceptance.js ├── test-helper.js └── index.html ├── .watchmanconfig ├── config ├── environment.js └── ember-try.js ├── index.js ├── .eslintrc.js ├── .npmignore ├── testem.js ├── .ember-cli ├── .editorconfig ├── .gitignore ├── ember-cli-build.js ├── .travis.yml ├── appveyor.yml ├── LICENSE.md ├── lib ├── utils │ └── fastboot-console.js └── commands │ └── console.js ├── package.json ├── README.md └── test └── fastboot-test.js /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 | -------------------------------------------------------------------------------- /tests/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | embertest: true 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /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 | /* eslint-env node */ 2 | 'use strict'; 3 | 4 | module.exports = function(/* environment, appConfig */) { 5 | return { }; 6 | }; 7 | -------------------------------------------------------------------------------- /tests/helpers/destroy-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default function destroyApp(application) { 4 | Ember.run(application, 'destroy'); 5 | } 6 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 | {{!-- The following component displays Ember's default welcome message. --}} 2 | {{welcome-page}} 3 | {{!-- Feel free to remove this! --}} 4 | 5 | {{outlet}} -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import resolver from './helpers/resolver'; 2 | import { 3 | setResolver 4 | } from 'ember-qunit'; 5 | import { start } from 'ember-cli-qunit'; 6 | 7 | setResolver(resolver); 8 | start(); 9 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = { 4 | browsers: [ 5 | 'ie 9', 6 | 'last 1 Chrome versions', 7 | 'last 1 Firefox versions', 8 | 'last 1 Safari versions' 9 | ] 10 | }; 11 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 'use strict'; 3 | 4 | module.exports = { 5 | name: 'ember-console', 6 | includedCommands() { 7 | return { 8 | console: require('./lib/commands/console') 9 | }; 10 | } 11 | }; 12 | 13 | 14 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | ecmaVersion: 2017, 5 | sourceType: 'module' 6 | }, 7 | extends: 'eslint:recommended', 8 | env: { 9 | browser: true 10 | }, 11 | rules: { 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /.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 | .gitignore 11 | .eslintrc.js 12 | .watchmanconfig 13 | .travis.yml 14 | bower.json 15 | ember-cli-build.js 16 | testem.js 17 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | module.exports = { 3 | "test_page": "tests/index.html?hidepassed", 4 | "disable_watching": true, 5 | "launch_in_ci": [ 6 | "PhantomJS" 7 | ], 8 | "launch_in_dev": [ 9 | "PhantomJS", 10 | "Chrome" 11 | ] 12 | }; 13 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from './config/environment'; 3 | 4 | const Router = Ember.Router.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 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from '../../resolver'; 2 | import config from '../../config/environment'; 3 | 4 | const resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | const App = Ember.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 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log* 17 | yarn-error.log 18 | testem.log 19 | 20 | # ember-try 21 | .node_modules.ember-try/ 22 | bower.json.ember-try 23 | package.json.ember-try 24 | View 25 | 26 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Application from '../../app'; 3 | import config from '../../config/environment'; 4 | 5 | export default function startApp(attrs) { 6 | let attributes = Ember.merge({}, config.APP); 7 | attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; 8 | 9 | return Ember.run(() => { 10 | let application = Application.create(attributes); 11 | application.setupForTesting(); 12 | application.injectTestHelpers(); 13 | return application; 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 'use strict'; 3 | 4 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 5 | 6 | module.exports = function(defaults) { 7 | let app = new EmberAddon(defaults, { 8 | // Add options here 9 | }); 10 | 11 | /* 12 | This build file specifies the options for the dummy test app of this 13 | addon, located in `/tests/dummy` 14 | This build file does *not* influence how the addon or the app using it 15 | behave. You most likely want to be modifying `./index.js` or app's build file 16 | */ 17 | 18 | return app.toTree(); 19 | }; 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | - "8" 5 | - "stable" 6 | 7 | sudo: false 8 | 9 | cache: 10 | yarn: true 11 | 12 | matrix: 13 | fast_finish: true 14 | 15 | before_install: 16 | - curl -o- -L https://yarnpkg.com/install.sh | bash 17 | - export PATH=$HOME/.yarn/bin:$PATH 18 | - yarn global add phantomjs-prebuilt 19 | - phantomjs --version 20 | 21 | install: 22 | - yarn install --no-lockfile --non-interactive 23 | 24 | script: 25 | # Usually, it's ok to finish the test scenario without reverting 26 | # to the addon's original dependency state, skipping "cleanup". 27 | - yarn run test 28 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /tests/helpers/module-for-acceptance.js: -------------------------------------------------------------------------------- 1 | import { module } from 'qunit'; 2 | import Ember from 'ember'; 3 | import startApp from '../helpers/start-app'; 4 | import destroyApp from '../helpers/destroy-app'; 5 | 6 | const { RSVP: { Promise } } = Ember; 7 | 8 | export default function(name, options = {}) { 9 | module(name, { 10 | beforeEach() { 11 | this.application = startApp(); 12 | 13 | if (options.beforeEach) { 14 | return options.beforeEach.apply(this, arguments); 15 | } 16 | }, 17 | 18 | afterEach() { 19 | let afterEach = options.afterEach && options.afterEach.apply(this, arguments); 20 | return Promise.resolve(afterEach).then(() => destroyApp(this.application)); 21 | } 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Fix line endings in Windows. (runs before repo cloning) 2 | init: 3 | - git config --global core.autocrlf input 4 | 5 | # Test against these versions of Node.js. 6 | environment: 7 | matrix: 8 | - nodejs_version: "6" 9 | - nodejs_version: "8" 10 | 11 | # Install scripts. (runs after repo cloning) 12 | install: 13 | # Get the latest stable version of Node 0.STABLE.latest 14 | - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) 15 | - set CI=true 16 | # Typical yarn stuff. 17 | - yarn install --non-interactive 18 | 19 | # Post-install test scripts. 20 | test_script: 21 | # Output useful info for debugging. 22 | - node --version 23 | - yarn --version 24 | - yarn run test 25 | 26 | # Don't actually build. 27 | build: off 28 | 29 | # Set build version format here instead of in the admin panel. 30 | version: "{build}" -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 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 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = function(environment) { 4 | var ENV = { 5 | modulePrefix: 'dummy', 6 | environment: 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 | } 44 | 45 | if (environment === 'production') { 46 | 47 | } 48 | 49 | return ENV; 50 | }; 51 | -------------------------------------------------------------------------------- /lib/utils/fastboot-console.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Fastboot = require('fastboot'); 4 | 5 | /** 6 | * FastBoot console that takes in a dist path and visits the root url and provides 7 | * a console API to debug app running in FastBoot. 8 | */ 9 | module.exports = function fastbootConsole(dist) { 10 | return new Promise((resolve, reject) => { 11 | const app = new Fastboot({ 12 | distPath: dist 13 | }); 14 | 15 | return app.visit('/').then((response) => { 16 | const fastbootConsoleApi = { 17 | dist, 18 | get html() { 19 | return response.html(); 20 | }, 21 | get currentURL() { 22 | return response.instance.lookup('router:main').get('currentURL'); 23 | }, 24 | get routes() { 25 | return Object.keys(response.instance.__container__.lookup('router:main').get('_routerMicrolib.recognizer.names')); 26 | }, 27 | get rootElement() { 28 | return response.instance.rootElement; 29 | }, 30 | lookup(fullName) { 31 | return response.instance.lookup(fullName); 32 | }, 33 | reload() { 34 | app.reload() 35 | return app.visit('/').then(_response => response = _response); 36 | }, 37 | visit() { 38 | return app.visit(...arguments); 39 | }, 40 | get sandbox() { 41 | return app._app.sandbox.sandbox; 42 | }, 43 | get instance() { 44 | return response.instance; 45 | } 46 | }; 47 | resolve({app, response, fastbootConsoleApi}) 48 | }, (error) => { 49 | reject(error) 50 | }); 51 | }); 52 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-console", 3 | "version": "0.0.7", 4 | "description": "The default blueprint for ember-cli addons.", 5 | "keywords": [ 6 | "ember-addon" 7 | ], 8 | "license": "MIT", 9 | "author": "Stefan Penner ", 10 | "directories": { 11 | "doc": "doc", 12 | "test": "tests" 13 | }, 14 | "repository": "https://github.com/stefanpenner/ember-console.git", 15 | "scripts": { 16 | "build": "ember build", 17 | "start": "ember server", 18 | "test": "ember build && node_modules/.bin/mocha test" 19 | }, 20 | "dependencies": { 21 | "await-outside": "^2.1.2", 22 | "fastboot": "^1.0.0-rc.6", 23 | "semver": "^5.3.0", 24 | "silent-error": "^1.1.0", 25 | "ember-cli-babel": "^6.3.0" 26 | }, 27 | "devDependencies": { 28 | "broccoli-asset-rev": "^2.4.5", 29 | "chai": "^3.5.0", 30 | "ember-ajax": "^3.0.0", 31 | "ember-cli": "~2.14.0", 32 | "ember-cli-dependency-checker": "^1.3.0", 33 | "ember-cli-eslint": "^3.0.0", 34 | "ember-cli-fastboot": "^1.0.0-rc.1", 35 | "ember-cli-htmlbars": "^2.0.1", 36 | "ember-cli-htmlbars-inline-precompile": "^0.4.3", 37 | "ember-cli-inject-live-reload": "^1.4.1", 38 | "ember-cli-qunit": "^4.0.0", 39 | "ember-cli-shims": "^1.1.0", 40 | "ember-cli-sri": "^2.1.0", 41 | "ember-cli-uglify": "^1.2.0", 42 | "ember-disable-prototype-extensions": "^1.1.2", 43 | "ember-export-application-global": "^2.0.0", 44 | "ember-load-initializers": "^1.0.0", 45 | "ember-resolver": "^4.0.0", 46 | "ember-source": "~2.14.0", 47 | "ember-welcome-page": "^3.0.0", 48 | "mocha": "^2.4.5", 49 | "loader.js": "^4.2.3" 50 | }, 51 | "engines": { 52 | "node": "^4.5 || 6.* || >= 7.*" 53 | }, 54 | "ember-addon": { 55 | "configPath": "tests/dummy/config" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | module.exports = { 3 | scenarios: [ 4 | { 5 | name: 'ember-lts-2.4', 6 | bower: { 7 | dependencies: { 8 | 'ember': 'components/ember#lts-2-4' 9 | }, 10 | resolutions: { 11 | 'ember': 'lts-2-4' 12 | } 13 | }, 14 | npm: { 15 | devDependencies: { 16 | 'ember-source': null 17 | } 18 | } 19 | }, 20 | { 21 | name: 'ember-lts-2.8', 22 | bower: { 23 | dependencies: { 24 | 'ember': 'components/ember#lts-2-8' 25 | }, 26 | resolutions: { 27 | 'ember': 'lts-2-8' 28 | } 29 | }, 30 | npm: { 31 | devDependencies: { 32 | 'ember-source': null 33 | } 34 | } 35 | }, 36 | { 37 | name: 'ember-release', 38 | bower: { 39 | dependencies: { 40 | 'ember': 'components/ember#release' 41 | }, 42 | resolutions: { 43 | 'ember': 'release' 44 | } 45 | }, 46 | npm: { 47 | devDependencies: { 48 | 'ember-source': null 49 | } 50 | } 51 | }, 52 | { 53 | name: 'ember-beta', 54 | bower: { 55 | dependencies: { 56 | 'ember': 'components/ember#beta' 57 | }, 58 | resolutions: { 59 | 'ember': 'beta' 60 | } 61 | }, 62 | npm: { 63 | devDependencies: { 64 | 'ember-source': null 65 | } 66 | } 67 | }, 68 | { 69 | name: 'ember-canary', 70 | bower: { 71 | dependencies: { 72 | 'ember': 'components/ember#canary' 73 | }, 74 | resolutions: { 75 | 'ember': 'canary' 76 | } 77 | }, 78 | npm: { 79 | devDependencies: { 80 | 'ember-source': null 81 | } 82 | } 83 | }, 84 | { 85 | name: 'ember-default', 86 | npm: { 87 | devDependencies: {} 88 | } 89 | } 90 | ] 91 | }; 92 | -------------------------------------------------------------------------------- /lib/commands/console.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const SilentError = require('silent-error'); 4 | const path = require('path'); 5 | 6 | module.exports = { 7 | name: 'console', 8 | description: 'runs your app in node and gives you a repl to it', 9 | 10 | availableOptions: [ 11 | { name: 'build', type: Boolean, default: 'auto' }, 12 | { name: 'environment', type: String, default: 'development', aliases: ['e',{'dev' : 'development'}, {'prod' : 'production'}] }, 13 | { name: 'output-path', type: 'Path', default: 'dist/', aliases: ['o'] }, 14 | ], 15 | 16 | run(options) { 17 | const fastbootConsole = require('../utils/fastboot-console'); 18 | const repl = require('repl'); 19 | const fs = require('fs'); 20 | const semver = require('semver'); 21 | const { addAwaitOutsideToReplServer } = require('await-outside'); 22 | const dist = options.outputPath; 23 | 24 | const addon = this.project.addons.find(addon => addon.name === 'ember-cli-fastboot');; 25 | 26 | if (!addon) { 27 | throw new SilentError('You must have ember-cli-fastboot@1.0.0-rc.1 >= installed and working') 28 | } 29 | 30 | if (!semver.gte(addon.pkg.version, '1.0.0-rc.1')) { 31 | throw new SilentError(`You must have ember-cli-fastboot@1.0.0-rc.1 >= installed, you have: '${addon.pkg.version}'`); 32 | } 33 | 34 | let setup; 35 | options['suppress-sizes'] = true; 36 | if (options.build === true) { 37 | setup = this.runTask('Build', options); 38 | } else if (options.build === 'auto' && !fs.existsSync(dist)) { 39 | setup = this.runTask('Build', options); 40 | } else { 41 | setup = Promise.resolve(); 42 | } 43 | 44 | return setup.then(() => { 45 | if (!fs.existsSync(dist)) { 46 | throw new SilentError('You must first ember your app (console is booted from dist/*)') 47 | } 48 | 49 | fastbootConsole(dist).then((data) => { 50 | let { app, response, fastbootConsoleApi } = data; 51 | 52 | const replServer = repl.start({ 53 | prompt: 'ember-console> ' 54 | }); 55 | 56 | addAwaitOutsideToReplServer(replServer); 57 | 58 | Object.assign(replServer.context, { 59 | get app() { 60 | return fastbootConsoleApi; 61 | } 62 | }); 63 | }) 64 | .catch((error) => { 65 | throw new SilentError('Failed to bring up ember-console'); 66 | }); 67 | 68 | return new Promise(_ => _); 69 | }); 70 | } 71 | }; 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ember-console 2 | 3 | [![Build Status](https://travis-ci.org/stefanpenner/ember-console.svg?branch=master)](https://travis-ci.org/stefanpenner/ember-console) 4 | [![Build status](https://ci.appveyor.com/api/projects/status/y315p6t4siiyicu6?svg=true)](https://ci.appveyor.com/project/embercli/ember-console) 5 | 6 | get a console (REPL) to you fastboot capable ember-app 7 | 8 | *WARNING: still experimental, but ideas/help is wanted!* 9 | 10 | [![asciicast](https://asciinema.org/a/dec9qcufpk88w5ylamd4dy53x.png)](https://asciinema.org/a/dec9qcufpk88w5ylamd4dy53x) 11 | 12 | # Installation 13 | 14 | ``` 15 | yarn add ember-console 16 | ``` 17 | 18 | or 19 | 20 | 21 | ``` 22 | npm install ember-console 23 | ``` 24 | 25 | # Usage 26 | 27 | 1. ensure your app has `ember-cli-fastboot` >= `1.0.0-rc.1` installed and working 28 | 2. build your app `ember build` 29 | 3. run `ember console` and your app in `dist/` is started in fastboot, and a repl to it is opened. 30 | 31 | Available repl commands: 32 | 33 | * `.help` for repl specific commands 34 | * `app` 35 | * `currentURL` 36 | * `routes` 37 | * `rootElement` 38 | * `lookup(fullName)`: enables looking up singletons, for example `lookup('router:mian')` 39 | * `reload()` reloads the app, if a new bulid has occured this can be used to reload new code. 40 | * `visit(path)` the fastboot `visit` helper, allowing you to manually navigate your app 41 | * `instance` the fastboot instance 42 | * `sandbox` the sandboxed global: for example `Object.keys(app.sandbox.require.entries)` will give you all the modules your app uses 43 | 44 | 45 | ** Bonus ** 46 | 47 | It is also possible to connect the console to a pre-built application (as long as it was built with fastboot) 48 | 49 | ```sh 50 | ember build --output-path my-other-dist` 51 | ember console --output-path my-pther-dist 52 | ``` 53 | 54 | [![asciicast](https://asciinema.org/a/874kex0jwo7xvuy62vqbzav13.png)](https://asciinema.org/a/874kex0jwo7xvuy62vqbzav13) 55 | 56 | # Development 57 | 58 | ## Installation 59 | 60 | * `git clone ` this repository 61 | * `cd ember-console` 62 | * `npm install` 63 | 64 | ## Running 65 | 66 | * `ember serve` 67 | * Visit your app at [http://localhost:4200](http://localhost:4200). 68 | 69 | ## Running Tests 70 | 71 | * `npm test` (Runs `ember try:each` to test your addon against multiple Ember versions) 72 | * `ember test` 73 | * `ember test --server` 74 | 75 | ## Building 76 | 77 | * `ember build` 78 | 79 | For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/). 80 | -------------------------------------------------------------------------------- /test/fastboot-test.js: -------------------------------------------------------------------------------- 1 | const assert = require('chai').assert; 2 | const fastbootConsole = require('../lib/utils/fastboot-console'); 3 | 4 | const DIST_PATH = 'dist'; 5 | 6 | describe('FastBoot Console', function() { 7 | it('should throw error if dist path is not defined', function() { 8 | return fastbootConsole('non-existent-path') 9 | .catch(function(error) { 10 | assert.include(error.message, 'Couldn\'t find'); 11 | }); 12 | }); 13 | 14 | it('should return fastboot console API when dist path is correctly defined', function() { 15 | return fastbootConsole(DIST_PATH).then(function(data) { 16 | assert.isDefined(data.app); 17 | assert.isDefined(data.response); 18 | assert.isDefined(data.fastbootConsoleApi); 19 | }); 20 | }); 21 | 22 | describe('API', function() { 23 | var fastbootConsoleApi; 24 | 25 | beforeEach(function() { 26 | return fastbootConsole(DIST_PATH).then(function(data) { 27 | fastbootConsoleApi = data.fastbootConsoleApi; 28 | }); 29 | }); 30 | 31 | it('should define dist property correctly', function() { 32 | assert.equal(fastbootConsoleApi.dist, DIST_PATH); 33 | }); 34 | 35 | it('should return html content of the request correctly', function() { 36 | return fastbootConsoleApi.html.then(function(result) { 37 | assert.include(result, 'You’ve officially spun up your very first Ember app :-)'); 38 | }); 39 | }); 40 | 41 | it('should get current url', function() { 42 | assert.equal(fastbootConsoleApi.currentURL, '/'); 43 | }); 44 | 45 | it('should get all routes of the app', function() { 46 | const expectedRoutes = [ 'application_loading', 47 | 'application_error', 48 | 'loading', 49 | 'error', 50 | 'index_loading', 51 | 'index_error', 52 | 'index', 53 | 'application' 54 | ]; 55 | assert.deepEqual(fastbootConsoleApi.routes, expectedRoutes); 56 | }); 57 | 58 | it('should get the rootElement', function() { 59 | assert.isDefined(fastbootConsoleApi.rootElement); 60 | }); 61 | 62 | it('reload should work correctly', function() { 63 | return fastbootConsoleApi.reload().then(function(resp) { 64 | return resp.html(); 65 | }) 66 | .then(function(result) { 67 | assert.include(result, 'You’ve officially spun up your very first Ember app :-)'); 68 | }); 69 | }); 70 | 71 | it('AMD modules should be loaded in sandbox', function() { 72 | assert.isAbove(Object.keys(fastbootConsoleApi.sandbox.require.entries).length, 0); 73 | }); 74 | }); 75 | }); --------------------------------------------------------------------------------