- Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathpackages.mts
43 lines (35 loc) · 1.21 KB
/
packages.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
importfastGlobfrom'fast-glob';
import{readFileSync}from'node:fs';
import{dirname}from'node:path';
exportinterfacePackageInfo{
name: string;
root: string;
experimental: boolean;
packageJson: Record<string,boolean|number|string|object>;
}
functiongetPackages(): PackageInfo[]{
constpackages: PackageInfo[]=[];
constmonorepoData=JSON.parse(readFileSync('./.monorepo.json','utf-8'));
for(constpkgoffastGlob.sync('./packages/*/*/package.json',{absolute: true})){
constpackageJson=JSON.parse(readFileSync(pkg,'utf-8'));
if(!(packageJson.nameinmonorepoData.packages)){
thrownewError(`${packageJson.name} does not exist in .monorepo.json`);
}
packages.push({
name: packageJson.name,
experimental: !!packageJson.experimental,
root: dirname(pkg),
packageJson,
});
}
returnpackages;
}
exportconstpackages=getPackages();
exportconstreleasePackages=packages.filter(({ packageJson })=>!packageJson.private);