SkillAgentSearch skills...

Trex

Package Manager for deno 🦕

Install / Use

/learn @crewdevio/Trex

README

<h1 align="center">Trex 🦕</h1> <p align="center"> <img src="https://cdn.discordapp.com/attachments/772853383803437058/828483429787500564/687474703a2f2f636c69706172742d6c6962726172792e636f6d2f696d6167655f67616c6c6572792f333131392e706e67.png" width="350"> <p align="center">Package management for deno (pronounced "tee rex") </p> </p> <p align="center"> <a href="https://github.com/crewdevio/Trex/issues"> <img alt="GitHub issues" src="https://img.shields.io/github/issues/crewdevio/Trex"> </a> <a href="https://github.com/crewdevio/Trex/network"> <img alt="GitHub forks" src="https://img.shields.io/github/forks/crewdevio/Trex"> </a> <a href="https://github.com/crewdevio/Trex/stargazers"> <img alt="GitHub stars" src="https://img.shields.io/github/stars/crewdevio/Trex"> </a> <a href="https://github.com/crewdevio/Trex/blob/master/LICENSE"> <img alt="GitHub license" src="https://img.shields.io/github/license/crewdevio/Trex"> </a> <a href="https://deno.land"> <img src="https://img.shields.io/badge/deno-%5E1.10.2-green?logo=deno"/> </a> <a href="https://nest.land/package/Trex"> <img src="https://nest.land/badge.svg" /> </a> </p>

Use Trex

About

Trex is a package management tool for deno similar to npm but keeping close to the deno philosophy. Packages are cached and only one import_map.json file is generated.

// import_map.json

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

For more information about the import maps in deno see import maps.

Additional topics

Installation

deno install -A --unstable --import-map=https://deno.land/x/trex/import_map.json -n trex --no-check https://deno.land/x/trex/cli.ts

Note: Works with deno >= 1.10.2

We shorten the install command so it's not that long

The permissions that Trex uses are:

  • --allow-net
  • --allow-read
  • --allow-write
  • --allow-run
  • --allow-env

You can give those permissions explicitly.

Updating Trex

Install new version with the -f flag:

deno install -f -A --unstable --import-map=https://deno.land/x/trex/import_map.json -n trex --no-check https://deno.land/x/trex/cli.ts

Or use the upgrade command:

trex upgrade

Note: available for versions 0.2.0 or higher.

Note: to try the latest pre-release features, use the --canary flag.

Verify the installation of Trex:

trex --version

The console should print the Trex version.

For help on the commands that Trex provides, use:

trex --help

Usage

Installing from deno.land

Use the --map flag to install packages from the Standard Library (std) and those hosted at deno.land/x.

Example

Install the fs, http and fmt modules from std:

trex install --map fs http fmt

Note: you can also use the shorthand i, as in: trex i --map fs http fmt

Installing from nest.land

Use the --nest flag and specify an explicit version to install packages hosted on nest.land.

trex install --nest [pkg]@[version]

Examples

trex install --nest opine@0.13.0
trex i --nest etag@0.0.2

You can install std packages from nest.land by specifying the package and version:

trex install --nest fs@0.61.0

Installing from a repository

trex install --pkg [user]/[repo or repo@tag/branch]/[path/to/file] [packageName]

Example

trex install --pkg oakserver/oak@main/mod.ts oak

Warning: In the event that the repository uses a branch other than master as the main branch, this must be specified!

The above downloads oak directly from its repository.

Example import map

All installation methods produce an import_map.json file:

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

Downloading packages

Download all the packages listed in the import_map.json similar to npm install:

trex install

Adding custom packages

Install a package from a custom URL source:

trex --custom React=https://dev.jspm.io/react/index.js
// import_map.json
{
  "imports": {
    "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"
  }
}

Deleting packages

trex delete React

Remove a specific version from the cache and the import_map.json file:

trex delete fs@0.52.0
// 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: Removing from cache only works with packages from std and deno.land/x

