Skip to content

Commit

Permalink
update deno.land/std usage to jsr.io/@std (#587)
Browse files Browse the repository at this point in the history
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
Co-authored-by: Luca Casonato <hello@lcas.dev>
  • Loading branch information
3 people authored Jul 26, 2024
1 parent 71e306e commit 3114421
Show file tree
Hide file tree
Showing 112 changed files with 792 additions and 849 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/update_versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ interface ReplacementsData {

const replacementsFile = $.path("replacements.json");
const latestCliVersion = (await getLatestTagForRepo("deno")).replace("v", "");
const latestStdVersion = await getLatestStdVersion();

$.log(`cli version: ${latestCliVersion}`);
$.log(`std version: ${latestStdVersion}`);

const replacements = replacementsFile.readJsonSync<ReplacementsData>();

replacements.CLI_VERSION = latestCliVersion;
replacements.STD_VERSION = latestStdVersion;

replacementsFile.writeJsonPrettySync(replacements);

Expand All @@ -39,14 +36,6 @@ async function getLatestTagForRepo(name: string) {
return latestRelease.tag_name;
}

async function getLatestStdVersion() {
$.logStep(`Fetching latest version number of std`);
const latestRelease = await $.request(`https://deno.com/versions.json`).json<
{ std: string[] }
>();
return latestRelease.std[0];
}

async function tryCreatePr() {
// check for local changes
await $`git add .`;
Expand Down
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,6 @@ a feature or API was released in. For example - in the Node 20 docs, the
[register function](https://nodejs.org/dist/latest-v20.x/docs/api/module.html#moduleregister)
is marked as being added in version `20.6.0`.

## Including version numbers in code and content

It may occasionally be desirable to dynamically include the current Deno CLI or
standard library version in content or code samples. We can accomplish this
using the `replacements.json` file at the root of this repository.

Any values you would like to change once, and then have appear dynamically in a
number of generated files, should be included in `replacements.json`.

In code samples (fenced with backticks), you can include a `$` character,
followed by the replacement variable name, directly within the code sample. When
the markdown is transformed, the current version number will be replaced within
it.

```ts
import { copy } from "https://deno.land/std@$STD_VERSION/fs/copy.ts";
```

## Contribution

We are very grateful for any help you can offer to improve Deno's documentation!
Expand Down
2 changes: 1 addition & 1 deletion _components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const data = [
},
{
label: "Standard Library",
href: "https://deno.land/std",
href: "https://jsr.io/@std",
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion by-example/byte-manipulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty beginner
* @tags cli
* @run <url>
* @resource {$std/bytes} Doc: std/bytes
* @resource {https://jsr.io/@std/bytes/doc} Doc: @std/bytes
* @group Encoding
*
* When working with lower-level data we often deal
Expand Down
4 changes: 2 additions & 2 deletions by-example/command-line-arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @difficulty beginner
* @tags cli
* @run <url> Deno Sushi --help --version=1.0.0 --no-color
* @resource {https://deno.land/api?s=Deno.args} Doc: Deno.args
* @resource {$std/cli/parse_args.ts} Doc: std/cli
* @resource {https://docs.deno.com/api/deno/~/Deno.args} Doc: Deno.args
* @resource {https://jsr.io/@std/cli/doc/parse-args/~} Doc: @std/cli
* @group CLI
*
* Command line arguments are often used to pass configuration options to a
Expand Down
4 changes: 2 additions & 2 deletions by-example/create-remove-directories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @difficulty beginner
* @tags cli
* @run --allow-write <url>
* @resource {https://deno.land/api?s=Deno.mkdir} Doc: Deno.mkdir
* @resource {https://deno.land/api?s=Deno.remove} Doc: Deno.remove
* @resource {https://docs.deno.com/api/deno/~/Deno.mkdir} Doc: Deno.mkdir
* @resource {https://docs.deno.com/api/deno/~/Deno.remove} Doc: Deno.remove
* @group File System
*
* Creating and removing directories is a common task. Deno has a number of
Expand Down
2 changes: 1 addition & 1 deletion by-example/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @tags cli, deploy
* @run --unstable <url>
* @resource {https://docs.deno.com/deploy/kv/manual/cron} Deno Cron user guide
* @resource {https://deno.land/api?s=Deno.cron&unstable=} Deno Cron Runtime API docs
* @resource {https://docs.deno.com/api/deno/~/Deno.cron} Deno Cron Runtime API docs
* @group Scheduled Tasks
*
* Deno Cron is a cron task scheduler built into the Deno runtime and works with
Expand Down
2 changes: 1 addition & 1 deletion by-example/deleting-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @title Deleting Files
* @difficulty beginner
* @tags cli
* @resource {https://deno.land/api?s=Deno.remove} Doc: Deno.remove
* @resource {https://docs.deno.com/api/deno/~/Deno.remove} Doc: Deno.remove
* @group File System
*
* Removing files and directories is a common task. Deno has a number of
Expand Down
2 changes: 1 addition & 1 deletion by-example/deno-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty beginner
* @tags cli
* @run <url>
* @resource {https://deno.land/api?s=Deno.version} Doc: Deno.version
* @resource {https://docs.deno.com/api/deno/~/Deno.version} Doc: Deno.version
* @group CLI
*
* How to examine the version of Deno being used.
Expand Down
2 changes: 1 addition & 1 deletion by-example/dns-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty beginner
* @tags cli, deploy
* @run --allow-net <url>
* @resource {https://deno.land/api?s=Deno.resolveDns} Doc: Deno.resolveDns
* @resource {https://docs.deno.com/api/deno/~/Deno.resolveDns} Doc: Deno.resolveDns
* @resource {https://developer.mozilla.org/en-US/docs/Glossary/DNS} MDN: DNS
* @group Network
*
Expand Down
2 changes: 1 addition & 1 deletion by-example/environment-variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty beginner
* @tags cli, deploy
* @run --allow-env <url>
* @resource {https://deno.land/api?s=Deno.env} Doc: Deno.env
* @resource {https://docs.deno.com/api/deno/~/Deno.env} Doc: Deno.env
* @resource {https://docs.deno.com/deploy/manual/environment-variables} Deploy Docs: Environment Variables
* @group System
*
Expand Down
2 changes: 1 addition & 1 deletion by-example/hashing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli, deploy
* @run --allow-read <url>
* @resource {https://deno.land/api?s=SubtleCrypto} Doc: crypto.subtle
* @resource {https://docs.deno.com/api/web/~/SubtleCrypto} Doc: crypto.subtle
* @resource {https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest} MDN: Cryptographic Digests
* @group Cryptography
*
Expand Down
4 changes: 2 additions & 2 deletions by-example/http-server-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @difficulty intermediate
* @tags cli, deploy
* @run --allow-net --allow-read <url>
* @resource {https://deno.land/api?s=Deno.serve} Doc: Deno.serve
* @resource {$std/http/file_server.ts} Doc: std/http/file_server
* @resource {https://docs.deno.com/api/deno/~/Deno.serve} Doc: Deno.serve
* @resource {https://jsr.io/@std/http#file-server} Doc: @std/http/file-server
* @resource {/examples/http-server} Example: HTTP Server: Hello World
* @group Network
*
Expand Down
2 changes: 1 addition & 1 deletion by-example/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli, deploy
* @run --allow-net <url>
* @resource {https://deno.land/api?s=Deno.serve} Doc: Deno.serve
* @resource {https://docs.deno.com/api/deno/~/Deno.serve} Doc: Deno.serve
* @resource {https://developer.mozilla.org/en-US/docs/Web/API/Response} MDN: Response
* @playground https://dash.deno.com/playground/example-helloworld
* @group Network
Expand Down
11 changes: 7 additions & 4 deletions by-example/import-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ sayHello("World");
import * as util from "./util.ts";
util.sayHello("World");

// Imports don't have to be relative, they can also reference absolute file or
// https URLs.
import { VERSION } from "https://deno.land/std/version.ts";
console.log(VERSION);
// Imports don't have to be relative, they can also reference absolute file,
// https, or [JSR](https://jsr.io) URLs.
import { camelCase } from "jsr:@luca/cases@1";
console.log(camelCase("hello world")); // helloWorld

import OpenAI from "https://deno.land/x/openai@v4.53.0/mod.ts";
const client = new OpenAI();
2 changes: 1 addition & 1 deletion by-example/kv-watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @tags cli, deploy
* @run --unstable <url>
* @resource {https://docs.deno.com/deploy/kv/manual} Deno KV user guide
* @resource {https://deno.land/api?unstable=&s=Deno.Kv} Deno KV Runtime API docs
* @resource {https://docs.deno.com/api/deno/~/Deno.Kv} Deno KV Runtime API docs
* @group Databases
*
* Deno KV watch allows you to detect changes to your KV database, making
Expand Down
2 changes: 1 addition & 1 deletion by-example/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @tags cli, deploy
* @run --unstable <url>
* @resource {https://docs.deno.com/deploy/kv/manual} Deno KV user guide
* @resource {https://deno.land/api?unstable=&s=Deno.Kv} Deno KV Runtime API docs
* @resource {https://docs.deno.com/api/deno/~/Deno.Kv} Deno KV Runtime API docs
* @group Databases
*
* Deno KV is a key/value database built in to the Deno runtime, and works with
Expand Down
2 changes: 1 addition & 1 deletion by-example/moving-renaming-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty beginner
* @tags cli
* @run --allow-read=./ --allow-write=./ <url>
* @resource {https://deno.land/api?s=Deno.rename} Doc: Deno.rename
* @resource {https://docs.deno.com/api/deno/~/Deno.rename} Doc: Deno.rename
* @group File System
*
* An example of how to move and rename files and directories in Deno.
Expand Down
2 changes: 1 addition & 1 deletion by-example/os-signals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty beginner
* @tags cli
* @run <url>
* @resource {https://deno.land/api?s=Deno.addSignalListener} Doc: Deno.addSignalListener
* @resource {https://docs.deno.com/api/deno/~/Deno.addSignalListener} Doc: Deno.addSignalListener
* @group System
*
* You can listen for OS signals using the `Deno.addSignalListener` function.
Expand Down
4 changes: 2 additions & 2 deletions by-example/path-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @difficulty beginner
* @tags cli
* @run --allow-read <url>
* @resource {$std/path} Deno: std/path
* @resource {https://deno.land/api?s=Deno.cwd} Deno: Deno.cwd
* @resource {https://jsr.io/@std/path/doc} Doc: @std/path
* @resource {https://docs.deno.com/api/deno/~/Deno.cwd} Deno: Deno.cwd
* @group File System
*
* Many applications need to manipulate file paths in one way or another.
Expand Down
4 changes: 2 additions & 2 deletions by-example/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty beginner
* @tags cli
* @run <url>
* @resource {https://deno.land/api?s=Deno.Permissions} Doc: Deno.Permissions
* @resource {https://docs.deno.com/api/deno/~/Deno.Permissions} Doc: Deno.Permissions
* @group CLI
*
* There are times where depending on the state of permissions
Expand Down Expand Up @@ -42,7 +42,7 @@ console.log(readStatus.state);
// In the case that we no longer need a permission, it is also possible
// to revoke a process's access to that permission. This is useful when
// a process starts running untrusted code.
import { assert } from "$std/assert/assert.ts";
import { assert } from "jsr:@std/assert@1/assert.ts";

const runStatus = await Deno.permissions.revoke({ name: "run" });
assert(runStatus.state !== "granted");
2 changes: 1 addition & 1 deletion by-example/queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @tags cli, deploy
* @run --unstable <url>
* @resource {https://docs.deno.com/deploy/kv/manual/queue_overview} Deno Queues user guide
* @resource {https://deno.land/api?s=Deno.Kv&unstable=} Deno Queues Runtime API docs
* @resource {https://docs.deno.com/api/deno/~/Deno.Kv} Deno Queues Runtime API docs
* @group Scheduled Tasks
*
* Deno Queues, built on Deno KV, allow you to offload parts of your application
Expand Down
6 changes: 3 additions & 3 deletions by-example/reading-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* @difficulty beginner
* @tags cli, deploy
* @run --allow-read <url>
* @resource {https://deno.land/api?s=Deno.readFile} Doc: Deno.readFile
* @resource {https://deno.land/api?s=Deno.open} Doc: Deno.open
* @resource {https://deno.land/api?s=Deno.FsFile} Doc: Deno.FsFile
* @resource {https://docs.deno.com/api/deno/~/Deno.readFile} Doc: Deno.readFile
* @resource {https://docs.deno.com/api/deno/~/Deno.open} Doc: Deno.open
* @resource {https://docs.deno.com/api/deno/~/Deno.FsFile} Doc: Deno.FsFile
* @group File System
*
* Many applications need to read files from disk. Deno provides a simple
Expand Down
4 changes: 2 additions & 2 deletions by-example/streaming-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @difficulty intermediate
* @tags cli
* @run --allow-read --allow-write <url>
* @resource {https://deno.land/api?s=Deno.open} Doc: Deno.open
* @resource {https://deno.land/api?s=Deno.FsFile} Doc: Deno.FsFile
* @resource {https://docs.deno.com/api/deno/~/Deno.open} Doc: Deno.open
* @resource {https://docs.deno.com/api/deno/~/Deno.FsFile} Doc: Deno.FsFile
* @group File System
*
* Sometimes we need more granular control over file operations.
Expand Down
2 changes: 1 addition & 1 deletion by-example/subprocesses-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli
* @run --allow-run <url>
* @resource {https://deno.land/api?s=Deno.Command} Doc: Deno.Command
* @resource {https://docs.deno.com/api/deno/~/Deno.Command} Doc: Deno.Command
* @group System
*
* We don't often write programs in isolation. In a lot of cases we want
Expand Down
2 changes: 1 addition & 1 deletion by-example/subprocesses-spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli
* @run --allow-run <url>
* @resource {https://deno.land/api?s=Deno.Command} Doc: Deno.Command
* @resource {https://docs.deno.com/api/deno/~/Deno.Command} Doc: Deno.Command
* @group System
*
* For more complex usecases, we don't simply want the output of some
Expand Down
4 changes: 2 additions & 2 deletions by-example/symlinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @difficulty beginner
* @tags cli
* @run --allow-write --allow-read <url>
* @resource {https://deno.land/api?s=Deno.writeTextFile} Doc: Deno.writeTextFile
* @resource {https://deno.land/api?s=Deno.symlink} Doc: Deno.symlink
* @resource {https://docs.deno.com/api/deno/~/Deno.writeTextFile} Doc: Deno.writeTextFile
* @resource {https://docs.deno.com/api/deno/~/Deno.symlink} Doc: Deno.symlink
* @group File System
*
* Creating and resolving symlink is a common task. Deno has a number of
Expand Down
2 changes: 1 addition & 1 deletion by-example/tcp-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli
* @run --allow-net <url>
* @resource {https://deno.land/api?s=Deno.connect} Doc: Deno.connect
* @resource {https://docs.deno.com/api/deno/~/Deno.connect} Doc: Deno.connect
* @resource {/examples/tcp-listener} Example: TCP Listener
* @group Network
*
Expand Down
2 changes: 1 addition & 1 deletion by-example/tcp-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli
* @run --allow-net <url>
* @resource {https://deno.land/api?s=Deno.listen} Doc: Deno.listen
* @resource {https://docs.deno.com/api/deno/~/Deno.listen} Doc: Deno.listen
* @group Network
*
* An example of a TCP listener on localhost that will log the message if written to and close the connection if connected to.
Expand Down
4 changes: 2 additions & 2 deletions by-example/temporary-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @difficulty beginner
* @tags cli
* @run --allow-read --allow-write <url>
* @resource {https://deno.land/api?s=Deno.makeTempFile} Doc: Deno.makeTempFile
* @resource {https://deno.land/api?s=Deno.makeTempDir} Doc: Deno.makeTempDir
* @resource {https://docs.deno.com/api/deno/~/Deno.makeTempFile} Doc: Deno.makeTempFile
* @resource {https://docs.deno.com/api/deno/~/Deno.makeTempDir} Doc: Deno.makeTempDir
* @group File System
*
* Temporary files and directories are used to store data that is not intended
Expand Down
2 changes: 1 addition & 1 deletion by-example/tls-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli
* @run --allow-net --allow-read <url>
* @resource {https://deno.land/api?s=Deno.connectTls} Doc: Deno.connectTls
* @resource {https://docs.deno.com/api/deno/~/Deno.connectTls} Doc: Deno.connectTls
* @resource {/examples/tls-listener.ts} Example: TCP/TLS Listener
* @group Network
*
Expand Down
2 changes: 1 addition & 1 deletion by-example/tls-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli
* @run --allow-net --allow-read <url>
* @resource {https://deno.land/api?s=Deno.listenTls} Doc: Deno.listenTls
* @resource {https://docs.deno.com/api/deno/~/Deno.listenTls} Doc: Deno.listenTls
* @group Network
*
* An example of a TCP listener using TLS on localhost that will log the message if written to and close the connection if connected to.
Expand Down
2 changes: 1 addition & 1 deletion by-example/udp-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli
* @run --allow-net --unstable <url>
* @resource {https://deno.land/api?s=Deno.connect} Doc: Deno.connect
* @resource {https://docs.deno.com/api/deno/~/Deno.connect} Doc: Deno.connect
* @resource {/examples/udp-listener.ts} Example: UDP Listener
* @group Network
*
Expand Down
2 changes: 1 addition & 1 deletion by-example/udp-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @difficulty intermediate
* @tags cli
* @run --allow-net --unstable <url>
* @resource {https://deno.land/api?s=Deno.listenDatagram} Doc: Deno.listenDatagram
* @resource {https://docs.deno.com/api/deno/~/Deno.listenDatagram} Doc: Deno.listenDatagram
* @resource {/examples/udp-connector.ts} Example: UDP Connector
* @group Network
*
Expand Down
4 changes: 2 additions & 2 deletions by-example/ulid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ console.log(ulid(timestamp));
console.log(ulid(timestamp));

// Given a ULID, you can get the timestamp back out
import { decodeTime } from "$std/ulid/mod.ts";
import { decodeTime } from "jsr:@std/ulid@0.224/mod.ts";
const myULID = ulid();
console.log(decodeTime(myULID));

// Optionally, if you're not on a distributed system and want monotonic ULIDs,
// you can use the monotonic ULID generator instead.
import { monotonicUlid } from "$std/ulid/mod.ts";
import { monotonicUlid } from "jsr:@std/ulid@0.224/mod.ts";
console.log(monotonicUlid(150000)); // 000XAL6S41ACTAV9WEVGEMMVR8
console.log(monotonicUlid(150000)); // 000XAL6S41ACTAV9WEVGEMMVR9
console.log(monotonicUlid(150000)); // 000XAL6S41ACTAV9WEVGEMMVRA
Loading

0 comments on commit 3114421

Please sign in to comment.