Skip to content
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
7 changes: 6 additions & 1 deletion bin/stencil-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ program
'-n, --no-cache',
'Turns off caching for API resource data per storefront page. The cache lasts for 5 minutes before automatically refreshing.',
)
.option('-t, --timeout', 'Set a timeout for the bundle operation. Default is 20 secs', '60');
.option('-t, --timeout', 'Set a timeout for the bundle operation. Default is 20 secs', '60')
.option(
'-cu, --channelUrl [channelUrl]',
'Set a custom domain url to bypass dns/proxy protection',
);
const cliOptions = prepareCommand(program);
const options = {
open: cliOptions.open,
Expand All @@ -28,6 +32,7 @@ const options = {
apiHost: cliOptions.host,
tunnel: cliOptions.tunnel,
cache: cliOptions.cache,
channelUrl: cliOptions.channelUrl,
};
const timeout = cliOptions.timeout * 1000; // seconds
const buildConfigManager = new BuildConfigManager({ timeout });
Expand Down
3 changes: 3 additions & 0 deletions lib/stencil-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class StencilStart {
this.storeHash = await this._themeApiClient.getStoreHash({
storeUrl: stencilConfig.normalStoreUrl,
});
if (cliOptions.channelUrl) {
return cliOptions.channelUrl;
}
const channels = await this._themeApiClient.getStoreChannels({
storeHash: this.storeHash,
accessToken,
Expand Down
16 changes: 16 additions & 0 deletions lib/stencil-start.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,21 @@ describe('StencilStart unit tests', () => {
const result = await instance.getChannelUrl({ accessToken }, { apiHost });
expect(result).toEqual(storeUrl);
});

it('should obtain channel url from the CLI', async () => {
const channelUrl = 'https://shop.bigcommerce.com';
const channels = [{ channel_id: channelId, url: storeUrl }];
const themeApiClientStub = {
checkCliVersion: jest.fn(),
getStoreHash: jest.fn().mockResolvedValue(storeHash),
getStoreChannels: jest.fn().mockResolvedValue(channels),
};
const { instance } = createStencilStartInstance({
themeApiClient: themeApiClientStub,
stencilPushUtils: stencilPushUtilsModule,
});
const result = await instance.getChannelUrl({ accessToken }, { apiHost, channelUrl });
expect(result).toEqual(channelUrl);
});
});
});
Loading