When setting environment variables to be used with ZCLI, I expect to be able to run commands and be authenticated.
Reality
After setting the following environment variables:
ZENDESK_API_TOKEN
ZENDESK_EMAIL
ZENDESK_SUBDOMAIN
And running zcli themes:preview, I get the following error:
ubuntu@dev-cgibson:~/git/zendesk-theme/dist$ zcli themes:preview
Uploading theme... Ok
/usr/lib/node_modules/@zendesk/zcli/node_modules/@zendesk/zcli-themes/dist/commands/themes/preview.js:60
const { subdomain, domain } = await new zcli_core_1.Auth().getLoggedInProfile();
^
TypeError: Cannot destructure property 'subdomain' of '(intermediate value)' as it is undefined.
at Server.<anonymous> (/usr/lib/node_modules/@zendesk/zcli/node_modules/@zendesk/zcli-themes/dist/commands/themes/preview.js:60:21)
Node.js v18.17.0
This appears to be an issue with the following code, where an assumption is made that the subdomain will always be coming from the logged in profile:
server.listen(port, host, async () => {
// preview requires authentication so we're sure
// to have a logged in profile at this point
const { subdomain, domain } = await new zcli_core_1.Auth().getLoggedInProfile();
const baseUrl = (0, zcli_core_1.getBaseUrl)(subdomain, domain);
this.log(chalk.bold.green('Ready', chalk.blueBright(`${baseUrl}/hc/admin/local_preview/start`, '🚀')));
this.log(`You can exit preview mode in the UI or by visiting ${baseUrl}/hc/admin/local_preview/stop`);
tailLogs && this.log(chalk.bold('Tailing logs'));
});
TEMPORARY FIX
For my use case, I was able to resolve this by editing the above file and changing:
Expectations
When setting environment variables to be used with ZCLI, I expect to be able to run commands and be authenticated.
Reality
After setting the following environment variables:
ZENDESK_SUBDOMAIN
And running
zcli themes:preview
, I get the following error:This appears to be an issue with the following code, where an assumption is made that the subdomain will always be coming from the logged in profile:
/usr/lib/node_modules/@zendesk/zcli/node_modules/@zendesk/zcli-themes/dist/commands/themes/preview.js
TEMPORARY FIX For my use case, I was able to resolve this by editing the above file and changing:
to:
Steps to Reproduce
sudo npm uninstall -g @zendesk/zcli; sudo npm install @zendesk/zcli -g
Issue details