diff options
Diffstat (limited to 'docs/tools')
-rw-r--r-- | docs/tools/bundler.md | 51 | ||||
-rw-r--r-- | docs/tools/compiler.md | 36 | ||||
-rw-r--r-- | docs/tools/dependency_inspector.md | 74 | ||||
-rw-r--r-- | docs/tools/documentation_generator.md | 31 | ||||
-rw-r--r-- | docs/tools/formatter.md | 29 | ||||
-rw-r--r-- | docs/tools/linter.md | 150 | ||||
-rw-r--r-- | docs/tools/repl.md | 52 | ||||
-rw-r--r-- | docs/tools/script_installer.md | 90 |
8 files changed, 0 insertions, 513 deletions
diff --git a/docs/tools/bundler.md b/docs/tools/bundler.md deleted file mode 100644 index 10df9c8bb..000000000 --- a/docs/tools/bundler.md +++ /dev/null @@ -1,51 +0,0 @@ -## Bundling - -`deno bundle [URL]` will output a single JavaScript file, which includes all -dependencies of the specified input. For example: - -```bash -deno bundle https://deno.land/std@$STD_VERSION/examples/colors.ts colors.bundle.js -Bundle https://deno.land/std@$STD_VERSION/examples/colors.ts -Download https://deno.land/std@$STD_VERSION/examples/colors.ts -Download https://deno.land/std@$STD_VERSION/fmt/colors.ts -Emit "colors.bundle.js" (9.83KB) -``` - -If you omit the out file, the bundle will be sent to `stdout`. - -The bundle can just be run as any other module in Deno would: - -```bash -deno run colors.bundle.js -``` - -The output is a self contained ES Module, where any exports from the main module -supplied on the command line will be available. For example, if the main module -looked something like this: - -```ts -export { foo } from "./foo.js"; - -export const bar = "bar"; -``` - -It could be imported like this: - -```ts -import { bar, foo } from "./lib.bundle.js"; -``` - -Bundles can also be loaded in the web browser. The bundle is a self-contained ES -module, and so the attribute of `type` must be set to `"module"`. For example: - -```html -<script type="module" src="website.bundle.js"></script> -``` - -Or you could import it into another ES module to consume: - -```html -<script type="module"> - import * as website from "website.bundle.js"; -</script> -``` diff --git a/docs/tools/compiler.md b/docs/tools/compiler.md deleted file mode 100644 index 5b3dfd5ec..000000000 --- a/docs/tools/compiler.md +++ /dev/null @@ -1,36 +0,0 @@ -## Compiling Executables - -`deno compile [--output <OUT>] <SRC>` will compile the script into a -self-contained executable. - -``` -> deno compile https://deno.land/std/examples/welcome.ts -``` - -If you omit the `OUT` parameter, the name of the executable file will be -inferred. - -### Flags - -As with [`deno install`](./script_installer.md), the runtime flags used to -execute the script must be specified at compilation time. This includes -permission flags. - -``` -> deno compile --allow-read --allow-net https://deno.land/std/http/file_server.ts -``` - -[Script arguments](../getting_started/command_line_interface.md#script-arguments) -can be partially embedded. - -``` -> deno compile --allow-read --allow-net https://deno.land/std/http/file_server.ts -p 8080 -> ./file_server --help -``` - -### Cross Compilation - -You can compile binaries for other platforms by adding the `--target` CLI flag. -Deno currently supports compiling to Windows x64, macOS x64, macOS ARM and Linux -x64. Use `deno compile --help` to list the full values for each compilation -target. diff --git a/docs/tools/dependency_inspector.md b/docs/tools/dependency_inspector.md deleted file mode 100644 index 80b747b3c..000000000 --- a/docs/tools/dependency_inspector.md +++ /dev/null @@ -1,74 +0,0 @@ -## Dependency Inspector - -`deno info [URL]` will inspect ES module and all of its dependencies. - -```shell -deno info https://deno.land/std@0.67.0/http/file_server.ts -Download https://deno.land/std@0.67.0/http/file_server.ts -... -local: /home/deno/.cache/deno/deps/https/deno.land/f57792e36f2dbf28b14a75e2372a479c6392780d4712d76698d5031f943c0020 -type: TypeScript -compiled: /home/deno/.cache/deno/gen/https/deno.land/f57792e36f2dbf28b14a75e2372a479c6392780d4712d76698d5031f943c0020.js -deps: 23 unique (total 139.89KB) -https://deno.land/std@0.67.0/http/file_server.ts (10.49KB) -├─┬ https://deno.land/std@0.67.0/path/mod.ts (717B) -│ ├── https://deno.land/std@0.67.0/path/_constants.ts (2.35KB) -│ ├─┬ https://deno.land/std@0.67.0/path/win32.ts (27.36KB) -│ │ ├── https://deno.land/std@0.67.0/path/_interface.ts (657B) -│ │ ├── https://deno.land/std@0.67.0/path/_constants.ts * -│ │ ├─┬ https://deno.land/std@0.67.0/path/_util.ts (3.3KB) -│ │ │ ├── https://deno.land/std@0.67.0/path/_interface.ts * -│ │ │ └── https://deno.land/std@0.67.0/path/_constants.ts * -│ │ └── https://deno.land/std@0.67.0/_util/assert.ts (405B) -│ ├─┬ https://deno.land/std@0.67.0/path/posix.ts (12.67KB) -│ │ ├── https://deno.land/std@0.67.0/path/_interface.ts * -│ │ ├── https://deno.land/std@0.67.0/path/_constants.ts * -│ │ └── https://deno.land/std@0.67.0/path/_util.ts * -│ ├─┬ https://deno.land/std@0.67.0/path/common.ts (1.14KB) -│ │ └─┬ https://deno.land/std@0.67.0/path/separator.ts (264B) -│ │ └── https://deno.land/std@0.67.0/path/_constants.ts * -│ ├── https://deno.land/std@0.67.0/path/separator.ts * -│ ├── https://deno.land/std@0.67.0/path/_interface.ts * -│ └─┬ https://deno.land/std@0.67.0/path/glob.ts (8.12KB) -│ ├── https://deno.land/std@0.67.0/path/_constants.ts * -│ ├── https://deno.land/std@0.67.0/path/mod.ts * -│ └── https://deno.land/std@0.67.0/path/separator.ts * -├─┬ https://deno.land/std@0.67.0/http/server.ts (10.23KB) -│ ├── https://deno.land/std@0.67.0/encoding/utf8.ts (433B) -│ ├─┬ https://deno.land/std@0.67.0/io/bufio.ts (21.15KB) -│ │ ├── https://deno.land/std@0.67.0/bytes/mod.ts (4.34KB) -│ │ └── https://deno.land/std@0.67.0/_util/assert.ts * -│ ├── https://deno.land/std@0.67.0/_util/assert.ts * -│ ├─┬ https://deno.land/std@0.67.0/async/mod.ts (202B) -│ │ ├── https://deno.land/std@0.67.0/async/deferred.ts (1.03KB) -│ │ ├── https://deno.land/std@0.67.0/async/delay.ts (279B) -│ │ ├─┬ https://deno.land/std@0.67.0/async/mux_async_iterator.ts (1.98KB) -│ │ │ └── https://deno.land/std@0.67.0/async/deferred.ts * -│ │ └── https://deno.land/std@0.67.0/async/pool.ts (1.58KB) -│ └─┬ https://deno.land/std@0.67.0/http/_io.ts (11.25KB) -│ ├── https://deno.land/std@0.67.0/io/bufio.ts * -│ ├─┬ https://deno.land/std@0.67.0/textproto/mod.ts (4.52KB) -│ │ ├── https://deno.land/std@0.67.0/io/bufio.ts * -│ │ ├── https://deno.land/std@0.67.0/bytes/mod.ts * -│ │ └── https://deno.land/std@0.67.0/encoding/utf8.ts * -│ ├── https://deno.land/std@0.67.0/_util/assert.ts * -│ ├── https://deno.land/std@0.67.0/encoding/utf8.ts * -│ ├── https://deno.land/std@0.67.0/http/server.ts * -│ └── https://deno.land/std@0.67.0/http/http_status.ts (5.93KB) -├─┬ https://deno.land/std@0.67.0/flags/mod.ts (9.54KB) -│ └── https://deno.land/std@0.67.0/_util/assert.ts * -└── https://deno.land/std@0.67.0/_util/assert.ts * -``` - -Dependency inspector works with any local or remote ES modules. - -## Cache location - -`deno info` can be used to display information about cache location: - -```shell -deno info -DENO_DIR location: "/Users/deno/Library/Caches/deno" -Remote modules cache: "/Users/deno/Library/Caches/deno/deps" -TypeScript compiler cache: "/Users/deno/Library/Caches/deno/gen" -``` diff --git a/docs/tools/documentation_generator.md b/docs/tools/documentation_generator.md deleted file mode 100644 index fa8b09c9c..000000000 --- a/docs/tools/documentation_generator.md +++ /dev/null @@ -1,31 +0,0 @@ -## Documentation Generator - -`deno doc` followed by a list of one or more source files will print the JSDoc -documentation for each of the module's **exported** members. - -For example, given a file `add.ts` with the contents: - -```ts -/** - * Adds x and y. - * @param {number} x - * @param {number} y - * @returns {number} Sum of x and y - */ -export function add(x: number, y: number): number { - return x + y; -} -``` - -Running the Deno `doc` command, prints the function's JSDoc comment to `stdout`: - -```shell -deno doc add.ts -function add(x: number, y: number): number - Adds x and y. @param {number} x @param {number} y @returns {number} Sum of x and y -``` - -Use the `--json` flag to output the documentation in JSON format. This JSON -format is consumed by the -[deno doc website](https://github.com/denoland/doc_website) and is used to -generate module documentation. diff --git a/docs/tools/formatter.md b/docs/tools/formatter.md deleted file mode 100644 index aedb6bdc9..000000000 --- a/docs/tools/formatter.md +++ /dev/null @@ -1,29 +0,0 @@ -## Code formatter - -Deno ships with a built in code formatter that auto-formats TypeScript and -JavaScript code. - -```shell -# format all JS/TS files in the current directory and subdirectories -deno fmt -# format specific files -deno fmt myfile1.ts myfile2.ts -# check if all the JS/TS files in the current directory and subdirectories are formatted -deno fmt --check -# format stdin and write to stdout -cat file.ts | deno fmt - -``` - -Ignore formatting code by preceding it with a `// deno-fmt-ignore` comment: - -```ts -// deno-fmt-ignore -export const identity = [ - 1, 0, 0, - 0, 1, 0, - 0, 0, 1, -]; -``` - -Or ignore an entire file by adding a `// deno-fmt-ignore-file` comment at the -top of the file. diff --git a/docs/tools/linter.md b/docs/tools/linter.md deleted file mode 100644 index 0f742be40..000000000 --- a/docs/tools/linter.md +++ /dev/null @@ -1,150 +0,0 @@ -## Linter - -Deno ships with a built in code linter for JavaScript and TypeScript. - -```shell -# lint all JS/TS files in the current directory and subdirectories -deno lint -# lint specific files -deno lint myfile1.ts myfile2.ts -# print result as JSON -deno lint --json -# read from stdin -cat file.ts | deno lint - -``` - -For more detail, run `deno lint --help`. - -### Available rules - -- `adjacent-overload-signatures` -- `ban-ts-comment` -- `ban-types` -- `ban-untagged-ignore` -- `camelcase` -- `constructor-super` -- `for-direction` -- `getter-return` -- `no-array-constructor` -- `no-async-promise-executor` -- `no-case-declarations` -- `no-class-assign` -- `no-compare-neg-zero` -- `no-cond-assign` -- `no-constant-condition` -- `no-control-regex` -- `no-debugger` -- `no-delete-var` -- `no-deprecated-deno-api` -- `no-dupe-args` -- `no-dupe-class-members` -- `no-dupe-else-if` -- `no-dupe-keys` -- `no-duplicate-case` -- `no-empty` -- `no-empty-character-class` -- `no-empty-interface` -- `no-empty-pattern` -- `no-ex-assign` -- `no-explicit-any` -- `no-extra-boolean-cast` -- `no-extra-non-null-assertion` -- `no-extra-semi` -- `no-fallthrough` -- `no-func-assign` -- `no-global-assign` -- `no-import-assign` -- `no-inferrable-types` -- `no-inner-declarations` -- `no-invalid-regexp` -- `no-irregular-whitespace` -- `no-misused-new` -- `no-mixed-spaces-and-tabs` -- `no-namespace` -- `no-new-symbol` -- `no-obj-calls` -- `no-octal` -- `no-prototype-builtins` -- `no-redeclare` -- `no-regex-spaces` -- `no-self-assign` -- `no-setter-return` -- `no-shadow-restricted-names` -- `no-this-alias` -- `no-this-before-super` -- `no-unreachable` -- `no-unsafe-finally` -- `no-unsafe-negation` -- `no-unused-labels` -- `no-unused-vars` -- `no-with` -- `prefer-as-const` -- `prefer-const` -- `prefer-namespace-keyword` -- `require-await` -- `require-yield` -- `use-isnan` -- `valid-typeof` - -For more detail about each rule, visit -[the deno_lint rule documentation](https://lint.deno.land). - -### Ignore directives - -#### Files - -To ignore whole file `// deno-lint-ignore-file` directive should placed at the -top of the file: - -```ts -// deno-lint-ignore-file - -function foo(): any { - // ... -} -``` - -Ignore directive must be placed before first statement or declaration: - -```ts -// Copyright 2020 the Deno authors. All rights reserved. MIT license. - -/** - * Some JS doc - **/ - -// deno-lint-ignore-file - -import { bar } from "./bar.js"; - -function foo(): any { - // ... -} -``` - -You can also ignore certain diagnostics in the whole file - -```ts -// deno-lint-ignore-file no-explicit-any no-empty - -function foo(): any { - // ... -} -``` - -#### Diagnostics - -To ignore certain diagnostic `// deno-lint-ignore <codes...>` directive should -be placed before offending line. Specifying ignored rule name is required: - -```ts -// deno-lint-ignore no-explicit-any -function foo(): any { - // ... -} - -// deno-lint-ignore no-explicit-any explicit-function-return-type -function bar(a: any) { - // ... -} -``` diff --git a/docs/tools/repl.md b/docs/tools/repl.md deleted file mode 100644 index ac512ec93..000000000 --- a/docs/tools/repl.md +++ /dev/null @@ -1,52 +0,0 @@ -# Read-eval-print-loop - -`deno repl` starts an read-eval-print-loop, which lets you interactively build -up program state in the global context. - -## Keyboard shortcuts - -| Keystroke | Action | -| --------------------- | ------------------------------------------------------------------------------------------------ | -| Ctrl-A, Home | Move cursor to the beginning of line | -| Ctrl-B, Left | Move cursor one character left | -| Ctrl-C | Interrupt and cancel the current edit | -| Ctrl-D | If if line _is_ empty, signal end of line | -| Ctrl-D, Del | If line is _not_ empty, delete character under cursor | -| Ctrl-E, End | Move cursor to end of line | -| Ctrl-F, Right | Move cursor one character right | -| Ctrl-H, Backspace | Delete character before cursor | -| Ctrl-I, Tab | Next completion | -| Ctrl-J, Ctrl-M, Enter | Finish the line entry | -| Ctrl-K | Delete from cursor to end of line | -| Ctrl-L | Clear screen | -| Ctrl-N, Down | Next match from history | -| Ctrl-P, Up | Previous match from history | -| Ctrl-R | Reverse Search history (Ctrl-S forward, Ctrl-G cancel) | -| Ctrl-T | Transpose previous character with current character | -| Ctrl-U | Delete from start of line to cursor | -| Ctrl-V | Insert any special character without performing its associated action | -| Ctrl-W | Delete word leading up to cursor (using white space as a word boundary) | -| Ctrl-X Ctrl-U | Undo | -| Ctrl-Y | Paste from Yank buffer | -| Ctrl-Y | Paste from Yank buffer (Meta-Y to paste next yank instead) | -| Ctrl-Z | Suspend (Unix only) | -| Ctrl-_ | Undo | -| Meta-0, 1, ..., - | Specify the digit to the argument. `–` starts a negative argument. | -| Meta-< | Move to first entry in history | -| Meta-> | Move to last entry in history | -| Meta-B, Alt-Left | Move cursor to previous word | -| Meta-Backspace | Kill from the start of the current word, or, if between words, to the start of the previous word | -| Meta-C | Capitalize the current word | -| Meta-D | Delete forwards one word | -| Meta-F, Alt-Right | Move cursor to next word | -| Meta-L | Lower-case the next word | -| Meta-T | Transpose words | -| Meta-U | Upper-case the next word | -| Meta-Y | See Ctrl-Y | - -## Special variables - -| Identifier | Description | -| ---------- | ------------------------------------ | -| _ | Yields the last evaluated expression | -| _error | Yields the last thrown error | diff --git a/docs/tools/script_installer.md b/docs/tools/script_installer.md deleted file mode 100644 index b5046719e..000000000 --- a/docs/tools/script_installer.md +++ /dev/null @@ -1,90 +0,0 @@ -## Script installer - -Deno provides `deno install` to easily install and distribute executable code. - -`deno install [OPTIONS...] [URL] [SCRIPT_ARGS...]` will install the script -available at `URL` under the name `EXE_NAME`. - -This command creates a thin, executable shell script which invokes `deno` using -the specified CLI flags and main module. It is placed in the installation root's -`bin` directory. - -Example: - -```shell -$ deno install --allow-net --allow-read https://deno.land/std@$STD_VERSION/http/file_server.ts -[1/1] Compiling https://deno.land/std@$STD_VERSION/http/file_server.ts - -✅ Successfully installed file_server. -/Users/deno/.deno/bin/file_server -``` - -To change the executable name, use `-n`/`--name`: - -```shell -deno install --allow-net --allow-read -n serve https://deno.land/std@$STD_VERSION/http/file_server.ts -``` - -The executable name is inferred by default: - -- Attempt to take the file stem of the URL path. The above example would become - 'file_server'. -- If the file stem is something generic like 'main', 'mod', 'index' or 'cli', - and the path has no parent, take the file name of the parent path. Otherwise - settle with the generic name. -- If the resulting name has an '@...' suffix, strip it. - -To change the installation root, use `--root`: - -```shell -deno install --allow-net --allow-read --root /usr/local https://deno.land/std@$STD_VERSION/http/file_server.ts -``` - -The installation root is determined, in order of precedence: - -- `--root` option -- `DENO_INSTALL_ROOT` environment variable -- `$HOME/.deno` - -These must be added to the path manually if required. - -```shell -echo 'export PATH="$HOME/.deno/bin:$PATH"' >> ~/.bashrc -``` - -You must specify permissions that will be used to run the script at installation -time. - -```shell -deno install --allow-net --allow-read https://deno.land/std@$STD_VERSION/http/file_server.ts -p 8080 -``` - -The above command creates an executable called `file_server` that runs with -network and read permissions and binds to port 8080. - -For good practice, use the [`import.meta.main`](../examples/module_metadata.md) -idiom to specify the entry point in an executable script. - -Example: - -<!-- deno-fmt-ignore --> - -```ts -// https://example.com/awesome/cli.ts -async function myAwesomeCli(): Promise<void> { - -- snip -- -} - -if (import.meta.main) { - myAwesomeCli(); -} -``` - -When you create an executable script make sure to let users know by adding an -example installation command to your repository: - -```shell -# Install using deno install - -$ deno install -n awesome_cli https://example.com/awesome/cli.ts -``` |