Skip to content

Commit

Permalink
[chore] prettierify
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Oct 3, 2017
1 parent 5d7ff30 commit 2c95da3
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 312 deletions.
2 changes: 1 addition & 1 deletion packages/ignite-core/ignite.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ function igniteCore(type, task) {
`Please use "ignite --help" to check all the available tasks.`
);
}
};
}

module.exports = igniteCore;
4 changes: 1 addition & 3 deletions packages/ignite-core/lib/back-to-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const ARGV = 2;

function backToMenu(type, igniteCore, showHint) {
if (showHint) {
logger.log(
chalk.green("Return to the main menu. Please choose your next task:")
);
logger.log(chalk.green("Return to the main menu. Please choose your next task:"));
}

if (type && igniteCore) {
Expand Down
3 changes: 1 addition & 2 deletions packages/ignite-core/lib/check-timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ const fs = require("fs");
const Path = require("path");
const errorHandler = require("../lib/error-handler");

const fileName =
process.platform === "win32" ? "timestamp-wml.txt" : "timestamp-oss.txt";
const fileName = process.platform === "win32" ? "timestamp-wml.txt" : "timestamp-oss.txt";
const timeStampPath = Path.resolve(__dirname, "..", fileName);

function setTimeStamp(obj) {
Expand Down
8 changes: 2 additions & 6 deletions packages/ignite-core/lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const pad2 = x => {

const timestamp = () => {
const d = new Date();
const ts = `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(
d.getSeconds()
)}`;
const ts = `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`;
return ts;
};

Expand All @@ -42,9 +40,7 @@ module.exports = {
return;
}
process.stdout.write(
`${chalk.magenta("[")}${chalk.gray(timestamp())}${chalk.magenta(
"]"
)} ${msg}\n`
`${chalk.magenta("[")}${chalk.gray(timestamp())}${chalk.magenta("]")} ${msg}\n`
);
}
};
9 changes: 2 additions & 7 deletions packages/ignite-core/lib/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ function createMenu(options) {
function igniteMenu(type, igniteCore, rl) {
let option;

const igniteName =
type === "oss" ? "Electrode Ignite" : "WML Electrode Ignite";
const igniteName = type === "oss" ? "Electrode Ignite" : "WML Electrode Ignite";

const options = [
`[1] \u2668 Install tools for Electrode development`,
Expand All @@ -73,11 +72,7 @@ function igniteMenu(type, igniteCore, rl) {
if (!isNaN(option) && option >= 1 && option <= options.length) {
taskLoader(option, type, igniteCore, true);
} else {
logger.log(
chalk.red(
`Please provide a valid option between 1 to ${options.length}.`
)
);
logger.log(chalk.red(`Please provide a valid option between 1 to ${options.length}.`));
igniteCore(type);
}
});
Expand Down
10 changes: 3 additions & 7 deletions packages/ignite-core/lib/task-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const CLISpinner = require("cli-spinner").Spinner;
const spinner = new CLISpinner(chalk.green("%s"));
spinner.setSpinnerString("|/-\\");

function taskLoader(option, type, igniteCore, showHint) { // eslint-disable-line
function taskLoader(option, type, igniteCore, showHint) {
// eslint-disable-line
const igniteName = type === "oss" ? "electrode-ignite" : "@walmart/electrode-ignite";

switch (option) {
Expand Down Expand Up @@ -41,12 +42,7 @@ function taskLoader(option, type, igniteCore, showHint) { // eslint-disable-line
// eslint-disable-next-line no-unused-expressions
type === "oss"
? generator(type, "electrode:component-add", igniteCore, spinner)
: generator(
type,
"@walmart/electrode:component-add",
igniteCore,
spinner
);
: generator(type, "@walmart/electrode:component-add", igniteCore, spinner);
break;
case "6":
docs(type, igniteCore, showHint);
Expand Down
25 changes: 5 additions & 20 deletions packages/ignite-core/lib/yargs-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,15 @@ const Yargs = require("yargs");

/* eslint-disable no-unused-expressions */
const yargsHelp = function() {
Yargs.command(
chalk.cyan("install"),
chalk.cyan("Install tools for Electrode development")
)
.command(
chalk.cyan("check-nodejs"),
chalk.cyan("Check your NodeJS and npm environment")
)
.command(
chalk.cyan("generate-app"),
chalk.cyan("Generate an Electrode application")
)
.command(
chalk.cyan("generate-component"),
chalk.cyan("Generate an Electrode component")
)
Yargs.command(chalk.cyan("install"), chalk.cyan("Install tools for Electrode development"))
.command(chalk.cyan("check-nodejs"), chalk.cyan("Check your NodeJS and npm environment"))
.command(chalk.cyan("generate-app"), chalk.cyan("Generate an Electrode application"))
.command(chalk.cyan("generate-component"), chalk.cyan("Generate an Electrode component"))
.command(
chalk.cyan("add-component"),
chalk.cyan("Add a component to your existing component repo")
)
.command(
chalk.cyan("check-ignite"),
chalk.cyan("Check for electrode-ignite update")
)
.command(chalk.cyan("check-ignite"), chalk.cyan("Check for electrode-ignite update"))
.command(chalk.cyan("docs"), chalk.cyan("Electrode official documenations"))
.help().argv;
};
Expand Down
65 changes: 9 additions & 56 deletions packages/ignite-core/tasks/check-ignite.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ spinner.setSpinnerString("|/-\\");

function igniteUpToDate(type, task, version, igniteCore, igniteName) {
logger.log(
chalk.cyan(
`Congratulations! You've aleady installed the latest ${igniteName}@${version}.`
)
chalk.cyan(`Congratulations! You've aleady installed the latest ${igniteName}@${version}.`)
);
setTimeStamp({
time: new Date().toDateString(),
Expand Down Expand Up @@ -62,18 +60,8 @@ function installLatestIgnite(igniteName, latestVersion) {
);
}

function cancelLatestIgnite(
version,
latestVersion,
type,
igniteCore,
showHint
) {
logger.log(
chalk.cyan(
`You've cancelled the electrode-ignite@${latestVersion} installation.`
)
);
function cancelLatestIgnite(version, latestVersion, type, igniteCore, showHint) {
logger.log(chalk.cyan(`You've cancelled the electrode-ignite@${latestVersion} installation.`));
setTimeStamp({
time: new Date().toDateString(),
latestVersion: latestVersion
Expand Down Expand Up @@ -103,26 +91,10 @@ function invalidProceedOption(
});
rl.close();

return igniteOutdated(
type,
task,
latestVersion,
version,
igniteCore,
igniteName,
showHint
);
return igniteOutdated(type, task, latestVersion, version, igniteCore, igniteName, showHint);
}

function igniteOutdated(
type,
task,
latestVersion,
version,
igniteCore,
igniteName,
showHint
) {
function igniteOutdated(type, task, latestVersion, version, igniteCore, igniteName, showHint) {
logger.log(
chalk.cyan(
`${igniteName} is about to update the following modules globally:\n- electrode-ignite (from version ${version} to version ${latestVersion})`
Expand All @@ -139,13 +111,7 @@ function igniteOutdated(
if (answer.toLowerCase() === "y") {
return installLatestIgnite(igniteName, latestVersion);
} else if (answer.toLowerCase() === "n") {
return cancelLatestIgnite(
version,
latestVersion,
type,
igniteCore,
showHint
);
return cancelLatestIgnite(version, latestVersion, type, igniteCore, showHint);
} else {
return invalidProceedOption(
type,
Expand Down Expand Up @@ -195,13 +161,7 @@ function checkIgniteVersion(type, igniteName, version, igniteCore, showHint) {

/* Case 2: electrode-ignite latest version */
} else if (versionComp === 0) {
igniteUpToDate(
type,
process.argv[2],
latestVersion,
igniteCore,
igniteName
);
igniteUpToDate(type, process.argv[2], latestVersion, igniteCore, igniteName);
spinner.stop();
return;

Expand All @@ -216,8 +176,7 @@ function checkIgniteVersion(type, igniteName, version, igniteCore, showHint) {
.catch(err =>
errorHandler(
err,
`Invalid ${igniteName} in the npm registry.` +
` Please report this to Electrode core team.`
`Invalid ${igniteName} in the npm registry.` + ` Please report this to Electrode core team.`
)
);
}
Expand All @@ -244,13 +203,7 @@ function checkIgnite(type, igniteCore, igniteName, showHint, manual, version) {
} else {
return igniteDailyCheck().then(checkRet => {
if (checkRet === "check") {
return checkIgniteRegistry(
type,
igniteCore,
igniteName,
showHint,
version
);
return checkIgniteRegistry(type, igniteCore, igniteName, showHint, version);
} else {
if (semverComp(version, checkRet.latestVersion) === 0) {
logger.log(chalk.cyan(`Your ${igniteName} is up-to-date.`));
Expand Down
18 changes: 5 additions & 13 deletions packages/ignite-core/tasks/check-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ function printNodeCheckLog() {

if (nodeVerRet >= 0) {
logger.log(
chalk.yellow(
`You are using Node version ${nodeVersion}. Electrode should work for you.\n`
)
chalk.yellow(`You are using Node version ${nodeVersion}. Electrode should work for you.\n`)
);
} else {
logger.log(
chalk.yellow(
`Your Node version is: ${nodeVersion}. We recommend use Node LTS version 6.\n`
)
chalk.yellow(`Your Node version is: ${nodeVersion}. We recommend use Node LTS version 6.\n`)
);
}
}
Expand All @@ -41,15 +37,11 @@ function printnpmCheckLog(npmVersion) {

if (npmVerRet >= 0) {
logger.log(
chalk.yellow(
`You are using npm version ${npmVersion}. Electrode should work for you.\n`
)
chalk.yellow(`You are using npm version ${npmVersion}. Electrode should work for you.\n`)
);
} else {
logger.log(
chalk.yellow(
`Your npm version is: ${npmVersion}. Electrode requires npm version 3 and up.\n`
)
chalk.yellow(`Your npm version is: ${npmVersion}. Electrode requires npm version 3 and up.\n`)
);
}
}
Expand Down Expand Up @@ -82,7 +74,7 @@ function checkNode(type, igniteCore, spinner) {
return true;
})
.catch(err => {
errorHandler(err, "Checking node env.")
errorHandler(err, "Checking node env.");
});
}

Expand Down
10 changes: 4 additions & 6 deletions packages/ignite-core/tasks/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ const logger = require("../lib/logger");

function printSucessLogs(type, igniteCore, showHint) {
logger.log(
chalk.green(
"You've successfully opened the oss gitbook. Please checkout your browser."
)
chalk.green("You've successfully opened the oss gitbook. Please checkout your browser.")
);

return backToMenu(type, igniteCore, showHint);
};
}

function openDocs(gitbookURL, type, igniteCore, showHint) {
if (process.platform === "win32") {
Expand All @@ -34,7 +32,7 @@ function openDocs(gitbookURL, type, igniteCore, showHint) {
return errorHandler("Failed at open a new browser on windows", e);
}
}
};
}

function electrodeDocs(type, igniteCore, showHint) {
let gitbookURL = "";
Expand All @@ -46,6 +44,6 @@ function electrodeDocs(type, igniteCore, showHint) {
errorHandler("Please provide a valid type");
}
return openDocs(gitbookURL, type, igniteCore, showHint);
};
}

module.exports = electrodeDocs;
6 changes: 3 additions & 3 deletions packages/ignite-core/tasks/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const errorHandler = require("../lib/error-handler");

const Generator = (type, generator, igniteCore, spinner) => {
return checkNode(type, null, spinner)
.then((nodeCheckPassed) => {
.then(nodeCheckPassed => {
spinner.start();

if (nodeCheckPassed) {
Expand All @@ -28,8 +28,8 @@ const Generator = (type, generator, igniteCore, spinner) => {
});
}

child.on("error", (err) => {
errorHandler(err, `Running ${generator} generator.`)
child.on("error", err => {
errorHandler(err, `Running ${generator} generator.`);
});

spinner.stop();
Expand Down
Loading

0 comments on commit 2c95da3

Please sign in to comment.