Skip to content

fix(deps): update dependency read-pkg to v9 #6346

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

Merged
merged 3 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 57 additions & 91 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion packages/build-info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dot-prop": "^9.0.0",
"find-up": "^7.0.0",
"minimatch": "^9.0.0",
"read-pkg": "^7.1.0",
"read-pkg": "^9.0.0",
"semver": "^7.3.8",
"yaml": "^2.1.3",
"yargs": "^17.6.0"
Expand Down
6 changes: 4 additions & 2 deletions packages/build-info/src/frameworks/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Detection = {
accuracy: Accuracy
/** The NPM package that was able to detect it (high accuracy) */
package?: { name: string; version?: SemVer }
packageJSON?: PackageJson
packageJSON?: Partial<PackageJson>
/** The absolute path to config file that is associated with the framework */
config?: string
/** The name of config file that is associated with the framework */
Expand Down Expand Up @@ -246,7 +246,9 @@ export abstract class BaseFramework implements Framework {
}

/** check if the npmDependencies are used inside the provided package.json */
private async npmDependenciesUsed(pkgJSON: PackageJson): Promise<{ name: string; version?: SemVer } | undefined> {
private async npmDependenciesUsed(
pkgJSON: Partial<PackageJson>,
): Promise<{ name: string; version?: SemVer } | undefined> {
const allDeps = [...Object.entries(pkgJSON.dependencies || {}), ...Object.entries(pkgJSON.devDependencies || {})]

const found = allDeps.find(([depName]) => this.npmDependencies.includes(depName))
Expand Down
9 changes: 3 additions & 6 deletions packages/build-info/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class Project {
}

/** retrieves the root package.json file */
async getRootPackageJSON(): Promise<PackageJson> {
async getRootPackageJSON(): Promise<Partial<PackageJson>> {
// get the most upper json file
const rootJSONPath = (
await this.fs.findUpMultiple('package.json', { cwd: this.baseDirectory, stopAt: this.root })
Expand All @@ -185,17 +185,14 @@ export class Project {
}

/** Retrieves the package.json and if one found with it's pkgPath */
async getPackageJSON(startDirectory?: string): Promise<PackageJson & { pkgPath: string | null }> {
async getPackageJSON(startDirectory?: string): Promise<Partial<PackageJson> & { pkgPath: string | null }> {
const pkgPath = await this.fs.findUp('package.json', {
cwd: startDirectory || this.baseDirectory,
stopAt: this.root,
})
if (pkgPath) {
const json = await this.fs.readJSON<PackageJson>(pkgPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone else reading this by any chance... I was confused by this PR until I pulled the code down and poked it around. For posterity, all is explained by this fs.readJSON<T> helper returning Partial<T> for some reason!

return {
...json,
pkgPath,
}
return Object.assign(json, { pkgPath })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to Object.assign to get around the type errors

}
return { pkgPath: null }
}
Expand Down
2 changes: 1 addition & 1 deletion packages/build-info/src/workspaces/detect-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function detectPnpmWorkspaceGlobs(project: Project): Promise<string
}

/** Get the workspace globs from the package.json file */
export async function detectNpmOrYarnWorkspaceGlobs(pkgJSON: PackageJson): Promise<string[]> {
export async function detectNpmOrYarnWorkspaceGlobs(pkgJSON: Partial<PackageJson>): Promise<string[]> {
if (Array.isArray(pkgJSON.workspaces)) {
return pkgJSON.workspaces || []
}
Expand Down
Loading