@pnpm/workspace.workspace-manifest-reader 1100.1.8 → 1100.2.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @pnpm/workspace.read-manifest
2
2
 
3
+ ## 1100.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `findWorkspaceDirSync`, `findPackagesSync`, `findWorkspaceProjectsSync`, `findWorkspaceProjectsNoCheckSync`, `readWorkspaceManifestSync`, and `readExactProjectManifestSync`.
8
+
9
+ ### Patch Changes
10
+
11
+ - pnpm now treats a missing global `config.yaml`, `auth.ini`, or other optional config file as absent in Node.js-compatible runtimes such as StackBlitz WebContainers. Commands such as `pnpm --version` failed there with `ENOENT` [#14030](https://github.com/pnpm/pnpm/issues/14030).
12
+
13
+ - Updated dependencies:
14
+ - @pnpm/error@1100.2.0
15
+ - @pnpm/types@1102.1.1
16
+
17
+ ## 1100.1.9
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies:
22
+ - @pnpm/error@1100.1.4
23
+
3
24
  ## 1100.1.8
4
25
 
5
26
  ### Patch Changes
package/lib/index.d.ts CHANGED
@@ -17,4 +17,5 @@ export interface WorkspaceManifest extends PnpmSettings {
17
17
  catalogs?: WorkspaceNamedCatalogs;
18
18
  }
19
19
  export declare function readWorkspaceManifest(dir: string, cfgFileName?: ConfigFileName): Promise<WorkspaceManifest | undefined>;
20
+ export declare function readWorkspaceManifestSync(dir: string, cfgFileName?: ConfigFileName): WorkspaceManifest | undefined;
20
21
  export declare function validateWorkspaceManifest(manifest: unknown): asserts manifest is WorkspaceManifest | undefined;
package/lib/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import path from 'node:path';
2
- import util from 'node:util';
3
2
  import { WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants';
4
- import { readYamlFile } from 'read-yaml-file';
3
+ import { readYamlFile, readYamlFileSync } from 'read-yaml-file';
5
4
  import { assertValidWorkspaceManifestCatalog, assertValidWorkspaceManifestCatalogs, } from './catalogs.js';
6
5
  import { InvalidWorkspaceManifestError } from './errors/InvalidWorkspaceManifestError.js';
7
6
  import { assertValidWorkspaceManifestVersioning } from './versioning.js';
@@ -10,19 +9,40 @@ export async function readWorkspaceManifest(dir, cfgFileName = WORKSPACE_MANIFES
10
9
  validateWorkspaceManifest(manifest);
11
10
  return manifest;
12
11
  }
12
+ export function readWorkspaceManifestSync(dir, cfgFileName = WORKSPACE_MANIFEST_FILENAME) {
13
+ const manifest = readManifestRawSync(dir, cfgFileName);
14
+ validateWorkspaceManifest(manifest);
15
+ return manifest;
16
+ }
13
17
  async function readManifestRaw(dir, cfgFileName) {
14
18
  try {
15
19
  return await readYamlFile(path.join(dir, cfgFileName));
16
20
  }
17
21
  catch (err) {
18
22
  // File not exists is the same as empty file (undefined)
19
- if (util.types.isNativeError(err) && 'code' in err && err.code === 'ENOENT') {
23
+ if (isErrorWithCode(err, 'ENOENT')) {
20
24
  return undefined;
21
25
  }
22
26
  // Any other error (missing perm, invalid yaml, etc.) fails the process
23
27
  throw err;
24
28
  }
25
29
  }
30
+ function readManifestRawSync(dir, cfgFileName) {
31
+ try {
32
+ return readYamlFileSync(path.join(dir, cfgFileName));
33
+ }
34
+ catch (err) {
35
+ if (isErrorWithCode(err, 'ENOENT')) {
36
+ return undefined;
37
+ }
38
+ throw err;
39
+ }
40
+ }
41
+ // Some Node.js-compatible runtimes, such as StackBlitz WebContainers, throw fs
42
+ // errors that carry a code but are not native errors.
43
+ function isErrorWithCode(err, code) {
44
+ return err != null && typeof err === 'object' && 'code' in err && err.code === code;
45
+ }
26
46
  export function validateWorkspaceManifest(manifest) {
27
47
  if (manifest === undefined || manifest === null) {
28
48
  // Empty or null manifest is ok
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/workspace.workspace-manifest-reader",
3
- "version": "1100.1.8",
3
+ "version": "1100.2.0",
4
4
  "description": "Reads a workspace manifest file",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,13 +28,13 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@pnpm/constants": "1102.0.0",
31
- "@pnpm/error": "1100.1.3",
32
- "@pnpm/types": "1102.1.0",
31
+ "@pnpm/error": "1100.2.0",
32
+ "@pnpm/types": "1102.1.1",
33
33
  "read-yaml-file": "^3.0.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@jest/globals": "30.4.1",
37
- "@pnpm/workspace.workspace-manifest-reader": "1100.1.8"
37
+ "@pnpm/workspace.workspace-manifest-reader": "1100.2.0"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=22.13"