Skip to content

Commit

Permalink
Fix circular dependency loading issue
Browse files Browse the repository at this point in the history
  • Loading branch information
amcaplan committed Aug 19, 2024
1 parent af41708 commit 59ca4e6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 33 deletions.
3 changes: 2 additions & 1 deletion packages/cli-kit/src/public/node/hooks/prerun.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {CLI_KIT_VERSION} from '../../common/version.js'
import {checkForNewVersion, checkForCachedNewVersion} from '../node-package-manager.js'
import {startAnalytics} from '../../../private/node/analytics.js'
import {outputDebug, outputWarn, getOutputUpdateCLIReminder} from '../../../public/node/output.js'
import {outputDebug, outputWarn} from '../../../public/node/output.js'
import {getOutputUpdateCLIReminder} from '../../../public/node/upgrade.js'
import Command from '../../../public/node/base-command.js'
import {initDemoRecorder} from '../../../private/node/demo-recorder.js'
import {runAtMinimumInterval} from '../../../private/node/conf-store.js'
Expand Down
32 changes: 2 additions & 30 deletions packages/cli-kit/src/public/node/output.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import {isUnitTest, isVerbose} from './context/local.js'
import {PackageManager, packageManagerFromUserAgent} from './node-package-manager.js'
import {currentProcessIsGlobal, inferPackageManagerForGlobalCLI} from './is-global.js'
import {PackageManager} from './node-package-manager.js'
import {currentProcessIsGlobal} from './is-global.js'
import {AbortSignal} from './abort.js'
import colors from './colors.js'
import {isTruthy} from './context/utilities.js'
Expand Down Expand Up @@ -459,34 +459,6 @@ export function shouldDisplayColors(_process = process): boolean {
}
}

/**
* Utility function for generating an install command for the user to run
* to install an updated version of Shopify CLI.
* @returns A string with the command to run.
*/
export function cliInstallCommand(): string {
const isGlobal = currentProcessIsGlobal()
let packageManager = packageManagerFromUserAgent() ?? inferPackageManagerForGlobalCLI()
if (packageManager === 'unknown') packageManager = 'npm'

if (packageManager === 'yarn') {
return `yarn ${isGlobal ? 'global ' : ''}add @shopify/cli@latest`
} else {
return `${packageManager} i ${isGlobal ? '-g ' : ''}@shopify/cli@latest`
}
}

/**
* Generates a message to remind the user to update the CLI.
*
* @param version - The version to update to.
* @returns The message to remind the user to update the CLI.
*/
export function getOutputUpdateCLIReminder(version: string): string {
return outputContent`💡 Version ${version} available! Run ${outputToken.genericShellCommand(cliInstallCommand())}`
.value
}

/**
* Parse title and body to be a single formatted string.
*
Expand Down
31 changes: 31 additions & 0 deletions packages/cli-kit/src/public/node/upgrade.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {currentProcessIsGlobal, inferPackageManagerForGlobalCLI} from './is-global.js'
import {packageManagerFromUserAgent} from './node-package-manager.js'
import {outputContent, outputToken} from './output.js'

/**
* Utility function for generating an install command for the user to run
* to install an updated version of Shopify CLI.
* @returns A string with the command to run.
*/
export function cliInstallCommand(): string {
const isGlobal = currentProcessIsGlobal()
let packageManager = packageManagerFromUserAgent() ?? inferPackageManagerForGlobalCLI()
if (packageManager === 'unknown') packageManager = 'npm'

if (packageManager === 'yarn') {
return `yarn ${isGlobal ? 'global ' : ''}add @shopify/cli@latest`
} else {
return `${packageManager} i ${isGlobal ? '-g ' : ''}@shopify/cli@latest`
}
}

/**
* Generates a message to remind the user to update the CLI.
*
* @param version - The version to update to.
* @returns The message to remind the user to update the CLI.
*/
export function getOutputUpdateCLIReminder(version: string): string {
return outputContent`💡 Version ${version} available! Run ${outputToken.genericShellCommand(cliInstallCommand())}`
.value
}
2 changes: 1 addition & 1 deletion packages/cli/src/cli/commands/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {cliInstallCommand} from '@shopify/cli-kit/node/output'
import {cliInstallCommand} from '@shopify/cli-kit/node/upgrade'
import Command from '@shopify/cli-kit/node/base-command'
import {renderInfo} from '@shopify/cli-kit/node/ui'

Expand Down
3 changes: 2 additions & 1 deletion packages/theme/src/cli/services/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {themeEditorUrl, themePreviewUrl} from '@shopify/cli-kit/node/themes/urls
import {Theme} from '@shopify/cli-kit/node/themes/types'
import {AdminSession} from '@shopify/cli-kit/node/session'
import {linesToColumns} from '@shopify/cli-kit/common/string'
import {OutputMessage, formatSection, getOutputUpdateCLIReminder} from '@shopify/cli-kit/node/output'
import {OutputMessage, formatSection} from '@shopify/cli-kit/node/output'
import {getOutputUpdateCLIReminder} from '@shopify/cli-kit/node/upgrade'

interface ThemeInfo {
theme: {
Expand Down

0 comments on commit 59ca4e6

Please sign in to comment.