MCPcopy Index your code
hub / github.com/larksuite/cli / PlanSync

Function PlanSync

internal/skillscheck/sync.go:197–246  ·  view source on GitHub ↗
(input SyncInput)

Source from the content-addressed store, hash-verified

195}
196
197func PlanSync(input SyncInput) SyncPlan {
198 official := uniqueSorted(input.OfficialSkills)
199 if input.Force {
200 return SyncPlan{
201 Version: input.Version,
202 OfficialSkills: official,
203 ToUpdate: official,
204 Added: []string{},
205 SkippedDeleted: []string{},
206 }
207 }
208
209 officialSet := toSet(official)
210 installedOfficial := intersection(input.LocalSkills, officialSet)
211
212 previousOfficial := []string{}
213 if input.StateReadable && input.PreviousState != nil {
214 previousOfficial = input.PreviousState.OfficialSkills
215 }
216 previousSet := toSet(previousOfficial)
217
218 newAddedOfficial := []string{}
219 for _, skill := range official {
220 if !previousSet[skill] {
221 newAddedOfficial = append(newAddedOfficial, skill)
222 }
223 }
224
225 updateSet := toSet(installedOfficial)
226 for _, skill := range newAddedOfficial {
227 updateSet[skill] = true
228 }
229 toUpdate := sortedKeys(updateSet)
230 updateSet = toSet(toUpdate)
231
232 skipped := []string{}
233 for _, skill := range official {
234 if !updateSet[skill] {
235 skipped = append(skipped, skill)
236 }
237 }
238
239 return SyncPlan{
240 Version: input.Version,
241 OfficialSkills: official,
242 ToUpdate: toUpdate,
243 Added: uniqueSorted(newAddedOfficial),
244 SkippedDeleted: skipped,
245 }
246}
247
248type SkillsRunner interface {
249 ListOfficialSkillsIndex() *selfupdate.NpmResult

Calls 4

toSetFunction · 0.85
intersectionFunction · 0.85
uniqueSortedFunction · 0.70
sortedKeysFunction · 0.70