Add support for running routines via command line

This commit is contained in:
garrettmills
2020-08-13 20:28:23 -05:00
parent afb35ebad8
commit f5b84b530c
33 changed files with 396 additions and 5 deletions

View File

@@ -40,6 +40,10 @@ class CheckoutState extends AbstractGitState {
check_message() {
return this.failure_message()
}
display() {
return `Check out ref ${this._config.target} in repo ${this._config.path}...`
}
}
module.exports = exports = CheckoutState

View File

@@ -30,6 +30,10 @@ class CloneState extends AbstractGitState {
check_message() {
return this.failure_message()
}
display() {
return `Clone repo at ${this._config.source} to ${this._config.path}...`
}
}
module.exports = exports = CloneState

View File

@@ -0,0 +1,36 @@
const AbstractGitState = require('./AbstractGitState')
class PullState extends AbstractGitState {
static get services() {
return [...super.services, 'output']
}
async apply() {
if ( !(await this.check()) ) {
const repo = await this._repo()
await repo.pull(this._config.target)
}
}
async check() {
return true // TODO support a better check here
}
async reverse() {
this.output.warn('Pull state does not currently support automatic reversal.')
}
failure_message() {
return `The Git repo at "${this._config.path}" on host "${this._host.name}" will be pulled.`
}
check_message() {
return this.failure_message()
}
display() {
return `Pull refs in repo ${this._config.path}...`
}
}
module.exports = exports = PullState

View File

@@ -33,6 +33,10 @@ class TagState extends AbstractGitState {
check_message() {
return this.failure_message()
}
display() {
return `Create tag ${this._config.tag} in repo ${this._config.path}...`
}
}
module.exports = exports = TagState