Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node

const yargs = require("yargs");
const checkKit = require("check-kit");

(async () => {
const { current, name, latest, updateAvailable } = await checkKit.check({
pkg: require("../package.json"),
});

if (updateAvailable) {
console.log(`New version of ${name} available! ${current} -> ${latest}`);
} else {
yargs
.commandDir("../cmds")
.wrap(yargs.terminalWidth())
.showHelpOnFail(true)
.demandCommand()
.recommendCommands()
.strict().argv;
}
})();
30 changes: 30 additions & 0 deletions cmds/open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";
const open = require("open");

const locations = {
website: "http://romajs.org",
twitter: "https://twitter.com/roma_js",
facebook: "https://www.facebook.com/romajs.org",
youtube: "https://www.youtube.com/channel/UCFm8OPi5USbFybw9SaTLxeA",
slack: "https://romajs.slack.com/",
slackSignup: "https://romajs.herokuapp.com/",
github: "https://github.com/Roma-JS",
meetup: "http://www.meetup.com/RomaJS/",
};

exports.command = "open <location>";

exports.desc = `open in a browser one of the following locations ${Object.keys(
locations,
)}`;

exports.builder = (yargs) => {
yargs.option("location", {
describe: "one of the RomaJS pages",
choices: Object.keys(locations),
});
};

exports.handler = async function (args) {
await open(locations[args.location]);
};
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"romajs": "bin/cli.js"
},
"author": "RomaJS",
"license": "MIT",
"repository": {
Expand All @@ -20,5 +23,10 @@
"bugs": {
"url": "https://github.com/Roma-JS/romajs-cli/issues"
},
"homepage": "https://github.com/Roma-JS/romajs-cli#readme"
"homepage": "https://github.com/Roma-JS/romajs-cli#readme",
"dependencies": {
"check-kit": "^1.2.1",
"open": "^8.2.1",
"yargs": "^17.0.1"
}
}