cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-8197) Switch to nodejs for ios platform scripts
Date Thu, 22 Jan 2015 13:04:36 GMT

    [ https://issues.apache.org/jira/browse/CB-8197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14287383#comment-14287383
] 

ASF GitHub Bot commented on CB-8197:
------------------------------------

Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-ios/pull/126#discussion_r23373440
  
    --- Diff: bin/templates/scripts/cordova/lib/run.js ---
    @@ -0,0 +1,184 @@
    +/*
    +       Licensed to the Apache Software Foundation (ASF) under one
    +       or more contributor license agreements.  See the NOTICE file
    +       distributed with this work for additional information
    +       regarding copyright ownership.  The ASF licenses this file
    +       to you under the Apache License, Version 2.0 (the
    +       "License"); you may not use this file except in compliance
    +       with the License.  You may obtain a copy of the License at
    +
    +         http://www.apache.org/licenses/LICENSE-2.0
    +
    +       Unless required by applicable law or agreed to in writing,
    +       software distributed under the License is distributed on an
    +       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +       KIND, either express or implied.  See the License for the
    +       specific language governing permissions and limitations
    +       under the License.
    +*/
    +
    +/*jshint node: true*/
    +
    +var Q = require('q'),
    +    nopt  = require('nopt'),
    +    path  = require('path'),
    +    shell = require('shelljs'),
    +    build = require('./build'),
    +    spawn = require('./spawn'),
    +    check_reqs = require('./check_reqs');
    +
    +var cordovaPath = path.join(__dirname, '..');
    +var projectPath = path.join(__dirname, '..', '..');
    +
    +module.exports.run = function (argv) {
    +
    +    // parse args here
    +    // --debug and --release args not parsed here
    +    // but still valid since they can be passed down to build command 
    +    var args  = nopt({
    +        // "archs": String,     // TODO: add support for building different archs
    +        "list": Boolean,
    +        "nobuild": Boolean,
    +        "device": Boolean, "emulator": Boolean, "target": String
    +    }, {}, argv);
    +
    +    // Validate args
    +    if (args.device && args.emulator) {
    +        return Q.reject('Only one of "device"/"emulator" options should be specified');
    +    }
    +
    +    // validate target device for ios-sim
    +    // Valid values for "--target" (case sensitive):
    +    var validTargets = ["iPhone-4s", "iPhone-5", "iPhone-5s", "iPhone-6-Plus", "iPhone-6",
    +        "iPad-2", "iPad-Retina", "iPad-Air", "Resizable-iPhone", "Resizable-iPad"];
    +    if (args.target && validTargets.indexOf(args.target) < 0 ) {
    +        return Q.reject(args.target + " is not a valid target for emulator");
    +    }
    +
    +    // check for either ios-sim or ios-deploy is available
    +    // depending on arguments provided
    +    var checkTools = args.device ? check_reqs.check_ios_deploy() : check_reqs.check_ios_sim();
    +
    +    // support for CB-8168 `cordova/run --list`
    +    if (args.list) {
    +        if (args.device) return listDevices();
    +        if (args.emulator) return listEmulators();
    +        return listDevices().then(function () {
    +            return listEmulators();
    +        });
    +    }
    +
    +    return checkTools.then(function () {
    +        if (args.nobuild) {
    +            // --nobuild option is passed. Skipping build...
    +            return Q();
    +        }
    +        // if --nobuild isn't specified then build app first
    +        return build.run(argv);
    +    }).then(function () {
    +
    +        var xcodeProjFiles = shell.ls(projectPath).filter(function (name) {
    +            return path.extname(name) === '.xcodeproj';
    +        });
    +        
    +        if (xcodeProjFiles.length === 0) {
    +            return Q.reject("No Xcode project found in " + projectPath);
    +        }
    +        if (xcodeProjFiles.length > 1) {
    +            console.warn('Found multiple .xcodeproj directories in \n' +
    +                projectPath + '\nUsing first one');
    +        }
    +
    +        var projectName = path.basename(xcodeProjFiles[0], '.xcodeproj');
    +
    +        var appPath = path.join(projectPath, 'build', (args.device ? 'device' : 'emulator'),
projectName + '.app');
    +        // select command to run and arguments depending whether
    +        // we're running on device/emulator
    +        if (args.device) {
    +            return checkDeviceConnected().then(function () {
    +                return deployToDevice(appPath);
    +            }).fail(function () {
    --- End diff --
    
    Well, i just ported an original flow. Take a look:
    ```bash
        DEVICE_CONNECTED=$(ios-deploy -c)
        if [ $? != 0 ]; then
        	echo "No device is connected, trying Simulator." 1>&2;
            USE_SIMULATOR=true
        else
            # if we got here, we can deploy the app, then exit success
            if ! [ "$NO_BUILD" = true ]; then
                "$CORDOVA_PATH/build" --device || exit $?
            fi
            ios-deploy -d -b "$DEVICE_APP_PATH"
        	exit 0
        fi
    ```
    
    But your point makes sense. Updated in https://github.com/MSOpenTech/cordova-ios/commit/079fcf3c32aa8fce98ad68ee062aaff00cb0dab3


> Switch to nodejs for ios platform scripts
> -----------------------------------------
>
>                 Key: CB-8197
>                 URL: https://issues.apache.org/jira/browse/CB-8197
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: iOS
>            Reporter: Vladimir Kotikov
>
> Currently platform tooling for ios is based on bash scripts and to improve maintainability
of such scripts it would be useful to port them to NodeJS.
> Part of this work is already done for create/update scripts in https://issues.apache.org/jira/browse/CB-5706
but platform scripts placed in cordova folder of platform is still being unported.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message