@pnpm/workspace.workspace-manifest-reader 1100.1.1 → 1100.1.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 +11 -0
- package/lib/catalogs.d.ts +18 -0
- package/lib/catalogs.js +45 -0
- package/lib/errors/InvalidWorkspaceManifestError.d.ts +4 -0
- package/lib/errors/InvalidWorkspaceManifestError.js +7 -0
- package/lib/index.d.ts +20 -0
- package/lib/versioning.d.ts +7 -0
- package/lib/versioning.js +73 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @pnpm/workspace.read-manifest
|
|
2
2
|
|
|
3
|
+
## 1100.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Republished every package: the tarballs published by the v11.13.1 through v11.16.0 releases were missing most of their compiled files due to a packing bug [#13164](https://github.com/pnpm/pnpm/issues/13164).
|
|
8
|
+
|
|
9
|
+
- Updated dependencies:
|
|
10
|
+
- @pnpm/constants@1100.0.1
|
|
11
|
+
- @pnpm/error@1100.1.0
|
|
12
|
+
- @pnpm/types@1101.6.0
|
|
13
|
+
|
|
3
14
|
## 1100.1.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface WorkspaceNamedCatalogs {
|
|
2
|
+
[catalogName: string]: WorkspaceCatalog;
|
|
3
|
+
}
|
|
4
|
+
export interface WorkspaceCatalog {
|
|
5
|
+
[dependencyName: string]: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function assertValidWorkspaceManifestCatalog(manifest: {
|
|
8
|
+
packages?: readonly string[];
|
|
9
|
+
catalog?: unknown;
|
|
10
|
+
}): asserts manifest is {
|
|
11
|
+
catalog?: WorkspaceCatalog;
|
|
12
|
+
};
|
|
13
|
+
export declare function assertValidWorkspaceManifestCatalogs(manifest: {
|
|
14
|
+
packages?: readonly string[];
|
|
15
|
+
catalogs?: unknown;
|
|
16
|
+
}): asserts manifest is {
|
|
17
|
+
catalogs?: WorkspaceNamedCatalogs;
|
|
18
|
+
};
|
package/lib/catalogs.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { InvalidWorkspaceManifestError } from './errors/InvalidWorkspaceManifestError.js';
|
|
2
|
+
export function assertValidWorkspaceManifestCatalog(manifest) {
|
|
3
|
+
if (manifest.catalog == null) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
if (Array.isArray(manifest.catalog)) {
|
|
7
|
+
throw new InvalidWorkspaceManifestError('Expected catalog field to be an object, but found - array');
|
|
8
|
+
}
|
|
9
|
+
if (typeof manifest.catalog !== 'object') {
|
|
10
|
+
throw new InvalidWorkspaceManifestError(`Expected catalog field to be an object, but found - ${typeof manifest.catalog}`);
|
|
11
|
+
}
|
|
12
|
+
for (const [alias, specifier] of Object.entries(manifest.catalog)) {
|
|
13
|
+
if (typeof specifier !== 'string') {
|
|
14
|
+
throw new InvalidWorkspaceManifestError(`Invalid catalog entry for ${alias}. Expected string, but found: ${typeof specifier}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function assertValidWorkspaceManifestCatalogs(manifest) {
|
|
19
|
+
if (manifest.catalogs == null) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(manifest.catalogs)) {
|
|
23
|
+
throw new InvalidWorkspaceManifestError('Expected catalogs field to be an object, but found - array');
|
|
24
|
+
}
|
|
25
|
+
if (typeof manifest.catalogs !== 'object') {
|
|
26
|
+
throw new InvalidWorkspaceManifestError(`Expected catalogs field to be an object, but found - ${typeof manifest.catalogs}`);
|
|
27
|
+
}
|
|
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
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=catalogs.js.map
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type GLOBAL_CONFIG_YAML_FILENAME, WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants';
|
|
2
|
+
import type { PnpmSettings } from '@pnpm/types';
|
|
3
|
+
import { type WorkspaceCatalog, type WorkspaceNamedCatalogs } from './catalogs.js';
|
|
4
|
+
export type ConfigFileName = typeof GLOBAL_CONFIG_YAML_FILENAME | typeof WORKSPACE_MANIFEST_FILENAME;
|
|
5
|
+
export interface WorkspaceManifest extends PnpmSettings {
|
|
6
|
+
packages: string[];
|
|
7
|
+
/**
|
|
8
|
+
* The default catalog. Package manifests may refer to dependencies in this
|
|
9
|
+
* definition through the `catalog:default` specifier or the `catalog:`
|
|
10
|
+
* shorthand.
|
|
11
|
+
*/
|
|
12
|
+
catalog?: WorkspaceCatalog;
|
|
13
|
+
/**
|
|
14
|
+
* A dictionary of named catalogs. Package manifests may refer to dependencies
|
|
15
|
+
* in this definition through the `catalog:<name>` specifier.
|
|
16
|
+
*/
|
|
17
|
+
catalogs?: WorkspaceNamedCatalogs;
|
|
18
|
+
}
|
|
19
|
+
export declare function readWorkspaceManifest(dir: string, cfgFileName?: ConfigFileName): Promise<WorkspaceManifest | undefined>;
|
|
20
|
+
export declare function validateWorkspaceManifest(manifest: unknown): asserts manifest is WorkspaceManifest | undefined;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { InvalidWorkspaceManifestError } from './errors/InvalidWorkspaceManifestError.js';
|
|
2
|
+
const BUMP_TYPES = ['patch', 'minor', 'major'];
|
|
3
|
+
const CHANGELOG_STORAGE_MODES = ['registry', 'repository'];
|
|
4
|
+
export function assertValidWorkspaceManifestVersioning(manifest) {
|
|
5
|
+
if (manifest.versioning == null) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const versioning = assertPlainObject(manifest.versioning, 'versioning');
|
|
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
|
+
}
|
|
18
|
+
}
|
|
19
|
+
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
|
+
}
|
|
32
|
+
}
|
|
33
|
+
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
|
+
}
|
|
37
|
+
}
|
|
38
|
+
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
|
+
}
|
|
42
|
+
}
|
|
43
|
+
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
|
+
}
|
|
53
|
+
}
|
|
54
|
+
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}`);
|
|
58
|
+
}
|
|
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)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function assertPlainObject(value, fieldName) {
|
|
65
|
+
if (Array.isArray(value)) {
|
|
66
|
+
throw new InvalidWorkspaceManifestError(`Expected ${fieldName} field to be an object, but found - array`);
|
|
67
|
+
}
|
|
68
|
+
if (typeof value !== 'object' || value === null) {
|
|
69
|
+
throw new InvalidWorkspaceManifestError(`Expected ${fieldName} field to be an object, but found - ${value === null ? 'null' : typeof value}`);
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=versioning.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/workspace.workspace-manifest-reader",
|
|
3
|
-
"version": "1100.1.
|
|
3
|
+
"version": "1100.1.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": "1100.0.
|
|
31
|
-
"@pnpm/error": "1100.0
|
|
32
|
-
"@pnpm/types": "1101.
|
|
30
|
+
"@pnpm/constants": "1100.0.1",
|
|
31
|
+
"@pnpm/error": "1100.1.0",
|
|
32
|
+
"@pnpm/types": "1101.6.0",
|
|
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.
|
|
37
|
+
"@pnpm/workspace.workspace-manifest-reader": "1100.1.2"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=22.13"
|