@pnpm/lockfile.fs 1100.1.5 → 1100.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,3 @@
1
1
  export declare function getGitBranchLockfileNames(lockfileDir: string): Promise<string[]>;
2
+ export declare function getGitBranchLockfileNamesSync(lockfileDir: string): string[];
2
3
  export declare function cleanGitBranchLockfiles(lockfileDir: string): Promise<void>;
@@ -1,16 +1,22 @@
1
- import { promises as fs } from 'node:fs';
1
+ import fs, { promises as fsp } from 'node:fs';
2
2
  import path from 'node:path';
3
+ // Branch lockfiles are written as `pnpm-lock.<branch>.yaml` with literal
4
+ // dots and a non-empty branch segment. Escaping the dots keeps unrelated
5
+ // files out of the matches that feed scanning and `cleanGitBranchLockfiles`.
6
+ const GIT_BRANCH_LOCKFILE_NAME = /^pnpm-lock\..+\.yaml$/;
3
7
  export async function getGitBranchLockfileNames(lockfileDir) {
4
- const files = await fs.readdir(lockfileDir);
5
- // eslint-disable-next-line regexp/no-useless-non-capturing-group
6
- const gitBranchLockfileNames = files.filter(file => file.match(/^pnpm-lock.(?:.*).yaml$/));
7
- return gitBranchLockfileNames;
8
+ const files = await fsp.readdir(lockfileDir);
9
+ return files.filter(file => GIT_BRANCH_LOCKFILE_NAME.test(file));
10
+ }
11
+ export function getGitBranchLockfileNamesSync(lockfileDir) {
12
+ const files = fs.readdirSync(lockfileDir);
13
+ return files.filter(file => GIT_BRANCH_LOCKFILE_NAME.test(file));
8
14
  }
9
15
  export async function cleanGitBranchLockfiles(lockfileDir) {
10
16
  const gitBranchLockfiles = await getGitBranchLockfileNames(lockfileDir);
11
17
  await Promise.all(gitBranchLockfiles.map(async (file) => {
12
18
  const filepath = path.join(lockfileDir, file);
13
- await fs.unlink(filepath);
19
+ await fsp.unlink(filepath);
14
20
  }));
15
21
  }
16
22
  //# sourceMappingURL=gitBranchLockfile.js.map
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createEnvLockfile, readEnvLockfile, writeEnvLockfile } from './envLockfile.js';
2
2
  export { existsNonEmptyWantedLockfile } from './existsWantedLockfile.js';
3
3
  export { getLockfileImporterId } from './getLockfileImporterId.js';
4
- export { cleanGitBranchLockfiles } from './gitBranchLockfile.js';
4
+ export { cleanGitBranchLockfiles, getGitBranchLockfileNamesSync } from './gitBranchLockfile.js';
5
5
  export { convertToLockfileFile, convertToLockfileObject } from './lockfileFormatConverters.js';
6
6
  export { getWantedLockfileName } from './lockfileName.js';
7
7
  export * from './read.js';
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createEnvLockfile, readEnvLockfile, writeEnvLockfile } from './envLockfile.js';
2
2
  export { existsNonEmptyWantedLockfile } from './existsWantedLockfile.js';
3
3
  export { getLockfileImporterId } from './getLockfileImporterId.js';
4
- export { cleanGitBranchLockfiles } from './gitBranchLockfile.js';
4
+ export { cleanGitBranchLockfiles, getGitBranchLockfileNamesSync } from './gitBranchLockfile.js';
5
5
  export { convertToLockfileFile, convertToLockfileObject } from './lockfileFormatConverters.js';
6
6
  export { getWantedLockfileName } from './lockfileName.js';
7
7
  export * from './read.js';
@@ -1,5 +1,6 @@
1
1
  export interface GetWantedLockfileNameOptions {
2
2
  useGitBranchLockfile?: boolean;
3
3
  mergeGitBranchLockfiles?: boolean;
4
+ cwd?: string;
4
5
  }
5
6
  export declare function getWantedLockfileName(opts?: GetWantedLockfileNameOptions): Promise<string>;
@@ -1,8 +1,8 @@
1
1
  import { WANTED_LOCKFILE } from '@pnpm/constants';
