├── .bowerrc ├── .editorconfig ├── .ember-cli ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── README.md ├── bin ├── corber └── cordova-lib-runner ├── bower.json ├── config └── ember-try.js ├── index.js ├── lib ├── .jshintrc ├── commands │ ├── -command.js │ ├── build.js │ ├── cordova.js │ ├── devices.js │ ├── index.js │ ├── init.js │ ├── lint-index.js │ ├── make-icons.js │ ├── make-splashes.js │ ├── open.js │ ├── platform.js │ ├── plugin.js │ ├── prepare.js │ ├── proxy.js │ ├── serve.js │ ├── start.js │ ├── utils │ │ ├── expand-platforms.js │ │ └── resolve-platform.js │ └── version.js ├── frameworks │ ├── ember │ │ ├── framework.js │ │ ├── tasks │ │ │ └── update-watchman-config.js │ │ ├── utils │ │ │ └── get-cli-version.js │ │ └── validators │ │ │ ├── browser-targets.js │ │ │ └── location-type.js │ ├── framework.js │ ├── react │ │ ├── framework.js │ │ └── validators │ │ │ └── homepage.js │ └── vue │ │ └── framework.js ├── objects │ └── device.js ├── targets │ ├── android │ │ ├── target.js │ │ ├── tasks │ │ │ ├── boot-emulator.js │ │ │ ├── get-emulator-state.js │ │ │ ├── install-app-device.js │ │ │ ├── install-app-emulator.js │ │ │ ├── kill-emulator.js │ │ │ ├── launch-app.js │ │ │ ├── list-devices.js │ │ │ ├── list-emulators.js │ │ │ └── list-running-emulators.js │ │ └── utils │ │ │ ├── apk-path.js │ │ │ ├── resolve-path.js │ │ │ ├── sdk-paths.js │ │ │ └── sdk-root.js │ ├── cordova │ │ ├── target.js │ │ ├── tasks │ │ │ ├── build.js │ │ │ ├── create-project.js │ │ │ ├── devices.js │ │ │ ├── open-app.js │ │ │ ├── platform.js │ │ │ ├── prepare.js │ │ │ ├── raw.js │ │ │ └── setup-webview.js │ │ ├── utils │ │ │ ├── cordova-assets.js │ │ │ ├── cordova-validator.js │ │ │ ├── edit-xml.js │ │ │ ├── get-app-name.js │ │ │ ├── get-config.js │ │ │ ├── get-path.js │ │ │ ├── get-platforms.js │ │ │ └── parse-build-flags.js │ │ └── validators │ │ │ ├── addon-args.js │ │ │ ├── allow-navigation.js │ │ │ ├── is-installed.js │ │ │ └── plugin.js │ └── ios │ │ ├── target.js │ │ ├── tasks │ │ ├── boot-emulator.js │ │ ├── build.js │ │ ├── get-ipa-path.js │ │ ├── install-app-device.js │ │ ├── install-app-emulator.js │ │ ├── launch-app-emulator.js │ │ ├── list-devices.js │ │ ├── list-emulators.js │ │ └── open-emulator.js │ │ ├── utils │ │ └── parse-pbxproj.js │ │ └── validators │ │ └── signing-identity.js ├── tasks │ ├── -task.js │ ├── .install-package.js.swp │ ├── add-cordova-js.js │ ├── bash-build.js │ ├── bash-serve.js │ ├── bash.js │ ├── create-livereload-shell.js │ ├── create-project.js │ ├── eslintignore.js │ ├── install-package.js │ ├── install-project-corber.js │ ├── lint-index.js │ ├── run-hook.js │ └── update-gitignore.js ├── templates │ ├── frameworks │ │ ├── custom.js │ │ ├── ember.js │ │ ├── glimmer.js │ │ ├── react.js │ │ └── vue.js │ └── livereload-shell │ │ └── index.html ├── utils │ ├── command-exists.js │ ├── corber-error.js │ ├── create-gitkeep.js │ ├── framework-type.js │ ├── fs-utils.js │ ├── get-last-command.js │ ├── get-network-ip.js │ ├── get-os.js │ ├── get-package.js │ ├── get-versions.js │ ├── logger.js │ ├── open-app-command.js │ ├── parse-xml.js │ ├── require-framework.js │ ├── require-target.js │ ├── run-validators.js │ ├── spawn.js │ └── string.js └── validators │ ├── livereload-package.js │ ├── root-url.js │ └── webpack-plugin.js ├── node-tests ├── .eslintrc.js ├── .jshintrc ├── fixtures │ └── corber-mock │ │ ├── analytics.js │ │ ├── app │ │ └── index.html │ │ ├── build │ │ ├── webpack-with-plugin.dev.conf.js │ │ └── webpack.dev.conf.js │ │ ├── corber │ │ ├── config │ │ │ └── framework.js │ │ ├── cordova │ │ │ ├── .gitignore │ │ │ ├── config.xml │ │ │ ├── fooPath │ │ │ └── plugins │ │ │ │ ├── fetch.json │ │ │ │ └── ios.json │ │ └── hooks │ │ │ ├── hook-promise-rejected.js │ │ │ ├── hook-promise-resolved.js │ │ │ ├── hook-with-error.js │ │ │ ├── hook-with-options.js │ │ │ └── hook.js │ │ ├── dist │ │ └── .gitkeep │ │ ├── package.json │ │ ├── project.js │ │ └── vue.config.js ├── helpers │ └── expect.js └── unit │ ├── commands │ ├── build-test.js │ ├── command-test.js │ ├── init-test.js │ ├── lint-index-test.js │ ├── make-icons-test.js │ ├── make-splashes-test.js │ ├── open-test.js │ ├── platform-test.js │ ├── plugin-test.js │ ├── prepare-test.js │ ├── proxy-test.js │ ├── serve-test.js │ ├── start-test.js │ ├── utils │ │ ├── expand-platforms-test.js │ │ └── resolve-platform-test.js │ └── version-test.js │ ├── frameworks │ ├── ember │ │ ├── .framework-test.js.swp │ │ ├── framework-test.js │ │ ├── tasks │ │ │ └── update-watchman-config-test.js │ │ ├── utils │ │ │ └── get-cli-version-test.js │ │ └── validators │ │ │ ├── browser-targets-test.js │ │ │ └── location-type-test.js │ ├── react │ │ ├── framework-test.js │ │ └── validators │ │ │ └── homepage-test.js │ └── vue │ │ └── framework-test.js │ ├── lint-test.js │ ├── targets │ ├── android │ │ ├── target-test.js │ │ ├── tasks │ │ │ ├── boot-emulator-test.js │ │ │ ├── get-emulator-state-test.js │ │ │ ├── install-app-device-test.js │ │ │ ├── install-app-emulator-test.js │ │ │ ├── kill-emulator-test.js │ │ │ ├── launch-app-test.js │ │ │ ├── list-devices-test.js │ │ │ ├── list-emulators-test.js │ │ │ └── list-running-emulators-test.js │ │ └── utils │ │ │ ├── apk-path-test.js │ │ │ ├── resolve-path-test.js │ │ │ └── sdk-paths-test.js │ ├── cordova │ │ ├── target-test.js │ │ ├── tasks │ │ │ ├── build-test.js │ │ │ ├── create-project-test.js │ │ │ ├── open-app-test.js │ │ │ ├── platform-test.js │ │ │ ├── prepare-test.js │ │ │ ├── raw-test.js │ │ │ └── setup-webview-test.js │ │ ├── utils │ │ │ ├── cordova-assets-test.js │ │ │ ├── cordova-validator-test.js │ │ │ ├── edit-xml-test.js │ │ │ ├── get-app-name-test.js │ │ │ ├── get-platforms-test.js │ │ │ └── parse-build-flags-test.js │ │ └── validators │ │ │ ├── allow-navigation-test.js │ │ │ ├── is-installed-test.js │ │ │ ├── plugin-test.js │ │ │ └── sanitize-args-test.js │ └── ios │ │ ├── target-test.js │ │ ├── tasks │ │ ├── boot-emulator-test.js │ │ ├── build-test.js │ │ ├── get-ipa-path-test.js │ │ ├── install-app-device-test.js │ │ ├── install-app-emulator-test.js │ │ ├── launch-app-test-emulator.js │ │ ├── list-devices-test.js │ │ ├── list-emulators-test.js │ │ └── open-emulator-test.js │ │ ├── utils │ │ └── parse-pbxproj-test.js │ │ └── validators │ │ └── signing-identity-test.js │ ├── tasks │ ├── add-cordova-js-test.js │ ├── bash-build-test.js │ ├── bash-serve-test.js │ ├── bash-test.js │ ├── create-livereload-shell-test.js │ ├── create-project-test.js │ ├── eslintignore-test.js │ ├── install-package-test.js │ ├── install-project-corber-test.js │ ├── lint-index-test.js │ ├── run-hook-test.js │ └── update-gitignore-test.js │ ├── utils │ ├── command-exists-test.js │ ├── create-gitkeep-test.js │ ├── framework-type-test.js │ ├── get-package-test.js │ ├── get-versions-test.js │ ├── logger-test.js │ ├── open-app-command-test.js │ ├── require-framework-test.js │ ├── require-target-test.js │ └── spawn-test.js │ └── validators │ ├── livereload-package-test.js │ ├── root-url-test.js │ └── webpack-plugin-test.js ├── package.json ├── public ├── .gitkeep └── cordova.js ├── vendor └── ios-deploy │ ├── .eslintrc │ ├── .eslintrc.yml │ ├── .github │ ├── CONTRIBUTING.md │ └── ISSUE_TEMPLATE.md │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── build │ ├── Release │ │ ├── ios-deploy │ │ ├── ios-deploy.dSYM │ │ │ └── Contents │ │ │ │ ├── Info.plist │ │ │ │ └── Resources │ │ │ │ └── DWARF │ │ │ │ └── ios-deploy │ │ ├── libios-deploy.a │ │ └── libios_deploy.h │ ├── XCBuildData │ │ ├── BuildDescriptionCacheIndex-69454fa4acb89502bb364ba3e077fe33 │ │ ├── build.db │ │ ├── d3028f7fea2dcd023fb3d06de5f9b0d6-desc.xcbuild │ │ └── d3028f7fea2dcd023fb3d06de5f9b0d6-manifest.xcbuild │ └── ios-deploy.build │ │ └── Release │ │ ├── ios-deploy-lib.build │ │ ├── Objects-normal │ │ │ └── x86_64 │ │ │ │ ├── ios-deploy.LinkFileList │ │ │ │ ├── libios_deploy.d │ │ │ │ ├── libios_deploy.dia │ │ │ │ └── libios_deploy.o │ │ ├── all-product-headers.yaml │ │ ├── ios-deploy-all-non-framework-target-headers.hmap │ │ ├── ios-deploy-all-target-headers.hmap │ │ ├── ios-deploy-generated-files.hmap │ │ ├── ios-deploy-own-target-headers.hmap │ │ ├── ios-deploy-project-headers.hmap │ │ └── ios-deploy.hmap │ │ └── ios-deploy.build │ │ ├── Objects-normal │ │ └── x86_64 │ │ │ ├── ios-deploy.LinkFileList │ │ │ ├── ios-deploy.d │ │ │ ├── ios-deploy.dia │ │ │ ├── ios-deploy.o │ │ │ └── ios-deploy_dependency_info.dat │ │ ├── Script-7EDCC3CF1C45E03B002F9851.sh │ │ ├── Script-C0CD3D981F59D20100F954DB.sh │ │ ├── Script-C0CD3D9B1F59DA8300F954DB.sh │ │ ├── all-product-headers.yaml │ │ ├── ios-deploy-all-non-framework-target-headers.hmap │ │ ├── ios-deploy-all-target-headers.hmap │ │ ├── ios-deploy-generated-files.hmap │ │ ├── ios-deploy-own-target-headers.hmap │ │ ├── ios-deploy-project-headers.hmap │ │ └── ios-deploy.hmap │ ├── demo │ ├── Entitlements.plist │ ├── Info.plist │ ├── Makefile │ ├── ResourceRules.plist │ └── demo.c │ ├── ios-deploy.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── shazron.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── xcshareddata │ │ └── xcschemes │ │ │ └── ios-deploy-tests.xcscheme │ └── xcuserdata │ │ └── shazron.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist │ ├── package.json │ └── src │ ├── ios-deploy-lib │ ├── libios_deploy.h │ └── libios_deploy.m │ ├── ios-deploy-tests │ ├── Info.plist │ └── ios_deploy_tests.m │ ├── ios-deploy │ ├── MobileDevice.h │ ├── device_db.h │ ├── errors.h │ ├── ios-deploy.m │ ├── lldb.py.h │ └── version.h │ └── scripts │ ├── .eslintrc.yml │ ├── check_reqs.js │ └── lldb.py └── 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 | [*] 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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | tmp/* 2 | node_modules/* 3 | blueprints/**/files/**/*.js 4 | tests/fixtures/* 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | !/dist/.keep 6 | /tmp 7 | 8 | # dependencies 9 | /node_modules 10 | /bower_components/* 11 | 12 | # misc 13 | /.sass-cache 14 | /connect.lock 15 | /coverage/* 16 | /libpeerconnection.log 17 | npm-debug.log 18 | testem.log 19 | .idea 20 | yarn-error.log 21 | .DS_Store 22 | *.swp 23 | 24 | ember-cordova/tmp-livereload 25 | ember-cordova/cordova/www/* 26 | !ember-cordova/cordova/www/.gitkeep 27 | ember-cordova/cordova/plugins/* 28 | !ember-cordova/cordova/plugins/.gitkeep 29 | ember-cordova/cordova/platforms/* 30 | !ember-cordova/cordova/platforms/.gitkeep 31 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "7" 4 | - "6" 5 | - "8" 6 | - "9" 7 | - "10" 8 | 9 | sudo: false 10 | 11 | cache: 12 | directories: 13 | - node_modules 14 | 15 | matrix: 16 | fast_finish: true 17 | 18 | before_install: 19 | - npm config set spin false 20 | - npm install -g bower phantomjs-prebuilt 21 | 22 | install: 23 | - npm install 24 | - bower install 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Isle of Code Inc 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. 8 | -------------------------------------------------------------------------------- /bin/corber: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | 4 | process.title = 'corber'; 5 | process.env.CORBER = true; 6 | 7 | const CLI = require('ember-cli/lib/cli/cli.js'); 8 | const Project = require('ember-cli/lib/models/project.js'); 9 | const UI = require('console-ui'); 10 | const resolve = require('resolve'); 11 | const path = require('path'); 12 | const requireAsHash = require('ember-cli/lib/utilities/require-as-hash'); 13 | const willInterruptProcess = require('ember-cli/lib/utilities/will-interrupt-process'); 14 | const exit = require('exit'); 15 | 16 | // `process` should be captured before we require any libraries which 17 | // may use `process.exit` work arounds for async cleanup. 18 | // See https://github.com/ember-cli/ember-cli/blob/953ba590d103fdf1161a385deb134805b6770553/lib/cli/index.js#L68 19 | willInterruptProcess.capture(process); 20 | 21 | function loadCommands() { 22 | const Command = require('ember-cli/lib/models/command.js'); 23 | let hash = requireAsHash('../lib/commands/*.js', Command); 24 | return hash; 25 | }; 26 | 27 | function loadTasks() { 28 | const Task = require('ember-cli/lib/models/task.js'); 29 | let hash = requireAsHash('../lib/tasks/*.js', Task); 30 | return hash; 31 | }; 32 | 33 | let ui = new UI({ 34 | inputStream: process.stdin, 35 | outputStream: process.stdout, 36 | errorStream: process.stderr, 37 | errorLog: [], 38 | }); 39 | 40 | let cli = new CLI({ 41 | ui, 42 | name: 'corber', 43 | npmPackage: 'corber', 44 | root: path.resolve(__dirname, '..'), 45 | disableDependencyChecker: true 46 | }); 47 | 48 | let project = Project.projectOrnullProject(ui, cli); 49 | 50 | let environment = { 51 | tasks: loadTasks(), 52 | cliArgs: process.argv.slice(2), 53 | commands: loadCommands(), 54 | project, 55 | settings: {} 56 | } 57 | 58 | let promise = cli.run(environment); 59 | 60 | promise.then(function(result) { 61 | let exitCode = typeof result === 'object' && result.exitCode ? result.exitCode : 0; 62 | exit(exitCode); 63 | }); 64 | promise.catch((error) => { 65 | let exitCode = typeof error === 'object' && result.exitCode ? result.exitCode : 1; 66 | exit(exitCode); 67 | }); 68 | 69 | return promise; 70 | -------------------------------------------------------------------------------- /bin/cordova-lib-runner: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const cordovaLib = require('cordova-lib'); 4 | 5 | // hook cordova-cli style logging up, corber will drop stdout without --verbose 6 | cordovaLib.cordova.on('log', console.log); 7 | cordovaLib.cordova.on('warn', console.error); 8 | 9 | // `lib/targets/cordova/tasks/raw.js` serializes all arguments into a single 10 | // string argument; this allow objects to be passed (e.g. options) 11 | let args = JSON.parse(process.argv[2]); 12 | let api = args.shift(); 13 | 14 | cordovaLib.cordova[api](...args); 15 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cordova", 3 | "dependencies": {} 4 | } 5 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | 3 | module.exports = function() { 4 | return { 5 | command: "./node_modules/.bin/mocha --harmony --compilers js:babel-register 'node-tests/**/*-test.js'", 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'corber' 3 | }; 4 | -------------------------------------------------------------------------------- /lib/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "browser": false, 3 | "node": true 4 | } 5 | -------------------------------------------------------------------------------- /lib/commands/cordova.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /* eslint-disable max-len */ 3 | 4 | var Command = require('./-command'); 5 | var logger = require('../utils/logger'); 6 | 7 | module.exports = Command.extend({ 8 | name: 'cordova', 9 | aliases: ['cdv'], 10 | description: 'Deprecated', 11 | 12 | run: function(options, rawArgs) { 13 | this._super.apply(this, arguments); 14 | 15 | logger.warn( 16 | '(DEPRECATION) The Cordova proxy command\n' + 17 | '\tcorber cdv \n' + 18 | 'has been deprecated in favour of\n' + 19 | '\tcorber proxy \n' + 20 | 'For example, "corber cdv run" is now "corber proxy run".' 21 | ); 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /lib/commands/devices.js: -------------------------------------------------------------------------------- 1 | const Command = require('./-command'); 2 | const Devices = require('../targets/cordova/tasks/devices'); 3 | const logger = require('../utils/logger'); 4 | 5 | module.exports = Command.extend({ 6 | name: 'devices', 7 | aliases: ['d'], 8 | description: 'List Devices', 9 | 10 | /* eslint-disable max-len */ 11 | availableOptions: [ 12 | ], 13 | /* eslint-enable max-len */ 14 | 15 | run(options) { 16 | this._super.apply(this, arguments); 17 | 18 | logger.info('Listing devices'); 19 | 20 | let devices = new Devices({ 21 | project: this.project 22 | }); 23 | 24 | return devices.run(); 25 | } 26 | }); 27 | 28 | -------------------------------------------------------------------------------- /lib/commands/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'build' : require('./build'), 3 | 'devices' : require('./devices'), 4 | 'init' : require('./init'), 5 | 'lint-index' : require('./lint-index'), 6 | 'make-icons' : require('./make-icons'), 7 | 'make-splashes' : require('./make-splashes'), 8 | 'open' : require('./open'), 9 | 'platform' : require('./platform'), 10 | 'plugin' : require('./plugin'), 11 | 'prepare' : require('./prepare'), 12 | 'proxy' : require('./proxy'), 13 | 'serve' : require('./serve'), 14 | 'start' : require('./start') 15 | }; 16 | -------------------------------------------------------------------------------- /lib/commands/lint-index.js: -------------------------------------------------------------------------------- 1 | const Command = require('./-command'); 2 | const getCordovaPath = require('../targets/cordova/utils/get-path'); 3 | const lint = require('../tasks/lint-index'); 4 | const path = require('path'); 5 | 6 | module.exports = Command.extend({ 7 | name: 'lint-index', 8 | description: 'Lints index.html for attributes with paths relative to root.', 9 | 10 | availableOptions: [{ 11 | name: 'source', 12 | type: String, 13 | default: 'www/index.html' 14 | }], 15 | 16 | run(options = {}) { 17 | let cordovaPath = getCordovaPath(this.project); 18 | let sourcePath = path.join(cordovaPath, options.source); 19 | 20 | return this._super(...arguments) 21 | .then(() => lint(sourcePath)); 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /lib/commands/make-icons.js: -------------------------------------------------------------------------------- 1 | const Command = require('./-command'); 2 | const iconTask = require('splicon/src/icon-task'); 3 | const expandPlatforms = require('./utils/expand-platforms'); 4 | const CorberError = require('../utils/corber-error'); 5 | const logger = require('../utils/logger'); 6 | const path = require('path'); 7 | 8 | module.exports = Command.extend({ 9 | name: 'make-icons', 10 | aliases: [ 'icons' ], 11 | description: 'Generates cordova icon files and updates config', 12 | 13 | availableOptions: [{ 14 | name: 'source', 15 | type: String, 16 | default: 'corber/icon.svg' 17 | }, { 18 | name: 'platform', 19 | type: Array, 20 | values: [ 21 | 'added', 22 | 'ios', 23 | 'android', 24 | 'windows', 25 | 'blackberry' 26 | ], 27 | default: ['added'] 28 | }], 29 | 30 | run(options) { 31 | let platforms; 32 | 33 | return this._super(...arguments) 34 | .then(() => expandPlatforms(this.project, options.platform)) 35 | .then((expandedPlatforms) => { 36 | platforms = expandedPlatforms; 37 | }) 38 | .then(() => { 39 | let platformsString = platforms.join(', '); 40 | logger.info(`corber: Generating icons for ${platformsString}`); 41 | }) 42 | .then(() => { 43 | return iconTask({ 44 | source: options.source, 45 | platforms: platforms, 46 | projectPath: path.join('corber', 'cordova') 47 | }).catch((e) => { 48 | throw new CorberError(e); 49 | }); 50 | }) 51 | .then(() => { 52 | logger.success('corber: icons generated'); 53 | }) 54 | .catch((e) => { 55 | if (e instanceof CorberError) { 56 | logger.error(e.message); 57 | return; 58 | } 59 | 60 | throw e; 61 | }); 62 | } 63 | }); 64 | -------------------------------------------------------------------------------- /lib/commands/make-splashes.js: -------------------------------------------------------------------------------- 1 | const Command = require('./-command'); 2 | const splashTask = require('splicon/src/splash-task'); 3 | const CorberError = require('../utils/corber-error'); 4 | const expandPlatforms = require('./utils/expand-platforms'); 5 | const logger = require('../utils/logger'); 6 | const path = require('path'); 7 | 8 | module.exports = Command.extend({ 9 | name: 'make-splashes', 10 | aliases: [ 'splashes' ], 11 | description: 'Generates cordova splash files and updates config', 12 | 13 | availableOptions: [{ 14 | name: 'source', 15 | type: String, 16 | default: 'corber/splash.svg' 17 | }, { 18 | name: 'platform', 19 | type: Array, 20 | values: [ 21 | 'added', 22 | 'ios', 23 | 'android' 24 | ], 25 | default: ['added'] 26 | }], 27 | 28 | run(options) { 29 | let platforms; 30 | 31 | return this._super(...arguments) 32 | .then(() => expandPlatforms(this.project, options.platform)) 33 | .then((expandedPlatforms) => { 34 | platforms = expandedPlatforms; 35 | }) 36 | .then(() => { 37 | let platformsString = platforms.join(', '); 38 | logger.info(`corber: Generating splashes for ${platformsString}`); 39 | }) 40 | .then(() => { 41 | return splashTask({ 42 | source: options.source, 43 | platforms: platforms, 44 | projectPath: path.join('corber', 'cordova') 45 | }).catch((e) => { 46 | throw new CorberError(e); 47 | }); 48 | }) 49 | .then(() => { 50 | logger.success('splashes generated'); 51 | }) 52 | .catch((e) => { 53 | if (e instanceof CorberError) { 54 | logger.error(e.message); 55 | return; 56 | } 57 | throw e; 58 | }); 59 | } 60 | }); 61 | -------------------------------------------------------------------------------- /lib/commands/open.js: -------------------------------------------------------------------------------- 1 | const Command = require('./-command'); 2 | const OpenAppTask = require('../targets/cordova/tasks/open-app'); 3 | const logger = require('../utils/logger'); 4 | 5 | module.exports = Command.extend({ 6 | name: 'open', 7 | aliases: [ 'o' ], 8 | description: 'Open the native platform project with the default or ' + 9 | 'specified application', 10 | 11 | availableOptions: [ 12 | { name: 'platform', type: String, default: 'ios' }, 13 | { name: 'application', type: String } 14 | ], 15 | 16 | run(options) { 17 | this._super(...arguments); 18 | 19 | logger.info(`Opening app for ${options.platform}`); 20 | 21 | let openAppTask = new OpenAppTask({ 22 | application: options.application, 23 | platform: options.platform, 24 | project: this.project 25 | }); 26 | 27 | return openAppTask.run() 28 | .catch((e) => { 29 | logger.error(e); 30 | throw e; 31 | }); 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /lib/commands/prepare.js: -------------------------------------------------------------------------------- 1 | const Command = require('./-command'); 2 | const Prepare = require('../targets/cordova/tasks/prepare'); 3 | const runHook = require('../tasks/run-hook'); 4 | const logger = require('../utils/logger'); 5 | 6 | module.exports = Command.extend({ 7 | name: 'prepare', 8 | description: 'Runs cordova prepare', 9 | 10 | availableOptions: [ 11 | { name: 'verbose', type: Boolean, default: false, aliases: ['v'] } 12 | ], 13 | 14 | run(options) { 15 | this._super(...arguments); 16 | 17 | let prepare = new Prepare({ 18 | project: this.project 19 | }); 20 | 21 | let hookOptions = { root: this.project.root }; 22 | 23 | return this._super(...arguments) 24 | .then(() => runHook('beforePrepare', options, hookOptions)) 25 | .then(() => prepare.run()) 26 | .then(() => runHook('afterPrepare', options, hookOptions)) 27 | .catch((e) => { 28 | logger.error(e.message ? e.message : e); 29 | throw e; 30 | }); 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /lib/commands/proxy.js: -------------------------------------------------------------------------------- 1 | const Command = require('./-command'); 2 | const getCordovaPath = require('../targets/cordova/utils/get-path'); 3 | const ValidateCordova = require('../targets/cordova/validators/is-installed'); 4 | const logger = require('../utils/logger'); 5 | const spawn = require('../utils/spawn'); 6 | 7 | module.exports = Command.extend({ 8 | name: 'proxy', 9 | description: 'Passes commands to Cordova CLI', 10 | 11 | supportedCommands: [ 12 | 'build', 13 | 'platform', 14 | 'platforms', 15 | 'plugin', 16 | 'plugins', 17 | 'prepare' 18 | ], 19 | 20 | knownCordovaCommands: [ 21 | 'run', 22 | 'emulate' 23 | ], 24 | 25 | onStdout: (data) => logger.stdout(data), 26 | onStderr: (data) => logger.stderr(data), 27 | 28 | validateAndRun(rawArgs) { 29 | let warning; 30 | 31 | if (this.supportedCommands.indexOf(rawArgs[0]) >= 0) { 32 | warning = rawArgs + 33 | ' run in cordova, but bypassed corber command.' + 34 | ` Consider running corber ${rawArgs} instead`; 35 | 36 | } else if (this.knownCordovaCommands.indexOf(rawArgs[0]) === -1) { 37 | warning = rawArgs + 38 | ' passed to Cordova, but is an unknown Cordova command'; 39 | 40 | } 41 | 42 | if (warning !== undefined) { 43 | logger.warn(warning); 44 | } 45 | 46 | return this.run({}, rawArgs); 47 | }, 48 | 49 | run(options, rawArgs) { 50 | this._super.apply(this, arguments); 51 | 52 | let isInstalled = new ValidateCordova({ 53 | project: this.project 54 | }); 55 | 56 | return isInstalled.run().then(() => { 57 | let joinedArgs = rawArgs.join(' '); 58 | let cdvCommand = 'cordova ' + joinedArgs; 59 | logger.success(`Running '${cdvCommand}'`); 60 | 61 | return spawn(cdvCommand, [], { shell: true }, { 62 | onStdout: this.onStdout, 63 | onStderr: this.onStderr, 64 | cwd: getCordovaPath(this.project) 65 | }).then(({ code }) => { 66 | if (code !== 0) { 67 | throw `'${cdvCommand}' failed with error code ${code}`; 68 | } 69 | }); 70 | }).catch((e) => { 71 | logger.error(e); 72 | }); 73 | } 74 | }); 75 | -------------------------------------------------------------------------------- /lib/commands/utils/expand-platforms.js: -------------------------------------------------------------------------------- 1 | const CorberError = require('../../utils/corber-error'); 2 | const getPlatforms = require('../../targets/cordova/utils/get-platforms'); 3 | 4 | module.exports = function expandPlatforms(project, platforms = []) { 5 | if (!platforms.includes('added')) { 6 | return Promise.resolve(platforms); 7 | } 8 | 9 | return getPlatforms(project).then((addedPlatforms) => { 10 | if (addedPlatforms.length === 0) { 11 | throw new CorberError('no added platforms to generate icons for'); 12 | } 13 | 14 | return addedPlatforms.reduce((arr, platform) => { 15 | if (arr.includes(platform)) { return arr; } 16 | arr.push(platform); 17 | return arr; 18 | }, platforms.filter((p) => p !== 'added')); 19 | }); 20 | }; 21 | -------------------------------------------------------------------------------- /lib/commands/utils/resolve-platform.js: -------------------------------------------------------------------------------- 1 | const getPlatforms = require('../../targets/cordova/utils/get-platforms'); 2 | const Promise = require('rsvp').Promise; 3 | 4 | const validPlatforms = ['ios', 'android']; 5 | const defaultPlatform = 'ios'; 6 | 7 | module.exports = function resolvePlatform(project, platform) { 8 | if (platform && !validPlatforms.includes(platform)) { 9 | return Promise.reject(`'${platform}' is not a valid platform`); 10 | } 11 | 12 | return getPlatforms(project).then((installedPlatforms) => { 13 | if (platform) { 14 | if (!installedPlatforms.includes(platform)) { 15 | let message = `'${platform}' is not an installed platform`; 16 | return Promise.reject(message); 17 | } 18 | 19 | return platform; 20 | } 21 | 22 | switch (installedPlatforms.length) { 23 | case 0: 24 | return Promise.reject('no platforms installed'); 25 | case 1: 26 | return installedPlatforms[0]; 27 | default: 28 | return defaultPlatform; 29 | } 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /lib/commands/version.js: -------------------------------------------------------------------------------- 1 | const Command = require('./-command'); 2 | const logger = require('../utils/logger'); 3 | const getVersions = require('../utils/get-versions'); 4 | const Promise = require('rsvp').Promise; 5 | 6 | module.exports = Command.extend({ 7 | name: 'version', 8 | aliases: ['v', '-v', '--version'], 9 | description: 'Prints the current version of Corber', 10 | scope: 'everywhere', 11 | 12 | run(options) { 13 | this._super.apply(this, arguments); 14 | 15 | let { 16 | corber: { 17 | global, 18 | project: { 19 | required, 20 | installed 21 | } 22 | }, 23 | node 24 | } = getVersions(this.project.root); 25 | 26 | if (global) { 27 | logger.info(`corber (global): ${global}`); 28 | } 29 | 30 | if (required) { 31 | logger.info(`corber (package.json): ${required}`); 32 | } 33 | 34 | if (installed) { 35 | logger.info(`corber (node_modules): ${installed}`); 36 | } 37 | 38 | logger.info(`node: ${node}`); 39 | 40 | return Promise.resolve(); 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /lib/frameworks/ember/tasks/update-watchman-config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable camelcase */ 2 | const Task = require('../../../tasks/-task'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const path = require('path'); 6 | const fsUtils = require('../../../utils/fs-utils'); 7 | const logger = require('../../../utils/logger'); 8 | const includes = require('lodash').includes; 9 | 10 | module.exports = Task.extend({ 11 | project: undefined, 12 | 13 | run() { 14 | logger.info('corber: updating .watchmanconfig'); 15 | 16 | let configPath = path.join(this.project.root, '.watchmanconfig') 17 | return fsUtils.read(configPath, { encoding: 'utf8' }) 18 | .then(function(config) { 19 | let json = JSON.parse(config); 20 | let ignored; 21 | 22 | if (json.ignore_dirs) { 23 | ignored = json.ignore_dirs; 24 | if (includes(ignored, 'corber') === false) { 25 | ignored.push('corber'); 26 | } 27 | } else { 28 | ignored = ['corber']; 29 | } 30 | 31 | json.ignore_dirs = ignored; 32 | 33 | let contents = JSON.stringify(json); 34 | 35 | return fsUtils.write(configPath, contents, 'utf8') 36 | .then(function() { 37 | logger.success('Added corber to watchman ignore'); 38 | }); 39 | }, function(err) { 40 | return Promise.reject( 41 | 'corber: failed to update .watchmanconfig, err: ' + err 42 | ); 43 | }); 44 | } 45 | }); 46 | /* eslint-enable camelcase */ 47 | -------------------------------------------------------------------------------- /lib/frameworks/ember/utils/get-cli-version.js: -------------------------------------------------------------------------------- 1 | const fsUtils = require('../../../utils/fs-utils'); 2 | const getPackage = require('../../../utils/get-package'); 3 | const path = require('path'); 4 | const semver = require('semver'); 5 | 6 | module.exports = function(root) { 7 | let emberCLIPackagePath = path.join( 8 | root, 9 | 'node_modules', 10 | 'ember-cli', 11 | 'package.json' 12 | ); 13 | 14 | if (fsUtils.existsSync(emberCLIPackagePath)) { 15 | let packageJSON = getPackage(emberCLIPackagePath); 16 | return packageJSON.version; 17 | } 18 | 19 | let packagePath = path.join(root, 'package.json'); 20 | let packageJSON = getPackage(packagePath); 21 | let { dependencies, devDependencies } = packageJSON; 22 | 23 | if (dependencies && dependencies['ember-cli']) { 24 | return semver.coerce(dependencies['ember-cli']).version; 25 | } 26 | 27 | if (devDependencies && devDependencies['ember-cli']) { 28 | return semver.coerce(devDependencies['ember-cli']).version; 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /lib/frameworks/ember/validators/browser-targets.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | const Task = require('../../../tasks/-task'); 3 | const rsvp = require('rsvp'); 4 | const semver = require('semver'); 5 | const path = require('path'); 6 | const getCLIVersion = require('../../../frameworks/ember/utils/get-cli-version'); 7 | const logger = require('../../../utils/logger'); 8 | const fsUtils = require('../../../utils/fs-utils'); 9 | const Promise = rsvp.Promise; 10 | 11 | const WEBSITE = 'http://corber.io/pages/frameworks/ember#configuring-browser-targets'; 12 | 13 | const CORBER_PLATFORM_REGEX = /process\.env\.CORBER_PLATFORM/; 14 | const EMBER_CLI_MIN_VERSION = '2.13.0'; 15 | /* eslint-enable max-len */ 16 | 17 | module.exports = Task.extend({ 18 | root: undefined, 19 | 20 | run() { 21 | let targetsPath = path.join(this.root, 'config', 'targets.js'); 22 | let targetsJs = path.join('config', 'targets.js'); 23 | let cliVersion = getCLIVersion(this.root); 24 | 25 | // targets.js doesn't exist prior to ember-cli 2.13 26 | if (!cliVersion || semver.lt(cliVersion, EMBER_CLI_MIN_VERSION)) { 27 | return Promise.resolve(); 28 | } 29 | 30 | if (!fsUtils.existsSync(targetsPath)) { 31 | logger.warn( 32 | `${targetsJs} was not found. When building with ember-cli 2.13 or ` 33 | + 'later, your project can be configured to generate platform-' 34 | + `optimized corber builds. See ${WEBSITE} for details.` 35 | ); 36 | 37 | return Promise.resolve(); 38 | } 39 | 40 | return fsUtils.read(targetsPath, { encoding: 'utf8' }).then((contents) => { 41 | if (!contents.match(CORBER_PLATFORM_REGEX)) { 42 | logger.warn( 43 | `${targetsJs} has not been configured for platform-optimized ` + 44 | `corber builds. See ${WEBSITE} for details.` 45 | ); 46 | } 47 | }); 48 | } 49 | }); 50 | -------------------------------------------------------------------------------- /lib/frameworks/ember/validators/location-type.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const Promise = require('rsvp').Promise; 3 | const chalk = require('chalk'); 4 | const logger = require('../../../utils/logger'); 5 | 6 | const MUST_SPECIFY_HASH = 7 | chalk.red('* config/environment.js: Cordova applications require:') + 8 | chalk.grey('\n`ENV.locationType = \'hash\'; \n'); 9 | 10 | module.exports = Task.extend({ 11 | config: undefined, 12 | force: false, 13 | 14 | run() { 15 | let config = this.config; 16 | let locationType = config.locationType; 17 | let isValidLocation = locationType === 'hash' || locationType === 'none'; 18 | 19 | if (!isValidLocation) { 20 | if (this.force === true) { 21 | var msg = MUST_SPECIFY_HASH; 22 | msg += 'You have passed the --force flag, so continuing'; 23 | logger.warn(msg); 24 | } else { 25 | return Promise.reject(MUST_SPECIFY_HASH); 26 | } 27 | } 28 | 29 | return Promise.resolve(); 30 | } 31 | }); 32 | -------------------------------------------------------------------------------- /lib/frameworks/framework.js: -------------------------------------------------------------------------------- 1 | const CoreObject = require('core-object'); 2 | const Promise = require('rsvp').Promise; 3 | 4 | module.exports = CoreObject.extend({ 5 | afterInstall() { 6 | return Promise.resolve(); 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /lib/frameworks/react/validators/homepage.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const path = require('path'); 3 | const getPackage = require('../../../utils/get-package'); 4 | const Promise = require('rsvp').Promise; 5 | const chalk = require('chalk'); 6 | 7 | module.exports = Task.extend({ 8 | root: undefined, 9 | 10 | warnMsg() { 11 | return chalk.red(` 12 | The homepage property in your package.json is undefined, 13 | or has a leading slash. 14 | 15 | Cordova applications use file based urls, and this will not work. 16 | Set the property to '' or './'` 17 | ); 18 | }, 19 | 20 | run() { 21 | let packagePath = path.join(this.root, 'package.json'); 22 | let packageJSON = getPackage(packagePath); 23 | let homepage = packageJSON.homepage; 24 | 25 | if (homepage === undefined || homepage && homepage[0] === '/') { 26 | return Promise.reject(this.warnMsg()); 27 | } else { 28 | return Promise.resolve(); 29 | } 30 | } 31 | }); 32 | -------------------------------------------------------------------------------- /lib/objects/device.js: -------------------------------------------------------------------------------- 1 | const CoreObject = require('core-object'); 2 | 3 | module.exports = CoreObject.extend({ 4 | id: undefined, 5 | uuid: undefined, 6 | name: undefined, 7 | platform: undefined, 8 | deviceType: undefined, 9 | state: undefined, 10 | 11 | label() { 12 | let display = `${this.platform} ${this.deviceType} - ${this.name}`; 13 | if (this.apiVersion) { 14 | display += ` API: ${this.apiVersion}` 15 | } 16 | 17 | return display; 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /lib/targets/android/target.js: -------------------------------------------------------------------------------- 1 | const CoreObject = require('core-object'); 2 | 3 | const bootEm = require('./tasks/boot-emulator'); 4 | const installAppEm = require('./tasks/install-app-emulator'); 5 | const installAppDevice = require('./tasks/install-app-device'); 6 | const launchApp = require('./tasks/launch-app'); 7 | const getApkPath = require('./utils/apk-path'); 8 | 9 | const CordovaTarget = require('../cordova/target'); 10 | const cdvConfig = require('../cordova/utils/get-config'); 11 | const cdvPath = require('../cordova/utils/get-path'); 12 | 13 | module.exports = CoreObject.extend({ 14 | device: undefined, 15 | packageName: undefined, 16 | project: undefined, 17 | isDebug: true, 18 | 19 | init() { 20 | this._super(...arguments); 21 | return cdvConfig(this.project).then((config) => { 22 | this.packageName = config.widget.$.id; 23 | }); 24 | }, 25 | 26 | build() { 27 | let cdvTarget = new CordovaTarget({ 28 | platform: 'android', 29 | project: this.project 30 | }); 31 | 32 | return cdvTarget.build(); 33 | }, 34 | 35 | run() { 36 | let device = this.device; 37 | return getApkPath(cdvPath(this.project), { 38 | debug: this.isDebug 39 | }).then((apkPath) => { 40 | if (device.deviceType === 'emulator') { 41 | return bootEm(device) 42 | .then(() => installAppEm(apkPath, device)) 43 | .then(() => launchApp(this.packageName)); 44 | } else { 45 | return installAppDevice(device.uuid, apkPath) 46 | .then(() => launchApp(this.packageName)); 47 | } 48 | }); 49 | } 50 | }); 51 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/boot-emulator.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const Promise = require('rsvp').Promise; 3 | const getEmulatorState = require('./get-emulator-state'); 4 | const sdkPaths = require('../utils/sdk-paths'); 5 | 6 | const defaultPollingInterval = 300; 7 | 8 | const pollDevices = function(emulator, spawnState, pollingInterval) { 9 | return getEmulatorState().then((emulatorState) => { 10 | // even if `emulatorState` is '1', reject if spawned process ended 11 | if (spawnState.error) { 12 | return Promise.reject(spawnState.error); 13 | } 14 | 15 | if (spawnState.isSettled) { 16 | return Promise.reject('emulator failed to start'); 17 | } 18 | 19 | if (emulatorState === '1') { 20 | return Promise.resolve(); 21 | } 22 | 23 | return new Promise((resolve, reject) => { 24 | setTimeout(() => { 25 | pollDevices(emulator, spawnState) 26 | .then(resolve) 27 | .catch(reject); 28 | }, pollingInterval); 29 | }); 30 | }); 31 | }; 32 | 33 | module.exports = function(emulator, pollingInterval = defaultPollingInterval) { 34 | let emulatorPath = sdkPaths().emulator; 35 | 36 | let boot = [ 37 | emulatorPath, 38 | ['-avd', emulator.name] 39 | ]; 40 | 41 | let spawnState = { 42 | isSettled: false, 43 | error: null 44 | }; 45 | 46 | spawn(...boot) 47 | .catch((error) => { 48 | spawnState.error = error; 49 | }).finally(() => { 50 | spawnState.isSettled = true 51 | }); 52 | 53 | return pollDevices(emulator, spawnState, pollingInterval); 54 | }; 55 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/get-emulator-state.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const sdkPaths = require('../utils/sdk-paths'); 3 | 4 | module.exports = function() { 5 | let adbPath = sdkPaths().adb; 6 | 7 | let emulatorState = [ 8 | adbPath, 9 | [ 10 | 'shell', 11 | 'getprop', 12 | 'sys.boot_completed' 13 | ] 14 | ]; 15 | 16 | return spawn(...emulatorState).then((result) => { 17 | let stdout = result.stdout.trim(); 18 | let stderr = result.stderr.trim(); 19 | 20 | //adb shell seems to always result in spawn.stderr 21 | if (stderr.length > 0) { 22 | return stderr; 23 | } 24 | 25 | return stdout; 26 | }); 27 | }; 28 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/install-app-device.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const sdkPaths = require('../utils/sdk-paths'); 3 | 4 | module.exports = function(deviceUUID, apkPath) { 5 | let adbPath = sdkPaths().adb; 6 | 7 | let install = [ 8 | adbPath, 9 | ['-s', deviceUUID, 'install', '-r', apkPath] 10 | ]; 11 | 12 | return spawn(...install); 13 | }; 14 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/install-app-emulator.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const sdkPaths = require('../utils/sdk-paths'); 3 | 4 | module.exports = function(apkPath) { 5 | let adbPath = sdkPaths().adb; 6 | 7 | let install = [ 8 | adbPath, 9 | ['-e', 'install', '-r', apkPath] 10 | ]; 11 | 12 | return spawn(...install); 13 | }; 14 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/kill-emulator.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const sdkPaths = require('../utils/sdk-paths'); 3 | 4 | module.exports = function(emulatorId) { 5 | let adbPath = sdkPaths().adb; 6 | 7 | let kill = [ 8 | adbPath, 9 | ['-s', emulatorId, 'emu', 'kill'] 10 | ]; 11 | 12 | return spawn(...kill); 13 | }; 14 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/launch-app.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const sdkPaths = require('../utils/sdk-paths'); 3 | 4 | module.exports = function(packageName) { 5 | let adbPath = sdkPaths().adb; 6 | 7 | let launch = [ 8 | adbPath, 9 | [ 10 | 'shell', 11 | 'monkey', 12 | '-p', 13 | packageName, 14 | '-c', 15 | 'android.intent.category.LAUNCHER', 16 | 1 17 | ] 18 | ]; 19 | 20 | return spawn(...launch); 21 | }; 22 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/list-devices.js: -------------------------------------------------------------------------------- 1 | const Device = require('../../../objects/device'); 2 | const spawn = require('../../../utils/spawn'); 3 | const sdkPaths = require('../utils/sdk-paths'); 4 | 5 | const deserializeDevices = function(list) { 6 | let devices = []; 7 | if (list === undefined) { return devices; } 8 | 9 | let items = list.split('\n'); 10 | items = items.splice(1, items.length - 1); 11 | 12 | items.forEach((item) => { 13 | if (item.trim() === '') { return; } 14 | 15 | let device = new Device({ 16 | name: item.split('model:')[1].split(' ')[0], 17 | uuid: item.split(' ')[0], 18 | deviceType: 'device', 19 | platform: 'android' 20 | }); 21 | 22 | devices.push(device); 23 | }); 24 | 25 | return devices; 26 | }; 27 | 28 | module.exports = function() { 29 | let adbPath = sdkPaths().adb; 30 | 31 | let list = [ 32 | adbPath, 33 | ['devices', '-l'] 34 | ]; 35 | 36 | return spawn(...list).then((result) => { 37 | let devices = deserializeDevices(result.stdout); 38 | return devices.reverse(); 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/list-emulators.js: -------------------------------------------------------------------------------- 1 | const Device = require('../../../objects/device'); 2 | const spawn = require('../../../utils/spawn'); 3 | const sdkPaths = require('../utils/sdk-paths'); 4 | 5 | module.exports = function() { 6 | let emulatorPath = sdkPaths().emulator; 7 | 8 | let list = [ 9 | emulatorPath, 10 | ['-list-avds'] 11 | ]; 12 | 13 | return spawn(...list).then((result) => { 14 | let emulators = []; 15 | 16 | let listedEmulators = result.stdout.split('\n'); 17 | listedEmulators.forEach((emulator, i) => { 18 | if (emulator && emulator !== '') { 19 | emulators.push(new Device({ 20 | name: emulator, 21 | deviceType: 'emulator', 22 | platform: 'android' 23 | })); 24 | } 25 | }); 26 | 27 | return emulators.reverse(); 28 | }); 29 | }; 30 | -------------------------------------------------------------------------------- /lib/targets/android/tasks/list-running-emulators.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const sdkPaths = require('../utils/sdk-paths'); 3 | 4 | module.exports = function() { 5 | let adbPath = sdkPaths().adb; 6 | 7 | let devices = [ 8 | adbPath, 9 | ['devices', '-l'] 10 | ]; 11 | 12 | return spawn(...devices).then((result) => { 13 | let devices = result.stdout.split('\n'); 14 | let emulators = []; 15 | 16 | devices.forEach((deviceString) => { 17 | let deviceId = deviceString.split(' ')[0]; 18 | 19 | //An emulator is booted when status goes from offline to device 20 | if (deviceId.indexOf('emulator') >= 0 21 | && deviceString.indexOf('device') >= 0) { 22 | emulators.push(deviceId); 23 | } 24 | }); 25 | 26 | return emulators; 27 | }); 28 | }; 29 | -------------------------------------------------------------------------------- /lib/targets/android/utils/apk-path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const RSVP = require('rsvp'); 3 | const fs = require('fs'); 4 | const logger = require('../../../utils/logger'); 5 | const Promise = RSVP.Promise; 6 | 7 | module.exports = function(root, opts = {}) { 8 | let buildType = opts.debug ? 'debug' : 'release'; 9 | 10 | //directory differs if build was with gradle vs studio 11 | /* eslint-disable max-len */ 12 | let basePath = path.join(root, 'platforms', 'android'); 13 | let gradlePath = path.join(basePath, 'build', 'outputs', 'apk', buildType); 14 | let studioPath = path.join(basePath, 'app', 'build', 'outputs', 'apk', buildType); 15 | /* eslint-enable max-len */ 16 | 17 | let apkPaths = [gradlePath, studioPath].reduce((arr, dir) => { 18 | if (!fs.existsSync(dir)) { 19 | return arr; 20 | } 21 | 22 | fs.readdirSync(dir).forEach((name) => { 23 | if (name.match(/\.apk$/i)) { 24 | arr.push(path.join(dir, name)) 25 | } 26 | }); 27 | 28 | return arr; 29 | }, []); 30 | 31 | if (apkPaths.length === 0) { 32 | return Promise.reject('No apk found') 33 | } 34 | 35 | if (apkPaths.length > 1) { 36 | logger.warn(`More than one apk found; using ${apkPaths[0]}`) 37 | } 38 | 39 | return Promise.resolve(apkPaths[0]); 40 | }; 41 | -------------------------------------------------------------------------------- /lib/targets/android/utils/resolve-path.js: -------------------------------------------------------------------------------- 1 | const fsUtils = require('../../../utils/fs-utils'); 2 | 3 | module.exports = function(paths) { 4 | let resolvedPath = paths.find((path) => { 5 | return fsUtils.existsSync(path); 6 | }); 7 | 8 | return resolvedPath; 9 | }; 10 | -------------------------------------------------------------------------------- /lib/targets/android/utils/sdk-paths.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const sdkRoot = require('./sdk-root'); 3 | const resolvePath = require('./resolve-path'); 4 | const logger = require('../../../utils/logger') 5 | 6 | module.exports = function() { 7 | let root = sdkRoot(); 8 | if (root === undefined) { 9 | logger.error( 10 | 'ANDROID_SDK_ROOT ENV variable not found ' + 11 | 'It is recommended to set this value in bash_profile or bashrc' 12 | ); 13 | 14 | return; 15 | } 16 | 17 | let adbPath = path.join(root, 'platform-tools', 'adb'); 18 | 19 | let emulatorPaths = [ 20 | path.join(root, 'emulator', 'emulator'), 21 | path.join(root, 'tools', 'emulator') 22 | ]; 23 | 24 | if (process.platform === 'win32') { 25 | adbPath += '.exe'; 26 | emulatorPaths = emulatorPaths.map((p) => p + '.exe'); 27 | } 28 | 29 | return { 30 | adb: resolvePath([adbPath]), 31 | emulator: resolvePath(emulatorPaths) 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /lib/targets/android/utils/sdk-root.js: -------------------------------------------------------------------------------- 1 | module.exports = function() { 2 | return process.env['ANDROID_SDK_ROOT']; 3 | }; 4 | -------------------------------------------------------------------------------- /lib/targets/cordova/target.js: -------------------------------------------------------------------------------- 1 | const CoreObject = require('core-object'); 2 | const Build = require('./tasks/build'); 3 | const ValidatePlugin = require('./validators/plugin'); 4 | const ValidateSigningIdentity = require('../ios/validators/signing-identity'); 5 | const AllowNavigation = require('./validators/allow-navigation'); 6 | const runValidators = require('../../utils/run-validators'); 7 | 8 | module.exports = CoreObject.extend({ 9 | platform: undefined, 10 | project: undefined, 11 | browserify: false, 12 | signingIdentityValidation: undefined, 13 | cordovaOpts: {}, 14 | 15 | _buildValidators(isServing, skipCordovaBuild = false) { 16 | let validators = []; 17 | 18 | validators.push( 19 | new AllowNavigation({ 20 | project: this.project, 21 | rejectIfUndefined: isServing 22 | }).run() 23 | ); 24 | 25 | if (this.platform === 'ios') { 26 | let validation = new ValidateSigningIdentity({ 27 | project: this.project, 28 | buildConfigName: this.cordovaOpts.release ? 'release' : 'debug', 29 | logLevel: 'warn' 30 | }); 31 | 32 | validators.push(validation.run()); 33 | 34 | // build command will inspect this to show message after error code 65 35 | this.signingIdentityValidation = validation; 36 | } 37 | 38 | return validators; 39 | }, 40 | 41 | validateBuild(skipCordovaBuild) { 42 | let validators = this._buildValidators(false, skipCordovaBuild); 43 | 44 | return runValidators(validators); 45 | }, 46 | 47 | validateServe() { 48 | let validators = this._buildValidators(true); 49 | 50 | validators.push( 51 | new ValidatePlugin({ 52 | project: this.project, 53 | platform: this.platform, 54 | pluginName: 'cordova-plugin-whitelist' 55 | }).run() 56 | ); 57 | 58 | return runValidators(validators); 59 | }, 60 | 61 | build() { 62 | let cordovaBuild = new Build({ 63 | project: this.project, 64 | platform: this.platform, 65 | cordovaOpts: this.cordovaOpts, 66 | browserify: this.browserify 67 | }); 68 | 69 | return cordovaBuild.run(); 70 | } 71 | }); 72 | -------------------------------------------------------------------------------- /lib/targets/cordova/tasks/build.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const CordovaRaw = require('./raw'); 3 | 4 | module.exports = Task.extend({ 5 | project: undefined, 6 | 7 | platform: undefined, 8 | cordovaOpts: {}, 9 | browserify: false, 10 | 11 | run() { 12 | let build = new CordovaRaw({ 13 | project: this.project, 14 | api: 'build', 15 | }); 16 | 17 | return build.run({ 18 | platforms: [this.platform], 19 | options: this.cordovaOpts, 20 | browserify: this.browserify, 21 | emulator: true 22 | }); 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /lib/targets/cordova/tasks/create-project.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const cordovaPath = require('../utils/get-path'); 3 | const fsUtils = require('../../../utils/fs-utils'); 4 | const logger = require('../../../utils/logger'); 5 | const camelize = require('../../../utils/string.js').camelize; 6 | 7 | const Promise = require('rsvp'); 8 | const cordovaProj = require('cordova-lib').cordova; 9 | 10 | module.exports = Task.extend({ 11 | id: undefined, 12 | name: undefined, 13 | templatePath: undefined, 14 | project: undefined, 15 | 16 | run() { 17 | let cdvPath = cordovaPath(this.project, false); 18 | 19 | if (!fsUtils.existsSync(cdvPath)) { 20 | let id = camelize(this.id); 21 | let name = camelize(this.name); 22 | 23 | let config = { 24 | lib: { 25 | www: {} 26 | } 27 | }; 28 | 29 | if (this.templatePath !== undefined) { 30 | config.lib.www.url = this.templatePath; 31 | } 32 | 33 | return cordovaProj.create(cdvPath, id, name, config); 34 | } else { 35 | logger.warn('Cordova dir already exists, please ensure it is valid'); 36 | return Promise.resolve(); 37 | } 38 | } 39 | }); 40 | -------------------------------------------------------------------------------- /lib/targets/cordova/tasks/devices.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const CordovaRaw = require('./raw'); 3 | 4 | module.exports = Task.extend({ 5 | project: undefined, 6 | verbose: false, 7 | 8 | run() { 9 | let devices = new CordovaRaw({ 10 | project: this.project, 11 | api: 'targets', 12 | }); 13 | 14 | return devices.run(); 15 | } 16 | }); 17 | -------------------------------------------------------------------------------- /lib/targets/cordova/tasks/open-app.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const logger = require('../../../utils/logger'); 3 | const getOpenCommand = require('../../../utils/open-app-command'); 4 | const getCordovaPath = require('../utils/get-path'); 5 | const getConfig = require('../utils/get-config'); 6 | const fsUtils = require('../../../utils/fs-utils'); 7 | const spawn = require('../../../utils/spawn'); 8 | const Promise = require('rsvp').Promise; 9 | const path = require('path'); 10 | 11 | module.exports = Task.extend({ 12 | application: undefined, 13 | platform: undefined, 14 | project: undefined, 15 | 16 | onStdout: (data) => logger.stdout(data), 17 | onStderr: (data) => logger.stderr(data), 18 | 19 | run() { 20 | return this.getProjectFilePath(this.platform, this.project) 21 | .then((projectFilePath) => { 22 | let openCommand = getOpenCommand(projectFilePath, this.application); 23 | 24 | return spawn(openCommand, [], { shell: true }, { 25 | onStdout: this.onStdout, 26 | onStderr: this.onStderr, 27 | cwd: this.project.root 28 | }).then(({ code }) => { 29 | if (code !== 0) { 30 | throw `'${openCommand}' failed with error code ${code}`; 31 | } 32 | }); 33 | }); 34 | }, 35 | 36 | getProjectFilePath(platform, project) { 37 | switch (platform) { 38 | case 'ios': 39 | return this.getIOSProjectFilePath(project); 40 | default: 41 | return Promise.reject(`Open is not supported for ${platform}`); 42 | } 43 | }, 44 | 45 | getIOSProjectFilePath(project) { 46 | let cordovaPath = getCordovaPath(project); 47 | let iosPath = path.join(cordovaPath, 'platforms', 'ios'); 48 | 49 | return getConfig(project).then((config) => { 50 | let appName = config.widget.name[0]; 51 | let xcworkspacePath = path.join(iosPath, `${appName}.xcworkspace`); 52 | let xcodeprojPath = path.join(iosPath, `${appName}.xcodeproj`); 53 | 54 | return fsUtils.existsSync(xcworkspacePath) ? 55 | xcworkspacePath : 56 | xcodeprojPath; 57 | }); 58 | } 59 | }); 60 | -------------------------------------------------------------------------------- /lib/targets/cordova/tasks/platform.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const CordovaRaw = require('./raw'); 3 | const SetupWebView = require('./setup-webview'); 4 | 5 | module.exports = Task.extend({ 6 | project: undefined, 7 | 8 | run(action, platform, opts) { 9 | let saveOpts = { save: opts.save, link: opts.link, fetch: true }; 10 | 11 | let platformTask = new CordovaRaw({ 12 | project: this.project, 13 | api: 'platforms' 14 | }); 15 | 16 | return platformTask.run(action, platform, saveOpts).then(() => { 17 | //By default we upgrade the default WebView in IOS 18 | if (action === 'add') { 19 | let setup = new SetupWebView({ 20 | project: this.project, 21 | platform: platform, 22 | crosswalk: opts.crosswalk, 23 | uiwebview: opts.uiwebview 24 | }); 25 | 26 | return setup.run(); 27 | } 28 | }); 29 | } 30 | }); 31 | 32 | -------------------------------------------------------------------------------- /lib/targets/cordova/tasks/prepare.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const CordovaRaw = require('./raw'); 3 | const logger = require('../../../utils/logger'); 4 | 5 | module.exports = Task.extend({ 6 | project: undefined, 7 | 8 | run() { 9 | logger.info('Running cordova prepare'); 10 | let prepare = new CordovaRaw({ 11 | project: this.project, 12 | api: 'prepare', 13 | }); 14 | 15 | return prepare.run({ fetch: true }); 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /lib/targets/cordova/tasks/raw.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const getCordovaPath = require('../utils/get-path'); 3 | const spawn = require('../../../utils/spawn'); 4 | const logger = require('../../../utils/logger'); 5 | const path = require('path'); 6 | 7 | const runnerPath = path.resolve( 8 | __dirname, '..', '..', '..', '..', 9 | 'bin', 10 | 'cordova-lib-runner' 11 | ); 12 | 13 | module.exports = Task.extend({ 14 | project: undefined, 15 | api: undefined, 16 | 17 | // hide all cordova-lib stdout unless `--verbose` flag is set explicitly 18 | onStdout: (data) => logger.stdoutVerbose(data), 19 | onStderr: (data) => logger.stderr(data), 20 | 21 | run(...args) { 22 | args.unshift(this.api); 23 | 24 | // in order to pass mixed-type arguments (including POJOs) safely, we 25 | // serialize all arguments to a single string argument 26 | let serializedArgs = JSON.stringify(args); 27 | 28 | return spawn(runnerPath, [serializedArgs], {}, { 29 | onStdout: this.onStdout, 30 | onStderr: this.onStderr, 31 | cwd: getCordovaPath(this.project), 32 | fork: true 33 | }); 34 | } 35 | }); 36 | -------------------------------------------------------------------------------- /lib/targets/cordova/tasks/setup-webview.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | 3 | const CordovaRaw = require('../../../targets/cordova/tasks/raw'); 4 | const logger = require('../../../utils/logger'); 5 | const Promise = require('rsvp').Promise; 6 | 7 | module.exports = Task.extend({ 8 | project: undefined, 9 | platform: undefined, 10 | uiwebview: false, 11 | crosswalk: false, 12 | 13 | warnPlatform(platform, view) { 14 | logger.warn( 15 | 'You have specified platform=' + platform + ' and ' + view + '.' + 16 | 'Crosswalk is only available on android. This will have no effect.' 17 | ); 18 | }, 19 | 20 | warnIosView() { 21 | logger.warn( 22 | 'corber initializes ios with the upgraded WKWebView. ' + 23 | 'See http://corber.io/pages/workflow/default_webviews for details and flags' 24 | ); 25 | }, 26 | 27 | run() { 28 | let viewName, upgradeWebView; 29 | 30 | upgradeWebView = new CordovaRaw({ 31 | project: this.project, 32 | api: 'plugins' 33 | }); 34 | 35 | if (this.platform === 'ios') { 36 | if (this.crosswalk === true) { 37 | this.warnPlatform('ios', 'crosswalk=true'); 38 | } else if (this.uiwebview === false) { 39 | this.warnIosView(); 40 | viewName = 'cordova-plugin-wkwebview-engine'; 41 | } 42 | } else if (this.platform === 'android') { 43 | if (this.uiwebview === true) { 44 | this.warnPlatform('android', 'uiwebview=true'); 45 | } else if (this.crosswalk === true) { 46 | viewName = 'cordova-plugin-crosswalk-webview'; 47 | } 48 | } 49 | 50 | if (viewName) { 51 | logger.success( 52 | 'Initializing cordova with upgraded WebView ' + viewName 53 | ); 54 | } else { 55 | logger.success('Initializing cordova with default WebView'); 56 | } 57 | 58 | if (viewName !== undefined) { 59 | return upgradeWebView.run('add', viewName, { 60 | save: true, 61 | fetch: true 62 | }); 63 | } else { 64 | return Promise.resolve(); 65 | } 66 | } 67 | }); 68 | -------------------------------------------------------------------------------- /lib/targets/cordova/utils/cordova-assets.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const logger = require('../../../utils/logger'); 3 | const existsSync = require('../../../utils/fs-utils').existsSync; 4 | 5 | module.exports = { 6 | getPaths(platform, projectPath) { 7 | let platformsPath = 'platforms'; 8 | let assetsPath; 9 | 10 | if (platform === 'ios') { 11 | assetsPath = path.join(platformsPath, 'ios', 'www'); 12 | } else if (platform === 'android') { 13 | assetsPath = path.join(platformsPath, 'android', 'assets', 'www'); 14 | // cordova-android 7.0 no longer provides assets/www path. 15 | // so use android/platform_www instead 16 | if (!this._exists(assetsPath)) { 17 | assetsPath = path.join(platformsPath, 'android', 'platform_www'); 18 | } 19 | } else if (platform === 'browser') { 20 | assetsPath = path.join(platformsPath, 'browser', 'www'); 21 | } 22 | 23 | let files = ['cordova_plugins.js', 'cordova.js']; 24 | 25 | let pluginPath = path.join(projectPath, assetsPath, 'plugins'); 26 | if (this._exists(pluginPath)) { 27 | files.push('plugins/**'); 28 | } 29 | 30 | return { 31 | assetsPath: assetsPath, 32 | files: files 33 | } 34 | }, 35 | 36 | /* eslint-disable max-len */ 37 | validatePaths(assetsPath, projectPath) { 38 | if (assetsPath === undefined) { 39 | throw new Error('corber: Platform asset path undefined, cant build'); 40 | } 41 | 42 | let platformPath = path.join(projectPath, assetsPath, 'cordova.js'); 43 | let pluginPath = path.join(projectPath, assetsPath, 'cordova_plugins.js'); 44 | 45 | if (!existsSync(platformPath) || !existsSync(pluginPath)) { 46 | logger.warn( 47 | 'Did not find cordova.js or cordova_plugins.js at ' + 48 | assetsPath + 49 | '. Ember App LiveReload will still work, but device & plugin APIS will fail.' 50 | ); 51 | } 52 | }, 53 | /* eslint-enable max-len */ 54 | 55 | _exists(path) { 56 | return existsSync(path); 57 | } 58 | }; 59 | -------------------------------------------------------------------------------- /lib/targets/cordova/utils/get-app-name.js: -------------------------------------------------------------------------------- 1 | const getConfig = require('./get-config'); 2 | 3 | module.exports = function(project) { 4 | return getConfig(project).then((config) => { 5 | return config.widget.name[0]; 6 | }); 7 | }; 8 | -------------------------------------------------------------------------------- /lib/targets/cordova/utils/get-config.js: -------------------------------------------------------------------------------- 1 | const cordovaPath = require('./get-path'); 2 | const parseXml = require('../../../utils/parse-xml'); 3 | const path = require('path'); 4 | 5 | module.exports = function getCordovaConfig(project) { 6 | let cdvPath = cordovaPath(project); 7 | let configPath = path.join(cdvPath, 'config.xml'); 8 | 9 | return parseXml(configPath); 10 | }; 11 | -------------------------------------------------------------------------------- /lib/targets/cordova/utils/get-path.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = function cordovaPath(project, excludeCordova) { 4 | let cdvPath = path.join(project.root, 'corber'); 5 | 6 | return excludeCordova ? 7 | cdvPath : 8 | path.join(cdvPath, 'cordova'); 9 | }; 10 | -------------------------------------------------------------------------------- /lib/targets/cordova/utils/get-platforms.js: -------------------------------------------------------------------------------- 1 | const getCordovaPath = require('./get-path'); 2 | const fsUtils = require('../../../utils/fs-utils'); 3 | const getPackage = require('../../../utils/get-package'); 4 | const parseXml = require('../../../utils/parse-xml'); 5 | const Promise = require('rsvp').Promise; 6 | const path = require('path'); 7 | const lodash = require('lodash'); 8 | 9 | module.exports = function getPlatforms(project = {}) { 10 | if (project.root === undefined) { 11 | throw new Error('\'root\' property missing from project'); 12 | } 13 | 14 | let cordovaPath = getCordovaPath(project); 15 | let packageJSONPath = path.join(cordovaPath, 'package.json'); 16 | let configXMLPath = path.join(cordovaPath, 'config.xml'); 17 | 18 | if (fsUtils.existsSync(packageJSONPath)) { 19 | let packageJSON = getPackage(packageJSONPath); 20 | let platforms = lodash.get(packageJSON, 'cordova.platforms'); 21 | if (platforms) { 22 | return Promise.resolve(platforms); 23 | } 24 | } 25 | 26 | if (fsUtils.existsSync(configXMLPath)) { 27 | return parseXml(configXMLPath).then((json) => { 28 | let engine = lodash.get(json, 'widget.engine') || []; 29 | return engine.map(p => p.$.name); 30 | }); 31 | } 32 | 33 | return Promise.resolve([]); 34 | }; 35 | -------------------------------------------------------------------------------- /lib/targets/cordova/utils/parse-build-flags.js: -------------------------------------------------------------------------------- 1 | const _pick = require('lodash').pick; 2 | 3 | const CORDOVA_OPTS = [ 4 | 'release', 5 | 'debug', 6 | 'emulator', 7 | 'device', 8 | 'buildConfig' 9 | ]; 10 | 11 | const IOS_OPTS = [ 12 | 'codeSignIdentity', 13 | 'provisioningProfile', 14 | 'codesignResourceRules', 15 | 'developmentTeam', 16 | 'packageType' 17 | ]; 18 | 19 | const ANDROID_OPTS = [ 20 | 'keystore', 21 | 'storePassword', 22 | 'alias', 23 | 'password', 24 | 'keystoreType', 25 | 'gradleArg', 26 | 'cdvBuildMultipleApks', 27 | 'cdvVersionCode', 28 | 'cdvReleaseSigningPropertiesFile', 29 | 'cdvDebugSigningPropertiesFile', 30 | 'cdvMinSdkVersion', 31 | 'cdvBuildToolsVersion', 32 | 'cdvCompileSdkVersion', 33 | 'packageType' 34 | ]; 35 | 36 | module.exports = function(platform, options) { 37 | let platformKeys = []; 38 | 39 | if (platform === 'ios') { 40 | platformKeys = IOS_OPTS; 41 | } else if (platform === 'android') { 42 | platformKeys = ANDROID_OPTS; 43 | } 44 | 45 | let ret = _pick(options, CORDOVA_OPTS.concat(platformKeys)); 46 | ret.argv = [].concat(...platformKeys 47 | .filter((key) => options.hasOwnProperty(key)) 48 | .map((key) => [`--${key}`, options[key]])); 49 | 50 | return ret; 51 | }; 52 | -------------------------------------------------------------------------------- /lib/targets/cordova/validators/addon-args.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const Promise = require('rsvp').Promise; 3 | const _pullAll = require('lodash').pullAll; 4 | const _intersection = require('lodash').intersection; 5 | 6 | const addCmds = ['add', 'a']; 7 | const rmCmds = ['remove', 'rm', 'r']; 8 | 9 | /* 10 | For a given platform/plugin command, return a hash with: 11 | { 12 | action: add or remove, 13 | name: name of platform/plugin, e.g. ios, 14 | varOpts: formatted plugin vars to cordova standards 15 | } 16 | */ 17 | 18 | module.exports = Task.extend({ 19 | rawArgs: undefined, 20 | api: undefined, 21 | varOpts: undefined, 22 | 23 | //cordova commands are long strings - we need to manually see if it is add/rm 24 | getAction(rawArgs) { 25 | if (_intersection(rawArgs, addCmds).length > 0) { 26 | return 'add'; 27 | } else if (_intersection(rawArgs, rmCmds).length > 0) { 28 | return 'remove' 29 | } 30 | }, 31 | 32 | //rm add/remove text from arguments 33 | getTargetName(rawArgs, opts = {}) { 34 | let availableActions = addCmds.concat(rmCmds); 35 | _pullAll(rawArgs, availableActions); 36 | return opts.multi ? rawArgs : rawArgs[0]; 37 | }, 38 | 39 | /* 40 | Vars are passed from ember-cli as 'VAR_NAME=VALUE' 41 | Cordova requires { VAR_NAME: 'VALUE' } 42 | */ 43 | hashifyVars(opts) { 44 | if (opts === undefined) { return {} } 45 | 46 | let hashedOpts = {}; 47 | opts.forEach(function(s) { 48 | let eq = s.indexOf('='); 49 | let key = s.substr(0, eq).toUpperCase(); 50 | let val = s.substr(eq + 1, s.length); 51 | hashedOpts[key] = val; 52 | }); 53 | 54 | return hashedOpts; 55 | }, 56 | 57 | run() { 58 | let action, targetName, sanitized; 59 | 60 | action = this.getAction(this.rawArgs); 61 | if (!action) { 62 | let cmd = `corber ${this.api} add ios`; 63 | return Promise.reject('Missing add/rm flag, e.g. ' + cmd); 64 | } 65 | 66 | //Cooerce rawArgs/Opts to cordova spec 67 | targetName = this.getTargetName(this.rawArgs, { multi: this.multi }); 68 | let hashedOpts = this.hashifyVars(this.varOpts); 69 | 70 | sanitized = { 71 | action: action, 72 | name: targetName, 73 | varOpts: hashedOpts 74 | }; 75 | 76 | return Promise.resolve(sanitized); 77 | } 78 | }); 79 | -------------------------------------------------------------------------------- /lib/targets/cordova/validators/is-installed.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const Promise = require('rsvp').Promise; 3 | const commandExists = require('../../../utils/command-exists'); 4 | 5 | const cordovaInstallText = '\n' + 6 | 'The command `cordova` was not found. This likely ' + 7 | 'means you need to install cordova globally. Please run the following ' + 8 | 'command to continue.\n\t' + 9 | 'npm install cordova -g \n' + 10 | 'installed by checking that the following command returns the currently ' + 11 | 'installed version:\n\t'; 12 | 13 | module.exports = Task.extend({ 14 | options: undefined, 15 | 16 | run() { 17 | if (this.options && this.options.skipCordovaCheck === true) { 18 | return Promise.resolve(); 19 | } 20 | 21 | let result = commandExists('cordova'); 22 | 23 | if (result) { 24 | return Promise.resolve(); 25 | } 26 | 27 | return Promise.reject(cordovaInstallText); 28 | } 29 | }); 30 | -------------------------------------------------------------------------------- /lib/targets/cordova/validators/plugin.js: -------------------------------------------------------------------------------- 1 | const Task = require('../../../tasks/-task'); 2 | const CordovaValidator = require('../utils/cordova-validator'); 3 | 4 | module.exports = Task.extend({ 5 | pluginName: undefined, 6 | project: undefined, 7 | platform: undefined, 8 | 9 | createValidator() { 10 | return new CordovaValidator({ 11 | project: this.project, 12 | platform: this.platform, 13 | desiredKeyName: this.pluginName, 14 | type: 'plugin', 15 | dir: 'plugins/', 16 | jsonPath: 'plugins/fetch.json' 17 | }); 18 | }, 19 | 20 | run() { 21 | let validator = this.createValidator(); 22 | 23 | return validator.validateCordovaConfig() 24 | .then(validator.validateCordovaJSON.bind(validator)) 25 | .then(validator.validatePluginJSON.bind(validator)) 26 | .then(validator.validateDirExists.bind(validator)); 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/boot-emulator.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const Promise = require('rsvp').Promise; 3 | 4 | module.exports = function(emulator) { 5 | let boot = [ 6 | '/usr/bin/xcrun', 7 | ['simctl', 'boot', emulator.uuid] 8 | ]; 9 | 10 | if (emulator.state !== 'Booted') { 11 | return spawn(...boot); 12 | } else { 13 | return Promise.resolve(); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/build.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | 3 | module.exports = function(device, derivedPath, scheme, iosPath) { 4 | let destination = `id=${device.uuid}`; 5 | 6 | let buildArgs = [ 7 | '-workspace', `${iosPath}/${scheme}.xcworkspace`, 8 | '-scheme', scheme, 9 | '-destination', destination 10 | ]; 11 | 12 | if (device.deviceType === 'emulator') { 13 | buildArgs.push('-configuration'); 14 | buildArgs.push('Debug'); 15 | buildArgs.push('-derivedDataPath'); 16 | buildArgs.push(derivedPath); 17 | buildArgs.push('CODE_SIGN_REQUIRED=NO'); 18 | buildArgs.push('CODE_SIGN_IDENTITY='); 19 | } 20 | 21 | let build = [ 22 | '/usr/bin/xcodebuild', 23 | buildArgs, 24 | { 25 | cwd: iosPath 26 | }, 27 | ]; 28 | 29 | return spawn(...build); 30 | }; 31 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/get-ipa-path.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const path = require('path'); 3 | 4 | module.exports = function(scheme, iosPath) { 5 | let workspacePath = path.join(iosPath, `${scheme}.xcworkspace`); 6 | 7 | let getBuildInfo = [ 8 | '/usr/bin/xcodebuild', 9 | ['-workspace', workspacePath, 10 | '-scheme', scheme, 11 | '-showBuildSettings'] 12 | ]; 13 | 14 | return spawn(...getBuildInfo).then(function(buildInfo) { 15 | let buildDir = buildInfo.stdout.split('BUILD_DIR')[1].split('\n')[0]; 16 | buildDir = buildDir.split('=')[1].trim(); 17 | 18 | let ipaPath = path.join(buildDir, 'Debug-iphoneos', `${scheme}.app`); 19 | 20 | return ipaPath; 21 | }); 22 | }; 23 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/install-app-device.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const path = require('path'); 3 | 4 | module.exports = function(deviceId, bundlePath, root) { 5 | let iosDeploy = path.join( 6 | root, 7 | 'node_modules', 8 | 'corber', 9 | 'vendor', 10 | 'ios-deploy', 11 | 'build', 12 | 'Release', 13 | 'ios-deploy' 14 | ); 15 | 16 | let install = [ 17 | iosDeploy, 18 | [ 19 | '--id', 20 | deviceId, 21 | '--bundle', 22 | bundlePath, 23 | '--justlaunch' 24 | ] 25 | ]; 26 | 27 | return spawn(...install); 28 | }; 29 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/install-app-emulator.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | 3 | module.exports = function(emulatorId, ipaPath) { 4 | let install = [ 5 | '/usr/bin/xcrun', 6 | ['simctl', 'install', emulatorId, ipaPath] 7 | ]; 8 | 9 | return spawn(...install); 10 | }; 11 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/launch-app-emulator.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | 3 | module.exports = function(emulatorId, appName) { 4 | let launch = [ 5 | '/usr/bin/xcrun', 6 | ['simctl', 'launch', emulatorId, appName] 7 | ]; 8 | 9 | return spawn(...launch); 10 | }; 11 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/list-devices.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const Device = require('../../../objects/device'); 3 | 4 | const deserializeDevices = function(stdout) { 5 | let devices = []; 6 | if (stdout === undefined) { return devices; } 7 | 8 | let list = stdout.split('\n'); 9 | 10 | //First line is always '== Devices ==' 11 | list.shift(); 12 | 13 | for (let item of list) { 14 | let line = item.trim(); 15 | 16 | if (line === '') { continue; } 17 | if (line === '== Simulators ==') { break; } 18 | 19 | let split = item.split(/[(]|[[]/g); 20 | 21 | let deviceName = split[0].trim(); 22 | //Cant exclude from device list 23 | if (deviceName.includes('MacBook')) { 24 | continue; 25 | } 26 | 27 | let apiVersion = split[1].replace(')', '').trim(); 28 | let uuid = split[split.length - 1].replace(')', '').trim(); 29 | 30 | let device = new Device({ 31 | platform: 'ios', 32 | deviceType: 'device', 33 | apiVersion: apiVersion, 34 | name: deviceName, 35 | uuid: uuid 36 | }); 37 | 38 | devices.push(device); 39 | } 40 | 41 | return devices; 42 | }; 43 | 44 | module.exports = function() { 45 | let list = [ 46 | '/usr/bin/xctrace', 47 | ['list', 'devices'] 48 | ]; 49 | 50 | return spawn(...list).then((output) => { 51 | let devices = deserializeDevices(output.stdout); 52 | return devices.reverse(); 53 | }); 54 | }; 55 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/list-emulators.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | const Device = require('../../../objects/device'); 3 | 4 | const deserializeEmulators = function(iosVersion, list) { 5 | let emulators = []; 6 | if (list === undefined) { return emulators; } 7 | 8 | let items = list.split('\n'); 9 | items.forEach((item) => { 10 | if (item.trim() === '') { return; } 11 | let split = item.replace(/\)/g, '').split('('); 12 | let emulator = new Device({ 13 | platform: 'ios', 14 | deviceType: 'emulator', 15 | apiVersion: iosVersion, 16 | name: split[0].trim(), 17 | uuid: split[split.length - 2].trim(), 18 | state: split[split.length - 1].trim() 19 | }) 20 | emulators.push(emulator); 21 | }); 22 | 23 | return emulators; 24 | }; 25 | 26 | module.exports = function() { 27 | let list = [ 28 | '/usr/bin/xcrun', 29 | ['simctl', 'list', 'devices'] 30 | ]; 31 | 32 | return spawn(...list).then((result) => { 33 | let listedEmulators = result.stdout.split(/(iOS \d+.\d+ --)([\s\S]*?)--/); 34 | let emulators = listedEmulators.reduce((arr, list, i) => { 35 | if (/iOS \d+.\d+ --/.test(list)) { 36 | let iosV = list.split(' ')[1]; 37 | let found = deserializeEmulators(iosV, listedEmulators[i + 1]); 38 | arr.push(...found); 39 | } 40 | return arr; 41 | }, []); 42 | 43 | return emulators.reverse(); 44 | }); 45 | }; 46 | -------------------------------------------------------------------------------- /lib/targets/ios/tasks/open-emulator.js: -------------------------------------------------------------------------------- 1 | const spawn = require('../../../utils/spawn'); 2 | 3 | module.exports = function() { 4 | let open = [ 5 | 'open', 6 | ['/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'] 7 | ]; 8 | 9 | return spawn(...open); 10 | }; 11 | -------------------------------------------------------------------------------- /lib/targets/ios/utils/parse-pbxproj.js: -------------------------------------------------------------------------------- 1 | const { Xcode } = require('pbxproj-dom/xcode'); 2 | const fsUtils = require('../../../utils/fs-utils'); 3 | 4 | module.exports = function(path, appName) { 5 | if (!fsUtils.existsSync(path)) { 6 | throw `pbxproj file does not exist at ${path}`; 7 | } 8 | 9 | let pbxproj; 10 | try { 11 | pbxproj = Xcode.open(path); 12 | } catch (err) { 13 | throw `failed to parse pbxproj file at ${path}`; 14 | } 15 | 16 | let target; 17 | let project = pbxproj.document.projects.find((p) => { 18 | target = p.targets.find(t => t.name === appName); 19 | return target; 20 | }); 21 | 22 | if (!target) { 23 | throw 'no build target found for app ${appName} in pbxproj file at ' 24 | + ` ${path}`; 25 | } 26 | 27 | let targetAttributes = project.ast.get('attributes') 28 | .get('TargetAttributes') 29 | .get(target.key); 30 | 31 | let provisioningStyle = targetAttributes.get('ProvisioningStyle').text; 32 | if (provisioningStyle) { 33 | provisioningStyle = provisioningStyle.toLowerCase(); 34 | } else { 35 | provisioningStyle = 'automatic'; 36 | } 37 | 38 | let developmentTeam, buildConfigurations; 39 | if (provisioningStyle === 'automatic') { 40 | developmentTeam = targetAttributes.get('DevelopmentTeam').text; 41 | } else { 42 | let pbxBuildConfigs = target.buildConfigurationsList.buildConfigurations; 43 | buildConfigurations = pbxBuildConfigs.reduce((hash, config) => { 44 | let key = config.name.toLowerCase(); 45 | let buildSettings = config.ast.get('buildSettings'); 46 | let provisioningProfile = buildSettings.get('PROVISIONING_PROFILE').text; 47 | 48 | hash[key] = { 49 | name: key, 50 | provisioningProfile 51 | }; 52 | 53 | return hash; 54 | }, {}); 55 | } 56 | 57 | return { 58 | provisioningStyle, 59 | developmentTeam, 60 | buildConfigurations 61 | }; 62 | }; 63 | -------------------------------------------------------------------------------- /lib/targets/ios/validators/signing-identity.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const Task = require('../../../tasks/-task'); 3 | const getAppName = require('../../cordova/utils/get-app-name'); 4 | const getPath = require('../../cordova/utils/get-path'); 5 | const logger = require('../../../utils/logger'); 6 | const parsePbxproj = require('../utils/parse-pbxproj'); 7 | 8 | module.exports = Task.extend({ 9 | buildConfigName: 'debug', 10 | failed: undefined, 11 | project: undefined, 12 | logLevel: 'error', 13 | 14 | run() { 15 | this.failed = false; 16 | return getAppName(this.project).then((appName) => { 17 | let pbxprojPath = this._buildPbxprojPath(this.project, appName); 18 | let config; 19 | try { 20 | config = parsePbxproj(pbxprojPath, appName); 21 | } catch (err) { 22 | return this._fail(err); 23 | } 24 | 25 | if (config.provisioningStyle === 'automatic' && !config.developmentTeam) { 26 | return this._fail('xcode project is configured for automatic signing,' 27 | + ' but no development team has been selected'); 28 | } 29 | 30 | if (config.provisioningStyle === 'manual') { 31 | let buildConfig = config.buildConfigurations[this.buildConfigName]; 32 | if (!buildConfig.provisioningProfile) { 33 | return this._fail('xcode project is configured for manual signing,' 34 | + ' but no provisioning profile has been selected'); 35 | } 36 | } 37 | }); 38 | }, 39 | 40 | _buildPbxprojPath(project, appName) { 41 | return path.join( 42 | getPath(project), 43 | 'platforms', 44 | 'ios', 45 | `${appName}.xcodeproj`, 46 | 'project.pbxproj' 47 | ); 48 | }, 49 | 50 | _fail(message) { 51 | this.failed = true; 52 | if (this.logLevel === 'warn') { 53 | message += '; project may build, but archive will fail.'; 54 | return logger.warn(message); 55 | } 56 | throw `${message}.`; 57 | } 58 | }); 59 | -------------------------------------------------------------------------------- /lib/tasks/-task.js: -------------------------------------------------------------------------------- 1 | const Task = require('ember-cli/lib/models/task'); 2 | 3 | module.exports = Task.extend({ 4 | init() { 5 | this._super.apply(this, arguments); 6 | 7 | process.env.CORBER = true; 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /lib/tasks/.install-package.js.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/lib/tasks/.install-package.js.swp -------------------------------------------------------------------------------- /lib/tasks/add-cordova-js.js: -------------------------------------------------------------------------------- 1 | const fsUtils = require('../utils/fs-utils'); 2 | const HTMLParser = require('htmlparser2').Parser; 3 | const DomHandler = require('htmlparser2').DomHandler; 4 | const DomUtils = require('htmlparser2').DomUtils; 5 | const Promise = require('rsvp').Promise; 6 | const logger = require('../utils/logger'); 7 | 8 | const getDom = function(fileContents) { 9 | let dom; 10 | let handler = new DomHandler(function(err, _dom) { 11 | if (err) { throw err } 12 | dom = _dom; 13 | }); 14 | let parser = new HTMLParser(handler); 15 | 16 | parser.end(fileContents); 17 | 18 | return dom; 19 | }; 20 | 21 | const scriptElementExists = function(dom) { 22 | return DomUtils.find(function(element) { 23 | return element.type === 'script' && element.attribs.src === 'cordova.js'; 24 | }, dom, true, 1).length > 0; 25 | }; 26 | 27 | const getBodyElement = function(dom) { 28 | return DomUtils.find(function(element) { 29 | return element.type === 'tag' && element.name === 'body'; 30 | }, dom, true, 1)[0]; 31 | }; 32 | 33 | const createScriptElement = function() { 34 | return getDom('')[0]; 35 | }; 36 | 37 | const prependChild = function(elem, child) { 38 | let firstChild = elem.children[0]; 39 | DomUtils.prepend(firstChild, child); 40 | }; 41 | 42 | const setupIndex = function(dom) { 43 | let bodyElement = getBodyElement(dom); 44 | let scriptElement = createScriptElement(); 45 | prependChild(bodyElement, scriptElement); 46 | }; 47 | 48 | module.exports = function(source) { 49 | logger.info(`Adding cordova.js to ${source}...\n`); 50 | 51 | return fsUtils.read(source).then((fileContents) => { 52 | let dom = getDom(fileContents); 53 | 54 | if (scriptElementExists(dom)) { return Promise.resolve(); } 55 | 56 | setupIndex(dom); 57 | 58 | return fsUtils.write(source, DomUtils.getOuterHTML(dom)); 59 | }); 60 | }; 61 | -------------------------------------------------------------------------------- /lib/tasks/bash-build.js: -------------------------------------------------------------------------------- 1 | const Task = require('./-task'); 2 | const Bash = require('./bash'); 3 | const fsUtils = require('../utils/fs-utils'); 4 | const createGitkeep = require('../utils/create-gitkeep'); 5 | const path = require('path'); 6 | 7 | module.exports = Task.extend({ 8 | buildCommand: undefined, 9 | buildPath: undefined, 10 | cordovaOutputPath: undefined, 11 | 12 | run() { 13 | let build = new Bash({ 14 | command: this.buildCommand, 15 | options: { 16 | //TODO - needs to alwyas be project root 17 | cwd: process.cwd() 18 | } 19 | }); 20 | 21 | let gitkeepPath = path.join(this.cordovaOutputPath, '.gitkeep'); 22 | 23 | return fsUtils.empty(this.cordovaOutputPath) 24 | .then(() => createGitkeep(gitkeepPath)) 25 | .then(() => build.run()) 26 | .then(() => fsUtils.copyDir(this.buildPath, this.cordovaOutputPath)) 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /lib/tasks/bash-serve.js: -------------------------------------------------------------------------------- 1 | const Task = require('./-task'); 2 | const Bash = require('./bash'); 3 | 4 | module.exports = Task.extend({ 5 | command: undefined, 6 | platform: undefined, 7 | 8 | run() { 9 | let serve = new Bash({ 10 | command: `${this.command} --CORBER_PLATFORM=${this.platform}` 11 | }); 12 | 13 | return serve.run(); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /lib/tasks/bash.js: -------------------------------------------------------------------------------- 1 | const Task = require('./-task'); 2 | const spawn = require('../utils/spawn'); 3 | const logger = require('../utils/logger'); 4 | const defaults = require('lodash').defaults; 5 | 6 | module.exports = Task.extend({ 7 | command: undefined, 8 | options: undefined, 9 | cwd: undefined, 10 | 11 | onStdout: (data) => logger.stdout(data), 12 | onStderr: (data) => logger.stderr(data), 13 | 14 | run() { 15 | let options = defaults(this.options, { 16 | // expands `this.command` as shell expression with args, pipes, etc. 17 | shell: true 18 | }); 19 | 20 | return spawn(this.command, [], options, { 21 | onStdout: this.onStdout, 22 | onStderr: this.onStderr, 23 | cwd: this.cwd 24 | }); 25 | } 26 | }); 27 | -------------------------------------------------------------------------------- /lib/tasks/create-livereload-shell.js: -------------------------------------------------------------------------------- 1 | const Task = require('./-task'); 2 | const Promise = require('rsvp').Promise; 3 | 4 | const cordovaPath = require('../targets/cordova/utils/get-path'); 5 | const fsUtils = require('../utils/fs-utils'); 6 | 7 | const path = require('path'); 8 | 9 | module.exports = Task.extend({ 10 | project: undefined, 11 | 12 | //Read in the shell index.html file 13 | getShellTemplate() { 14 | let shellPath = path.join( 15 | __dirname, 16 | '../templates/livereload-shell/index.html' 17 | ); 18 | 19 | return fsUtils.read(shellPath, { encoding: 'utf8' }); 20 | }, 21 | 22 | createShell(outputPath, template, reloadUrl) { 23 | let regExp = new RegExp('{{liveReloadUrl}}', 'gi'); 24 | template = template.replace(regExp, reloadUrl); 25 | return fsUtils.write(outputPath, template, 'utf8'); 26 | }, 27 | 28 | run(reloadUrl) { 29 | let project = this.project; 30 | 31 | return this.getShellTemplate() 32 | .then((html) => { 33 | let outputPath = path.join(cordovaPath(project), 'www/index.html'); 34 | 35 | return this.createShell(outputPath, html, reloadUrl); 36 | }) 37 | .catch(function(err) { 38 | return Promise.reject('Error moving index.html for livereload ' + err); 39 | }); 40 | } 41 | }); 42 | -------------------------------------------------------------------------------- /lib/tasks/eslintignore.js: -------------------------------------------------------------------------------- 1 | const Task = require('./-task'); 2 | const fsUtils = require('../utils/fs-utils'); 3 | const logger = require('../utils/logger'); 4 | const includes = require('lodash').includes; 5 | 6 | const ignores = [ 7 | 'corber/cordova', 8 | ]; 9 | 10 | const addLine = function(contents, path) { 11 | return '\n' + path; 12 | }; 13 | 14 | const addIfNew = function(contents, path) { 15 | if (includes(contents, path) === false) { 16 | return addLine(contents, path); 17 | } else { 18 | return ''; 19 | } 20 | }; 21 | 22 | module.exports = Task.extend({ 23 | project: undefined, 24 | 25 | run() { 26 | return fsUtils.read('.eslintignore', { encoding: 'utf8' }) 27 | .then((contents) => { 28 | logger.info('corber: updating .eslintignore'); 29 | 30 | this.eslintIgnore(contents); 31 | }) 32 | .catch(() => {}); 33 | }, 34 | 35 | eslintIgnore(contents) { 36 | contents += addIfNew(contents, '\n# corber'); 37 | 38 | ignores.forEach(function(ignore) { 39 | contents += addIfNew(contents, ignore); 40 | }); 41 | 42 | return fsUtils.write('.eslintignore', contents); 43 | } 44 | }); 45 | -------------------------------------------------------------------------------- /lib/tasks/install-package.js: -------------------------------------------------------------------------------- 1 | const Task = require('./-task'); 2 | const Bash = require('./bash'); 3 | const fsUtils = require('../utils/fs-utils'); 4 | const logger = require('../utils/logger'); 5 | const path = require('path'); 6 | 7 | module.exports = Task.extend({ 8 | rootPath: undefined, 9 | 10 | run(packageName, version) { 11 | let versionTag, command; 12 | if (version !== undefined) { 13 | versionTag = `@${version}`; 14 | } else { 15 | versionTag = ''; 16 | } 17 | 18 | logger.info(`Installing ${packageName}`); 19 | 20 | return fsUtils.read(path.join(this.rootPath, 'yarn.lock')).then(() => { 21 | command = `yarn add ${packageName}${versionTag} --dev`; 22 | logger.info('Detected yarn.lock - using yarn'); 23 | }, () => { 24 | command = `npm install ${packageName}${versionTag} --save`; 25 | logger.info('Did not detect a yarn.lock, using npm'); 26 | }).then(() => { 27 | return new Bash({ 28 | command: command 29 | }).run(); 30 | }); 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /lib/tasks/install-project-corber.js: -------------------------------------------------------------------------------- 1 | const Task = require('./-task'); 2 | const InstallPackage = require('./install-package'); 3 | const logger = require('../utils/logger'); 4 | 5 | module.exports = Task.extend({ 6 | rootPath: undefined, 7 | 8 | run() { 9 | logger.info('Adding corber to devDependencies'); 10 | 11 | let corberVersion = require('../../package.json').version; 12 | let install = new InstallPackage({ 13 | rootPath: this.rootPath 14 | }); 15 | 16 | return install.run('corber', corberVersion); 17 | } 18 | }); 19 | -------------------------------------------------------------------------------- /lib/tasks/run-hook.js: -------------------------------------------------------------------------------- 1 | const getCordovaPath = require('../targets/cordova/utils/get-path'); 2 | const logger = require('../utils/logger'); 3 | const fsUtils = require('../utils/fs-utils'); 4 | const Promise = require('rsvp').Promise; 5 | const path = require('path'); 6 | 7 | module.exports = function runHook(hookName, hookOptions, options = {}) { 8 | let projectPath, hookPath, hook, hookReturn; 9 | let { root } = options; 10 | 11 | projectPath = getCordovaPath({ root }, true); 12 | hookPath = path.join(projectPath, 'hooks', hookName); 13 | 14 | if (!fsUtils.existsSync(`${hookPath}.js`)) { 15 | // it's OK if a hook doesn't exist, most people won't use them 16 | return Promise.resolve(); 17 | } 18 | 19 | logger.info(`Located hook '${hookName}'`); 20 | hook = require(hookPath); 21 | 22 | try { 23 | hookReturn = hook(hookOptions); 24 | } catch (e) { 25 | let message = e.message ? e.message : e; 26 | logger.error(`Hook '${hookName}' exited with exception: ${message}`); 27 | return Promise.reject(e); 28 | } 29 | 30 | return Promise.resolve(hookReturn).then((value) => { 31 | logger.success(`Executed hook '${hookName}'`); 32 | return value; 33 | }).catch((e) => { 34 | let message = e.message ? e.message : e; 35 | logger.error(`Hook '${hookName}' exited with rejection: ${message}`); 36 | throw e; 37 | }); 38 | }; 39 | -------------------------------------------------------------------------------- /lib/tasks/update-gitignore.js: -------------------------------------------------------------------------------- 1 | const Task = require('./-task'); 2 | const fsUtils = require('../utils/fs-utils'); 3 | const logger = require('../utils/logger'); 4 | const includes = require('lodash').includes; 5 | 6 | const ignores = [ 7 | 'corber/tmp-livereload', 8 | 'corber/cordova/node_modules', 9 | ]; 10 | 11 | const emptyCheckins = [ 12 | 'corber/cordova/platforms/', 13 | 'corber/cordova/plugins/', 14 | 'corber/cordova/www/' 15 | ]; 16 | 17 | const addLine = function(contents, path) { 18 | return '\n' + path; 19 | }; 20 | 21 | const addIfNew = function(contents, path) { 22 | if (includes(contents, path) === false) { 23 | return addLine(contents, path); 24 | } else { 25 | return ''; 26 | } 27 | }; 28 | 29 | module.exports = Task.extend({ 30 | project: undefined, 31 | 32 | run() { 33 | logger.info('corber: updating .gitignore'); 34 | 35 | return fsUtils.read('.gitignore', { encoding: 'utf8' }) 36 | .then((contents) => this.updateGitIgnore(contents)) 37 | .catch(() => { 38 | this.updateGitIgnore(''); 39 | }); 40 | }, 41 | 42 | updateGitIgnore(contents) { 43 | ignores.forEach(function(ignore) { 44 | contents += addIfNew(contents, ignore); 45 | }); 46 | 47 | emptyCheckins.forEach(function(item) { 48 | //First add each item 49 | contents += addIfNew(contents, item + '*'); 50 | 51 | //Add an empty gitKeep as these folders should be checked in 52 | let gitkeepPath = item + '.gitkeep'; 53 | contents += addIfNew(contents, '!' + gitkeepPath); 54 | 55 | //Create the empty gitkeep 56 | fsUtils.write(gitkeepPath, '', { encoding: 'utf8' }); 57 | }); 58 | 59 | return fsUtils.write('.gitignore', contents); 60 | } 61 | }); 62 | -------------------------------------------------------------------------------- /lib/templates/frameworks/custom.js: -------------------------------------------------------------------------------- 1 | const Framework = require('corber/lib/frameworks/framework'); 2 | const Promise = require('rsvp').Promise; 3 | const logger = require('corber/lib/utils/logger'); 4 | 5 | /* 6 | corber has pre-defined frameworks at ../frameworks/foo 7 | 8 | In some cases your framework may not be supported, 9 | or custtomization is easier with a custom object. 10 | 11 | Implementing these base functions will enable use of the CLI. 12 | Each function should return a Promise.resolve on completion. 13 | Rejections will be handled, logged as an error and halt the given command 14 | */ 15 | 16 | module.exports = Framework.extend({ 17 | afterInstall() { 18 | /* 19 | any custom setup after a user has run ec init 20 | the cordova project already exists 21 | usually just Promise.resolve() 22 | */ 23 | logger.warn('afterInstall not implemented'); 24 | return Promise.reject(); 25 | }, 26 | 27 | validateBuild() { 28 | /* 29 | any validators to run before building 30 | use this to reject cases where we know cordova will nto work 31 | e.g. ember will ensure baseURL is not '/' 32 | */ 33 | logger.warn('afterInstall not implemented'); 34 | return Promise.reject(); 35 | }, 36 | 37 | build() { 38 | //implement the _framework_ build 39 | logger.warn('afterInstall not implemented'); 40 | return Promise.reject(); 41 | }, 42 | 43 | validateServe() { 44 | /* 45 | any validators to run before servinb 46 | use this to reject cases where we know cordova will nto work 47 | e.g. ember will ensure baseURL is not '/' 48 | */ 49 | logger.warn('afterInstall not implemented'); 50 | return Promise.reject(); 51 | }, 52 | 53 | serve() { 54 | //implement serve 55 | logger.warn('afterInstall not implemented'); 56 | return Promise.reject(); 57 | } 58 | }); 59 | -------------------------------------------------------------------------------- /lib/templates/frameworks/ember.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | const EmberFramework = require('corber/lib/frameworks/ember/framework'); 4 | 5 | module.exports = EmberFramework.extend({ 6 | }); 7 | -------------------------------------------------------------------------------- /lib/templates/frameworks/glimmer.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | const EmberFramework = require('corber/lib/frameworks/ember/framework'); 4 | 5 | module.exports = EmberFramework.extend({ 6 | isGlimmer: true 7 | }); 8 | -------------------------------------------------------------------------------- /lib/templates/frameworks/react.js: -------------------------------------------------------------------------------- 1 | const ReactFramework = require('corber/lib/frameworks/react/framework'); 2 | 3 | module.exports = ReactFramework.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /lib/templates/frameworks/vue.js: -------------------------------------------------------------------------------- 1 | const VueFramework = require('corber/lib/frameworks/vue/framework'); 2 | 3 | module.exports = VueFramework.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /lib/templates/livereload-shell/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 |

