-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: implement npmMinimalAgeGate and npmPreapprovedPackages config options
#6901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
a05df86
db24b78
900a7d2
11f5edd
eccba6c
257fa2d
84d4b5d
0c7b130
ebd41b5
79d3aa7
55b5185
9db6b3b
93957a6
98e58ad
fb35bc8
ef35b65
b0d4031
0cdbdfb
e4cd5dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| releases: | ||
| "@yarnpkg/core": minor | ||
| "@yarnpkg/plugin-essentials": minor | ||
| "@yarnpkg/plugin-npm": minor | ||
| "@yarnpkg/plugin-compat": minor | ||
| "@yarnpkg/plugin-constraints": minor | ||
| "@yarnpkg/plugin-dlx": minor | ||
| "@yarnpkg/plugin-exec": minor | ||
| "@yarnpkg/plugin-file": minor | ||
| "@yarnpkg/plugin-git": minor | ||
| "@yarnpkg/plugin-github": minor | ||
| "@yarnpkg/plugin-http": minor | ||
| "@yarnpkg/plugin-init": minor | ||
| "@yarnpkg/plugin-interactive-tools": minor | ||
| "@yarnpkg/plugin-jsr": minor | ||
| "@yarnpkg/plugin-link": minor | ||
| "@yarnpkg/plugin-nm": minor | ||
| "@yarnpkg/plugin-npm-cli": minor | ||
| "@yarnpkg/plugin-pack": minor | ||
| "@yarnpkg/plugin-patch": minor | ||
| "@yarnpkg/plugin-pnp": minor | ||
| "@yarnpkg/plugin-pnpm": minor | ||
| "@yarnpkg/plugin-stage": minor | ||
| "@yarnpkg/plugin-typescript": minor | ||
| "@yarnpkg/plugin-version": minor | ||
| "@yarnpkg/plugin-workspace-tools": minor | ||
| "@yarnpkg/builder": minor | ||
| "@yarnpkg/cli": minor | ||
| "@yarnpkg/doctor": minor | ||
| "@yarnpkg/extensions": minor | ||
| "@yarnpkg/nm": minor | ||
| "@yarnpkg/pnpify": minor | ||
| "@yarnpkg/sdks": minor | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ export const TEST_TIMEOUT = os.endianness() === `BE` | |
| ? 300000 | ||
| : 75000; | ||
|
|
||
| export type PackageEntry = Map<string, {path: string, packageJson: Record<string, any>}>; | ||
| export type PackageEntry = Map<string, {path: string, packageJson: Record<string, any>, releaseDate: string | undefined}>; | ||
| export type PackageRegistry = Map<string, PackageEntry>; | ||
|
|
||
| interface RunDriverOptions extends Record<string, any> { | ||
|
|
@@ -177,6 +177,24 @@ export const ADVISORIES = new Map<string, Array<npmAuditTypes.AuditMetadata>>([ | |
| }]], | ||
| ]); | ||
|
|
||
| const RELEASE_DATE_PACKAGES: Record<string, Record<string, number | string>> = { | ||
| "release-date": { | ||
| "1.0.0": new Date(new Date().getTime() - /* 10 days */ 1000 * 60 * 60 * 24 * 10).toISOString(), | ||
| "1.1.0": new Date(new Date().getTime() - /* 5 days */ 1000 * 60 * 60 * 24 * 5).toISOString(), | ||
| "1.1.1": new Date().toISOString(), | ||
| }, | ||
| "release-date-transitive": { | ||
| "1.0.0": new Date(new Date().getTime() - /* 10 days */ 1000 * 60 * 60 * 24 * 10).toISOString(), | ||
| "1.1.0": new Date(new Date().getTime() - /* 5 days */ 1000 * 60 * 60 * 24 * 5).toISOString(), | ||
| "1.1.1": new Date().toISOString(), | ||
| }, | ||
| "@scoped/release-date": { | ||
| "1.0.0": new Date(new Date().getTime() - /* 10 days */ 1000 * 60 * 60 * 24 * 10).toISOString(), | ||
| "1.1.0": new Date(new Date().getTime() - /* 5 days */ 1000 * 60 * 60 * 24 * 5).toISOString(), | ||
| "1.1.1": new Date().toISOString(), | ||
| }, | ||
| }; | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. open to a better way of storing/computing this metadata. The only other thought I had was to store a delta (e.g. 5 days) in the fixture package.json metadata and calculate the registry response as
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way you implemented it seems good to me 👍 |
||
| export const validLogins = { | ||
| fooUser: new Login(`foo-user`), | ||
| barUser: new Login(`bar-user`), | ||
|
|
@@ -233,7 +251,7 @@ export const getPackageRegistry = (): Promise<PackageRegistry> => { | |
| const packageFile = ppath.join(packagesDir, packageName, Filename.manifest); | ||
| const packageJson = await xfs.readJsonPromise(packageFile); | ||
|
|
||
| const {name, version} = packageJson; | ||
| const {name, version}: {name: string, version: string} = packageJson; | ||
| if (name.startsWith(`git-`)) | ||
| continue; | ||
|
|
||
|
|
@@ -422,6 +440,7 @@ export const startPackageServer = ({type}: {type: keyof typeof packageServerUrls | |
| }), | ||
| )), | ||
| ), | ||
| time: name in RELEASE_DATE_PACKAGES ? RELEASE_DATE_PACKAGES[name] : undefined, | ||
| [`dist-tags`]: { | ||
| latest: semver.maxSatisfying(versions, `*`), | ||
| ...distTags, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "@scoped/release-date", | ||
| "version": "1.0.0" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "@scoped/release-date", | ||
| "version": "1.1.0" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "@scoped/release-date", | ||
| "version": "1.1.1" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "release-date", | ||
| "version": "1.0.0", | ||
| "dependencies": { | ||
| "release-date-transitive": "^1.0.0" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "release-date", | ||
| "version": "1.1.0", | ||
| "dependencies": { | ||
| "release-date-transitive": "^1.0.0" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "name": "release-date", | ||
| "version": "1.1.1", | ||
| "dependencies": { | ||
| "release-date-transitive": "^1.0.0" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "release-date-transitive", | ||
| "version": "1.0.0" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "release-date-transitive", | ||
| "version": "1.1.0" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| module.exports = require(`./package.json`); | ||
|
|
||
| for (const key of [`dependencies`, `devDependencies`, `peerDependencies`]) { | ||
| for (const dep of Object.keys(module.exports[key] || {})) { | ||
| module.exports[key][dep] = require(dep); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "name": "release-date-transitive", | ||
| "version": "1.1.1" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an a bug leftover from a while ago or something. My tests were failing because the array was not being parsed correctly -- they are comma-delimited when passed as
YARN_- seeberry/packages/yarnpkg-core/sources/Configuration.ts
Lines 754 to 759 in 5aad466