Skip to content

Commit 45a5c8f

Browse files
committed
fix: fixes docs cache to be based on npm version
1 parent 433f1b8 commit 45a5c8f

File tree

7 files changed

+16
-27
lines changed

7 files changed

+16
-27
lines changed

cli-cache.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
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"
66
}

cli/lib/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const fs = require('fs').promises
33
const yaml = require('yaml')
44
const semver = require('semver')
55
const pacote = require('pacote')
6-
const extractRelease = require('./extract')
6+
const {unpackRelease} = require('./extract')
77
const log = require('./log')
88

99
const DOCS_PATH = 'cli'
@@ -120,7 +120,7 @@ const main = async ({loglevel, releases: rawReleases, useCurrent, navPath, conte
120120
cache?.voidOnNewKey(releases.map(v => v.id))
121121

122122
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})),
124124
).then(r => r.filter(Boolean))
125125

126126
await cache?.save()

cli/lib/extract.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ const writeChangelog = async ({release, nav, cwd, srcPath, contentPath}) => {
140140

141141
const unpackRelease = async (release, {cache, contentPath, baseNav, prerelease = false}) => {
142142
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)) {
145145
log.info(`Skipping ${release.id} due to cache`)
146146
return
147147
}
148-
cache.set(release.id, sha)
148+
cache.set(release.id, currentVersion)
149149
}
150150

151151
if (release.prerelease && !prerelease) {
@@ -231,4 +231,6 @@ const unpackRelease = async (release, {cache, contentPath, baseNav, prerelease =
231231
}
232232
}
233233

234-
module.exports = unpackRelease
234+
module.exports = {
235+
unpackRelease,
236+
}

cli/lib/gh.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ const owner = 'npm'
1515
const repo = 'cli'
1616
const opts = {owner, repo}
1717

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-
3018
const getFile = async ({sha, ref, path}) => {
3119
if (!octokit) {
3220
const {Octokit} = await import('@octokit/rest')
@@ -69,6 +57,5 @@ const pathExists = async (ref, path) => {
6957
module.exports = {
7058
getFile,
7159
pathExists,
72-
getCurrentSha,
7360
nwo: `${owner}/${repo}`,
7461
}

cli/test/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ const mockBuild = async (t, {releases = getReleases(), packument = {}, testdir:
8484
},
8585
'@prettier/sync': {format: s => s},
8686
'../lib/gh.js': {
87-
getCurrentSha: async () => {
88-
shaCounter = shaCounter + 1
89-
return 'abc' + shaCounter
90-
},
9187
getFile: async ({ref}) => navSection(ref),
9288
pathExists: async (ref, p) => {
9389
if (ref.includes('v6') && p.includes('docs/lib/content')) {

content/cli/v8/using-npm/registry.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ You can configure npm to use any compatible registry you like, and even run your
2121

2222
npm's package registry implementation supports several write APIs as well, to allow for publishing packages and managing user account information.
2323

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+
2426
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.
2527

2628
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ You can configure npm to use any compatible registry you like, and even run your
2121

2222
npm's package registry implementation supports several write APIs as well, to allow for publishing packages and managing user account information.
2323

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+
2426
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)
2527

2628
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.

0 commit comments

Comments
 (0)