Skip to content

Commit

Permalink
added additional query for single case
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream Dev authored and Dream Dev committed Aug 18, 2022
1 parent e8eebb4 commit feba321
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,16 @@ Options:
--chromiumPath Executable Chromium path. [string] [default: ""]
--puppeteerLaunchConfig JSON string of launch config for Puppeteer.
[string] [default: "{ "args": ["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"] }"]
--additionalQuery, --aq Additional query string for extra setting specific story [string] [default: ""]
Examples:
storycap http://localshot:9009
storycap http://localshot:9009 -V 1024x768 -V 320x568
storycap http://localshot:9009 -i "some-kind/a-story"
storycap http://example.com/your-storybook -e "**/default" -V iPad
storycap --serverCmd "start-storybook -p 3000" http://localshot:3000
storycap http://localshot:9009 -aq "knobs-primary=true&knobs-show-lines=true" -i "Global/Components/CodeBlock/Code
Block Story"
```

Expand Down
12 changes: 11 additions & 1 deletion packages/storycap/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,21 @@ function createOptions(): MainOptions {
default: '{ "args": ["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage"] }',
description: 'JSON string of launch config for Puppeteer.',
})
.options('additionalQuery', {
string: true,
default: '',
description: 'Additional query string for extra setting specific story',
alias: 'aq',
})
.example('storycap http://localshot:9009', '')
.example('storycap http://localshot:9009 -V 1024x768 -V 320x568', '')
.example('storycap http://localshot:9009 -i "some-kind/a-story"', '')
.example('storycap http://example.com/your-storybook -e "**/default" -V iPad', '')
.example('storycap --serverCmd "start-storybook -p 3000" http://localshot:3000', '');
.example('storycap --serverCmd "start-storybook -p 3000" http://localshot:3000', '')
.example(
'storycap http://localshot:9009 -aq "knobs-primary=true&knobs-show-lines=true" -i "Global/Components/CodeBlock/Code Block Story"',
'',
);
let storybookUrl;

if (!setting.argv._.length) {
Expand Down
9 changes: 8 additions & 1 deletion packages/storycrawler/src/browser/base-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ export interface BaseBrowserOptions {

/**
*
* User defind Chromium execuatable binary path
* User defined Chromium executable binary path
*
**/
chromiumPath?: string;

/**
*
* User defined additional setting query for example knobs
*
**/
additionalQuery?: string;
}

/**
Expand Down
14 changes: 10 additions & 4 deletions packages/storycrawler/src/browser/story-preview-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ export class StoryPreviewBrowser extends BaseBrowser {
**/
async boot() {
await super.boot();
await this.page.goto(this.connection.url + '/iframe.html?selectedKind=scszisui&selectedStory=scszisui', {
timeout: 60_000,
waitUntil: 'domcontentloaded',
});
await this.page.goto(
this.connection.url +
'/iframe.html?selectedKind=scszisui&selectedStory=scszisui&' +
(this.opt.additionalQuery || ''),
{
timeout: 60_000,
waitUntil: 'domcontentloaded',
},
);

return this;
}

Expand Down

0 comments on commit feba321

Please sign in to comment.