Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Update the changed format looks nicer in the github comment #3216

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/cli/src/cli/config/action.import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export class CommandImport extends CommandLineAction {
const styleUpdate = [];
for (const change of this.changes) {
if (mem.TileSet.is(change) && change.type === TileSetType.Vector) {
vectorUpdate.push(`## Vector data updates for ${change.id}`);
const id = ConfigId.unprefix(ConfigPrefix.TileSet, change.id);
for (const style of VectorStyles) {
vectorUpdate.push(
Expand All @@ -340,9 +341,11 @@ export class CommandImport extends CommandLineAction {
}
const existingTileSet = await cfg.TileSet.get(change.id);
const featureChanges = await diffVectorUpdate(change, existingTileSet);
vectorUpdate.push(featureChanges);
vectorUpdate.push(`## Feature updates for ${change.id}`);
vectorUpdate.push(...featureChanges);
}
if (mem.Style.is(change)) {
styleUpdate.push(`## Vector Style updated for ${change.id}`);
const style = ConfigId.unprefix(ConfigPrefix.Style, change.id);
styleUpdate.push(`* [${style}](${PublicUrlBase}?config=${this.config.value}&i=topographic&s=${style}&debug)\n`);
}
Expand Down
11 changes: 6 additions & 5 deletions packages/cli/src/cli/config/config.diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export function getVectorChanges(newLayer: StacLink | undefined, existingLayer:
/**
* Prepare and create pull request for the aerial tileset config
*/
export async function diffVectorUpdate(tileSet: ConfigTileSet, existingTileSet: ConfigTileSet | null): Promise<string> {
export async function diffVectorUpdate(
tileSet: ConfigTileSet,
existingTileSet: ConfigTileSet | null,
): Promise<string[]> {
// Vector layer only support for 3857 and only contain on layer inside
const changes: string[] = [];
const layer = tileSet.layers[0];
Expand All @@ -112,19 +115,17 @@ export async function diffVectorUpdate(tileSet: ConfigTileSet, existingTileSet:

// Log all the new inserts for new tileset
if (existingTileSet == null) {
changes.push(`New TileSet ts_${layer.name} with layer ${layer.name}.\n`);
for (const l of ldsLayers) {
const change = getVectorChanges(l, undefined);
if (change != null) changes.push(change);
}
return changes.join('\n');
return changes;
}

// Compare the different of existing tileset, we usually only have one layers in the vector tiles, so the loop won't fetch very much
for (const l of existingTileSet.layers) {
if (l[Epsg.Google.code] == null) continue;
if (l.name !== layer.name) continue;
changes.push(`Update for TileSet ${existingTileSet.id} layer ${layer.name}.`);
const existingCollectionPath = new URL('collection.json', l[Epsg.Google.code]);
const existingCollection = await fsa.readJson<StacCollection>(existingCollectionPath);
if (existingCollection == null) {
Expand Down Expand Up @@ -152,5 +153,5 @@ export async function diffVectorUpdate(tileSet: ConfigTileSet, existingTileSet:
}
}

return changes.join('\n');
return changes;
}
Loading