1.0.3 • Published 23 days ago

project-updater v1.0.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
23 days ago

About

A simple and easy to use project updater for your Node.js projects. Suppose you have a specific project and you offer this project to many of your customers and you prepare projects with different features (but the same codebase) for each customer. In this case, you can use this package to update your project for your customers. You can host your project on a server and update it for your customers with a single command. This package saves you from having to apply the same changes to all your customers' projects whenever you make any changes. You can also ignore specific files to prevent them from being updated.

Highlights

  • Simple: Easy to use and understand.
  • Secure: Protect your project with a secret key.
  • Customizable: Customize the updater to your needs.
  • Automatic: Automatically update your project when a new version is available.
  • Fast: Update your project in seconds.
  • Save Time: Save time by updating your project with a single command.

Installation

Note:: This package requires Node.js 16.0.0 or higher.

Using npm:

$ npm install project-updater

Using yarn:

$ yarn add project-updater

Usage

This package consists of two parts: the server side and the client side. The server side is used to host your project and update it for your client projects. The client side is used to connect to the host server and update your project.

Server side

Project structure:

root/
├── updater.js
├── package.json
└── your-project-path/
    ├── ...
    └── package.json

Note: The package.json file in the root directory is the main package file, and the package.json file in the my-project directory is the project package file and must exist.

Create a server to host your project and update it for your client projects:

// updater.js
import { Server } from "project-updater";
import packageJson from "./your-project-path/package.json";

const server = new Server({
    package: packageJson,
    port: 5000,
    key: "your-super-secret-key",
    path: "/your-project-path/",
    ignore: ["node_modules", "package-lock.json"],
});

server.start();

Server configuration options:

OptionTypeDefaultDescription
keystring-The secret key to protect your project.
pathstring-The path to your project directory.
portnumber8080The port to listen on.
packagePackageJson-The project package.json file.
commandsstring[][]The commands that will run on the client side after the client updates the project.
packagesstring[][]The npm packages that will be installed on the client side after the client updates the project.
ignorestring[]["node_modules", "package-lock.json"]The files and directories that will be ignored when updating the project.

Client side

Project structure:

root/
├── updater.js
├── package.json
└── your-project-path/

Connect to the host server and update your project:

// updater.js
import { Client } from "project-updater";

const client = new Client("start", {
    host: "http://localhost:5000",
    auth: { key: "your-super-secret-key" },
    projectDir: "./your-project-path/",
    reconnectionDelayMax: 5000,
    autoConnect: false,
});

client.connect();

Client configuration options:

OptionTypeDefaultDescription
hoststring-The host server URL.
auth.keystring-The secret key to connect to the host server.
projectDirstring./projectThe project directory.
autoUpdatebooleantrueAutomatically update the project when a new version is available.
autoConnectbooleantrueAutomatically connect to the host server.
autoStartbooleantrueAutomatically start the project after updating.
autoRestartbooleantrueAutomatically restart the project when it crashes.
packageJsonPathstring./package.jsonThe path to the project package.json file.
reconnectionDelayMaxnumber10000The maximum reconnection delay between reconnection attempts in milliseconds.
reconnectionAttemptsnumber10The maximum reconnection attempts.
ignorestring[]["package-lock.json"]The files that will be ignored when updating the project (Only files can be ignored for now, not directories)

Future Plans

  • Add realtime update function to update the project when the server produces a new version.
  • Add support for ignoring directories in the client side.

Information

This project is still in development and may contain bugs. New features and improvements are planned for the future. If you have any suggestions or find a bug, please create an issue.

Help

If you need help, you can ask questions to me on my Discord server.

1.0.3

23 days ago

1.0.2

26 days ago

1.0.1

26 days ago

1.0.0

26 days ago

0.1.0

11 months ago