Last active
April 2, 2020 15:45
-
-
Save saulshanabrook/0cb54933391eefe07da4b6983cd7a4e0 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const newPreVersion = assign({ | |
preVersion: () => 0 | |
}); | |
const bumpPreVersion = assign({ | |
preVersion: context => context.preVersion + 1 | |
}); | |
const bumpVersion = assign({ | |
version: context => context.version + 1 | |
}); | |
const addCommit = assign({ | |
unreleasedCommits: context => context.unreleasedCommits + 1 | |
}); | |
const resetCommits = assign({ | |
unreleasedCommits: context => 0 | |
}); | |
const commits = { | |
initial: 'clean', | |
states: { | |
clean: { | |
on: { COMMIT: { target: 'dirty', actions: 'addCommit' } } | |
}, | |
dirty: { | |
on: { COMMIT: { target: 'dirty', actions: 'addCommit' } } | |
} | |
} | |
}; | |
Machine({ | |
id: 'release', | |
context: { | |
version: 1, | |
preVersion: 0, | |
unreleasedCommits: 0 | |
}, | |
initial: 'final', | |
states: { | |
final: { | |
on: { | |
ALPHA: { target: 'alpha', actions: ['newPreVersion', resetCommits] } | |
}, | |
...commits | |
}, | |
alpha: { | |
on: { | |
ALPHA: { target: 'alpha', actions: ['bumpPreVersion', resetCommits] }, | |
RC: { target: 'rc', actions: ['newPreVersion', resetCommits] } | |
}, | |
...commits | |
}, | |
rc: { | |
on: { | |
RC: { target: 'rc', actions: ['bumpPreVersion', resetCommits] }, | |
FINAL: { target: 'final', actions: ['bumpVersion', resetCommits] } | |
}, | |
...commits | |
} | |
} | |
}, { | |
actions: { | |
newPreVersion, | |
bumpPreVersion, | |
bumpVersion, | |
addCommit, | |
resetCommits | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment