项目作者: pruizlezcano

项目描述 :
Compare local package.json and remote package.json and if versions don't match, copy remote files
高级语言: JavaScript
项目地址: git://github.com/pruizlezcano/gh-autoupdater.git
创建时间: 2020-10-23T19:20:20Z
项目社区:https://github.com/pruizlezcano/gh-autoupdater

开源协议:MIT License

下载


AutoUpdater

Compare local package.json and remote package.json and if versions don’t match, copy remote files

Installation

npm install gh-autoupdater

How it works?

  • Compare local version with remote version
  • If versions don’t match, download the repository
  • Copy files to local
  • Compare local dependencies with remote dependencies
  • If dependencies don’t match, install the remote dependencies

Config

  • repo: 'http://github.com/user/repo' - The url to the root of a git repository to update from.
  • branch: 'main' - The branch to update from.
  • temp: './temp-update' - The local dir to save temporary information for the update.
  • ignore: ['.git',...] - An array of files for not copiyng when updating.
  • testing: false - If true, copy update inside ./testing folder.
  • dev: false - If true, ignore the update.
  • token: 123456... - If you are using a private repository you should use a personal access token for downloading it

This values are the default values

Events

  • out-dated(localVersion, remoteVersion) - Local version is out-dated
  • up-to-date(version) - Versions match
  • download.start(repo) - Download started from the repository
  • download.end - Files downloaded
  • update.start - Copying files from “tepm folder”
  • modules.start - Installing dependencies
  • modules.end(modules) - Dependencies installed
  • end - All is over

Example

  1. const AutoUpdate = require('gh-autoupdater');
  2. const update = new AutoUpdate({
  3. repo: 'https://github.com/user/repo',
  4. branch: 'main',
  5. temp: './temp-update',
  6. testing: false,
  7. });
  8. // Initialize update
  9. update.autoUpdate();
  10. // Events
  11. update.on('out-dated', (local, remote) => {
  12. console.log('Out-dated: Local-' + local + ' Remote-' + remote);
  13. });
  14. update.on('up-to-date', (local) => {
  15. console.log('Up to date: local-' + local);
  16. });
  17. update.on('modules.start', () => {
  18. console.log('Updating dependencies...');
  19. });
  20. update.on('modules.end', (modules) => {
  21. console.log('Dependencies updated: ');
  22. console.log(modules);
  23. });
  24. update.on('download.start', (repo) => {
  25. console.log('Downloading files from: ' + repo);
  26. });
  27. update.on('download.end', () => {
  28. console.log('Files downloaded');
  29. });
  30. update.on('update.start', () => {
  31. console.log('Copying files...');
  32. });
  33. update.on('end', () => {
  34. console.log('Application updated');
  35. });