Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHMHCP-CLI #3,#5] - init command and hooks #9

Closed
wants to merge 8 commits into from

Conversation

evanshortiss
Copy link
Member

@evanshortiss evanshortiss commented Jul 31, 2017

This is the start for #3 and #5 features. Here's what it looks like in usage:

rhcp

Asks user what cordova binary we should use, installs hcp plugin, updates config.xml, adds before hook - done.

@@ -0,0 +1,10 @@
# Tells the .editorconfg plugin to stop searching once it finds this file
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep code indents standard.

@@ -0,0 +1,43 @@
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some simple eslint rules - no need to be strict yet, but should try follow some guide.


Copyright (c) 2010-2017 Google, Inc. http://angularjs.org
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we want to remove this? 😂

* @return {Promise<Object>}
*/
exports.generateConfig = function (args) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main new addition here. It will generate a new config. Should probably add some assert calls?

* @return {String}
*/
exports.getCordovaLocation = function () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to have these so we can change cordova.location etc without needing to change these calls elsewhere

@@ -1,7 +1,7 @@
exports.get = get;
exports.set = set;
var def = {
"configFile": "rhmhcp.json"
"RHM_HCP_CFG": "rhmhcp.json"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be an env-var? Changed to match env var casing standards just in case

.then(() => log.progress('project initialisation complete!'));
}

if (isRhmcpReady()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick check to ask user if they want to override existing rhmcp.json

* @param {Object} args
*/
function verifyArgs (args) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe support more args from the plugin, such as autoupdate?

'use strict';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to clean logging approaches up.

{
type: 'list',
name: 'cordova.location',
message: 'Where is the Cordova executable located? Local is recommended to avoid versioning issues.',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows user to choose cordova installed in node_modules, global, or custom binary location.

* Add any required hooks to the project. For now the hook simply ensures the rhmcp.json file is copied into www/
* @return {Promise<undefined>}
*/
function addHooks () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add more hooks here if necessary later.

const mkdirSync = require('mkdirp').sync;
const fs = require('fs');
const join = require('path').join;
const et = require('elementtree');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used to update config.xml. Seems like cordova-cli uses this too

* We might need to resolve strings such as "local" or "global" to an actual path
* @return {String}
*/
function resolveCordovaLocation () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses the setting chosen by the user on init to determine which cordova binary to use.

@@ -1,24 +1,30 @@
{
"name": "rhmhcp-cli",
"version": "1.0.0",
"description": "RedHat Mobile Hot Code Push Command Line",
"version": "0.1.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 0.1.0 is best for "unstable"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant