summaryrefslogtreecommitdiff
path: root/docs/tools
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2020-05-07 00:21:13 +0200
committerGitHub <noreply@github.com>2020-05-06 18:21:13 -0400
commit34ec3b225425cecdccf754fbc87f4a8f3728890d (patch)
tree35db52bf25ccf64425692116197df61a69ea8838 /docs/tools
parent846c049c9b3ab36d0893292a204c4d0a18de4c8e (diff)
Multi page manual (#5110)
Diffstat (limited to 'docs/tools')
-rw-r--r--docs/tools/bundler.md50
-rw-r--r--docs/tools/debugger.md3
-rw-r--r--docs/tools/dependency_inspector.md3
-rw-r--r--docs/tools/documentation_generator.md3
-rw-r--r--docs/tools/formatter.md33
-rw-r--r--docs/tools/script_installer.md88
6 files changed, 180 insertions, 0 deletions
diff --git a/docs/tools/bundler.md b/docs/tools/bundler.md
new file mode 100644
index 000000000..0844dfd5e
--- /dev/null
+++ b/docs/tools/bundler.md
@@ -0,0 +1,50 @@
+## Bundling
+
+`deno bundle [URL]` will output a single JavaScript file, which includes all
+dependencies of the specified input. For example:
+
+```
+> deno bundle https://deno.land/std/examples/colors.ts colors.bundle.js
+Bundling "colors.bundle.js"
+Emitting bundle to "colors.bundle.js"
+9.2 kB emitted.
+```
+
+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:
+
+```
+deno 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 { foo, bar } 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/debugger.md b/docs/tools/debugger.md
new file mode 100644
index 000000000..626032d5f
--- /dev/null
+++ b/docs/tools/debugger.md
@@ -0,0 +1,3 @@
+## Debugger
+
+<!-- TODO(lucacasonto): write things -->
diff --git a/docs/tools/dependency_inspector.md b/docs/tools/dependency_inspector.md
new file mode 100644
index 000000000..37bd13c5e
--- /dev/null
+++ b/docs/tools/dependency_inspector.md
@@ -0,0 +1,3 @@
+## Dependency Inspector
+
+<!-- TODO(lucacasonto): write things -->
diff --git a/docs/tools/documentation_generator.md b/docs/tools/documentation_generator.md
new file mode 100644
index 000000000..07b0b5c95
--- /dev/null
+++ b/docs/tools/documentation_generator.md
@@ -0,0 +1,3 @@
+## Documentation Generator
+
+<!-- TODO(lucacasonto): write things -->
diff --git a/docs/tools/formatter.md b/docs/tools/formatter.md
new file mode 100644
index 000000000..16a5a9ab4
--- /dev/null
+++ b/docs/tools/formatter.md
@@ -0,0 +1,33 @@
+## 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:
+
+<!-- prettier-ignore-start -->
+
+```ts
+// deno-fmt-ignore
+export const identity = [
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1,
+];
+```
+
+<!-- prettier-ignore-end -->
+
+Or ignore an entire file by adding a `// deno-fmt-ignore-file` comment at the
+top of the file.
diff --git a/docs/tools/script_installer.md b/docs/tools/script_installer.md
new file mode 100644
index 000000000..ffd920cf3
--- /dev/null
+++ b/docs/tools/script_installer.md
@@ -0,0 +1,88 @@
+## 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 place in the installation root's
+`bin` directory.
+
+Example:
+
+```shell
+$ deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts
+[1/1] Compiling https://deno.land/std/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/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.
+
+To change the installation root, use `--root`:
+
+```shell
+$ deno install --allow-net --allow-read --root /usr/local https://deno.land/std/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/http/file_server.ts 8080
+```
+
+The above command creates an executable called `file_server` that runs with
+write and read permissions and binds to port 8080.
+
+For good practice, use the
+[`import.meta.main`](#testing-if-current-file-is-the-main-program) idiom to
+specify the entry point in an executable script.
+
+Example:
+
+```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
+```