Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace deno.land/std with jsr:@std #377

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/update_versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@ import {

interface ReplacementsData {
CLI_VERSION: string;
STD_VERSION: string;
}

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

$.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 @@ -32,7 +28,7 @@ if (Deno.args.includes("--create-pr")) {
async function getLatestTagForRepo(name: string) {
$.logStep(`Fetching latest release for ${name}...`);
const latestRelease = await $.request(
`https://api.github.com/repos/denoland/${name}/releases/latest`
`https://api.github.com/repos/denoland/${name}/releases/latest`,
)
.header("accept", "application/vnd.github.v3+json")
.json<{ tag_name: string }>();
Expand Down Expand Up @@ -73,8 +69,7 @@ async function tryCreatePr() {
$.log(`Opened PR at ${openedPr.data.url}`);

function getPrBody() {
let text =
`Bumped versions for ${latestCliVersion}\n\n` +
let text = `Bumped versions for ${latestCliVersion}\n\n` +
`To make edits to this PR:\n` +
"```shell\n" +
`gh pr checkout <THIS PR NUMBER>\n` +
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ 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";
import { copy } from "jsr:@std/fs@^0/copy";
```

To include version number in markdown / MDX content, we recommend using the
Expand Down
2 changes: 1 addition & 1 deletion deploy/manual/ci_github.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ See
[deployctl README](https://github.com/denoland/deployctl/blob/main/action/README.md)
for more details.

[fileserver]: https://deno.land/std/http/file_server.ts
[fileserver]: https://jsr.io/@std/http/doc/file_server/~
[ghapp]: https://github.com/apps/deno-deploy
[deploy-action]: https://github.com/denoland/deployctl/blob/main/action/README.md
[ahead-of-time builds]: https://fresh.deno.dev/docs/concepts/ahead-of-time-builds
Expand Down
4 changes: 2 additions & 2 deletions deploy/manual/deployctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ deployctl deploy --include=./static --entrypoint=./main.ts
```

The entrypoint can also be a remote script. A common use case for this is to
deploy an static site using `std/http/file_server.ts` (more details in
deploy an static site using `@std/http/file_server` (more details in
[Static Site Tutorial](https://docs.deno.com/deploy/tutorials/static-site)):

```shell
deployctl deploy --include=dist --entrypoint=https://deno.land/std@0.208.0/http/file_server.ts
deployctl deploy --include=dist --entrypoint=jsr:@std/http@^0/file_server
```

See the help message (`deployctl -h`) for more details.
Expand Down
33 changes: 20 additions & 13 deletions deploy/manual/neon-postgres.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Connect to Neon Postgres

This tutorial covers how to connect to a Neon Postgres database from an application
deployed on Deno Deploy.
This tutorial covers how to connect to a Neon Postgres database from an
application deployed on Deno Deploy.

You can find a more comprehensive tutorial that builds a sample application on
top of Postgres [here](../tutorials/tutorial-postgres).
Expand All @@ -17,28 +17,35 @@ For this tutorial, we will be using [Neon Postgres](https://neon.tech/) as they
provide free, managed Postgres instances. If you like to host your database
somewhere else, you can do that too.

1. Visit https://neon.tech/ and click **Sign up** to sign up with an email, Github, Google, or partner account. After signing up, you are directed to the Neon Console to create your first project.
2. Enter a name for your project, select a Postgres version, provide a database name, and select a region. Generally, you'll want to select the region closest to your application. When you're finished, click **Create project**.
3. You are presented with the connection string for your new project, which you can use to connect to your database. Save the connection string, which looks something like this:
1. Visit https://neon.tech/ and click **Sign up** to sign up with an email,
Github, Google, or partner account. After signing up, you are directed to the
Neon Console to create your first project.
2. Enter a name for your project, select a Postgres version, provide a database
name, and select a region. Generally, you'll want to select the region
closest to your application. When you're finished, click **Create project**.
3. You are presented with the connection string for your new project, which you
can use to connect to your database. Save the connection string, which looks
something like this:

```sh
postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname?sslmode=require
```
```sh
postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname?sslmode=require
```

You will need the connection string in the next step.
You will need the connection string in the next step.

## Create a project in Deno Deploy

Next, let's create a project in Deno Deploy and set it up with the requisite
environment variables:

1. Go to [https://dash.deno.com/new](https://dash.deno.com/new) (Sign in with
GitHub if you didn't already) and click on **Create an empty project** under **Deploy your own code**.
GitHub if you didn't already) and click on **Create an empty project** under
**Deploy your own code**.
2. Now click on the **Settings** button available on the project page.
3. Navigate to **Environment Variables** Section and add the following secret.

- `DATABASE_URL` - The value should be set to the connection string you saved
in the last step.
- `DATABASE_URL` - The value should be set to the connection string you saved in
the last step.

![postgres_env_variable](../docs-images/neon_postgres_env_variable.png)

Expand Down Expand Up @@ -93,4 +100,4 @@ Unless you want to add a build step, we recommend that you select the GitHub
integration.

For more details on the different ways to deploy on Deno Deploy and the
different configuration options, read [here](how-to-deploy).
different configuration options, read [here](how-to-deploy).
2 changes: 1 addition & 1 deletion deploy/tutorials/static-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```console
deployctl deploy --project=careful-goat-90 https://deno.land/std@$STD_VERSION/http/file_server.ts
deployctl deploy --project=careful-goat-90 jsr:@std/http@^0/file_server
```

To give a little more explanation of these commands: Because this is a static
Expand Down
2 changes: 1 addition & 1 deletion deploy/tutorials/tutorial-http-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ global network. This guarantees fast and reliable performance, no matter the
location of your users.

[native-http]: https://deno.land/manual@v1.15.1/runtime/http_server_apis
[std-http]: https://deno.land/std/http
[std-http]: https://jsr.io/@std/http
[request]: ../api/runtime-request
[conninfo]: https://doc.deno.land/https/deno.land%2Fstd%2Fhttp%2Fserver.ts#ConnInfo
[response]: ../api/runtime-response
31 changes: 19 additions & 12 deletions deploy/tutorials/tutorial-postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ POST /todos

In this tutorial, we will be:

- Creating and setting up a [Postgres](https://www.postgresql.org/) instance
on [Neon Postgres](https://neon.tech/) or [Supabase](https://supabase.com).
- Creating and setting up a [Postgres](https://www.postgresql.org/) instance on
[Neon Postgres](https://neon.tech/) or [Supabase](https://supabase.com).
- Using a [Deno Deploy](/deploy) Playground to develop and deploy the
application.
- Testing our application using [cURL](https://curl.se/).
Expand All @@ -54,19 +54,26 @@ In this tutorial, we will be:
> documentation [here](https://deno-postgres.com/#/?id=ssltls-connection).

To get started we need to create a new Postgres instance for us to connect to.
For this tutorial, you can use either [Neon Postgres](https://neon.tech/) or [Supabase](https://supabase.com), as they
both provide free, managed Postgres instances. If you like to host your database
somewhere else, you can do that too.
For this tutorial, you can use either [Neon Postgres](https://neon.tech/) or
[Supabase](https://supabase.com), as they both provide free, managed Postgres
instances. If you like to host your database somewhere else, you can do that
too.

### Neon Postgres

1. Visit https://neon.tech/ and click **Sign up** to sign up with an email, Github, Google, or partner account. After signing up, you are directed to the Neon Console to create your first project.
2. Enter a name for your project, select a Postgres version, provide a database name, and select a region. Generally, you'll want to select the region closest to your application. When you're finished, click **Create project**.
3. You are presented with the connection string for your new project, which you can use to connect to your database. Save the connection string, which looks something like this:

```sh
postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname?sslmode=require
```
1. Visit https://neon.tech/ and click **Sign up** to sign up with an email,
Github, Google, or partner account. After signing up, you are directed to the
Neon Console to create your first project.
2. Enter a name for your project, select a Postgres version, provide a database
name, and select a region. Generally, you'll want to select the region
closest to your application. When you're finished, click **Create project**.
3. You are presented with the connection string for your new project, which you
can use to connect to your database. Save the connection string, which looks
something like this:

```sh
postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname?sslmode=require
```

### Supabase

Expand Down
7 changes: 3 additions & 4 deletions deploy/tutorials/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Since there is a build step here, you will need to use the Github Actions mode.
uses: denoland/deployctl@v1
with:
project: "<project-name>"
entrypoint: https://deno.land/std@$STD_VERSION/http/file_server.ts
entrypoint: jsr:@std/http@^0/file_server
root: dist
```

Expand All @@ -99,8 +99,7 @@ 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@$STD_VERSION/http/file_server.ts`, and the root to
`/dist`.
`jsr:@std/http@^0/file_server`, 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
Expand All @@ -118,5 +117,5 @@ Deploy.

```console
cd /dist
deployctl deploy --project=<project-name> https://deno.land/std@$STD_VERSION/http/file_server.ts
deployctl deploy --project=<project-name> jsr:@std/http@^0/file_server
```
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const config = {
},
{
label: "Standard Library",
href: "https://deno.land/std",
href: "https://jsr.io/@std",
},
{
label: "Deno by Example",
Expand Down
3 changes: 1 addition & 2 deletions replacements.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"CLI_VERSION": "1.41.3",
"STD_VERSION": "0.220.0"
"CLI_VERSION": "1.41.3"
}
5 changes: 2 additions & 3 deletions runtime/manual/advanced/continuous_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,10 @@ which is discussed in detail [here](../basics/modules/integrity_checking.md).
Now, if the contents of `deno.lock` are changed, a new cache will be made and
used in subsequent pipeline runs thereafter.

To demonstrate, let's say you have a project that uses the logger from
`deno.land/std`:
To demonstrate, let's say you have a project that uses the logger from `@std`:

```ts
import * as log from "https://deno.land/std@$STD_VERSION/log/mod.ts";
import * as log from "jsr:std/log@^0";
```

In order to increment this version, you can update the `import` statement and
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/deploying_deno/kinsta.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To do so, your `package.json` should look like this:
## Example application

```js
import { parseArgs } from "https://deno.land/std@$STD_VERSION/cli/parse_args.ts";
import { parseArgs } from "jsr:std/cli@^0/parse_args";

const { args } = Deno;
const port = parseArgs(args).port ? Number(parseArgs(args).port) : 8000;
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/jsx_dom/css.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Then we will stringify the modified CSS AST and output it to the console:

```ts
import * as css from "https://esm.sh/css@3.0.0";
import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts";
import { assert } from "jsr:std/assert@^0";

declare global {
interface AbortSignal {
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/jsx_dom/deno_dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -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@$STD_VERSION/assert/mod.ts";
import { assert } from "jsr:std/assert@^0";

const document = new DOMParser().parseFromString(
`<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/jsx_dom/jsdom.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ first heading it encounters and print out the text content of that heading:

```ts
import { JSDOM } from "jsdom";
import { assert } from "https://deno.land/std@$STD_VERSION/assert/mod.ts";
import { assert } from "jsr:std/assert@^0";

const { window: { document } } = new JSDOM(
`<!DOCTYPE html>
Expand Down
2 changes: 1 addition & 1 deletion runtime/manual/advanced/jsx_dom/linkedom.md
Original file line number Diff line number Diff line change
Expand Up @@ -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@$STD_VERSION/assert/mod.ts";
import { assert } from "jsr:std/assert@^0";

const document = new DOMParser().parseFromString(
`<!DOCTYPE html>
Expand Down
4 changes: 2 additions & 2 deletions runtime/manual/advanced/jsx_dom/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ A web application is generally made up of three key technologies:
- HTML
- CSS

As well as increasingly, [WebAssembly](../../runtime/webassembly/index.md)
might play a part in a web application.
As well as increasingly, [WebAssembly](../../runtime/webassembly/index.md) might
play a part in a web application.

These technologies combine to allow a developer to build an application in a
browser using the web platform. While Deno supports a lot of web platform APIs,
Expand Down
Loading