From fb31ae73e40896c1d1dfdb26c265222f49907d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 29 Feb 2024 19:12:04 +0000 Subject: feat(unstable): `deno add` subcommand (#22520) This commit adds "deno add" subcommand that has a basic support for adding "jsr:" packages to "deno.json" file. This currently doesn't support "npm:" specifiers and specifying version constraints. --- .../@denotest/subset-type-graph-invalid/0.1.0/mod.ts | 12 ++++++++++++ .../subset-type-graph-invalid/0.1.0_meta.json | 5 +++++ .../@denotest/subset-type-graph-invalid/meta.json | 5 +++++ .../registry/@denotest/subset-type-graph/0.1.0/mod.ts | 17 +++++++++++++++++ .../@denotest/subset-type-graph/0.1.0_meta.json | 5 +++++ .../jsr/registry/@denotest/subset-type-graph/meta.json | 5 +++++ .../registry/@denotest/subset_type_graph/0.1.0/mod.ts | 17 ----------------- .../@denotest/subset_type_graph/0.1.0_meta.json | 5 ----- .../jsr/registry/@denotest/subset_type_graph/meta.json | 5 ----- .../@denotest/subset_type_graph_invalid/0.1.0/mod.ts | 12 ------------ .../subset_type_graph_invalid/0.1.0_meta.json | 5 ----- .../@denotest/subset_type_graph_invalid/meta.json | 5 ----- tests/testdata/jsr/subset_type_graph/main.check.out | 18 +++++++++--------- tests/testdata/jsr/subset_type_graph/main.ts | 4 ++-- 14 files changed, 60 insertions(+), 60 deletions(-) create mode 100644 tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/0.1.0/mod.ts create mode 100644 tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/0.1.0_meta.json create mode 100644 tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/meta.json create mode 100644 tests/testdata/jsr/registry/@denotest/subset-type-graph/0.1.0/mod.ts create mode 100644 tests/testdata/jsr/registry/@denotest/subset-type-graph/0.1.0_meta.json create mode 100644 tests/testdata/jsr/registry/@denotest/subset-type-graph/meta.json delete mode 100644 tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts delete mode 100644 tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json delete mode 100644 tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json delete mode 100644 tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts delete mode 100644 tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json delete mode 100644 tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json (limited to 'tests/testdata/jsr') diff --git a/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/0.1.0/mod.ts b/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/0.1.0/mod.ts new file mode 100644 index 000000000..6a5036bf5 --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/0.1.0/mod.ts @@ -0,0 +1,12 @@ +export class Foo { + method() { + return Math.random(); + } +} + +// This will be analyzed because the method above is missing an +// explicit type which is required for the subset type graph to take +// effect. So the entire source file will be type checked against, +// causing a type error here. +const invalidTypeCheck: number = ""; +console.log(invalidTypeCheck); diff --git a/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/0.1.0_meta.json b/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/0.1.0_meta.json new file mode 100644 index 000000000..631a18d0e --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/0.1.0_meta.json @@ -0,0 +1,5 @@ +{ + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/meta.json b/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/meta.json new file mode 100644 index 000000000..d10aa5c3a --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/subset-type-graph-invalid/meta.json @@ -0,0 +1,5 @@ +{ + "versions": { + "0.1.0": {} + } +} diff --git a/tests/testdata/jsr/registry/@denotest/subset-type-graph/0.1.0/mod.ts b/tests/testdata/jsr/registry/@denotest/subset-type-graph/0.1.0/mod.ts new file mode 100644 index 000000000..e81b2309a --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/subset-type-graph/0.1.0/mod.ts @@ -0,0 +1,17 @@ +// add some statements that will be removed by the subset +// type graph so that we can test that the source map works +console.log(1); +console.log(2); +console.log(3); + +export class Foo { + method(): number { + return Math.random(); + } +} + +// this won't be type checked against because the subset +// type graph omit this code because it's not part of the +// public API. +const invalidTypeCheck: number = ""; +console.log(invalidTypeCheck); diff --git a/tests/testdata/jsr/registry/@denotest/subset-type-graph/0.1.0_meta.json b/tests/testdata/jsr/registry/@denotest/subset-type-graph/0.1.0_meta.json new file mode 100644 index 000000000..631a18d0e --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/subset-type-graph/0.1.0_meta.json @@ -0,0 +1,5 @@ +{ + "exports": { + ".": "./mod.ts" + } +} diff --git a/tests/testdata/jsr/registry/@denotest/subset-type-graph/meta.json b/tests/testdata/jsr/registry/@denotest/subset-type-graph/meta.json new file mode 100644 index 000000000..d10aa5c3a --- /dev/null +++ b/tests/testdata/jsr/registry/@denotest/subset-type-graph/meta.json @@ -0,0 +1,5 @@ +{ + "versions": { + "0.1.0": {} + } +} diff --git a/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts b/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts deleted file mode 100644 index e81b2309a..000000000 --- a/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts +++ /dev/null @@ -1,17 +0,0 @@ -// add some statements that will be removed by the subset -// type graph so that we can test that the source map works -console.log(1); -console.log(2); -console.log(3); - -export class Foo { - method(): number { - return Math.random(); - } -} - -// this won't be type checked against because the subset -// type graph omit this code because it's not part of the -// public API. -const invalidTypeCheck: number = ""; -console.log(invalidTypeCheck); diff --git a/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json b/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json deleted file mode 100644 index 631a18d0e..000000000 --- a/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "exports": { - ".": "./mod.ts" - } -} diff --git a/tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json b/tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json deleted file mode 100644 index d10aa5c3a..000000000 --- a/tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "versions": { - "0.1.0": {} - } -} diff --git a/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts b/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts deleted file mode 100644 index 6a5036bf5..000000000 --- a/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts +++ /dev/null @@ -1,12 +0,0 @@ -export class Foo { - method() { - return Math.random(); - } -} - -// This will be analyzed because the method above is missing an -// explicit type which is required for the subset type graph to take -// effect. So the entire source file will be type checked against, -// causing a type error here. -const invalidTypeCheck: number = ""; -console.log(invalidTypeCheck); diff --git a/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json b/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json deleted file mode 100644 index 631a18d0e..000000000 --- a/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "exports": { - ".": "./mod.ts" - } -} diff --git a/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json b/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json deleted file mode 100644 index d10aa5c3a..000000000 --- a/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "versions": { - "0.1.0": {} - } -} diff --git a/tests/testdata/jsr/subset_type_graph/main.check.out b/tests/testdata/jsr/subset_type_graph/main.check.out index 278884579..f46610c0a 100644 --- a/tests/testdata/jsr/subset_type_graph/main.check.out +++ b/tests/testdata/jsr/subset_type_graph/main.check.out @@ -1,16 +1,16 @@ -Download http://127.0.0.1:4250/@denotest/subset_type_graph/meta.json -Download http://127.0.0.1:4250/@denotest/subset_type_graph_invalid/meta.json -Download http://127.0.0.1:4250/@denotest/subset_type_graph/0.1.0_meta.json -Download http://127.0.0.1:4250/@denotest/subset_type_graph_invalid/0.1.0_meta.json +Download http://127.0.0.1:4250/@denotest/subset-type-graph/meta.json +Download http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/meta.json +Download http://127.0.0.1:4250/@denotest/subset-type-graph/0.1.0_meta.json +Download http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/0.1.0_meta.json [UNORDERED_START] -Download http://127.0.0.1:4250/@denotest/subset_type_graph/0.1.0/mod.ts -Download http://127.0.0.1:4250/@denotest/subset_type_graph_invalid/0.1.0/mod.ts +Download http://127.0.0.1:4250/@denotest/subset-type-graph/0.1.0/mod.ts +Download http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/0.1.0/mod.ts [UNORDERED_END] Check file:///[WILDCARD]/subset_type_graph/main.ts error: TS2322 [ERROR]: Type 'string' is not assignable to type 'number'. const invalidTypeCheck: number = ""; ~~~~~~~~~~~~~~~~ - at http://127.0.0.1:4250/@denotest/subset_type_graph_invalid/0.1.0/mod.ts:11:7 + at http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/0.1.0/mod.ts:11:7 TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. const error1: string = new Foo1().method(); @@ -30,7 +30,7 @@ new Foo1().method2(); 'method' is declared here. method(): number { ~~~~~~ - at http://127.0.0.1:4250/@denotest/subset_type_graph/0.1.0/mod.ts:8:3 + at http://127.0.0.1:4250/@denotest/subset-type-graph/0.1.0/mod.ts:8:3 TS2551 [ERROR]: Property 'method2' does not exist on type 'Foo'. Did you mean 'method'? new Foo2().method2(); @@ -40,6 +40,6 @@ new Foo2().method2(); 'method' is declared here. method() { ~~~~~~ - at http://127.0.0.1:4250/@denotest/subset_type_graph_invalid/0.1.0/mod.ts:2:3 + at http://127.0.0.1:4250/@denotest/subset-type-graph-invalid/0.1.0/mod.ts:2:3 Found 5 errors. diff --git a/tests/testdata/jsr/subset_type_graph/main.ts b/tests/testdata/jsr/subset_type_graph/main.ts index 2e1614be9..2fff966a7 100644 --- a/tests/testdata/jsr/subset_type_graph/main.ts +++ b/tests/testdata/jsr/subset_type_graph/main.ts @@ -1,5 +1,5 @@ -import { Foo as Foo1 } from "jsr:@denotest/subset_type_graph@0.1.0"; -import { Foo as Foo2 } from "jsr:@denotest/subset_type_graph_invalid@0.1.0"; +import { Foo as Foo1 } from "jsr:@denotest/subset-type-graph@0.1.0"; +import { Foo as Foo2 } from "jsr:@denotest/subset-type-graph-invalid@0.1.0"; // these will both raise type checking errors const error1: string = new Foo1().method(); -- cgit v1.2.3