From 457011c09bcf2cc8add8033db60943e54e8a25e1 Mon Sep 17 00:00:00 2001 From: Kevin Whinnery Date: Thu, 14 Sep 2023 19:12:01 -0500 Subject: [PATCH 1/2] version import URLs --- README.md | 11 ++++++ deploy/api/runtime-broadcast-channel.md | 2 +- deploy/api/runtime-fetch.md | 15 ++++---- deploy/api/runtime-fs.md | 25 +++++++------ deploy/api/runtime-request.md | 4 +-- deploy/api/runtime-response.md | 2 +- deploy/api/runtime-sockets.md | 4 +-- deploy/manual/ci_github.md | 2 +- deploy/manual/middleware.md | 2 +- deploy/tutorials/simple-api.md | 2 +- deploy/tutorials/static-site.md | 2 +- deploy/tutorials/tutorial-http-server.md | 8 ++--- deploy/tutorials/tutorial-postgres.md | 4 +-- deploy/tutorials/vite.md | 7 ++-- docusaurus.config.js | 6 ++++ .../manual/advanced/continuous_integration.md | 2 +- .../manual/advanced/deploying_deno/kinsta.md | 4 +-- runtime/manual/advanced/jsx_dom/css.md | 2 +- runtime/manual/advanced/jsx_dom/deno_dom.md | 2 +- runtime/manual/advanced/jsx_dom/jsdom.md | 2 +- runtime/manual/advanced/jsx_dom/linkedom.md | 2 +- .../manual/basics/connecting_to_databases.md | 2 +- runtime/manual/basics/debugging_your_code.md | 10 +++--- runtime/manual/basics/env_variables.md | 6 ++-- runtime/manual/basics/import_maps.md | 2 +- runtime/manual/basics/modules/index.md | 2 +- .../basics/modules/integrity_checking.md | 6 ++-- .../basics/modules/reloading_modules.md | 4 +-- runtime/manual/basics/permissions.md | 8 ++--- runtime/manual/basics/standard_library.md | 8 ++--- runtime/manual/basics/testing/assertions.md | 10 +++--- .../testing/behavior_driven_development.md | 36 +++++++++++++------ runtime/manual/basics/testing/index.md | 12 +++---- runtime/manual/basics/testing/mocking.md | 27 +++++++------- .../manual/basics/testing/snapshot_testing.md | 8 ++--- .../getting_started/configuration_file.md | 2 +- runtime/manual/getting_started/first_steps.md | 4 +-- .../getting_started/setup_your_environment.md | 2 ++ runtime/manual/index.mdx | 14 +++++--- runtime/manual/node/how_to_with_npm/prisma.md | 4 +-- runtime/manual/node/how_to_with_npm/redis.md | 2 +- .../references/contributing/style_guide.md | 2 +- .../manual/references/vscode_deno/index.md | 2 +- runtime/manual/runtime/workers.md | 2 +- runtime/manual/tools/benchmarker.md | 2 +- runtime/tutorials/how_to_with_npm/prisma.md | 4 +-- runtime/tutorials/how_to_with_npm/redis.md | 2 +- runtime/tutorials/subprocess.md | 4 ++- src/components/Replacement.jsx | 3 +- 49 files changed, 171 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index 72f3b70d2..a59340c34 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,17 @@ import Replacement from "@site/src/components/Replacement"; The current CLI version is ****. ``` +If you are writing inline JSX, you can also use the replacements object directly +like so: + +```mdx +import { replacements } from "@site/src/components/Replacement"; + +

+ The current CLI version is { replacements.CLI_VERSION }. +

