visual-companion 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PUBLISHING.md +58 -9
- package/package.json +1 -1
package/PUBLISHING.md
CHANGED
|
@@ -25,23 +25,72 @@ That is npm's response to a token it does not accept — it deliberately does no
|
|
|
25
25
|
distinguish "no such package" from "you may not create it", so a 404 on PUT
|
|
26
26
|
almost always means the token, not the name.
|
|
27
27
|
|
|
28
|
-
Check
|
|
28
|
+
Check which token you are actually using before blaming anything else. This
|
|
29
|
+
machine demonstrates both failure modes at once:
|
|
30
|
+
|
|
31
|
+
- `~/.npmrc` holds a token scoped to `registry.npmjs.org` that has since been
|
|
32
|
+
revoked. `npm whoami` against the official registry answers `{}` or 401.
|
|
33
|
+
- The valid token lives in the `NPM_TOKEN` environment variable, exported from
|
|
34
|
+
`~/.zshrc`. **npm does not read `NPM_TOKEN` on its own** — an env var is not
|
|
35
|
+
an `.npmrc` entry, so `npm whoami` fails even though a working token is right
|
|
36
|
+
there in the environment.
|
|
37
|
+
|
|
38
|
+
Two consequences worth remembering:
|
|
39
|
+
|
|
40
|
+
1. A non-interactive shell does not source `~/.zshrc`. `zsh -c 'echo $NPM_TOKEN'`
|
|
41
|
+
prints nothing; `zsh -ic` (interactive) does. That difference cost more time
|
|
42
|
+
here than the actual publish did.
|
|
43
|
+
2. The registry file and the environment variable can disagree. Check both:
|
|
29
44
|
|
|
30
45
|
```bash
|
|
31
|
-
npm whoami --registry=https://registry.npmjs.org/
|
|
46
|
+
zsh -ic 'npm whoami --registry=https://registry.npmjs.org/' # uses ~/.npmrc
|
|
47
|
+
zsh -ic 'curl -sS -H "Authorization: Bearer $NPM_TOKEN" \
|
|
48
|
+
https://registry.npmjs.org/-/whoami' # uses the env var
|
|
32
49
|
```
|
|
33
50
|
|
|
34
|
-
`{}`
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
The second returning `{"username":"..."}` while the first returns 401 means the
|
|
52
|
+
env var is the good one.
|
|
53
|
+
|
|
54
|
+
Also note that `~/.npmrc` may point `registry` at a mirror (npmmirror here), so
|
|
55
|
+
`whoami` and `publish` would go somewhere your npmjs token means nothing. Always
|
|
56
|
+
pass the registry explicitly.
|
|
57
|
+
|
|
58
|
+
Publishing with the environment token, without writing it to disk anywhere
|
|
59
|
+
`git` can see:
|
|
37
60
|
|
|
61
|
+
```bash
|
|
62
|
+
cd packaging/npm
|
|
63
|
+
printf "//registry.npmjs.org/:_authToken=%s\n" "$NPM_TOKEN" > .npmrc # gitignored
|
|
64
|
+
chmod 600 .npmrc
|
|
65
|
+
npm publish
|
|
66
|
+
rm -f .npmrc
|
|
38
67
|
```
|
|
39
|
-
|
|
68
|
+
|
|
69
|
+
Or mint a fresh granular token with *Read and write* permission at
|
|
70
|
+
<https://www.npmjs.com/settings/~/tokens> and fix `~/.npmrc` properly.
|
|
71
|
+
|
|
72
|
+
## A 404 on PUT does not mean the name is taken
|
|
73
|
+
|
|
74
|
+
`npm publish` answers
|
|
75
|
+
|
|
40
76
|
```
|
|
77
|
+
404 Not Found - PUT https://registry.npmjs.org/<name>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
both when the token is rejected and when the package genuinely does not exist
|
|
81
|
+
yet. npm deliberately does not distinguish them. If a GET of the same name also
|
|
82
|
+
404s, the name is free and the problem is the token.
|
|
41
83
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
84
|
+
## A successful publish is not immediately readable
|
|
85
|
+
|
|
86
|
+
The write path and the read path are different services. `npm publish` returned
|
|
87
|
+
`200` for the PUT while `GET /visual-companion` kept answering `404` for roughly
|
|
88
|
+
twenty seconds afterwards. Check the log for the PUT status before concluding a
|
|
89
|
+
publish failed:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
grep "http fetch PUT" ~/.npm/_logs/*-debug-0.log | tail -1
|
|
93
|
+
```
|
|
45
94
|
|
|
46
95
|
## Publishing
|
|
47
96
|
|
package/package.json
CHANGED