Welcome to corber

10 | 11 |

Starting Live Reload

12 | 13 |

14 | Redirecting to your app now; if you still see this page after a few 15 | seconds, try clicking the 'Redirect' button. 16 |

17 | 18 | 21 | 22 |

23 | If that doesn't work, make sure this device is connected to the same 24 | network that your corber build server is running on, and that your build 25 | server's address ({{liveReloadUrl}}) can be accessed by other devices on 26 | the network. 27 |

28 | 29 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /lib/utils/command-exists.js: -------------------------------------------------------------------------------- 1 | const childProcess = require('child_process'); 2 | 3 | module.exports = function(commandName) { 4 | let cmdStr; 5 | 6 | let isUsingWindows = process.platform === 'win32'; 7 | 8 | if (isUsingWindows) { 9 | cmdStr = 'where ' + commandName; 10 | } else { 11 | cmdStr = 'command -v ' + commandName + 12 | ' >/dev/null && { echo >&1 \'command found\'; }'; 13 | } 14 | 15 | try { 16 | childProcess.execSync(cmdStr); 17 | return true; 18 | } 19 | catch (err) { 20 | return false; 21 | } 22 | }; 23 | -------------------------------------------------------------------------------- /lib/utils/corber-error.js: -------------------------------------------------------------------------------- 1 | const CorberError = function(content) { 2 | let message = content.message ? content.message : content; 3 | let stack = content.stack ? content.stack : (new Error()).stack; 4 | 5 | this.name = 'CorberError'; 6 | this.message = message; 7 | this.stack = stack.substr(stack.indexOf('\n') + 1); 8 | }; 9 | 10 | CorberError.prototype = Object.create(Error.prototype); 11 | CorberError.prototype.toString = function() { 12 | return `${this.message}`; 13 | }; 14 | CorberError.constructor = CorberError; 15 | 16 | module.exports = CorberError; 17 | -------------------------------------------------------------------------------- /lib/utils/create-gitkeep.js: -------------------------------------------------------------------------------- 1 | const fsUtils = require('./fs-utils'); 2 | 3 | module.exports = function(gitkeepPath) { 4 | return fsUtils.write(gitkeepPath, '', { encoding: 'utf8' }); 5 | } 6 | -------------------------------------------------------------------------------- /lib/utils/framework-type.js: -------------------------------------------------------------------------------- 1 | const some = require('lodash').some; 2 | const get = require('lodash').get; 3 | const path = require('path'); 4 | const getPackage = require('./get-package'); 5 | 6 | const frameworkPackages = { 7 | glimmer: ['@glimmer/application'], 8 | ember: ['ember-resolver', 'ember-source'], 9 | vue: ['vue'], 10 | react: ['react'] 11 | }; 12 | 13 | module.exports = { 14 | detectAll(root) { 15 | let packagePath = path.join(root, 'package.json'); 16 | let packageJSON = getPackage(packagePath); 17 | let devDeps = packageJSON.devDependencies; 18 | let deps = packageJSON.dependencies; 19 | 20 | let frameworks = Object.keys(frameworkPackages).filter((framework) => { 21 | return some(frameworkPackages[framework], (pkg) => { 22 | return get(deps, pkg) || get(devDeps, pkg); 23 | }); 24 | }); 25 | 26 | if (frameworks.length === 0) { 27 | return ['custom']; 28 | } 29 | 30 | return frameworks; 31 | }, 32 | 33 | get(root) { 34 | return this.detectAll(root)[0]; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /lib/utils/fs-utils.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const fsExtra = require('fs-extra'); 3 | const RSVP = require('rsvp') 4 | 5 | const denodeify = RSVP.denodeify 6 | const fsReadFile = denodeify(fs.readFile) 7 | const fsWriteFile = denodeify(fs.writeFile); 8 | const fsMkdir = denodeify(fs.mkdir); 9 | const fsAppend = denodeify(fs.appendFile); 10 | 11 | module.exports = { 12 | read() { 13 | return fsReadFile.apply(this, arguments); 14 | }, 15 | 16 | readSync() { 17 | return fs.readFileSync.apply(this, arguments); 18 | }, 19 | 20 | write() { 21 | return fsWriteFile.apply(this, arguments); 22 | }, 23 | 24 | existsSync() { 25 | return fs.existsSync.apply(this, arguments); 26 | }, 27 | 28 | mkdir() { 29 | return fsMkdir.apply(this, arguments); 30 | }, 31 | 32 | append() { 33 | return fsAppend.apply(this, arguments); 34 | }, 35 | 36 | copy(source, destination) { 37 | return this.read(source, {encoding: 'utf8'}).then((contents) => { 38 | return this.write(destination, contents, {encoding: 'utf8'}); 39 | }); 40 | }, 41 | 42 | copyDir(source, destination) { 43 | let defer = RSVP.defer(); 44 | 45 | fsExtra.copy(source, destination, defer.resolve); 46 | 47 | return defer.promise; 48 | }, 49 | 50 | empty(path) { 51 | let defer = RSVP.defer(); 52 | 53 | fsExtra.emptyDir(path, defer.resolve); 54 | 55 | return defer.promise; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/utils/get-last-command.js: -------------------------------------------------------------------------------- 1 | module.exports = function getLastCommand() { 2 | let args = Array.prototype.slice.call(process.argv); 3 | 4 | args.shift(); 5 | args.shift(); 6 | 7 | return 'ember ' + args.join(' '); 8 | }; 9 | -------------------------------------------------------------------------------- /lib/utils/get-network-ip.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | 3 | module.exports = function getNetworkIp() { 4 | let interfaces = os.networkInterfaces(); 5 | let addresses = []; 6 | 7 | for (let k in interfaces) { 8 | for (let k2 in interfaces[k]) { 9 | let address = interfaces[k][k2]; 10 | if (address.family === 'IPv4' && !address.internal) { 11 | addresses.push(address.address); 12 | } 13 | } 14 | } 15 | 16 | // Default to 'localhost' when a suitable IP address isn't found. 17 | // This will allow live-reload emulators builds to function when 18 | // working without a network connection. 19 | return addresses[0] || 'localhost'; 20 | }; 21 | -------------------------------------------------------------------------------- /lib/utils/get-os.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | 3 | module.exports = function() { 4 | return os.platform(); 5 | }; 6 | -------------------------------------------------------------------------------- /lib/utils/get-package.js: -------------------------------------------------------------------------------- 1 | module.exports = function(packagePath) { 2 | return require(packagePath); 3 | }; 4 | -------------------------------------------------------------------------------- /lib/utils/get-versions.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const getPackage = require('./get-package'); 3 | const existsSync = require('./fs-utils').existsSync; 4 | 5 | module.exports = function getVersions(root) { 6 | let versions = {}; 7 | let globalPackagePath = path.resolve(__dirname, '..', '..', 'package.json'); 8 | 9 | if (existsSync(globalPackagePath)) { 10 | versions.global = getPackage(globalPackagePath).version; 11 | } 12 | 13 | versions.project = {}; 14 | 15 | if (root) { 16 | let projectPackagePath = path.join(root, 'package.json'); 17 | 18 | if (existsSync(projectPackagePath)) { 19 | let { dependencies, devDependencies } = getPackage(projectPackagePath); 20 | 21 | if (devDependencies && devDependencies.corber) { 22 | versions.project.required = devDependencies.corber 23 | } else if (dependencies && dependencies.corber) { 24 | versions.project.required = dependencies.corber; 25 | } 26 | 27 | let corberPackagePath = path.join( 28 | root, 29 | 'node_modules', 30 | 'corber', 31 | 'package.json' 32 | ); 33 | 34 | if (existsSync(corberPackagePath)) { 35 | versions.project.installed = getPackage(corberPackagePath).version; 36 | } 37 | } 38 | } 39 | 40 | return { 41 | corber: versions, 42 | node: process.versions.node 43 | }; 44 | }; 45 | -------------------------------------------------------------------------------- /lib/utils/logger.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk'); 2 | const ECError = require('./corber-error'); 3 | 4 | // supported log level must be sorted by verbosity 5 | const SUPPORTED_LOG_LEVELS = ['verbose', 'info', 'success', 'warn', 'error']; 6 | 7 | module.exports = { 8 | logLevel: 'info', 9 | 10 | verbose(message) { 11 | if (!this.shouldLog('verbose')) { 12 | return; 13 | } 14 | console.debug(message); 15 | }, 16 | 17 | info(message) { 18 | if (!this.shouldLog('info')) { 19 | return; 20 | } 21 | console.log(message); 22 | }, 23 | 24 | success(message) { 25 | if (!this.shouldLog('success')) { 26 | return; 27 | } 28 | console.log(chalk.green(message)); 29 | }, 30 | 31 | warn(content) { 32 | if (!this.shouldLog('warn')) { 33 | return; 34 | } 35 | let message = 'WARNING: corber \n'; 36 | message += content; 37 | console.warn(chalk.yellow(message)); 38 | }, 39 | 40 | error(content) { 41 | let error = new ECError(content); 42 | console.error(chalk.red(error)); 43 | return error; 44 | }, 45 | 46 | stdoutVerbose(data) { 47 | if (!this.shouldLog('verbose')) { 48 | return; 49 | } 50 | process.stdout.write(data); 51 | }, 52 | 53 | stdout(data) { 54 | if (!this.shouldLog('info')) { 55 | return; 56 | } 57 | process.stdout.write(data); 58 | }, 59 | 60 | stderr(data) { 61 | process.stderr.write(data); 62 | }, 63 | 64 | getLogLevel() { 65 | return this.logLevel; 66 | }, 67 | 68 | setLogLevel(logLevel) { 69 | if (SUPPORTED_LOG_LEVELS.indexOf(logLevel) === -1) { 70 | this.error( 71 | 'Log level must be one of `info`, `success`, `warn`, `error`. ' . 72 | logLevel + ' given.'); 73 | } 74 | this.logLevel = logLevel; 75 | }, 76 | 77 | shouldLog(logLevel) { 78 | let currentLogLevel = this.getLogLevel(); 79 | let logLevels = SUPPORTED_LOG_LEVELS; 80 | return logLevels.indexOf(currentLogLevel) <= logLevels.indexOf(logLevel); 81 | } 82 | }; 83 | -------------------------------------------------------------------------------- /lib/utils/open-app-command.js: -------------------------------------------------------------------------------- 1 | //TODO - move to cordova 2 | /* 3 | This file needs to be removed when issue https://github.com/pwnall/node-open/issues/30 4 | is resolved, original file can be seen here: 5 | https://github.com/pwnall/node-open/blob/0c3ad272bfbc163cce8806e64630c623a9cfd8f4/lib/open.js 6 | */ 7 | 8 | const escapeDoubleQuotes = (str) => str.replace(/"/g, '\\\"'); 9 | 10 | module.exports = function(target, appName) { 11 | let opener; 12 | 13 | switch (process.platform) { 14 | case 'darwin': 15 | if (appName) { 16 | opener = 'open -a "' + escapeDoubleQuotes(appName) + '"'; 17 | } else { 18 | opener = 'open'; 19 | } 20 | break; 21 | case 'win32': 22 | // if the first parameter to start is quoted, it uses that as the title 23 | // so we pass a blank title so we can quote the file we are opening 24 | if (appName) { 25 | opener = 'start "" "' + escapeDoubleQuotes(appName) + '"'; 26 | } else { 27 | opener = 'start'; 28 | } 29 | break; 30 | default: 31 | if (appName) { 32 | opener = escapeDoubleQuotes(appName); 33 | } else { 34 | // use Portlands xdg-open everywhere else 35 | opener = 'xdg-open'; 36 | } 37 | break; 38 | } 39 | 40 | if (process.env.SUDO_USER) { 41 | opener = 'sudo -u ' + process.env.SUDO_USER + ' ' + opener; 42 | } 43 | 44 | return `${opener} "${escapeDoubleQuotes(target)}"` 45 | }; 46 | -------------------------------------------------------------------------------- /lib/utils/parse-xml.js: -------------------------------------------------------------------------------- 1 | const xml2js = require('xml2js'); 2 | const Promise = require('rsvp').Promise; 3 | 4 | const fsUtils = require('./fs-utils'); 5 | const logger = require('./logger'); 6 | 7 | module.exports = function parseXML(xmlPath) { 8 | return new Promise(function(resolve, reject) { 9 | let contents = fsUtils.readSync(xmlPath, { encoding: 'utf8' }); 10 | let parser = new xml2js.Parser(); 11 | 12 | parser.parseString(contents, function (err, result) { 13 | if (err) { 14 | logger.error(err); 15 | return reject(err); 16 | } 17 | 18 | if (result) { 19 | resolve(result); 20 | } 21 | }); 22 | }); 23 | }; 24 | -------------------------------------------------------------------------------- /lib/utils/require-framework.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const logger = require('../utils/logger'); 3 | 4 | module.exports = function(project) { 5 | let Framework; 6 | try { 7 | Framework = require(path.join( 8 | project.root, 'corber/config/framework.js' 9 | )); 10 | } catch (err) { 11 | logger.error(` 12 | No corber/config/framework.js found. 13 | Have you run corber init? 14 | `); 15 | throw err; 16 | } 17 | 18 | let framework = new Framework({ 19 | root: project.root 20 | }); 21 | 22 | if (framework.name === 'ember' || framework.name === 'glimmer') { 23 | framework.project = project; 24 | } 25 | 26 | return framework; 27 | }; 28 | -------------------------------------------------------------------------------- /lib/utils/require-target.js: -------------------------------------------------------------------------------- 1 | const CordovaTarget = require('../targets/cordova/target'); 2 | const cdvBuildFlags = require('../targets/cordova/utils/parse-build-flags'); 3 | 4 | module.exports = function(project, opts) { 5 | let cordovaOpts = cdvBuildFlags(opts.platform, opts); 6 | 7 | return new CordovaTarget({ 8 | platform: opts.platform, 9 | project: project, 10 | cordovaOpts: cordovaOpts 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /lib/utils/run-validators.js: -------------------------------------------------------------------------------- 1 | const RSVP = require('rsvp'); 2 | const chain = require('lodash').chain; 3 | 4 | module.exports = function(validators) { 5 | return RSVP.allSettled(validators).then(function(result) { 6 | let errors = chain(result) 7 | .filter({state: 'rejected'}) 8 | .map('reason') 9 | .value() 10 | 11 | if (errors.length > 0) { 12 | let message = 'Validation error(s) \n \n'; 13 | message += errors.join('\n \n'); 14 | return RSVP.reject(message); 15 | } else { 16 | return RSVP.resolve(); 17 | } 18 | }); 19 | }; 20 | -------------------------------------------------------------------------------- /lib/utils/spawn.js: -------------------------------------------------------------------------------- 1 | const RSVP = require('rsvp'); 2 | const childProcess = require('child_process'); 3 | 4 | const EXIT_CODE_NOT_FOUND = 127; 5 | 6 | module.exports = function(command, args = [], processOpts = {}, opts = {}) { 7 | let { onStderr, onStdout, cwd, fork } = opts; 8 | let processPath; 9 | 10 | if (cwd) { 11 | processPath = process.cwd(); 12 | process.chdir(cwd); 13 | } 14 | 15 | let deferred = RSVP.defer(); 16 | 17 | let spawned; 18 | if (fork) { 19 | // pipe fork output to stdout/stderr streams 20 | processOpts.silent = true; 21 | 22 | spawned = childProcess.fork(command, args, processOpts); 23 | } else { 24 | spawned = childProcess.spawn(command, args, processOpts); 25 | } 26 | 27 | let stdoutLines = []; 28 | let stderrLines = []; 29 | 30 | spawned.stdout.on('data', (data) => { 31 | stdoutLines.push(data); 32 | 33 | if (onStdout) { 34 | onStdout(data.toString()); 35 | } 36 | }); 37 | 38 | spawned.stderr.on('data', (data) => { 39 | stderrLines.push(data); 40 | 41 | if (onStderr) { 42 | onStderr(data.toString()); 43 | } 44 | }); 45 | 46 | spawned.on('exit', (code) => { 47 | if (code === EXIT_CODE_NOT_FOUND) { 48 | deferred.reject(`command '${command}' not found`); 49 | return; 50 | } 51 | 52 | deferred.resolve({ 53 | stdout: stdoutLines.join('\n'), 54 | stderr: stderrLines.join('\n'), 55 | code 56 | }); 57 | }); 58 | 59 | if (processPath) { 60 | deferred.promise.finally(() => { 61 | process.chdir(processPath); 62 | }); 63 | } 64 | 65 | return deferred.promise; 66 | }; 67 | -------------------------------------------------------------------------------- /lib/utils/string.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | camelize(str) { 3 | return str.replace(/-([(a-zA-Z1-9])/g, function (m, w) { 4 | return w.toUpperCase(); 5 | }); 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /lib/validators/livereload-package.js: -------------------------------------------------------------------------------- 1 | const Task = require('../tasks/-task'); 2 | const getPackage = require('../utils/get-package'); 3 | const logger = require('../utils/logger'); 4 | const path = require('path'); 5 | const RSVP = require('rsvp'); 6 | 7 | module.exports = Task.extend({ 8 | root: undefined, 9 | packageName: undefined, 10 | 11 | run() { 12 | let packageName = this.packageName; 13 | if (!packageName) { 14 | return RSVP.reject('no package name provided'); 15 | } 16 | 17 | let packagePath = path.join(this.root, 'package.json'); 18 | let packageJSON = getPackage(packagePath); 19 | if (!packageJSON) { 20 | return RSVP.reject('could not read package.json'); 21 | } 22 | 23 | let { 24 | dependencies = {}, 25 | devDependencies = {} 26 | } = packageJSON; 27 | 28 | if (!dependencies[packageName] && 29 | !devDependencies[packageName]) { 30 | let message = this.buildWarningMessage(packageName, packagePath); 31 | logger.warn(message); 32 | } 33 | 34 | return RSVP.resolve(); 35 | }, 36 | 37 | buildWarningMessage(packageName, packagePath) { 38 | return `Could not find ${packageName} in ${packagePath}. ` + 39 | 'This means that cordova.js & plugins will not be available in ' + 40 | 'livereload.\n\n' + 41 | 'To fix, run:\n' + 42 | '\tember install corber-ember-livereload\n\n' + 43 | 'Read more: http://corber.io/pages/frameworks/ember'; 44 | } 45 | }); 46 | 47 | -------------------------------------------------------------------------------- /lib/validators/webpack-plugin.js: -------------------------------------------------------------------------------- 1 | const Task = require('../tasks/-task'); 2 | const logger = require('../utils/logger'); 3 | const Promise = require('rsvp').Promise; 4 | const find = require('lodash').find; 5 | 6 | module.exports = Task.extend({ 7 | root: undefined, 8 | framework: undefined, 9 | config: undefined, 10 | configPath: undefined, 11 | 12 | warnMsg() { 13 | let message = 14 | `Could not find corber-webpack-plugin in ${this.configPath}. This means` + 15 | ' the cordova.js & plugins will not be available in livereload.\n\n' + 16 | 'Ensure corber-webpack-plugin has been installed with:\n' + 17 | '\tyarn add corber-webpack-plugin --dev\n' + 18 | 'or\n' + 19 | '\tnpm install corber-webpack-plugin --save-dev\n' + 20 | `and the ${this.configPath} configureWebpack.plugins array contains ` + 21 | 'new CorberWebpackPlugin().\n\n' + 22 | `Read More: http://corber.io/pages/frameworks/${this.framework}`; 23 | 24 | logger.warn(message); 25 | }, 26 | 27 | includesWebpack(plugins) { 28 | let webpackPlugin = find(plugins, function(plugin) { 29 | if (plugin.constructor.name === 'CorberWebpackPlugin') { 30 | return true; 31 | } 32 | }); 33 | 34 | return webpackPlugin !== undefined; 35 | }, 36 | 37 | run() { 38 | process.env.NODE_ENV = 'development'; 39 | 40 | if (this.config === null) { 41 | this.warnMsg(); 42 | return Promise.reject(); 43 | } 44 | 45 | switch (this.configPath) { 46 | case 'vue.config.js': 47 | if (this.config.configureWebpack === undefined || 48 | !(this.config.configureWebpack.plugins instanceof Array) || 49 | !this.includesWebpack(this.config.configureWebpack.plugins)) { 50 | 51 | this.warnMsg(); 52 | } 53 | 54 | break; 55 | default: 56 | if (!(this.config.plugins instanceof Array) || 57 | !this.includesWebpack(this.config.plugins)) { 58 | 59 | this.warnMsg(); 60 | } 61 | } 62 | 63 | return Promise.resolve(); 64 | } 65 | }); 66 | -------------------------------------------------------------------------------- /node-tests/.eslintrc.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | // ht ember-cli 3 | 4 | module.exports = { 5 | globals: { 6 | 'describe': true, 7 | 'it': true, 8 | 'beforeEach': true, 9 | 'afterEach': true, 10 | 'context': true 11 | }, 12 | rules: { 13 | 'max-len': [2, { 'ignoreUrls': true, 'code': 240 }], 14 | 'no-unused-expressions': 'off' 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /node-tests/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "browser": false, 3 | "node": true, 4 | "esnext": true, 5 | "globals": { 6 | /* MOCHA */ 7 | "describe" : false, 8 | "it" : false, 9 | "before" : false, 10 | "beforeEach" : false, 11 | "context" : false, 12 | "after" : false, 13 | "afterEach" : false 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/analytics.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | track: function() {}, 3 | trackTiming: function() {}, 4 | trackError: function() {} 5 | } 6 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/build/webpack-with-plugin.dev.conf.js: -------------------------------------------------------------------------------- 1 | function CorberWebpackPlugin() {}; 2 | 3 | module.exports = { 4 | plugins: [new CorberWebpackPlugin()] 5 | }; 6 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [] 3 | }; 4 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/config/framework.js: -------------------------------------------------------------------------------- 1 | //Mock Ember Config 2 | const CoreObject = require('core-object'); 3 | 4 | module.exports = CoreObject.extend({ 5 | name: 'ember' 6 | }); 7 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/cordova/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | emberCordovaDummyApp 4 | 5 | A sample Apache Cordova application that responds to the deviceready event. 6 | 7 | 8 | Apache Cordova Team 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/cordova/fooPath: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/node-tests/fixtures/corber-mock/corber/cordova/fooPath -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/cordova/plugins/fetch.json: -------------------------------------------------------------------------------- 1 | { 2 | "cordova-test-plugin": {} 3 | } 4 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/cordova/plugins/ios.json: -------------------------------------------------------------------------------- 1 | { 2 | "installed_plugins": { 3 | "cordova-test-plugin": {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/hooks/hook-promise-rejected.js: -------------------------------------------------------------------------------- 1 | var Promise = require('rsvp'); 2 | 3 | module.exports = function() { 4 | return Promise.reject('hook rejected'); 5 | }; 6 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/hooks/hook-promise-resolved.js: -------------------------------------------------------------------------------- 1 | var Promise = require('rsvp'); 2 | 3 | module.exports = function() { 4 | return Promise.resolve('resolved promise from hook'); 5 | }; 6 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/hooks/hook-with-error.js: -------------------------------------------------------------------------------- 1 | module.exports = function() { 2 | throw new Error("hook failed") 3 | }; 4 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/hooks/hook-with-options.js: -------------------------------------------------------------------------------- 1 | var Promise = require('rsvp'); 2 | 3 | module.exports = function(options) { 4 | return Promise.resolve(options); 5 | }; 6 | 7 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/corber/hooks/hook.js: -------------------------------------------------------------------------------- 1 | module.exports = function() {}; 2 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/dist/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/node-tests/fixtures/corber-mock/dist/.gitkeep -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mock-project", 3 | "devDependencies": {} 4 | } 5 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/project.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const Promise = require('rsvp').Promise; 3 | 4 | module.exports = { 5 | env: 'development', 6 | id: 'corber-mock', 7 | name: 'corber-mock', 8 | 9 | project: { 10 | root: path.resolve(__dirname, '..', '..', 'fixtures', 'corber-mock'), 11 | name() { return 'corber-mock' }, 12 | isEmberCLIProject() { return true; }, 13 | config() { 14 | return {} 15 | } 16 | }, 17 | 18 | config() {}, 19 | 20 | ui: { 21 | prompt() { return Promise.resolve(); } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /node-tests/fixtures/corber-mock/vue.config.js: -------------------------------------------------------------------------------- 1 | //Mock Vue Config 2 | module.exports = { 3 | configureWebpack: { 4 | plugins: [] 5 | } 6 | }; -------------------------------------------------------------------------------- /node-tests/helpers/expect.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var chai = require('chai'); 4 | var chaiAsPromised = require('chai-as-promised'); 5 | 6 | chai.use(chaiAsPromised); 7 | 8 | module.exports = chai.expect; 9 | -------------------------------------------------------------------------------- /node-tests/unit/commands/lint-index-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const Promise = require('rsvp').Promise; 3 | const mockProject = require('../../fixtures/corber-mock/project'); 4 | const mockAnalytics = require('../../fixtures/corber-mock/analytics'); 5 | const cloneDeep = require('lodash').cloneDeep; 6 | const path = require('path'); 7 | 8 | describe('Lint Index Command', () => { 9 | let lintTask; 10 | 11 | let project; 12 | let lint; 13 | let opts; 14 | 15 | beforeEach(() => { 16 | let getCordovaPath = td.replace('../../../lib/targets/cordova/utils/get-path'); 17 | lintTask = td.replace('../../../lib/tasks/lint-index'); 18 | 19 | project = cloneDeep(mockProject.project); 20 | 21 | td.when(getCordovaPath(project)).thenReturn('cordova'); 22 | td.when(lintTask(), { ignoreExtraArgs: true }).thenReturn(Promise.resolve()); 23 | 24 | let LintCommand = require('../../../lib/commands/lint-index'); 25 | 26 | lint = new LintCommand({ 27 | project 28 | }); 29 | 30 | lint.analytics = mockAnalytics; 31 | 32 | opts = {}; 33 | }); 34 | 35 | afterEach(() => { 36 | td.reset(); 37 | }); 38 | 39 | context('when options contains source', () => { 40 | it('calls Lint Index Task', () => { 41 | opts.source = 'www/index.html'; 42 | 43 | return lint.run(opts).then(() => { 44 | td.config({ ignoreWarnings: true }); 45 | td.verify(lintTask(path.join('cordova', opts.source))); 46 | td.config({ ignoreWarnings: false }); 47 | }); 48 | }); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /node-tests/unit/commands/open-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const mockProject = require('../../fixtures/corber-mock/project'); 6 | const mockAnalytics = require('../../fixtures/corber-mock/analytics'); 7 | 8 | describe('Open Command', () => { 9 | let OpenAppTask; 10 | let logger; 11 | 12 | let open; 13 | let options; 14 | 15 | beforeEach(() => { 16 | OpenAppTask = td.replace('../../../lib/targets/cordova/tasks/open-app'); 17 | logger = td.replace('../../../lib/utils/logger'); 18 | 19 | td.when(OpenAppTask.prototype.run(), { ignoreExtraArgs: true }) 20 | .thenReturn(Promise.resolve()); 21 | 22 | let OpenCmd = require('../../../lib/commands/open'); 23 | 24 | open = new OpenCmd({ 25 | project: mockProject.project 26 | }); 27 | 28 | open.analytics = mockAnalytics; 29 | 30 | options = { 31 | application: 'dummy', 32 | platform: 'ios' 33 | }; 34 | }); 35 | 36 | afterEach(() => { 37 | td.reset(); 38 | }); 39 | 40 | it('should resolve on completion', () => { 41 | return expect(open.run(options)).to.eventually.be.fulfilled; 42 | }); 43 | 44 | it('logs an opening message', () => { 45 | return open.run(options).then(() => { 46 | td.verify(logger.info('Opening app for ios')); 47 | }); 48 | }); 49 | 50 | it('runs Open App Task', () => { 51 | return open.run(options).then(() => { 52 | td.config({ ignoreWarnings: true }); 53 | td.verify(OpenAppTask.prototype.run()); 54 | td.config({ ignoreWarnings: false }); 55 | }); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /node-tests/unit/commands/prepare-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const mockProject = require('../../fixtures/corber-mock/project'); 6 | const mockAnalytics = require('../../fixtures/corber-mock/analytics'); 7 | 8 | describe('Prepare Command', () => { 9 | let PrepareTask; 10 | let opts; 11 | 12 | let setupTaskTracking = (tasks) => { 13 | let stubTask = (id, returnValue) => { 14 | return (...args) => { 15 | let label = typeof (id) === 'function' ? id(...args) : id; 16 | tasks.push(label); 17 | return Promise.resolve(returnValue); 18 | } 19 | }; 20 | 21 | td.replace('../../../lib/tasks/run-hook', stubTask((name) => `hook ${name}`)); 22 | td.replace(PrepareTask.prototype, 'run', stubTask('prepare')); 23 | }; 24 | 25 | let setupCommand = () => { 26 | let PrepareCommand = require('../../../lib/commands/prepare'); 27 | 28 | let prepare = new PrepareCommand({ 29 | project: mockProject.project 30 | }); 31 | 32 | prepare.analytics = mockAnalytics; 33 | 34 | return prepare; 35 | }; 36 | 37 | beforeEach(() => { 38 | td.replace('../../../lib/tasks/run-hook'); 39 | 40 | PrepareTask = td.replace('../../../lib/targets/cordova/tasks/prepare'); 41 | 42 | opts = {}; 43 | }); 44 | 45 | afterEach(() => { 46 | td.reset(); 47 | }); 48 | 49 | it('runs tasks in the correct order', () => { 50 | let tasks = []; 51 | 52 | setupTaskTracking(tasks); 53 | 54 | let prepare = setupCommand(); 55 | 56 | return prepare.run(opts).then(() => { 57 | ////h-t ember-electron for the pattern 58 | expect(tasks).to.deep.equal([ 59 | 'hook beforePrepare', 60 | 'prepare', 61 | 'hook afterPrepare' 62 | ]); 63 | }); 64 | }); 65 | }); 66 | -------------------------------------------------------------------------------- /node-tests/unit/commands/utils/expand-platforms-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | const CorberError = require('../../../../lib/utils/corber-error'); 5 | 6 | const project = { root: 'root' }; 7 | 8 | describe('expandPlatforms Command Util', () => { 9 | let getPlatforms; 10 | let expandPlatforms; 11 | 12 | beforeEach(() => { 13 | getPlatforms = td.replace('../../../../lib/targets/cordova/utils/get-platforms'); 14 | 15 | td.when(getPlatforms(project)) 16 | .thenReturn(Promise.resolve(['added-platform'])); 17 | 18 | expandPlatforms = require('../../../../lib/commands/utils/expand-platforms'); 19 | }); 20 | 21 | context('when \'added\' is a specified platform', () => { 22 | it('appends added platforms', () => { 23 | return expect(expandPlatforms(project, ['added'])) 24 | .to.eventually.include('added-platform'); 25 | }); 26 | 27 | it('removes \'added\' from list', () => { 28 | return expect(expandPlatforms(project, ['added'])) 29 | .to.eventually.not.include('added'); 30 | }); 31 | 32 | it('does not remove another specified platform', () => { 33 | return expect(expandPlatforms(project, ['specified-platform', 'added'])) 34 | .to.eventually.include('specified-platform'); 35 | }); 36 | 37 | it('does not introduce a duplicate platform', () => { 38 | return expect(expandPlatforms(project, ['added-platform', 'added'])) 39 | .to.eventually.deep.equal(['added-platform']) 40 | }); 41 | 42 | it('rejects with CorberError if no added platforms', () => { 43 | td.when(getPlatforms(project)).thenReturn(Promise.resolve([])); 44 | 45 | return expect(expandPlatforms(project, ['added'])) 46 | .to.eventually.be.rejectedWith(CorberError); 47 | }); 48 | }); 49 | 50 | context('when \'added\' is not a specified platform', () => { 51 | it('does not remove a specified platform', () => { 52 | return expect(expandPlatforms(project, ['specified-platform'])) 53 | .to.eventually.include('specified-platform'); 54 | }); 55 | 56 | it('does not append any unspecified added platforms', () => { 57 | return expect(expandPlatforms(project), ['specified-platform']) 58 | .to.eventually.not.include('added-platform'); 59 | }); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /node-tests/unit/frameworks/ember/.framework-test.js.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/node-tests/unit/frameworks/ember/.framework-test.js.swp -------------------------------------------------------------------------------- /node-tests/unit/frameworks/ember/utils/get-cli-version-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const mockProject = require('../../../../fixtures/corber-mock/project'); 4 | const path = require('path'); 5 | const root = mockProject.project.root; 6 | 7 | let cliPackagePath = path.join(root, 'node_modules', 'ember-cli', 'package.json'); 8 | let packagePath = path.join(root, 'package.json'); 9 | 10 | describe('Get Ember CLI version test', () => { 11 | let fsUtils, getPackage; 12 | let getCLIVersion; 13 | 14 | beforeEach(() => { 15 | fsUtils = td.replace('../../../../../lib/utils/fs-utils'); 16 | getPackage = td.replace('../../../../../lib/utils/get-package'); 17 | 18 | getCLIVersion = require('../../../../../lib/frameworks/ember/utils/get-cli-version'); 19 | 20 | td.when(fsUtils.existsSync(cliPackagePath)).thenReturn(true); 21 | td.when(getPackage(cliPackagePath)).thenReturn({ version: '2.13.2' }); 22 | td.when(getPackage(packagePath)).thenReturn({ 23 | devDependencies: { 24 | 'ember-cli': '~2.13.0' 25 | } 26 | }); 27 | }); 28 | 29 | afterEach(() => { 30 | td.reset(); 31 | }); 32 | 33 | it('returns the node_modules/ember-cli/package.json version', () => { 34 | expect(getCLIVersion(root)).to.equal('2.13.2'); 35 | }); 36 | 37 | context('when node_modules/ember-cli/package.json does not exist', () => { 38 | beforeEach(() => { 39 | td.when(fsUtils.existsSync(cliPackagePath)).thenReturn(false); 40 | }); 41 | 42 | it('coerces version from package.json devDependencies', () => { 43 | expect(getCLIVersion(root)).to.equal('2.13.0'); 44 | }); 45 | 46 | context('when ember-cli is in package.json dependencies', () => { 47 | beforeEach(() => { 48 | td.when(getPackage(packagePath)).thenReturn({ 49 | dependencies: { 50 | 'ember-cli': '~3.10.0' 51 | } 52 | }); 53 | }) 54 | 55 | it('coerces version from package.json devDependencies', () => { 56 | expect(getCLIVersion(root)).to.equal('3.10.0'); 57 | }); 58 | }); 59 | }); 60 | }); 61 | -------------------------------------------------------------------------------- /node-tests/unit/frameworks/ember/validators/location-type-test.js: -------------------------------------------------------------------------------- 1 | var td = require('testdouble'); 2 | var expect = require('../../../../helpers/expect'); 3 | var mockProject = require('../../../../fixtures/corber-mock/project'); 4 | var ValidateLocType = require('../../../../../lib/frameworks/ember/validators/location-type'); 5 | var logger = require('../../../../../lib/utils/logger'); 6 | var contains = td.matchers.contains; 7 | 8 | describe('Validate Location Type', function() { 9 | var validateLoc; 10 | 11 | beforeEach(function() { 12 | validateLoc = new ValidateLocType({ 13 | project: mockProject.project 14 | }); 15 | }); 16 | 17 | afterEach(function() { 18 | td.reset(); 19 | }); 20 | 21 | it('rejects when config.locationType is auto', function() { 22 | validateLoc.config = { locationType: 'auto' }; 23 | return expect(validateLoc.run()).to.eventually.be.rejected; 24 | }); 25 | 26 | it('throws an error with config.locationType is blank', function() { 27 | validateLoc.config = {}; 28 | return expect(validateLoc.run()).to.eventually.be.rejected; 29 | }); 30 | 31 | it('resolves if config.locationType is hash', function() { 32 | validateLoc.config = { locationType: 'hash' }; 33 | return expect(validateLoc.run()).to.eventually.be.fulfilled; 34 | }); 35 | 36 | it('resolves if config.locationType is none', function() { 37 | validateLoc.config = { locationType: 'none' }; 38 | return expect(validateLoc.run()).to.eventually.be.fulfilled; 39 | }); 40 | 41 | it('when force is true, it warns vs rejects', function() { 42 | validateLoc.config = { locationType: 'auto' }; 43 | validateLoc.force = true; 44 | 45 | var warnDouble = td.replace(logger, 'warn'); 46 | 47 | return validateLoc.run().then(function() { 48 | td.verify(warnDouble(contains('You have passed the --force flag'))); 49 | }); 50 | }); 51 | }); 52 | -------------------------------------------------------------------------------- /node-tests/unit/frameworks/react/validators/homepage-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const mockProject = require('../../../../fixtures/corber-mock/project'); 4 | 5 | const initValidator = function() { 6 | let Homepage = require('../../../../../lib/frameworks/react/validators/homepage'); 7 | return new Homepage({root: mockProject.project.root}); 8 | }; 9 | 10 | describe('React Homepage Validator', function() { 11 | afterEach(function() { 12 | td.reset(); 13 | }); 14 | 15 | it('rejects with warnMsg if package.homepage[0] === /', function() { 16 | td.replace('../../../../../lib/utils/get-package', function() { 17 | return { 18 | homepage: '/' 19 | }; 20 | }); 21 | 22 | let validator = initValidator(); 23 | return expect(validator.run()).to.eventually.be.rejectedWith(validator.warnMsg()); 24 | }); 25 | 26 | it('rejects with warnMsg if package.homepage === undefined', function() { 27 | td.replace('../../../../../lib/utils/get-package', function() { 28 | return {}; 29 | }); 30 | 31 | let validator = initValidator(); 32 | return expect(validator.run()).to.eventually.be.rejectedWith(validator.warnMsg()); 33 | }); 34 | 35 | it('resolves if package.homepage does not meet fail criteria', function() { 36 | td.replace('../../../../../lib/utils/get-package', function() { 37 | return { 38 | homepage: './' 39 | }; 40 | }); 41 | 42 | let validator = initValidator(); 43 | return expect(validator.run()).to.eventually.be.fulfilled; 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /node-tests/unit/lint-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var glob = require('glob').sync; 4 | var lint = require('mocha-eslint'); 5 | var paths, options; 6 | 7 | // ht ember-cli 8 | paths = glob('node-tests/*').filter(function(path) { 9 | return !/fixtures/.test(path); 10 | }); 11 | 12 | paths = paths.concat([ 13 | 'lib', 14 | 'bin', 15 | 'blueprints' 16 | ]); 17 | 18 | options = { 19 | timeout: 5000, 20 | slow: 1000, 21 | strict: true 22 | }; 23 | 24 | lint(paths, options); 25 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/tasks/get-emulator-state-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const adbPath = 'adbPath'; 6 | const spawnArgs = [adbPath, ['shell', 'getprop', 'sys.boot_completed']]; 7 | 8 | describe('Android Emulator State', function() { 9 | let getEmulatorState; 10 | let spawn; 11 | 12 | beforeEach(function() { 13 | let sdkPaths = td.replace('../../../../../lib/targets/android/utils/sdk-paths'); 14 | td.when(sdkPaths()).thenReturn({ adb: adbPath }); 15 | 16 | spawn = td.replace('../../../../../lib/utils/spawn'); 17 | td.when(spawn(...spawnArgs)) 18 | .thenReturn(Promise.resolve({ 19 | stdout: ' default \n', 20 | stderr: '' 21 | })); 22 | 23 | getEmulatorState = require('../../../../../lib/targets/android/tasks/get-emulator-state'); 24 | }); 25 | 26 | afterEach(function() { 27 | td.reset(); 28 | }); 29 | 30 | it('calls spawn with correct arguments', () => { 31 | td.config({ ignoreWarnings: true }); 32 | 33 | td.when(spawn(), { ignoreExtraArgs: true }) 34 | .thenReturn(Promise.resolve({ stdout: '', stderr: '' })); 35 | 36 | return getEmulatorState().then(() => { 37 | td.verify(spawn(...spawnArgs)); 38 | 39 | td.config({ ignoreWarnings: false }); 40 | }); 41 | }); 42 | 43 | it('spawns adb shell and returns trimmed stdout', () => { 44 | return expect(getEmulatorState()).to.eventually.equal('default'); 45 | }); 46 | 47 | it('returns trimmed stderr instead if present', () => { 48 | td.when(spawn(...spawnArgs)) 49 | .thenReturn(Promise.resolve({ stdout: 'foo', stderr: ' error \n' })); 50 | 51 | return expect(getEmulatorState()).to.eventually.equal('error'); 52 | }); 53 | 54 | it('bubbles up error message when spawn rejects', () => { 55 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 56 | 57 | return expect(getEmulatorState()) 58 | .to.eventually.be.rejectedWith('spawn error'); 59 | }); 60 | }); 61 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/tasks/install-app-device-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const RSVP = require('rsvp'); 4 | const Promise = RSVP.Promise; 5 | 6 | const adbPath = 'adbPath'; 7 | const deviceUUID = 'uuid'; 8 | const apkPath = 'apk-path'; 9 | const spawnArgs = [adbPath, ['-s', deviceUUID, 'install', '-r', apkPath]]; 10 | 11 | describe('Android Install App - Device', () => { 12 | let installAppDevice; 13 | let spawn; 14 | 15 | beforeEach(() => { 16 | let sdkPaths = td.replace('../../../../../lib/targets/android/utils/sdk-paths'); 17 | td.when(sdkPaths()).thenReturn({ adb: adbPath }); 18 | 19 | spawn = td.replace('../../../../../lib/utils/spawn'); 20 | td.when(spawn(...spawnArgs)).thenReturn(Promise.resolve({ code: 0 })); 21 | 22 | installAppDevice = require('../../../../../lib/targets/android/tasks/install-app-device'); 23 | }); 24 | 25 | afterEach(() => { 26 | td.reset(); 27 | }); 28 | 29 | it('calls spawn with correct arguments', () => { 30 | td.config({ ignoreWarnings: true }); 31 | 32 | td.when(spawn(), { ignoreExtraArgs: true }) 33 | .thenReturn(Promise.resolve({ code: 0 })); 34 | 35 | return installAppDevice(deviceUUID, apkPath).then(() => { 36 | td.verify(spawn(...spawnArgs)); 37 | 38 | td.config({ ignoreWarnings: false }); 39 | }); 40 | }); 41 | 42 | it('resolves with object containing exit code from spawned process', () => { 43 | return expect(installAppDevice(deviceUUID, apkPath)) 44 | .to.eventually.contain({ code: 0 }); 45 | }); 46 | 47 | it('bubbles up error message when spawn rejects', () => { 48 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 49 | 50 | return expect(installAppDevice(deviceUUID, apkPath)) 51 | .to.eventually.be.rejectedWith('spawn error'); 52 | }); 53 | }); 54 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/tasks/install-app-emulator-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const adbPath = 'adbPath'; 6 | const apkPath = 'apkPath'; 7 | const spawnArgs = [adbPath, ['-e', 'install', '-r', apkPath]]; 8 | 9 | describe('Android Install App', () => { 10 | let installAppEmulator; 11 | let spawn; 12 | 13 | beforeEach(() => { 14 | let sdkPaths = td.replace('../../../../../lib/targets/android/utils/sdk-paths'); 15 | td.when(sdkPaths()).thenReturn({ adb: adbPath }); 16 | 17 | spawn = td.replace('../../../../../lib/utils/spawn'); 18 | td.when(spawn(...spawnArgs)).thenReturn(Promise.resolve({ code: 0 })); 19 | 20 | installAppEmulator = require('../../../../../lib/targets/android/tasks/install-app-emulator'); 21 | }); 22 | 23 | afterEach(() => { 24 | td.reset(); 25 | }); 26 | 27 | it('calls spawn with correct arguments', () => { 28 | td.config({ ignoreWarnings: true }); 29 | 30 | td.when(spawn(), { ignoreExtraArgs: true }) 31 | .thenReturn(Promise.resolve({ code: 0 })); 32 | 33 | return installAppEmulator(apkPath).then(() => { 34 | td.verify(spawn(...spawnArgs)); 35 | 36 | td.config({ ignoreWarnings: false }); 37 | }); 38 | }); 39 | 40 | it('spawns adb install and resolves with obj containing exit code', () => { 41 | return expect(installAppEmulator(apkPath)) 42 | .to.eventually.contain({ code: 0 }); 43 | }); 44 | 45 | it('bubbles up error message when spawn rejects', () => { 46 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 47 | 48 | return expect(installAppEmulator(apkPath)) 49 | .to.eventually.be.rejectedWith('spawn error'); 50 | }); 51 | }); 52 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/tasks/kill-emulator-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const adbPath = 'adbPath'; 6 | const emulatorName = 'emulator-fake'; 7 | const spawnArgs = [adbPath, ['-s', emulatorName, 'emu', 'kill']]; 8 | 9 | describe('Android Kill Emulator', () => { 10 | let killEmulator; 11 | let spawn; 12 | 13 | beforeEach(() => { 14 | let sdkPaths = td.replace('../../../../../lib/targets/android/utils/sdk-paths'); 15 | td.when(sdkPaths()).thenReturn({ adb: adbPath }); 16 | 17 | spawn = td.replace('../../../../../lib/utils/spawn'); 18 | td.when(spawn(...spawnArgs)) 19 | .thenReturn(Promise.resolve({ code: 0 })); 20 | 21 | killEmulator = require('../../../../../lib/targets/android/tasks/kill-emulator'); 22 | }); 23 | 24 | afterEach(() => { 25 | td.reset(); 26 | }); 27 | 28 | it('calls spawn with correct arguments', () => { 29 | td.config({ ignoreWarnings: true }); 30 | 31 | td.when(spawn(), { ignoreExtraArgs: true }) 32 | .thenReturn(Promise.resolve({ code: 0 })); 33 | 34 | return killEmulator(emulatorName).then(() => { 35 | td.verify(spawn(...spawnArgs)); 36 | 37 | td.config({ ignoreWarnings: false }); 38 | }); 39 | }); 40 | 41 | it('spawns adb kill and resolves with exit code', () => { 42 | return expect(killEmulator(emulatorName)) 43 | .to.eventually.deep.equal({ code: 0 }) 44 | }); 45 | 46 | it('rejects with same error message when spawned command rejects', () => { 47 | td.when(spawn(...spawnArgs)).thenReject('spawn error'); 48 | 49 | return expect(killEmulator(emulatorName)) 50 | .to.eventually.be.rejectedWith('spawn error'); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/tasks/launch-app-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const adbPath = 'adbPath'; 6 | const packageName = 'io.corber.project'; 7 | 8 | const spawnArgs = [ 9 | adbPath, 10 | [ 11 | 'shell', 12 | 'monkey', 13 | '-p', 14 | packageName, 15 | '-c', 16 | 'android.intent.category.LAUNCHER', 17 | 1 18 | ] 19 | ]; 20 | 21 | describe('Android LaunchApp', () => { 22 | let launchApp; 23 | let spawn; 24 | 25 | beforeEach(() => { 26 | let sdkPaths = td.replace('../../../../../lib/targets/android/utils/sdk-paths'); 27 | td.when(sdkPaths()).thenReturn({ adb: adbPath }); 28 | 29 | spawn = td.replace('../../../../../lib/utils/spawn'); 30 | td.when(spawn(...spawnArgs)) 31 | .thenReturn(Promise.resolve({ code: 0 })); 32 | 33 | launchApp = require('../../../../../lib/targets/android/tasks/launch-app'); 34 | }); 35 | 36 | afterEach(() => { 37 | td.reset(); 38 | }); 39 | 40 | it('calls spawn with correct arguments', () => { 41 | td.config({ ignoreWarnings: true }); 42 | 43 | td.when(spawn(), { ignoreExtraArgs: true }) 44 | .thenReturn(Promise.resolve({ code: 0 })); 45 | 46 | return launchApp(packageName).then(() => { 47 | td.verify(spawn(...spawnArgs)); 48 | 49 | td.config({ ignoreWarnings: false }); 50 | }); 51 | }); 52 | 53 | it('spawns adb monkey and resolves with obj containing exit code', () => { 54 | return expect(launchApp(packageName)).to.eventually.contain({ code: 0 }); 55 | }); 56 | 57 | it('bubbles up error message when spawn rejects', () => { 58 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 59 | 60 | return expect(launchApp(packageName)) 61 | .to.eventually.be.rejectedWith('spawn error'); 62 | }); 63 | }); 64 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/tasks/list-devices-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const Promise = require('rsvp').Promise; 3 | const expect = require('../../../../helpers/expect'); 4 | const Device = require('../../../../../lib/objects/device'); 5 | 6 | const adbPath = 'adbPath'; 7 | const spawnArgs = [adbPath, ['devices', '-l']]; 8 | const deviceList = `List of Devices Attached \nuuid device usb:337641472X product:jfltevl model:SGH_I337M device:jfltecan transport_id:1 \n`; 9 | 10 | describe('Android List Device Task', () => { 11 | let spawn; 12 | let listDevices; 13 | 14 | beforeEach(() => { 15 | let sdkPaths = td.replace('../../../../../lib/targets/android/utils/sdk-paths'); 16 | td.when(sdkPaths()).thenReturn({ adb: adbPath }); 17 | 18 | spawn = td.replace('../../../../../lib/utils/spawn'); 19 | td.when(spawn(...spawnArgs)) 20 | .thenReturn(Promise.resolve({ stdout: deviceList })); 21 | 22 | listDevices = require('../../../../../lib/targets/android/tasks/list-devices'); 23 | }); 24 | 25 | afterEach(() => { 26 | td.reset(); 27 | }); 28 | 29 | it('calls spawn with correct arguments', () => { 30 | td.config({ ignoreWarnings: true }); 31 | 32 | td.when(spawn(), { ignoreExtraArgs: true }) 33 | .thenReturn(Promise.resolve({})); 34 | 35 | return listDevices().then(() => { 36 | td.verify(spawn(...spawnArgs)); 37 | 38 | td.config({ ignoreWarnings: false }); 39 | }); 40 | }); 41 | 42 | it('lints out emulators, ignoring non iOS devices', () => { 43 | return listDevices().then((found) => { 44 | expect(found).to.deep.equal([new Device({ 45 | name: 'SGH_I337M', 46 | uuid: 'uuid', 47 | platform: 'android', 48 | deviceType: 'device' 49 | })]); 50 | }); 51 | }); 52 | 53 | it('bubbles up error message when spawn rejects', () => { 54 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 55 | return expect(listDevices()).to.eventually.be.rejectedWith('spawn error'); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/tasks/list-emulators-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Device = require('../../../../../lib/objects/device'); 4 | const Promise = require('rsvp').Promise; 5 | 6 | const emulatorPath = 'emulatorPath'; 7 | const spawnArgs = [emulatorPath, ['-list-avds']]; 8 | const emulatorList = 'Nexus_5X_API_27\nPixel_2_API_27'; 9 | 10 | describe('Android List Emulators', () => { 11 | let listEmulators; 12 | let spawn; 13 | 14 | beforeEach(() => { 15 | let sdkPaths = td.replace('../../../../../lib/targets/android/utils/sdk-paths'); 16 | td.when(sdkPaths()).thenReturn({ emulator: emulatorPath }); 17 | 18 | spawn = td.replace('../../../../../lib/utils/spawn'); 19 | td.when(spawn(...spawnArgs)) 20 | .thenReturn(Promise.resolve({ stdout: emulatorList })); 21 | 22 | listEmulators = require('../../../../../lib/targets/android/tasks/list-emulators'); 23 | }); 24 | 25 | afterEach(() => { 26 | td.reset(); 27 | }); 28 | 29 | it('calls spawn with correct arguments', () => { 30 | td.config({ ignoreWarnings: true }); 31 | 32 | td.when(spawn(), { ignoreExtraArgs: true }) 33 | .thenReturn(Promise.resolve({ stdout: '' })); 34 | 35 | return listEmulators().then(() => { 36 | td.verify(spawn(...spawnArgs)); 37 | 38 | td.config({ ignoreWarnings: false }); 39 | }); 40 | }); 41 | 42 | it('parses emulator -list-avds to Emulator objects', () => { 43 | return expect(listEmulators()).to.eventually.deep.equal([ 44 | new Device({ 45 | name: 'Pixel_2_API_27', 46 | platform: 'android', 47 | deviceType: 'emulator' 48 | }), 49 | new Device({ 50 | name: 'Nexus_5X_API_27', 51 | platform: 'android', 52 | deviceType: 'emulator' 53 | }) 54 | ]); 55 | }); 56 | 57 | it('bubbles up error message when spawn rejects', () => { 58 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 59 | return expect(listEmulators()).to.eventually.be.rejectedWith('spawn error'); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/tasks/list-running-emulators-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const adbPath = 'adbPath'; 6 | const spawnArgs = [adbPath, ['devices', '-l']]; 7 | const emulatorList = 'emulator-5554 device product:sdk_gphone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:26'; 8 | 9 | describe('Android List Running Emulators', () => { 10 | let listRunningEmulators; 11 | let spawn; 12 | 13 | beforeEach(() => { 14 | let sdkPaths = td.replace('../../../../../lib/targets/android/utils/sdk-paths'); 15 | td.when(sdkPaths()).thenReturn({ adb: adbPath }); 16 | 17 | spawn = td.replace('../../../../../lib/utils/spawn'); 18 | td.when(spawn(...spawnArgs)) 19 | .thenReturn(Promise.resolve({ stdout: emulatorList })); 20 | 21 | listRunningEmulators = require('../../../../../lib/targets/android/tasks/list-running-emulators'); 22 | }); 23 | 24 | afterEach(() => { 25 | td.reset(); 26 | }); 27 | 28 | it('calls spawn with correct arguments', () => { 29 | td.config({ ignoreWarnings: true }); 30 | 31 | td.when(spawn(), { ignoreExtraArgs: true }) 32 | .thenReturn(Promise.resolve({ stdout: '' })); 33 | 34 | return listRunningEmulators().then(() => { 35 | td.verify(spawn(...spawnArgs)); 36 | 37 | td.config({ ignoreWarnings: false }); 38 | }); 39 | }); 40 | 41 | it('returns an array of active emulator ids', () => { 42 | return expect(listRunningEmulators()) 43 | .to.eventually.deep.equal(['emulator-5554']); 44 | }); 45 | 46 | it('bubbles up error message when spawn rejects', () => { 47 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 48 | 49 | return expect(listRunningEmulators()) 50 | .to.eventually.be.rejectedWith('spawn error'); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /node-tests/unit/targets/android/utils/resolve-path-test.js: -------------------------------------------------------------------------------- 1 | const resolvePath = require('../../../../../lib/targets/android/utils/resolve-path'); 2 | const expect = require('../../../../helpers/expect'); 3 | 4 | describe('When user passes and array of paths', function() { 5 | it('finds the existing one', function() { 6 | let paths = [ 7 | undefined, 8 | process.env['HOME'], 9 | ]; 10 | 11 | expect(resolvePath(paths)).to.eq(process.env['HOME']); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /node-tests/unit/targets/cordova/tasks/build-test.js: -------------------------------------------------------------------------------- 1 | var td = require('testdouble'); 2 | var mockProject = require('../../../../fixtures/corber-mock/project'); 3 | var CdvRawTask = require('../../../../../lib/targets/cordova/tasks/raw'); 4 | 5 | var setupBuildTask = function() { 6 | var CdvBuildTask = require('../../../../../lib/targets/cordova/tasks/build'); 7 | return new CdvBuildTask(mockProject); 8 | }; 9 | 10 | describe('Cordova Build Task', function() { 11 | afterEach(function() { 12 | td.reset(); 13 | }); 14 | 15 | it('creates a raw build task', function() { 16 | var cdvBuild = td.replace(CdvRawTask.prototype, 'run'); 17 | var build = setupBuildTask(); 18 | build.platform = 'ios'; 19 | build.run(); 20 | 21 | td.verify(cdvBuild({platforms: ['ios'], options: {}, browserify: false, emulator: true})); 22 | }); 23 | 24 | it('sets platform to android', function() { 25 | var cdvBuild = td.replace(CdvRawTask.prototype, 'run'); 26 | var build = setupBuildTask(); 27 | build.platform = 'android'; 28 | build.run(); 29 | 30 | td.verify(cdvBuild({platforms: ['android'], options: {}, browserify: false, emulator: true})); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /node-tests/unit/targets/cordova/tasks/prepare-test.js: -------------------------------------------------------------------------------- 1 | var td = require('testdouble'); 2 | var mockProject = require('../../../../fixtures/corber-mock/project'); 3 | var CdvRawTask = require('../../../../../lib/targets/cordova/tasks/raw'); 4 | 5 | var setupPrepareTask = function() { 6 | var PrepareTask = require('../../../../../lib/targets/cordova/tasks/prepare'); 7 | return new PrepareTask(mockProject); 8 | }; 9 | 10 | describe('Cordova Prepare Task', function() { 11 | afterEach(function() { 12 | td.reset(); 13 | }); 14 | 15 | it('runs cordova prepare with fetch defaulted', function() { 16 | var RawDouble = td.replace(CdvRawTask.prototype, 'run'); 17 | var prepare = setupPrepareTask(); 18 | prepare.run(); 19 | 20 | td.verify(new RawDouble({fetch: true})); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /node-tests/unit/targets/cordova/utils/get-app-name-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const mockProject = require('../../../../fixtures/corber-mock/project'); 4 | const getAppName = require('../../../../../lib/targets/cordova/utils/get-app-name'); 5 | const { Promise } = require('rsvp'); 6 | 7 | describe('Get App Name Util', function() { 8 | beforeEach(function() { 9 | td.replace('../../../../../lib/targets/cordova/utils/get-config', () => { 10 | return Promise.resolve({ 11 | widget: { 12 | name: ['fooApp'] 13 | } 14 | }); 15 | }); 16 | }); 17 | 18 | afterEach(() => { 19 | td.reset(); 20 | }); 21 | 22 | it('should return the correct app name', function() { 23 | let project = mockProject.project; 24 | expect(getAppName(project)).to.eventually.equal('fooApp'); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /node-tests/unit/targets/cordova/utils/parse-build-flags-test.js: -------------------------------------------------------------------------------- 1 | var expect = require('../../../../helpers/expect'); 2 | var parseCordovaOpts = require('../../../../../lib/targets/cordova/utils/parse-build-flags'); 3 | 4 | describe('Parse Cordova Build Options Util', function() { 5 | it('sets generic flags', function() { 6 | var cordovaOpts = parseCordovaOpts('ios', { 7 | release: true, device: 'deviceName' 8 | }) 9 | 10 | expect(cordovaOpts.release).to.equal(true); 11 | expect(cordovaOpts.device).to.equal('deviceName'); 12 | }); 13 | 14 | describe('for ios', function() { 15 | it('returns ios options', function() { 16 | var options = { codeSignIdentity: 'FOO' }; 17 | var cordovaOpts = parseCordovaOpts('ios', options) 18 | 19 | expect(cordovaOpts.codeSignIdentity).to.equal('FOO'); 20 | }); 21 | 22 | it ('does not parse android options', function() { 23 | var options = { keystore: 'FOO-KEYSTORE' }; 24 | var cordovaOpts = parseCordovaOpts('ios', options) 25 | 26 | expect(cordovaOpts.keystore).to.equal(undefined); 27 | }); 28 | }); 29 | 30 | describe('for android', function() { 31 | it('returns android options', function() { 32 | var options = { keystore: 'FOO-KEYSTORE' }; 33 | var cordovaOpts = parseCordovaOpts('android', options) 34 | 35 | expect(cordovaOpts.keystore).to.equal('FOO-KEYSTORE'); 36 | }); 37 | 38 | it('does not parse ios options', function() { 39 | var options = { codeSignIdentity: 'FOO' }; 40 | var cordovaOpts = parseCordovaOpts('android', options) 41 | 42 | expect(cordovaOpts.codeSignIdentity).to.equal(undefined); 43 | }); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /node-tests/unit/targets/cordova/validators/is-installed-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | 4 | describe('Verify Cordova Installed Task', () => { 5 | let commandExists; 6 | let isInstalled; 7 | 8 | beforeEach(() => { 9 | commandExists = td.replace('../../../../../lib/utils/command-exists'); 10 | td.when(commandExists('cordova')).thenReturn(true); 11 | 12 | let IsInstalled = require('../../../../../lib/targets/cordova/validators/is-installed'); 13 | 14 | isInstalled = new IsInstalled({ 15 | command: 'foo', 16 | options: {} 17 | }); 18 | }); 19 | 20 | afterEach(() => { 21 | td.reset(); 22 | }); 23 | 24 | it('resolves when cordova command exists', () => { 25 | expect(isInstalled.run()).to.eventually.be.fulfilled; 26 | }); 27 | 28 | describe('when cordova command does not exist', () => { 29 | beforeEach(() => { 30 | td.when(commandExists('cordova')).thenReturn(false); 31 | }); 32 | 33 | it('rejects with message', () => { 34 | expect(isInstalled.run()) 35 | .to.eventually.be.rejectedWith(/The command `cordova` was not found/); 36 | }); 37 | 38 | it('resolves if cordova check is skipped', () => { 39 | isInstalled.options.skipCordovaCheck = true 40 | expect(isInstalled.run()).to.eventually.be.fulfilled; 41 | }); 42 | }) 43 | }); 44 | -------------------------------------------------------------------------------- /node-tests/unit/targets/ios/tasks/boot-emulator-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const Promise = require('rsvp').Promise; 3 | const expect = require('../../../../helpers/expect'); 4 | 5 | const uuid = 'uuid'; 6 | const spawnArgs = ['/usr/bin/xcrun', ['simctl', 'boot', uuid]]; 7 | 8 | describe('iOS Boot Emulator Task', () => { 9 | let bootEmulator; 10 | let spawn; 11 | 12 | beforeEach(() => { 13 | spawn = td.replace('../../../../../lib/utils/spawn'); 14 | td.when(spawn(...spawnArgs)).thenReturn(Promise.resolve({ code: 0 })); 15 | 16 | bootEmulator = require('../../../../../lib/targets/ios/tasks/boot-emulator'); 17 | }); 18 | 19 | afterEach(() => { 20 | td.reset(); 21 | }); 22 | 23 | it('does not spawn boot if the emulator state is Booted', () => { 24 | return bootEmulator({ uuid, state: 'Booted' }).then(() => { 25 | td.verify(spawn(), { ignoreExtraArgs: true, times: 0 }); 26 | }); 27 | }); 28 | 29 | it('calls spawn with correct arguments', () => { 30 | td.config({ ignoreWarnings: true }); 31 | 32 | td.when(spawn(), { ignoreExtraArgs: true }) 33 | .thenReturn(Promise.resolve()); 34 | 35 | return bootEmulator({ uuid }).then(() => { 36 | td.verify(spawn(...spawnArgs)); 37 | 38 | td.config({ ignoreWarnings: false }); 39 | }); 40 | }); 41 | 42 | it('spawns xcrun and resolves with exit code', () => { 43 | return expect(bootEmulator({ uuid })).to.eventually.deep.equal({ code: 0 }); 44 | }); 45 | 46 | it('bubbles up error message when spawn rejects', () => { 47 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 48 | 49 | return expect(bootEmulator({ uuid })) 50 | .to.eventually.be.rejectedWith('spawn error'); 51 | }); 52 | }); 53 | -------------------------------------------------------------------------------- /node-tests/unit/targets/ios/tasks/install-app-device-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | const path = require('path'); 5 | 6 | const deviceId = 'deviceId'; 7 | const bundlePath = 'bundlePath'; 8 | const rootPath = 'rootPath'; 9 | 10 | const iosDeployPath = path.join(rootPath, 'node_modules', 'corber', 'vendor', 'ios-deploy', 'build', 'Release', 'ios-deploy'); 11 | 12 | const spawnArgs = [ 13 | iosDeployPath, 14 | [ 15 | '--id', 16 | deviceId, 17 | '--bundle', 18 | bundlePath, 19 | '--justlaunch' 20 | ] 21 | ]; 22 | 23 | describe('IOS Install App Device', function() { 24 | let installApp; 25 | let spawn; 26 | 27 | beforeEach(() => { 28 | spawn = td.replace('../../../../../lib/utils/spawn'); 29 | td.when(spawn(...spawnArgs)).thenReturn(Promise.resolve({ code: 0 })); 30 | 31 | installApp = require('../../../../../lib/targets/ios/tasks/install-app-device'); 32 | }); 33 | 34 | afterEach(() => { 35 | td.reset(); 36 | }); 37 | 38 | it('calls spawn with correct arguments', () => { 39 | td.config({ ignoreWarnings: true }); 40 | 41 | td.when(spawn(), { ignoreExtraArgs: true }) 42 | .thenReturn(Promise.resolve()); 43 | 44 | return installApp(deviceId, bundlePath, rootPath).then(() => { 45 | td.verify(spawn(...spawnArgs)); 46 | 47 | td.config({ ignoreWarnings: false }); 48 | }); 49 | }); 50 | 51 | it('spawns task and resolves with exit code', () => { 52 | return expect(installApp(deviceId, bundlePath, rootPath)) 53 | .to.eventually.deep.equal({ code: 0 }); 54 | }); 55 | }); 56 | 57 | -------------------------------------------------------------------------------- /node-tests/unit/targets/ios/tasks/install-app-emulator-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const emulatorId = 'emulatorId'; 6 | const ipaPath = 'ipa-path'; 7 | 8 | const spawnArgs = [ 9 | '/usr/bin/xcrun', 10 | [ 11 | 'simctl', 12 | 'install', 13 | emulatorId, 14 | ipaPath 15 | ] 16 | ]; 17 | 18 | describe('IOS Install App Emulator', function() { 19 | let installApp; 20 | let spawn; 21 | 22 | beforeEach(() => { 23 | spawn = td.replace('../../../../../lib/utils/spawn'); 24 | td.when(spawn(...spawnArgs)).thenReturn(Promise.resolve({ code: 0 })); 25 | 26 | installApp = require('../../../../../lib/targets/ios/tasks/install-app-emulator'); 27 | }); 28 | 29 | afterEach(() => { 30 | td.reset(); 31 | }); 32 | 33 | it('calls spawn with correct arguments', () => { 34 | td.config({ ignoreWarnings: true }); 35 | 36 | td.when(spawn(), { ignoreExtraArgs: true }) 37 | .thenReturn(Promise.resolve()); 38 | 39 | return installApp(emulatorId, ipaPath).then(() => { 40 | td.verify(spawn(...spawnArgs)); 41 | 42 | td.config({ ignoreWarnings: false }); 43 | }); 44 | }); 45 | 46 | it('spawns scrun and resolves with exit code', () => { 47 | return expect(installApp(emulatorId, ipaPath)) 48 | .to.eventually.deep.equal({ code: 0 }); 49 | }); 50 | 51 | it('bubbles up error message when spawn rejects', () => { 52 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 53 | 54 | return expect(installApp(emulatorId, ipaPath)) 55 | .to.eventually.be.rejectedWith('spawn error'); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /node-tests/unit/targets/ios/tasks/launch-app-test-emulator.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const emulatorId = 'emulatorId'; 6 | const appName = 'appName'; 7 | 8 | const spawnArgs = [ 9 | '/usr/bin/xcrun', 10 | [ 11 | 'simctl', 12 | 'launch', 13 | emulatorId, 14 | appName 15 | ] 16 | ]; 17 | 18 | describe('IOS Launch App Emulator', () => { 19 | let launchApp; 20 | let spawn; 21 | 22 | beforeEach(() => { 23 | spawn = td.replace('../../../../../lib/utils/spawn'); 24 | td.when(spawn(...spawnArgs)).thenReturn(Promise.resolve({ code: 0 })); 25 | 26 | launchApp = require('../../../../../lib/targets/ios/tasks/launch-app-emulator'); 27 | }); 28 | 29 | afterEach(() => { 30 | td.reset(); 31 | }); 32 | 33 | it('calls spawn with correct arguments', () => { 34 | td.config({ ignoreWarnings: true }); 35 | 36 | td.when(spawn(), { ignoreExtraArgs: true }) 37 | .thenReturn(Promise.resolve()); 38 | 39 | return launchApp(emulatorId, appName).then(() => { 40 | td.verify(spawn(...spawnArgs)); 41 | 42 | td.config({ ignoreWarnings: false }); 43 | }); 44 | }); 45 | 46 | it('spawns xcrun and resolves with exit code', () => { 47 | return expect(launchApp(emulatorId, appName)) 48 | .to.eventually.deep.equal({ code: 0 }); 49 | }); 50 | 51 | it('bubbles up error message when spawn rejects', () => { 52 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 53 | 54 | return expect(launchApp(emulatorId, appName)) 55 | .to.eventually.be.rejectedWith('spawn error'); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /node-tests/unit/targets/ios/tasks/list-devices-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Device = require('../../../../../lib/objects/device'); 4 | const Promise = require('rsvp').Promise; 5 | 6 | const spawnArgs = ['/usr/bin/xctrace', ['list', 'devices']]; 7 | 8 | //yes - isleofcode.com is my actual device name 9 | //(turn on the hotspot and be branding all conference long!) 10 | const deviceList = `== Devices == 11 | MacBook Pro (Tomasz) (uuid) 12 | isleofcode.com (12.1.2) (uuid) 13 | 14 | == Simulators == 15 | Apple TV Simulator (12.1) (uuid) 16 | iPhone X Simulator (12.1) (uuid)` 17 | 18 | describe('iOS List Emulator Task', () => { 19 | let listDevices; 20 | let spawn; 21 | 22 | beforeEach(() => { 23 | spawn = td.replace('../../../../../lib/utils/spawn'); 24 | td.when(spawn(...spawnArgs)) 25 | .thenReturn(Promise.resolve({ stdout: deviceList })); 26 | 27 | listDevices = require('../../../../../lib/targets/ios/tasks/list-devices'); 28 | }); 29 | 30 | afterEach(() => { 31 | td.reset(); 32 | }); 33 | 34 | it('calls spawn with correct arguments', () => { 35 | td.config({ ignoreWarnings: true }); 36 | 37 | td.when(spawn(), { ignoreExtraArgs: true }) 38 | .thenReturn(Promise.resolve({ stdout: '' })); 39 | 40 | return listDevices().then(() => { 41 | td.verify(spawn(...spawnArgs)); 42 | 43 | td.config({ ignoreWarnings: false }); 44 | }); 45 | }); 46 | 47 | it('lints out ios device, ignoring emulators & non ios devices', () => { 48 | return expect(listDevices()).to.eventually.deep.equal([ 49 | new Device({ 50 | apiVersion: '12.1.2', 51 | name: 'isleofcode.com', 52 | uuid: 'uuid', 53 | platform: 'ios', 54 | deviceType: 'device' 55 | }) 56 | ]); 57 | }); 58 | 59 | it('bubbles up error message when spawn rejects', () => { 60 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 61 | return expect(listDevices()).to.eventually.be.rejectedWith('spawn error'); 62 | }); 63 | }); 64 | 65 | -------------------------------------------------------------------------------- /node-tests/unit/targets/ios/tasks/open-emulator-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | const spawnArgs = [ 6 | 'open', 7 | ['/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'] 8 | ]; 9 | 10 | describe('IOS Open Emulator', function() { 11 | let openEmulator; 12 | let spawn; 13 | 14 | beforeEach(() => { 15 | spawn = td.replace('../../../../../lib/utils/spawn'); 16 | td.when(spawn(...spawnArgs)).thenReturn(Promise.resolve({ code: 0 })); 17 | 18 | openEmulator = require('../../../../../lib/targets/ios/tasks/open-emulator'); 19 | }); 20 | 21 | afterEach(() => { 22 | td.reset(); 23 | }); 24 | 25 | it('calls spawn with correct arguments', () => { 26 | td.config({ ignoreWarnings: true }); 27 | 28 | td.when(spawn(), { ignoreExtraArgs: true }) 29 | .thenReturn(Promise.resolve()); 30 | 31 | return openEmulator().then(() => { 32 | td.verify(spawn(...spawnArgs)); 33 | 34 | td.config({ ignoreWarnings: false }); 35 | }); 36 | }); 37 | 38 | it('spawns xcrun and resolves with exit code', () => { 39 | return expect(openEmulator()) 40 | .to.eventually.deep.equal({ code: 0 }); 41 | }); 42 | 43 | it('bubbles up error message when spawn rejects', () => { 44 | td.when(spawn(...spawnArgs)).thenReturn(Promise.reject('spawn error')); 45 | 46 | return expect(openEmulator()) 47 | .to.eventually.be.rejectedWith('spawn error'); 48 | }); 49 | }); 50 | -------------------------------------------------------------------------------- /node-tests/unit/targets/ios/utils/parse-pbxproj-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../../../helpers/expect'); 3 | const parsePbx = require('../../../../../lib/targets/ios/utils/parse-pbxproj'); 4 | const fsUtils = require('../../../../../lib/utils/fs-utils'); 5 | 6 | describe('Parse pbxproj Test', function() { 7 | afterEach(function() { 8 | td.reset(); 9 | }); 10 | 11 | it('throws if pbxproj file does not exist', function() { 12 | td.replace(fsUtils, 'existsSync', () => false); 13 | return expect(() => parsePbx('foo.pbxproj')).to.throw(); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /node-tests/unit/tasks/bash-build-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | let tasks, Bash, fsArgs; 6 | 7 | const setupBuild = function(stubFs) { 8 | tasks = []; 9 | fsArgs = []; 10 | 11 | td.replace('../../../lib/utils/fs-utils', { 12 | empty: function(path) { 13 | tasks.push('empty-dir'); 14 | fsArgs.push(path); 15 | return Promise.resolve(); 16 | }, 17 | 18 | copyDir: function(source, dest) { 19 | tasks.push('copy-dir'); 20 | fsArgs.push(`${source} ${dest}`); 21 | return Promise.resolve(); 22 | } 23 | }); 24 | 25 | td.replace('../../../lib/utils/create-gitkeep', function() { 26 | tasks.push('create-gitkeep'); 27 | return Promise.resolve(); 28 | }); 29 | 30 | Bash = td.replace('../../../lib/tasks/bash'); 31 | let Build = require('../../../lib/tasks/bash-build'); 32 | 33 | td.replace(Bash.prototype, 'run', function() { 34 | tasks.push('bash-task'); 35 | return Promise.resolve(); 36 | }); 37 | 38 | return new Build({ 39 | buildCommand: 'fakeBuildCommand', 40 | buildPath: 'fakePath', 41 | cordovaOutputPath: 'fakeCordovaPath' 42 | }); 43 | } 44 | 45 | 46 | describe('Bash Build Task', function() { 47 | afterEach(function() { 48 | td.reset(); 49 | }); 50 | 51 | it('runs tasks in the correct order', function() { 52 | let buildTask = setupBuild(); 53 | 54 | return buildTask.run({cordovaOutputPath: 'fakePath'}).then(function() { 55 | expect(tasks).to.deep.equal([ 56 | 'empty-dir', 57 | 'create-gitkeep', 58 | 'bash-task', 59 | 'copy-dir' 60 | ]); 61 | }); 62 | }); 63 | 64 | it('constructs tasks with the right params', function() { 65 | let buildTask = setupBuild(); 66 | 67 | let captor = td.matchers.captor(); 68 | return buildTask.run({cordovaOutputPath: 'fakePath'}).then(function() { 69 | td.verify(new Bash(captor.capture())); 70 | expect(captor.values[0].command).to.equal('fakeBuildCommand'); 71 | expect(fsArgs[0]).to.equal('fakeCordovaPath'); 72 | expect(fsArgs[1]).to.equal('fakePath fakeCordovaPath'); 73 | }); 74 | }); 75 | }); 76 | -------------------------------------------------------------------------------- /node-tests/unit/tasks/bash-serve-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../helpers/expect'); 3 | const Promise = require('rsvp').Promise; 4 | 5 | describe('Vue Serve Task', function() { 6 | afterEach(function() { 7 | td.reset(); 8 | }); 9 | 10 | it('constructs and runs a Bash Task', function() { 11 | let Bash = td.replace('../../../lib/tasks/bash'); 12 | let Serve = require('../../../lib/tasks/bash-serve'); 13 | let tasks = []; 14 | 15 | td.replace(Bash.prototype, 'run', function() { 16 | tasks.push('bash-task'); 17 | return Promise.resolve(); 18 | }); 19 | 20 | let serveTask = new Serve({ 21 | command: 'node build/dev-server.js', 22 | platform: 'ios' 23 | }); 24 | return serveTask.run('ios').then(function() { 25 | td.verify(new Bash({ 26 | command: 'node build/dev-server.js --CORBER_PLATFORM=ios' 27 | })); 28 | 29 | expect(tasks).to.deep.equal([ 30 | 'bash-task' 31 | ]); 32 | }); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /node-tests/unit/tasks/install-package-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const mockProject = require('../../fixtures/corber-mock/project'); 3 | const fsUtils = require('../../../lib/utils/fs-utils'); 4 | const Promise = require('rsvp').Promise; 5 | 6 | describe('InstallPackage Task', function() { 7 | function getTask() { 8 | let InstallPackage = require('../../../lib/tasks/install-package'); 9 | return new InstallPackage({ rootPath: mockProject.project.root }); 10 | } 11 | 12 | afterEach(function() { 13 | td.reset(); 14 | }); 15 | 16 | context('install command', function() { 17 | let bashDouble; 18 | beforeEach(function() { 19 | bashDouble = td.replace('../../../lib/tasks/bash'); 20 | td.replace(fsUtils, 'write'); 21 | }); 22 | 23 | it('detects and installs with yarn', function() { 24 | td.replace(fsUtils, 'read', function(path) { 25 | if (path.indexOf('yarn') >= 0) { 26 | return Promise.resolve(); 27 | } 28 | }); 29 | 30 | let install = getTask(); 31 | return install.run('corber').then(function() { 32 | td.verify(bashDouble({command: 'yarn add corber --dev'})); 33 | }); 34 | }); 35 | 36 | it('detects and installs with npm', function() { 37 | td.replace(fsUtils, 'read', function(path) { 38 | if (path.indexOf('yarn') >= 0) { 39 | return Promise.reject(); 40 | } 41 | }); 42 | 43 | let install = getTask(); 44 | return install.run('corber').then(function() { 45 | td.verify(bashDouble({command: 'npm install corber --save'})); 46 | }); 47 | }); 48 | 49 | it('appends version when provided', function() { 50 | td.replace(fsUtils, 'read', function(path) { 51 | if (path.indexOf('yarn') >= 0) { 52 | return Promise.resolve(); 53 | } 54 | }); 55 | 56 | let install = getTask(); 57 | return install.run('corber', '1.0').then(function() { 58 | td.verify(bashDouble({command: 'yarn add corber@1.0 --dev'})); 59 | }); 60 | }); 61 | }); 62 | }); 63 | -------------------------------------------------------------------------------- /node-tests/unit/tasks/install-project-corber-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../helpers/expect'); 3 | const mockProject = require('../../fixtures/corber-mock/project'); 4 | const InstallPackage = require('../../../lib/tasks/install-package'); 5 | const Promise = require('rsvp').Promise; 6 | 7 | 8 | describe('Install project corber Task', function() { 9 | function getTask() { 10 | let InstallCorber = require('../../../lib/tasks/install-project-corber'); 11 | return new InstallCorber({ rootPath: mockProject.project.root }); 12 | } 13 | 14 | afterEach(function() { 15 | td.reset(); 16 | }); 17 | 18 | it('detects the current corber version and spawns an install-task', function() { 19 | let passedName, passedVersion; 20 | 21 | td.replace(InstallPackage.prototype, 'run', function(name, version) { 22 | passedName = name; 23 | passedVersion = version; 24 | return Promise.resolve(); 25 | }); 26 | 27 | let installCorber = getTask(); 28 | 29 | let expectedVersion = require('../../../package.json').version; 30 | return installCorber.run().then(function() { 31 | expect(passedName).to.equal('corber'); 32 | expect(passedVersion).to.equal(expectedVersion); 33 | }); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /node-tests/unit/tasks/lint-index-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const Promise = require('rsvp').Promise; 3 | const contains = td.matchers.contains; 4 | 5 | const source = 'www/index.html'; 6 | 7 | describe('Lint Index Task', () => { 8 | let fsUtils; 9 | let logger; 10 | let lintIndex; 11 | 12 | beforeEach(() => { 13 | fsUtils = td.replace('../../../lib/utils/fs-utils'); 14 | logger = td.replace('../../../lib/utils/logger'); 15 | 16 | td.when(fsUtils.read(source)).thenReturn(Promise.resolve('')); 17 | 18 | lintIndex = require('../../../lib/tasks/lint-index'); 19 | }); 20 | 21 | afterEach(() => { 22 | td.reset(); 23 | }); 24 | 25 | it('logs a starting message to info', () => { 26 | return lintIndex(source).then(() => { 27 | td.verify(logger.info(contains(`Linting ${source}...`))); 28 | }); 29 | }); 30 | 31 | it('logs to success when there are no problems', () => { 32 | return lintIndex(source).then(() => { 33 | td.verify(logger.success(contains('0 problems'))); 34 | }); 35 | }); 36 | 37 | it('logs a warning when is a href property with leading /', () => { 38 | td.when(fsUtils.read(source), { ignoreExtraArgs: true }) 39 | .thenReturn(Promise.resolve('Foo')); 40 | 41 | return lintIndex(source).then(() => { 42 | td.verify(logger.warn(contains('paths beginning with /'))); 43 | }); 44 | }); 45 | 46 | it('logs a warning when is a src property with leading /', () => { 47 | td.when(fsUtils.read(source), { ignoreExtraArgs: true }) 48 | .thenReturn(Promise.resolve('')); 49 | 50 | return lintIndex(source).then(() => { 51 | td.verify(logger.warn(contains('paths beginning with /'))); 52 | }); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /node-tests/unit/utils/command-exists-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../helpers/expect'); 3 | 4 | describe('Command Exists util', () => { 5 | let childProcess; 6 | let commandExists; 7 | let originalPlatform; 8 | 9 | beforeEach(() => { 10 | originalPlatform = Object.getOwnPropertyDescriptor(process, 'platform'); 11 | 12 | childProcess = td.replace('child_process'); 13 | 14 | commandExists = require('../../../lib/utils/command-exists'); 15 | }); 16 | 17 | afterEach(() => { 18 | td.reset(); 19 | 20 | Object.defineProperty(process, 'platform', originalPlatform); 21 | }); 22 | 23 | it('uses command on osx', () => { 24 | Object.defineProperty(process, 'platform', { value: 'darwin' }); 25 | 26 | commandExists('foo'); 27 | 28 | let cmd = 'command -v foo >/dev/null && { echo >&1 \'command found\'; }'; 29 | td.verify(childProcess.execSync(cmd)); 30 | }); 31 | 32 | it('uses command on linux', () => { 33 | Object.defineProperty(process, 'platform', { value: 'linux' }); 34 | 35 | commandExists('foo'); 36 | 37 | let cmd = 'command -v foo >/dev/null && { echo >&1 \'command found\'; }'; 38 | td.verify(childProcess.execSync(cmd)); 39 | }); 40 | 41 | it('uses where on windows', () => { 42 | Object.defineProperty(process, 'platform', { value: 'win32' }); 43 | 44 | commandExists('foo'); 45 | 46 | td.verify(childProcess.execSync('where foo')) 47 | }); 48 | 49 | it('returns true when execSync returns true', () => { 50 | td.when(childProcess.execSync(), { ignoreExtraArgs: true }) 51 | .thenReturn(true); 52 | 53 | expect(commandExists('foo')).to.be.true; 54 | }); 55 | 56 | it('return false when execSync throws an exception', () => { 57 | td.when(childProcess.execSync(), { ignoreExtraArgs: true }) 58 | .thenThrow(new Error('error')); 59 | 60 | expect(commandExists('foo')).to.be.false; 61 | }); 62 | }); 63 | -------------------------------------------------------------------------------- /node-tests/unit/utils/create-gitkeep-test.js: -------------------------------------------------------------------------------- 1 | var td = require('testdouble'); 2 | var fsUtils = require('../../../lib/utils/fs-utils'); 3 | var createGitkeep = require('../../../lib/utils/create-gitkeep'); 4 | 5 | 6 | describe('Create gitkeep util', function() { 7 | beforeEach(function() { 8 | td.reset(); 9 | }); 10 | 11 | it('attempts to write an empty gitkeep file', function() { 12 | var writeDouble = td.replace(fsUtils, 'write'); 13 | createGitkeep('fooPath'); 14 | 15 | td.verify(writeDouble('fooPath', '', { encoding: 'utf8' })); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /node-tests/unit/utils/get-package-test.js: -------------------------------------------------------------------------------- 1 | const expect = require('../../helpers/expect'); 2 | const path = require('path'); 3 | 4 | const mockProject = require('../../fixtures/corber-mock/project'); 5 | const getPackage = require('../../../lib/utils/get-package'); 6 | 7 | const root = mockProject.project.root; 8 | 9 | describe('getPackage', function() { 10 | it('attempts to requre package path', function() { 11 | const packagePath = path.join(root, 'package.json'); 12 | let packageJSON = getPackage(packagePath); 13 | expect(packageJSON.name).to.equal('mock-project'); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /node-tests/unit/utils/logger-test.js: -------------------------------------------------------------------------------- 1 | const logger = require('../../../lib/utils/logger'); 2 | const expect = require('../../helpers/expect'); 3 | 4 | describe('logger util', function() { 5 | it('allows to set and get a log level', function() { 6 | logger.setLogLevel('error'); 7 | expect(logger.getLogLevel()).to.equal('error'); 8 | }); 9 | 10 | describe('shouldLog', function() { 11 | beforeEach(function() { 12 | logger.setLogLevel('info'); 13 | }); 14 | 15 | it('returns true for higher levels', function() { 16 | let shouldLog = logger.shouldLog('success'); 17 | expect(shouldLog).to.equal(true); 18 | }); 19 | 20 | it('returns true for equal levels', function() { 21 | let shouldLog = logger.shouldLog('info'); 22 | expect(shouldLog).to.equal(true); 23 | }); 24 | 25 | it('returns false for lower levels', function() { 26 | let shouldLog = logger.shouldLog('verbose'); 27 | expect(shouldLog).to.equal(false); 28 | }); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /node-tests/unit/utils/open-app-command-test.js: -------------------------------------------------------------------------------- 1 | const expect = require('../../helpers/expect'); 2 | const openAppCommand = require('../../../lib/utils/open-app-command'); 3 | 4 | describe('openAppCommand util', () => { 5 | context('platform is darwin', () => { 6 | beforeEach(() => { 7 | Object.defineProperty(process, 'platform', { 8 | value: 'darwin' 9 | }); 10 | }); 11 | 12 | it('returns a valid open command', () => { 13 | let command = openAppCommand('my app'); 14 | expect(command).to.equal('open "my app"'); 15 | }); 16 | 17 | it('allows a custom opener', () => { 18 | let command = openAppCommand('my app', 'my opener'); 19 | expect(command).to.equal('open -a "my opener" "my app"'); 20 | }); 21 | }); 22 | 23 | context('platform is win32', () => { 24 | beforeEach(() => { 25 | Object.defineProperty(process, 'platform', { 26 | value: 'win32' 27 | }); 28 | }); 29 | 30 | it('returns a valid open command', () => { 31 | let command = openAppCommand('my app'); 32 | expect(command).to.equal('start "my app"'); 33 | }); 34 | 35 | it('allows a custom opener', () => { 36 | let command = openAppCommand('my app', 'my opener'); 37 | expect(command).to.equal('start "" "my opener" "my app"'); 38 | }); 39 | }); 40 | 41 | context('platform is something weird', () => { 42 | beforeEach(() => { 43 | Object.defineProperty(process, 'platform', { 44 | value: 'mysteryOS' 45 | }); 46 | }); 47 | it('returns an open command using xdg-open', () => { 48 | let command = openAppCommand('my app'); 49 | expect(command).to.equal('xdg-open "my app"'); 50 | }); 51 | }); 52 | }); 53 | 54 | -------------------------------------------------------------------------------- /node-tests/unit/utils/require-framework-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const expect = require('../../helpers/expect'); 3 | const mockProject = require('../../fixtures/corber-mock/project'); 4 | const requireFramework = require('../../../lib/utils/require-framework'); 5 | const path = require('path'); 6 | 7 | describe('requireFramework util', function() { 8 | let configPath = path.join( 9 | mockProject.project.root, 10 | 'corber/config/framework.js' 11 | ); 12 | 13 | afterEach(function() { 14 | td.reset(); 15 | }); 16 | 17 | it('requires framework config', function() { 18 | let called = false; 19 | td.replace(configPath, function() { 20 | called = true; 21 | }); 22 | 23 | requireFramework(mockProject.project); 24 | expect(called).to.equal(true); 25 | }); 26 | 27 | it('sets root path on framework', function() { 28 | let framework = requireFramework(mockProject.project); 29 | expect(framework.root).to.equal(mockProject.project.root); 30 | }); 31 | 32 | it('adds ember/glimmer config for Ember/Glimmer Frameworks', function() { 33 | let framework = requireFramework(mockProject.project); 34 | expect(framework.project).to.not.equal(undefined); 35 | }); 36 | }); 37 | 38 | -------------------------------------------------------------------------------- /node-tests/unit/utils/require-target-test.js: -------------------------------------------------------------------------------- 1 | const td = require('testdouble'); 2 | const isAnything = td.matchers.anything; 3 | const isObject = td.matchers.isA(Object); 4 | 5 | describe('requireTarget util', function() { 6 | afterEach(function() { 7 | td.reset(); 8 | }); 9 | 10 | it('parses cordova build flag', function() { 11 | let optDouble = td.replace('../../../lib/targets/cordova/utils/parse-build-flags'); 12 | let requireTarget = require('../../../lib/utils/require-target'); 13 | 14 | requireTarget({}, {}); 15 | td.verify(optDouble(isAnything(), isAnything())); 16 | }); 17 | 18 | it('initializes a CordovaTarget with required values', function() { 19 | let CordovaTarget = td.replace('../../../lib/targets/cordova/target'); 20 | let requireTarget = require('../../../lib/utils/require-target'); 21 | td.constructor(CordovaTarget); 22 | 23 | requireTarget({}, {platform: 'android'}); 24 | 25 | td.verify(new CordovaTarget({ 26 | platform: 'android', 27 | project: isObject, 28 | cordovaOpts: isObject 29 | })); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /public/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/public/.gitkeep -------------------------------------------------------------------------------- /public/cordova.js: -------------------------------------------------------------------------------- 1 | /* 2 | No-op script for when serving to both browser and Cordova device. 3 | */ 4 | -------------------------------------------------------------------------------- /vendor/ios-deploy/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "standard" 3 | } 4 | -------------------------------------------------------------------------------- /vendor/ios-deploy/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | root: true 2 | 3 | extends: semistandard 4 | 5 | rules: 6 | indent: 7 | - error 8 | - 4 9 | 10 | no-unused-vars: 11 | - error 12 | - args: after-used 13 | 14 | # excpetions specified in: 15 | # - src/scripts/.eslintrc.yml 16 | -------------------------------------------------------------------------------- /vendor/ios-deploy/.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to ios-deploy 2 | 3 | Github url: 4 | 5 | https://github.com/phonegap/ios-deploy 6 | 7 | Git clone url: 8 | 9 | https://github.com/phonegap/ios-deploy.git 10 | 11 | ## Filing an issue 12 | 13 | Please run the commands below in your Terminal.app and include it in the issue: 14 | 15 | ``` 16 | 1. sw_vers -productVersion 17 | 2. ios-deploy -V 18 | 3. xcodebuild -version 19 | 4. xcode-select --print-path 20 | 5. gcc --version 21 | 6. lldb --version 22 | 23 | ``` 24 | Also include **command line arguments** you used for ios-deploy. 25 | 26 | Don't forget to check out the [El Capitan](https://github.com/phonegap/ios-deploy/blob/master/README.md#os-x-1011-el-capitan) section of the [README](https://github.com/phonegap/ios-deploy/blob/master/README.md) before filing that issue! 27 | 28 | 29 | ## Sending a Pull Request 30 | 31 | Please **create a topic branch** for your issue before submitting your pull request. You will be asked to re-submit if your pull request contains unrelated commits. 32 | 33 | Please elaborate regarding the problem the pull request is supposed to solve, and perhaps also link to any relevant issues the pull request is trying to fix. -------------------------------------------------------------------------------- /vendor/ios-deploy/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## MUST READ BEFORE YOU FILE (DELETE THIS SECTION BEFORE FILING) 2 | 3 | Include the **command line arguments** you used for ios-deploy. 4 | 5 | Don't forget to check out the [El Capitan](https://github.com/phonegap/ios-deploy/blob/master/README.md#os-x-1011-el-capitan) section of the [README](https://github.com/phonegap/ios-deploy/blob/master/README.md) before filing this issue. 6 | 7 | # Expected behavior 8 | 9 | 10 | # Actual behavior. 11 | 12 | 13 | # Steps to reproduce the problem 14 | 15 | 16 | # System Specs 17 | 18 | Please run the commands below in your Terminal.app and include it in the issue. Check when done and include results below. 19 | 20 | - [ ] 1. system_profiler SPSoftwareDataType 21 | - [ ] 2. ios-deploy -V 22 | - [ ] 3. xcodebuild -version 23 | - [ ] 4. xcode-select --print-path 24 | - [ ] 5. gcc --version 25 | - [ ] 6. lldb --version 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /vendor/ios-deploy/.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | sudo: false 3 | install: 4 | - npm install 5 | script: 6 | - npm test 7 | notifications: 8 | slack: 9 | secure: ZJtWH/UQ+AdzakirR0gg7EL1SJg2hd+HWJPk/Gn5fibFh05P7qYdFu056fjQyVM2Kbv+39bnv+fg4lxb3OeewSDCSYgbJ7JzYFSwCb/ERwtJgoUJIDZiNzsTodJ4mCFnddgA0DEIFPhK2ntNa71VnKrVbWDJTY4+Kl+GBtmPplk= 10 | -------------------------------------------------------------------------------- /vendor/ios-deploy/LICENSE: -------------------------------------------------------------------------------- 1 | ios-deploy is available under the provisions of the GNU General Public License, 2 | version 3 (or later), available here: http://www.gnu.org/licenses/gpl-3.0.html 3 | 4 | 5 | Error codes used for error messages were taken from SDMMobileDevice framework, 6 | originally reverse engineered by Sam Marshall. SDMMobileDevice is distributed 7 | under BSD 3-Clause license and is available here: 8 | https://github.com/samdmarshall/SDMMobileDevice 9 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/Release/ios-deploy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/Release/ios-deploy -------------------------------------------------------------------------------- /vendor/ios-deploy/build/Release/ios-deploy.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.ios-deploy 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/Release/ios-deploy.dSYM/Contents/Resources/DWARF/ios-deploy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/Release/ios-deploy.dSYM/Contents/Resources/DWARF/ios-deploy -------------------------------------------------------------------------------- /vendor/ios-deploy/build/Release/libios-deploy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/Release/libios-deploy.a -------------------------------------------------------------------------------- /vendor/ios-deploy/build/Release/libios_deploy.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface ios_deploy_lib : NSObject 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/XCBuildData/BuildDescriptionCacheIndex-69454fa4acb89502bb364ba3e077fe33: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/XCBuildData/BuildDescriptionCacheIndex-69454fa4acb89502bb364ba3e077fe33 -------------------------------------------------------------------------------- /vendor/ios-deploy/build/XCBuildData/build.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/XCBuildData/build.db -------------------------------------------------------------------------------- /vendor/ios-deploy/build/XCBuildData/d3028f7fea2dcd023fb3d06de5f9b0d6-desc.xcbuild: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/XCBuildData/d3028f7fea2dcd023fb3d06de5f9b0d6-desc.xcbuild -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/Objects-normal/x86_64/ios-deploy.LinkFileList: -------------------------------------------------------------------------------- 1 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/Objects-normal/x86_64/libios_deploy.o 2 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/Objects-normal/x86_64/libios_deploy.d: -------------------------------------------------------------------------------- 1 | dependencies: \ 2 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy-lib/libios_deploy.m \ 3 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy-lib/libios_deploy.h 4 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/Objects-normal/x86_64/libios_deploy.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/Objects-normal/x86_64/libios_deploy.dia -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/Objects-normal/x86_64/libios_deploy.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/Objects-normal/x86_64/libios_deploy.o -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/all-product-headers.yaml: -------------------------------------------------------------------------------- 1 | { 2 | 'version': 0, 3 | 'case-sensitive': 'false', 4 | 'roots': [ 5 | { 6 | 'type': 'directory', 7 | 'name': "/Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/build/Release", 8 | 'contents': [ 9 | { 10 | 'type': 'file', 11 | 'name': "libios_deploy.h", 12 | 'external-contents': "/Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy-lib/libios_deploy.h" 13 | } 14 | ] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/ios-deploy-all-non-framework-target-headers.hmap: -------------------------------------------------------------------------------- 1 | pamhxkios-deploy/libios_deploy.h/Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy-lib/libios_deploy.h -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/ios-deploy-all-target-headers.hmap: -------------------------------------------------------------------------------- 1 | pamhxkios-deploy/libios_deploy.h/Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy-lib/libios_deploy.h -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/ios-deploy-generated-files.hmap: -------------------------------------------------------------------------------- 1 | pamhx -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/ios-deploy-own-target-headers.hmap: -------------------------------------------------------------------------------- 1 | pamhxlibios_deploy.hios-deploy/ -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/ios-deploy-project-headers.hmap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/ios-deploy-project-headers.hmap -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy-lib.build/ios-deploy.hmap: -------------------------------------------------------------------------------- 1 | pamhx -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Objects-normal/x86_64/ios-deploy.LinkFileList: -------------------------------------------------------------------------------- 1 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Objects-normal/x86_64/ios-deploy.o 2 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Objects-normal/x86_64/ios-deploy.d: -------------------------------------------------------------------------------- 1 | dependencies: \ 2 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy/ios-deploy.m \ 3 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy/MobileDevice.h \ 4 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy/errors.h \ 5 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy/device_db.h \ 6 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy/lldb.py.h \ 7 | /Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy/version.h 8 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Objects-normal/x86_64/ios-deploy.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Objects-normal/x86_64/ios-deploy.dia -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Objects-normal/x86_64/ios-deploy.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Objects-normal/x86_64/ios-deploy.o -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Script-7EDCC3CF1C45E03B002F9851.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "\"# AUTO-GENERATED - DO NOT MODIFY\"" > src/ios-deploy/lldb.py.h 3 | awk '{ print "\""$0"\\n\""}' src/scripts/lldb.py >> src/ios-deploy/lldb.py.h 4 | 5 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Script-C0CD3D981F59D20100F954DB.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p "${PROJECT_DIR}/_Frameworks" 3 | rsync -r /System/Library/PrivateFrameworks/MobileDevice.framework "${PROJECT_DIR}/_Frameworks" --exclude=XPCServices --links 4 | 5 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/Script-C0CD3D9B1F59DA8300F954DB.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf "${PROJECT_DIR}/_Frameworks" 3 | 4 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/all-product-headers.yaml: -------------------------------------------------------------------------------- 1 | { 2 | 'version': 0, 3 | 'case-sensitive': 'false', 4 | 'roots': [ 5 | { 6 | 'type': 'directory', 7 | 'name': "/Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/build/Release", 8 | 'contents': [ 9 | { 10 | 'type': 'file', 11 | 'name': "libios_deploy.h", 12 | 'external-contents': "/Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy-lib/libios_deploy.h" 13 | } 14 | ] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/ios-deploy-all-non-framework-target-headers.hmap: -------------------------------------------------------------------------------- 1 | pamhxkios-deploy/libios_deploy.h/Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy-lib/libios_deploy.h -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/ios-deploy-all-target-headers.hmap: -------------------------------------------------------------------------------- 1 | pamhxkios-deploy/libios_deploy.h/Users/alexblom/Desktop/dev/corber/node_modules/ios-deploy/src/ios-deploy-lib/libios_deploy.h -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/ios-deploy-generated-files.hmap: -------------------------------------------------------------------------------- 1 | pamhx -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/ios-deploy-own-target-headers.hmap: -------------------------------------------------------------------------------- 1 | pamhx -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/ios-deploy-project-headers.hmap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/ios-deploy-project-headers.hmap -------------------------------------------------------------------------------- /vendor/ios-deploy/build/ios-deploy.build/Release/ios-deploy.build/ios-deploy.hmap: -------------------------------------------------------------------------------- 1 | pamhx -------------------------------------------------------------------------------- /vendor/ios-deploy/demo/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | get-task-allow 6 | 7 | 8 | -------------------------------------------------------------------------------- /vendor/ios-deploy/demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleName 6 | demo 7 | CFBundleSupportedPlatforms 8 | 9 | iPhoneOS 10 | 11 | CFBundleExecutable 12 | demo 13 | CFBundleVersion 14 | 1.0 15 | CFBundleIdentifier 16 | demo 17 | CFBundleResourceSpecification 18 | ResourceRules.plist 19 | LSRequiresIPhoneOS 20 | 21 | CFBundleDisplayName 22 | demo 23 | 24 | -------------------------------------------------------------------------------- /vendor/ios-deploy/demo/Makefile: -------------------------------------------------------------------------------- 1 | IOS_SDK_VERSION = 9.1 2 | 3 | IOS_CC = gcc -ObjC 4 | IOS_SDK = $(shell xcode-select --print-path)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(IOS_SDK_VERSION).sdk 5 | 6 | all: clean demo.app 7 | 8 | demo.app: demo Info.plist 9 | mkdir -p demo.app 10 | cp demo demo.app/ 11 | cp Info.plist ResourceRules.plist demo.app/ 12 | codesign -f -s "iPhone Developer" --entitlements Entitlements.plist demo.app 13 | 14 | demo: demo.c 15 | $(IOS_CC) -g -arch armv7 -isysroot $(IOS_SDK) -framework CoreFoundation -o demo demo.c 16 | 17 | debug: all ios-deploy 18 | @../build/Release/ios-deploy --debug --bundle demo.app 19 | 20 | clean: 21 | @rm -rf *.app demo demo.dSYM 22 | 23 | ios-deploy: 24 | @xcodebuild -project ../ios-deploy.xcodeproj 25 | -------------------------------------------------------------------------------- /vendor/ios-deploy/demo/ResourceRules.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | rules 6 | 7 | .* 8 | 9 | Info.plist 10 | 11 | omit 12 | 13 | weight 14 | 10 15 | 16 | ResourceRules.plist 17 | 18 | omit 19 | 20 | weight 21 | 100 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /vendor/ios-deploy/demo/demo.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, const char* argv[]) { 4 | int i; 5 | for (i = 0; i < argc; i++) { 6 | printf("argv[%d] = %s\n", i, argv[i]); 7 | } 8 | return 0; 9 | } -------------------------------------------------------------------------------- /vendor/ios-deploy/ios-deploy.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /vendor/ios-deploy/ios-deploy.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /vendor/ios-deploy/ios-deploy.xcodeproj/project.xcworkspace/xcuserdata/shazron.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isleofcode/corber/5202457dae6c2cb8d14aa11e0cafb4df28d7d2ec/vendor/ios-deploy/ios-deploy.xcodeproj/project.xcworkspace/xcuserdata/shazron.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /vendor/ios-deploy/ios-deploy.xcodeproj/xcshareddata/xcschemes/ios-deploy-tests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 14 | 15 | 17 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 39 | 40 | 41 | 42 | 48 | 49 | 51 | 52 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /vendor/ios-deploy/ios-deploy.xcodeproj/xcuserdata/shazron.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ios-deploy-lib.xcscheme 8 | 9 | orderHint 10 | 2 11 | 12 | ios-deploy-tests.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | ios-deploy.xcscheme 18 | 19 | orderHint 20 | 1 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /vendor/ios-deploy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ios-deploy", 3 | "version": "1.9.4", 4 | "os": [ 5 | "darwin" 6 | ], 7 | "description": "launch iOS apps iOS devices from the command line (Xcode 7)", 8 | "main": "ios-deploy", 9 | "bin": "./build/Release/ios-deploy", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/ios-control/ios-deploy" 13 | }, 14 | "devDependencies": { 15 | "eslint": "~4.19.1", 16 | "eslint-config-semistandard": "^12.0.1", 17 | "eslint-config-standard": "^11.0.0", 18 | "eslint-plugin-import": "^2.12.0", 19 | "eslint-plugin-node": "^6.0.1", 20 | "eslint-plugin-promise": "^3.8.0", 21 | "eslint-plugin-standard": "^3.1.0" 22 | }, 23 | "scripts": { 24 | "preinstall": "./src/scripts/check_reqs.js && xcodebuild", 25 | "build-test": "npm run pycompile && xcodebuild -target ios-deploy-lib && xcodebuild test -scheme ios-deploy-tests", 26 | "eslint": "eslint src/scripts/*.js", 27 | "test": "npm run eslint && npm run build-test", 28 | "pycompile": "python -m py_compile src/scripts/*.py" 29 | }, 30 | "keywords": [ 31 | "ios-deploy", 32 | "deploy to iOS device" 33 | ], 34 | "bugs": { 35 | "url": "https://github.com/phonegap/ios-deploy/issues" 36 | }, 37 | "author": "Greg Hughes", 38 | "license": "GPLv3" 39 | } 40 | -------------------------------------------------------------------------------- /vendor/ios-deploy/src/ios-deploy-lib/libios_deploy.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface ios_deploy_lib : NSObject 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /vendor/ios-deploy/src/ios-deploy-lib/libios_deploy.m: -------------------------------------------------------------------------------- 1 | #import "libios_deploy.h" 2 | 3 | @implementation ios_deploy_lib 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /vendor/ios-deploy/src/ios-deploy-tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /vendor/ios-deploy/src/ios-deploy-tests/ios_deploy_tests.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface ios_deploy_tests : XCTestCase 4 | 5 | @end 6 | 7 | @implementation ios_deploy_tests 8 | 9 | - (void)setUp { 10 | [super setUp]; 11 | // Put setup code here. This method is called before the invocation of each test method in the class. 12 | } 13 | 14 | - (void)tearDown { 15 | // Put teardown code here. This method is called after the invocation of each test method in the class. 16 | [super tearDown]; 17 | } 18 | 19 | - (void)testExample { 20 | // This is an example of a functional test case. 21 | // Use XCTAssert and related functions to verify your tests produce the correct results. 22 | } 23 | 24 | - (void)testPerformanceExample { 25 | // This is an example of a performance test case. 26 | [self measureBlock:^{ 27 | // Put the code you want to measure the time of here. 28 | }]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /vendor/ios-deploy/src/ios-deploy/version.h: -------------------------------------------------------------------------------- 1 | "1.9.4" 2 | -------------------------------------------------------------------------------- /vendor/ios-deploy/src/scripts/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | rules: 2 | # common src exception: 3 | camelcase: off 4 | 5 | # FUTURE TBD: 6 | no-unused-vars: 7 | - error 8 | - args: none 9 | 10 | # TBD easy fix: 11 | padded-blocks: off 12 | 13 | # FUTURE TBD: 14 | handle-callback-err: off 15 | indent: off 16 | no-multiple-empty-lines: off 17 | no-tabs: off 18 | one-var: off 19 | -------------------------------------------------------------------------------- /vendor/ios-deploy/src/scripts/check_reqs.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var util = require('util'); 4 | var os = require('os'); 5 | var child_process = require('child_process'); 6 | 7 | var XCODEBUILD_MIN_VERSION = 7.0; 8 | var XCODEBUILD_NOT_FOUND_MESSAGE = util.format('Please install Xcode version %s or greater from the Mac App Store.', XCODEBUILD_MIN_VERSION); 9 | var TOOL = 'xcodebuild'; 10 | 11 | var xcode_version = child_process.spawn(TOOL, ['-version']), 12 | version_string = ''; 13 | 14 | xcode_version.stdout.on('data', function (data) { 15 | version_string += data; 16 | }); 17 | 18 | xcode_version.stderr.on('data', function (data) { 19 | console.log('stderr: ' + data); 20 | }); 21 | 22 | xcode_version.on('error', function (err) { 23 | console.log(util.format('Tool %s was not found. %s', TOOL, XCODEBUILD_NOT_FOUND_MESSAGE)); 24 | }); 25 | 26 | xcode_version.on('close', function (code) { 27 | if (code === 0) { 28 | var arr = version_string.match(/^Xcode (\d+\.\d+)/); 29 | var ver = arr[1]; 30 | 31 | if (os.release() >= '15.0.0' && ver < XCODEBUILD_MIN_VERSION) { 32 | console.log(util.format('You need at least Xcode 7.0 when you are on OS X 10.11 El Capitan (you have version %s)', ver)); 33 | process.exit(1); 34 | } 35 | 36 | if (ver < XCODEBUILD_MIN_VERSION) { 37 | console.log(util.format('%s : %s. (you have version %s)', TOOL, XCODEBUILD_NOT_FOUND_MESSAGE, ver)); 38 | } 39 | 40 | if (os.release() >= '15.0.0') { // print the El Capitan warning 41 | console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 42 | console.log('!!!! WARNING: You are on OS X 10.11 El Capitan or greater, you may need to add the'); 43 | console.log('!!!! WARNING: `--unsafe-perm=true` flag when running `npm install`'); 44 | console.log('!!!! WARNING: or else it will fail.'); 45 | console.log('!!!! WARNING: link:'); 46 | console.log('!!!! WARNING: https://github.com/phonegap/ios-deploy#os-x-1011-el-capitan-or-greater'); 47 | console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 48 | } 49 | 50 | } 51 | process.exit(code); 52 | }); 53 | 54 | 55 | 56 | 57 | --------------------------------------------------------------------------------