Code Monkey home page Code Monkey logo

denon's Introduction



Denon Stars Denon Workflows Denon Dependencies Denon Releases Denon Supported Version Denon Chat Denon License


denon is the deno replacement for nodemon providing a feature packed, highly configurable and easy to use experience.

denon does not require any additional changes to your code or method of development. denon is a replacement wrapper for deno. To use denon,replace the word deno on the command line when executing your script.



Features

Denon provides most of the features you would expect of a file watcher and more.

  • Automatically restart your deno projects
  • Drop-in replacement for deno executable
  • Extensive configuration options with script support
  • Configurable file watcher with support for filesystem events and directory walking
  • Ignoring specific files or directories with glob patterns
  • Not limited to deno projects with a powerful script configuration

Install

To install denon simply enter the following into a terminal:

deno.land

deno install -qAf --unstable https://deno.land/x/denon/denon.ts

nest.land

deno install -qAf --unstable https://x.nest.land/denon/denon.ts

⚠️ Make sure you are using deno version ^1.6.0 to install this executable. You can upgrade running deno upgrade.

Usage

denon wraps your application, so you can pass all the arguments you would normally pass to your app:

denon run app.ts

you can pass arguments to deno:

denon run --allow-env app.ts

and even to your application:

denon run --allow-env app.ts --arg-for-my-app

you can run scripts declared in config:

denon [script name]

and you can see which scripts are available in your config:

denon

to see what else you can do with deno CLI use the help flag:

denon --help

Configuration

denon is designed to be simple but also extremely configurable to fit your project needs. It supports both json and yaml for the configuration file. The configuration options in yaml is the same as json making it compatible.

to create a basic configuration in the root directory of your project file you can run:

denon --init

this will create a basic scripts.json file:

{
  "scripts": {
    "start": "app.js"
  }
}

you can also initialize from a custom template (see src/templates.ts file for all the available templates)

denon --init typescript

JSON config (scripts.json template)

Denon configuration can be provided as a JSON file:

{
  // optional but highly recommended
  "$schema": "https://deno.land/x/denon/schema.json",

  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "run my app.ts file"
    }
  }
}

JSON Schema

You can use a JSON schema to have type checking on your configuration. Simply add:

{
  "$schema": "https://deno.land/x/denon/schema.json",
  "scripts": {
    /* */
  }
}

YAML Configuration (scripts.yml template)

Denon configuration can be provided as a YAML file:

scripts:
  start:
    cmd: "deno run app.ts"
    desc: "run my app.ts file"

Typescript config (scripts.config.ts template)

Denon configuration can be provided as a .config.ts file:

import type { DenonConfig } from "https://deno.land/x/denon/mod.ts";

const config: DenonConfig = {
  scripts: {
    start: {
      cmd: "deno run app.ts",
      desc: "run my app.ts file",
    },
  },
};

export default config;

You can use a typescript configuration file to have programmable configuration based on your environment (for example loading a .env file):

import { DenonConfig } from "https://deno.land/x/denon/mod.ts";
import { config as env } from "https://deno.land/x/dotenv/mod.ts";

const config: DenonConfig = {
  scripts: {
    // same as json configuration
    start: {
      cmd: "app.js",
      desc: "Run my webserver",
      env: env(),
    },
  },
};

export default config;

Available options

denon takes inspiration from the awesome velociraptor module in the way it handles scripts.

Scripts

Scripts are declared inside the scripts object and are identified by a name:

{
  "scripts": {
    // they all resolve to `deno run app.ts` when you run `denon start`
    "start": "app.ts",
    // OR
    "start": "run app.ts",
    // OR
    "start": "deno run app.ts"
  }
}

Scripts can also be defined by a complex object:

{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      // with an optional description that
      // is shown when you run `denon` to list
      // all the scripts
      "desc": "Run the main server.",

      // available options...
      // they are described in the next paragraph
      "allow": ["env", "write"],
      "unstable": true
      // running `denon start` will resolve in
      // deno run --allow-env --allow-write --unstable app.ts
    }
  }
}

Script Options

Options can be script specific or be declared as global in the root of the config file.

Environment variables

Environment variables can be provided as an object and are passed directly to the child process.

{
  // globally applied to all scripts
  "env": {
    "TOKEN": "SUPER SECRET TOKEN"
  },

  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "env": {
        "PORT": 3000
      }
    }
  }
}

Permissions

Permission can be granted to child processes. You can provide specific permissions for each script, but you can also declare permissions globally, following the same format.

{
  // globally applied to all scripts
  // as object ...
  "allow": {
    "read": "/etc,/tmp", // --allow-read=/etc,/tmp
    "env": true // --allow-env
  },
  // ... or as array
  "allow": [
    "run", // --allow-run
    "net" // --allow-net
  ],

  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      // specific for a single script
      // as object ...
      "allow": {
        "read": "/etc,/tmp", // --allow-read=/etc,/tmp
        "env": true // --allow-env
      },
      // ... or as array
      "allow": [
        "run", // --allow-run
        "net" // --allow-net
      ]
    }
  }
}

File watching

