csantanapr / grunt-cordovacli

Wraps web app with Cordova CLI using GruntJS
Apache License 2.0
60 stars 31 forks source link

Feature request: add_plugins with variable #7

Closed florentvaldelievre closed 10 years ago

florentvaldelievre commented 10 years ago

Hello,

With cordovacli, it is possible to add plugins with variable like:

cordova plugins add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=hibe

It would be nice to be able to do the following:

  add_plugins: {
      options: {
          command: 'plugin',
          action: 'add',
          plugins: [
               'https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=tel',
          ]
      }
    }

At the moment it is failing with the following error:

Running:node C:\dev\apps\turkey\hibe-webapp\web-app\node_modules\cordova\bin\cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.gi t --variable URL_SCHEME=hibe Fetching plugin "https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=hibe" via git clone Error: Command failed: Cloning into 'C:\Users\valdelif\AppData\Local\Temp\plugman\git\1409081179796'... fatal: unable to access 'https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=tel/': The requested URL returned error: 400

at ChildProcess.exithandler (child_process.js:637:15)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)

Error Error-> with Series tasksError Warning: Task "cordovacli:add_plugins" failed. Use --force to continue.

As a workaround I am using the 'args' options like this:

  add_plugins: {
      options: {
          command: 'plugin',
          action: 'add',
          plugins: [
               'https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git',
          ],
          args: '--variable URL_SCHEME=tel'
      }
  },

However, it will add all the plugins with the args which is not the expected behavior. Let me know the feasability

Many thanks

csantanapr commented 10 years ago

@florentvaldelievre you can create as many tasks as you want for adding plugins you don't have to use only one.

add_plugins: {
      options: {
          command: 'plugin',
          action: 'add',
          plugins: [
               'device','camera'
          ]
      }
  },
 add_plugins_vars: {
      options: {
          command: 'plugin',
          action: 'add',
          plugins: [
               'https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git',
          ],
          args: '--variable URL_SCHEME=tel'
      }
  },
grunt.registerTask('add_all_plugins', ['cordovacli:add_plugins','cordovacli:add_plugins_vars']);
AlexanderSchmidt commented 9 years ago

Are you sure the "args" option is working properly?

I am getting "Variable is missing" and plugin is not added even though the command line looks good:

Running "cordovacli:add_intent" (cordovacli) task
Using cordova CLI version (4.1.2)
Setting Current Working Directory (CWD) to cordova
Running:node C:\Users\Alexander Schmidt\Projects\rsion\node_modules\cordova\bin\cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin .git --variable URL_SCHEME=rsmobile
Fetching plugin "https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git" via git clone
Variable(s) missing (use: --variable URL_SCHEME=value).
Done-> cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=rsmobile
Success-> with Series tasks

Done, without errors.

My grunt task looks exactly the same as the one above. Any idea?

michelhabib commented 9 years ago

same here as @AlexanderSchmidt :(

dream commented 9 years ago

This worked for me:

options: {
    command: 'plugin',
    action: 'add',
    args: ["--variable", " URL_SCHEME=abc123"],
    plugins: ["https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git"]
}
AlexanderSchmidt commented 9 years ago

"args" as Array works! Thanks for the hint! This will make my live much easier in future :+1: