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

fix(init): use bare specifier for jsr:@std/assert #24581

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 9 additions & 3 deletions cli/tools/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn init_project(init_flags: InitFlags) -> Result<(), AnyError> {
create_file(
&dir,
"mod_test.ts",
r#"import { assertEquals } from "jsr:@std/assert";
r#"import { assertEquals } from "@std/assert";
import { add } from "./mod.ts";

Deno.test(function addTest() {
Expand All @@ -53,10 +53,13 @@ Deno.test(function addTest() {
"deno.json",
&json!({
"name": project_name,
"version": "1.0.0",
"version": "0.1.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a better starting version IMO because you rarely release a 1.0.0 version the first time.

"exports": "./mod.ts",
"tasks": {
"dev": "deno test --watch mod.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1"
}
}),
)?;
Expand All @@ -77,7 +80,7 @@ if (import.meta.main) {
create_file(
&dir,
"main_test.ts",
r#"import { assertEquals } from "jsr:@std/assert";
r#"import { assertEquals } from "@std/assert";
import { add } from "./main.ts";

Deno.test(function addTest() {
Expand All @@ -92,6 +95,9 @@ Deno.test(function addTest() {
&json!({
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1"
}
}),
)?;
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/init_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ fn init_subcommand_with_dir_arg() {
let output = context
.new_command()
.env("NO_COLOR", "1")
.args("test my_dir/main_test.ts")
.current_dir("my_dir")
.args("test main_test.ts")
.split_output()
.run();

Expand Down
4 changes: 4 additions & 0 deletions tests/registry/jsr/@std/assert/1.0.0/assert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// deno-lint-ignore-file
export function assert(expr: unknown) {
return true;
}
9 changes: 9 additions & 0 deletions tests/registry/jsr/@std/assert/1.0.0/assert_equals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// deno-lint-ignore-file
export function assertEquals<T>(
actual: T,
expected: T,
msg?: string,
options: { formatter?: (value: unknown) => string } = {},
) {
return true;
}
5 changes: 5 additions & 0 deletions tests/registry/jsr/@std/assert/1.0.0/fail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// deno-lint-ignore-file

export function fail() {
return true;
}
22 changes: 22 additions & 0 deletions tests/registry/jsr/@std/assert/1.0.0/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

/** A library of assertion functions.
* If the assertion is false an `AssertionError` will be thrown which will
* result in pretty-printed diff of failing assertion.
*
* This module is browser compatible, but do not rely on good formatting of
* values for AssertionError messages in browsers.
*
* ```ts
* import { assert } from "@std/assert/assert";
*
* assert("I am truthy"); // Doesn't throw
* assert(false); // Throws `AssertionError`
* ```
*
* @module
*/

export * from "./assert_equals.ts";
export * from "./assert.ts";
export * from "./fail.ts";
8 changes: 8 additions & 0 deletions tests/registry/jsr/@std/assert/1.0.0_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"exports": {
".": "./mod.ts",
"./assert": "./assert.ts",
"./assert-equals": "./assert-equals.ts",
"./fail": "./fail.ts"
}
}
3 changes: 2 additions & 1 deletion tests/registry/jsr/@std/assert/meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"scope": "std",
"name": "assert",
"latest": "0.220.1",
"latest": "1.0.0",
"versions": {
"1.0.0": {},
"0.220.1": {}
}
}
10 changes: 5 additions & 5 deletions tests/specs/init/lib/test.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Download http://127.0.0.1:4250/@std/assert/meta.json
Download http://127.0.0.1:4250/@std/assert/0.220.1_meta.json
Download http://127.0.0.1:4250/@std/assert/1.0.0_meta.json
[UNORDERED_START]
Download http://127.0.0.1:4250/@std/assert/0.220.1/mod.ts
Download http://127.0.0.1:4250/@std/assert/0.220.1/assert_equals.ts
Download http://127.0.0.1:4250/@std/assert/0.220.1/assert.ts
Download http://127.0.0.1:4250/@std/assert/0.220.1/fail.ts
Download http://127.0.0.1:4250/@std/assert/1.0.0/mod.ts
Download http://127.0.0.1:4250/@std/assert/1.0.0/assert_equals.ts
Download http://127.0.0.1:4250/@std/assert/1.0.0/assert.ts
Download http://127.0.0.1:4250/@std/assert/1.0.0/fail.ts
[UNORDERED_END]
Check file:///[WILDLINE]/mod_test.ts
running 1 test from ./mod_test.ts
Expand Down