Skip to content

Commit

Permalink
feat: STRF-12941 Add channelUrl parameter to stencil start (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
jairo-bc authored Jan 17, 2025
1 parent 15195aa commit 988c787
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
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);
});
});
});

0 comments on commit 988c787

Please sign in to comment.