+``` + ## Server-side code and redirects The Deno code that serves the site in production is in the `src-deno` folder. diff --git a/deploy/api/runtime-broadcast-channel.md b/deploy/api/runtime-broadcast-channel.md index b9408d4b1..30f0def61 100644 --- a/deploy/api/runtime-broadcast-channel.md +++ b/deploy/api/runtime-broadcast-channel.md @@ -56,7 +56,7 @@ running instances in different regions and another to fetch all messages from an instance. ```ts -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; const messages = []; // Create a new broadcast channel named earth. diff --git a/deploy/api/runtime-fetch.md b/deploy/api/runtime-fetch.md index faf041b6e..ad70b1731 100644 --- a/deploy/api/runtime-fetch.md +++ b/deploy/api/runtime-fetch.md @@ -5,10 +5,8 @@ allows you to make outbound HTTP requests in Deno Deploy. It is a web standard and has the following interfaces: - `fetch()` - The method that allows you to make outbound HTTP requests -- [`Request`](./runtime-request) - represents a request resource of - fetch() -- [`Response`](./runtime-response) - represents a response resource of - fetch() +- [`Request`](./runtime-request) - represents a request resource of fetch() +- [`Response`](./runtime-response) - represents a response resource of fetch() - [`Headers`](./runtime-headers) - represents HTTP Headers of requests and responses. @@ -16,8 +14,7 @@ This page shows usage for the fetch() method. You can click above on the other interfaces to learn more about them. Fetch also supports fetching from file URLs to retrieve static files. For more -info on static files, see the -[filesystem API documentation](./runtime-fs). +info on static files, see the [filesystem API documentation](./runtime-fs). ## `fetch()` @@ -33,8 +30,8 @@ function fetch( #### Parameters -| name | type | optional | description | -| -------- | ------------------------------------------------------------------- | -------- | ------------------------------------------------------------------ | +| name | type | optional | description | +| -------- | ------------------------------------------------------------- | -------- | ------------------------------------------------------------------ | | resource | [`Request`](./runtime-request)
[`USVString`][usvstring] | `false` | The resource can either be a request object or a URL string. | | init | [`RequestInit`](./runtime-request#requestinit) | `true` | The init object lets you apply optional parameters to the request. | @@ -47,7 +44,7 @@ The Deno Deploy script below makes a `fetch()` request to the GitHub API for each incoming request, and then returns that response from the handler function. ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(req: Request): Promise { const resp = await fetch("https://api.github.com/users/denoland", { diff --git a/deploy/api/runtime-fs.md b/deploy/api/runtime-fs.md index 96b6d492a..09f2bdccc 100644 --- a/deploy/api/runtime-fs.md +++ b/deploy/api/runtime-fs.md @@ -47,7 +47,7 @@ This example lists the contents of a directory and returns this list as a JSON object in the response body. ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(_req) { // List the posts in the `blog` directory located at the root @@ -90,7 +90,7 @@ This example reads the contents of a file into memory as a byte array, then returns it as the response body. ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(_req) { // Let's read the README.md file available at the root @@ -116,10 +116,9 @@ serve(handler); > Note: to use this feature, you must link a GitHub repository to your project. -Deno Deploy supports the `Deno.readFile` -API to read static assets from the file system. This is useful for serving -static assets such as images, stylesheets, and JavaScript files. This guide -demonstrates how to use this feature. +Deno Deploy supports the `Deno.readFile` API to read static assets from the file +system. This is useful for serving static assets such as images, stylesheets, +and JavaScript files. This guide demonstrates how to use this feature. Imagine the following file structure on a GitHub repository: @@ -131,7 +130,7 @@ Imagine the following file structure on a GitHub repository: The contents of `mod.ts`: ```ts -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handleRequest(request: Request): Promise { const { pathname } = new URL(request.url); @@ -193,7 +192,7 @@ This example reads a text file into memory and returns the contents as the response body. ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(_req) { const readme = await Deno.readTextFile("./README.md"); @@ -226,8 +225,8 @@ The path can be a relative or absolute. It can also be a `file:` URL. This example opens a file, and then streams the content as the response body. ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; -import { readableStreamFromReader } from "https://deno.land/std@0.140.0/streams/conversion.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; +import { readableStreamFromReader } from "https://deno.land/std@$STD_VERSION/streams/conversion.ts"; async function handler(_req) { // Open the README.md file available at the root of the repository. @@ -305,7 +304,7 @@ This example gets the size of a file, and returns the result as the response body. ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(_req) { // Get file info of the README.md at the root of the repository. @@ -373,7 +372,7 @@ This example calls `Deno.realPath()` to get the absolute path of a file in the root of the repository. The result is returned as the response body. ```ts -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(_req) { const path = await Deno.realPath("./README.md"); @@ -403,7 +402,7 @@ This example calls `Deno.readLink()` to get the absolute path of a file in the root of the repository. The result is returned as the response body. ```ts -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(_req) { const path = await Deno.readLink("./my_symlink"); diff --git a/deploy/api/runtime-request.md b/deploy/api/runtime-request.md index 0e88c3025..453b90253 100644 --- a/deploy/api/runtime-request.md +++ b/deploy/api/runtime-request.md @@ -50,7 +50,7 @@ The return type is a `Request` instance. | [`body`][body] | [`ReadableStream`][readablestream] | The getter exposes a `ReadableStream` of the body contents. | | [`bodyUsed`][bodyused] | `boolean` | Indicates whether the body content is read. | | [`url`][url] | `USVString` | The URL of the request. | -| [`headers`][headers] | [`Headers`](runtime-headers) | The headers associated with the request. | +| [`headers`][headers] | [`Headers`](runtime-headers) | The headers associated with the request. | | [`integrity`][integrity] | `string` | The crypotographic hash of the request's body. | | [`method`][method] | `string` | The request's method (`POST`, `GET`, etc). | | [`mode`][mode] | `string` | Indicates the mode of the request (e.g. `cors` ). | @@ -74,7 +74,7 @@ All the above properties are read only. ## Example ```ts -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; function handler(_req) { // Create a post request diff --git a/deploy/api/runtime-response.md b/deploy/api/runtime-response.md index 4ce8861c1..eee21d7db 100644 --- a/deploy/api/runtime-response.md +++ b/deploy/api/runtime-response.md @@ -65,7 +65,7 @@ The return type is a `Response` instance. ## Example ```ts -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; function handler(_req) { // Create a response with html as its body. diff --git a/deploy/api/runtime-sockets.md b/deploy/api/runtime-sockets.md index e06259d99..40d594c88 100644 --- a/deploy/api/runtime-sockets.md +++ b/deploy/api/runtime-sockets.md @@ -19,7 +19,7 @@ function Deno.connect(options: ConnectOptions): Promise ### Example ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(_req) { // Make a TCP connection to example.com @@ -65,7 +65,7 @@ function Deno.connectTls(options: ConnectTlsOptions): Promise ### Example ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; async function handler(_req) { // Make a TLS connection to example.com diff --git a/deploy/manual/ci_github.md b/deploy/manual/ci_github.md index bdc9ae09d..281131aa6 100644 --- a/deploy/manual/ci_github.md +++ b/deploy/manual/ci_github.md @@ -98,7 +98,7 @@ process by leveraging the `deployctl` [Github action][deploy-action]: uses: denoland/deployctl@v1 with: project: my-project - entrypoint: https://deno.land/std/http/file_server.ts + entrypoint: https://deno.land/std@$STD_VERSION/http/file_server.ts root: dist ``` diff --git a/deploy/manual/middleware.md b/deploy/manual/middleware.md index c2edb0dd6..5fad57914 100644 --- a/deploy/manual/middleware.md +++ b/deploy/manual/middleware.md @@ -16,7 +16,7 @@ On the next page, copy and paste the code below into the editor. It is an HTTP server that proxies all requests to https://example.com. ```ts -import { serve } from "https://deno.land/std/http/mod.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/mod.ts"; async function reqHandler(req: Request) { const reqPath = new URL(req.url).pathname; return await fetch("https://example.com" + reqPath, { headers: req.headers }); diff --git a/deploy/tutorials/simple-api.md b/deploy/tutorials/simple-api.md index 51ed3aae1..2c98e8098 100644 --- a/deploy/tutorials/simple-api.md +++ b/deploy/tutorials/simple-api.md @@ -7,7 +7,7 @@ This tutorial will cover how to deploy a simple API on Deno Deploy. ```js // simple_api.js -import { serve } from "https://deno.land/std@0.155.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; serve((req: Request) => new Response("Hello World")); ``` diff --git a/deploy/tutorials/static-site.md b/deploy/tutorials/static-site.md index 26486fde1..773b5eea8 100644 --- a/deploy/tutorials/static-site.md +++ b/deploy/tutorials/static-site.md @@ -41,7 +41,7 @@ You have now a html page that says "Hello" and has a logo. To deploy this repo on Deno Deploy, from the `static-site` repository, run: ``` -deployctl deploy --project=careful-goat-90 https://deno.land/std@0.171.0/http/file_server.ts +deployctl deploy --project=careful-goat-90 https://deno.land/std@$STD_VERSION/http/file_server.ts ``` To give a little more explanation of these commands: Because this is a static diff --git a/deploy/tutorials/tutorial-http-server.md b/deploy/tutorials/tutorial-http-server.md index afd889064..8d4a81867 100644 --- a/deploy/tutorials/tutorial-http-server.md +++ b/deploy/tutorials/tutorial-http-server.md @@ -12,11 +12,11 @@ Deploy lets you listen for incoming HTTP requests using the same level though, so instead of using this API directly we'll use the high level HTTP API exposed by [`std/http`][std-http]. -This API revolves around the -[`serve`](https://deno.land/std@0.140.0/http/server.ts) function. +This API revolves around the [`serve`](https://deno.land/std/http/server.ts) +function. ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; serve((_req) => {/* .. */}); ``` @@ -34,7 +34,7 @@ underlying connection, such as the origin IP address. You must return a Let's use this information to finish our hello world script: ```js -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; serve((_req) => { return new Response("Hello World!", { diff --git a/deploy/tutorials/tutorial-postgres.md b/deploy/tutorials/tutorial-postgres.md index 8d6277cb1..b989e3d67 100644 --- a/deploy/tutorials/tutorial-postgres.md +++ b/deploy/tutorials/tutorial-postgres.md @@ -90,7 +90,7 @@ left navigation menu, and press "Open Playground". Let's start by the `std/http` module so we can start serving HTTP requests: ```ts -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; serve(async (req) => { return new Response("Not Found", { status: 404 }); @@ -105,7 +105,7 @@ Next, let's import the Postgres module, read the connection string from the environment variables, and create a connection pool. ```ts -import { serve } from "https://deno.land/std@0.140.0/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; import * as postgres from "https://deno.land/x/postgres@v0.14.0/mod.ts"; // Get the connection string from the environment variable "DATABASE_URL" diff --git a/deploy/tutorials/vite.md b/deploy/tutorials/vite.md index 494d94965..06a873f0f 100644 --- a/deploy/tutorials/vite.md +++ b/deploy/tutorials/vite.md @@ -99,7 +99,7 @@ Since there is a build step here, you will need to use the Github Actions mode. uses: denoland/deployctl@v1 with: project: "" - entrypoint: https://deno.land/std/http/file_server.ts + entrypoint: https://deno.land/std@$STD_VERSION/http/file_server.ts root: dist ``` @@ -109,7 +109,8 @@ Since there is a build step here, you will need to use the Github Actions mode. - running `deno task build` You will also have to set the entrypoint file to - `https://deno.land/std/http/file_server.ts`, and the root to `/dist`. + `https://deno.land/std@$STD_VERSION/http/file_server.ts`, and the root to + `/dist`. Note that this is not a file that exists in the Vite repo itself. Instead, it is an external program. When run, this program uploads all the static asset @@ -127,5 +128,5 @@ Deploy. ``` cd /dist -deployctl deploy --project= https://deno.land/std@0.171.0/http/file_server.ts +deployctl deploy --project= https://deno.land/std@$STD_VERSION/http/file_server.ts ``` diff --git a/docusaurus.config.js b/docusaurus.config.js index 44e40aa68..07820e42a 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -55,6 +55,9 @@ const config = { path: "deploy", routeBasePath: "/deploy", sidebarPath: require.resolve("./sidebars/deploy.js"), + remarkPlugins: [ + findReplace, + ], }, ], [ @@ -64,6 +67,9 @@ const config = { path: "kv", routeBasePath: "/kv", sidebarPath: require.resolve("./sidebars/kv.js"), + remarkPlugins: [ + findReplace, + ], }, ], // Enables our custom pages in "src" to use Tailwind classes diff --git a/runtime/manual/advanced/continuous_integration.md b/runtime/manual/advanced/continuous_integration.md index 4e2c5554a..b55938142 100644 --- a/runtime/manual/advanced/continuous_integration.md +++ b/runtime/manual/advanced/continuous_integration.md @@ -184,7 +184,7 @@ To demonstrate, let's say you have a project that uses the logger from `deno.land/std`: ```ts -import * as log from "https://deno.land/std/log/mod.ts"; +import * as log from "https://deno.land/std@$STD_VERSION/log/mod.ts"; ``` In order to increment this version, you can update the `import` statement and diff --git a/runtime/manual/advanced/deploying_deno/kinsta.md b/runtime/manual/advanced/deploying_deno/kinsta.md index 43bc9c62e..cba6a2d77 100644 --- a/runtime/manual/advanced/deploying_deno/kinsta.md +++ b/runtime/manual/advanced/deploying_deno/kinsta.md @@ -27,8 +27,8 @@ To do so, your `package.json` should look like this: ## Example application ```js -import { serve } from "https://deno.land/std/http/server.ts"; -import { parse } from "https://deno.land/std/flags/mod.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; +import { parse } from "https://deno.land/std@$STD_VERSION/flags/mod.ts"; const { args } = Deno; const argPort = parse(args).port ? Number(parse(args).port) : 8000; diff --git a/runtime/manual/advanced/jsx_dom/css.md b/runtime/manual/advanced/jsx_dom/css.md index e1a3341f1..b57cd422d 100644 --- a/runtime/manual/advanced/jsx_dom/css.md +++ b/runtime/manual/advanced/jsx_dom/css.md @@ -27,7 +27,7 @@ Then we will stringify the modified CSS AST and output it to the console: ```ts, ignore import * as css from "https://esm.sh/css@3.0.0"; -import { assert } from "https://deno.land/std/assert/mod.ts"; +import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; declare global { interface AbortSignal { diff --git a/runtime/manual/advanced/jsx_dom/deno_dom.md b/runtime/manual/advanced/jsx_dom/deno_dom.md index 13375b67a..0bac1171f 100644 --- a/runtime/manual/advanced/jsx_dom/deno_dom.md +++ b/runtime/manual/advanced/jsx_dom/deno_dom.md @@ -20,7 +20,7 @@ first heading it encounters and print out the text content of that heading: ```ts import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts"; -import { assert } from "https://deno.land/std/assert/mod.ts"; +import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; const document = new DOMParser().parseFromString( ` diff --git a/runtime/manual/advanced/jsx_dom/jsdom.md b/runtime/manual/advanced/jsx_dom/jsdom.md index 8eddffe24..acb6df202 100644 --- a/runtime/manual/advanced/jsx_dom/jsdom.md +++ b/runtime/manual/advanced/jsx_dom/jsdom.md @@ -66,7 +66,7 @@ first heading it encounters and print out the text content of that heading: ```ts, ignore import { JSDOM } from "jsdom"; -import { assert } from "https://deno.land/std/assert/mod.ts"; +import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; const { window: { document } } = new JSDOM( ` diff --git a/runtime/manual/advanced/jsx_dom/linkedom.md b/runtime/manual/advanced/jsx_dom/linkedom.md index bbbfaff48..21968a620 100644 --- a/runtime/manual/advanced/jsx_dom/linkedom.md +++ b/runtime/manual/advanced/jsx_dom/linkedom.md @@ -29,7 +29,7 @@ first heading it encounters and print out the text content of that heading: ```ts import { DOMParser } from "https://esm.sh/linkedom"; -import { assert } from "https://deno.land/std/assert/mod.ts"; +import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; const document = new DOMParser().parseFromString( ` diff --git a/runtime/manual/basics/connecting_to_databases.md b/runtime/manual/basics/connecting_to_databases.md index 933dad4ae..0ab31c108 100644 --- a/runtime/manual/basics/connecting_to_databases.md +++ b/runtime/manual/basics/connecting_to_databases.md @@ -224,7 +224,7 @@ for Deno, to run a GraphQL API server in Deno. #### Run a GraphQL API server with gql ```ts, ignore -import { Server } from "https://deno.land/std/http/server.ts"; +import { Server } from "https://deno.land/std@$STD_VERSION/http/server.ts"; import { GraphQLHTTP } from "https://deno.land/x/gql/mod.ts"; import { makeExecutableSchema } from "https://deno.land/x/graphql_tools@0.0.2/mod.ts"; import { gql } from "https://deno.land/x/graphql_tag@0.0.1/mod.ts"; diff --git a/runtime/manual/basics/debugging_your_code.md b/runtime/manual/basics/debugging_your_code.md index 24edafb71..ca7b7ab08 100644 --- a/runtime/manual/basics/debugging_your_code.md +++ b/runtime/manual/basics/debugging_your_code.md @@ -21,16 +21,16 @@ execution on the first line of code. ## Chrome Devtools Let's try debugging a program using Chrome Devtools. For this, we'll use -[file_server.ts](https://deno.land/std/http/file_server.ts) from -`std`, a static file server. +[file_server.ts](https://deno.land/std/http/file_server.ts) from `std`, a static +file server. Use the `--inspect-brk` flag to break execution on the first line: ```shell -$ deno run --inspect-brk --allow-read --allow-net https://deno.land/std/http/file_server.ts +$ deno run --inspect-brk --allow-read --allow-net https://deno.land/std@$STD_VERSION/http/file_server.ts Debugger listening on ws://127.0.0.1:9229/ws/1e82c406-85a9-44ab-86b6-7341583480b1 -Download https://deno.land/std/http/file_server.ts -Compile https://deno.land/std/http/file_server.ts +Download https://deno.land/std@$STD_VERSION/http/file_server.ts +Compile https://deno.land/std@$STD_VERSION/http/file_server.ts ... ``` diff --git a/runtime/manual/basics/env_variables.md b/runtime/manual/basics/env_variables.md index 56b2a46a4..97c4a2abf 100644 --- a/runtime/manual/basics/env_variables.md +++ b/runtime/manual/basics/env_variables.md @@ -33,7 +33,7 @@ To access the environment variables in the `.env` file, import the `load` function from the standard library. Then, import the configuration using it. ```ts -import { load } from "https://deno.land/std/dotenv/mod.ts"; +import { load } from "https://deno.land/std@$STD_VERSION/dotenv/mod.ts"; const env = await load(); const password = env["PASSWORD"]; @@ -45,5 +45,5 @@ console.log(password); ## `std/flags` The Deno standard library has a -[`std/flags` module](https://deno.land/std/flags/mod.ts) for -parsing command line arguments. +[`std/flags` module](https://deno.land/std/flags/mod.ts) for parsing command +line arguments. diff --git a/runtime/manual/basics/import_maps.md b/runtime/manual/basics/import_maps.md index 84e8da7d7..767ceaa43 100644 --- a/runtime/manual/basics/import_maps.md +++ b/runtime/manual/basics/import_maps.md @@ -45,7 +45,7 @@ written something similar in our `deno.json` configuration file: ```json { "imports": { - "fmt/": "https://deno.land/std/fmt/" + "fmt/": "https://deno.land/std@$STD_VERSION/fmt/" } } ``` diff --git a/runtime/manual/basics/modules/index.md b/runtime/manual/basics/modules/index.md index 842c9e891..ec1438a0c 100644 --- a/runtime/manual/basics/modules/index.md +++ b/runtime/manual/basics/modules/index.md @@ -149,7 +149,7 @@ export { assert, assertEquals, assertStringIncludes, -} from "https://deno.land/std/assert/mod.ts"; +} from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; ``` And throughout the same project, you can import from the `deps.ts` and avoid diff --git a/runtime/manual/basics/modules/integrity_checking.md b/runtime/manual/basics/modules/integrity_checking.md index 68fb43d0c..6dd584059 100644 --- a/runtime/manual/basics/modules/integrity_checking.md +++ b/runtime/manual/basics/modules/integrity_checking.md @@ -29,9 +29,9 @@ dependency: ```json { - "https://deno.land/std/textproto/mod.ts": "3118d7a42c03c242c5a49c2ad91c8396110e14acca1324e7aaefd31a999b71a4", - "https://deno.land/std/io/util.ts": "ae133d310a0fdcf298cea7bc09a599c49acb616d34e148e263bcb02976f80dee", - "https://deno.land/std/async/delay.ts": "35957d585a6e3dd87706858fb1d6b551cb278271b03f52c5a2cb70e65e00c26a", + "https://deno.land/std@$STD_VERSION/textproto/mod.ts": "3118d7a42c03c242c5a49c2ad91c8396110e14acca1324e7aaefd31a999b71a4", + "https://deno.land/std@$STD_VERSION/io/util.ts": "ae133d310a0fdcf298cea7bc09a599c49acb616d34e148e263bcb02976f80dee", + "https://deno.land/std@$STD_VERSION/async/delay.ts": "35957d585a6e3dd87706858fb1d6b551cb278271b03f52c5a2cb70e65e00c26a", ... } ``` diff --git a/runtime/manual/basics/modules/reloading_modules.md b/runtime/manual/basics/modules/reloading_modules.md index 0a01bef14..e2e4edd17 100644 --- a/runtime/manual/basics/modules/reloading_modules.md +++ b/runtime/manual/basics/modules/reloading_modules.md @@ -20,14 +20,14 @@ argument to a `--reload` flag. To reload all \$STD_VERSION standard modules: ```bash -deno cache --reload=https://deno.land/std my_module.ts +deno cache --reload=https://deno.land/std@$STD_VERSION my_module.ts ``` To reload specific modules (in this example - colors and file system copy) use a comma to separate URLs. ```bash -deno cache --reload=https://deno.land/std/fs/copy.ts,https://deno.land/std/fmt/colors.ts my_module.ts +deno cache --reload=https://deno.land/std@$STD_VERSION/fs/copy.ts,https://deno.land/std@$STD_VERSION/fmt/colors.ts my_module.ts ``` diff --git a/runtime/manual/basics/permissions.md b/runtime/manual/basics/permissions.md index 04524de60..732bfa051 100644 --- a/runtime/manual/basics/permissions.md +++ b/runtime/manual/basics/permissions.md @@ -100,7 +100,7 @@ This example restricts file system access by allowing read-only access to the attempting to read a file in the `/etc` directory: ```shell -$ deno run --allow-read=/usr https://deno.land/std/examples/cat.ts /etc/passwd +$ deno run --allow-read=/usr https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd error: Uncaught PermissionDenied: read access to "/etc/passwd", run again with the --allow-read flag ► $deno$/dispatch_json.ts:40:11 at DenoError ($deno$/errors.ts:20:5) @@ -111,15 +111,15 @@ Try it out again with the correct permissions by allowing access to `/etc` instead: ```shell -deno run --allow-read=/etc https://deno.land/std/examples/cat.ts /etc/passwd +deno run --allow-read=/etc https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd ``` You can further restrict some sub-paths to not be accessible, using `--deny-read` flag: ```shell -deno run --allow-read=/etc --deny-read=/etc/hosts https://deno.land/std/examples/cat.ts /etc/passwd -deno run --allow-read=/etc --deny-read=/etc/hosts https://deno.land/std/examples/cat.ts /etc/hosts +deno run --allow-read=/etc --deny-read=/etc/hosts https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd +deno run --allow-read=/etc --deny-read=/etc/hosts https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/hosts error: Uncaught PermissionDenied: read access to "/etc/hosts"... ``` diff --git a/runtime/manual/basics/standard_library.md b/runtime/manual/basics/standard_library.md index 2eabc3f7d..70266da70 100644 --- a/runtime/manual/basics/standard_library.md +++ b/runtime/manual/basics/standard_library.md @@ -9,8 +9,8 @@ Standard library is available at: https://deno.land/std Standard library is not yet stable and therefore it is versioned differently than Deno. For latest release consult https://deno.land/std or -https://deno.land/std/version.ts. The standard library is released -each time Deno is released. +https://deno.land/std/version.ts. The standard library is released each time +Deno is released. We strongly suggest to always use imports with pinned version of standard library to avoid unintended changes. For example, rather than linking to the @@ -19,7 +19,7 @@ compilation errors or unexpected behavior: ```typescript // import the latest release, this should be avoided -import { copy } from "https://deno.land/std/fs/copy.ts"; +import { copy } from "https://deno.land/std@$STD_VERSION/fs/copy.ts"; ``` instead, use a version of the std library which is immutable and will not @@ -27,5 +27,5 @@ change: ```typescript // imports from v$STD_VERSION of std, never changes -import { copy } from "https://deno.land/std/fs/copy.ts"; +import { copy } from "https://deno.land/std@$STD_VERSION/fs/copy.ts"; ``` diff --git a/runtime/manual/basics/testing/assertions.md b/runtime/manual/basics/testing/assertions.md index b11e6bd53..a284e7b36 100644 --- a/runtime/manual/basics/testing/assertions.md +++ b/runtime/manual/basics/testing/assertions.md @@ -5,7 +5,7 @@ To help developers write tests the Deno standard library comes with a built-in from `https://deno.land/std/assert/mod.ts`. ```js -import { assert } from "https://deno.land/std/assert/mod.ts"; +import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; Deno.test("Hello Test", () => { assert("Hello"); @@ -128,7 +128,7 @@ That's especially true when working with decimal numbers, where import { assertStrictEquals, assertThrows, -} from "https://deno.land/std/assert/mod.ts"; +} from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; Deno.test("Test Assert Strict Equals with float numbers", () => { assertStrictEquals(0.25 + 0.25, 0.25); @@ -145,7 +145,7 @@ it is possible to change it by passing a third optional parameter. import { assertAlmostEquals, assertThrows, -} from "https://deno.land/std/assert/mod.ts"; +} from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; Deno.test("Test Assert Almost Equals", () => { assertAlmostEquals(0.1 + 0.2, 0.3); @@ -161,7 +161,7 @@ To check if an object is an instance of a specific constructor, you can use the passed in variable has a specific type: ```ts -import { assertInstanceOf } from "https://deno.land/std/assert/mod.ts"; +import { assertInstanceOf } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; Deno.test("Test Assert Instance Type", () => { const variable = new Date() as unknown; @@ -311,7 +311,7 @@ something specific to the project you can add. Creating code. ```ts -import { AssertionError } from "https://deno.land/std/assert/mod.ts"; +import { AssertionError } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; function assertPowerOf(actual: number, expected: number, msg?: string): void { let received = actual; diff --git a/runtime/manual/basics/testing/behavior_driven_development.md b/runtime/manual/basics/testing/behavior_driven_development.md index 4dc92eec2..6e9763ea2 100644 --- a/runtime/manual/basics/testing/behavior_driven_development.md +++ b/runtime/manual/basics/testing/behavior_driven_development.md @@ -89,8 +89,10 @@ import { assertEquals, assertStrictEquals, assertThrows, -} from "https://deno.land/std/assert/mod.ts"; -import { User } from "https://deno.land/std/testing/bdd_examples/user.ts"; +} from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; +import { + User, +} from "https://deno.land/std@$STD_VERSION/testing/bdd_examples/user.ts"; Deno.test("User.users initially empty", () => { assertEquals(User.users.size, 0); @@ -134,14 +136,16 @@ import { assertEquals, assertStrictEquals, assertThrows, -} from "https://deno.land/std/assert/mod.ts"; +} from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import { afterEach, beforeEach, describe, it, -} from "https://deno.land/std/testing/bdd.ts"; -import { User } from "https://deno.land/std/testing/bdd_examples/user.ts"; +} from "https://deno.land/std@$STD_VERSION/testing/bdd.ts"; +import { + User, +} from "https://deno.land/std@$STD_VERSION/testing/bdd_examples/user.ts"; describe("User", () => { it("users initially empty", () => { @@ -196,9 +200,14 @@ import { assertEquals, assertStrictEquals, assertThrows, -} from "https://deno.land/std/assert/mod.ts"; -import { describe, it } from "https://deno.land/std/testing/bdd.ts"; -import { User } from "https://deno.land/std/testing/bdd_examples/user.ts"; +} from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; +import { + describe, + it, +} from "https://deno.land/std@$STD_VERSION/testing/bdd.ts"; +import { + User, +} from "https://deno.land/std@$STD_VERSION/testing/bdd_examples/user.ts"; const userTests = describe("User"); @@ -253,9 +262,14 @@ import { assertEquals, assertStrictEquals, assertThrows, -} from "https://deno.land/std/assert/mod.ts"; -import { describe, it } from "https://deno.land/std/testing/bdd.ts"; -import { User } from "https://deno.land/std/testing/bdd_examples/user.ts"; +} from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; +import { + describe, + it, +} from "https://deno.land/std@$STD_VERSION/testing/bdd.ts"; +import { + User, +} from "https://deno.land/std@$STD_VERSION/testing/bdd_examples/user.ts"; describe("User", () => { it("users initially empty", () => { diff --git a/runtime/manual/basics/testing/index.md b/runtime/manual/basics/testing/index.md index 50caec6b8..9a0a3adff 100644 --- a/runtime/manual/basics/testing/index.md +++ b/runtime/manual/basics/testing/index.md @@ -14,7 +14,7 @@ Firstly, let's create a file `url_test.ts` and register a test case using ```ts // url_test.ts -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; Deno.test("url test", () => { const url = new URL("./foo.js", "https://deno.land/"); @@ -40,7 +40,7 @@ switching between the forms (eg. when you need to quickly focus a single test for debugging, using `only: true` option): ```ts -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; // Compact form: name and function Deno.test("hello world #1", () => { @@ -91,7 +91,7 @@ You can also test asynchronous code by passing a test function that returns a promise. For this you can use the `async` keyword when defining a function: ```ts -import { delay } from "https://deno.land/std/async/delay.ts"; +import { delay } from "https://deno.land/std@$STD_VERSION/async/delay.ts"; Deno.test("async hello world", async () => { const x = 1 + 2; @@ -111,7 +111,7 @@ The test steps API provides a way to report distinct steps within a test and do setup and teardown code within that test. ```ts -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import { Client } from "https://deno.land/x/postgres@v0.15.0/mod.ts"; interface User { @@ -474,7 +474,7 @@ around `bar` and call `foo(spy)` in the testing code: ```js, ignore import sinon from "https://cdn.skypack.dev/sinon"; -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import { bar, foo } from "./my_file.js"; Deno.test("calls bar during execution of foo", () => { @@ -514,7 +514,7 @@ And then `import` in a test file: ```js, ignore import sinon from "https://cdn.skypack.dev/sinon"; -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import { foo, funcs } from "./my_file.js"; Deno.test("calls bar during execution of foo", () => { diff --git a/runtime/manual/basics/testing/mocking.md b/runtime/manual/basics/testing/mocking.md index 4d31ef095..1392ba81e 100644 --- a/runtime/manual/basics/testing/mocking.md +++ b/runtime/manual/basics/testing/mocking.md @@ -38,12 +38,12 @@ import { assertSpyCall, assertSpyCalls, spy, -} from "https://deno.land/std/testing/mock.ts"; -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +} from "https://deno.land/std@$STD_VERSION/testing/mock.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import { multiply, square, -} from "https://deno.land/std/testing/mock_examples/parameter_injection.ts"; +} from "https://deno.land/std@$STD_VERSION/testing/mock_examples/parameter_injection.ts"; Deno.test("square calls multiply and returns results", () => { const multiplySpy = spy(multiply); @@ -91,12 +91,12 @@ import { assertSpyCall, assertSpyCalls, spy, -} from "https://deno.land/std/testing/mock.ts"; -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +} from "https://deno.land/std@$STD_VERSION/testing/mock.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import { _internals, square, -} from "https://deno.land/std/testing/mock_examples/internals_injection.ts"; +} from "https://deno.land/std@$STD_VERSION/testing/mock_examples/internals_injection.ts"; Deno.test("square calls multiply and returns results", () => { const multiplySpy = spy(_internals, "multiply"); @@ -175,12 +175,12 @@ import { assertSpyCalls, returnsNext, stub, -} from "https://deno.land/std/testing/mock.ts"; -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +} from "https://deno.land/std@$STD_VERSION/testing/mock.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import { _internals, randomMultiple, -} from "https://deno.land/std/testing/mock_examples/random.ts"; +} from "https://deno.land/std@$STD_VERSION/testing/mock_examples/random.ts"; Deno.test("randomMultiple uses randomInt to generate random multiples between -10 and 10 times the value", () => { const randomIntStub = stub(_internals, "randomInt", returnsNext([-3, 3])); @@ -232,9 +232,12 @@ until real time is restored. You can control how time ticks forward with the ```ts // https://deno.land/std/testing/mock_examples/interval_test.ts -import { assertSpyCalls, spy } from "https://deno.land/std/testing/mock.ts"; -import { FakeTime } from "https://deno.land/std/testing/time.ts"; -import { secondInterval } from "https://deno.land/std/testing/mock_examples/interval.ts"; +import { + assertSpyCalls, + spy, +} from "https://deno.land/std@$STD_VERSION/testing/mock.ts"; +import { FakeTime } from "https://deno.land/std@$STD_VERSION/testing/time.ts"; +import { secondInterval } from "https://deno.land/std@$STD_VERSION/testing/mock_examples/interval.ts"; Deno.test("secondInterval calls callback every second and stops after being cleared", () => { const time = new FakeTime(); diff --git a/runtime/manual/basics/testing/snapshot_testing.md b/runtime/manual/basics/testing/snapshot_testing.md index 9db48e9c2..b030e3475 100644 --- a/runtime/manual/basics/testing/snapshot_testing.md +++ b/runtime/manual/basics/testing/snapshot_testing.md @@ -1,10 +1,10 @@ # Snapshot Testing The Deno standard library comes with a -[snapshot module](https://deno.land/std@$STD_VERSION/testing/snapshot.ts), which -enables developers to write tests which assert a value against a reference -snapshot. This reference snapshot, is a serialized representation of the -original value and is stored alongside the test file. +[snapshot module](https://deno.land/std/testing/snapshot.ts), which enables +developers to write tests which assert a value against a reference snapshot. +This reference snapshot, is a serialized representation of the original value +and is stored alongside the test file. Snapshot testing can be useful in many cases, as it enables catching a wide array of bugs with very little code. It is particularly helpful in situations diff --git a/runtime/manual/getting_started/configuration_file.md b/runtime/manual/getting_started/configuration_file.md index e396a8de9..6d63ed712 100644 --- a/runtime/manual/getting_started/configuration_file.md +++ b/runtime/manual/getting_started/configuration_file.md @@ -27,7 +27,7 @@ Since version 1.30, the `deno.json` configuration file acts as an ```jsonc { "imports": { - "std/": "https://deno.land/std/" + "std/": "https://deno.land/std@$STD_VERSION/" }, "tasks": { "dev": "deno run --watch main.ts" diff --git a/runtime/manual/getting_started/first_steps.md b/runtime/manual/getting_started/first_steps.md index 1ec06e646..3ee4da103 100644 --- a/runtime/manual/getting_started/first_steps.md +++ b/runtime/manual/getting_started/first_steps.md @@ -75,7 +75,7 @@ deno run first_steps.ts Or, try this script hosted at `https://deno.land/std/examples/curl.ts`: ```shell -deno run https://deno.land/std/examples/curl.ts https://deno.com +deno run https://deno.land/std@$STD_VERSION/examples/curl.ts https://deno.com ``` The program will display a prompt like this: @@ -148,7 +148,7 @@ One of the most common use cases for Deno is building an HTTP Server. Create a new file called `http_server.ts` and copy and paste the code below: ```ts -import { serve } from "https://deno.land/std/http/server.ts"; +import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; const handler = async (_request: Request): Promise => { const resp = await fetch("https://api.github.com/users/denoland", { diff --git a/runtime/manual/getting_started/setup_your_environment.md b/runtime/manual/getting_started/setup_your_environment.md index edcfde4a4..882c757ce 100644 --- a/runtime/manual/getting_started/setup_your_environment.md +++ b/runtime/manual/getting_started/setup_your_environment.md @@ -79,6 +79,8 @@ resolve this, make sure to set some unique `root_dir` for both `tsserver` and of such a configuration: ```lua +local nvim_lsp = require('lspconfig') + nvim_lsp.denols.setup { on_attach = on_attach, root_dir = nvim_lsp.util.root_pattern("deno.json", "deno.jsonc"), diff --git a/runtime/manual/index.mdx b/runtime/manual/index.mdx index ae15dffb9..a078f3587 100644 --- a/runtime/manual/index.mdx +++ b/runtime/manual/index.mdx @@ -4,6 +4,8 @@ sidebar_position: 1 pagination_next: manual/getting_started/installation --- +import { replacements } from "@site/src/components/Replacement"; + # Deno Runtime Quick Start [Deno](https://www.deno.com) @@ -259,7 +261,7 @@ above. Deno provides a [built-in test runner](./basics/testing/index.md), which uses an assertion module distributed via HTTPS URL. ```ts title="person_test.ts" -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import Person, { sayHello } from "./person.ts"; Deno.test("sayHello function", () => { @@ -302,8 +304,12 @@ file acts a bit like a `package.json` file in Node.js. One of the things you can use `deno.json` for is configuring an [import map](./basics/import_maps.md), which will let you set up aliases for -frequently used modules. To demonstrate, let's pin the version of the standard -library we want to use in our project to version `0.200.0`. +frequently used modules. + +

+ To demonstrate, let's pin the version of the standard library we want to + use in our project to version { replacements.STD_VERSION }. +

Create a `deno.jsonc` file with the following contents. @@ -312,7 +318,7 @@ Create a `deno.jsonc` file with the following contents. "imports": { // The dollar sign in front of "std" isn't special - it's an optional // convention to show that $std is an alias set up in an import map - "$std/": "https://deno.land/std@0.200.0/" + "$std/": "https://deno.land/std@$STD_VERSION/" } } ``` diff --git a/runtime/manual/node/how_to_with_npm/prisma.md b/runtime/manual/node/how_to_with_npm/prisma.md index 02da75fad..2eb8f2a8a 100644 --- a/runtime/manual/node/how_to_with_npm/prisma.md +++ b/runtime/manual/node/how_to_with_npm/prisma.md @@ -101,7 +101,7 @@ And in `./prisma/seed.ts`: ```ts, ignore import { Prisma, PrismaClient } from "../generated/client/deno/edge.ts"; -import { load } from "https://deno.land/std/dotenv/mod.ts"; +import { load } from "https://deno.land/std@$STD_VERSION/dotenv/mod.ts"; const envVars = await load(); @@ -169,7 +169,7 @@ Then, in your `main.ts` file: ```ts, ignore import { PrismaClient } from "./generated/client/deno/edge.ts"; import { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts"; -import { load } from "https://deno.land/std/dotenv/mod.ts"; +import { load } from "https://deno.land/std@$STD_VERSION/dotenv/mod.ts"; const envVars = await load(); diff --git a/runtime/manual/node/how_to_with_npm/redis.md b/runtime/manual/node/how_to_with_npm/redis.md index 7f5018587..79acbe88f 100644 --- a/runtime/manual/node/how_to_with_npm/redis.md +++ b/runtime/manual/node/how_to_with_npm/redis.md @@ -22,7 +22,7 @@ information from the user to query our API. The second is Redis. We can grab the node package for Redis using the `npm:` modifier: ```tsx, ignore -import { Server } from "https://deno.land/std/http/server.ts"; +import { Server } from "https://deno.land/std@$STD_VERSION/http/server.ts"; import { createClient } from "npm:redis@^4.5"; ``` diff --git a/runtime/manual/references/contributing/style_guide.md b/runtime/manual/references/contributing/style_guide.md index c108536f2..2fafb1424 100644 --- a/runtime/manual/references/contributing/style_guide.md +++ b/runtime/manual/references/contributing/style_guide.md @@ -313,7 +313,7 @@ test myTestFunction ... ok Example of test: ```ts, ignore -import { assertEquals } from "https://deno.land/std/assert/mod.ts"; +import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; import { foo } from "./mod.ts"; Deno.test("myTestFunction", function () { diff --git a/runtime/manual/references/vscode_deno/index.md b/runtime/manual/references/vscode_deno/index.md index 8b8865a0c..d9296ce77 100644 --- a/runtime/manual/references/vscode_deno/index.md +++ b/runtime/manual/references/vscode_deno/index.md @@ -190,7 +190,7 @@ editor. When you have a block of code that provides a test, like: ```ts -import { assert } from "https://deno.land/std/assert/mod.ts"; +import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts"; Deno.test({ name: "a test case", diff --git a/runtime/manual/runtime/workers.md b/runtime/manual/runtime/workers.md index 429403034..ad056051b 100644 --- a/runtime/manual/runtime/workers.md +++ b/runtime/manual/runtime/workers.md @@ -34,7 +34,7 @@ it's just an unfortunate interaction of features, and it also happens in all browsers that support module workers. ```ts, ignore -import { delay } from "https://deno.land/std/async/delay.ts"; +import { delay } from "https://deno.land/std@$STD_VERSION/async/delay.ts"; // First await: waits for a second, then continues running the module. await delay(1000); diff --git a/runtime/manual/tools/benchmarker.md b/runtime/manual/tools/benchmarker.md index 1d40d0d98..804437422 100644 --- a/runtime/manual/tools/benchmarker.md +++ b/runtime/manual/tools/benchmarker.md @@ -98,7 +98,7 @@ you want to measure. Everything outside of the section between these two calls will be excluded from the measurement. ```ts, ignore -import { readAll } from "https://deno.land/std/streams/mod.ts"; +import { readAll } from "https://deno.land/std@$STD_VERSION/streams/mod.ts"; Deno.bench("foo", async (b) => { // Open a file that we will act upon. diff --git a/runtime/tutorials/how_to_with_npm/prisma.md b/runtime/tutorials/how_to_with_npm/prisma.md index e22bf70e6..dafcca1f7 100644 --- a/runtime/tutorials/how_to_with_npm/prisma.md +++ b/runtime/tutorials/how_to_with_npm/prisma.md @@ -101,7 +101,7 @@ And in `./prisma/seed.ts`: ```ts, ignore import { Prisma, PrismaClient } from "../generated/client/deno/edge.ts"; -import { load } from "https://deno.land/std/dotenv/mod.ts"; +import { load } from "https://deno.land/std@$STD_VERSION/dotenv/mod.ts"; const envVars = await load(); @@ -169,7 +169,7 @@ Then, in your `main.ts` file: ```ts, ignore import { PrismaClient } from "./generated/client/deno/edge.ts"; import { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts"; -import { load } from "https://deno.land/std/dotenv/mod.ts"; +import { load } from "https://deno.land/std@$STD_VERSION/dotenv/mod.ts"; const envVars = await load(); diff --git a/runtime/tutorials/how_to_with_npm/redis.md b/runtime/tutorials/how_to_with_npm/redis.md index 6ae388681..bd824822b 100644 --- a/runtime/tutorials/how_to_with_npm/redis.md +++ b/runtime/tutorials/how_to_with_npm/redis.md @@ -22,7 +22,7 @@ information from the user to query our API. The second is Redis. We can grab the node package for Redis using the `npm:` modifier: ```tsx, ignore -import { Server } from "https://deno.land/std/http/server.ts"; +import { Server } from "https://deno.land/std@$STD_VERSION/http/server.ts"; import { createClient } from "npm:redis@^4.5"; ``` diff --git a/runtime/tutorials/subprocess.md b/runtime/tutorials/subprocess.md index d43dea957..61698cced 100644 --- a/runtime/tutorials/subprocess.md +++ b/runtime/tutorials/subprocess.md @@ -64,7 +64,9 @@ This example is the equivalent of running `yes &> ./process_output` in bash. * subprocess_piping_to_file.ts */ -import { mergeReadableStreams } from "https://deno.land/std/streams/merge_readable_streams.ts"; +import { + mergeReadableStreams, +} from "https://deno.land/std@$STD_VERSION/streams/merge_readable_streams.ts"; // create the file to attach the process to const file = await Deno.open("./process_output.txt", { diff --git a/src/components/Replacement.jsx b/src/components/Replacement.jsx index 1be4d511f..c5627d007 100644 --- a/src/components/Replacement.jsx +++ b/src/components/Replacement.jsx @@ -1,5 +1,6 @@ const React = require("react"); -const replacements = require("../../replacements.json"); + +export const replacements = require("../../replacements.json"); export default function Replacement(props) { return {replacements[props.for] || ""}; From e1afa3b02668a68671583e8835106650c99e1125 Mon Sep 17 00:00:00 2001 From: Kevin Whinnery Date: Fri, 15 Sep 2023 07:04:54 -0500 Subject: [PATCH 2/2] updates --- deploy/manual/index.mdx | 2 +- runtime/manual/index.mdx | 28 +-- runtime/manual/node/compatibility.mdx | 281 +++++++++++++++++++++++--- 3 files changed, 273 insertions(+), 38 deletions(-) diff --git a/deploy/manual/index.mdx b/deploy/manual/index.mdx index 2e8acf498..e45715005 100644 --- a/deploy/manual/index.mdx +++ b/deploy/manual/index.mdx @@ -170,6 +170,6 @@ centers around the world, ready to handle large volumes of traffic. ## Next Steps Now that you've created your first project, you can -[check out the kids of apps](./use-cases.md) you can run on Deploy. You could +[check out the kinds of apps](./use-cases.md) you can run on Deploy. You could also skip right to [setting up your own custom domain](./custom-domains.md). We're so excited to see what you'll ship with Deploy! diff --git a/runtime/manual/index.mdx b/runtime/manual/index.mdx index a078f3587..07324dc7e 100644 --- a/runtime/manual/index.mdx +++ b/runtime/manual/index.mdx @@ -158,7 +158,7 @@ console.log(await site.text()); Run this program **without** the `-A` flag - what happens then? -```ts +```bash deno run hello.ts ``` @@ -174,6 +174,12 @@ kevin@kevin-deno scratchpad % deno run index.ts └ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all net permissions) > ``` +In the prompt, you might have noticed that it mentions the CLI flag you'd need to run your code with permission to access the network - the `--allow-net` flag. If you run the script again using this flag, you won't be prompted to interactively grant network access to your script: + +```bash +deno run --allow-net hello.ts +``` + For simplicity, we will sometimes show examples that use `deno run -A ...`, but whenever possible (and in your production or CI environments), we'd encourage you to take advantage of Deno's full suite of @@ -360,7 +366,7 @@ following - a simple HTTP server using the popular [Express](https://expressjs.com) framework. ```js -import express from "npm:express"; +import express from "npm:express@4"; const app = express(); @@ -405,11 +411,9 @@ exist in the Deno ecosystem. Here are a few of the most popular choices. Deno. Pages are server-rendered by default, with the option to include interactive islands that run JavaScript on the client. If you're new to Deno and looking for a place to start, we recommend trying Fresh first! -- [Hono](https://hono.dev/) - Hono is a light-weight web framework in the - tradition of [Express](https://expressjs.com). Great for API servers and - simple web applications. -- [Oak](https://deno.land/x/oak) - Oak is a middleware framework modeled after - [Koa](https://koajs.com/). +- [Hono](https://hono.dev/getting-started/deno) - Hono is a light-weight web + framework in the tradition of [Express](https://expressjs.com). Great for + API servers and simple web applications. ### Deno-compatible frameworks @@ -418,13 +422,11 @@ exist in the Deno ecosystem. Here are a few of the most popular choices. starting with [this template](https://github.com/denoland/deno-astro-template). - [SvelteKit](https://kit.svelte.dev/) - SvelteKit is another more - runtime-agnostic web framework that can be used with Deno. We recommend using - [this adapter](https://github.com/dbushell/sveltekit-adapter-deno) in your - SvelteKit application to use SvelteKit with Deno. + runtime-agnostic web framework that can be used with Deno. We recommend + starting with [this template](https://github.com/denoland/deno-sveltekit-template). - [Nuxt (Vue)](https://nuxt.com/) - Nuxt is a hybrid SSR and client-side - framework that works with Deno. - [Follow these instructions](https://nitro.unjs.io/deploy/providers/deno) to - build this Nitro-based framework for Deno. + framework that works with Deno. We recommend + starting with [this template](https://github.com/denoland/deno-nuxt-template). Many more frameworks support Deno than are listed here, but we'd recommend these as a great starting point. diff --git a/runtime/manual/node/compatibility.mdx b/runtime/manual/node/compatibility.mdx index 630d263ca..30f6a4c52 100644 --- a/runtime/manual/node/compatibility.mdx +++ b/runtime/manual/node/compatibility.mdx @@ -5,30 +5,24 @@ Node compatibility is an ongoing project - help us identify gaps and let us know which modules you need by [opening an issue on GitHub](https://github.com/denoland/deno). -### Fully supported built-in modules +## Built-in module support -- [`node:assert`](https://nodejs.org/api/assert.html) -- [`node:assert/strict`](https://nodejs.org/api/assert.html) -- [`node:buffer`](https://nodejs.org/api/buffer.html) -- [`node:console`](https://nodejs.org/api/console.html) -- [`node:dgram`](https://nodejs.org/api/dgram.html) -- [`node:diagnostics_channel`](https://nodejs.org/api/diagnostics_channel.html) -- [`node:events`](https://nodejs.org/api/events.html) -- [`node:module`](https://nodejs.org/api/module.html) -- [`node:os`](https://nodejs.org/api/os.html) -- [`node:path`, `node:path/posix`, `node:path/win32`](https://nodejs.org/api/path.html) -- [`node:punycode`](https://nodejs.org/api/punycode.html) -- [`node:querystring`](https://nodejs.org/api/querystring.html) -- [`node:readline`](https://nodejs.org/api/readline.html) -- [`node:stream`, `node:stream/consumers`, `node:stream/promises`, `node:stream/web`](https://nodejs.org/api/stream.html) -- [`node:sys`](https://nodejs.org/api/util.html) -- [`node:timers`, `node:timers/promises`](https://nodejs.org/api/timers.html) -- [`node:url`](https://nodejs.org/api/url.html) -- [`node:util`, `node:util/types`](https://nodejs.org/api/util.html) +✅ = Full support   ℹ️ = Partial support   ❌ = Stubs only -### Partially supported built-in modules - -ℹ️ = Partial support   ❌ = Stubs only +
+ + node:assert, node:assert/strict +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
@@ -47,6 +41,21 @@ which modules you need by

+
+ + node:buffer +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:child_process @@ -76,6 +85,21 @@ which modules you need by

+
+ + node:console +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:crypto @@ -102,6 +126,36 @@ which modules you need by

+
+ + node:dgram +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+ +
+ + node:diagnostics_channel +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:dns @@ -130,6 +184,21 @@ which modules you need by

+
+ + node:events +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:fs, node:fs/promises @@ -222,6 +291,21 @@ which modules you need by

+
+ + node:module +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:net @@ -238,6 +322,36 @@ which modules you need by

+
+ + node:os +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+ +
+ + node:path +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:perf_hooks @@ -255,6 +369,21 @@ which modules you need by

+
+ + node:punycode +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:process @@ -272,6 +401,36 @@ which modules you need by

+
+ + node:querystring +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+ +
+ + node:readline +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:repl @@ -289,6 +448,22 @@ which modules you need by

+
+ + node:stream, node:stream/consumers,  + node:stream/promises, node:stream/web +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:string_decoder @@ -305,6 +480,21 @@ which modules you need by

+
+ + node:sys +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:test @@ -320,6 +510,21 @@ which modules you need by

+
+ + node:timers, node:timers/promises +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:tls @@ -363,6 +568,36 @@ which modules you need by

+
+ + node:util +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+ +
+ + node:url +
+ +
+
+

+ Fully supported. +

+

+ Node.js docs +

+
+
node:v8 @@ -450,8 +685,6 @@ which modules you need by ## Globals -These global objects are fully supported in Deno: - This is the list of Node globals that Deno supports. These globals are only available in the `npm` package scope. In your own code you can use them by importing them from the relevant `node:` module.