cli: fix lockfile test formats
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -19,12 +19,20 @@ import mockFs from 'mock-fs';
|
||||
import { ExtendedPackage } from '../monorepo';
|
||||
import { Lockfile } from './Lockfile';
|
||||
|
||||
const HEADER = `# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
const LEGACY_HEADER = `# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
`;
|
||||
|
||||
const mockA = `${HEADER}
|
||||
const MODERN_HEADER = `# This file is generated by running "yarn install" inside your project.
|
||||
# Manual changes might be lost - proceed with caution!
|
||||
|
||||
__metadata:
|
||||
version: 6
|
||||
cacheKey: 8
|
||||
`;
|
||||
|
||||
const mockA = `${LEGACY_HEADER}
|
||||
a@^1:
|
||||
version "1.0.1"
|
||||
resolved "https://my-registry/a-1.0.01.tgz#abc123"
|
||||
@@ -39,7 +47,7 @@ b@^2:
|
||||
version "2.0.0"
|
||||
`;
|
||||
|
||||
const mockADedup = `${HEADER}
|
||||
const mockADedup = `${LEGACY_HEADER}
|
||||
a@^1:
|
||||
version "1.0.1"
|
||||
resolved "https://my-registry/a-1.0.01.tgz#abc123"
|
||||
@@ -51,7 +59,7 @@ b@2.0.x, b@^2:
|
||||
version "2.0.1"
|
||||
`;
|
||||
|
||||
const mockB = `${HEADER}
|
||||
const mockB = `${LEGACY_HEADER}
|
||||
"@s/a@*", "@s/a@1 || 2", "@s/a@^1":
|
||||
version "1.0.1"
|
||||
|
||||
@@ -59,7 +67,7 @@ const mockB = `${HEADER}
|
||||
version "2.0.0"
|
||||
`;
|
||||
|
||||
const mockBDedup = `${HEADER}
|
||||
const mockBDedup = `${LEGACY_HEADER}
|
||||
"@s/a@*", "@s/a@1 || 2", "@s/a@^2.0.x":
|
||||
version "2.0.0"
|
||||
|
||||
@@ -157,15 +165,7 @@ describe('Lockfile', () => {
|
||||
});
|
||||
});
|
||||
|
||||
const newHeader = `# This file is generated by running "yarn install" inside your project.
|
||||
# Manual changes might be lost - proceed with caution!
|
||||
|
||||
__metadata:
|
||||
version: 6
|
||||
cacheKey: 8
|
||||
`;
|
||||
|
||||
const mockANew = `${newHeader}
|
||||
const mockANew = `${MODERN_HEADER}
|
||||
a@^1:
|
||||
version: 1.0.1
|
||||
dependencies:
|
||||
@@ -180,7 +180,7 @@ b@^2:
|
||||
version: 2.0.0
|
||||
`;
|
||||
|
||||
const mockANewDedup = `${newHeader}
|
||||
const mockANewDedup = `${MODERN_HEADER}
|
||||
a@^1:
|
||||
version: 1.0.1
|
||||
dependencies:
|
||||
@@ -321,7 +321,7 @@ describe('New Lockfile', () => {
|
||||
});
|
||||
|
||||
describe('diff', () => {
|
||||
const lockfileLegacyA = Lockfile.parse(`${HEADER}
|
||||
const lockfileLegacyA = Lockfile.parse(`${LEGACY_HEADER}
|
||||
a@^1:
|
||||
version "1.0.1"
|
||||
resolved "https://my-registry/a-1.0.01.tgz#abc123"
|
||||
@@ -346,7 +346,7 @@ c@^1:
|
||||
integrity x
|
||||
`);
|
||||
|
||||
const lockfileLegacyB = Lockfile.parse(`${HEADER}
|
||||
const lockfileLegacyB = Lockfile.parse(`${LEGACY_HEADER}
|
||||
a@^1:
|
||||
version "1.0.1"
|
||||
resolved "https://my-registry/a-1.0.01.tgz#abc123"
|
||||
@@ -367,50 +367,50 @@ d@^1:
|
||||
integrity x
|
||||
`);
|
||||
|
||||
const lockfileModernA = Lockfile.parse(`${HEADER}
|
||||
"a@^1":
|
||||
version "1.0.1"
|
||||
resolved "https://my-registry/a-1.0.01.tgz#abc123"
|
||||
checksum sha512-xyz
|
||||
const lockfileModernA = Lockfile.parse(`${MODERN_HEADER}
|
||||
"a@npm:^1":
|
||||
version: "1.0.1"
|
||||
resolved: "https://my-registry/a-1.0.01.tgz#abc123"
|
||||
checksum: sha512-xyz
|
||||
dependencies:
|
||||
b "^2"
|
||||
b: "^2"
|
||||
|
||||
"b@3":
|
||||
version "3.0.1"
|
||||
checksum sha512-abc1
|
||||
"b@npm:3":
|
||||
version: "3.0.1"
|
||||
checksum: sha512-abc1
|
||||
|
||||
"b@2.0.x":
|
||||
version "2.0.1"
|
||||
checksum sha512-abc2
|
||||
"b@npm:2.0.x":
|
||||
version: "2.0.1"
|
||||
checksum: sha512-abc2
|
||||
|
||||
"b@^2":
|
||||
version "2.0.0"
|
||||
checksum sha512-abc3
|
||||
"b@npm:^2":
|
||||
version: "2.0.0"
|
||||
checksum: sha512-abc3
|
||||
|
||||
"c@^1":
|
||||
version "1.0.1"
|
||||
checksum x
|
||||
"c@npm:^1":
|
||||
version: "1.0.1"
|
||||
checksum: x
|
||||
`);
|
||||
|
||||
const lockfileModernB = Lockfile.parse(`${HEADER}
|
||||
"a@^1":
|
||||
version "1.0.1"
|
||||
resolution "a@npm:1.0.1"
|
||||
checksum sha512-xyz-other
|
||||
const lockfileModernB = Lockfile.parse(`${MODERN_HEADER}
|
||||
"a@npm:^1":
|
||||
version: "1.0.1"
|
||||
resolution: "a@npm:1.0.1"
|
||||
checksum: sha512-xyz-other
|
||||
dependencies:
|
||||
b "^2"
|
||||
b: "^2"
|
||||
|
||||
"b@2.0.x, b@^2":
|
||||
version "2.0.0"
|
||||
checksum sha512-abc3
|
||||
"b@npm:2.0.x, b@npm:^2":
|
||||
version: "2.0.0"
|
||||
checksum: sha512-abc3
|
||||
|
||||
"b@4":
|
||||
version "4.0.0"
|
||||
checksum sha512-abc
|
||||
"b@npm:4":
|
||||
version: "4.0.0"
|
||||
checksum: sha512-abc
|
||||
|
||||
"d@^1":
|
||||
version "1.0.1"
|
||||
checksum x
|
||||
"d@npm:^1":
|
||||
version: "1.0.1"
|
||||
checksum: x
|
||||
`);
|
||||
|
||||
it('should diff two legacy lockfiles', async () => {
|
||||
@@ -538,7 +538,7 @@ d@^1:
|
||||
});
|
||||
|
||||
it('should handle workspace ranges', async () => {
|
||||
const lockfile = `${HEADER}
|
||||
const lockfile = `${MODERN_HEADER}
|
||||
"@backstage/app-defaults@workspace:^, @backstage/app-defaults@workspace:packages/app-defaults":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/app-defaults@workspace:packages/app-defaults"
|
||||
|
||||
Reference in New Issue
Block a user