Prism

June 4, 2020 · View on GitHub

version Maintenance MIT

SlimIO Prism Addon. This addon has been designed to be a Distribution Server (it manage archive of Addons).

Getting Started

This package is available in the SlimIO Package Registry and can be easily installed with SlimIO CLI.

$ slimio --add prism
# or
$ slimio --add https://github.com/SlimIO/Prism

Tcp-Sdk code to transfert archives

// Require Node.js Dependencies
const { createReadStream } = require("fs");
const { resolve } = require("path");

// Require Third-party Dependencies
const TcpSdk = require("@slimio/tcp-sdk");

async function sendArchive(client, name) {
    const id = await client.sendOne("prism.start_bundle", name);

    const readStream = createReadStream(resolve("archives", name));
    try {
        for await (const chunk of readStream) {
            await client.sendOne("prism.send_bundle", [id, chunk.toJSON()]);
        }
        await client.sendOne("prism.end_bundle", id);
    }
    catch (error) {
        readStream.close();
    }
}

async function main() {
    const client = new TcpSdk({ host: "localhost", port: 1337 });
    client.catch((err) => console.error(err));
    await client.once("connect", 1000);

    try {
        await sendArchive(client, "Addon-aggregator-0.1.0.tar");

        // Send install callback (depending on your need).
        await client.sendOne("prism.install_archive", ["aggregator", "0.1.0"]);
    }
    finally {
        client.close();
    }
}
main().catch(console.error);

Dependencies

NameRefactoringSecurity RiskUsage
@lukeed/uuidMinorLowA tiny (230B), fast, and cryptographically secure UUID (v4) generator
@slimio/addonMinorLowAddon container
@slimio/tarball⚠️MajorHighSlimIO Addon & module archive tarball packer/extractor
@slimio/timemapMinorLowES6 Map-Like implementation with keys that have a defined timelife
semiverMinorLowA tiny (187B) utility to compare semver strings.
semver⚠️MajorLowSemver parser/utilities for node

License

MIT