2

We have a node_module bookiza which is essentially a command line tool that people install with --global flag and then use it to create and publish books online. We are following semver for it (mostly) but I envisage it will be done so strictly in the future.

Is there a way to make this module a self-updating one? So that all our clients (writers) are on the same version of bookiza at all the times (unless they disable autoupdate). Essentially, run npm update [-g] bookiza every 15 days or when a new release is outed.

How should I go about implementing this?

1

2 Answers 2

6

For those who are looking for the same thing, I have created a module for automatically updating node.js applications from git repositories. It compares the local package.json with the one from your repo, then automatically clones the repo and install dependencies.

Auto Git Update - https://github.com/chegele/AutoGitUpdate

import AutoGitUpdate from 'auto-git-update';

const config = {
    repository: 'https://github.com/chegele/BackupPurger'
    tempLocation: 'C:/Users/scheg/Desktop/tmp/',
    ignoreFiles: ['util/config.js'],
    executeOnComplete: 'C:\\Users\\scheg\\Desktop\\worksapce\\AutoGitUpdate\\startTest.bat',
    exitOnComplete: true
}

const updater = new AutoGitUpdate(config);

updater.autoUpdate();
1

Your users could install the command line tool a number of ways.. So it's not guaranteed that npm install -g will work, particularly in their environment.

I think the best thing to do here is make some sort of "latest version" check at start. If there's a new version, warn the user, and offer to automatically run the update command with a [Y/n].

This is what bower and a few other packages do.

1
  • > some sort of "latest version" check at start. That is correct. Start of the "terminal app", like zsh or bower does. I'm looking at what event does the bower latch on to… and if that event is fired cross-platform across linux, windows and mac. Thanks! Aug 25, 2016 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.