fix: fixes docs cache to be based on npm version
reggi committed
Apr 23, 2025 at 13:40 UTC
45a5c8f4edf8155d451c932cfaae6798d9d66405
7 files changed
+16
-27
cli-cache.json
+4
-4
@@ -1,6 +1,6 @@
1
{
2
- "v8": "aa8fff11cdab94fff1a2160ee5241f5f4632e96b",
3
- "v9": "64763a341e7aa5b456e696f956759bf9b3440dc1",
4
- "v10": "e510f14bf6a20d67e7b37c3f25ff271d9f7a0da5",
5
- "v11": "4b08e2ed252a18f85a360b76c7273a7aa7a994ca"
2
+ "v8": "8.19.4",
3
+ "v9": "9.9.4",
4
+ "v10": "10.9.2",
5
+ "v11": "11.3.0"
6
}
\ No newline at end of file
cli/lib/build.js
+2
-2
@@ -3,7 +3,7 @@ const fs = require('fs').promises
3
const yaml = require('yaml')
4
const semver = require('semver')
5
const pacote = require('pacote')
6
-const extractRelease = require('./extract')
6
+const {unpackRelease} = require('./extract')
7
const log = require('./log')
8
9
const DOCS_PATH = 'cli'
@@ -120,7 +120,7 @@ const main = async ({loglevel, releases: rawReleases, useCurrent, navPath, conte
120
cache?.voidOnNewKey(releases.map(v => v.id))
121
122
const updates = await Promise.all(
123
- releases.map(r => extractRelease(r, {cache, contentPath, baseNav: navData, prerelease})),
123
+ releases.map(r => unpackRelease(r, {cache, contentPath, baseNav: navData, prerelease})),
124
).then(r => r.filter(Boolean))
125
126
await cache?.save()
cli/lib/extract.js
+6
-4
@@ -140,12 +140,12 @@ const writeChangelog = async ({release, nav, cwd, srcPath, contentPath}) => {
140
141
const unpackRelease = async (release, {cache, contentPath, baseNav, prerelease = false}) => {
142
if (cache) {
143
- const sha = await gh.getCurrentSha(release.branch)
144
- if (cache.same(release.id, sha)) {
143
+ const currentVersion = await pacote.manifest(`npm@${release.version}`).then(manifest => manifest.version)
144
+ if (cache.same(release.id, currentVersion)) {
145
log.info(`Skipping ${release.id} due to cache`)
146
return
147
}
148
- cache.set(release.id, sha)
148
+ cache.set(release.id, currentVersion)
149
}
150
151
if (release.prerelease && !prerelease) {
@@ -231,4 +231,6 @@ const unpackRelease = async (release, {cache, contentPath, baseNav, prerelease =
231
}
232
}
233
234
-module.exports = unpackRelease
234
+module.exports = {
235
+ unpackRelease,
236
+}
cli/lib/gh.js
-13
@@ -15,18 +15,6 @@ const owner = 'npm'
15
const repo = 'cli'
16
const opts = {owner, repo}
17
18
-const getCurrentSha = async branch => {
19
- if (!octokit) {
20
- const {Octokit} = await import('@octokit/rest')
21
- octokit = new Octokit({auth: process.env.GITHUB_TOKEN})
22
- }
23
- const {data} = await octokit.repos.getBranch({
24
- ...opts,
25
- branch,
26
- })
27
- return data.commit.sha
28
-}
29
-
18
const getFile = async ({sha, ref, path}) => {
19
if (!octokit) {
20
const {Octokit} = await import('@octokit/rest')
@@ -69,6 +57,5 @@ const pathExists = async (ref, path) => {
57
module.exports = {
58
getFile,
59
pathExists,
72
- getCurrentSha,
60
nwo: `${owner}/${repo}`,
61
}
cli/test/index.js
-4
@@ -84,10 +84,6 @@ const mockBuild = async (t, {releases = getReleases(), packument = {}, testdir:
84
},
85
'@prettier/sync': {format: s => s},
86
'../lib/gh.js': {
87
- getCurrentSha: async () => {
88
- shaCounter = shaCounter + 1
89
- return 'abc' + shaCounter
90
- },
87
getFile: async ({ref}) => navSection(ref),
88
pathExists: async (ref, p) => {
89
if (ref.includes('v6') && p.includes('docs/lib/content')) {
content/cli/v8/using-npm/registry.mdx
+2
@@ -21,6 +21,8 @@ You can configure npm to use any compatible registry you like, and even run your
21
22
npm's package registry implementation supports several write APIs as well, to allow for publishing packages and managing user account information.
23
24
+The npm public registry is powered by a CouchDB database, of which there is a public mirror at [https://skimdb.npmjs.com/registry](https://skimdb.npmjs.com/registry).
25
+
26
The registry URL used is determined by the scope of the package (see [`scope`](/cli/v8/using-npm/scope). If no scope is specified, the default registry is used, which is supplied by the `registry` config parameter. See [`npm config`](/cli/v8/commands/npm-config), [`npmrc`](/cli/v8/configuring-npm/npmrc), and [`config`](/cli/v8/using-npm/config) for more on managing npm's configuration.
27
28
When the default registry is used in a package-lock or shrinkwrap is has the special meaning of "the currently configured registry". If you create a lock file while using the default registry you can switch to another registry and npm will install packages from the new registry, but if you create a lock file while using a custom registry packages will be installed from that registry even after you change to another registry.
content/cli/v9/using-npm/registry.mdx
+2
@@ -21,6 +21,8 @@ You can configure npm to use any compatible registry you like, and even run your
21
22
npm's package registry implementation supports several write APIs as well, to allow for publishing packages and managing user account information.
23
24
+The npm public registry is powered by a CouchDB database, of which there is a public mirror at [https://skimdb.npmjs.com/registry](https://skimdb.npmjs.com/registry).
25
+
26
The registry URL used is determined by the scope of the package (see [`scope`](/cli/v9/using-npm/scope). If no scope is specified, the default registry is used, which is supplied by the [`registry` config](/cli/v9/using-npm/config#registry) parameter. See [`npm config`](/cli/v9/commands/npm-config), [`npmrc`](/cli/v9/configuring-npm/npmrc), and [`config`](/cli/v9/using-npm/config) for more on managing npm's configuration. Authentication configuration such as auth tokens and certificates are configured specifically scoped to an individual registry. See [Auth Related Configuration](/cli/v9/configuring-npm/npmrc#auth-related-configuration)
27
28
When the default registry is used in a package-lock or shrinkwrap it has the special meaning of "the currently configured registry". If you create a lock file while using the default registry you can switch to another registry and npm will install packages from the new registry, but if you create a lock file while using a custom registry packages will be installed from that registry even after you change to another registry.