@basemaps/cli 6.20.0 → 6.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,59 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.22.1](https://github.com/linz/basemaps/compare/v6.22.0...v6.22.1) (2022-03-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cli:** allow unicode job names ([#2126](https://github.com/linz/basemaps/issues/2126)) ([bab5cef](https://github.com/linz/basemaps/commit/bab5cefdc8365cb52bf687230a078ea599c359ce))
12
+
13
+
14
+
15
+
16
+
17
+ # [6.22.0](https://github.com/linz/basemaps/compare/v6.21.1...v6.22.0) (2022-03-20)
18
+
19
+
20
+ ### Features
21
+
22
+ * **cli:** support multiple invalidations for cloudfront ([#2120](https://github.com/linz/basemaps/issues/2120)) ([764fdeb](https://github.com/linz/basemaps/commit/764fdebaf7624c7761cede3a24c2184105bff9e2))
23
+
24
+
25
+
26
+
27
+
28
+ ## [6.21.1](https://github.com/linz/basemaps/compare/v6.21.0...v6.21.1) (2022-03-17)
29
+
30
+ **Note:** Version bump only for package @basemaps/cli
31
+
32
+
33
+
34
+
35
+
36
+ # [6.21.0](https://github.com/linz/basemaps/compare/v6.20.0...v6.21.0) (2022-03-17)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * **config:** fetch all unprocessed keys from dynamo if there are any ([#2101](https://github.com/linz/basemaps/issues/2101)) ([731430e](https://github.com/linz/basemaps/commit/731430e73756f05b2684f5b7ae7bd2852bc0a9b5))
42
+
43
+
44
+ ### Features
45
+
46
+ * **cli:** remove unused config cli this has been moved into linz/basemaps-config ([#2102](https://github.com/linz/basemaps/issues/2102)) ([b047e11](https://github.com/linz/basemaps/commit/b047e111a9be2b200d5812d2d32fc6df7fdf4c2a))
47
+
48
+
49
+ ### Reverts
50
+
51
+ * Revert "release: v6.21.0 (#2104)" (#2111) ([d07f8ab](https://github.com/linz/basemaps/commit/d07f8ab4037466b060bf7e83960737554ff064b4)), closes [#2104](https://github.com/linz/basemaps/issues/2104) [#2111](https://github.com/linz/basemaps/issues/2111)
52
+ * Revert "release: v6.22.0 (#2108)" (#2110) ([abcd2e4](https://github.com/linz/basemaps/commit/abcd2e4732a6d606eed865f526d6df2e4617aad3)), closes [#2108](https://github.com/linz/basemaps/issues/2108) [#2110](https://github.com/linz/basemaps/issues/2110)
53
+ * Revert "release: v6.21.0 (#2104)" (#2107) ([2c7e7f6](https://github.com/linz/basemaps/commit/2c7e7f6686a293995abdeb9604413808f2208bd6)), closes [#2104](https://github.com/linz/basemaps/issues/2104) [#2107](https://github.com/linz/basemaps/issues/2107)
54
+
55
+
56
+
57
+
58
+
6
59
  # [6.20.0](https://github.com/linz/basemaps/compare/v6.19.0...v6.20.0) (2022-02-01)
7
60
 
8
61
 
@@ -1,5 +1,5 @@
1
1
  import o from 'ospec';
2
- import { extractResolutionFromName } from '../action.batch.js';
2
+ import { ActionBatchJob, extractResolutionFromName } from '../action.batch.js';
3
3
  o.spec('action.batch', () => {
4
4
  o('extractResolutionFromName', () => {
5
5
  o(extractResolutionFromName('2013')).equals(-1);
@@ -10,4 +10,14 @@ o.spec('action.batch', () => {
10
10
  o(extractResolutionFromName('wellington_urban_2017_1.00m')).equals(1000);
11
11
  o(extractResolutionFromName('wellington_urban_2017_0.025m')).equals(25);
12
12
  });
13
+ o('should create valid jobNames', () => {
14
+ const fakeJob = { id: '01FHRPYJ5FV1XAARZAC4T4K6MC', name: 'geographx_nz_texture_shade_2012_8-0m' };
15
+ o(ActionBatchJob.id(fakeJob, '0')).equals('01FHRPYJ5FV1XAARZAC4T4K6MC-9af5e139bbb3e502-0');
16
+ fakeJob.name = 'ōtorohanga_urban_2021_0.1m_RGB';
17
+ o(ActionBatchJob.id(fakeJob, '0')).equals('01FHRPYJ5FV1XAARZAC4T4K6MC-5294acface81c107-0');
18
+ });
19
+ o('should truncate job names to 128 characters', () => {
20
+ const fakeJob = { id: '01FHRPYJ5FV1XAARZAC4T4K6MC', name: 'geographx_nz_texture_shade_2012_8-0m' };
21
+ o(ActionBatchJob.id(fakeJob, 'this is a really long file name it should over flow 128 characters so it should be truncated at some point.tiff')).equals('01FHRPYJ5FV1XAARZAC4T4K6MC-9af5e139bbb3e502-this is a really long file name it should over flow 128 characters so it should be t');
22
+ });
13
23
  });
@@ -14,7 +14,15 @@ export declare class ActionBatchJob extends CommandLineAction {
14
14
  private commit?;
15
15
  private oneCog?;
16
16
  constructor();
17
- static id(job: CogJob, name: string): string;
17
+ /**
18
+ * Create a id for a job
19
+ *
20
+ * This needs to be within `[a-Z_-]` upto 128 characters log
21
+ * @param job job to process
22
+ * @param fileName output filename
23
+ * @returns job id
24
+ */
25
+ static id(job: CogJob, fileName: string): string;
18
26
  static batchOne(jobPath: string, job: CogJob, batch: Batch, name: string, isCommit: boolean): Promise<{
19
27
  jobName: string;
20
28
  jobId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"action.batch.d.ts","sourceRoot":"","sources":["../../../src/cli/cogify/action.batch.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,OAAO,EAAc,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAwD,MAAM,4BAA4B,CAAC;AACrH,OAAO,KAAK,MAAM,0BAA0B,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAS5C;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,qBAAa,cAAe,SAAQ,iBAAiB;IACnD,OAAO,CAAC,GAAG,CAAC,CAA6B;IACzC,OAAO,CAAC,MAAM,CAAC,CAA2B;IAC1C,OAAO,CAAC,MAAM,CAAC,CAA6B;;IAU5C,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;WAI/B,QAAQ,CACnB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA6B9D;;;OAGG;WACU,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAqBrE,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;WAanB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,qBAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAyD9G,SAAS,CAAC,kBAAkB,IAAI,IAAI;CAqBrC"}
1
+ {"version":3,"file":"action.batch.d.ts","sourceRoot":"","sources":["../../../src/cli/cogify/action.batch.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,OAAO,EAAc,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAwD,MAAM,4BAA4B,CAAC;AACrH,OAAO,KAAK,MAAM,0BAA0B,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAS5C;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,qBAAa,cAAe,SAAQ,iBAAiB;IACnD,OAAO,CAAC,GAAG,CAAC,CAA6B;IACzC,OAAO,CAAC,MAAM,CAAC,CAA2B;IAC1C,OAAO,CAAC,MAAM,CAAC,CAA6B;;IAU5C;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;WAMnC,QAAQ,CACnB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA6B9D;;;OAGG;WACU,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAqBrE,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;WAanB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,qBAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAyD9G,SAAS,CAAC,kBAAkB,IAAI,IAAI;CAqBrC"}
@@ -2,6 +2,7 @@ import { TileMatrixSet } from '@basemaps/geo';
2
2
  import { Env, fsa, LogConfig, Projection } from '@basemaps/shared';
3
3
  import { CommandLineAction } from '@rushstack/ts-command-line';
4
4
  import Batch from 'aws-sdk/clients/batch.js';
5
+ import { createHash } from 'crypto';
5
6
  import { CogStacJob } from '../../cog/cog.stac.job.js';
6
7
  const JobQueue = 'CogBatchJobQueue';
7
8
  const JobDefinition = 'CogBatchJob';
@@ -28,8 +29,18 @@ export class ActionBatchJob extends CommandLineAction {
28
29
  documentation: 'Submit a list of cogs to a AWS Batch queue to be process',
29
30
  });
30
31
  }
31
- static id(job, name) {
32
- return `${job.id}-${job.name}-${name}`;
32
+ /**
33
+ * Create a id for a job
34
+ *
35
+ * This needs to be within `[a-Z_-]` upto 128 characters log
36
+ * @param job job to process
37
+ * @param fileName output filename
38
+ * @returns job id
39
+ */
40
+ static id(job, fileName) {
41
+ // Job names are uncontrolled so hash the name and grab a small slice to use as a identifier
42
+ const jobName = createHash('sha256').update(job.name).digest('hex').slice(0, 16);
43
+ return `${job.id}-${jobName}-${fileName}`.slice(0, 128);
33
44
  }
34
45
  static async batchOne(jobPath, job, batch, name, isCommit) {
35
46
  const jobName = ActionBatchJob.id(job, name);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Invalidate the cloudfront distribution cache when updating imagery sets
3
3
  */
4
- export declare function invalidateCache(path: string, commit?: boolean): Promise<void>;
4
+ export declare function invalidateCache(path: string | string[], commit?: boolean): Promise<void>;
5
5
  export declare const HashKey = "linz-hash";
6
6
  export declare function getHash(Bucket: string, Key: string): Promise<string | null>;
7
7
  export declare function getStaticBucket(): Promise<string | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/cli/util.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BjF;AAED,eAAO,MAAM,OAAO,cAAc,CAAC;AAEnC,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQjF;AAOD,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQ9D;AAMD;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,CA6BlB"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/cli/util.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B5F;AAED,eAAO,MAAM,OAAO,cAAc,CAAC;AAEnC,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQjF;AAOD,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQ9D;AAMD;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,CA6BlB"}
package/build/cli/util.js CHANGED
@@ -31,12 +31,13 @@ export async function invalidateCache(path, commit = false) {
31
31
  return;
32
32
  }
33
33
  LogConfig.get().info({ path, cfId: cf.Id }, 'Invalidating');
34
+ const Items = Array.isArray(path) ? path : [path];
34
35
  if (commit) {
35
36
  await cloudFront
36
37
  .createInvalidation({
37
38
  DistributionId: cf.Id,
38
39
  InvalidationBatch: {
39
- Paths: { Quantity: 1, Items: [path] },
40
+ Paths: { Quantity: Items.length, Items },
40
41
  CallerReference: `${CliId}-${InvalidationId++}`,
41
42
  },
42
43
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/cli",
3
- "version": "6.20.0",
3
+ "version": "6.22.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,8 +16,7 @@
16
16
  "main": "./build/index.js",
17
17
  "types": "./build/index.d.ts",
18
18
  "bin": {
19
- "cogify": "./cogify.js",
20
- "basemaps": "./basemaps.js"
19
+ "cogify": "./cogify.js"
21
20
  },
22
21
  "scripts": {
23
22
  "build": "tsc",
@@ -38,12 +37,12 @@
38
37
  "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
39
38
  },
40
39
  "dependencies": {
41
- "@basemaps/config": "^6.18.0",
42
- "@basemaps/geo": "^6.10.0",
43
- "@basemaps/shared": "^6.20.0",
44
- "@chunkd/fs": "^8.0.3",
40
+ "@basemaps/config": "^6.21.1",
41
+ "@basemaps/geo": "^6.21.1",
42
+ "@basemaps/shared": "^6.22.0",
43
+ "@chunkd/fs": "^8.1.0",
45
44
  "@cogeotiff/core": "^6.1.1",
46
- "@linzjs/geojson": "^6.10.0",
45
+ "@linzjs/geojson": "^6.21.1",
47
46
  "@rushstack/ts-command-line": "^4.3.13",
48
47
  "ansi-colors": "^4.1.1",
49
48
  "p-limit": "^4.0.0",
@@ -60,5 +59,5 @@
60
59
  "files": [
61
60
  "build/"
62
61
  ],
63
- "gitHead": "ca2a4b302477accd62e80f994d7ef12873808fe5"
62
+ "gitHead": "3190b6a49a91b3220b429a736484a93f3b76c721"
64
63
  }
package/basemaps.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import './build/cli/basemaps/index.js';
@@ -1,10 +0,0 @@
1
- import { TileSetBaseAction } from './tileset.action.js';
2
- export declare class TileSetInvalidateAction extends TileSetBaseAction {
3
- private commit;
4
- private projection;
5
- private tileSet;
6
- constructor();
7
- protected onDefineParameters(): void;
8
- protected onExecute(): Promise<void>;
9
- }
10
- //# sourceMappingURL=action.invalidate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action.invalidate.d.ts","sourceRoot":"","sources":["../../../src/cli/basemaps/action.invalidate.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,qBAAa,uBAAwB,SAAQ,iBAAiB;IAC5D,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,OAAO,CAA6B;;IAU5C,SAAS,CAAC,kBAAkB,IAAI,IAAI;cAMpB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAgB3C"}
@@ -1,36 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- import { Epsg } from '@basemaps/geo';
3
- import { Config, LogConfig } from '@basemaps/shared';
4
- import { TagActions } from '../tag.action.js';
5
- import { TileSetBaseAction } from './tileset.action.js';
6
- import { invalidateXYZCache } from './tileset.util.js';
7
- export class TileSetInvalidateAction extends TileSetBaseAction {
8
- constructor() {
9
- super({
10
- actionName: 'invalidate',
11
- summary: 'Invalidate basemaps caches rendering',
12
- documentation: 'Destroy the cache for cloudfront, useful if all the tiles need to be rendered again',
13
- });
14
- }
15
- onDefineParameters() {
16
- this.commit = this.defineFlagParameter(TagActions.Commit);
17
- this.projection = this.defineIntegerParameter(TagActions.Projection);
18
- this.tileSet = this.defineStringParameter(TagActions.TileSet);
19
- }
20
- async onExecute() {
21
- const tileSet = this.tileSet.value;
22
- const projection = Epsg.tryGet(this.projection.value);
23
- if (projection == null)
24
- return this.fatal({ projection: this.projection.value }, 'Invalid projection');
25
- const tsData = await Config.TileSet.get(Config.TileSet.id(tileSet));
26
- if (tsData == null)
27
- return this.fatal({ tileSet }, 'Could not find tileset');
28
- LogConfig.get().info({ tileSet, projection }, 'Invalidating');
29
- if (this.commit.value) {
30
- await invalidateXYZCache(tileSet, projection, this.commit.value);
31
- }
32
- else {
33
- LogConfig.get().warn('DryRun:Done');
34
- }
35
- }
36
- }
@@ -1,12 +0,0 @@
1
- import { TileSetBaseAction } from './tileset.action.js';
2
- export declare class TileSetInfoAction extends TileSetBaseAction {
3
- private imagery;
4
- private projection;
5
- private tileSet;
6
- private version;
7
- constructor();
8
- protected onDefineParameters(): void;
9
- private imageInfo;
10
- protected onExecute(): Promise<void>;
11
- }
12
- //# sourceMappingURL=action.tileset.info.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action.tileset.info.d.ts","sourceRoot":"","sources":["../../../src/cli/basemaps/action.tileset.info.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,qBAAa,iBAAkB,SAAQ,iBAAiB;IACtD,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,UAAU,CAA8B;IAChD,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,OAAO,CAA8B;;IAU7C,SAAS,CAAC,kBAAkB,IAAI,IAAI;YAOtB,SAAS;cAcP,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB3C"}
@@ -1,56 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- import { Epsg } from '@basemaps/geo';
3
- import { Config, LogConfig } from '@basemaps/shared';
4
- import * as c from 'ansi-colors';
5
- import { TagActions } from '../tag.action.js';
6
- import { TileSetBaseAction } from './tileset.action.js';
7
- import { printTileSet } from './tileset.util.js';
8
- export class TileSetInfoAction extends TileSetBaseAction {
9
- constructor() {
10
- super({
11
- actionName: 'info',
12
- summary: 'Rendering information for tile sets or imagery',
13
- documentation: 'Get rendering information for the tile set or imagery',
14
- });
15
- }
16
- onDefineParameters() {
17
- this.imagery = this.defineStringParameter(TagActions.Imagery);
18
- this.projection = this.defineIntegerParameter(TagActions.Projection);
19
- this.tileSet = this.defineStringParameter(TagActions.TileSet);
20
- this.version = this.defineIntegerParameter(TagActions.Version);
21
- }
22
- async imageInfo(imageryId) {
23
- const img = await Config.Imagery.get(imageryId);
24
- if (img == null)
25
- throw new Error('Cannot find imagery with id ' + imageryId);
26
- console.log(c.bold('Imagery:'), img.name);
27
- console.log(c.bold('CreatedAt:'), new Date(img.createdAt).toString());
28
- console.log(c.bold('UpdatedAt:'), new Date(img.updatedAt).toString());
29
- console.log(c.bold('Year:'), img.year);
30
- console.log(c.bold('Projection:'), img.projection);
31
- console.log(c.bold('Resolution:'), img.resolution);
32
- console.log(c.bold('Files:\n'), img.files.map((c) => `\t${c.name}`).join('\n'));
33
- // TODO get job.json from s3 and get information on how the imagery was made.
34
- }
35
- async onExecute() {
36
- const tileSet = this.tileSet.value;
37
- const projection = Epsg.tryGet(this.projection.value);
38
- if (projection == null)
39
- return this.fatal({ projection: this.projection.value }, 'Invalid projection');
40
- const imgId = this.imagery.value;
41
- if (imgId != null)
42
- return this.imageInfo(imgId);
43
- if (tileSet == null) {
44
- LogConfig.get().fatal('Missing --tileset and --projection or --imagery');
45
- console.log(this.renderHelpText());
46
- return;
47
- }
48
- const tileSetId = Config.TileSet.id(tileSet);
49
- const tsData = await Config.TileSet.get(tileSetId);
50
- if (tsData == null) {
51
- LogConfig.get().fatal({ tileSet }, 'Unable to find tile set');
52
- return;
53
- }
54
- await printTileSet(tsData, projection);
55
- }
56
- }
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import 'source-map-support/register.js';
3
- import { BaseCommandLine } from '../base.cli.js';
4
- export declare class BasemapsCommandLine extends BaseCommandLine {
5
- constructor();
6
- }
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/basemaps/index.ts"],"names":[],"mappings":";AACA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIjD,qBAAa,mBAAoB,SAAQ,eAAe;;CASvD"}
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env node
2
- import 'source-map-support/register.js';
3
- import { BaseCommandLine } from '../base.cli.js';
4
- import { TileSetInvalidateAction } from './action.invalidate.js';
5
- import { TileSetInfoAction } from './action.tileset.info.js';
6
- export class BasemapsCommandLine extends BaseCommandLine {
7
- constructor() {
8
- super({
9
- toolFilename: 'basemaps',
10
- toolDescription: 'Basemaps configuration utilities',
11
- });
12
- this.addAction(new TileSetInfoAction());
13
- this.addAction(new TileSetInvalidateAction());
14
- }
15
- }
16
- new BasemapsCommandLine().run();
@@ -1,7 +0,0 @@
1
- import { LogType } from '@basemaps/shared';
2
- import { CommandLineAction } from '@rushstack/ts-command-line';
3
- export declare abstract class TileSetBaseAction extends CommandLineAction {
4
- /** Log a fatal error and render the help text */
5
- fatal(obj: Record<string, unknown>, msg: string, logger?: LogType): void;
6
- }
7
- //# sourceMappingURL=tileset.action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tileset.action.d.ts","sourceRoot":"","sources":["../../../src/cli/basemaps/tileset.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,8BAAsB,iBAAkB,SAAQ,iBAAiB;IAC/D,iDAAiD;IACjD,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAyB,GAAG,IAAI;CAK1F"}
@@ -1,10 +0,0 @@
1
- import { LogConfig } from '@basemaps/shared';
2
- import { CommandLineAction } from '@rushstack/ts-command-line';
3
- export class TileSetBaseAction extends CommandLineAction {
4
- /** Log a fatal error and render the help text */
5
- fatal(obj, msg, logger = LogConfig.get()) {
6
- logger.fatal(obj, msg);
7
- console.log('\n');
8
- console.log(this.renderHelpText());
9
- }
10
- }
@@ -1,22 +0,0 @@
1
- import { ConfigImagery, ConfigLayer, ConfigTileSet, ConfigTileSetRaster } from '@basemaps/config';
2
- import { Epsg } from '@basemaps/geo';
3
- import { CliTable } from '../cli.table.js';
4
- export declare function rgbaToHex(c: {
5
- r: number;
6
- g: number;
7
- b: number;
8
- alpha: number;
9
- }): string;
10
- interface TileSetLayerImagery {
11
- layer: ConfigLayer;
12
- imagery: ConfigImagery;
13
- }
14
- export declare const TileSetTable: CliTable<TileSetLayerImagery>;
15
- export declare function printTileSetImagery(tsData: ConfigTileSetRaster, projection: Epsg): Promise<void>;
16
- export declare function printTileSet(tsData: ConfigTileSet, projection: Epsg, printImagery?: boolean): Promise<void>;
17
- /**
18
- * Invalidate the cloudfront distribution cache when updating imagery sets
19
- */
20
- export declare function invalidateXYZCache(name: string, projection: Epsg, commit?: boolean): Promise<void>;
21
- export {};
22
- //# sourceMappingURL=tileset.util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tileset.util.d.ts","sourceRoot":"","sources":["../../../src/cli/basemaps/tileset.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAe,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAU3C,wBAAgB,SAAS,CAAC,CAAC,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEvF;AAED,UAAU,mBAAmB;IAC3B,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,eAAO,MAAM,YAAY,+BAAsC,CAAC;AAMhE,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CActG;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAc9G;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAItG"}
@@ -1,58 +0,0 @@
1
- import { TileSetType } from '@basemaps/config';
2
- import { Config } from '@basemaps/shared';
3
- import * as c from 'ansi-colors';
4
- import { CliTable } from '../cli.table.js';
5
- import { invalidateCache } from '../util.js';
6
- /**
7
- * Convert a number to a two digit hex string. numbers < 16 are padded with '0'
8
- */
9
- function numberToHexString(n) {
10
- const ans = n.toString(16);
11
- return ans.length === 1 ? '0' + ans : ans;
12
- }
13
- export function rgbaToHex(c) {
14
- return numberToHexString(c.r) + numberToHexString(c.g) + numberToHexString(c.b) + numberToHexString(c.alpha);
15
- }
16
- export const TileSetTable = new CliTable();
17
- TileSetTable.field('Imagery Id', 30, (obj) => c.dim(obj.imagery.id));
18
- TileSetTable.field('Name', 40, (obj) => obj.imagery.name);
19
- TileSetTable.field('Zoom', 10, (obj) => obj.layer.minZoom + ' -> ' + obj.layer.maxZoom);
20
- TileSetTable.field('CreatedAt', 10, (obj) => new Date(obj.imagery.createdAt).toISOString());
21
- export async function printTileSetImagery(tsData, projection) {
22
- const allImagery = await Config.getTileSetImagery(tsData);
23
- const ruleImagery = [];
24
- for (const layer of tsData.layers) {
25
- const imgId = Config.getImageId(layer, projection);
26
- if (imgId != null) {
27
- const imagery = allImagery.get(imgId);
28
- if (imagery == null)
29
- continue;
30
- ruleImagery.push({ layer, imagery });
31
- }
32
- }
33
- console.log('');
34
- TileSetTable.header();
35
- TileSetTable.print(ruleImagery);
36
- }
37
- export async function printTileSet(tsData, projection, printImagery = true) {
38
- console.log(c.bold('TileSet:'), `${tsData.name} `);
39
- console.log(c.bold('CreatedAt:'), new Date(tsData.createdAt).toISOString());
40
- console.log(c.bold('UpdatedAt:'), new Date(tsData.updatedAt).toISOString());
41
- if (tsData.type === TileSetType.Vector)
42
- return;
43
- if (tsData.background) {
44
- console.log(c.bold('Background'), tsData.background);
45
- }
46
- if (tsData.resizeKernel) {
47
- console.log(c.bold('ResizeKernel:'), c.dim('in'), tsData.resizeKernel.in, c.dim('out'), tsData.resizeKernel.out);
48
- }
49
- if (printImagery)
50
- await printTileSetImagery(tsData, projection);
51
- }
52
- /**
53
- * Invalidate the cloudfront distribution cache when updating imagery sets
54
- */
55
- export async function invalidateXYZCache(name, projection, commit = false) {
56
- const path = `/v1/tiles/${name}/${projection.toEpsgString()}/*`;
57
- return invalidateCache(path, commit);
58
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Simple fixed width table formatter
3
- */
4
- export declare class CliTable<T extends Record<string, any>> {
5
- fields: {
6
- name: string;
7
- width: number;
8
- value: (obj: T) => string;
9
- }[];
10
- field(name: string, width: number, value: (obj: T) => string): void;
11
- header(): void;
12
- line(obj: T): string;
13
- print(obj: T[]): void;
14
- }
15
- //# sourceMappingURL=cli.table.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.table.d.ts","sourceRoot":"","sources":["../../src/cli/cli.table.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACjD,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,CAAA;KAAE,EAAE,CAAM;IAE1E,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI;IAInE,MAAM,IAAI,IAAI;IAId,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM;IAIpB,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI;CAGtB"}
@@ -1,21 +0,0 @@
1
- import * as c from 'ansi-colors';
2
- /**
3
- * Simple fixed width table formatter
4
- */
5
- export class CliTable {
6
- constructor() {
7
- this.fields = [];
8
- }
9
- field(name, width, value) {
10
- this.fields.push({ name, width, value });
11
- }
12
- header() {
13
- console.log(this.fields.map((f) => c.bold(f.name.substr(0, f.width).padEnd(f.width))).join('\t'));
14
- }
15
- line(obj) {
16
- return this.fields.map((f) => f.value(obj).padEnd(f.width)).join('\t');
17
- }
18
- print(obj) {
19
- obj.forEach((o) => console.log(this.line(o)));
20
- }
21
- }
@@ -1,37 +0,0 @@
1
- /** Commonly used definitions for cli args */
2
- export declare const TagActions: {
3
- readonly Version: {
4
- readonly argumentName: "VERSION";
5
- readonly parameterLongName: "--version";
6
- readonly parameterShortName: "-v";
7
- readonly description: "Version ID";
8
- readonly required: false;
9
- };
10
- readonly Commit: {
11
- readonly parameterLongName: "--commit";
12
- readonly description: "Commit to database";
13
- readonly required: false;
14
- };
15
- readonly Imagery: {
16
- readonly argumentName: "IMAGERY";
17
- readonly parameterLongName: "--imagery";
18
- readonly parameterShortName: "-i";
19
- readonly description: "Imagery ID";
20
- readonly required: false;
21
- };
22
- readonly TileSet: {
23
- readonly argumentName: "TILE_SET";
24
- readonly parameterLongName: "--tileset-name";
25
- readonly parameterShortName: "-n";
26
- readonly description: "Tileset name to use";
27
- readonly required: false;
28
- };
29
- readonly Projection: {
30
- readonly argumentName: "PROJECTION";
31
- readonly parameterLongName: "--projection";
32
- readonly parameterShortName: "-p";
33
- readonly description: "Projection to use";
34
- readonly required: false;
35
- };
36
- };
37
- //# sourceMappingURL=tag.action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tag.action.d.ts","sourceRoot":"","sources":["../../src/cli/tag.action.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCb,CAAC"}
@@ -1,36 +0,0 @@
1
- /** Commonly used definitions for cli args */
2
- export const TagActions = {
3
- Version: {
4
- argumentName: 'VERSION',
5
- parameterLongName: '--version',
6
- parameterShortName: '-v',
7
- description: 'Version ID',
8
- required: false,
9
- },
10
- Commit: {
11
- parameterLongName: '--commit',
12
- description: 'Commit to database',
13
- required: false,
14
- },
15
- Imagery: {
16
- argumentName: 'IMAGERY',
17
- parameterLongName: '--imagery',
18
- parameterShortName: '-i',
19
- description: 'Imagery ID',
20
- required: false,
21
- },
22
- TileSet: {
23
- argumentName: 'TILE_SET',
24
- parameterLongName: '--tileset-name',
25
- parameterShortName: '-n',
26
- description: 'Tileset name to use',
27
- required: false,
28
- },
29
- Projection: {
30
- argumentName: 'PROJECTION',
31
- parameterLongName: '--projection',
32
- parameterShortName: '-p',
33
- description: 'Projection to use',
34
- required: false,
35
- },
36
- };