MCPcopy Create free account
hub / github.com/Snapchat/Valdi / syncPathsByLabel

Function syncPathsByLabel

npm_modules/cli/src/commands/projectsync.ts:135–172  ·  view source on GitHub ↗
(
  client: BazelClient,
  workspaceInfo: BazelWorkspaceInfo,
  pathsByLabel: Map<string, string[]>,
  projectSyncOutputs: readonly ProjectSyncOutput[],
)

Source from the content-addressed store, hash-verified

133}
134
135async function syncPathsByLabel(
136 client: BazelClient,
137 workspaceInfo: BazelWorkspaceInfo,
138 pathsByLabel: Map<string, string[]>,
139 projectSyncOutputs: readonly ProjectSyncOutput[],
140) {
141 for (const projectSyncOutput of projectSyncOutputs) {
142 const paths: string[] = [];
143 paths.push(bazelLabelToAbsolutePath(workspaceInfo, projectSyncOutput.target));
144
145 if (projectSyncOutput.tsGeneratedDir) {
146 paths.push(projectSyncOutput.tsGeneratedDir);
147 }
148
149 pathsByLabel.set(projectSyncOutput.target.toString(), paths);
150 }
151
152 // TODO(simon): Refactor projectsync bzl rule so that it recursively resolves
153 // all of these without us having to take care of it.
154 const missingLabels = new Map<string, BazelLabel>();
155
156 for (const projectSyncOutput of projectSyncOutputs) {
157 for (const dependency of projectSyncOutput.dependencies) {
158 const key = dependency.toString();
159 if (!pathsByLabel.has(key)) {
160 missingLabels.set(key, dependency);
161 }
162 }
163 }
164
165 if (missingLabels.size > 0) {
166 const targets = [...missingLabels.values()]
167 .sort((a, b) => a.toString().localeCompare(b.toString()))
168 .map(label => `${label.toBuildableString()}_projectsync`);
169 const newProjectSyncOutputs = await buildProjectSyncs(client, workspaceInfo.workspaceRoot, targets);
170 await syncPathsByLabel(client, workspaceInfo, pathsByLabel, newProjectSyncOutputs);
171 }
172}
173
174async function collectTsConfigDirs(
175 bazel: BazelClient,

Callers 1

collectTsConfigDirsFunction · 0.85

Calls 10

bazelLabelToAbsolutePathFunction · 0.85
buildProjectSyncsFunction · 0.85
valuesMethod · 0.80
toBuildableStringMethod · 0.80
setMethod · 0.65
toStringMethod · 0.65
hasMethod · 0.65
sortMethod · 0.65
pushMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected