Skip to content

Commit

Permalink
fix(lanes), improve lane-list description, fix lane-list --remote to …
Browse files Browse the repository at this point in the history
…not show current-lane (#8473)
  • Loading branch information
davidfirst authored Jan 30, 2024
1 parent b41df61 commit 8fb0283
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
7 changes: 4 additions & 3 deletions scopes/lanes/lanes/lane.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type LaneOptions = {

export class LaneListCmd implements Command {
name = 'list';
description = `list local lanes`;
description = `list local or remote lanes`;
alias = '';
options = [
['d', 'details', 'show more details on the state of each component in each lane'],
Expand Down Expand Up @@ -65,8 +65,9 @@ export class LaneListCmd implements Command {
const laneDataOfCurrentLane = currentLane ? lanes.find((l) => currentLane.isEqual(l.id)) : undefined;
const currentAlias = laneDataOfCurrentLane ? laneDataOfCurrentLane.alias : undefined;
const currentLaneReadmeComponentStr = outputReadmeComponent(laneDataOfCurrentLane?.readmeComponent);
let currentLaneStr = `current lane - ${chalk.green.green(laneIdStr(currentLane, currentAlias))}`;
currentLaneStr += currentLaneReadmeComponentStr;
let currentLaneStr = remote
? ''
: `current lane - ${chalk.green.green(laneIdStr(currentLane, currentAlias))}${currentLaneReadmeComponentStr}`;

if (details) {
const currentLaneComponents = laneDataOfCurrentLane ? outputComponents(laneDataOfCurrentLane.components) : '';
Expand Down
24 changes: 0 additions & 24 deletions src/scope/lanes/lanes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ export default class Lanes {
}

async listLanes(): Promise<Lane[]> {
return this.listLanesBackwardCompatible();

// @todo: remove the above after all the lanes are migrated to the new format (2022-06-01 will be a good time to do so)
return (await this.objects.listObjectsFromIndex(IndexType.lanes)) as Lane[];
}

Expand Down Expand Up @@ -224,27 +221,6 @@ export default class Lanes {

return lanes;
}

private async listLanesBackwardCompatible(): Promise<Lane[]> {
const lanes = (await this.objects.listObjectsFromIndex(IndexType.lanes)) as Lane[];
const oldLanes = lanes.filter((lane) => !lane.scope);
if (oldLanes.length) await this.fixOldLanesToIncludeScope(oldLanes);
return lanes;
}

private async fixOldLanesToIncludeScope(lanes: Lane[]) {
logger.warn(`lanes, fixOldLanesToIncludeScope: ${lanes.map((l) => l.id.toString()).join(', ')}`);
lanes.forEach((lane) => {
const trackLaneData = this.getRemoteTrackedDataByLocalLane(lane.name);
if (trackLaneData) {
lane.scope = trackLaneData.remoteScope;
} else {
lane.scope = this.scopeJson.name;
}
});
await this.objects.deleteObjectsFromFS(lanes.map((l) => l.hash()));
await this.objects.writeObjectsToTheFS(lanes);
}
}

export type LaneData = {
Expand Down

0 comments on commit 8fb0283

Please sign in to comment.