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(config-cli): New config-cli package includes dump basemaps screenshots command line tool #2231

Merged
merged 8 commits into from
Jun 2, 2022

Conversation

Wentao-Kuang
Copy link
Contributor

No description provided.

@Wentao-Kuang Wentao-Kuang requested a review from a team as a code owner June 1, 2022 22:56
import 'source-map-support/register.js';
import { CommandScreenShot } from './screenshot.js';

export class ScreenshotCommandLine extends BaseCommandLine {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets call this BasemapsConfig as we will add more sub tools to it like the config import

bmc as the script name? or basemaps-config ?

import { Browser, chromium } from 'playwright';
import { CommandLineAction, CommandLineFlagParameter, CommandLineStringParameter } from '@rushstack/ts-command-line';

const TileTest = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this pull request it would be great to store these as a JSON file.

await page.waitForTimeout(1000);
await page.waitForLoadState('networkidle');
} else {
throw new Error('Not supported on production yet');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now in production we can take this logic out.

@@ -0,0 +1,3 @@
#!/usr/bin/env node
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should be referenced by the bin field in the package.json, it also wont be published.

Its best to put this into ./bin/bmc.mjs (being specific is super helpful for these)

then add bin/ to the files exported and add a bin section to map it to basemaps-screenshot ?

export class BasemapsConfig extends BaseCommandLine {
constructor() {
super({
toolFilename: 'screenshot',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should the same name as the bin file

lng: number;
z: number;
}
interface TileTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use zod to parse these?

defaultValue: './test-tiles/default.test.tiles.json',
});

this.verbose = this.defineFlagParameter({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verbose is handled by being a part of BaseCommandLine

./bmc --verbose screenshot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fixed. Can you give another look?

const host = this.host.value ?? this.host.defaultValue;
const tag = this.tag.value ?? this.tag.defaultValue;
const tiles = this.tiles.value ?? this.tiles.defaultValue;
if (host == null || tag == null || tiles == null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this ever happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. But we need a checking in typescript to parse them as string instead of string | undefiened

@lgtm-com
Copy link

lgtm-com bot commented Jun 2, 2022

This pull request introduces 1 alert when merging a6e3544 into e7b6a9e - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@Wentao-Kuang Wentao-Kuang requested a review from blacha June 2, 2022 22:36
Dump the screenshots from basemaps production

```bash
./bin/bmc.js screenshot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: if its described as bin : { "bmc": ... } the actual command will be bmc once you npm install it

Dump the screenshots from different host and tag

```bash
.bin//bmc.js screenshot --host HOST --tag PR-TAG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: //

"access": "public"
},
"files": [
"build/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing bin/

export class BasemapsConfig extends BaseCommandLine {
constructor() {
super({
toolFilename: 'bin',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bmc

@@ -0,0 +1,16 @@
#!/usr/bin/env node
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should never be executed directly.

}
}

new BasemapsConfig().run();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this .run() part into the bin file. that way this file could in theory be imported

import { z } from 'zod';

enum TileMatrixIdentifier {
NZTM = 'NZTM2000Quad',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have this as a enum somewhere else?

We should be specific here Nztm2000Quad so we know we are talking about nztm2000quad tms and not the other one.

@kodiakhq kodiakhq bot merged commit 39186d5 into master Jun 2, 2022
@kodiakhq kodiakhq bot deleted the feat/config-cli branch June 2, 2022 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants