diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2024-05-23 22:26:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-23 23:26:23 +0200 |
commit | 959739f609dddacde3bbe9ecede2f409214fb34c (patch) | |
tree | 04d1776efbd3561205829f78288d26b6e14c3429 /tests/specs/npm | |
parent | 5de30c53239ac74843725d981afc0bb8c45bdf16 (diff) |
FUTURE: initial support for .npmrc file (#23560)
This commit adds initial support for ".npmrc" files.
Currently we only discover ".npmrc" files next to "package.json" files
and discovering these files in user home dir is left for a follow up.
This pass supports "_authToken" and "_auth" configuration
for providing authentication.
LSP support has been left for a follow up PR.
Towards https://github.com/denoland/deno/issues/16105
Diffstat (limited to 'tests/specs/npm')
27 files changed, 168 insertions, 0 deletions
diff --git a/tests/specs/npm/npmrc/.npmrc b/tests/specs/npm/npmrc/.npmrc new file mode 100644 index 000000000..085885ec8 --- /dev/null +++ b/tests/specs/npm/npmrc/.npmrc @@ -0,0 +1,4 @@ +@denotest:registry=http://127.0.0.1:4261/ +//127.0.0.1:4261/denotest/:_auth=ZGVubzpsYW5k +@denotest2:registry=http://127.0.0.1:4262/ +//127.0.0.1:4262/denotest2/:_auth=ZGVubzpsYW5kMg== diff --git a/tests/specs/npm/npmrc/__test__.jsonc b/tests/specs/npm/npmrc/__test__.jsonc new file mode 100644 index 000000000..44298ed2f --- /dev/null +++ b/tests/specs/npm/npmrc/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "envs": { + "DENO_FUTURE": "1" + }, + "tempDir": true, + "steps": [{ + "args": "install", + "output": "install.out" + }, { + "args": "run -A main.js", + "output": "main.out" + }] +} diff --git a/tests/specs/npm/npmrc/install.out b/tests/specs/npm/npmrc/install.out new file mode 100644 index 000000000..7484405db --- /dev/null +++ b/tests/specs/npm/npmrc/install.out @@ -0,0 +1,9 @@ +⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag. +[UNORDERED_START] +Download http://127.0.0.1:4261/@denotest/basic +Download http://127.0.0.1:4262/@denotest2/basic +Download http://localhost:4261/@denotest/basic/1.0.0.tgz +Download http://localhost:4262/@denotest2/basic/1.0.0.tgz +Initialize @denotest2/basic@1.0.0 +Initialize @denotest/basic@1.0.0 +[UNORDERED_END] diff --git a/tests/specs/npm/npmrc/main.js b/tests/specs/npm/npmrc/main.js new file mode 100644 index 000000000..66b393636 --- /dev/null +++ b/tests/specs/npm/npmrc/main.js @@ -0,0 +1,8 @@ +import { getValue, setValue } from "@denotest/basic"; +import * as test from "@denotest2/basic"; + +console.log(getValue()); +setValue(42); +console.log(getValue()); + +console.log(test.getValue()); diff --git a/tests/specs/npm/npmrc/main.out b/tests/specs/npm/npmrc/main.out new file mode 100644 index 000000000..bbe210bdb --- /dev/null +++ b/tests/specs/npm/npmrc/main.out @@ -0,0 +1,3 @@ +0 +42 +0 diff --git a/tests/specs/npm/npmrc/package.json b/tests/specs/npm/npmrc/package.json new file mode 100644 index 000000000..274d1ed7f --- /dev/null +++ b/tests/specs/npm/npmrc/package.json @@ -0,0 +1,8 @@ +{ + "name": "npmrc_test", + "version": "0.0.1", + "dependencies": { + "@denotest/basic": "1.0.0", + "@denotest2/basic": "1.0.0" + } +} diff --git a/tests/specs/npm/npmrc_bad_token/.npmrc b/tests/specs/npm/npmrc_bad_token/.npmrc new file mode 100644 index 000000000..c4b03fd7a --- /dev/null +++ b/tests/specs/npm/npmrc_bad_token/.npmrc @@ -0,0 +1,2 @@ +@denotest:registry=http://127.0.0.1:4261/ +//127.0.0.1:4261/denotest/:_authToken=invalid-token diff --git a/tests/specs/npm/npmrc_bad_token/__test__.jsonc b/tests/specs/npm/npmrc_bad_token/__test__.jsonc new file mode 100644 index 000000000..fe99247b1 --- /dev/null +++ b/tests/specs/npm/npmrc_bad_token/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "envs": { + "DENO_FUTURE": "1" + }, + "tempDir": true, + "args": "install", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/npm/npmrc_bad_token/main.js b/tests/specs/npm/npmrc_bad_token/main.js new file mode 100644 index 000000000..e8ccf7611 --- /dev/null +++ b/tests/specs/npm/npmrc_bad_token/main.js @@ -0,0 +1,5 @@ +import { getValue, setValue } from "@denotest/basic"; + +console.log(getValue()); +setValue(42); +console.log(getValue()); diff --git a/tests/specs/npm/npmrc_bad_token/main.out b/tests/specs/npm/npmrc_bad_token/main.out new file mode 100644 index 000000000..ceee1fed4 --- /dev/null +++ b/tests/specs/npm/npmrc_bad_token/main.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://127.0.0.1:4261/@denotest/basic +error: Error getting response at http://127.0.0.1:4261/@denotest/basic for package "@denotest/basic": Bad response: 401 +[WILDCARD]
\ No newline at end of file diff --git a/tests/specs/npm/npmrc_bad_token/package.json b/tests/specs/npm/npmrc_bad_token/package.json new file mode 100644 index 000000000..b5ca7df42 --- /dev/null +++ b/tests/specs/npm/npmrc_bad_token/package.json @@ -0,0 +1,7 @@ +{ + "name": "npmrc_test", + "version": "0.0.1", + "dependencies": { + "@denotest/basic": "1.0.0" + } +} diff --git a/tests/specs/npm/npmrc_basic_auth/.npmrc b/tests/specs/npm/npmrc_basic_auth/.npmrc new file mode 100644 index 000000000..0624091f0 --- /dev/null +++ b/tests/specs/npm/npmrc_basic_auth/.npmrc @@ -0,0 +1,4 @@ +@denotest:registry=http://127.0.0.1:4261/ +//127.0.0.1:4261/denotest/:_authToken=private-reg-token +@denotest2:registry=http://127.0.0.1:4262/ +//127.0.0.1:4262/denotest2/:_authToken=private-reg-token2 diff --git a/tests/specs/npm/npmrc_basic_auth/__test__.jsonc b/tests/specs/npm/npmrc_basic_auth/__test__.jsonc new file mode 100644 index 000000000..44298ed2f --- /dev/null +++ b/tests/specs/npm/npmrc_basic_auth/__test__.jsonc @@ -0,0 +1,13 @@ +{ + "envs": { + "DENO_FUTURE": "1" + }, + "tempDir": true, + "steps": [{ + "args": "install", + "output": "install.out" + }, { + "args": "run -A main.js", + "output": "main.out" + }] +} diff --git a/tests/specs/npm/npmrc_basic_auth/install.out b/tests/specs/npm/npmrc_basic_auth/install.out new file mode 100644 index 000000000..7484405db --- /dev/null +++ b/tests/specs/npm/npmrc_basic_auth/install.out @@ -0,0 +1,9 @@ +⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag. +[UNORDERED_START] +Download http://127.0.0.1:4261/@denotest/basic +Download http://127.0.0.1:4262/@denotest2/basic +Download http://localhost:4261/@denotest/basic/1.0.0.tgz +Download http://localhost:4262/@denotest2/basic/1.0.0.tgz +Initialize @denotest2/basic@1.0.0 +Initialize @denotest/basic@1.0.0 +[UNORDERED_END] diff --git a/tests/specs/npm/npmrc_basic_auth/main.js b/tests/specs/npm/npmrc_basic_auth/main.js new file mode 100644 index 000000000..66b393636 --- /dev/null +++ b/tests/specs/npm/npmrc_basic_auth/main.js @@ -0,0 +1,8 @@ +import { getValue, setValue } from "@denotest/basic"; +import * as test from "@denotest2/basic"; + +console.log(getValue()); +setValue(42); +console.log(getValue()); + +console.log(test.getValue()); diff --git a/tests/specs/npm/npmrc_basic_auth/main.out b/tests/specs/npm/npmrc_basic_auth/main.out new file mode 100644 index 000000000..bbe210bdb --- /dev/null +++ b/tests/specs/npm/npmrc_basic_auth/main.out @@ -0,0 +1,3 @@ +0 +42 +0 diff --git a/tests/specs/npm/npmrc_basic_auth/package.json b/tests/specs/npm/npmrc_basic_auth/package.json new file mode 100644 index 000000000..274d1ed7f --- /dev/null +++ b/tests/specs/npm/npmrc_basic_auth/package.json @@ -0,0 +1,8 @@ +{ + "name": "npmrc_test", + "version": "0.0.1", + "dependencies": { + "@denotest/basic": "1.0.0", + "@denotest2/basic": "1.0.0" + } +} diff --git a/tests/specs/npm/npmrc_deno_json/.npmrc b/tests/specs/npm/npmrc_deno_json/.npmrc new file mode 100644 index 000000000..18887e8d3 --- /dev/null +++ b/tests/specs/npm/npmrc_deno_json/.npmrc @@ -0,0 +1,2 @@ +@denotest:registry=http://127.0.0.1:4261/ +//127.0.0.1:4261/denotest/:_authToken=private-reg-token diff --git a/tests/specs/npm/npmrc_deno_json/__test__.jsonc b/tests/specs/npm/npmrc_deno_json/__test__.jsonc new file mode 100644 index 000000000..5d07b7034 --- /dev/null +++ b/tests/specs/npm/npmrc_deno_json/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "envs": { + "DENO_FUTURE": "1" + }, + "tempDir": true, + "args": "run -A main.js", + "output": "main.out" +} diff --git a/tests/specs/npm/npmrc_deno_json/deno.json b/tests/specs/npm/npmrc_deno_json/deno.json new file mode 100644 index 000000000..f6ca8454c --- /dev/null +++ b/tests/specs/npm/npmrc_deno_json/deno.json @@ -0,0 +1,3 @@ +{ + "imports": {} +} diff --git a/tests/specs/npm/npmrc_deno_json/main.js b/tests/specs/npm/npmrc_deno_json/main.js new file mode 100644 index 000000000..9246715d1 --- /dev/null +++ b/tests/specs/npm/npmrc_deno_json/main.js @@ -0,0 +1,5 @@ +import { getValue, setValue } from "npm:@denotest/basic"; + +console.log(getValue()); +setValue(42); +console.log(getValue()); diff --git a/tests/specs/npm/npmrc_deno_json/main.out b/tests/specs/npm/npmrc_deno_json/main.out new file mode 100644 index 000000000..6a1e47669 --- /dev/null +++ b/tests/specs/npm/npmrc_deno_json/main.out @@ -0,0 +1,4 @@ +Download http://127.0.0.1:4261/@denotest/basic +Download http://localhost:4261/@denotest/basic/1.0.0.tgz +0 +42 diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/.npmrc b/tests/specs/npm/npmrc_not_next_to_package_json/.npmrc new file mode 100644 index 000000000..18887e8d3 --- /dev/null +++ b/tests/specs/npm/npmrc_not_next_to_package_json/.npmrc @@ -0,0 +1,2 @@ +@denotest:registry=http://127.0.0.1:4261/ +//127.0.0.1:4261/denotest/:_authToken=private-reg-token diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/__test__.jsonc b/tests/specs/npm/npmrc_not_next_to_package_json/__test__.jsonc new file mode 100644 index 000000000..fa545c290 --- /dev/null +++ b/tests/specs/npm/npmrc_not_next_to_package_json/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "envs": { + "DENO_FUTURE": "1" + }, + "tempDir": true, + "args": "install -A -L debug", + "output": "main.out", + "cwd": "subdir" +} diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/main.out b/tests/specs/npm/npmrc_not_next_to_package_json/main.out new file mode 100644 index 000000000..8f42fb6d8 --- /dev/null +++ b/tests/specs/npm/npmrc_not_next_to_package_json/main.out @@ -0,0 +1,6 @@ +[# This test is still downloading code, because we have a private registry] +[# that serves the same packages. The important bit is the message below.] +[WILDCARD] No .npmrc file found +[WILDCARD] +Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz +Initialize @denotest/esm-basic@1.0.0 diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/subdir/main.js b/tests/specs/npm/npmrc_not_next_to_package_json/subdir/main.js new file mode 100644 index 000000000..81dd521da --- /dev/null +++ b/tests/specs/npm/npmrc_not_next_to_package_json/subdir/main.js @@ -0,0 +1,5 @@ +import { getValue, setValue } from "@denotest/esm-basic"; + +console.log(getValue()); +setValue(42); +console.log(getValue()); diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/subdir/package.json b/tests/specs/npm/npmrc_not_next_to_package_json/subdir/package.json new file mode 100644 index 000000000..99feed9d8 --- /dev/null +++ b/tests/specs/npm/npmrc_not_next_to_package_json/subdir/package.json @@ -0,0 +1,7 @@ +{ + "name": "npmrc_test", + "version": "0.0.1", + "dependencies": { + "@denotest/esm-basic": "1.0.0" + } +} |