diff --git a/packages/create-catalyst/src/commands/create.ts b/packages/create-catalyst/src/commands/create.ts index 4c980f3a1a..2e63da0415 100644 --- a/packages/create-catalyst/src/commands/create.ts +++ b/packages/create-catalyst/src/commands/create.ts @@ -71,8 +71,6 @@ export const create = async (options: CreateCommandOptions) => { canCreateChannel = false; } else if (channels.length >= limits.total_including_inactive) { canCreateChannel = false; - } else { - console.log(`${limits.active - activeChannels.length} active channels remaining.`); } if (!canCreateChannel) { diff --git a/packages/create-catalyst/src/utils/https.ts b/packages/create-catalyst/src/utils/https.ts index b05343b8ca..a5b4fd3dd0 100644 --- a/packages/create-catalyst/src/utils/https.ts +++ b/packages/create-catalyst/src/utils/https.ts @@ -30,7 +30,7 @@ interface HttpsConfig { } export class Https { - DEVICE_OAUTH_CLIENT_ID = 'o094w49fnipwgbo0h9772pc2q6pw1p7'; + DEVICE_OAUTH_CLIENT_ID = 'acse0vvawm9r1n0evag4b8e1ea1fo90'; bigCommerceApiUrl: string; bigCommerceAuthUrl: string; @@ -118,10 +118,7 @@ export class Https { }); if (response.status !== 200) { - console.error( - chalk.red(`\nPOST /device/token failed: ${response.status} ${response.statusText}\n`), - ); - process.exit(1); + throw new Error('Device code not yet verified'); } const DeviceCodeSuccessSchema = z.object({ diff --git a/packages/create-catalyst/src/utils/login.ts b/packages/create-catalyst/src/utils/login.ts index 64c0f1d51f..6c303c4f73 100644 --- a/packages/create-catalyst/src/utils/login.ts +++ b/packages/create-catalyst/src/utils/login.ts @@ -1,13 +1,11 @@ /* eslint-disable no-await-in-loop */ -import { confirm, input } from '@inquirer/prompts'; +import { confirm } from '@inquirer/prompts'; import chalk from 'chalk'; import { Https } from './https'; import { spinner } from './spinner'; -const DEVICE_OAUTH_ENABLED = process.env.DEVICE_OAUTH_ENABLED ?? false; - const poll = async (auth: Https, deviceCode: string, interval: number, expiresIn: number) => { const intervalMs = interval * 1000; const expiresAtMs = expiresIn * 1000; @@ -44,34 +42,6 @@ export const login = async ( return { storeHash, accessToken }; } - if (!DEVICE_OAUTH_ENABLED) { - console.log( - [ - `\nPlease create an access token at ${chalk.cyan( - `${bigCommerceAuthUrl}/deep-links/settings/api-accounts/create`, - )} with the following scopes:`, - ` - Content: ${chalk.yellow('modify')}`, - ` - Information & settings: ${chalk.yellow('modify')}`, - ` - Products: ${chalk.yellow('modify')}`, - ` - Carts: ${chalk.yellow('read-only')}`, - ` - Sites & routes: ${chalk.yellow('modify')}`, - ` - Channel settings: ${chalk.yellow('modify')}`, - ` - Storefront API customer impersonation tokens: ${chalk.yellow('manage')}\n`, - ].join('\n'), - ); - - return { - storeHash: await input({ - message: 'Enter your store hash', - validate: (i) => (i.length > 0 ? true : 'Store hash is required'), - }), - accessToken: await input({ - message: 'Enter your access token', - validate: (i) => (i.length > 0 ? true : 'Access token is required'), - }), - }; - } - const auth = new Https({ bigCommerceAuthUrl }); const deviceCode = await auth.getDeviceCode(); @@ -89,8 +59,8 @@ export const login = async ( poll(auth, deviceCode.device_code, deviceCode.interval, deviceCode.expires_in), { text: 'Waiting for device code to be authorized', - successText: 'Device code authorized', - failText: 'Device code expired', + successText: 'Device code authorized\n', + failText: 'Device code expired\n', }, );