While file watching is a core feature of denon you always have the option of disabling file watching and run a script only once:

{
  // globally applied to all scripts
  // now denon will essentialy be a script runner
  "watch": false,

  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      // you can still enable watch on a script-by-script basis
      "watch": true
    }
  }
}

Import Map

Load import map file. Take a look a at the official docs for additional info.

⚠️ This feature in unstable in the current version of the deno executable.

{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "importMap": "importmap.json"
    }
  }
}

TS config

Load tsconfig.json configuration file:

{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "tsconfig": "tsconfig.json"
    }
  }
}

Unstable

Enable if the script is using unstable features of deno stdlib:

{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "unstable": true
    }
  }
}

Inspect and InspectBrk

Activate inspector on host:port. If inspectBrk is used the executions breaks at the start of the user script:

{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "inspect": "127.0.0.1:9229",
      // OR
      "inspectBrk": "127.0.0.1:9229"
    }
  }
}

Lockfile

Check the specified lock file:

{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "lock": "lock.json"
    }
  }
}

Cert

Load certificate authority from PEM encoded file:

{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "cert": "cert.pem"
    }
  }
}

Log

Set log level: (possible values: debug, info)

{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "log": "debug" // or "info"
    }
  }
}

Watcher

File watcher options:

{
  "scripts": {
    /* */
  },

  "watcher": {
    // The number of milliseconds after the last change.
    "interval": 350,
    // The file extensions that it will scan for.
    "exts": ["js", "jsx", "ts", "tsx", "json"],
    // The globs that it will scan for.
    "match": ["**/*.*"],
    // The globs that it will not scan for.
    "skip": ["*/.git/*"],
    // Use the legacy file monitoring algorithm. (walking)
    "legacy": false
  }
}

Logger

Internal logger options:

{
  "scripts": {
    /* */
  },

  "logger": {
    // Clear screen after every restart.
    "fullscreen": false,
    // Output only errors
    "quiet": false,
    // Output debug messages
    "debug": true
  }
}

Supporters

Huge thanks to all our amazing supporters ❤️


Luca Casonato

Denoland

Other

FAQ / Troubleshooting

  • Command not found error

    This probably means that the executable path of your os does not include the .deno/bin directory, where denon will be installed.

    To fix this you must update your $PATH:

    echo 'export PATH="$HOME/.deno/bin:$PATH"' >> ~/.bashrc

    as mentioned in the deno manual.

Contribution

Pull request, issues and feedback are very welcome. Code style is formatted with deno fmt and commit messages are done following Conventional Commits spec.

Licence

Copyright 2020-2021, the denosaurs team. All rights reserved. MIT license.

denon's People

Contributors

a2-nier avatar brandonpsmith avatar codacy-badger avatar eliassjogreen avatar femave avatar freshfish70 avatar hong4rc avatar kamekyame avatar kylejune avatar leonelv avatar littledivy avatar mustachedninja avatar neale-forrest avatar nnmrts avatar notfilippo avatar olaven avatar pabloszx avatar pavelflegr avatar qu4k avatar ronhippler avatar t8 avatar taiprogramer avatar u-ways avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

denon's Issues

🐞 Recommended install steps fail with 16 errors

The recommended install steps on the README fail with 16 type errors.

deno install denon https://deno.land/x/denon/denon.ts --allow-read --allow-run --allow-net

It appears Deno install now has stricter TypeScript configuration;

deno --version
deno 0.36.0
v8 8.1.310
typescript 3.8.3

v2.0.0 not working

Please see attached screenshots.

If I use denon --allow-net run index.js as per the README then I get a crash. If I use denon run --allow-net index.js it seems to work, but when I update the file nothing happens.

deno 1.0.2

Screenshot from 2020-05-23 11-11-55
Screenshot from 2020-05-23 11-12-28

Cannot find name 'env' in denon.config.ts

Describe the bug

As screenshots below:

Configuration or Project

import { DenonConfig } from "https://deno.land/x/denon/mod.ts"
export { config as env } from "https://deno.land/x/dotenv/mod.ts"

const config: DenonConfig = {
  env: env(), // Cannot find name 'env'
  scripts: {
    start: {
      cmd: "deno run src/server.ts",
      desc: "start from server.ts file",
      watch: true,
      env: {
        PORT: Deno.env.get('PORT') || "8080",
      },
      allow: [
        "env",
        "net",
        "read",
        "write",
        "plugin",
      ],
      unstable: true
    },
  },
  logger: {
    debug: true,
  },
  watcher: {
    exts: ["ts", "json", "ini"],
    skip: ["super_duper_secret/*"],
  },
}

export default config

Screenshots

Setup

  • OS: (e.g. macOS, windows, linux) MacOS
  • Deno version: (deno version) 1.0.5
  • Denon version: (denon --version) v2.2.0

Additional context

Why denon --version need to compile denon.config.ts instead of return version number directly?

Can't find scripts

Denon can't see scripts property in denon.config.ts.

To Reproduce

// denon.config.ts
import { DenonConfig } from "https://deno.land/x/denon/mod.ts";

