MCPcopy
hub / github.com/toeverything/AFFiNE / constructor

Method constructor

tools/utils/src/workspace.ts:53–88  ·  view source on GitHub ↗
(list: typeof PackageList = PackageList)

Source from the content-addressed store, hash-verified

51 }
52
53 constructor(list: typeof PackageList = PackageList) {
54 this.packageJson = readPackageJson(ProjectRoot);
55 const packages = new Map<string, Package>();
56
57 for (const meta of list) {
58 try {
59 const pkg = new Package(meta.name as PackageName, meta);
60 // @ts-expect-error internal api
61 pkg.workspace = this;
62 packages.set(meta.location, pkg);
63 } catch (e) {
64 this.logger.error(e as Error);
65 }
66 }
67
68 const building = new Set<string>();
69 try {
70 packages.forEach(pkg => this.buildDeps(pkg, packages, building));
71 } catch (e) {
72 if (e instanceof CircularDependenciesError) {
73 const inProcessPackages = Array.from(building);
74 console.log(inProcessPackages, e.currentName);
75 const circle = inProcessPackages
76 .slice(inProcessPackages.indexOf(e.currentName))
77 .concat(e.currentName);
78 this.logger.error(
79 `Circular dependencies found: \n ${circle.join(' -> ')}`
80 );
81 process.exit(1);
82 }
83
84 throw e;
85 }
86
87 this.packages = Array.from(packages.values());
88 }
89
90 tryGetPackage(name: PackageName) {
91 return this.packages.find(p => p.name === name);

Callers

nothing calls this directly

Calls 9

buildDepsMethod · 0.95
readPackageJsonFunction · 0.90
valuesMethod · 0.80
setMethod · 0.65
errorMethod · 0.45
forEachMethod · 0.45
fromMethod · 0.45
logMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected