├── examples ├── .env ├── issue_101 │ ├── src │ │ └── foo.ts │ ├── main.ts │ └── scripts.json ├── issue_91 │ ├── src │ │ └── server │ │ │ ├── app.ts │ │ │ └── denon.json │ ├── .docker │ │ └── deno.dockerfile │ └── docker-compose.yml ├── watched.ini ├── super_duper_secret │ └── not_watched.ini ├── issue_49 │ ├── denon.json │ └── main.ts ├── denon.config.ts ├── oak.ts └── simple.ts ├── .github ├── FUNDING.yml ├── workflows │ ├── depsbot.yml │ └── checks.yml ├── ISSUE_TEMPLATE │ ├── feature-request.md │ └── bug-report.md └── CODE_OF_CONDUCT.md ├── docs ├── module.md ├── contributing.md ├── configuration │ ├── logger.md │ ├── watcher.md │ ├── templates.md │ └── script.md ├── sidebar.json ├── installation.md ├── usage.md └── home.md ├── scripts.yml ├── .gitignore ├── test_deps.ts ├── info.ts ├── mod.ts ├── src ├── closest.ts ├── merge.ts ├── templates.ts ├── watcher.test.ts ├── args.ts ├── scripts.test.ts ├── runner.test.ts ├── scripts.ts ├── runner.ts ├── daemon.ts ├── config.ts ├── watcher.ts └── cli.ts ├── egg.json ├── LICENSE ├── deps.ts ├── assets ├── example.cast ├── example.svg ├── denon.svg └── denon-horizontal.svg ├── denon.ts ├── schema.json ├── CHANGELOG.md └── README.md /examples/.env: -------------------------------------------------------------------------------- 1 | SECRET_ENV_VARIABLE=Deno + Denon = <3 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: denosaurs 2 | github: denosaurs 3 | -------------------------------------------------------------------------------- /examples/issue_101/src/foo.ts: -------------------------------------------------------------------------------- 1 | export const bar = "Hello from foo!"; 2 | -------------------------------------------------------------------------------- /examples/issue_91/src/server/app.ts: -------------------------------------------------------------------------------- 1 | // empty as it isnt required to have code 2 | -------------------------------------------------------------------------------- /examples/watched.ini: -------------------------------------------------------------------------------- 1 | [reload-me] 2 | msg: "Reload me I should affect process reloading!" -------------------------------------------------------------------------------- /docs/module.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Importing Denon 3 | --- 4 | 5 | :::caution Work in Progress ::: 6 | -------------------------------------------------------------------------------- /examples/super_duper_secret/not_watched.ini: -------------------------------------------------------------------------------- 1 | [reload-me] 2 | msg: "Reload me but I should not affect process reloading" -------------------------------------------------------------------------------- /examples/issue_101/main.ts: -------------------------------------------------------------------------------- 1 | import { bar } from "./src/foo.ts"; 2 | 3 | console.log("Hello from main!"); 4 | console.log(bar); 5 | -------------------------------------------------------------------------------- /scripts.yml: -------------------------------------------------------------------------------- 1 | scripts: 2 | test: 3 | - "deno fmt --check" 4 | - "deno lint --unstable" 5 | - "deno test --unstable -A" 6 | watch: false 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ide 2 | .idea 3 | .vscode 4 | workspace.code-workspace 5 | 6 | # testing directory 7 | testing/ 8 | issues/ 9 | 10 | # macOS files 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /test_deps.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license. 2 | 3 | // *_test.ts files 4 | export { 5 | assert, 6 | assertEquals, 7 | } from "https://deno.land/std@0.125.0/testing/asserts.ts"; 8 | -------------------------------------------------------------------------------- /examples/issue_49/denon.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://deno.land/x/denon/schema.json", 3 | "scripts": { 4 | "start": { 5 | "cmd": "deno run -A ./main.ts" 6 | } 7 | }, 8 | "logger": { 9 | "debug": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/issue_49/main.ts: -------------------------------------------------------------------------------- 1 | import { Application } from "https://deno.land/x/oak/mod.ts"; 2 | 3 | const app = new Application(); 4 | 5 | app.use((ctx) => { 6 | ctx.response.body = "Hello World!"; 7 | }); 8 | 9 | await app.listen({ port: 8080 }); 10 | -------------------------------------------------------------------------------- /info.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license. 2 | 3 | export const VERSION = "2.5.0"; 4 | export const BRANCH = "main"; 5 | // export const COMPAT: { [denon: string]: string[] } = { 6 | // "2.3.0": ["1.2.0"], 7 | // "2.3.1": ["1.2.0", "1.2.1", "1.2.2"], 8 | // }; 9 | -------------------------------------------------------------------------------- /mod.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license. 2 | 3 | export * from "./denon.ts"; 4 | export * from "./src/watcher.ts"; 5 | export * from "./src/runner.ts"; 6 | 7 | export { DEFAULT_DENON_CONFIG } from "./src/config.ts"; 8 | export type { DenonConfig } from "./src/config.ts"; 9 | -------------------------------------------------------------------------------- /examples/issue_101/scripts.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://deno.land/x/denon/schema.json", 3 | "scripts": { 4 | "start": { 5 | "cmd": "deno run ./main.ts" 6 | } 7 | }, 8 | "watcher": { 9 | "match": ["src/**/*.ts", "./main.ts"] 10 | }, 11 | "logger": { 12 | "debug": true, 13 | "fullscreen": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contributing 3 | --- 4 | 5 | Pull request, issues and feedback are very welcome. Code style is formatted with 6 | `deno fmt` and commit messages are done following 7 | [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec. 8 | 9 | ### Licence 10 | 11 | Copyright 2020-2021, the denosaurs team. All rights reserved. MIT license. 12 | -------------------------------------------------------------------------------- /docs/configuration/logger.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Logger Options 3 | --- 4 | 5 | Internal logger options: 6 | 7 | ```json 8 | { 9 | "scripts": { 10 | /* */ 11 | }, 12 | 13 | "logger": { 14 | // Clear screen after every restart. 15 | "fullscreen": false, 16 | // Output only errors 17 | "quiet": false, 18 | // Output debug messages 19 | "debug": true 20 | } 21 | } 22 | ``` 23 | -------------------------------------------------------------------------------- /examples/issue_91/.docker/deno.dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stable-slim 2 | 3 | RUN apt update -y \ 4 | && apt clean \ 5 | && apt install bash curl unzip -y 6 | 7 | RUN curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL=/usr/local sh -s v1.4.6 8 | RUN export DENO_INSTALL="/root/.local" 9 | RUN export PATH="$DENO_INSTALL/bin:$PATH" 10 | COPY . denon 11 | RUN deno install -qAfr --unstable denon/denon.ts 12 | -------------------------------------------------------------------------------- /examples/denon.config.ts: -------------------------------------------------------------------------------- 1 | import { DenonConfig } from "../src/config.ts"; 2 | 3 | const config: DenonConfig = { 4 | scripts: { 5 | app: { 6 | cmd: "oak.ts", 7 | desc: "Run oak instance", 8 | allow: ["env", "net"], 9 | env: { 10 | PORT: "9001", 11 | }, 12 | }, 13 | simple: { 14 | cmd: "simple.ts", 15 | desc: "Run main app", 16 | allow: ["env"], 17 | }, 18 | }, 19 | }; 20 | 21 | export default config; 22 | -------------------------------------------------------------------------------- /src/closest.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license. 2 | 3 | import { levenshtein } from "../deps.ts"; 4 | 5 | /** Returns the closest string in the array */ 6 | export function closest(word: string, words: string[]): string | undefined { 7 | if (words.length === 0) return; 8 | 9 | const dist = words.map((w) => levenshtein(word, w)); 10 | const index = dist.indexOf(Math.min(...dist)); 11 | 12 | return words[index]; 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/depsbot.yml: -------------------------------------------------------------------------------- 1 | name: depsbot 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | # schedule: 9 | # - cron: "0 0 */2 * *" 10 | 11 | jobs: 12 | run: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout Repository 16 | uses: actions/checkout@v2 17 | 18 | - name: Run depsbot 19 | uses: denosaurs/depsbot@master 20 | with: 21 | github_token: ${{ secrets.GITHUB_TOKEN }} 22 | -------------------------------------------------------------------------------- /examples/oak.ts: -------------------------------------------------------------------------------- 1 | import { Application } from "https://deno.land/x/oak/mod.ts"; 2 | import { green } from "https://deno.land/std/fmt/colors.ts"; 3 | 4 | const app = new Application(); 5 | 6 | const PORT = 8000; 7 | 8 | const port = Deno.env.get("PORT"); 9 | if (port) { 10 | PORT = Number.parseInt(port); 11 | } 12 | 13 | app.use((ctx) => { 14 | ctx.response.body = "Hello Denon!"; 15 | }); 16 | 17 | console.log("Webserver listening to", green(`:${PORT}`)); 18 | 19 | await app.listen({ port: PORT }); 20 | -------------------------------------------------------------------------------- /examples/issue_91/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | server: 5 | container_name: my_server 6 | build: 7 | context: ../../ 8 | dockerfile: examples/issue_91/.docker/deno.dockerfile 9 | volumes: 10 | - ./src/server:/var/www/server 11 | working_dir: /var/www/server 12 | ports: 13 | - "1667:1667" 14 | command: bash -c "/root/.deno/bin/denon start" 15 | networks: 16 | - my-app-network 17 | 18 | networks: 19 | my-app-network: 20 | driver: bridge -------------------------------------------------------------------------------- /examples/issue_91/src/server/denon.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": { 4 | "cmd": "deno run app.ts", 5 | "desc": "Run the server.", 6 | "allow": [ 7 | "env", 8 | "net", 9 | "read", 10 | "run" 11 | ] 12 | } 13 | }, 14 | "watcher": { 15 | "interval": 350, 16 | "exts": ["js", "ts", "json"], 17 | "match": ["**/*.*"], 18 | "legacy": false 19 | }, 20 | "logger": { 21 | "fullscreen": false, 22 | "quiet": false, 23 | "debug": true 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /egg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "denon", 3 | "description": "👀 Monitor any changes in you Deno application and automatically restart.", 4 | "repository": "https://github.com/denosaurs/denon.git", 5 | "unlisted": false, 6 | "version": "2.4.4", 7 | "files": [ 8 | "./assets/**/*", 9 | "./README.md", 10 | "./deps.ts", 11 | "./test_deps.ts", 12 | "./denon.ts", 13 | "./info.ts", 14 | "./scripts.yml", 15 | "./mod.ts", 16 | "./src/**/*", 17 | "./mod.ts" 18 | ], 19 | "ignore": [], 20 | "entry": "/mod.ts", 21 | "checkAll": true 22 | } 23 | -------------------------------------------------------------------------------- /examples/simple.ts: -------------------------------------------------------------------------------- 1 | import { green, red } from "https://deno.land/std/fmt/colors.ts"; 2 | import { delay } from "https://deno.land/std/async/delay.ts"; 3 | 4 | console.log(Deno.pid, green("New process, new Hello World!")); 5 | 6 | console.log( 7 | Deno.pid, 8 | green("env.SECRET_ENV_VARIABLE:"), 9 | Deno.env.get("SECRET_ENV_VARIABLE"), 10 | ); 11 | 12 | console.log(Deno.pid, green("args:"), Deno.args); 13 | 14 | let i = 50; 15 | 16 | while (i > 0) { 17 | await delay(1000); 18 | console.log(Deno.pid, red(`Execution #${i}!`)); 19 | 20 | if (--i % 10 === 0) { 21 | throw new Error("Oh no."); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /docs/configuration/watcher.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Watcher Options 3 | --- 4 | 5 | File watcher options: 6 | 7 | ```json 8 | { 9 | "scripts": { 10 | /* */ 11 | }, 12 | 13 | "watcher": { 14 | // The number of milliseconds after the last change. 15 | "interval": 350, 16 | // The file extensions that it will scan for. 17 | "exts": ["js", "jsx", "ts", "tsx", "json"], 18 | // The globs that it will scan for. 19 | "match": ["*.*"], 20 | // The globs that it will not scan for. 21 | "skip": ["*/.git/*"], 22 | // Use the legacy file monitoring algorithm. (walking) 23 | "legacy": false 24 | } 25 | } 26 | ``` 27 | -------------------------------------------------------------------------------- /docs/sidebar.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "category", 4 | "label": "Denon", 5 | "items": [ 6 | "denon/home", 7 | "denon/installation", 8 | "denon/usage" 9 | ] 10 | }, 11 | { 12 | "type": "category", 13 | "label": "Advanced", 14 | "items": [ 15 | { 16 | "type": "category", 17 | "label": "Configuration", 18 | "items": [ 19 | "denon/configuration/templates", 20 | "denon/configuration/script", 21 | "denon/configuration/watcher", 22 | "denon/configuration/logger" 23 | ] 24 | }, 25 | "denon/module", 26 | "denon/contributing" 27 | ] 28 | } 29 | ] 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for denon 4 | title: "" 5 | labels: enhancement 6 | assignees: "" 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** A clear and 10 | concise description of what the problem is. Ex. I'm always frustrated when (...) 11 | 12 | **Describe the solution you'd like** A clear and concise description of what you 13 | want to happen. 14 | 15 | **Describe alternatives you've considered** A clear and concise description of 16 | any alternative solutions or features you've considered. 17 | 18 | **Additional context** Add any other context or screenshots about the feature 19 | request here. 20 | -------------------------------------------------------------------------------- /.github/workflows/checks.yml: -------------------------------------------------------------------------------- 1 | name: check 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | lint: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout sources 10 | uses: actions/checkout@v2 11 | 12 | - name: Setup latest deno version 13 | uses: denoland/setup-deno@main 14 | with: 15 | deno-version: v1.x 16 | 17 | - name: Run deno fmt 18 | run: deno fmt --check 19 | 20 | - name: Run deno lint 21 | run: deno lint --unstable 22 | 23 | test: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - name: Checkout sources 27 | uses: actions/checkout@v2 28 | 29 | - name: Setup latest deno version 30 | uses: denoland/setup-deno@main 31 | with: 32 | deno-version: v1.x 33 | 34 | - name: Run deno test 35 | run: deno test -A --unstable 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve denon 4 | title: "" 5 | labels: bug 6 | assignees: "" 7 | --- 8 | 9 | **Describe the bug** A clear and concise description of what the bug is. 10 | 11 | **To Reproduce** Steps to reproduce the behavior: 1\. Go to '...' 2\. Click on 12 | '....' 3\. Scroll down to '....' 4\. See error 13 | 14 | **Expected behavior** A clear and concise description of what you expected to 15 | happen. 16 | 17 | **Configuration or Project** If applicable, add your denon configuration file or 18 | project so we can accurately test our solution. 19 | 20 | **Screenshots** If applicable, add screenshots to help explain your problem. 21 | 22 | **Setup** 23 | 24 | - OS: (e.g. macOS, windows, linux) 25 | - Deno version: (`deno version`) 26 | - Denon version: (`denon --version`) 27 | 28 | **Additional context** Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /src/merge.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license. 2 | 3 | // deno-lint-ignore-file 4 | export type Indexable = Record; 5 | 6 | /** Performs a deep merge of `source` into `target`. 7 | * Mutates `target` only but not its objects and arrays. */ 8 | export function merge>( 9 | target: T, 10 | source: Indexable, 11 | ): T { 12 | const t = target as Record; 13 | const isObject = (obj: unknown) => obj && typeof obj === "object"; 14 | 15 | if (!isObject(target) || !isObject(source)) { 16 | return source as T; 17 | } 18 | 19 | for (const key of Object.keys(source)) { 20 | const targetValue = target[key]; 21 | const sourceValue = source[key]; 22 | 23 | if (Array.isArray(targetValue) && Array.isArray(sourceValue)) { 24 | t[key] = sourceValue; 25 | } else if (isObject(targetValue) && isObject(sourceValue)) { 26 | t[key] = merge(Object.assign({}, targetValue), sourceValue as Indexable); 27 | } else { 28 | t[key] = sourceValue; 29 | } 30 | } 31 | 32 | return t as T; 33 | } 34 | -------------------------------------------------------------------------------- /docs/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Installation 3 | --- 4 | 5 | import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; 6 | 7 | To install denon simply enter the following into a terminal: 8 | 9 | 11 | 12 | 13 | ```bash 14 | deno install -qA -f --unstable https://deno.land/x/denon@2.3.2/denon.ts 15 | ``` 16 | 17 | 18 | 19 | 20 | ```bash 21 | deno install -qA -f --unstable https://x.nest.land/denon@2.3.2/denon.ts 22 | ``` 23 | 24 | 25 | 26 | 27 | ## Autocompletion 28 | 29 | In **zsh**, you can install autocompletion with: 30 | 31 | ```bash 32 | echo '. <(denon --completion)' >> ~/.zshrc 33 | ``` 34 | 35 | In **bash**: 36 | 37 | ```bash 38 | denon --completion >> ~/.config/denon.completion.sh 39 | echo 'source ~/.config/denon.completion.sh' >> ~/.bash_profile 40 | ``` 41 | 42 | In **fish**: 43 | 44 | ```bash 45 | echo 'denon --completion-fish | source' >> ~/.config/fish/config.fish 46 | ``` 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2021 the denosaurs team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /deps.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license. 2 | 3 | // provide better logging, see src/log.ts 4 | export * as log from "https://deno.land/x/branch@0.1.6/mod.ts"; 5 | 6 | // colors for a pretty cli 7 | export { 8 | blue, 9 | bold, 10 | gray, 11 | green, 12 | italic, 13 | red, 14 | reset, 15 | setColorEnabled, 16 | yellow, 17 | } from "https://deno.land/std@0.125.0/fmt/colors.ts"; 18 | 19 | // configuration reading 20 | export { 21 | exists, 22 | existsSync, 23 | walk, // ... and one type of file monitoring 24 | } from "https://deno.land/std@0.125.0/fs/mod.ts"; 25 | 26 | // configuration parsing (YAML) 27 | export { 28 | JSON_SCHEMA, 29 | parse as parseYaml, 30 | } from "https://deno.land/std@0.125.0/encoding/yaml.ts"; 31 | 32 | // file watching and directory matching 33 | export { 34 | dirname, 35 | extname, 36 | globToRegExp, 37 | relative, 38 | resolve, 39 | } from "https://deno.land/std@0.125.0/path/mod.ts"; 40 | 41 | // event control 42 | export { deferred, delay } from "https://deno.land/std@0.125.0/async/mod.ts"; 43 | 44 | // permission management 45 | export { grant } from "https://deno.land/std@0.125.0/permissions/mod.ts"; 46 | -------------------------------------------------------------------------------- /src/templates.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license. 2 | 3 | import { VERSION } from "../info.ts"; 4 | 5 | // deno-lint-ignore-file 6 | 7 | export interface Template { 8 | filename: string; 9 | source: string; 10 | } 11 | 12 | const json: Template = { 13 | filename: "scripts.json", 14 | source: String.raw`{ 15 | "$schema": "https://deno.land/x/denon@${VERSION}/schema.json", 16 | "scripts": { 17 | "start": { 18 | "cmd": "deno run app.ts", 19 | "desc": "run my app.ts file" 20 | } 21 | } 22 | }`, 23 | }; 24 | 25 | const yaml: Template = { 26 | filename: "scripts.yml", 27 | source: String.raw`scripts: 28 | start: 29 | cmd: "deno run app.ts" 30 | desc: "run my app.ts file"`, 31 | }; 32 | 33 | const typescript: Template = { 34 | filename: "scripts.config.ts", 35 | source: String.raw` 36 | import { DenonConfig } from "https://deno.land/x/denon@${VERSION}/mod.ts"; 37 | 38 | const config: DenonConfig = { 39 | scripts: { 40 | start: { 41 | cmd: "deno run app.ts", 42 | desc: "run my app.ts file", 43 | }, 44 | }, 45 | }; 46 | 47 | export default config;`, 48 | }; 49 | 50 | export const templates: { [key: string]: Template } = { 51 | json: json, 52 | yaml: yaml, 53 | yml: yaml, 54 | ts: typescript, 55 | typescript: typescript, 56 | }; 57 | -------------------------------------------------------------------------------- /assets/example.cast: -------------------------------------------------------------------------------- 1 | {"version": 2, "width": 61, "height": 58, "timestamp": 1598897156, "env": {"SHELL": "/bin/zsh", "TERM": "xterm-256color"}} 2 | [0.100668, "o", "\u001b[34m[*]\u001b[39m \u001b[90m[\u001b[3mmain\u001b[23m]\u001b[39m \u001b[0mv2.4.4\u001b[0m\r\n"] 3 | [0.151823, "o", "\u001b[34m[*]\u001b[39m \u001b[90m[\u001b[3mdaem\u001b[23m]\u001b[39m \u001b[0mwatching path(s): *.*\u001b[0m\r\n\u001b[34m[*]\u001b[39m \u001b[90m[\u001b[3mdaem\u001b[23m]\u001b[39m \u001b[0mwatching extensions: ts,tsx,js,jsx,json\u001b[0m\r\n"] 4 | [0.151927, "o", "\u001b[33m[!]\u001b[39m \u001b[90m[\u001b[3m#0\u001b[23m]\u001b[39m \u001b[0mstarting `deno run --allow-env --allow-net oak.ts`\u001b[0m\r\n"] 5 | [0.267581, "o", "Webserver listening to \u001b[32m:9001\u001b[39m\r\n"] 6 | [2.9768, "o", "\u001b[34m[*]\u001b[39m \u001b[90m[\u001b[3mdaem\u001b[23m]\u001b[39m \u001b[0mrestarting due to changes...\u001b[0m\r\n"] 7 | [2.977312, "o", "\u001b[34m[*]\u001b[39m \u001b[90m[\u001b[3mdaem\u001b[23m]\u001b[39m \u001b[0mwatching path(s): *.*\u001b[0m\r\n\u001b[34m[*]\u001b[39m \u001b[90m[\u001b[3mdaem\u001b[23m]\u001b[39m \u001b[0mwatching extensions: ts,tsx,js,jsx,json\u001b[0m\r\n"] 8 | [2.977476, "o", "\u001b[33m[!]\u001b[39m \u001b[90m[\u001b[3m#0\u001b[23m]\u001b[39m \u001b[0mstarting `deno run --allow-env --allow-net oak.ts`\u001b[0m\r\n"] 9 | [3.10966, "o", "Webserver listening to \u001b[32m:9001\u001b[39m\r\n"] 10 | [5.984198, "o", "^C"] 11 | -------------------------------------------------------------------------------- /src/watcher.test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 the denosaurs team. All rights reserved. MIT license. 2 | 3 | import { assert } from "../test_deps.ts"; 4 | 5 | import { Watcher, WatcherConfig } from "./watcher.ts"; 6 | 7 | Deno.test({ 8 | name: "watcher | exts", 9 | fn(): void { 10 | const config: WatcherConfig = { 11 | paths: [Deno.cwd()], 12 | interval: 350, 13 | exts: ["json"], 14 | skip: [], 15 | match: [], 16 | }; 17 | 18 | const watcher = new Watcher(config); 19 | assert( 20 | !watcher.isWatched("src/args.ts"), 21 | "should not match because of extension", 22 | ); 23 | 24 | config.exts = []; 25 | config.skip = ["src/*"]; 26 | watcher.reload(); 27 | assert( 28 | !watcher.isWatched("src/args.ts"), 29 | "should not match because parent dir is skipped", 30 | ); 31 | 32 | config.exts = []; 33 | config.skip = []; 34 | config.match = ["lib/*"]; 35 | watcher.reload(); 36 | assert( 37 | !watcher.isWatched("src/args.ts"), 38 | "should not match because parent dir is not matched", 39 | ); 40 | 41 | config.exts = [".ts"]; 42 | config.skip = []; 43 | config.match = ["**"]; 44 | watcher.reload(); 45 | assert( 46 | watcher.isWatched("src/args.ts"), 47 | "should match because of extensions", 48 | ); 49 | }, 50 | }); 51 | 52 | Deno.test({ 53 | name: "watcher | skip", 54 | fn(): void { 55 | const config: WatcherConfig = { 56 | paths: [Deno.cwd()], 57 | interval: 350, 58 | exts: [], 59 | skip: ["src/*"], 60 | match: [], 61 | }; 62 | 63 | const watcher = new Watcher(config); 64 | assert( 65 | !watcher.isWatched("src/args.ts"), 66 | "should not match because parent dir is skipped", 67 | ); 68 | }, 69 | }); 70 | -------------------------------------------------------------------------------- /docs/configuration/templates.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Templates 3 | --- 4 | 5 | import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; 6 | 7 | **Denon** is designed to be simple but also extremely configurable to fit your 8 | project needs. It supports `JSON`, `YAML`, and `Typescript` configuration file. 9 | Example in this page are provided in all three formats. 10 | 11 | to create a basic configuration in the root directory of your project you can 12 | run: 13 | 14 | ``` 15 | denon --init 16 | ``` 17 | 18 | this will create a basic `denon.json` file: 19 | 20 | ```json 21 | { 22 | "scripts": { 23 | "start": "app.js" 24 | } 25 | } 26 | ``` 27 | 28 | you can also initialize from a custom template (see the 29 | [`templates`](https://github.com/denosaurs/denon/tree/master/templates) folder 30 | for all the available templates) 31 | 32 | ``` 33 | denon --init