Welcome to Trex π±βπ
Package management for deno
What is Trex?
is a Package management for deno similar to npm but maintaining 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 import maps
visual studio code
Setupinstall the deno extension first, then add in settings.json the following configuration.
activate the enable option Deno unstable features in settings >> extensions >> Deno
if you get this error after installing a module.
run your project to cache all dependencies.
note: when installing a module using ( Trex install βmap someModule ) or ( Trex βcustom someModule=someModule.com/someModule.ts ) this is automatically cached
Atom
Setupfirst install typescript plugin. then install the typescript-deno-plugin
using npm
$ npm install --save-dev typescript-deno-plugin typescript
using yarn
$ yarn add -D typescript-deno-plugin typescript
Then add a plugins section to your tsconfig.json.
{
"compilerOptions": {
"plugins": [
{
"name": "typescript-deno-plugin",
"enable": true,
"importmap": "import_map.json"
}
]
}
}
note:
enable
by default istrue
Then restart Atom. after restart you should have no problems.
before installing
after installing
Guide:
installation:
Download the repository and open the terminal in the folder of the repository and write:
$ deno install -A --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 -A --unstable https://deno.land/x/trex/Trex.ts
we shorten the install command so itβs not that long
The resources that Trex uses are:
- βallow-net
- βallow-read
- βallow-write
- βallow-run
- βallow-env
you can give those permissions explicitly
update Trex using
$ deno install -f -A --unstable https://deno.land/x/trex/Trex.ts
or use:
$ Trex update
for versions 0.2.0 or higher.
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:
advance package management for deno to implement an import_map.
USAGE:
Trex [OPTIONS] [SUBCOMMAND]
OPTIONS:
--help
Prints help information.
--custom
install custom module.
--version
Prints version information.
--deps
show dependencies versions.
--map
add module to import_mao.json.
SUBCOMMANDS:
[install or i] install some module.
delete<@version> delete a module from import_map.json and cache.
getTool install some tool.
update update Trex.
treeDeps view dependencie tree.
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"
}
}
velociraptor or Commands
install tools likein your command line write:
$ Trex getTool Commands
this will install the tool
note: If you are a linux/MacOs user youβll have to specificate the PATH manually when the tool gets installed the will appear in your terminal export PATH=β/home/username/.deno/bin:$PATHβ
delete module
in your command line write:
$ Trex delete React
to remove a specific version from the cache and import_map.json, it only works with standard modules and those installed from deno.land/x
$ Trex delete fs@0.52.0
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"
}
}
The modules in the standard library or those installed from deno.land/x
will be removed from the cache.
install another version of a module
write the name of the module more @<Version>
example:
$ Trex install --map fs@0.54.0
in import_map.json
{
"imports": {
"fs/": "https://deno.land/std@0.54.0/fs/"
}
}
note: can be used with third party modules.
check the versions of dependencies using
$ Trex --deps
you should see something like that on the console.
// in import_map.json
{
"imports": {
"oak": "https://deno.land/x/oak@v4.0.0/mod.ts",
"http/": "https://deno.land/std@0.51.0/http/"
}
}
name | module | url | version | latest | upToDate |
---|---|---|---|---|---|
oak | oak | βhttps://deno.land/x/oak@v4.0.0/mod.tsβ | βv4.0.0β | βv5.0.0β | false |
http/ | std | βhttps://deno.land/std@0.54.0/http/β | β0.54.0β | β0.54.0β | true |
thanks to Fzwael this functionality is based on your tool deno-check-updates
see module dependency tree.
$ Trex treeDeps fs
you should see this in the terminal
local: C:\Users\trex\AppData\Local\deno\deps\https\deno.land\434fe4a7be02d187573484b382f4c1fec5b023d27d1dcf4f768f300799a073e0
type: TypeScript
compiled: C:\Users\trex\AppData\Local\deno\gen\https\deno.land\std\fs\mod.ts.js
map: C:\Users\trex\AppData\Local\deno\gen\https\deno.land\std\fs\mod.ts.js.map
deps:
https://deno.land/std/fs/mod.ts
βββ¬ https://deno.land/std/fs/empty_dir.ts
β βββ¬ https://deno.land/std/path/mod.ts
β βββ https://deno.land/std/path/_constants.ts
β βββ¬ https://deno.land/std/path/win32.ts
β β βββ https://deno.land/std/path/_constants.ts
β β βββ¬ https://deno.land/std/path/_util.ts
β β β βββ https://deno.land/std/path/_constants.ts
β β βββ https://deno.land/std/_util/assert.ts
β βββ¬ https://deno.land/std/path/posix.ts
β β βββ https://deno.land/std/path/_constants.ts
β β βββ https://deno.land/std/path/_util.ts
β βββ¬ https://deno.land/std/path/common.ts
β β βββ¬ https://deno.land/std/path/separator.ts
β β βββ https://deno.land/std/path/_constants.ts
β βββ https://deno.land/std/path/separator.ts
β βββ https://deno.land/std/path/_interface.ts
β βββ¬ https://deno.land/std/path/glob.ts
β βββ https://deno.land/std/path/separator.ts
β βββ¬ https://deno.land/std/path/_globrex.ts
β β βββ https://deno.land/std/path/_constants.ts
β βββ https://deno.land/std/path/mod.ts
β βββ https://deno.land/std/_util/assert.ts
βββ¬ https://deno.land/std/fs/ensure_dir.ts
β βββ¬ https://deno.land/std/fs/_util.ts
β βββ https://deno.land/std/path/mod.ts
βββ¬ https://deno.land/std/fs/ensure_file.ts
β βββ https://deno.land/std/path/mod.ts
β βββ https://deno.land/std/fs/ensure_dir.ts
β βββ https://deno.land/std/fs/_util.ts
βββ¬ https://deno.land/std/fs/ensure_link.ts
β βββ https://deno.land/std/path/mod.ts
β βββ https://deno.land/std/fs/ensure_dir.ts
β βββ https://deno.land/std/fs/exists.ts
β βββ https://deno.land/std/fs/_util.ts
βββ¬ https://deno.land/std/fs/ensure_symlink.ts
β βββ https://deno.land/std/path/mod.ts
β βββ https://deno.land/std/fs/ensure_dir.ts
β βββ https://deno.land/std/fs/exists.ts
β βββ https://deno.land/std/fs/_util.ts
βββ https://deno.land/std/fs/exists.ts
βββ¬ https://deno.land/std/fs/expand_glob.ts
β βββ https://deno.land/std/path/mod.ts
β βββ¬ https://deno.land/std/fs/walk.ts
β β βββ https://deno.land/std/_util/assert.ts
β β βββ https://deno.land/std/path/mod.ts
β βββ https://deno.land/std/_util/assert.ts
βββ¬ https://deno.land/std/fs/move.ts
β βββ https://deno.land/std/fs/exists.ts
β βββ https://deno.land/std/fs/_util.ts
βββ¬ https://deno.land/std/fs/copy.ts
β βββ https://deno.land/std/path/mod.ts
β βββ https://deno.land/std/fs/ensure_dir.ts
β βββ https://deno.land/std/fs/_util.ts
β βββ https://deno.land/std/_util/assert.ts
βββ https://deno.land/std/fs/read_file_str.ts
βββ https://deno.land/std/fs/write_file_str.ts
βββ https://deno.land/std/fs/read_json.ts
βββ https://deno.land/std/fs/write_json.ts
βββ https://deno.land/std/fs/walk.ts
βββ https://deno.land/std/fs/eol.ts
Proxy
Some modules in the standard deno library do not have a mod.ts
file.
When installing a standard library module, a request is made to deno.land/std/moduleName/mod.ts
to be able to cache the module.
the solution we have is to create a bridge between the request to download the module and the files in the library.
in the proxy folder are the bridges of the modules that do not have the mod.ts
file.
these are the modules that use proxy
- _util
- archive
- encoding
- fmt
- node
- testing
To Do
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.
- 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:
$ Trex install --map fs@0.50.0
safe installation for tools like Commands, velociraptor or dpx.
- display a warning message with the permissions of the tool
check the versions of the libraries.
$ Trex --deps
System to cache package when install it. (!unstable):
it is currently being tested on windows and linux but it is an instable feature at the moment.
note: by default it caches the modules using the mod.ts file, if it cannot find it, it does not add it to the cache but add to the import_map.json.
List all the tools you can install.
choose the destination file when installing a module.
$ Trex --custom djwt/create.ts=https://deno.land/x/djwt/create.ts