Skip to content

Commit

Permalink
feat(tracking): save which stage is currently activated
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed Mar 4, 2019
1 parent 5f522b7 commit dbb7b98
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ async function main() {
// after a bootstrap is done, it's moved to main (with settings)
// if it was already finished, we will set the settings on the main index
await bootstrap(await stateManager.check());

// then we figure out which updates we missed since
// the last time main index was updated
await replicate(await stateManager.get());

// then we watch 👀 for all changes happening in the ecosystem
return watch(await stateManager.get());
}
Expand Down Expand Up @@ -89,6 +91,10 @@ function infoDocs(offset, nbDocs, emoji) {
}

async function bootstrap(state) {
await stateManager.save({
stage: 'watch',
});

if (state.seq > 0 && state.bootstrapDone === true) {
await setSettings(mainIndex);
log.info('⛷ Bootstrap: done');
Expand Down Expand Up @@ -167,6 +173,10 @@ async function replicate({ seq }) {
seq
);

await stateManager.save({
stage: 'replicate',
});

const { seq: npmSeqToReach } = await npm.info();

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -213,11 +223,15 @@ async function replicate({ seq }) {
});
}

function watch({ seq }) {
async function watch({ seq }) {
log.info(
`🛰 Watch: 👍 We are in sync (or almost). Will now be 🔭 watching for registry updates, since ${seq}`
);

await stateManager.save({
stage: 'watch',
});

return new Promise((resolve, reject) => {
const changes = db.changes({
...defaultOptions,
Expand Down

0 comments on commit dbb7b98

Please sign in to comment.