diff --git a/src/constants/store.ts b/src/constants/store.ts index 85afcbd..3b5240d 100644 --- a/src/constants/store.ts +++ b/src/constants/store.ts @@ -9,6 +9,7 @@ export type NextUIComponentsMap = Record; export type Store = { debug: boolean; + beta: boolean; cliLatestVersion: string; latestVersion: string; betaVersion: string; diff --git a/src/index.ts b/src/index.ts index c5a5880..ad2be38 100644 --- a/src/index.ts +++ b/src/index.ts @@ -156,6 +156,7 @@ nextui.hook('preAction', async (command) => { initCache(noCache); // Init debug store.debug = debug; + store.beta = options.includes('-b') || options.includes('--beta'); if (args && commandList.includes(args as CommandName)) { // Before run the command init the components.json diff --git a/src/scripts/helpers.ts b/src/scripts/helpers.ts index 3276ba4..f4f5ece 100644 --- a/src/scripts/helpers.ts +++ b/src/scripts/helpers.ts @@ -10,7 +10,7 @@ import ora, {oraPromise} from 'ora'; import {Logger} from '@helpers/logger'; import {COMPONENTS_PATH} from 'src/constants/path'; -import {getStore} from 'src/constants/store'; +import {getStore, getStoreSync} from 'src/constants/store'; import {getPackageVersion} from './cache/cache'; @@ -147,7 +147,7 @@ export async function autoUpdateComponents(latestVersion?: string, betaVersion?: const [components, betaComponents] = await Promise.all([ downloadFile(url), - downloadFile(getUnpkgUrl(betaVersion), false) + getStoreSync('beta') ? downloadFile(getUnpkgUrl(betaVersion), false) : Promise.resolve([]) ]); const filterMissingComponents = betaComponents.filter( @@ -201,9 +201,9 @@ export async function downloadFile(url: string, log = true): Promise log && Logger.prefix('error', `Update components data error: ${error}`); process.exit(1); }, - successText: (() => { - return chalk.greenBright('Components data updated successfully!\n'); - })(), + successText() { + return log ? chalk.greenBright('Components data updated successfully!\n') : ''; + }, text: 'Fetching components data...' } );