feat: improved formatting of the pnpm-lock.yaml (#3196)

close #3195
This commit is contained in:
Zoltan Kochan
2021-02-25 23:54:42 +02:00
committed by GitHub
parent be52cb5324
commit f7750baed4
9 changed files with 45 additions and 32 deletions

View File

@@ -0,0 +1,7 @@
---
"@pnpm/lockfile-file": minor
---
Add blank lines to the lockfile between items.
The `resolution` object should be written in a single line.

View File

@@ -60,7 +60,8 @@
"istanbul-reports": "npm:@zkochan/istanbul-reports",
"http-errors": "^1.7.3",
"table@^6.0.3": "6.0.4",
"graceful-fs": "4.2.4"
"graceful-fs": "4.2.4",
"js-yaml@^4.0.0": "npm:@zkochan/js-yaml@0.0.1"
},
"neverBuiltDependencies": [
"core-js",

View File

@@ -50,7 +50,7 @@
"@pnpm/merge-lockfile-changes": "workspace:1.0.1",
"@pnpm/types": "workspace:6.4.0",
"@zkochan/rimraf": "^1.0.0",
"js-yaml": "^4.0.0",
"js-yaml": "npm:@zkochan/js-yaml@0.0.1",
"normalize-path": "^3.0.0",
"ramda": "^0.27.1",
"sort-keys": "^4.2.0",

View File

@@ -15,6 +15,7 @@ async function writeFileAtomic (filename: string, data: string) {
}
const LOCKFILE_YAML_FORMAT = {
blankLines: true,
lineWidth: 1000,
noCompatMode: true,
noRefs: true,

View File

@@ -4,19 +4,22 @@ exports[`writeLockfiles() 1`] = `
"dependencies:
is-negative: 1.0.0
is-positive: 1.0.0
lockfileVersion: 5.3
packages:
/is-negative/1.0.0:
resolution:
integrity: sha1-ChbBDewTLAqLCzb793Fo5VDvg/g=
resolution: {integrity: sha1-ChbBDewTLAqLCzb793Fo5VDvg/g=}
dependencies:
is-positive: 2.0.0
/is-positive/1.0.0:
resolution:
integrity: sha1-ChbBDewTLAqLCzb793Fo5VDvg/g=
resolution: {integrity: sha1-ChbBDewTLAqLCzb793Fo5VDvg/g=}
/is-positive/2.0.0:
resolution:
integrity: sha1-ChbBDewTLAqLCzb793Fo5VDvg/g=
resolution: {integrity: sha1-ChbBDewTLAqLCzb793Fo5VDvg/g=}
specifiers:
is-negative: ^1.0.0
is-positive: ^1.0.0

View File

@@ -963,7 +963,7 @@ test('all the subdeps of dependencies are linked when a node_modules is partiall
specifiers: {
foobarqar: '1.0.1',
},
})
}, { lineWidth: 1000 })
await mutateModules([
{
@@ -1053,7 +1053,7 @@ test('subdep symlinks are updated if the lockfile has new subdep versions specif
specifiers: {
'parent-of-pkg-with-1-dep': '1.0.0',
},
})
}, { lineWidth: 1000 })
await mutateModules([
{

View File

@@ -651,7 +651,7 @@ test('partial installation in a monorepo does not remove dependencies of other w
},
},
},
})
}, { lineWidth: 1000 })
await mutateModules([
{
@@ -744,7 +744,7 @@ test('partial installation in a monorepo does not remove dependencies of other w
},
},
},
})
}, { lineWidth: 1000 })
await mutateModules([
{

View File

@@ -107,7 +107,7 @@ test('lockfile with scoped package', async () => {
specifiers: {
'@types/semver': '^5.3.31',
},
})
}, { lineWidth: 1000 })
await install({
dependencies: {
@@ -135,7 +135,7 @@ test('fail when shasum from lockfile does not match with the actual one', async
specifiers: {
'is-negative': '2.1.0',
},
})
}, { lineWidth: 1000 })
try {
await install({
@@ -194,7 +194,7 @@ test('lockfile removed when no deps in package.json', async () => {
specifiers: {
'is-negative': '2.1.0',
},
})
}, { lineWidth: 1000 })
await install({}, await testDefaults())
@@ -233,7 +233,7 @@ test('lockfile is fixed when it does not match package.json', async () => {
'is-negative': '^2.1.0',
'is-positive': '^3.1.0',
},
})
}, { lineWidth: 1000 })
const reporter = sinon.spy()
await install({
@@ -291,7 +291,7 @@ test(`doing named installation when ${WANTED_LOCKFILE} exists already`, async ()
'is-negative': '^2.1.0',
'is-positive': '^3.1.0',
},
})
}, { lineWidth: 1000 })
const reporter = sinon.spy()
@@ -385,7 +385,7 @@ test(`subdeps are updated on repeat install if outer ${WANTED_LOCKFILE} does not
lockfile.packages['/pkg-with-1-dep/100.0.0'].dependencies!['dep-of-pkg-with-1-dep'] = '100.1.0'
await writeYamlFile(WANTED_LOCKFILE, lockfile)
await writeYamlFile(WANTED_LOCKFILE, lockfile, { lineWidth: 1000 })
await install(manifest, await testDefaults())
@@ -697,7 +697,7 @@ test('lockfile is ignored when lockfile = false', async () => {
specifiers: {
'is-negative': '2.1.0',
},
})
}, { lineWidth: 1000 })
const reporter = sinon.spy()
@@ -957,7 +957,7 @@ test(`doing named installation when shared ${WANTED_LOCKFILE} exists already`, a
},
},
},
})
}, { lineWidth: 1000 })
pkg2 = await addDependenciesToPackage(
pkg2,
@@ -1017,7 +1017,7 @@ test('existing dependencies are preserved when updating a lockfile to a newer fo
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults())
const initialLockfile = await project.readLockfile()
await writeYamlFile(WANTED_LOCKFILE, { ...initialLockfile, lockfileVersion: 5.01 })
await writeYamlFile(WANTED_LOCKFILE, { ...initialLockfile, lockfileVersion: 5.01 }, { lineWidth: 1000 })
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
@@ -1074,7 +1074,7 @@ test('broken lockfile is fixed even if it seems like up-to-date at first. Unless
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
delete lockfile.packages['/dep-of-pkg-with-1-dep/100.0.0']
await writeYamlFile(WANTED_LOCKFILE, lockfile)
await writeYamlFile(WANTED_LOCKFILE, lockfile, { lineWidth: 1000 })
}
let err!: PnpmError

21
pnpm-lock.yaml generated
View File

@@ -942,7 +942,7 @@ importers:
'@pnpm/merge-lockfile-changes': link:../merge-lockfile-changes
'@pnpm/types': link:../types
'@zkochan/rimraf': 1.0.0
js-yaml: 4.0.0
js-yaml: /@zkochan/js-yaml/0.0.1
normalize-path: 3.0.0
ramda: 0.27.1
sort-keys: 4.2.0
@@ -971,7 +971,7 @@ importers:
'@types/ramda': ^0.27.35
'@types/write-file-atomic': ^3.0.1
'@zkochan/rimraf': ^1.0.0
js-yaml: ^4.0.0
js-yaml: npm:@zkochan/js-yaml@0.0.1
normalize-path: ^3.0.0
ramda: ^0.27.1
sort-keys: ^4.2.0
@@ -3038,6 +3038,7 @@ overrides:
graceful-fs: 4.2.4
http-errors: ^1.7.3
istanbul-reports: npm:@zkochan/istanbul-reports
js-yaml@^4.0.0: npm:@zkochan/js-yaml@0.0.1
table@^6.0.3: 6.0.4
packages:
/@arcanis/slice-ansi/1.0.2:
@@ -4867,6 +4868,12 @@ packages:
node: '>=8'
resolution:
integrity: sha512-GeZZ9YNlvveT1CrMqe64s9+5hNF5p9Gj6J+PRQU3OnBS/9c2y5kSFavUZ9YAuoAgxFW8tKGKWIxJK4I6HBSigg==
/@zkochan/js-yaml/0.0.1:
dependencies:
argparse: 2.0.1
hasBin: true
resolution:
integrity: sha512-+mc2rjw5RJfXp9CoZPze7t4TA2RSNjiUGsocGg5WTAn3J/Ft/Xcd2PzHLIbSee6YnTzYMTLF5NsKl3sv/8RAew==
/@zkochan/libnpx/11.0.3:
dependencies:
'@zkochan/npm-package-arg': 1.0.2
@@ -9821,12 +9828,6 @@ packages:
hasBin: true
resolution:
integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
/js-yaml/4.0.0:
dependencies:
argparse: 2.0.1
hasBin: true
resolution:
integrity: sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==
/jsbn/0.1.1:
resolution:
integrity: sha1-peZUwuWi3rXyAdls77yoDA7y9RM=
@@ -12339,7 +12340,7 @@ packages:
integrity: sha512-k1KSHstyNvNq5mE6gGdqKuPEmlCYxvXMFgYdCuhzh4G3UCZynAzObU2fPpaOJ8Xd/AIUWZ1jkEwEljLVH3xkow==
/read-yaml-file/2.1.0:
dependencies:
js-yaml: 4.0.0
js-yaml: /@zkochan/js-yaml/0.0.1
strip-bom: 4.0.0
engines:
node: '>=10.13'
@@ -14736,7 +14737,7 @@ packages:
integrity: sha512-v2UQ+50TNf2rNHJ8NyWttfm/EJUBWMJcx6ZTYZr6Qp52uuegWw/lBkCtCbnYZEmPRNL61m+u67dAmGxo+HTULA==
/write-yaml-file/4.2.0:
dependencies:
js-yaml: 4.0.0
js-yaml: /@zkochan/js-yaml/0.0.1
write-file-atomic: 3.0.3
engines:
node: '>=10.13'