mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-03 22:15:13 +01:00
* chore(repo): config cleanups and improvements (TS, Nx...) * fix connect e2e * chore: add eslin cache file to nx cache * chore: add stylelint cache file to nx * chore: add ts-node config for to base.tsconfig.json
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { A, D, pipe } from '@mobily/ts-belt';
|
|
import { execSync } from 'child_process';
|
|
|
|
type WorkspacePackageName = string;
|
|
type WorkspaceItem = {
|
|
location: string;
|
|
name: WorkspacePackageName;
|
|
workspaceDependencies: WorkspacePackageName[];
|
|
mismatchedWorkspaceDependencies: WorkspacePackageName[];
|
|
};
|
|
|
|
export const getWorkspacesList = (): Record<WorkspacePackageName, WorkspaceItem> => {
|
|
const rawList = execSync('yarn workspaces list --json --verbose')
|
|
.toString()
|
|
.replaceAll('}', '},');
|
|
const indexOfLastComma = rawList.lastIndexOf(',');
|
|
const validJsonString = `[ ${
|
|
rawList.slice(0, indexOfLastComma) + rawList.slice(indexOfLastComma + 1)
|
|
} ]`;
|
|
const workspaces = pipe(
|
|
JSON.parse(validJsonString),
|
|
(A.sortBy as any)((current: WorkspaceItem, next: WorkspaceItem) =>
|
|
current?.name > next?.name ? 1 : -1,
|
|
),
|
|
A.map((workspace: WorkspaceItem) => [workspace.name, workspace] as const),
|
|
D.fromPairs,
|
|
);
|
|
|
|
return workspaces;
|
|
};
|