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

[major][feat] electrode-ignite modules #548

Merged
merged 59 commits into from
Sep 26, 2017
Merged

Conversation

didi0613
Copy link
Contributor

@didi0613 didi0613 commented Aug 16, 2017

A bootstrap tool for installing, updating, and assiting development with OSS Electrode platform.
screen shot 2017-08-23 at 9 08 52 am

PR is along with the gitbook: #552

#!/usr/bin/env node

const Path = require("path");
require(Path.join(__dirname, "../cli/ignite"))();
Copy link
Member

Choose a reason for hiding this comment

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

no __dirname necessary. Just require("../cli/ignite") works.

.then(function(latestVersion) {
var latestVersion = latestVersion.stdout.slice(0, -1);

if (latestVersion > pkg.version) {
Copy link
Member

Choose a reason for hiding this comment

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

can't compare semver like strings

if (latestVersion > pkg.version) {
/* Case 1: electrode-ignite version outdated */
logger.log(
chalk.yellow(`Latest version is ${latestVersion} - trying to update.`)
Copy link
Member

Choose a reason for hiding this comment

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

show current version and latest version

logger.log(
chalk.yellow(`Latest version is ${latestVersion} - trying to update.`)
);
xsh
Copy link
Member

Choose a reason for hiding this comment

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

dangling promise here. intended?

} else {
/* Case 3: Invalid electrode-ignite version */
errorHandler(
"Failed at: Invalid electrode-ignite version. Please verify your package.json."
Copy link
Member

Choose a reason for hiding this comment

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

this message is misleading. If there's issue with electrode-ignite version, it's our problem, has nothing to do with user's package.json and nothing they can verify.

First use proper semver comparison to check if version is newer, and then consider what error could occur and handle accordingly.

} else {
errorHandler("Please provide a valid task name.");
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Please use https://www.npmjs.com/package/yargs and provide proper command line options and usage helps.

@@ -0,0 +1,42 @@
"use strict";
Copy link
Member

Choose a reason for hiding this comment

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

isn't this file also in electrode-ignite?

};

const Installation = function() {
checkXClapCLI().then(function(version) {
Copy link
Member

Choose a reason for hiding this comment

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

return promise

console.log(
`Electrode Ignite is about to install the following modules globally:\n- xclap-cli\n`
);
installXClapCLI();
Copy link
Member

Choose a reason for hiding this comment

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

return promise

);
installXClapCLI();
} else {
checkXClapCLILatestVersion().then(function(latestversion) {
Copy link
Member

Choose a reason for hiding this comment

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

return promise

@jchip
Copy link
Member

jchip commented Aug 16, 2017

Many promises are not returned and left dangling. Please address comments and make sure all promises are chained properly.

@jchip
Copy link
Member

jchip commented Aug 16, 2017

Please use electrode-archetype-njs-module-dev and setup test and eslint properly.

#!/usr/bin/env node

const Path = require("path");
require(Path.join("../cli/ignite"))();
Copy link
Member

Choose a reason for hiding this comment

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

what's the Path.join for?

return taskLoader("1", type, igniteCore);
} else if (task === "check-nodejs") {
return taskLoader("2", type, igniteCore);
} else if (task === "generate-app") {
Copy link
Member

Choose a reason for hiding this comment

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

should find a way to avoid a long chain of if/else constructs that's all similar.

}
}
ret += chalk.blueBright("Electrode Ignite Menu");
for (let i = 0; i < STARNUM; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

this block of code looks exactly like it's above line 23-29

`[7] \u261E Exit`
];

console.log(chalk.blueBright(dashedLines)); // eslint-disable-line no-console
Copy link
Member

Choose a reason for hiding this comment

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

I'd just /* eslint-disable no-console */ at top of the file.

option = answer;

// Invalid Electrode Option will re-trigger the menu
while (option < 1 || option > options.length || isNaN(option)) {
Copy link
Member

Choose a reason for hiding this comment

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

what's the while for?

let yoPath = "";
let child = "";

if(process.platform.startsWith("win")) {
Copy link
Member

Choose a reason for hiding this comment

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

process.platform === "win32"

return xsh
.exec(true, "npm ls -g -j --depth=0 xclap-cli")
.then(function(ret) {
resolve(JSON.parse(ret.stdout).dependencies["xclap-cli"].version);
Copy link
Member

Choose a reason for hiding this comment

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

xsh.exec returns a promise. You don't need to create another promise like this.

return xsh
.exec(true, "npm show xclap-cli version")
.then(function(version) {
resolve(version.stdout.slice(0, -1));
Copy link
Member

Choose a reason for hiding this comment

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

xsh.exec returns a promise. You don't need to create another promise like this.

return igniteCore(type);
}
return ;
} else if (semverComp(version, latestversion) < 0) {
Copy link
Member

Choose a reason for hiding this comment

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

you are calling semverComp repetitively for the same input.

return igniteOutdated(latestVersion);

/* Case 2: electrode-ignite latest version */
} else if (semverComp(latestVersion, pkg.version) === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

you are calling semverComp repetitively for the same input.

@jchip jchip merged commit 73cad61 into electrode-io:master Sep 26, 2017
@didi0613 didi0613 deleted the ignite branch April 9, 2018 16:38
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.

2 participants