summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2024-05-08 20:34:46 +0100
committerGitHub <noreply@github.com>2024-05-08 12:34:46 -0700
commit4e23a5b1fc2ba0e26f1832a2c374a1f3aef9e7ff (patch)
tree4e71d07cce253b3a8035285e11999c1294643074 /tests
parent525b3c8d746b8eb358ed6466cd4b68ebd6542392 (diff)
FUTURE: `deno install` changes (#23498)
This PR implements the changes we plan to make to `deno install` in deno 2.0. - `deno install` without arguments caches dependencies from `package.json` / `deno.json` and sets up the `node_modules` folder - `deno install <pkg>` adds the package to the config file (either `package.json` or `deno.json`), i.e. it aliases `deno add` - `deno add` can also add deps to `package.json` (this is gated behind `DENO_FUTURE` due to uncertainty around handling projects with both `deno.json` and `package.json`) - `deno install -g <bin>` installs a package as a globally available binary (the same as `deno install <bin>` in 1.0) --------- Co-authored-by: Nathan Whitaker <nathan@deno.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/specs/install/future_install_global/__test__.jsonc16
-rw-r--r--tests/specs/install/future_install_global/assert.js11
-rw-r--r--tests/specs/install/future_install_global/install.out5
-rw-r--r--tests/specs/install/future_install_global/main.js3
-rw-r--r--tests/specs/install/future_install_global/package.json7
-rw-r--r--tests/specs/install/future_install_local_add_deno/__test__.jsonc24
-rw-r--r--tests/specs/install/future_install_local_add_deno/deno.json1
-rw-r--r--tests/specs/install/future_install_local_add_deno/deno.json.out5
-rw-r--r--tests/specs/install/future_install_local_add_deno/install.out4
-rw-r--r--tests/specs/install/future_install_local_add_deno/main.js2
-rw-r--r--tests/specs/install/future_install_local_add_npm/__test__.jsonc25
-rw-r--r--tests/specs/install/future_install_local_add_npm/install.out5
-rw-r--r--tests/specs/install/future_install_local_add_npm/main.js2
-rw-r--r--tests/specs/install/future_install_local_add_npm/package.json3
-rw-r--r--tests/specs/install/future_install_local_add_npm/package.json.out3
-rw-r--r--tests/specs/install/future_install_local_deno/__test__.jsonc17
-rw-r--r--tests/specs/install/future_install_local_deno/deno.json8
-rw-r--r--tests/specs/install/future_install_local_deno/install.out10
-rw-r--r--tests/specs/install/future_install_local_deno/main.js6
-rw-r--r--tests/specs/install/future_install_node_modules/__test__.jsonc17
-rw-r--r--tests/specs/install/future_install_node_modules/install.out4
-rw-r--r--tests/specs/install/future_install_node_modules/main.js3
-rw-r--r--tests/specs/install/future_install_node_modules/package.json5
-rw-r--r--tests/specs/install/no_future_install_global/__test__.jsonc13
-rw-r--r--tests/specs/install/no_future_install_global/assert.js11
-rw-r--r--tests/specs/install/no_future_install_global/install.out5
-rw-r--r--tests/specs/install/no_future_install_global/main.js3
-rw-r--r--tests/specs/install/no_future_install_global/package.json6
28 files changed, 224 insertions, 0 deletions
diff --git a/tests/specs/install/future_install_global/__test__.jsonc b/tests/specs/install/future_install_global/__test__.jsonc
new file mode 100644
index 000000000..be6fcab97
--- /dev/null
+++ b/tests/specs/install/future_install_global/__test__.jsonc
@@ -0,0 +1,16 @@
+{
+ "tempDir": true,
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "steps": [
+ {
+ "args": "install --global --root ./bins --name deno-test-bin ./main.js",
+ "output": "install.out"
+ },
+ {
+ "args": "run -A assert.js",
+ "output": ""
+ }
+ ]
+}
diff --git a/tests/specs/install/future_install_global/assert.js b/tests/specs/install/future_install_global/assert.js
new file mode 100644
index 000000000..c7a6a0680
--- /dev/null
+++ b/tests/specs/install/future_install_global/assert.js
@@ -0,0 +1,11 @@
+const dirs = Deno.readDir("./bins/bin");
+
+let found = false;
+for await (const entry of dirs) {
+ if (entry.name.includes("deno-test-bin")) {
+ found = true;
+ }
+}
+if (!found) {
+ throw new Error("Failed to find test bin");
+}
diff --git a/tests/specs/install/future_install_global/install.out b/tests/specs/install/future_install_global/install.out
new file mode 100644
index 000000000..adb8b4598
--- /dev/null
+++ b/tests/specs/install/future_install_global/install.out
@@ -0,0 +1,5 @@
+Download http://localhost:4260/@denotest/esm-basic
+Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
+Initialize @denotest/esm-basic@1.0.0
+✅ Successfully installed deno-test-bin[WILDCARD]
+[WILDCARD]
diff --git a/tests/specs/install/future_install_global/main.js b/tests/specs/install/future_install_global/main.js
new file mode 100644
index 000000000..2ba55540b
--- /dev/null
+++ b/tests/specs/install/future_install_global/main.js
@@ -0,0 +1,3 @@
+import { setValue } from "@denotest/esm-basic";
+
+setValue(5);
diff --git a/tests/specs/install/future_install_global/package.json b/tests/specs/install/future_install_global/package.json
new file mode 100644
index 000000000..f3b6cb7be
--- /dev/null
+++ b/tests/specs/install/future_install_global/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "deno-test-bin",
+ "dependencies": {
+ "@denotest/esm-basic": "*"
+ },
+ "type": "module"
+}
diff --git a/tests/specs/install/future_install_local_add_deno/__test__.jsonc b/tests/specs/install/future_install_local_add_deno/__test__.jsonc
new file mode 100644
index 000000000..eaafafbdd
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_deno/__test__.jsonc
@@ -0,0 +1,24 @@
+{
+ "tempDir": true,
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "steps": [
+ {
+ "args": "install npm:@denotest/esm-basic",
+ "output": "install.out"
+ },
+ {
+ // make sure the dep got cached
+ "args": "run --cached-only main.js",
+ "output": ""
+ },
+ {
+ "args": [
+ "eval",
+ "console.log(Deno.readTextFileSync('deno.json').trim())"
+ ],
+ "output": "deno.json.out"
+ }
+ ]
+}
diff --git a/tests/specs/install/future_install_local_add_deno/deno.json b/tests/specs/install/future_install_local_add_deno/deno.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_deno/deno.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/specs/install/future_install_local_add_deno/deno.json.out b/tests/specs/install/future_install_local_add_deno/deno.json.out
new file mode 100644
index 000000000..0172071c3
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_deno/deno.json.out
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "@denotest/esm-basic": "npm:@denotest/esm-basic@^1.0.0"
+ }
+}
diff --git a/tests/specs/install/future_install_local_add_deno/install.out b/tests/specs/install/future_install_local_add_deno/install.out
new file mode 100644
index 000000000..df58284fc
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_deno/install.out
@@ -0,0 +1,4 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+Add @denotest/esm-basic - npm:@denotest/esm-basic@^1.0.0
+Download http://localhost:4260/@denotest/esm-basic
+Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
diff --git a/tests/specs/install/future_install_local_add_deno/main.js b/tests/specs/install/future_install_local_add_deno/main.js
new file mode 100644
index 000000000..c29b48b4e
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_deno/main.js
@@ -0,0 +1,2 @@
+import { setValue } from "@denotest/esm-basic";
+setValue(5);
diff --git a/tests/specs/install/future_install_local_add_npm/__test__.jsonc b/tests/specs/install/future_install_local_add_npm/__test__.jsonc
new file mode 100644
index 000000000..19ded2ab5
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_npm/__test__.jsonc
@@ -0,0 +1,25 @@
+{
+ "tempDir": true,
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "steps": [
+ {
+ "args": "install npm:@denotest/esm-basic",
+ "output": "install.out"
+ },
+ {
+ // make sure the dep got cached
+ "args": "run --cached-only main.js",
+ "exitCode": 0,
+ "output": ""
+ },
+ {
+ "args": [
+ "eval",
+ "console.log(Deno.readTextFileSync('package.json').trim())"
+ ],
+ "output": "package.json.out"
+ }
+ ]
+}
diff --git a/tests/specs/install/future_install_local_add_npm/install.out b/tests/specs/install/future_install_local_add_npm/install.out
new file mode 100644
index 000000000..d9c23abf0
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_npm/install.out
@@ -0,0 +1,5 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+Add @denotest/esm-basic - npm:@denotest/esm-basic@^1.0.0
+Download http://localhost:4260/@denotest/esm-basic
+Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
+Initialize @denotest/esm-basic@1.0.0
diff --git a/tests/specs/install/future_install_local_add_npm/main.js b/tests/specs/install/future_install_local_add_npm/main.js
new file mode 100644
index 000000000..c29b48b4e
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_npm/main.js
@@ -0,0 +1,2 @@
+import { setValue } from "@denotest/esm-basic";
+setValue(5);
diff --git a/tests/specs/install/future_install_local_add_npm/package.json b/tests/specs/install/future_install_local_add_npm/package.json
new file mode 100644
index 000000000..18a1e415e
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_npm/package.json
@@ -0,0 +1,3 @@
+{
+ "dependencies": {}
+}
diff --git a/tests/specs/install/future_install_local_add_npm/package.json.out b/tests/specs/install/future_install_local_add_npm/package.json.out
new file mode 100644
index 000000000..ad8518e79
--- /dev/null
+++ b/tests/specs/install/future_install_local_add_npm/package.json.out
@@ -0,0 +1,3 @@
+{
+ "dependencies": { "@denotest/esm-basic": "^1.0.0" }
+}
diff --git a/tests/specs/install/future_install_local_deno/__test__.jsonc b/tests/specs/install/future_install_local_deno/__test__.jsonc
new file mode 100644
index 000000000..eb780d962
--- /dev/null
+++ b/tests/specs/install/future_install_local_deno/__test__.jsonc
@@ -0,0 +1,17 @@
+{
+ "tempDir": true,
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "steps": [
+ {
+ "args": "install",
+ "output": "install.out"
+ },
+ {
+ // ensure deps are actually cached
+ "args": "run --cached-only main.js",
+ "output": ""
+ }
+ ]
+}
diff --git a/tests/specs/install/future_install_local_deno/deno.json b/tests/specs/install/future_install_local_deno/deno.json
new file mode 100644
index 000000000..dbcf1c220
--- /dev/null
+++ b/tests/specs/install/future_install_local_deno/deno.json
@@ -0,0 +1,8 @@
+{
+ "imports": {
+ "@std/fs/": "https://deno.land/std@0.224.0/fs/",
+ "@denotest/esm-basic": "npm:@denotest/esm-basic@^1.0.0",
+ "@denotest/add": "jsr:@denotest/add",
+ "test-http": "http://localhost:4545/v1/extensionless"
+ }
+}
diff --git a/tests/specs/install/future_install_local_deno/install.out b/tests/specs/install/future_install_local_deno/install.out
new file mode 100644
index 000000000..efb77d8f2
--- /dev/null
+++ b/tests/specs/install/future_install_local_deno/install.out
@@ -0,0 +1,10 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+Download http://localhost:4545/v1/extensionless
+Download http://localhost:4545/subdir/mod1.ts
+Download http://localhost:4545/subdir/subdir2/mod2.ts
+Download http://localhost:4545/subdir/print_hello.ts
+Download http://127.0.0.1:4250/@denotest/add/meta.json
+Download http://127.0.0.1:4250/@denotest/add/1.0.0_meta.json
+Download http://127.0.0.1:4250/@denotest/add/1.0.0/mod.ts
+Download http://localhost:4260/@denotest/esm-basic
+Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
diff --git a/tests/specs/install/future_install_local_deno/main.js b/tests/specs/install/future_install_local_deno/main.js
new file mode 100644
index 000000000..5c09f1f20
--- /dev/null
+++ b/tests/specs/install/future_install_local_deno/main.js
@@ -0,0 +1,6 @@
+import { setValue } from "@denotest/esm-basic";
+import { add } from "@denotest/add";
+import { returnsHi } from "test-http";
+setValue(5);
+returnsHi();
+add(2, 2);
diff --git a/tests/specs/install/future_install_node_modules/__test__.jsonc b/tests/specs/install/future_install_node_modules/__test__.jsonc
new file mode 100644
index 000000000..eb780d962
--- /dev/null
+++ b/tests/specs/install/future_install_node_modules/__test__.jsonc
@@ -0,0 +1,17 @@
+{
+ "tempDir": true,
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "steps": [
+ {
+ "args": "install",
+ "output": "install.out"
+ },
+ {
+ // ensure deps are actually cached
+ "args": "run --cached-only main.js",
+ "output": ""
+ }
+ ]
+}
diff --git a/tests/specs/install/future_install_node_modules/install.out b/tests/specs/install/future_install_node_modules/install.out
new file mode 100644
index 000000000..22574688a
--- /dev/null
+++ b/tests/specs/install/future_install_node_modules/install.out
@@ -0,0 +1,4 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+Download http://localhost:4260/@denotest/esm-basic
+Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
+Initialize @denotest/esm-basic@1.0.0
diff --git a/tests/specs/install/future_install_node_modules/main.js b/tests/specs/install/future_install_node_modules/main.js
new file mode 100644
index 000000000..2ba55540b
--- /dev/null
+++ b/tests/specs/install/future_install_node_modules/main.js
@@ -0,0 +1,3 @@
+import { setValue } from "@denotest/esm-basic";
+
+setValue(5);
diff --git a/tests/specs/install/future_install_node_modules/package.json b/tests/specs/install/future_install_node_modules/package.json
new file mode 100644
index 000000000..54ca824d6
--- /dev/null
+++ b/tests/specs/install/future_install_node_modules/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "@denotest/esm-basic": "*"
+ }
+}
diff --git a/tests/specs/install/no_future_install_global/__test__.jsonc b/tests/specs/install/no_future_install_global/__test__.jsonc
new file mode 100644
index 000000000..ca351ee0d
--- /dev/null
+++ b/tests/specs/install/no_future_install_global/__test__.jsonc
@@ -0,0 +1,13 @@
+{
+ "tempDir": true,
+ "steps": [
+ {
+ "args": "install --root ./bins --name deno-test-bin ./main.js",
+ "output": "install.out"
+ },
+ {
+ "args": "run -A ./assert.js",
+ "output": ""
+ }
+ ]
+}
diff --git a/tests/specs/install/no_future_install_global/assert.js b/tests/specs/install/no_future_install_global/assert.js
new file mode 100644
index 000000000..c7a6a0680
--- /dev/null
+++ b/tests/specs/install/no_future_install_global/assert.js
@@ -0,0 +1,11 @@
+const dirs = Deno.readDir("./bins/bin");
+
+let found = false;
+for await (const entry of dirs) {
+ if (entry.name.includes("deno-test-bin")) {
+ found = true;
+ }
+}
+if (!found) {
+ throw new Error("Failed to find test bin");
+}
diff --git a/tests/specs/install/no_future_install_global/install.out b/tests/specs/install/no_future_install_global/install.out
new file mode 100644
index 000000000..f3a394c6f
--- /dev/null
+++ b/tests/specs/install/no_future_install_global/install.out
@@ -0,0 +1,5 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+Download http://localhost:4260/@denotest/esm-basic
+Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
+✅ Successfully installed deno-test-bin[WILDCARD]
+[WILDCARD]
diff --git a/tests/specs/install/no_future_install_global/main.js b/tests/specs/install/no_future_install_global/main.js
new file mode 100644
index 000000000..6268d7136
--- /dev/null
+++ b/tests/specs/install/no_future_install_global/main.js
@@ -0,0 +1,3 @@
+import { setValue } from "npm:@denotest/esm-basic";
+
+setValue(5);
diff --git a/tests/specs/install/no_future_install_global/package.json b/tests/specs/install/no_future_install_global/package.json
new file mode 100644
index 000000000..9f465ad50
--- /dev/null
+++ b/tests/specs/install/no_future_install_global/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "deno-test-bin",
+ "dependencies": {
+ "@denotest/esm-basic": "*"
+ }
+}