Welcome to Trex!

Trex 🐱‍🐉

GitHub issues GitHub forks GitHub stars GitHub license GitHub tag (latest SemVer)

Trex

Package management for deno

What is Trex?

is a “Package management” for deno to implement an import_map.json for your imports is an easiest way to make imports in deno.

// import_map.json

{
    "imports":  {
    "http/":  "https://deno.land/std/http/"
    }
}

For more information about the import maps in deno import maps

Guide:

installation:

Download the repository and open the terminal in the folder of the repository and write:

  deno install --allow-read --allow-write --allow-net --allow-run --unstable Trex.ts

note: You should have the last version 1.0.0 >= of deno for no errors.

or in your terminal you can write

  deno install --allow-read --allow-write --allow-net --allow-run --unstable https://deno.land/x/trex/Trex.ts

update trex using

  Trex update

check for the installation of the Trex tool writing in the terminal:

  Trex --version

and the console should presente the Trex version.

for any help of the commands of Trex write:

  Trex --help

and the console should present:

help:
   * flags:
       --map: for install a library
       --version: logs version
       --custom: for install custom package

   * install module using:
        Trex install --map fs http

   * install custom module usig:
        Trex --custom module_name=module_url

   * uninstall module using:
        Trex delete module_name

   * install Tool using:
        Trex getTool tool_name

for a better implementation of this tool you can use the tool Commands of deno Commands

How to use

in your command line write:

$ Trex install --map fs http fmt

note: you can use Trex i –map fs http fmt

an import_map.json file will be created with the following.

{
    "imports": {
        "fs/": "https://deno.land/std/fs/",
        "http/": "https://deno.land/std/http/",
        "fmt/": "https://deno.land/std/fmt/"
    }
}

Usage example.

create a test file

// server.ts
import { serve } from "http/server.ts"
import { green } from "fmt/colors.ts" 

const server = serve({ port: 8000 });
console.log(green("http://localhost:8000/"));

for await (const req of server) {
  req.respond({ body: "Hello World\n" });
}

run in terminal

$ deno run --allow-net --importmap=import_map.json --unstable server.ts

note: it is important to use –importmap=import_map.json –unstable

using third party modules

example using oak

$ Trex i --map oak

in import_map.json

{
    "imports": {
        "fs/": "https://deno.land/std/fs/",
        "http/": "https://deno.land/std/http/",
        "fmt/": "https://deno.land/std/fmt/",
        "oak": "https://deno.land/x/oak/mod.ts"
    }
}

note: third party modules are added using mod.ts

in server.ts

// server.ts
import { Application } from "oak";

const app = new Application();

app.use((ctx) => {
  ctx.response.body = "Hello World!";
});

await app.listen({ port: 8000 });

run in terminal

$ deno run --allow-net --importmap=import_map.json --unstable server.ts

add custom module

in your command line write:

$ Trex --custom React=https://dev.jspm.io/react/index.js

in import_map.json

{
    "imports": {
        "fs/": "https://deno.land/std/fs/",
        "http/": "https://deno.land/std/http/",
        "fmt/": "https://deno.land/std/fmt/",
        "oak": "https://deno.land/x/oak/mod.ts",
        "React": "https://dev.jspm.io/react/index.js"
    }
}

install tools like velociraptor or Commands

in your command line write:

$ Trex getTool Commands

this will install the tool

note: this feature is currently unstable

delete module

in your command line write:

$ Trex delete React

in import_map.json

{
    "imports": {
        "fs/": "https://deno.land/std/fs/",
        "http/": "https://deno.land/std/http/",
        "fmt/": "https://deno.land/std/fmt/",
        "oak": "https://deno.land/x/oak/mod.ts"
    }
}

update Trex

in your command line write:

$ deno install -f --allow-read --allow-write --allow-net --allow-run --unstable https://deno.land/x/trex/Trex.ts

flags

view Trex version

$ Trex --version

view help

$ Trex --help

Todo

  • install std modules and third party modules in deno.land/x.

  • delete modules from import_map.json.

  • support for custom module outside of deno third party modules.

  • sort modules names in import_map.json.

  • support to install tools like Commands (!unstable).

    • if you want add your tool in database edit this file database.json
  • update using:

    • Trex update
  • support to choose install other versions of modules. (!unstable):

    • Trex install --map fs@0.50.0