const config: DenonConfig = {
  scripts: {
    build: {
      cmd: "build.ts",
      desc: "run my build.ts file",
    },
  },
};
export default config;

run denon to view scripts
output is

[denon] v2.1.0
[denon] It looks like you don't have any scripts...
[denon] You can add scripts to your `denon.config.ts` file. Check the docs.

Expected behavior
denon should list build as a script

Setup

  • OS: Windows
  • Deno version: 1.0.4
  • Denon version: 2.1.0

Inspect Config Doc is Incorrect

The documentation outlines you can use inspect in your config:

"inspect": "localhost:1234"

But Deno is saying localhost is not a valid host to use. If we switch localhost with 127.0.0.1 (or similar), it works:

"inspect": "127.0.0.1:1234"

How To Replicate
Add "inspect": "localhost:9229", to a script in your config and run

Deleted path

If a path currently being watched is deleted the following error is thrown:

error: Uncaught NotFound: The system cannot find the path specified. (os error 3)
► $deno$/dispatch_json.ts:40:11
    at DenoError ($deno$/errors.ts:20:5)
    at unwrapResponse ($deno$/dispatch_json.ts:40:11)
    at sendAsync ($deno$/dispatch_json.ts:91:10)

A nicer exception should be thrown by the watcher and cli should (probably) be able to handle it.

Can not install

