Skip to content

chore: support up to Deno LTS and refine supported Deno versions logic #6670

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
fail-fast: false
matrix:
deno:
- v1.x
- v2.x
- lts
- vx.x.x
- canary
os:
- ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[![ci](https://github.com/denoland/std/actions/workflows/ci.yml/badge.svg)](https://github.com/denoland/std/actions/workflows/ci.yml)

High-quality APIs for [Deno](https://deno.com/) and the web. Use fearlessly.
Supports up to the
[current Deno LTS version](https://docs.deno.com/runtime/fundamentals/stability_and_releases/#long-term-support-(lts)).

> [!IMPORTANT]
> Newer versions of the Standard Library are now hosted on
Expand Down
13 changes: 7 additions & 6 deletions _tools/lint_plugin_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// @ts-nocheck Deno.lint namespace does not pass type checking in Deno 1.x

import { assertEquals } from "@std/assert/equals";
import { IS_LINT_PLUGIN_SUPPORTED } from "../internal/support.ts";
import lintPlugin from "./lint_plugin.ts";

function assertLintPluginDiagnostics(
Expand All @@ -18,7 +19,7 @@ function assertLintPluginDiagnostics(
}

Deno.test("deno-style-guide/prefer-private-field", {
ignore: !Deno.version.deno.startsWith("2"),
ignore: !IS_LINT_PLUGIN_SUPPORTED,
}, () => {
// Good
assertLintPluginDiagnostics(
Expand Down Expand Up @@ -57,7 +58,7 @@ class MyClass {
});

Deno.test("deno-style-guide/no-top-level-arrow-syntax", {
ignore: !Deno.version.deno.startsWith("2"),
ignore: !IS_LINT_PLUGIN_SUPPORTED,
}, () => {
// Bad
assertLintPluginDiagnostics(
Expand Down Expand Up @@ -98,7 +99,7 @@ function foo() {
});

Deno.test("deno-style-guide/no-external-code", {
ignore: !Deno.version.deno.startsWith("2"),
ignore: !IS_LINT_PLUGIN_SUPPORTED,
}, () => {
// Good
assertLintPluginDiagnostics('import { walk } from "@std/fs/walk";', []);
Expand Down Expand Up @@ -128,7 +129,7 @@ import { bad } from "jsr:@malicious-muffin/bad";
});

Deno.test("deno-style-guide/naming-convention", {
ignore: !Deno.version.deno.startsWith("2"),
ignore: !IS_LINT_PLUGIN_SUPPORTED,
}, () => {
// Good
assertLintPluginDiagnostics(
Expand Down Expand Up @@ -243,7 +244,7 @@ enum enumName {
});

Deno.test("deno-style-guide/error-message", {
ignore: !Deno.version.deno.startsWith("2"),
ignore: !IS_LINT_PLUGIN_SUPPORTED,
}, () => {
// Good
assertLintPluginDiagnostics(
Expand Down Expand Up @@ -312,7 +313,7 @@ new CustomError("Can't parse input");
});

Deno.test("deno-style-guide/exported-function-args-maximum", {
ignore: !Deno.version.deno.startsWith("2"),
ignore: !IS_LINT_PLUGIN_SUPPORTED,
}, () => {
// Good
assertLintPluginDiagnostics(
Expand Down
2 changes: 2 additions & 0 deletions dotenv/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export interface LoadOptions {
*
* @param options Options for loading the environment variables.
* @returns The parsed environment variables.
* @throws {Deno.errors.NotCapable} If the required `--allow-env` permission is
* not granted.
*/
export function loadSync(
options: LoadOptions = {},
Expand Down
7 changes: 1 addition & 6 deletions dotenv/mod_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "@std/assert";
import { load, type LoadOptions, loadSync } from "./mod.ts";
import * as path from "@std/path";
import { IS_DENO_2 } from "../internal/_is_deno_2.ts";

const moduleDir = path.dirname(path.fromFileUrl(import.meta.url));
const testdataDir = path.resolve(moduleDir, "testdata");
Expand Down Expand Up @@ -174,11 +173,7 @@ Deno.test(
};
assertThrows(
() => loadSync(loadOptions),
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
Deno.errors.NotCapable,
`Requires env access to "EMPTY", run again with the --allow-env flag`,
);
},
Expand Down
5 changes: 5 additions & 0 deletions fs/ensure_dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { getFileInfoType } from "./_get_file_info_type.ts";
*
* await ensureDir("./bar");
* ```
* @throws {Deno.errors.NotCapable} If the required `--allow-write` permission
* is not granted.
*/
export async function ensureDir(dir: string | URL) {
try {
Expand Down Expand Up @@ -71,6 +73,9 @@ export async function ensureDir(dir: string | URL) {
*
* ensureDirSync("./bar");
* ```
*
* @throws {Deno.errors.NotCapable} If the required `--allow-write` permission
* is not granted.
*/
export function ensureDirSync(dir: string | URL) {
try {
Expand Down
15 changes: 3 additions & 12 deletions fs/ensure_dir_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { assertEquals, assertRejects, assertThrows } from "@std/assert";
import * as path from "@std/path";
import { ensureDir, ensureDirSync } from "./ensure_dir.ts";
import { ensureFile, ensureFileSync } from "./ensure_file.ts";
import { IS_DENO_2 } from "../internal/_is_deno_2.ts";

const moduleDir = path.dirname(path.fromFileUrl(import.meta.url));
const testdataDir = path.resolve(moduleDir, "testdata", "ensure_dir");
Expand Down Expand Up @@ -183,12 +182,8 @@ Deno.test({
// ensureDir fails because this test doesn't have write permissions,
// but don't swallow that error.
await assertRejects(
async () => await ensureDir(baseDir),
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
() => ensureDir(baseDir),
Deno.errors.NotCapable,
);
},
});
Expand All @@ -206,11 +201,7 @@ Deno.test({
// but don't swallow that error.
assertThrows(
() => ensureDirSync(baseDir),
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
Deno.errors.NotCapable,
);
},
});
Expand Down
6 changes: 6 additions & 0 deletions fs/ensure_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import { toPathString } from "./_to_path_string.ts";
*
* await ensureFile("./folder/targetFile.dat");
* ```
*
* @throws {Deno.errors.NotCapable} If the required `--allow-write` permission
* is not granted.
*/
export async function ensureFile(filePath: string | URL): Promise<void> {
try {
Expand Down Expand Up @@ -72,6 +75,9 @@ export async function ensureFile(filePath: string | URL): Promise<void> {
*
* ensureFileSync("./folder/targetFile.dat");
* ```
*
* @throws {Deno.errors.NotCapable} If the required `--allow-write` permission
* is not granted.
*/
export function ensureFileSync(filePath: string | URL): void {
try {
Expand Down
15 changes: 3 additions & 12 deletions fs/ensure_file_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { assertRejects, assertThrows } from "@std/assert";
import * as path from "@std/path";
import { ensureFile, ensureFileSync } from "./ensure_file.ts";
import { IS_DENO_2 } from "../internal/_is_deno_2.ts";

const moduleDir = path.dirname(path.fromFileUrl(import.meta.url));
const testdataDir = path.resolve(moduleDir, "testdata");
Expand Down Expand Up @@ -133,12 +132,8 @@ Deno.test({
// ensureFile fails because this test doesn't have write permissions,
// but don't swallow that error.
await assertRejects(
async () => await ensureFile(testFile),
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
() => ensureFile(testFile),
Deno.errors.NotCapable,
);
},
});
Expand All @@ -154,11 +149,7 @@ Deno.test({
// but don't swallow that error.
assertThrows(
() => ensureFileSync(testFile),
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
Deno.errors.NotCapable,
);
},
});
Expand Down
6 changes: 6 additions & 0 deletions fs/ensure_symlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function getSymlinkOption(
* // Ensures the link `./folder/targetFile.link.dat` exists and points to `./folder/targetFile.dat`
* await ensureSymlink("./targetFile.dat", "./folder/targetFile.link.dat");
* ```
*
* @throws {Deno.errors.NotCapable} If the required `--allow-write` permission
* is not granted.
*/
export async function ensureSymlink(
target: string | URL,
Expand Down Expand Up @@ -134,6 +137,9 @@ export async function ensureSymlink(
* // Ensures the link `./folder/targetFile.link.dat` exists and points to `./folder/targetFile.dat`
* ensureSymlinkSync("./targetFile.dat", "./folder/targetFile.link.dat");
* ```
*
* @throws {Deno.errors.NotCapable} If the required `--allow-write` permission
* is not granted.
*/
export function ensureSymlinkSync(
target: string | URL,
Expand Down
21 changes: 4 additions & 17 deletions fs/ensure_symlink_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from "@std/assert";
import * as path from "@std/path";
import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts";
import { IS_DENO_2 } from "../internal/_is_deno_2.ts";

const moduleDir = path.dirname(path.fromFileUrl(import.meta.url));
const testdataDir = path.resolve(moduleDir, "testdata");
Expand Down Expand Up @@ -354,14 +353,8 @@ Deno.test(
const linkFile = path.join(testdataDir, "link.ts");

await assertRejects(
async () => {
await ensureSymlink(testFile, linkFile);
},
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
() => ensureSymlink(testFile, linkFile),
Deno.errors.NotCapable,
);
},
);
Expand All @@ -374,14 +367,8 @@ Deno.test(
const linkFile = path.join(testdataDir, "link.ts");

assertThrows(
() => {
ensureSymlinkSync(testFile, linkFile);
},
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
() => ensureSymlinkSync(testFile, linkFile),
Deno.errors.NotCapable,
);
},
);
3 changes: 3 additions & 0 deletions fs/expand_glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ function comparePath(a: WalkEntry, b: WalkEntry): number {
* @returns An async iterator that yields each walk entry matching the glob
* pattern.
*
* @throws {Deno.errors.NotCapable} If the required `--allow-read` permission
* is not granted.
*
* @example Basic usage
*
* File structure:
Expand Down
27 changes: 5 additions & 22 deletions fs/expand_glob_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
type ExpandGlobOptions,
expandGlobSync,
} from "./expand_glob.ts";
import { IS_DENO_2 } from "../internal/_is_deno_2.ts";

async function expandGlobArray(
globString: string,
Expand Down Expand Up @@ -114,28 +113,16 @@ Deno.test(
async function () {
{
await assertRejects(
async () => {
await expandGlobArray("*", EG_OPTIONS);
},
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
() => expandGlobArray("*", EG_OPTIONS),
Deno.errors.NotCapable,
"run again with the --allow-read flag",
);
}

{
assertThrows(
() => {
expandGlobSyncArray("*", EG_OPTIONS);
},
IS_DENO_2
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
// deno-lint-ignore no-explicit-any
? (Deno as any).errors.NotCapable
: Deno.errors.PermissionDenied,
() => expandGlobSyncArray("*", EG_OPTIONS),
Deno.errors.NotCapable,
"run again with the --allow-read flag",
);
}
Expand Down Expand Up @@ -307,11 +294,7 @@ Deno.test(
assert(!success);
assertEquals(code, 1);
assertEquals(decoder.decode(stdout), "");
assertStringIncludes(
decoder.decode(stderr),
// TODO(iuioiua): Just use `Deno.errors.NotCapable` once Deno 2 is released.
IS_DENO_2 ? "NotCapable" : "PermissionDenied",
);
assertStringIncludes(decoder.decode(stderr), "NotCapable");
},
);

Expand Down
5 changes: 2 additions & 3 deletions fs/unstable_rename_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2018-2025 the Deno authors. MIT license.

import { assert, assertRejects, assertThrows } from "@std/assert";
import { lessOrEqual, parse as parseSemver } from "@std/semver";
import { rename, renameSync } from "./unstable_rename.ts";
import { NotFound } from "./unstable_errors.js";
import { mkdir, mkdtemp, open, rm, stat, symlink } from "node:fs/promises";
Expand All @@ -17,11 +16,11 @@ import {
statSync,
symlinkSync,
} from "node:fs";
import { isDenoVersionGreaterOrEqual } from "../internal/support.ts";

// In Deno 2.2.2 or earlier, the `rename` function has an issue on Windows.
const RENAME_HAS_ISSUE = Deno.version &&
parseSemver(Deno.version.deno).build?.length === 0 && // not canary
lessOrEqual(parseSemver(Deno.version.deno), parseSemver("2.2.2")) &&
!isDenoVersionGreaterOrEqual("2.2.3") &&
platform() === "win32";

/** Tests if the original file/directory is missing since the file is renamed.
Expand Down
6 changes: 2 additions & 4 deletions http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import denoConfig from "./deno.json" with { type: "json" };
import { MINUTE } from "@std/datetime/constants";
import { getAvailablePort } from "@std/net/get-available-port";
import { concat } from "@std/bytes/concat";
import { lessThan, parse as parseSemver } from "@std/semver";
import { isDenoVersionGreaterOrEqual } from "../internal/support.ts";

const moduleDir = dirname(fromFileUrl(import.meta.url));
const testdataDir = resolve(moduleDir, "testdata");
Expand All @@ -33,11 +33,9 @@ const serveDirOptions: ServeDirOptions = {
showDotfiles: true,
enableCors: true,
};
const denoVersion = parseSemver(Deno.version.deno);
const isCanary = denoVersion.build ? denoVersion.build.length > 0 : false;
// FileInfo.mode is not available on Windows before Deno 2.1.0
const fsModeUnavailable = Deno.build.os === "windows" &&
lessThan(denoVersion, parseSemver("2.1.0")) && !isCanary;
!isDenoVersionGreaterOrEqual("2.1.0");

const TEST_FILE_PATH = join(testdataDir, "test_file.txt");
const TEST_FILE_STAT = await Deno.stat(TEST_FILE_PATH);
Expand Down
3 changes: 0 additions & 3 deletions internal/_is_deno_2.ts

This file was deleted.

Loading
Loading