Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BentoumiTech/denox
Script runner and workspace configuration for Deno
https://github.com/BentoumiTech/denox
cli deno denoland javascript script-runner typescript
Last synced: 3 months ago
JSON representation
Script runner and workspace configuration for Deno
- Host: GitHub
- URL: https://github.com/BentoumiTech/denox
- Owner: BentoumiTech
- License: mit
- Created: 2020-05-13T05:50:45.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-05T07:15:18.000Z (over 2 years ago)
- Last Synced: 2024-04-27T05:37:23.620Z (7 months ago)
- Topics: cli, deno, denoland, javascript, script-runner, typescript
- Language: TypeScript
- Homepage:
- Size: 223 KB
- Stars: 138
- Watchers: 3
- Forks: 13
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-deno-cn - @BentoumiTech/denox
- awesome-deno - denox - Like packages.json scripts, but for Deno with permissions support.![GitHub stars](https://img.shields.io/github/stars/BentoumiTech/denox?style=plastic) (Tools / Online Playgrounds)
- awesome-deno - denox - Like packages.json scripts, but for Deno with permissions support. (Tools / XML)
README
Install/Upgrade •
Overview •
Usage •
Getting started •
Contributing
## Install/Upgrade
Prerequisites: [Deno](https://github.com/denoland/deno_install) (>=1.0.0)
```bash
$ deno install -Af -n denox https://denopkg.com/BentoumiTech/denox/denox.ts
```## Overview
DenoX is a cross platform script runner and workspace wrapper for Deno
Using DenoX, you can set up your workspace scripts permissions and options in declarative code.
In short, it allows you to to replace this:
```bash
$ deno run --allow-read --allow-write --allow-net main.ts
```with this:
```bash
$ denox run start
```- **DRY** Only write your permissions and options once.
- **Packaged** Your code can run on a different machine with a short single command `denox run start`
- **Cross Platform** DenoX support and is tested on Linux, Mac OS and Windows.
- **Extensible** :soon:## Usage
```bash
$ denox --help
denox v0.4.0Usage:
$ denox [options]Commands:
run [...args] Run a scriptFor more info, run any command with the `--help` flag:
$ denox run --helpOptions:
-h, --help Display this message
-v, --version Display version numberExamples:
denox run start
```## Getting Started
### `deno-workspace` file
Scripts and options need to be defined in a `deno-workspace` file at the root of your project.
DenoX supports YAML, JSON and typescript as format for `deno-workspace`.
In the following examples running `$ denox run start` will execute main.ts file with `example.com` networking permissions
#### YAML
`deno-workspace.yml`
```yaml
scripts:
start:
file: main.ts
deno_options:
allow-net: example.com
```#### JSON
`deno-workspace.json`
```json
{
"scripts": {
"start": {
"file": "main.ts",
"deno_options": {
"allow-net": "example.com"
}
}
}
}
```#### Typescript
`deno-workspace.ts`
```typescript
import { DenoWorkspace } from "https://denopkg.com/BentoumiTech/denox/src/interfaces.ts";const workspace: DenoWorkspace = {
"scripts": {
"start": {
"file": "main.ts",
"deno_options": {
"allow-net": "example.com"
}
},
},
};export { workspace };
```## Scripts
You can easily run scripts using denox by adding them to the "scripts" field in `deno-workspace` and run them with `denox run <script-name>`.
### Example:
```yaml
scripts:
# "denox run start" will execute main.ts with example.com networking permissions
start:
file: main.ts
deno_options:
allow-net: example.com
# "denox run develop" will execute main.ts with localhost networking permissions and source code cache reloaded
develop:
file: main.ts
deno_options:
allow-net: localhost
reload: true
v8-flags:
- --regexp-tier-up
- --adjust-os-scheduling-parameters true
```## Options
Scripts can be extended with options.
### deno_options:
Deno options will add the corresponding deno argument with it's value to the deno command.
It supports string, array of strings and boolean.
### Example:
```yaml
scripts:
# "denox run start" will execute "deno run --allow-net=example.com github.com --reload --allow-read=./files main.ts"
start:
file: main.ts
deno_options:
reload: true
allow-net:
- example.com
- github.com
allow-read: ./files
allow-write: false
```### Compatibility
It currently support all the options that are accepted by the `deno run` command. For more informations refer to `deno run --help`.
```
allow-all, allow-env, allow-hrtime, allow-net, allow-plugin, allow-read, allow-run,
allow-write, cached-only, cert, config, importmap, inspect, inspect-brk, lock, lock-write,
log-level, no-remote, quiet, reload, seed, unstable, v8-flags
```## Globals
Options added in "globals" field gets added to all scripts.
> Note: If a same option is set in a script and also set globally the script scoped value overwrite the global one
### Example:
```yaml
scripts:
# "denox run develop" inherit the --allow-read permission from the globals deno_options
# "deno run --all-read main.ts"
develop:
file: main.ts
globals:
deno_options:
allow-read: true
```## Contributing
Please take a look at our [contributing](./CONTRIBUTING.md) guidelines if you're interested in helping!