Skip to content

Commit

Permalink
Fix access script and suppress some errors of publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Oct 10, 2024
1 parent 9c1f831 commit 28213e2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
15 changes: 0 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"fs-extra": "^11.2.0",
"husky": "^9.1.6",
"knip": "^5.30.6",
"libnpmaccess": "^9.0.0",
"make-fetch-happen": "^14.0.1",
"normalize-package-data": "^7.0.0",
"npm-package-arg": "^12.0.0",
Expand Down
17 changes: 12 additions & 5 deletions scripts/update-npm-package-access.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

const path = require('node:path')
const util = require('node:util')

const access = require('libnpmaccess')

const constants = require('@socketregistry/scripts/constants')
const { COLUMN_LIMIT, ENV, parseArgsConfig } = constants
const { COLUMN_LIMIT, ENV, npmPackagesPath, parseArgsConfig } = constants
const { joinAsList } = require('@socketregistry/scripts/utils/arrays')
const { execNpm } = require('@socketregistry/scripts/utils/npm')

const { values: cliArgs } = util.parseArgs(parseArgsConfig)

Expand All @@ -19,9 +19,16 @@ const { values: cliArgs } = util.parseArgs(parseArgsConfig)
await Promise.all(
// Lazily access constants.npmPackageNames.
constants.npmPackageNames.map(async regPkgName => {
const pkgPath = path.join(npmPackagesPath, regPkgName)
try {
await access.setMfa(regPkgName, 'automation', {
'//registry.npmjs.org/:_authToken': ENV.NODE_AUTH_TOKEN
await execNpm(['access', 'set', 'mfa=automation'], {
cwd: pkgPath,
stdio: 'inherit',
env: {
__proto__: null,
...process.env,
NODE_AUTH_TOKEN: ENV.NODE_AUTH_TOKEN
}
})
} catch {
failures.push(regPkgName)
Expand Down
8 changes: 6 additions & 2 deletions scripts/update-npm-package-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ const { values: cliArgs } = util.parseArgs(parseArgsConfig)
NODE_AUTH_TOKEN: ENV.NODE_AUTH_TOKEN
}
})
} catch {
failures.push(regPkgName)
} catch (e) {
const stderr = e?.stderr ?? ''
const isPublishOverError = stderr.includes('code E403') && stderr.includes('cannot publish over')
if (!isPublishOverError) {
failures.push(regPkgName)
}
}
})
)
Expand Down

0 comments on commit 28213e2

Please sign in to comment.