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): expose the smoke checker in the CLI container so linz/basemaps-config can use it BM-1010 #3229

Merged
merged 1 commit into from
Apr 11, 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
3 changes: 0 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ RUN npm install [email protected]
# Install the landing assets
COPY ./basemaps-landing*.tgz /app/
COPY ./basemaps-cogify*.tgz /app/
COPY ./basemaps-smoke*.tgz /app/

RUN npm install ./basemaps-landing*.tgz ./basemaps-cogify*.tgz
RUN npm install ./basemaps-landing*.tgz ./basemaps-cogify*.tgz ./basemaps-smoke*.tgz

COPY dist/index.cjs /app/

Expand Down
4 changes: 1 addition & 3 deletions packages/smoke/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@
"build/",
"bin/"
],
"dependencies": {
"@basemaps/shared": "^7.1.0"
}
"dependencies": {}
}
10 changes: 5 additions & 5 deletions packages/smoke/src/base.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import assert from 'node:assert';

import { LogConfig } from '@basemaps/shared';
import ulid from 'ulid';

const logger = LogConfig.get();
/** Fresh API Key to use */
const apiKey = 'c' + ulid.ulid().toLowerCase().slice(0, 22) + 'test';

Expand All @@ -27,14 +25,16 @@ if (!host.protocol.startsWith('http')) throw new Error(`Invalid host: ${host}`);
*/
async function req(path: string, opts?: RequestInit): Promise<Response> {
const target = new URL(path, host);
logger.trace({ path, url: target.href }, 'Fetch');

const startTime = performance.now();
const res = await fetch(target, opts);
logger.info({ url: target.href, status: res.status, ...opts, duration: performance.now() - startTime }, 'Fetch:Done');

// eslint-disable-next-line no-console
console.log({ url: target.href, status: res.status, ...opts, duration: performance.now() - startTime }, 'Fetch:Done');
return res;
}

export const ctx = { logger, host, Cors, apiKey, req };
export const ctx = { host, Cors, apiKey, req };

/** Validate that the response was not a cached response */
export function assertCacheMiss(res: Response): void {
Expand Down
Loading