node: started
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
8
bin/creature
Executable file
8
bin/creature
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const commander = require("commander");
|
||||||
|
const program = new commander.Command();
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("start feature-words", "start a new feature")
|
||||||
|
.parse(process.argv);
|
||||||
61
bin/creature-start
Executable file
61
bin/creature-start
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const commander = require("commander");
|
||||||
|
const program = new commander.Command();
|
||||||
|
|
||||||
|
const util = require("util");
|
||||||
|
const exec = util.promisify(require("child_process").exec);
|
||||||
|
|
||||||
|
program.parse(process.argv);
|
||||||
|
|
||||||
|
function setCurrentBranch(dp) {
|
||||||
|
return exec(`git branch|grep '\*'|sed 's/\*\s*//'`)
|
||||||
|
.then(x => x.stdout.trim())
|
||||||
|
.then(x => Object.assign({}, dp, { currentBranch: x }));
|
||||||
|
}
|
||||||
|
|
||||||
|
function setStandardBranches(dp) {
|
||||||
|
return Object.assign({}, dp, { standardBranches: ["master", "release"] });
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateCurrentBranch(dp) {
|
||||||
|
if (!dp.standardBranches.includes(dp.currentBranch)) {
|
||||||
|
throw `invalid base branch: ${dp.currentBranch}`;
|
||||||
|
} else {
|
||||||
|
return dp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateFeatureBranch(dp) {
|
||||||
|
if (dp.standardBranches.includes(dp.featureName)) {
|
||||||
|
throw `invalid feature branch: ${dp.featureName}`;
|
||||||
|
} else {
|
||||||
|
return dp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setFeatureName(dp) {
|
||||||
|
const fn = program.args.join("-");
|
||||||
|
return Object.assign({}, dp, { featureName: fn });
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPrefix(dp) {
|
||||||
|
const p = process.env.FEATURE_USER || process.env.USER;
|
||||||
|
return Object.assign({}, dp, { prefix: p });
|
||||||
|
}
|
||||||
|
|
||||||
|
function setFeatureBranch(dp) {
|
||||||
|
const fb = `${dp.prefix}-${dp.currentBranch}-${dp.featureName}`;
|
||||||
|
return Object.assign({}, dp, { featureBranch: fb });
|
||||||
|
}
|
||||||
|
|
||||||
|
const x = Promise.resolve({ program })
|
||||||
|
.then(setStandardBranches)
|
||||||
|
.then(setFeatureName)
|
||||||
|
.then(setPrefix)
|
||||||
|
.then(setCurrentBranch)
|
||||||
|
.then(validateCurrentBranch)
|
||||||
|
.then(setFeatureBranch)
|
||||||
|
.then(validateFeatureBranch)
|
||||||
|
.then(x => console.log("x", x))
|
||||||
|
.catch(err => console.error(err));
|
||||||
13
package-lock.json
generated
Normal file
13
package-lock.json
generated
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "git-utilities",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
|
"dependencies": {
|
||||||
|
"commander": {
|
||||||
|
"version": "2.20.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
|
||||||
|
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
package.json
Normal file
26
package.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "git-utilities",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "This is a collection of simple command-line scripts, bash aliases, and bash utilities that make using `git` even easier.",
|
||||||
|
"main": "index.js",
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/rkiel/git-utilities.git"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/rkiel/git-utilities/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/rkiel/git-utilities#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"commander": "^2.20.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user