Administrator@TAIDEPTRAI-PC MINGW64 /d/Code/hello-deno
$ deno install --unstable --allow-read --allow-run -f https://deno.land/x/denon/denon.ts
Download https://deno.land/x/denon/denon.ts
Compile https://deno.land/x/denon/denon.ts
Download https://deno.land/x/denon/deps.ts
Download https://deno.land/x/denon/cli.ts
Download https://deno.land/x/denon/denon_config.ts
Download https://deno.land/x/denon/log.ts
Download https://deno.land/x/denon/watcher.ts
Download https://deno.land/[email protected]/flags/mod.ts
Download https://deno.land/[email protected]/fs/mod.ts
Download https://deno.land/[email protected]/path/mod.ts
Download https://deno.land/[email protected]/async/mod.ts
Download https://deno.land/[email protected]/fmt/mod.ts
Download https://deno.land/[email protected]/permissions/mod.ts
Download https://deno.land/[email protected]/testing/asserts.ts
Download https://deno.land/[email protected]/fmt/colors.ts
Download https://deno.land/[email protected]/testing/diff.ts
Download https://deno.land/[email protected]/fs/empty_dir.ts
Download https://deno.land/[email protected]/fs/ensure_dir.ts
Download https://deno.land/[email protected]/fs/ensure_file.ts
Download https://deno.land/[email protected]/fs/ensure_link.ts
Download https://deno.land/[email protected]/fs/ensure_symlink.ts
Download https://deno.land/[email protected]/fs/exists.ts
Download https://deno.land/[email protected]/fs/expand_glob.ts
Download https://deno.land/[email protected]/fs/move.ts
Download https://deno.land/[email protected]/fs/copy.ts
Download https://deno.land/[email protected]/fs/read_file_str.ts
Download https://deno.land/[email protected]/fs/write_file_str.ts
Download https://deno.land/[email protected]/fs/read_json.ts
Download https://deno.land/[email protected]/fs/write_json.ts
Download https://deno.land/[email protected]/fs/walk.ts
Download https://deno.land/[email protected]/fs/eol.ts
Download https://deno.land/[email protected]/path/win32.ts
Download https://deno.land/[email protected]/path/posix.ts
Download https://deno.land/[email protected]/path/common.ts
Download https://deno.land/[email protected]/path/separator.ts
Download https://deno.land/[email protected]/path/interface.ts
Download https://deno.land/[email protected]/path/glob.ts
Download https://deno.land/[email protected]/path/_constants.ts
Download https://deno.land/[email protected]/path/_util.ts
Download https://deno.land/[email protected]/path/_globrex.ts
Download https://deno.land/[email protected]/fs/_util.ts
Download https://deno.land/[email protected]/async/deferred.ts
Download https://deno.land/[email protected]/async/delay.ts
Download https://deno.land/[email protected]/async/mux_async_iterator.ts
Download https://deno.land/[email protected]/fmt/sprintf.ts
error: TS2322 [ERROR]: Type 'string' is not assignable to type 'boolean'.
  return srcArray.reduce(
  
    at https://deno.land/[email protected]/fs/_util.ts:20:3

Plugins

Once events are implemented a use of them could be for plugins. These would be written in a specific denon plugin configuration file with only the events. These plugins could perhaps be written directly in deno and imported as such with #23. The plugins should be imported in the denonrc configuration files by an URL that extends the current configuration file with the event specific commands of the plugin.

An example denon plugin:

{
	"events": {
		"restart": "do live reload"
	}
}

The plugin would be imported like the following:

{
	"plugins": [
		"https://example.com/live_reload.json"
	]
}

Installation error on Windows/WSL

Hey guys, i have an issue while installing denon. I installed deno (v1.0.1) some minutes ago and now i've tried to install denon. I get this error on Windows and Windows WSL Ubuntu:

....
Compile https://deno.land/x/denon/denon.ts
error: TS2345 [ERROR]: Argument of type '"file" | "dir" | "symlink" | undefined' is not assignable to parameter of type 'SymlinkOptions | undefined'.
Type '"file"' is not assignable to type 'SymlinkOptions | undefined'.
await Deno.symlink(originSrcFilePath, dest, type);
~~~~
at https://deno.land/[email protected]/fs/copy.ts:114:47

TS2345 [ERROR]: Argument of type '"file" | "dir" | "symlink" | undefined' is not assignable to parameter of type 'SymlinkOptions | undefined'.
Type '"file"' is not assignable to type 'SymlinkOptions | undefined'.
Deno.symlinkSync(originSrcFilePath, dest, type);
~~~~
at https://deno.land/[email protected]/fs/copy.ts:132:45

TS2345 [ERROR]: Argument of type '"file" | "dir" | "symlink" | undefined' is not assignable to parameter of type 'SymlinkOptions | undefined'.
Type '"file"' is not assignable to type 'SymlinkOptions | undefined'.
await Deno.symlink(src, dest, srcFilePathType);
~~~~~~~~~~~~~~~
at https://deno.land/[email protected]/fs/ensure_symlink.ts:31:33

TS2345 [ERROR]: Argument of type '"file" | "dir" | "symlink" | undefined' is not assignable to parameter of type 'SymlinkOptions | undefined'.
Type '"file"' is not assignable to type 'SymlinkOptions | undefined'.
Deno.symlinkSync(src, dest, srcFilePathType);
~~~~~~~~~~~~~~~
at https://deno.land/[email protected]/fs/ensure_symlink.ts:58:31

Found 4 errors.

deno.json match subdirectory

Describe the bug
Specifying directory in match section of deno.json does not seem to have an effect.

To Reproduce
Add:
"match": [
".",
"./client/*"
],
to deno.json
start denon using: denon run --allow-read --allow-net server.ts
Change any files in the ./client/ directory but deno does not re-start.

Expected behavior
deno should restart when a file in ./client/ directory is changed.

Configuration or Project
{ "$schema": "https://deno.land/x/denon/schema.json", "scripts": { "start": { "cmd": "server.ts", "desc": "Run the main server.", "allow": [ "env", "net", "write" ], "unstable": true } }, "watcher": { "interval": 350, "exts": [ "jsx", "tsx", "ts", "js", "json", "html" ], "match": [ "*.*", "./client/*" ], "skip": [ "*/.git/*" ], "legacy": false } }

Setup

  • OS: Ubuntu 20.04 on WSL2
  • Deno version: 1.0.4
  • Denon version: 2.0.2

Tests not running anymore?

Just updated, and it seems deno test is not run anymore, and as mentioned here #50 it's not possible to have &/&& to run multiple commands one after another?

Maybe adding a "test" to a scripts-object would be useful. (this has been an option before i updated though it was in the main config; seems like it isn't mentioned in the README anymore, has it been removed?)

Support for sequential scripts

I am using denon inside a Docker container build with the hayd deno image and would like to support file watching/restart that rebundles my client scripts then runs server.ts... however, I don't believe I am able to do this without passing multiple cmds into my denon.json script... If I use multiple scripts, denon hangs on the first one called, and if I pre bundle, then I am only getting file watching/restart on my server-side code.

Support for outputting the bundle to a file

Deno will create an executable file with e.g. deno bundle src.ts > dist.ts. It looks like this package currently supports bundling, but not really outputting the bundle to a file.

Deno requests network access. Grant?

Describe the bug
With each run of denon, I get this question:

⚠️ Deno requests network access. Grant? [g/d (g = grant, d = deny)]

To Reproduce
Steps to reproduce the behavior:
1. denon --allow-net

Expected behavior
--allow-net should avoid this question

Setup

  • OS: Ubuntu 20.04, WSL2
  • Deno version: 1.1.1
  • Denon version: 2.2.0

Watch Is Not An Option

In the documentation, it mentions watch can be used for an option in the allow property of a script which I don't believe is a supported option for Deno, and if used, errors:

Denon Config

// denon.json
{
  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",
      "allow": [
        "env",
        "net",
        "read",
        "write",
        "run"
      ],
      "inspect": "localhost:9229",
      "log": "debug"
    }
  },
  "watcher": {
    "interval": 350,
    "exts": ["js", "ts", "json"],
    "match": ["*.*"],
    "skip": [".git/*"],
    "legacy": false
  },
  "logger": {
    "fullscreen": false,
    "quiet": false,
    "debug": true
  }
}

Command Ran

// Note i haven't installed it - personal preference
deno run --unstable --allow-read --allow-run https://deno.land/x/denon/denon.ts start

Error

$ deno run --unstable --allow-read --allow-run https://deno.land/x/denon/denon.ts start
[denon] v2.0.2
[denon] watching path(s): *.*
[denon] watching extensions: js,ts,json
[denon] starting `deno run --allow-env --allow-net --allow-read --allow-write --allow-run --allow-watch --log-level debug --inspect=localhost:9229 app.ts`
 S: starting process with pid 10614
 M: monitoring status of process with pid 10614
