@budsbox/constraints 2.1.3 → 3.0.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/dist/cjs/dependencies/peer.d.ts +0 -19
- package/dist/cjs/dependencies/root.js +6 -0
- package/dist/cjs/esm.d.ts +20 -0
- package/dist/cjs/esm.js +20 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/utils.d.ts +4 -2
- package/dist/cjs/utils.js +2 -0
- package/package.json +28 -28
|
@@ -7,25 +7,6 @@ export interface PeerDependenciesConstraintOptions {
|
|
|
7
7
|
* Indicates whether private workspaces can have peer dependencies.
|
|
8
8
|
*/
|
|
9
9
|
readonly allowPrivates?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Specifies an optional list of glob patterns used to automatically
|
|
12
|
-
* identify and import peer dependencies.
|
|
13
|
-
*
|
|
14
|
-
* The property defines a set of patterns (e.g., 'package-name', 'module-name')
|
|
15
|
-
* that determine which peer dependencies should be automatically imported
|
|
16
|
-
* and managed by the dependency constraints. These patterns make it easier
|
|
17
|
-
* to include relevant peer dependencies without manual configuration.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // Example usage in configuration options:
|
|
21
|
-
* const options: PeerDependenciesConstraintOptions = {
|
|
22
|
-
* autoImportFrom: ['eslint-plugin-*', 'packages/*']
|
|
23
|
-
* };
|
|
24
|
-
*
|
|
25
|
-
* // Patterns like 'eslint-plugin-*' can match all peer dependencies
|
|
26
|
-
* // starting with 'eslint-plugin-' (e.g., `eslint-plugin-react`).
|
|
27
|
-
* @see {@link micromatch} for supported glob syntax.
|
|
28
|
-
*/
|
|
29
10
|
/**
|
|
30
11
|
* Glob patterns of direct dependencies whose `peerDependencies` should be
|
|
31
12
|
* propagated to the dependant workspace.
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.constraintRootDependencies = void 0;
|
|
4
4
|
const guards_1 = require("@budsbox/lib-es/guards");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const guards_2 = require("@budsbox/lib-es/guards");
|
|
6
7
|
/**
|
|
7
8
|
* A constraint function that enforces the consistency of dependencies among Yarn workspaces.
|
|
8
9
|
* It ensures that if a dependency exists with multiple version ranges across different workspaces,
|
|
@@ -16,6 +17,11 @@ const utils_1 = require("../utils");
|
|
|
16
17
|
*/
|
|
17
18
|
const constraintRootDependencies = ({ Yarn }) => {
|
|
18
19
|
const root = (0, utils_1.getRootWs)(Yarn);
|
|
20
|
+
for (const ws of Yarn.workspaces()) {
|
|
21
|
+
if (ws !== root && (0, guards_2.isNotNil)(ws.ident)) {
|
|
22
|
+
root.set(['dependencies', ws.ident], 'workspace:^');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
19
25
|
const dependencyRecords = Yarn.workspaces()
|
|
20
26
|
.filter((ws) => ws !== root)
|
|
21
27
|
.reduce((acc, workspace) => Yarn.dependencies({ workspace }).reduce((depAcc, { ident, range }) => ([
|
package/dist/cjs/esm.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import type { Constraint } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* A constraint function that ensures all workspaces have a proper `./package.json` export.
|
|
4
|
+
*
|
|
5
|
+
* This function iterates through all workspaces in the Yarn project and sets the
|
|
6
|
+
* `exports['./package.json']` field to `./package.json` in each workspace's manifest.
|
|
7
|
+
* This ensures that the `package.json` file can be resolved as a subpath export.
|
|
8
|
+
*
|
|
9
|
+
* @param options - The constraint options containing the Yarn instance.
|
|
10
|
+
*/
|
|
2
11
|
export declare const constraintExports: Constraint;
|
|
12
|
+
/**
|
|
13
|
+
* A constraint function that automatically generates `imports` based on `exports` in each workspace.
|
|
14
|
+
*
|
|
15
|
+
* For each workspace that defines `exports`, this function mirrors those exports in the `imports` field
|
|
16
|
+
* by replacing the `./` prefix with `#`. It skips the root export (`.`).
|
|
17
|
+
*
|
|
18
|
+
* This allows using the same paths for internal imports and external consumers while using the `#` prefix
|
|
19
|
+
* for better clarity and alignment with ESM standards.
|
|
20
|
+
*
|
|
21
|
+
* @param options - The constraint options containing the Yarn instance.
|
|
22
|
+
*/
|
|
3
23
|
export declare const constraintImports: Constraint;
|
|
4
24
|
//# sourceMappingURL=esm.d.ts.map
|
package/dist/cjs/esm.js
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.constraintImports = exports.constraintExports = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A constraint function that ensures all workspaces have a proper `./package.json` export.
|
|
6
|
+
*
|
|
7
|
+
* This function iterates through all workspaces in the Yarn project and sets the
|
|
8
|
+
* `exports['./package.json']` field to `./package.json` in each workspace's manifest.
|
|
9
|
+
* This ensures that the `package.json` file can be resolved as a subpath export.
|
|
10
|
+
*
|
|
11
|
+
* @param options - The constraint options containing the Yarn instance.
|
|
12
|
+
*/
|
|
4
13
|
const constraintExports = ({ Yarn }) => {
|
|
5
14
|
for (const workspace of Yarn.workspaces()) {
|
|
6
15
|
workspace.set(['exports', './package.json'], './package.json');
|
|
7
16
|
}
|
|
8
17
|
};
|
|
9
18
|
exports.constraintExports = constraintExports;
|
|
19
|
+
/**
|
|
20
|
+
* A constraint function that automatically generates `imports` based on `exports` in each workspace.
|
|
21
|
+
*
|
|
22
|
+
* For each workspace that defines `exports`, this function mirrors those exports in the `imports` field
|
|
23
|
+
* by replacing the `./` prefix with `#`. It skips the root export (`.`).
|
|
24
|
+
*
|
|
25
|
+
* This allows using the same paths for internal imports and external consumers while using the `#` prefix
|
|
26
|
+
* for better clarity and alignment with ESM standards.
|
|
27
|
+
*
|
|
28
|
+
* @param options - The constraint options containing the Yarn instance.
|
|
29
|
+
*/
|
|
10
30
|
const constraintImports = ({ Yarn }) => {
|
|
11
31
|
for (const workspace of Yarn.workspaces()) {
|
|
12
32
|
const { exports } = workspace.manifest;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { Constraint, ConstraintOptions } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runs a sequence of constraint functions in order.
|
|
4
|
+
*
|
|
5
|
+
* This utility function takes a set of constraint options and a list of constraint functions,
|
|
6
|
+
* then executes each constraint one after another. This is useful for organizing multiple
|
|
7
|
+
* constraints into a single execution pipeline.
|
|
8
|
+
*
|
|
9
|
+
* @param options - The common constraint options (containing the Yarn instance) to be passed to each constraint.
|
|
10
|
+
* @param constraints - A rest parameter containing the constraint functions to execute.
|
|
11
|
+
* @returns A promise that resolves when all constraints in the sequence have finished executing.
|
|
12
|
+
*/
|
|
2
13
|
export declare function runConstraintsSequence(options: ConstraintOptions, ...constraints: readonly Constraint[]): Promise<void>;
|
|
3
14
|
export { constraintPackageName, createManifestFieldsConstraint, } from './base.js';
|
|
4
15
|
export { constraintExports, constraintImports } from './esm.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWorkspaceDependenciesConstraint = exports.createPeerDependenciesConstraint = exports.constraintRootDependencies = exports.constraintImports = exports.constraintExports = exports.createManifestFieldsConstraint = exports.constraintPackageName = void 0;
|
|
4
4
|
exports.runConstraintsSequence = runConstraintsSequence;
|
|
5
|
+
/**
|
|
6
|
+
* Runs a sequence of constraint functions in order.
|
|
7
|
+
*
|
|
8
|
+
* This utility function takes a set of constraint options and a list of constraint functions,
|
|
9
|
+
* then executes each constraint one after another. This is useful for organizing multiple
|
|
10
|
+
* constraints into a single execution pipeline.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The common constraint options (containing the Yarn instance) to be passed to each constraint.
|
|
13
|
+
* @param constraints - A rest parameter containing the constraint functions to execute.
|
|
14
|
+
* @returns A promise that resolves when all constraints in the sequence have finished executing.
|
|
15
|
+
*/
|
|
5
16
|
async function runConstraintsSequence(options, ...constraints) {
|
|
6
17
|
for (const constraint of constraints) {
|
|
7
18
|
await constraint(options);
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -24,9 +24,9 @@ export type Constraint = (options: ConstraintOptions) => Awaitable<void>;
|
|
|
24
24
|
* - If `Options` is an empty object, the factory function can be called with or without the `options` parameter.
|
|
25
25
|
* - Otherwise, the `options` parameter is required when calling the factory function.
|
|
26
26
|
*
|
|
27
|
-
* @typeParam Options - The type of the option parameter used to configure the `Constraint`.
|
|
28
27
|
* @param options - An optional or required configuration object, depending on whether `Options` is an empty object or not.
|
|
29
28
|
* @returns A `Constraint` object configured based on the provided options.
|
|
29
|
+
* @typeParam Options - The type of the option parameter used to configure the `Constraint`.
|
|
30
30
|
*/
|
|
31
31
|
export type ConstraintFactory<Options extends object> = object extends Options ? (options?: Options) => Constraint : (options: Options) => Constraint;
|
|
32
32
|
/**
|
|
@@ -43,6 +43,8 @@ export declare function getRootWs(yarn: YarnNS.Constraints.Yarn): YarnNS.Constra
|
|
|
43
43
|
*
|
|
44
44
|
* @param workspace - The workspace whose manifest is to be retrieved.
|
|
45
45
|
* @returns The manifest of the provided workspace as an object of type T.
|
|
46
|
+
* @throws {@link Error} if the workspace manifest is null.
|
|
47
|
+
* @typeParam T - The type of the manifest object, defaults to PackageJson.
|
|
46
48
|
*/
|
|
47
49
|
export declare function getManifest<T extends object = PackageJson>(workspace: YarnNS.Constraints.Workspace): T;
|
|
48
50
|
/**
|
|
@@ -54,7 +56,7 @@ export declare function getManifest<T extends object = PackageJson>(workspace: Y
|
|
|
54
56
|
* @returns The dependency range considering the root workspace dependency if present,
|
|
55
57
|
* otherwise the original dependency range.
|
|
56
58
|
*/
|
|
57
|
-
export declare const getRangeConsideringRoot: (yarn: YarnNS.Constraints.Yarn, dependency: Readonly<Pick<YarnNS.Constraints.Dependency, "
|
|
59
|
+
export declare const getRangeConsideringRoot: (yarn: YarnNS.Constraints.Yarn, dependency: Readonly<Pick<YarnNS.Constraints.Dependency, "ident" | "range">>) => string;
|
|
58
60
|
/**
|
|
59
61
|
* Updates the version range of a dependency if it differs from the current range.
|
|
60
62
|
*
|
package/dist/cjs/utils.js
CHANGED
|
@@ -24,6 +24,8 @@ function getRootWs(yarn) {
|
|
|
24
24
|
*
|
|
25
25
|
* @param workspace - The workspace whose manifest is to be retrieved.
|
|
26
26
|
* @returns The manifest of the provided workspace as an object of type T.
|
|
27
|
+
* @throws {@link Error} if the workspace manifest is null.
|
|
28
|
+
* @typeParam T - The type of the manifest object, defaults to PackageJson.
|
|
27
29
|
*/
|
|
28
30
|
function getManifest(workspace) {
|
|
29
31
|
if (workspace.manifest == null) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budsbox/constraints",
|
|
3
|
-
"version": "
|
|
4
|
-
"homepage": "https://
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"homepage": "https://github.com/budsbox/seed",
|
|
5
5
|
"bugs": {
|
|
6
|
-
"url": "https://
|
|
6
|
+
"url": "https://github.com/budsbox/seed/issues"
|
|
7
7
|
},
|
|
8
|
-
"repository": "
|
|
8
|
+
"repository": "git@github.com:budsbox/seed.git",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"author": "Konstantin Kutsyllo <trikadin@pm.me>",
|
|
11
11
|
"type": "commonjs",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
"./package.json": "./package.json",
|
|
21
21
|
".": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"types": "./dist/cjs/index.d.ts",
|
|
23
|
+
"require": "./dist/cjs/index.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
@@ -33,37 +33,37 @@
|
|
|
33
33
|
"setup": "[ -f dist/dist.tsbuildinfo ] || run p:lib:setup"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@budsbox/lib-es": "^
|
|
37
|
-
"@types/micromatch": "^4.0.
|
|
36
|
+
"@budsbox/lib-es": "^3.0.0",
|
|
37
|
+
"@types/micromatch": "^4.0.10",
|
|
38
38
|
"@yarnpkg/types": "^4.0.1",
|
|
39
39
|
"micromatch": "^4.0.8",
|
|
40
|
-
"semver": "^7.7.
|
|
40
|
+
"semver": "^7.7.3",
|
|
41
41
|
"semver-intersect": "^1.5.0",
|
|
42
|
-
"type-fest": "^
|
|
42
|
+
"type-fest": "^5.3.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@budsbox/eslint": "^1.
|
|
46
|
-
"@budsbox/eslint_presets-node-lib": "^1.0.
|
|
47
|
-
"@budsbox/eslint_presets-tools": "^1.0.
|
|
48
|
-
"@budsbox/lib-types": "^1.
|
|
49
|
-
"@budsbox/tsconfigs": "^4.
|
|
50
|
-
"@budsbox/types": "^
|
|
51
|
-
"@eslint/js": "^9.
|
|
45
|
+
"@budsbox/eslint": "^1.3.0",
|
|
46
|
+
"@budsbox/eslint_presets-node-lib": "^1.0.5",
|
|
47
|
+
"@budsbox/eslint_presets-tools": "^1.0.5",
|
|
48
|
+
"@budsbox/lib-types": "^1.4.0",
|
|
49
|
+
"@budsbox/tsconfigs": "^4.4.0",
|
|
50
|
+
"@budsbox/types": "^3.0.0",
|
|
51
|
+
"@eslint/js": "^9.39.1",
|
|
52
52
|
"@types/eslint": "^9.6.1",
|
|
53
|
-
"@types/node": "^22.
|
|
54
|
-
"@types/semver": "^7",
|
|
55
|
-
"@typescript-eslint/parser": "^8.
|
|
56
|
-
"eslint": "^9.
|
|
57
|
-
"eslint-config-prettier": "^10.1.
|
|
58
|
-
"eslint-import-resolver-typescript": "^4.
|
|
59
|
-
"eslint-plugin-jsdoc": "^
|
|
53
|
+
"@types/node": "^22.19.1",
|
|
54
|
+
"@types/semver": "^7.7.1",
|
|
55
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
56
|
+
"eslint": "^9.39.1",
|
|
57
|
+
"eslint-config-prettier": "^10.1.8",
|
|
58
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
59
|
+
"eslint-plugin-jsdoc": "^61.5.0",
|
|
60
60
|
"eslint-plugin-react": "^7.37.5",
|
|
61
61
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
62
|
-
"eslint-plugin-react-refresh": "^0.4.
|
|
63
|
-
"globals": "^16.
|
|
62
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
63
|
+
"globals": "^16.5.0",
|
|
64
64
|
"tslib": "^2.8.1",
|
|
65
|
-
"typescript": "^5.
|
|
66
|
-
"typescript-eslint": "^8.
|
|
65
|
+
"typescript": "^5.9.3",
|
|
66
|
+
"typescript-eslint": "^8.48.1"
|
|
67
67
|
},
|
|
68
68
|
"packageManager": "yarn@4.9.2"
|
|
69
69
|
}
|