@pnpm/workspace.workspace-manifest-reader 1100.1.9 → 1100.2.1

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,28 @@
1
1
  # @pnpm/workspace.read-manifest
2
2
 
3
+ ## 1100.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - A falsy non-array `packages` field in `pnpm-workspace.yaml`, such as `packages: false`, is now rejected with an error instead of being treated as omitted.
8
+
9
+ - Updated dependencies:
10
+ - @pnpm/error@1100.2.1
11
+
12
+ ## 1100.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - Added `findWorkspaceDirSync`, `findPackagesSync`, `findWorkspaceProjectsSync`, `findWorkspaceProjectsNoCheckSync`, `readWorkspaceManifestSync`, and `readExactProjectManifestSync`.
17
+
18
+ ### Patch Changes
19
+
20
+ - 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).
21
+
22
+ - Updated dependencies:
23
+ - @pnpm/error@1100.2.0
24
+ - @pnpm/types@1102.1.1
25
+
3
26
  ## 1100.1.9
4
27
 
5
28
  ### 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
@@ -45,7 +65,7 @@ export function validateWorkspaceManifest(manifest) {
45
65
  checkWorkspaceManifestAssignability(manifest);
46
66
  }
47
67
  function assertValidWorkspaceManifestPackages(manifest) {
48
- if (!manifest.packages) {
68
+ if (manifest.packages == null) {
49
69
  return;
50
70
  }
51
71
  if (!Array.isArray(manifest.packages)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/workspace.workspace-manifest-reader",
3
- "version": "1100.1.9",
3
+ "version": "1100.2.1",
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.4",
32
- "@pnpm/types": "1102.1.0",
31
+ "@pnpm/error": "1100.2.1",
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.9"
37
+ "@pnpm/workspace.workspace-manifest-reader": "1100.2.1"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=22.13"