error: Found argument '--allow-watch' which wasn't expected, or isn't valid in this context
        Did you mean --allow-write?

USAGE:
    deno run <SCRIPT_ARG>... --allow-env --allow-net=<allow-net> --allow-read=<allow-read> --allow-run --allow-write=<allow-write>

For more information try --help
 M: got status of process with pid 10614
 M: process with pid 10614 exited on its own
[denon] app crashed - waiting for file changes before starting ...

denon [script name] doesn't kill app on reload

I have a simple web server application running with oak. When I use the command denon run --allow-net app.ts the auto reload successfully kill the webserver on each reload.

But when I use the denon dev command and using the denon.json file, the application isn't killed on each reload. For example, if I run the webserver on 8080 port, then change it to 8081 then save, I end up with 2 webserver. If I doesn't change the port between two save, I hand up with an error saying one app already use this port.

Here is my denon.json file
01

And my app.ts file
02

typo in scripts.ts | inspect / inspect-brk

Hello :)
there is an error with inspect and inspect-brk in scripts config

$ denon start
[denon] v2.0.0
[denon] starting `deno run --allow-all --config tsconfig.json --inspect=localhost:9229} src/main.ts`
error: Invalid value for '--inspect=<HOST:PORT>': invalid IP address syntax

there is additional braces at end of pushed strings

flags.push(`--inspect=${options.inspect}}`);

flags.push(`--inspect-brk=${options.inspectBrk}}`);

Use from code

Denon is currently easiest used with a config file but should be easier to use from code. This would allow for more programmatically assigned configuration options, etc. Another perk of this could perhaps be easier use of events.

[doc] Clarify permissions format

In README#permissions, it shows this example:

Permission can be granted to child processes.

{
  // globally applied to all scripts
  "allow": {
    "read": "/etc", // --allow-read=/etc
    "env": true     // --allow-env
  },

  "scripts": {
    "start": {
      "cmd": "deno run app.ts",
      "desc": "Run the main server.",

      "allow": [
        "run", // --allow-run
        "net", // --allow-net
      ]
    }
  }
}

but it doesn't make clear which format/s is/are acceptable. For example:

  1. Does the top-level allow key accept an array of boolean values in addition to the object format?
  2. Does each script's allow key accept an object value (like the top-level example) with keys' values corresponding to granular permission values?
  3. How does the object format work if a permission has multiple values? Should an array be supplied, like so?
{
  "allow": {
    "read": [
      "/etc",
      "/opt"
    ], // --allow-read=/etc,/opt
    "env": true // --allow-env
  }
}

Issue when running!

I ahve imports map and custom tsconfig.

I usually run this
deno run -A --importmap=imports.json --config ./tsconfig.json index.ts

I have .denonrc.json

{
  "files": [
    "index.ts",
    "src/**/*.ts"
  ],
  "quiet": false,
  "debug": true,
  "fullscreen": true,
  "extensions": [
    "js",
    "ts",
    "json"
  ],
  "match": [
    "*.ts"
  ],
  "skip": [
    "*_test.ts",
    "*_test.js"
  ],
  "interval": 500,
  "watch": [
    "src/"
  ],
  "execute": {
    ".js": ["deno", "run"],
    ".ts": ["deno", "run"]
  }
}

When i run this denon -A --config .denonrc.json --importmap=imports.json index.ts, i have following error error: Uncaught #<Object>

Events

Emit events that trigger certain scripts or commands, this would allow for live-reload of websites, linting, formatting etc. A good inspiration for events would be nodemon events. The events would also not block the normal function or executors of denon and should probably be called before the executors are called.

I propose that the bare minimum events would be:

  • start
  • restart
  • exit

And would be specified in the config like the following:

"events": {
	"start": "deno run ./setup.ts",
	"restart": "deno fmt",
	"exit": "deno run ./finish.ts"
}

Not Watching Files

Hey,

With the --watch flag or options present, denon doesn't seem to watch for changes. I assume i can run a a Deno app with Denon, make a change to the file, and it would show the new change without restarting the server.

My Setup

  • Windows 10
  • Deno application using Drash, with Denon
  • Deno Version:
PS Some\Path\To\My\Project> deno --version
deno 0.33.0
v8 8.1.108
typescript 3.7.2

Command
I can running the following command to use denon to initiate the server:

Note: the below command is the way it is because after installing denon, the command for it isn't working and i can't be bothered to look into it yet

deno --allow-net --allow-read --allow-run --allow-env --allow-write https://deno.land/x/denon/denon.ts

Config

# .denonrc
{
    "files": [
        "app.ts"
    ],
    "quiet": false,
    "debug": true,
    "fullscreen": true,
    "extensions": [
        "js",
        "ts"
    ],
    "match": [
        "*.ts"
    ],
    "skip": [
        "*_test.ts",
        "*_test.js"
    ],
    "interval": 500,
    "watch": [
        "./"
    ],
    "execute": {
        ".ts": ["deno", "--allow-read", "--allow-env", "--allow-write", "--allow-run", "--allow-net"]
    }
}

