Skip to content

config command line option - #295

Open
ozcoder wants to merge 6 commits into
cloudflare:mainfrom
ozcoder:config-option
Open

config command line option#295
ozcoder wants to merge 6 commits into
cloudflare:mainfrom
ozcoder:config-option

Conversation

@ozcoder

@ozcoder ozcoder commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Added the command line option --config CONFIG_FILENAME. Command line options will override any options set in the configuration file.

I've moved some things around, in particular defaults are handled in executeTest. The URL to test can be in the configuration file or -u URL or as an argument to the command line.

Closes #62

ozcoder added 3 commits May 19, 2026 11:21
…place.

Read and parse the supplied configuration file.
Due to the possibility of url being in the config file, I moved the checking.
Do not let undefined values override earlier values.
Added schemas for configuration file processing.
Added associated types.
Moved URL checking around a bit.
Allow config.url to be missing the protocol.
programmatic API does NOT partially auto-prefix.
Emojis are not part of a valid URL.
Just throw the error from normalizeUrlScheme.

@nicjansma nicjansma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR @ozcoder! Would love to have this option.

Comment thread packages/telescope/src/index.ts Outdated
Comment thread packages/telescope/src/index.ts Outdated
}
} else if (engine === 'webkit') {
cfg.browser = 'safari';
} else { // chromium

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you run npm run prettier on the project? I think some of these minor formatting consistency things will be auto-fixed.

Comment thread packages/telescope/src/config.ts Outdated
throw err;
}

if (cfgStat.size > 4096) { // Arbitrary size

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Any particular reason for blocking at > 4096 bytes?

I could see things like headers potentially grow above this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point.
Arbitrary size, maybe 32K would be better. I was hoping for some guidance.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

32K seems more reasonable.

What kind of situations do you think the size check will help with? People putting incorrect data in there for some reason? Unsure if we need the gate at all.

Comment thread packages/telescope/__tests__/emulation.test.ts
Comment thread packages/telescope/src/config.ts Outdated
Comment thread packages/telescope/src/index.ts
Comment thread packages/telescope/src/config.ts
)
.addOption(
new Option(
'--config <string>',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you update README.md for the new --config option?

Comment thread packages/telescope/src/schemas.ts

let cfg: LaunchOptions = { url: baseConfig.url || '' }; // Always required

if (baseConfig.options) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It wasn't immediately obvious to me that the config JSON file should have a top-level options: {} key that all CLI options go into.

After looking at the original issue, I see that this comes from the results\xxx\config.json having a top-level options: {}.

Maybe this can be just documented clearly, with an example, in README.md?

@MildMax MildMax added the ticket This label indicates that internal ticket was created to track it. label Jul 6, 2026
@sergeychernyshev
sergeychernyshev requested a review from Copilot July 7, 2026 16:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for supplying a configuration file to Telescope via a new CLI option (--config <file>), and updates the option resolution flow so CLI flags override values from that config file. It also shifts where defaults are applied (into executeTest) and adjusts URL resolution to allow the URL to come from positional args, --url, or the config file.

Changes:

  • Add --config <file> CLI option and load base configuration from a JSON file.
  • Introduce Zod schemas/types for the config file shape and options loaded from it.
  • Refactor option/default merging and update a couple of programmatic/CLI tests.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
packages/telescope/src/types.ts Adds config option and new inferred types for config-file-related schemas.
packages/telescope/src/schemas.ts Adds Zod schemas for config-file input and browser config/options blocks.
packages/telescope/src/index.ts Adds --config flag, loads config in launchTest, and changes URL/default handling in executeTest.
packages/telescope/src/config.ts Adds getBaseConfig() to parse config files and map them into LaunchOptions.
packages/telescope/tests/programmatic.test.ts Updates programmatic URL/error handling expectations.
packages/telescope/tests/emulation.test.ts Removes a test that asserted default browser selection in normalizeCLIConfig.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/telescope/src/types.ts
Comment thread packages/telescope/src/schemas.ts Outdated
Comment thread packages/telescope/src/schemas.ts Outdated
Comment thread packages/telescope/src/schemas.ts Outdated
Comment thread packages/telescope/src/index.ts
Comment thread packages/telescope/src/config.ts Outdated
Comment thread packages/telescope/src/config.ts Outdated
Comment thread packages/telescope/src/config.ts
Comment on lines 261 to 265
export async function launchTest(options: LaunchOptions): Promise<TestResult> {
try {
return await executeTest(options);
const baseConfig = options.config ? getBaseConfig(options.config) : { url: '' };
return await executeTest(options, baseConfig);
} catch (error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I need help creating a test. I'm not sure where the test config should live.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think a clone of params.test.ts that focuses on the --config options would be nice. I haven't written tests for this project yet either! But if you have access to a coding agent, it could probably start with some boilerplate.

Comment thread packages/telescope/src/schemas.ts
ozcoder added 3 commits July 9, 2026 22:09
Increased max config file size to 32Kb.
Do not use `any` during config copying.
Do not need so many try/catches since they throw Errors anyways.
Cleaned up comments.
Copy the URL as-an-argument into options if existing.
Some schemas can be a string or false, but not true.
Better URL schema checking.
),
new Option(
'--disableJS',
`Disable JavaScript (default: ${DEFAULT_OPTIONS.disableJS})`)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason some of the options use .default(xyz) and others describe the default in the description ... (default: xyz)?

@nicjansma

Copy link
Copy Markdown
Collaborator

Thanks for the updates @ozcoder! Lots of the changes look good.

Only a few outstanding things left:

  • Updates to README to describe --config
  • npm run prettier and npm run lint:fix
  • tests

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ticket This label indicates that internal ticket was created to track it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to provide a config file.

4 participants