Skip to content

Commit dbb7b98

Browse files
committed
feat(tracking): save which stage is currently activated
1 parent 5f522b7 commit dbb7b98

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ async function main() {
3636
// after a bootstrap is done, it's moved to main (with settings)
3737
// if it was already finished, we will set the settings on the main index
3838
await bootstrap(await stateManager.check());
39+
3940
// then we figure out which updates we missed since
4041
// the last time main index was updated
4142
await replicate(await stateManager.get());
43+
4244
// then we watch 👀 for all changes happening in the ecosystem
4345
return watch(await stateManager.get());
4446
}
@@ -89,6 +91,10 @@ function infoDocs(offset, nbDocs, emoji) {
8991
}
9092

9193
async function bootstrap(state) {
94+
await stateManager.save({
95+
stage: 'watch',
96+
});
97+
9298
if (state.seq > 0 && state.bootstrapDone === true) {
9399
await setSettings(mainIndex);
94100
log.info('⛷ Bootstrap: done');
@@ -167,6 +173,10 @@ async function replicate({ seq }) {
167173
seq
168174
);
169175

176+
await stateManager.save({
177+
stage: 'replicate',
178+
});
179+
170180
const { seq: npmSeqToReach } = await npm.info();
171181

172182
return new Promise((resolve, reject) => {
@@ -213,11 +223,15 @@ async function replicate({ seq }) {
213223
});
214224
}
215225

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

231+
await stateManager.save({
232+
stage: 'watch',
233+
});
234+
221235
return new Promise((resolve, reject) => {
222236
const changes = db.changes({
223237
...defaultOptions,

0 commit comments

Comments
 (0)