Summary
Denon runs the app fine, it starts the correct file, and i can view the project in the browser, but watch doesn't 'seem' o be working, for example, i have a console.log('Hello'), i run the app, change the log text to console.log('Hello world'), but still see "Hello" and not "Hello World"

Git Bash denon: command not found

Administrator@TAIDEPTRAI-PC MINGW64 ~
$ deno install --allow-read --allow-run --allow-write -f --unstable https://deno.land/x/denon/denon.ts
Download https://deno.land/x/denon/denon.ts
Download https://deno.land/x/denon/deps.ts
...
Compile https://deno.land/x/denon/denon.ts
✅ Successfully installed denon
C:\Users\Administrator\.deno\bin\denon.cmd

Administrator@TAIDEPTRAI-PC MINGW64 ~
$ denon
bash: denon: command not found

Administrator@TAIDEPTRAI-PC MINGW64 ~
$

After this.
Close and open Git bash. Still not working.
Powershell works well.

denon upgrade

A denon upgrade command as an alias for deno install denon -f --allow-read --allow-run https://deno.land/x/denon/denon.ts would be useful. denon upgrade could be able to select version if entered otherwise it would just use latest. This would probably be done with denon upgrade v1.6.0

Uncaught NotFound: No such file or directory (os error 2)

Tried to install as per the docs, didn't work, said:

Add /Users/danknights/.deno/bin to PATH export PATH="/Users/danknights/.deno/bin:$PATH"

Added the path and tried again, the above message went away, tried denon init and got this:

