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

Structure refactoring #19

Merged
merged 3 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
move commands into its own module
  • Loading branch information
volkanto committed Jun 14, 2021
commit 36e4e8b6d875b12d082b69ad6504dfa57acc143c
43 changes: 1 addition & 42 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

// third party lib definitions
const yargs = require("yargs");
const pkg = require('../package.json');
const chalk = require("chalk");

// local variables
const package = require('../package.json');
const helper = require('./utils/helper.js');
const tool = require('./utils/tool.js');
const flow = require('./utils/flow.js');
const options = require('./utils/command.js');

async function run() {

Expand All @@ -19,46 +18,6 @@ async function run() {
// can be used instead below method.
await tool.checkUpdate(); // check if the yaba cli has newer version

// yaba commands
const options = yargs
.usage("Usage: yaba -o <owner> -r <repository> -t <tag> -n <release-name> -b <body> -d <draft> -c")
.option("o", {alias: "owner", describe: "The repository owner.", type: "string"})
.option("r", {alias: "repo", describe: "The repository name.", type: "string"})
.option("t", {alias: "tag", describe: "The name of the tag.", type: "string"})
.option("n", {alias: "release-name", describe: "The name of the release.", type: "string"})
.option("b", {
alias: "body",
describe: "Text describing the contents of the tag. If not provided, the default changelog will be generated with the usage of the difference of master and latest release.",
type: "string"
})
.option("d", {
alias: "draft",
describe: "Creates the release as draft.",
type: "boolean"
})
.option("c", {
alias: "changelog",
describe: "Shows only changelog without creating the release.",
type: "boolean"
})
.option("i", {
alias: "interactive",
describe: "Prompt before (draft) release is created (default true)",
type: "boolean"
})
.option("s", {
alias: "sound",
describe: "Play sound when the release created",
type: "boolean"
})
.epilog(`Copyleft ${new Date().getFullYear()} ${package.author} - ${package.githubProfile}`)
.alias('h', 'help')
.help('help')
.alias('v', 'version')
.version(pkg.version)
.argv;


// check required ENV variables
flow.checkRequiredEnvVariables();

Expand Down
47 changes: 47 additions & 0 deletions bin/utils/command.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const yargs = require("yargs");
const package = require('../../package.json');

const commands = yargs
.usage("Usage: yaba -o <owner> -r <repository> -t <tag> -n <release-name> -b <body> -d <draft> " +
"-c <changelog> -i <interactive> -s <sound>")
.option("o", {alias: "owner", describe: "The repository owner.", type: "string"})
.option("r", {alias: "repo", describe: "The repository name.", type: "string"})
.option("t", {alias: "tag", describe: "The name of the tag.", type: "string"})
.option("n", {alias: "release-name", describe: "The name of the release.", type: "string"})
.option("b", {
alias: "body",
describe: "Text describing the contents of the tag. If not provided, the default changelog " +
"will be generated with the usage of the difference of master and latest release.",
type: "string"
})
.option("d", {
alias: "draft",
describe: "Creates the release as draft.",
type: "boolean"
})
.option("c", {
alias: "changelog",
describe: "Shows only changelog without creating the release.",
type: "boolean"
})
.option("i", {
alias: "interactive",
describe: "Prompt before (draft) release is created (default true)",
type: "boolean"
})
.option("s", {
alias: "sound",
describe: "Play sound when the release created",
type: "boolean"
})
.epilog(`Copyleft ${new Date().getFullYear()} ${package.author} - ${package.githubProfile}`)
.alias('h', 'help')
.help('help')
.alias('v', 'version')
.version(package.version)
.argv;

// yaba commands
module.exports = {
options: commands
}