2
2
  import { getCurrentBranch } from '@pnpm/network.git-utils';
3
- export async function getWantedLockfileName(opts = { useGitBranchLockfile: false, mergeGitBranchLockfiles: false }) {
3
+ export async function getWantedLockfileName(opts = {}) {
4
4
  if (opts.useGitBranchLockfile && !opts.mergeGitBranchLockfiles) {
5
- const currentBranchName = await getCurrentBranch();
5
+ const currentBranchName = await getCurrentBranch({ cwd: opts.cwd });
6
6
  if (currentBranchName) {
7
7
  return WANTED_LOCKFILE.replace('.yaml', `.${stringifyBranchName(currentBranchName)}.yaml`);
8
8
  }
package/lib/read.d.ts CHANGED
@@ -33,7 +33,7 @@ export declare function readWantedLockfileFile(pkgPath: string, opts: {
33
33
  useGitBranchLockfile?: boolean;
34
34
  mergeGitBranchLockfiles?: boolean;
35
35
  }): Promise<LockfileFile | null>;
36
- export declare function wantedLockfileHasMergeConflictsSync(pkgPath: string): boolean;
36
+ export declare function wantedLockfileHasMergeConflictsSync(pkgPath: string, lockfileName?: string): boolean;
37
37
  export declare function createLockfileObject(importerIds: ProjectId[], opts: {
38
38
  lockfileVersion: string;
39
39
  autoInstallPeers: boolean;
package/lib/read.js CHANGED
@@ -39,9 +39,9 @@ export async function readWantedLockfile(pkgPath, opts) {
39
39
  export async function readWantedLockfileFile(pkgPath, opts) {
40
40
  return (await _readWantedLockfile(pkgPath, opts)).lockfileFile;
41
41
  }
42
- export function wantedLockfileHasMergeConflictsSync(pkgPath) {
42
+ export function wantedLockfileHasMergeConflictsSync(pkgPath, lockfileName = WANTED_LOCKFILE) {
43
43
  try {
44
- const lockfileRawContent = stripBom(fs.readFileSync(path.join(pkgPath, WANTED_LOCKFILE), 'utf8'));
44
+ const lockfileRawContent = stripBom(fs.readFileSync(path.join(pkgPath, lockfileName), 'utf8'));
45
45
  return isDiff(extractMainDocument(lockfileRawContent));
46
46
  }
47
47
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/lockfile.fs",
3
- "version": "1100.1.5",
3
+ "version": "1100.1.6",
4
4
  "description": "Read/write pnpm-lock.yaml files",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -37,15 +37,15 @@
37
37
  "semver": "^7.8.4",
38
38
  "strip-bom": "^5.0.0",
39
39
  "write-file-atomic": "^7.0.1",
40
- "@pnpm/lockfile.utils": "1100.0.13",
41
40
  "@pnpm/lockfile.types": "1100.0.11",
42
41
  "@pnpm/lockfile.merger": "1100.0.11",
43
- "@pnpm/network.git-utils": "1100.0.1",
44
- "@pnpm/types": "1101.3.2",
42
+ "@pnpm/error": "1100.0.0",
43
+ "@pnpm/network.git-utils": "1100.0.2",
45
44
  "@pnpm/object.key-sorting": "1100.0.1",
45
+ "@pnpm/types": "1101.3.2",
46
+ "@pnpm/lockfile.utils": "1100.0.13",
46
47
  "@pnpm/deps.path": "1100.0.8",
47
- "@pnpm/constants": "1100.0.0",
48
- "@pnpm/error": "1100.0.0"
48
+ "@pnpm/constants": "1100.0.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@pnpm/logger": "^1100.0.0"
@@ -60,8 +60,8 @@
60
60
  "tempy": "3.0.0",
61
61
  "write-yaml-file": "^6.0.0",
62
62
  "yaml-tag": "1.1.0",
63
- "@pnpm/logger": "1100.0.0",
64
- "@pnpm/lockfile.fs": "1100.1.5"
63
+ "@pnpm/lockfile.fs": "1100.1.6",
64
+ "@pnpm/logger": "1100.0.0"
65
65
  },
66
66
  "engines": {
67
67
  "node": ">=22.13"