[denon] v2.0.2
[denon] watching path(s): *.*
[denon] watching extensions: ts,js,json
[denon] starting `init`
error: Uncaught NotFound: No such file or directory (os error 2)
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at Object.run ($deno$/ops/process.ts:41:10)
    at Object.run ($deno$/process.ts:118:15)
    at Runner.execute (https://deno.land/x/denon/src/runner.ts:117:17)
    at Daemon.start (https://deno.land/x/denon/src/daemon.ts:45:40)
    at Daemon.iterate (https://deno.land/x/denon/src/daemon.ts:122:10)
    at iterate.next (<anonymous>)
    at https://deno.land/x/denon/denon.ts:144:18

Is this a bug or am I missing something?

denon test and fmt broken

After updating deno and denon, denon test and fmt stopped working for me. I would usually just run denon test and it would run all my test files once I made a modification. With the current version, it just tells me I need to specify a file and if I do it appears to just run the file without running the tests. deno test and deno test binary_heap_test.ts both work but do not work with denon test.

$ deno install -Af --unstable https://deno.land/x/denon/denon.ts
Download https://deno.land/x/denon/denon.ts
Compile https://deno.land/x/denon/denon.ts
Download https://deno.land/x/denon/deps.ts
Download https://deno.land/x/denon/cli.ts
Download https://deno.land/x/denon/denon_config.ts
Download https://deno.land/x/denon/log.ts
Download https://deno.land/x/denon/watcher.ts
Download https://deno.land/[email protected]/flags/mod.ts
Download https://deno.land/[email protected]/fs/mod.ts
Download https://deno.land/[email protected]/path/mod.ts
Download https://deno.land/[email protected]/async/mod.ts
Download https://deno.land/[email protected]/fmt/mod.ts
Download https://deno.land/[email protected]/permissions/mod.ts
Download https://deno.land/[email protected]/testing/asserts.ts
Download https://deno.land/[email protected]/fmt/colors.ts
Download https://deno.land/[email protected]/testing/diff.ts
Download https://deno.land/[email protected]/fs/empty_dir.ts
Download https://deno.land/[email protected]/fs/ensure_dir.ts
Download https://deno.land/[email protected]/fs/ensure_file.ts
Download https://deno.land/[email protected]/fs/ensure_link.ts
Download https://deno.land/[email protected]/fs/ensure_symlink.ts
Download https://deno.land/[email protected]/fs/exists.ts
Download https://deno.land/[email protected]/fs/expand_glob.ts
Download https://deno.land/[email protected]/fs/move.ts
Download https://deno.land/[email protected]/fs/copy.ts
Download https://deno.land/[email protected]/fs/read_file_str.ts
Download https://deno.land/[email protected]/fs/write_file_str.ts
Download https://deno.land/[email protected]/fs/read_json.ts
Download https://deno.land/[email protected]/fs/write_json.ts
Download https://deno.land/[email protected]/fs/walk.ts
Download https://deno.land/[email protected]/fs/eol.ts
Download https://deno.land/[email protected]/path/win32.ts
Download https://deno.land/[email protected]/path/posix.ts
Download https://deno.land/[email protected]/path/common.ts
Download https://deno.land/[email protected]/path/separator.ts
Download https://deno.land/[email protected]/path/interface.ts
Download https://deno.land/[email protected]/path/glob.ts
Download https://deno.land/[email protected]/path/_constants.ts
Download https://deno.land/[email protected]/path/_util.ts
Download https://deno.land/[email protected]/path/_globrex.ts
Download https://deno.land/[email protected]/fs/_util.ts
Download https://deno.land/[email protected]/async/deferred.ts
Download https://deno.land/[email protected]/async/delay.ts
Download https://deno.land/[email protected]/async/mux_async_iterator.ts
Download https://deno.land/[email protected]/fmt/sprintf.ts
✅ Successfully installed denon
/home/kyle/.deno/bin/denon
$ denon test
[DENON] Could not start denon because no file was provided, use -h for help
$ denon test binary_heap_test.ts
[DENON] Watching /mnt/c/Users/kylej/projects/deno/collections
[DENON] Detected 1 change. Rerunning...
[DENON] Detected 1 change. Rerunning...

Absolute path monitoring

Passing an absolute path on Linux to the match property doesn't work. It will ignore file changes in this path:

  "watcher": {
    "interval": 350,
    "exts": ["ts", "html"],
    "match": ["/home/user/javascript/myWebComponents/**/*.*"],
    "skip": ["*/.git/*"]
  }

It would make things easier if the watcher would accept absolute paths.

Feature Request: Implement Test Directories

What

Add the ability to select only certain directories for running tests

Why

Currently when using the flag or config --test denon runs deno test without an option to select which directories to look and run tests in.

Deno provides this option. ie:

$ deno test src/fetch_test.ts src/signal_test.ts

Giving this ability would allow us to have other folders and files in our root directory which are ignored.

Related files

https://github.com/eliassjogreen/denon/blob/a2d386958a41d21b94875b9ab11b0be2673e502c/denon.ts#L73
image
https://github.com/eliassjogreen/denon/blob/a2d386958a41d21b94875b9ab11b0be2673e502c/denon.ts#L158
image

https://github.com/eliassjogreen/denon/blob/a2d386958a41d21b94875b9ab11b0be2673e502c/cli.ts#L12

Suggested Solution

To implement this:

  1. add another argument to cli.ts deno_test_args.
  2. Remove adding working directory automatically to watch paths
  3. Create config.test_watch variable in denon.ts and use it here:
    https://github.com/eliassjogreen/denon/blob/a2d386958a41d21b94875b9ab11b0be2673e502c/denon.ts#L158
  4. Add tests

Background - How I found this issue

I had to use a local node_modules folder in a project as I can't quite make the shift over to deno completely yet. This meant that the test runner as it is traversed the node_modules directory and tried to run any tests it found there. Causing it to fail.
I solved this by building my own denon by removing the addition of the root directory and adding the ...config.watch argument to the end of the executor function shown above.

If you agree with the approach above I don't mind implementing this. Let me know.

Allow flag type warning

Describe the bug
I used the allow flag to specification (see the documentation : here), but the linter prints warning on the boolean type for the allow flag"env": true due to deno flag type (Array<String> | Object --> schema.json )

To Reproduce
Steps to reproduce the behavior:
1. Go to denon.json
2. Scroll down to env: true
3. See the warning: Incorrect type. Expected "string".

Expected behavior
No linter warning

Configuration or Project

{
  "$schema": "https://deno.land/x/denon/schema.json",
  "allow": {
    "net": true, 
    "env": true, 
    "read": true, 
    "write": true, 
    "plugin": true
  },
  "unstable": true,
  "inspect": "127.0.0.1:9229",
  "scripts": {
    "start": {
      "cmd": "deno run index.ts",
      "desc": "run my deno server file",
      "lock": "lock.json"
    }
  }
}

Screenshots
If applicable, add screenshots to help explain your problem.

Setup

  • OS: macOS v10.15.5
  • Deno version: 1.1.1
  • Denon version: v2.1.0

Installation Error

Trying to install denon on my laptop using

deno install denon --allow-read --allow-run https://deno.land/x/denon/denon.ts 

But it yields this error

error TS2345: Argument of type '{ cmd: string[]; }' is not assignable to parameter of type 'RunOptions'.

Object literal may only specify known properties, and 'cmd' does not exist in type 'RunOptions'.

What could be the issue?

Error when installing

error: TS2345 [ERROR]: Argument of type '{ type: string; }' is not assignable to parameter of type 'string'.
await Deno.symlink(originSrcFilePath, dest, {

at https://deno.land/[email protected]/fs/copy.ts:117:49

TS2345 [ERROR]: Argument of type '{ type: string; }' is not assignable to parameter of type 'string'.
Deno.symlinkSync(originSrcFilePath, dest, {

at https://deno.land/[email protected]/fs/copy.ts:141:47

TS2345 [ERROR]: Argument of type '{ type: string; }' is not assignable to parameter of type 'string'.
await Deno.symlink(src, dest, {

at https://deno.land/[email protected]/fs/ensure_symlink.ts:33:35

TS2345 [ERROR]: Argument of type '{ type: string; }' is not assignable to parameter of type 'string'.
Deno.symlinkSync(src, dest, {

at https://deno.land/[email protected]/fs/ensure_symlink.ts:65:33

Found 4 errors.

i'm using xubuntu 20.04

deno_args are loaded empty from config file

Using a config file .denon.json with the content

{
    "files": [
        "src/main.ts"
    ],
    "quiet": false,
    "debug": true,
    "fullscreen": true,
    "extensions": [
        ".js",
        ".ts",
        ".json"
    ],
    "interval": 500,
    "watch": [
        "src"
    ],
    "execute": {
        ".js": [
            "deno",
            "run"
        ],
        ".ts": [
            "deno",
            "run"
        ]
    },
    "deno_args": [
        "--allow-net",
        "--allow-read",
        "--lock=lock.json",
        "--lock-write"
    ],
    "fmt": true,
    "test": true
}

when running denon --debugshow that the deno_args array is empty

[DENON] Debug enabled!
[DENON] Required permissions "read" and "run" granted
[DENON] Reading config from .denon | .denon.json | .denonrc | .denonrc.json
[DENON] Args: --debug
[DENON] Flags: {"debug":true,"help":false,"fullscreen":false,"quiet":false,"files":[],"runnerFlags":[],"deno_args":[],"fmt":false,"test":false}
[DENON] Config: {"files":["src/main.ts"],"quiet":false,"debug":true,"fullscreen":false,"extensions":[".js",".ts",".json"],"interval":500,"watch":["src"],**"deno_args":[],**"execute":{".js":["deno","run"],".ts":["deno","run"]},"fmt":false,"test":false}
[DENON] Files: /***/deno/deno-test/src/main.ts
[DENON] Paths: /***/deno/deno-test/src
[DENON] Running "deno run /***/deno/deno-test/src/main.ts"
[DENON] Creating watchers
[DENON] Creating watcher for paths "/***/deno/deno-test/src"
[DENON] Watching /***/deno/deno-test/src
error: Uncaught PermissionDenied: network access to "localhost:1234", run again with the --allow-net flag
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
    at Object.listen ($deno$/ops/net.ts:51:10)
    at listen ($deno$/net.ts:152:22)
    at Application.serve (server.ts:261:20)
    at Application.listen (application.ts:106:31)
    at startServer (file:///***/deno/deno-test/src/server.ts:19:13)
    at file:///***/deno/deno-test/src/main.ts:8:7

Seems like they get overwritten by the the default flags. applyIfDefined seems to do that.

denon v2.1.0 CLI commands errors

an issue while using denon CLI commands
im trying to run denon --init and it responds with an error

PS D:\deno\denon> denon --init
⚠️ Deno requests network access. Grant? [g/d (g = grant, d = deny)] g
[denon] fetching template from https://deno.land/x/[email protected]/templates/denon.json
[denon] denon.json is not a denon template. All templates are available on https://deno.land/x/[email protected]/templates/

and when i try to upgrade this error pops out

Screenshots
denon

Setup

  • OS: (windows,)
  • Deno version: (1.0.3)
  • Denon version: (V2.1.0)

0.31.0 support

Due to some breaking changes to deno 0.31.0 (denoland/deno#3722) denon no longer works. This is because the way it watches multiple paths in parallel is with worker blobs and the support for those were removed this release.

Trigger failsafe if many reloads are triggered

Not sure if this is the correct way to do it, but I wanted to save a cache script I could easily run.

"cache": {
      "desc": "Cache versions and update lock file",
      "cmd": "deno cache server.ts --lock-write",
      "lock": "./lock.json"
}

The result however when running denon cache is an endless loop instead of just executing it once, looks like this:

Skärmavbild 2020-05-29 kl  19 10 40

Now is this a bug or aren't you suppose to add and execute scripts in this way?

How to properly attach tsconfig.json?

Hello :)

files:
https://gist.github.com/Tnifey/5339e42b92348ab45dc96cca27ce9776

If i run deno run --config tsconfig.json test.ts
prints Decorator loaded [Function: Entity] without errors

but when I run denon

[DENON] Watching /mnt/s/test/test.ts, /mnt/s/test
Compile file:///mnt/s/test/test.ts
Decorator loaded [Function: Entity]
error: TS1219 [ERROR]: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' 
option in your 'tsconfig' or 'jsconfig' to remove this warning.
class Entity {
      ~~~~~~
    at file:///mnt/s/test/test.ts:8:7

prints error, like there is no tsconfig.json loaded but decorator is working

i tried to change "--config=tsconfig.json" in .denon.json to "--config tsconfig.json"
but it spits

error: Found argument '--config tsconfig.json' which wasn't expected, or isn't valid in this context
        Did you mean --config?

My question is how to properly attach tsconfig.json into .denon.json that it won't print any error?

Bad resource ID

This seems to happen a lot when I ctrl + s and the process restarts, any idea on why?

error: Uncaught BadResource: Bad resource ID
    at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
    at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
    at async runStatus ($deno$/process.ts:22:15)
    at async Daemon.monitor (https://deno.land/x/denon/src/daemon.ts:63:15)

My .denon.json file:

{
  "scripts": {
    "start": {
      "cmd": "deno run ./src/index.ts",
      "desc": "Starting up Client...",
      "allow": [
        "env", "hrtime", "read", "net"
      ],
      "unstable": true
    },
    "test": {
      "cmd": "deno test tests/tests.ts",
      "desc": "Running tests...",
      "allow": [
        "env", "read"
      ]
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.