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

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,13 @@
1
1
  # @pnpm/workspace.read-manifest
2
2
 
3
+ ## 1100.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/constants@1102.0.1
9
+ - @pnpm/error@1100.2.2
10
+
3
11
  ## 1100.2.1
4
12
 
5
13
  ### Patch Changes
package/lib/catalogs.js CHANGED
@@ -26,19 +26,25 @@ export function assertValidWorkspaceManifestCatalogs(manifest) {
26
26
  throw new InvalidWorkspaceManifestError(`Expected catalogs field to be an object, but found - ${typeof manifest.catalogs}`);
27
27
  }
28
28
  for (const [catalogName, catalog] of Object.entries(manifest.catalogs)) {
29
- if (Array.isArray(catalog)) {
30
- throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - array`);
31
- }
32
- if (catalog === null) {
33
- throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - null`);
34
- }
35
- if (typeof catalog !== 'object') {
36
- throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - ${typeof catalog}`);
37
- }
38
- for (const [alias, specifier] of Object.entries(catalog)) {
39
- if (typeof specifier !== 'string') {
40
- throw new InvalidWorkspaceManifestError(`Catalog '${catalogName}' has invalid entry '${alias}'. Expected string specifier, but found: ${typeof specifier}`);
41
- }
29
+ assertValidNamedCatalog(catalogName, catalog);
30
+ }
31
+ }
32
+ function assertValidNamedCatalog(catalogName, catalog) {
33
+ if (Array.isArray(catalog)) {
34
+ throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - array`);
35
+ }
36
+ if (catalog === null) {
37
+ throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - null`);
38
+ }
39
+ if (typeof catalog !== 'object') {
40
+ throw new InvalidWorkspaceManifestError(`Expected named catalog ${catalogName} to be an object, but found - ${typeof catalog}`);
41
+ }
42
+ assertValidCatalogEntries(catalogName, catalog);
43
+ }
44
+ function assertValidCatalogEntries(catalogName, catalog) {
45
+ for (const [alias, specifier] of Object.entries(catalog)) {
46
+ if (typeof specifier !== 'string') {
47
+ throw new InvalidWorkspaceManifestError(`Catalog '${catalogName}' has invalid entry '${alias}'. Expected string specifier, but found: ${typeof specifier}`);
42
48
  }
43
49
  }
44
50
  }
package/lib/index.js CHANGED
@@ -83,9 +83,7 @@ function assertValidWorkspaceManifestPackages(manifest) {
83
83
  }
84
84
  /**
85
85
  * Empty function to ensure TypeScript has narrowed the manifest object to
86
- * something assignable to the {@see WorkspaceManifest} interface. This helps
87
- * make sure the validation logic in this file is correct as it's refactored in
88
- * the future.
86
+ * something assignable to the {@see WorkspaceManifest} interface.
89
87
  */
90
88
  function checkWorkspaceManifestAssignability(_manifest) { }
91
89
  //# sourceMappingURL=index.js.map
package/lib/versioning.js CHANGED
@@ -7,60 +7,81 @@ export function assertValidWorkspaceManifestVersioning(manifest) {
7
7
  }
8
8
  const versioning = assertPlainObject(manifest.versioning, 'versioning');
9
9
  if (versioning.fixed != null) {
10
- if (!Array.isArray(versioning.fixed)) {
11
- throw new InvalidWorkspaceManifestError(`Expected versioning.fixed to be an array of arrays, but found - ${typeof versioning.fixed}`);
12
- }
13
- for (const group of versioning.fixed) {
14
- if (!Array.isArray(group) || group.some((name) => typeof name !== 'string' || name === '')) {
15
- throw new InvalidWorkspaceManifestError('Expected every versioning.fixed group to be an array of package names');
16
- }
17
- }
10
+ validateFixedGroups(versioning.fixed);
18
11
  }
19
12
  if (versioning.epics != null) {
20
- if (!Array.isArray(versioning.epics)) {
21
- throw new InvalidWorkspaceManifestError(`Expected versioning.epics to be an array, but found - ${typeof versioning.epics}`);
22
- }
23
- for (const epic of versioning.epics) {
24
- const entry = assertPlainObject(epic, 'versioning.epics entry');
25
- if (typeof entry.lead !== 'string' || entry.lead === '') {
26
- throw new InvalidWorkspaceManifestError('Expected every versioning.epics entry to have a non-empty "lead" package reference');
27
- }
28
- if (!Array.isArray(entry.packages) || entry.packages.length === 0 || entry.packages.some((selector) => typeof selector !== 'string' || selector === '')) {
29
- throw new InvalidWorkspaceManifestError(`Expected versioning.epics entry for "${entry.lead}" to have a non-empty "packages" array of selector strings`);
30
- }
31
- }
13
+ validateEpics(versioning.epics);
32
14
  }
33
15
  if (versioning.ignore != null) {
34
- if (!Array.isArray(versioning.ignore) || versioning.ignore.some((name) => typeof name !== 'string' || name === '')) {
35
- throw new InvalidWorkspaceManifestError('Expected versioning.ignore to be an array of package names');
36
- }
16
+ validateIgnore(versioning.ignore);
37
17
  }
38
18
  if (versioning.maxBump != null) {
39
- if (!BUMP_TYPES.includes(versioning.maxBump)) {
40
- throw new InvalidWorkspaceManifestError(`Expected versioning.maxBump to be one of ${BUMP_TYPES.join(', ')}, but found - ${String(versioning.maxBump)}`);
41
- }
19
+ validateMaxBump(versioning.maxBump);
42
20
  }
43
21
  if (versioning.lanes != null) {
44
- const lanes = assertPlainObject(versioning.lanes, 'versioning.lanes');
45
- for (const [pkgName, lane] of Object.entries(lanes)) {
46
- if (typeof lane !== 'string' || lane === '') {
47
- throw new InvalidWorkspaceManifestError(`Expected versioning.lanes entry for ${pkgName} to be a non-empty lane name`);
48
- }
49
- if (lane.toLowerCase() === 'main') {
50
- throw new InvalidWorkspaceManifestError(`Invalid versioning.lanes entry for ${pkgName}: "main" is the reserved default lane. Remove the entry instead.`);
51
- }
52
- }
22
+ validateLanes(versioning.lanes);
53
23
  }
54
24
  if (versioning.changelog != null) {
55
- const changelog = assertPlainObject(versioning.changelog, 'versioning.changelog');
56
- if (changelog.format != null && typeof changelog.format !== 'string') {
57
- throw new InvalidWorkspaceManifestError(`Expected versioning.changelog.format to be a string, but found - ${typeof changelog.format}`);
25
+ validateChangelog(versioning.changelog);
26
+ }
27
+ }
28
+ function validateFixedGroups(fixed) {
29
+ if (!Array.isArray(fixed)) {
30
+ throw new InvalidWorkspaceManifestError(`Expected versioning.fixed to be an array of arrays, but found - ${typeof fixed}`);
31
+ }
32
+ for (const group of fixed) {
33
+ if (!Array.isArray(group) || group.some((name) => typeof name !== 'string' || name === '')) {
34
+ throw new InvalidWorkspaceManifestError('Expected every versioning.fixed group to be an array of package names');
35
+ }
36
+ }
37
+ }
38
+ function validateEpics(epics) {
39
+ if (!Array.isArray(epics)) {
40
+ throw new InvalidWorkspaceManifestError(`Expected versioning.epics to be an array, but found - ${typeof epics}`);
41
+ }
42
+ for (const epic of epics) {
43
+ validateEpicEntry(epic);
44
+ }
45
+ }
46
+ function validateEpicEntry(epic) {
47
+ const entry = assertPlainObject(epic, 'versioning.epics entry');
48
+ if (typeof entry.lead !== 'string' || entry.lead === '') {
49
+ throw new InvalidWorkspaceManifestError('Expected every versioning.epics entry to have a non-empty "lead" package reference');
50
+ }
51
+ if (!Array.isArray(entry.packages) || entry.packages.length === 0 || entry.packages.some((selector) => typeof selector !== 'string' || selector === '')) {
52
+ throw new InvalidWorkspaceManifestError(`Expected versioning.epics entry for "${entry.lead}" to have a non-empty "packages" array of selector strings`);
53
+ }
54
+ }
55
+ function validateIgnore(ignore) {
56
+ if (!Array.isArray(ignore) || ignore.some((name) => typeof name !== 'string' || name === '')) {
57
+ throw new InvalidWorkspaceManifestError('Expected versioning.ignore to be an array of package names');
58
+ }
59
+ }
60
+ function validateMaxBump(maxBump) {
61
+ if (!BUMP_TYPES.includes(maxBump)) {
62
+ throw new InvalidWorkspaceManifestError(`Expected versioning.maxBump to be one of ${BUMP_TYPES.join(', ')}, but found - ${String(maxBump)}`);
63
+ }
64
+ }
65
+ function validateLanes(lanesValue) {
66
+ const lanes = assertPlainObject(lanesValue, 'versioning.lanes');
67
+ for (const [pkgName, lane] of Object.entries(lanes)) {
68
+ if (typeof lane !== 'string' || lane === '') {
69
+ throw new InvalidWorkspaceManifestError(`Expected versioning.lanes entry for ${pkgName} to be a non-empty lane name`);
58
70
  }
59
- if (changelog.storage != null && !CHANGELOG_STORAGE_MODES.includes(changelog.storage)) {
60
- throw new InvalidWorkspaceManifestError(`Expected versioning.changelog.storage to be one of ${CHANGELOG_STORAGE_MODES.join(', ')}, but found - ${String(changelog.storage)}`);
71
+ if (lane.toLowerCase() === 'main') {
72
+ throw new InvalidWorkspaceManifestError(`Invalid versioning.lanes entry for ${pkgName}: "main" is the reserved default lane. Remove the entry instead.`);
61
73
  }
62
74
  }
63
75
  }
76
+ function validateChangelog(changelogValue) {
77
+ const changelog = assertPlainObject(changelogValue, 'versioning.changelog');
78
+ if (changelog.format != null && typeof changelog.format !== 'string') {
79
+ throw new InvalidWorkspaceManifestError(`Expected versioning.changelog.format to be a string, but found - ${typeof changelog.format}`);
80
+ }
81
+ if (changelog.storage != null && !CHANGELOG_STORAGE_MODES.includes(changelog.storage)) {
82
+ throw new InvalidWorkspaceManifestError(`Expected versioning.changelog.storage to be one of ${CHANGELOG_STORAGE_MODES.join(', ')}, but found - ${String(changelog.storage)}`);
83
+ }
84
+ }
64
85
  function assertPlainObject(value, fieldName) {
65
86
  if (Array.isArray(value)) {
66
87
  throw new InvalidWorkspaceManifestError(`Expected ${fieldName} field to be an object, but found - array`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/workspace.workspace-manifest-reader",
3
- "version": "1100.2.1",
3
+ "version": "1100.2.2",
4
4
  "description": "Reads a workspace manifest file",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -27,14 +27,14 @@
27
27
  "!*.map"
28
28
  ],
29
29
  "dependencies": {
30
- "@pnpm/constants": "1102.0.0",
31
- "@pnpm/error": "1100.2.1",
30
+ "@pnpm/constants": "1102.0.1",
31
+ "@pnpm/error": "1100.2.2",
32
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.2.1"
37
+ "@pnpm/workspace.workspace-manifest-reader": "1100.2.2"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=22.13"