mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-25 15:07:06 -04:00
fix: updateWorkspaceManifest not writing to manifest file (#9171)
* fix: updateWorkspaceManifest not writing to manifest file close #9168 * fix: updating fields in pnpm-workspace.yaml * refactor: import statement --------- Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
6
.changeset/fifty-trainers-unite.md
Normal file
6
.changeset/fifty-trainers-unite.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/workspace.manifest-writer": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Fix the update of `pnpm-workspace.yaml` by the `pnpm approve-builds` command [#9168](https://github.com/pnpm/pnpm/issues/9168).
|
||||
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@@ -8048,6 +8048,9 @@ importers:
|
||||
|
||||
workspace/manifest-writer:
|
||||
dependencies:
|
||||
'@pnpm/constants':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/constants
|
||||
'@pnpm/workspace.read-manifest':
|
||||
specifier: workspace:*
|
||||
version: link:../read-manifest
|
||||
@@ -8055,9 +8058,15 @@ importers:
|
||||
specifier: 'catalog:'
|
||||
version: 5.0.0
|
||||
devDependencies:
|
||||
'@pnpm/prepare-temp-dir':
|
||||
specifier: workspace:*
|
||||
version: link:../../__utils__/prepare-temp-dir
|
||||
'@pnpm/workspace.manifest-writer':
|
||||
specifier: workspace:*
|
||||
version: 'link:'
|
||||
read-yaml-file:
|
||||
specifier: 'catalog:'
|
||||
version: 2.1.0
|
||||
|
||||
workspace/pkgs-graph:
|
||||
dependencies:
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
"node": ">=18.12"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint \"src/**/*.ts\"",
|
||||
"test": "pnpm run compile",
|
||||
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"test": "pnpm run compile && pnpm run _test",
|
||||
"prepublishOnly": "pnpm run compile",
|
||||
"compile": "tsc --build && pnpm run lint --fix"
|
||||
"compile": "tsc --build && pnpm run lint --fix",
|
||||
"_test": "jest"
|
||||
},
|
||||
"repository": "https://github.com/pnpm/pnpm/blob/main/workspace/manifest-writer",
|
||||
"keywords": [
|
||||
@@ -28,12 +29,15 @@
|
||||
},
|
||||
"homepage": "https://github.com/pnpm/pnpm/blob/main/workspace/manifest-writer#readme",
|
||||
"dependencies": {
|
||||
"@pnpm/constants": "workspace:*",
|
||||
"@pnpm/workspace.read-manifest": "workspace:*",
|
||||
"write-yaml-file": "catalog:"
|
||||
},
|
||||
"funding": "https://opencollective.com/pnpm",
|
||||
"devDependencies": {
|
||||
"@pnpm/workspace.manifest-writer": "workspace:*"
|
||||
"@pnpm/prepare-temp-dir": "workspace:*",
|
||||
"@pnpm/workspace.manifest-writer": "workspace:*",
|
||||
"read-yaml-file": "catalog:"
|
||||
},
|
||||
"exports": {
|
||||
".": "./lib/index.js"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import path from 'path'
|
||||
import { readWorkspaceManifest, type WorkspaceManifest } from '@pnpm/workspace.read-manifest'
|
||||
import { WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants'
|
||||
import writeYamlFile from 'write-yaml-file'
|
||||
|
||||
export async function updateWorkspaceManifest (dir: string, updatedFields: Partial<WorkspaceManifest>): Promise<void> {
|
||||
const manifest = await readWorkspaceManifest(dir)
|
||||
await writeYamlFile(dir, {
|
||||
await writeYamlFile(path.join(dir, WORKSPACE_MANIFEST_FILENAME), {
|
||||
...manifest,
|
||||
updatedFields,
|
||||
...updatedFields,
|
||||
})
|
||||
}
|
||||
|
||||
17
workspace/manifest-writer/test/tsconfig.json
Normal file
17
workspace/manifest-writer/test/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"outDir": "../test.lib",
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"../../../__typings__/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": ".."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import path from 'path'
|
||||
import { WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants'
|
||||
import { tempDir } from '@pnpm/prepare-temp-dir'
|
||||
import { updateWorkspaceManifest } from '@pnpm/workspace.manifest-writer'
|
||||
import { sync as readYamlFile } from 'read-yaml-file'
|
||||
import { sync as writeYamlFile } from 'write-yaml-file'
|
||||
|
||||
test('updateWorkspaceManifest', async () => {
|
||||
const dir = tempDir(false)
|
||||
const filePath = path.join(dir, WORKSPACE_MANIFEST_FILENAME)
|
||||
writeYamlFile(filePath, { packages: ['*'] })
|
||||
await updateWorkspaceManifest(dir, {
|
||||
onlyBuiltDependencies: [],
|
||||
})
|
||||
expect(readYamlFile(filePath)).toStrictEqual({
|
||||
packages: ['*'],
|
||||
onlyBuiltDependencies: [],
|
||||
})
|
||||
})
|
||||
@@ -9,6 +9,12 @@
|
||||
"../../__typings__/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../__utils__/prepare-temp-dir"
|
||||
},
|
||||
{
|
||||
"path": "../../packages/constants"
|
||||
},
|
||||
{
|
||||
"path": "../read-manifest"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user