Skip to content

Commit

Permalink
refactor: Remove dead code (#804)
Browse files Browse the repository at this point in the history
#### Motivation

Cleans up miscellaneous issues found by JetBrains IDEA.

#### Modification

- Remove unreferenced example code
- Remove unused variables, types, classes
- Import type rather than relying on UMD global variable
- Wait for writes to finish

#### Checklist

None of these are applicable. This is just a cleanup.

- [ ] Tests updated
- [ ] Docs updated
- [ ] Issue linked in Title
  • Loading branch information
l0b0 authored Jan 7, 2024
1 parent 0cdb351 commit 8923fce
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 79 deletions.
6 changes: 4 additions & 2 deletions src/commands/basemaps-mapsheet/create-mapsheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const basemapsCreateMapSheet = command({
const mem = ConfigProviderMemory.fromJson(configJson);

const rest = fgb.deserialize(buf) as FeatureCollection;
fsa.write('features.json', JSON.stringify(rest));
const featuresWritePromise = fsa.write('features.json', JSON.stringify(rest));

const aerial = await mem.TileSet.get('ts_aerial');
if (aerial == null) throw new Error('Invalid config file.');
Expand All @@ -95,7 +95,9 @@ export const basemapsCreateMapSheet = command({
const outputs = await createMapSheet(aerial, mem, rest, include, exclude);

logger.info({ outputPath }, 'MapSheet:WriteOutput');
fsa.write(outputPath, JSON.stringify(outputs, null, 2));
const outputWritePromise = fsa.write(outputPath, JSON.stringify(outputs, null, 2));

await Promise.all([featuresWritePromise, outputWritePromise]);
},
});

Expand Down
4 changes: 1 addition & 3 deletions src/commands/format/pretty.print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ export async function formatFile(path: string, target = ''): Promise<void> {
* @returns the stringify JSON pretty printed
*/
export async function prettyPrint(jsonStr: string, config: prettier.Options): Promise<string> {
const formatted = await prettier.format(jsonStr, {
return await prettier.format(jsonStr, {
...config,
parser: 'json',
});

return formatted;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { before, beforeEach, describe, it } from 'node:test';

import { fsa } from '@chunkd/fs';
import { FsMemory } from '@chunkd/source-memory';
import { FeatureCollection } from 'geojson';

import { MapSheet } from '../../../utils/mapsheet.js';
import {
Expand Down Expand Up @@ -115,7 +116,7 @@ describe('validate', () => {
assert.equal(stub.mock.callCount(), 1);
assert.deepEqual(stub.mock.calls[0]?.arguments[0], ['s3://test']);

const outputFileList: GeoJSON.FeatureCollection = await fsa.readJson('/tmp/tile-index-validate/output.geojson');
const outputFileList: FeatureCollection = await fsa.readJson('/tmp/tile-index-validate/output.geojson');
assert.equal(outputFileList.features.length, 1);
const firstFeature = outputFileList.features[0];
assert.equal(firstFeature?.properties?.['tileName'], 'AS21_1000_0101');
Expand Down
4 changes: 0 additions & 4 deletions src/commands/tileindex-validate/tileindex.validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ export const TiffLoader = {
},
};

export interface FileList {
tileName: string;
uris: string[];
}
/**
* Validate list of tiffs match a LINZ Mapsheet tile index
*
Expand Down
13 changes: 0 additions & 13 deletions src/direct/README.md

This file was deleted.

47 changes: 0 additions & 47 deletions src/direct/copy.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/utils/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type Actions = ActionCopy;

export interface ActionCopy {
action: 'copy';
parameters: {
Expand Down
7 changes: 0 additions & 7 deletions src/utils/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import { Api } from '@octokit/plugin-rest-endpoint-methods/dist-types/types.js';

import { logger } from '../log.js';

export interface Job {
imagery: string;
tileMatrix: string;
content: string;
}

export interface Blob {
path: string;
mode: '100644';
Expand All @@ -34,7 +28,6 @@ export class GithubApi {
}

isOk = (s: number): boolean => s >= 200 && s <= 299;
isNotFound = (s: number): boolean => s === 404;
toRef = (branch: string): string => `heads/${branch}`;

/**
Expand Down

0 comments on commit 8923fce

Please sign in to comment.