pnpm-shrinkwrap
Advanced tools
Comparing version 3.3.3 to 3.4.0
@@ -1,3 +0,4 @@ | ||
export declare const SHRINKWRAP_FILENAME = "shrinkwrap.yaml"; | ||
export declare const PRIVATE_SHRINKWRAP_FILENAME: string; | ||
export declare const WANTED_SHRINKWRAP_FILENAME = "shrinkwrap.yaml"; | ||
export declare const CURRENT_SHRINKWRAP_FILENAME: string; | ||
export declare const SHRINKWRAP_VERSION = 3; | ||
export declare const SHRINKWRAP_MINOR_VERSION = 1; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path = require("path"); | ||
exports.SHRINKWRAP_FILENAME = 'shrinkwrap.yaml'; | ||
exports.PRIVATE_SHRINKWRAP_FILENAME = path.join('node_modules', '.shrinkwrap.yaml'); | ||
exports.WANTED_SHRINKWRAP_FILENAME = 'shrinkwrap.yaml'; | ||
exports.CURRENT_SHRINKWRAP_FILENAME = path.join('node_modules', '.shrinkwrap.yaml'); | ||
// Although .0 versions are supported, a bump to 3.1 would be a breaking change | ||
@@ -10,2 +10,4 @@ // because comver version support was added after releasing version 3. | ||
exports.SHRINKWRAP_VERSION = 3; | ||
// The minor version as a perate field should be deprecated from v4 | ||
exports.SHRINKWRAP_MINOR_VERSION = 1; | ||
//# sourceMappingURL=constants.js.map |
import { Shrinkwrap } from './types'; | ||
export declare function readPrivate(pkgPath: string, opts: { | ||
export declare const readPrivate: typeof readCurrent; | ||
export declare function readCurrent(pkgPath: string, opts: { | ||
ignoreIncompatible: boolean; | ||
}): Promise<Shrinkwrap | null>; | ||
export declare function read(pkgPath: string, opts: { | ||
export declare const read: typeof readWanted; | ||
export declare function readWanted(pkgPath: string, opts: { | ||
ignoreIncompatible: boolean; | ||
@@ -10,2 +12,3 @@ }): Promise<Shrinkwrap | null>; | ||
shrinkwrapVersion: number; | ||
shrinkwrapMinorVersion: number; | ||
specifiers: {}; | ||
@@ -12,0 +15,0 @@ dependencies: {}; |
@@ -28,16 +28,18 @@ "use strict"; | ||
} | ||
function readPrivate(pkgPath, opts) { | ||
exports.readPrivate = readCurrent; | ||
function readCurrent(pkgPath, opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const shrinkwrapPath = path.join(pkgPath, constants_1.PRIVATE_SHRINKWRAP_FILENAME); | ||
const shrinkwrapPath = path.join(pkgPath, constants_1.CURRENT_SHRINKWRAP_FILENAME); | ||
return yield _read(shrinkwrapPath, opts); | ||
}); | ||
} | ||
exports.readPrivate = readPrivate; | ||
function read(pkgPath, opts) { | ||
exports.readCurrent = readCurrent; | ||
exports.read = readWanted; | ||
function readWanted(pkgPath, opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const shrinkwrapPath = path.join(pkgPath, constants_1.SHRINKWRAP_FILENAME); | ||
const shrinkwrapPath = path.join(pkgPath, constants_1.WANTED_SHRINKWRAP_FILENAME); | ||
return yield _read(shrinkwrapPath, opts); | ||
}); | ||
} | ||
exports.read = read; | ||
exports.readWanted = readWanted; | ||
function _read(shrinkwrapPath, opts) { | ||
@@ -77,2 +79,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
shrinkwrapVersion: constants_2.SHRINKWRAP_VERSION, | ||
shrinkwrapMinorVersion: constants_2.SHRINKWRAP_MINOR_VERSION, | ||
specifiers: {}, | ||
@@ -79,0 +82,0 @@ dependencies: {}, |
export declare type Shrinkwrap = { | ||
shrinkwrapVersion: number; | ||
shrinkwrapMinorVersion?: number; | ||
specifiers: ResolvedDependencies; | ||
@@ -50,2 +51,14 @@ dependencies?: ResolvedDependencies; | ||
optionalDependencies?: ResolvedDependencies; | ||
peerDependencies?: { | ||
[name: string]: string; | ||
}; | ||
bundledDependencies?: { | ||
[name: string]: string; | ||
}; | ||
engines?: { | ||
node: string; | ||
}; | ||
os?: string[]; | ||
cpu?: string[]; | ||
deprecated?: string; | ||
}; | ||
@@ -52,0 +65,0 @@ export declare type Dependencies = { |
import { Shrinkwrap } from './types'; | ||
export default function write(pkgPath: string, shrinkwrap: Shrinkwrap, privateShrinkwrap: Shrinkwrap): Promise<[any, any]>; | ||
export default function write(pkgPath: string, wantedShrinkwrap: Shrinkwrap, currentShrinkwrap: Shrinkwrap): Promise<[any, any]>; |
@@ -17,20 +17,20 @@ "use strict"; | ||
}; | ||
function write(pkgPath, shrinkwrap, privateShrinkwrap) { | ||
const shrinkwrapPath = path.join(pkgPath, constants_1.SHRINKWRAP_FILENAME); | ||
const privateShrinkwrapPath = path.join(pkgPath, constants_1.PRIVATE_SHRINKWRAP_FILENAME); | ||
function write(pkgPath, wantedShrinkwrap, currentShrinkwrap) { | ||
const wantedShrinkwrapPath = path.join(pkgPath, constants_1.WANTED_SHRINKWRAP_FILENAME); | ||
const currentShrinkwrapPath = path.join(pkgPath, constants_1.CURRENT_SHRINKWRAP_FILENAME); | ||
// empty shrinkwrap is not saved | ||
if (Object.keys(shrinkwrap.specifiers).length === 0) { | ||
if (Object.keys(wantedShrinkwrap.specifiers).length === 0) { | ||
return Promise.all([ | ||
rimraf(shrinkwrapPath), | ||
rimraf(privateShrinkwrapPath), | ||
rimraf(wantedShrinkwrapPath), | ||
rimraf(currentShrinkwrapPath), | ||
]); | ||
} | ||
const yamlDoc = yaml.safeDump(shrinkwrap, SHRINKWRAP_YAML_FORMAT); | ||
const yamlDoc = yaml.safeDump(wantedShrinkwrap, SHRINKWRAP_YAML_FORMAT); | ||
// in most cases the `shrinkwrap.yaml` and `node_modules/.shrinkwrap.yaml` are equal | ||
// in those cases the YAML document can be stringified only once for both files | ||
// which is more efficient | ||
if (shrinkwrap === privateShrinkwrap) { | ||
if (wantedShrinkwrap === currentShrinkwrap) { | ||
return Promise.all([ | ||
writeFileAtomic(shrinkwrapPath, yamlDoc), | ||
mkdirp(path.dirname(privateShrinkwrapPath)).then(() => writeFileAtomic(privateShrinkwrapPath, yamlDoc)), | ||
writeFileAtomic(wantedShrinkwrapPath, yamlDoc), | ||
mkdirp(path.dirname(currentShrinkwrapPath)).then(() => writeFileAtomic(currentShrinkwrapPath, yamlDoc)), | ||
]); | ||
@@ -41,6 +41,6 @@ } | ||
'when the content of `node_modules` won\'t match what the `shrinkwrap.yaml` expects.'); | ||
const privateYamlDoc = yaml.safeDump(privateShrinkwrap, SHRINKWRAP_YAML_FORMAT); | ||
const currentYamlDoc = yaml.safeDump(currentShrinkwrap, SHRINKWRAP_YAML_FORMAT); | ||
return Promise.all([ | ||
writeFileAtomic(shrinkwrapPath, yamlDoc), | ||
mkdirp(path.dirname(privateShrinkwrapPath)).then(() => writeFileAtomic(privateShrinkwrapPath, privateYamlDoc)), | ||
writeFileAtomic(wantedShrinkwrapPath, yamlDoc), | ||
mkdirp(path.dirname(currentShrinkwrapPath)).then(() => writeFileAtomic(currentShrinkwrapPath, currentYamlDoc)), | ||
]); | ||
@@ -47,0 +47,0 @@ } |
{ | ||
"name": "pnpm-shrinkwrap", | ||
"version": "3.3.3", | ||
"version": "3.4.0", | ||
"description": "pnpm's shrinkwrap", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -19,6 +19,8 @@ # pnpm-shrinkwrap | ||
### `read(pkgPath, opts) => Promise<Shrinkwrap>` | ||
### `readWanted(pkgPath, opts) => Promise<Shrinkwrap>` | ||
Reads the public `shrinkwrap.yaml` file from the root of the package. | ||
Alias: `read` | ||
Reads the `shrinkwrap.yaml` file from the root of the package. | ||
#### Arguments | ||
@@ -30,10 +32,12 @@ | ||
### `readPrivate(pkgPath, opts) => Promise<Shrinkwrap>` | ||
### `readCurrent(pkgPath, opts) => Promise<Shrinkwrap>` | ||
Same as `read()` but for the private shrinkwrap file at `node_modules/.shrinkwrap.yaml`. | ||
Alias: `readPrivate` | ||
### `write(pkgPath, shrinkwrap, privateShrinkwrap) => Promise<void>` | ||
Reads the shrinkwrap file from `node_modules/.shrinkwrap.yaml`. | ||
Writes the public private shrinkwrap files. When they are empty, removes them. | ||
### `write(pkgPath, wantedShrinkwrap, currentShrinkwrap) => Promise<void>` | ||
Writes the wanted/current shrinkwrap files. When they are empty, removes them. | ||
### `prune(shrinkwrap, package) => Promise<Shrinkwrap>` | ||
@@ -40,0 +44,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28647
396
48