@crossplatformai/dependency-graph 0.9.3 → 0.10.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/README.md +36 -22
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/pr-preview.d.ts +3 -0
- package/dist/cli/pr-preview.d.ts.map +1 -0
- package/dist/cli/validate-workflows.d.ts +3 -0
- package/dist/cli/validate-workflows.d.ts.map +1 -0
- package/dist/graph/analysis.d.ts +6 -0
- package/dist/graph/analysis.d.ts.map +1 -0
- package/dist/graph/builder.d.ts +3 -0
- package/dist/graph/builder.d.ts.map +1 -0
- package/dist/graph/traversal.d.ts +5 -0
- package/dist/graph/traversal.d.ts.map +1 -0
- package/dist/graph/types.d.ts +47 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/index-cli.js +1094 -0
- package/dist/index-cli.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +738 -0
- package/dist/index.js.map +1 -0
- package/dist/types/clients.d.ts +15 -0
- package/dist/types/clients.d.ts.map +1 -0
- package/dist/workflow/discovery.d.ts +4 -0
- package/dist/workflow/discovery.d.ts.map +1 -0
- package/dist/workflow/expected-paths.d.ts +13 -0
- package/dist/workflow/expected-paths.d.ts.map +1 -0
- package/dist/workflow/parser.d.ts +3 -0
- package/dist/workflow/parser.d.ts.map +1 -0
- package/dist/workflow/policy.d.ts +3 -0
- package/dist/workflow/policy.d.ts.map +1 -0
- package/dist/workflow/types.d.ts +34 -0
- package/dist/workflow/types.d.ts.map +1 -0
- package/dist/workflow/validator.d.ts +3 -0
- package/dist/workflow/validator.d.ts.map +1 -0
- package/dist/workspace/discovery.d.ts +12 -0
- package/dist/workspace/discovery.d.ts.map +1 -0
- package/dist/workspace/file-mapping.d.ts +4 -0
- package/dist/workspace/file-mapping.d.ts.map +1 -0
- package/dist/workspace/package-map.d.ts +12 -0
- package/dist/workspace/package-map.d.ts.map +1 -0
- package/package.json +49 -45
- package/src/cli/pr-preview.ts +0 -388
- package/src/cli/validate-workflows.ts +0 -847
- package/src/graph/analysis.ts +0 -147
- package/src/graph/builder.ts +0 -52
- package/src/graph/traversal.ts +0 -132
- package/src/graph/types.ts +0 -50
- package/src/index.test.ts +0 -94
- package/src/index.ts +0 -40
- package/src/types/clients.ts +0 -19
- package/src/workspace/discovery.ts +0 -94
- package/src/workspace/file-mapping.ts +0 -35
package/README.md
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @crossplatformai/dependency-graph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Workspace dependency graph tooling for CrossPlatform.ai projects.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package provides workspace discovery, graph building, traversal, and analysis utilities for developer tooling, CI, release workflows, and repository maintenance.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Package Role
|
|
8
|
+
|
|
9
|
+
`@crossplatformai/dependency-graph` belongs in the developer tooling layer.
|
|
10
|
+
|
|
11
|
+
It is intended for:
|
|
12
|
+
|
|
13
|
+
- workspace analysis
|
|
14
|
+
- affected package detection
|
|
15
|
+
- release and CI automation
|
|
16
|
+
- dependency health checks
|
|
17
|
+
- repository tooling
|
|
18
|
+
|
|
19
|
+
It is not an app runtime capability.
|
|
8
20
|
|
|
9
21
|
## Installation
|
|
10
22
|
|
|
11
23
|
```bash
|
|
12
|
-
pnpm add @
|
|
24
|
+
pnpm add @crossplatformai/dependency-graph
|
|
13
25
|
```
|
|
14
26
|
|
|
15
27
|
## Usage
|
|
@@ -17,7 +29,7 @@ pnpm add @repo/dependency-graph
|
|
|
17
29
|
### Discovering Workspaces
|
|
18
30
|
|
|
19
31
|
```typescript
|
|
20
|
-
import { discoverWorkspaces } from '@
|
|
32
|
+
import { discoverWorkspaces } from '@crossplatformai/dependency-graph';
|
|
21
33
|
import { readFile } from 'node:fs/promises';
|
|
22
34
|
import { glob } from 'glob';
|
|
23
35
|
import { parse } from 'yaml';
|
|
@@ -46,7 +58,7 @@ const packages = await discoverWorkspaces(process.cwd(), {
|
|
|
46
58
|
### Building Dependency Graph
|
|
47
59
|
|
|
48
60
|
```typescript
|
|
49
|
-
import { buildDependencyGraph } from '@
|
|
61
|
+
import { buildDependencyGraph } from '@crossplatformai/dependency-graph';
|
|
50
62
|
|
|
51
63
|
const graph = buildDependencyGraph(packages);
|
|
52
64
|
```
|
|
@@ -54,19 +66,17 @@ const graph = buildDependencyGraph(packages);
|
|
|
54
66
|
### Finding Affected Packages
|
|
55
67
|
|
|
56
68
|
```typescript
|
|
57
|
-
import { findAffectedPackages } from '@
|
|
69
|
+
import { findAffectedPackages } from '@crossplatformai/dependency-graph';
|
|
58
70
|
|
|
59
|
-
const affected = findAffectedPackages(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{ includeSelf: true }
|
|
63
|
-
);
|
|
71
|
+
const affected = findAffectedPackages(graph, 'my-package', {
|
|
72
|
+
includeSelf: true,
|
|
73
|
+
});
|
|
64
74
|
```
|
|
65
75
|
|
|
66
76
|
### Detecting Cycles
|
|
67
77
|
|
|
68
78
|
```typescript
|
|
69
|
-
import { detectCycles } from '@
|
|
79
|
+
import { detectCycles } from '@crossplatformai/dependency-graph';
|
|
70
80
|
|
|
71
81
|
const cycles = detectCycles(graph);
|
|
72
82
|
if (cycles.length > 0) {
|
|
@@ -77,7 +87,7 @@ if (cycles.length > 0) {
|
|
|
77
87
|
### Mapping Files to Packages
|
|
78
88
|
|
|
79
89
|
```typescript
|
|
80
|
-
import { mapFilesToPackages } from '@
|
|
90
|
+
import { mapFilesToPackages } from '@crossplatformai/dependency-graph';
|
|
81
91
|
|
|
82
92
|
const changedFiles = ['apps/web/src/index.ts', 'packages/ui/src/button.tsx'];
|
|
83
93
|
const fileMap = mapFilesToPackages(changedFiles, packages);
|
|
@@ -131,10 +141,10 @@ console.log(fileMap);
|
|
|
131
141
|
|
|
132
142
|
## Dependency Injection Pattern
|
|
133
143
|
|
|
134
|
-
This
|
|
144
|
+
This package accepts clients supplied by the calling tool or script:
|
|
135
145
|
|
|
136
146
|
```typescript
|
|
137
|
-
import type { WorkspaceDiscoveryConfig } from '@
|
|
147
|
+
import type { WorkspaceDiscoveryConfig } from '@crossplatformai/dependency-graph';
|
|
138
148
|
import { readFile } from 'node:fs/promises';
|
|
139
149
|
import { glob } from 'glob';
|
|
140
150
|
import { parse as parseYaml } from 'yaml';
|
|
@@ -192,12 +202,16 @@ mockConfig.yaml.parse.mockReturnValue({ packages: ['apps/*', 'packages/*'] });
|
|
|
192
202
|
const packages = await discoverWorkspaces('/fake/root', mockConfig);
|
|
193
203
|
```
|
|
194
204
|
|
|
195
|
-
##
|
|
205
|
+
## Design Approach
|
|
206
|
+
|
|
207
|
+
This package prefers host-provided implementations for filesystem, globbing, and YAML parsing when flexibility matters.
|
|
208
|
+
|
|
209
|
+
That keeps the graph logic:
|
|
196
210
|
|
|
197
|
-
-
|
|
198
|
-
-
|
|
199
|
-
-
|
|
200
|
-
-
|
|
211
|
+
- testable
|
|
212
|
+
- environment-agnostic
|
|
213
|
+
- reusable across scripts and CI contexts
|
|
214
|
+
- decoupled from any one file access strategy
|
|
201
215
|
|
|
202
216
|
## License
|
|
203
217
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr-preview.d.ts","sourceRoot":"","sources":["../../src/cli/pr-preview.ts"],"names":[],"mappings":";AAoLA,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CA6MlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-workflows.d.ts","sourceRoot":"","sources":["../../src/cli/validate-workflows.ts"],"names":[],"mappings":";AA4NA,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAgE1D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DependencyGraph, GraphStats } from './types';
|
|
2
|
+
export declare function analyzeGraph(graph: DependencyGraph): GraphStats;
|
|
3
|
+
export declare function detectCycles(graph: DependencyGraph): string[][];
|
|
4
|
+
export declare function getTransitiveDependencies(pkgName: string, graph: DependencyGraph): Set<string>;
|
|
5
|
+
export declare function getTransitiveDependents(pkgName: string, graph: DependencyGraph): Set<string>;
|
|
6
|
+
//# sourceMappingURL=analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../src/graph/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU,CA6B/D;AAqCD,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,EAAE,EAAE,CAkC/D;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,eAAe,GACrB,GAAG,CAAC,MAAM,CAAC,CAiBb;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,eAAe,GACrB,GAAG,CAAC,MAAM,CAAC,CAiBb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/graph/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjE,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,eAAe,CA8BjB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DependencyGraph, TraversalOptions } from './types';
|
|
2
|
+
export declare function findAffectedPackages(startingPackages: Set<string>, graph: DependencyGraph, options?: TraversalOptions): Set<string>;
|
|
3
|
+
export declare function findDependencyPath(from: string, to: string, graph: DependencyGraph): string[] | null;
|
|
4
|
+
export declare function findAllPaths(from: string, to: string, graph: DependencyGraph, maxPaths?: number): string[][];
|
|
5
|
+
//# sourceMappingURL=traversal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../../src/graph/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEjE,wBAAgB,oBAAoB,CAClC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC7B,KAAK,EAAE,eAAe,EACtB,OAAO,GAAE,gBAAqB,GAC7B,GAAG,CAAC,MAAM,CAAC,CA6Db;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,eAAe,GACrB,MAAM,EAAE,GAAG,IAAI,CA0BjB;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,eAAe,EACtB,QAAQ,SAAK,GACZ,MAAM,EAAE,EAAE,CAyBZ"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface PackageJson {
|
|
2
|
+
name: string;
|
|
3
|
+
version?: string;
|
|
4
|
+
dependencies?: Record<string, string>;
|
|
5
|
+
devDependencies?: Record<string, string>;
|
|
6
|
+
release?: {
|
|
7
|
+
type?: string;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
affectsUpstream?: boolean;
|
|
10
|
+
platform?: string;
|
|
11
|
+
service?: string;
|
|
12
|
+
workflow?: string;
|
|
13
|
+
versioned?: {
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
strategy?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface WorkspacePackage {
|
|
21
|
+
name: string;
|
|
22
|
+
version: string;
|
|
23
|
+
path: string;
|
|
24
|
+
packageJson: PackageJson;
|
|
25
|
+
dependencies: Record<string, string>;
|
|
26
|
+
devDependencies: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface DependencyGraph {
|
|
29
|
+
packages: Map<string, WorkspacePackage>;
|
|
30
|
+
dependsOn: Map<string, Set<string>>;
|
|
31
|
+
dependedBy: Map<string, Set<string>>;
|
|
32
|
+
}
|
|
33
|
+
export interface TraversalOptions {
|
|
34
|
+
direction?: 'upstream' | 'downstream' | 'both';
|
|
35
|
+
maxDepth?: number;
|
|
36
|
+
filter?: (pkg: WorkspacePackage) => boolean;
|
|
37
|
+
respectAffectsUpstream?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface GraphStats {
|
|
40
|
+
totalPackages: number;
|
|
41
|
+
totalEdges: number;
|
|
42
|
+
maxDepth: number;
|
|
43
|
+
leafNodes: string[];
|
|
44
|
+
rootNodes: string[];
|
|
45
|
+
cycles: string[][];
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/graph/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAA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