Skip to content

Commit 988c787

Browse files
authored
feat: STRF-12941 Add channelUrl parameter to stencil start (#1254)
1 parent 15195aa commit 988c787

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

bin/stencil-start.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ program
1919
'-n, --no-cache',
2020
'Turns off caching for API resource data per storefront page. The cache lasts for 5 minutes before automatically refreshing.',
2121
)
22-
.option('-t, --timeout', 'Set a timeout for the bundle operation. Default is 20 secs', '60');
22+
.option('-t, --timeout', 'Set a timeout for the bundle operation. Default is 20 secs', '60')
23+
.option(
24+
'-cu, --channelUrl [channelUrl]',
25+
'Set a custom domain url to bypass dns/proxy protection',
26+
);
2327
const cliOptions = prepareCommand(program);
2428
const options = {
2529
open: cliOptions.open,
@@ -28,6 +32,7 @@ const options = {
2832
apiHost: cliOptions.host,
2933
tunnel: cliOptions.tunnel,
3034
cache: cliOptions.cache,
35+
channelUrl: cliOptions.channelUrl,
3136
};
3237
const timeout = cliOptions.timeout * 1000; // seconds
3338
const buildConfigManager = new BuildConfigManager({ timeout });

lib/stencil-start.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ class StencilStart {
9191
this.storeHash = await this._themeApiClient.getStoreHash({
9292
storeUrl: stencilConfig.normalStoreUrl,
9393
});
94+
if (cliOptions.channelUrl) {
95+
return cliOptions.channelUrl;
96+
}
9497
const channels = await this._themeApiClient.getStoreChannels({
9598
storeHash: this.storeHash,
9699
accessToken,

lib/stencil-start.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,21 @@ describe('StencilStart unit tests', () => {
134134
const result = await instance.getChannelUrl({ accessToken }, { apiHost });
135135
expect(result).toEqual(storeUrl);
136136
});
137+
138+
it('should obtain channel url from the CLI', async () => {
139+
const channelUrl = 'https://shop.bigcommerce.com';
140+
const channels = [{ channel_id: channelId, url: storeUrl }];
141+
const themeApiClientStub = {
142+
checkCliVersion: jest.fn(),
143+
getStoreHash: jest.fn().mockResolvedValue(storeHash),
144+
getStoreChannels: jest.fn().mockResolvedValue(channels),
145+
};
146+
const { instance } = createStencilStartInstance({
147+
themeApiClient: themeApiClientStub,
148+
stencilPushUtils: stencilPushUtilsModule,
149+
});
150+
const result = await instance.getChannelUrl({ accessToken }, { apiHost, channelUrl });
151+
expect(result).toEqual(channelUrl);
152+
});
137153
});
138154
});

0 commit comments

Comments
 (0)