Installing an explicit version of a package

Specify a package's version:

trex install --map fs@0.54.0
// import_map.json
{
  "imports": {
    "fs/": "https://deno.land/std@0.54.0/fs/"
  }
}

Note: can be used with third party packages.

Checking for outdated dependencies

trex check

Warning: Currently limited to packages from deno.land/std and deno.land/x, in future versions this will support third party registries and CDN sources as well.

Run Scripts with run.json

You can create command aliases, similar to deno task or npm run.

Simply create a run.json file with the following structure:

{
  "scripts": {
    "welcome": "deno run https://deno.land/std@0.71.0/examples/welcome.ts"
  }
}

Aliasing external commands

You can call a command from within another, or call a script like denopack or eggs update from within a command alias:

// run.json
{
  "scripts": {
    "start": "trex run welcome",
    "welcome": "deno run https://deno.land/std@0.71.0/examples/welcome.ts",
    "dev": "denon run ./app.ts",
    "build": "aleph build",
		"update": "eggs update"
  }
}

Then, for example, to update your dependencies:

trex run update

This will execute eggs update

Installation life cycle

When the command trex install or trex i executed, you can perform actions before and after the execution of trex install.

Execution order:

  1. preinstall
  2. install
  3. postinstall
// run.json
{
  "scripts": {
    "start": "trex run welcome",
    "welcome": "deno run https://deno.land/std@0.71.0/examples/welcome.ts",
    "dev": "denon run ./app.ts",
    "build": "aleph build",
    "preinstall": "deno --version",
    "postinstall": "deno test --unstable"
  }
}

Note: you can use the --watch flag to monitor the changes and rerun the script, example:

deno run --watch --unstable https://deno.land/std@0.71.0/examples/welcome.ts

Passing arguments to aliases

You can provide arguments when calling the command alias. These will be passed to the file to execute:

trex run start --port=3000 --env
console.log(Deno.args); // ["--port=3000", "--env"]

Reboot Script Alias Protocol (or RSAP)

With trex you can create script aliases that reload every time a file is changed, similar to running deno with the --watch flag.

The Reboot Script Alias Protocol (RSAP) provides this same functionality. Just add a files property to your run.json file, specifying an array of files that will be watched. When changes are detected in those files, your script aliases will be restarted immediately.

// run.json
{
  "scripts": {
    "start": "trex run welcome",
    "dev": "denon run ./app.ts",
    "build": "aleph build"
  },
  "files": ["./app.ts"]
}

You only have to add the files option in the run.json file and it will only observe the files and folders that you specify, if you leave the array empty it will observe all the files.

// run.json
{
  "scripts": {
    "dev": "go build"
  },
  "files": ["./main.go"]
}

For the script alias to use rsap you just need to add the --watch or -w flag to the end of the command alias:

trex run dev --watch [...args]

It can be used with any CLI tool, compiler or interpreter.

YAML is also acceptable (run.yml or run.yaml)

- scripts:
    dev: go build
- files:
    - ./main.go

Limitations

A limitation of watch mode is that they do not restart the processes that never end (such as http servers). In those cases we recommend other alternatives, such as denon.

Virtual cli tool execution

Trex will auto detect cli file in the order of "cli.ts", "cli.js", "%pacakge-name%.ts", "%package-name%.js", "main.ts", "main.js", "mod.ts", "mod.js", "index.ts", "index.js". If you want to publish a cli package, name your cli file as either of above(e.g. cli.ts) in your root package.

trex exec allows you to run many cli tools hosted at deno.land/x

trex exec aleph init hello_world

trex will fetch aleph's cli and run without installing it locally using deno install, you can also specify the version you want to use.

trex exec aleph@v0.2.28 init hello_world

Permissions (perms)

You can also specify the permissions that the cli

View on GitHub
GitHub Stars729
CategoryDevelopment
Updated1d ago
Forks22

Languages

TypeScript

Security Score

100/100

Audited on Mar 26, 2026

No findings