Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modern-coins-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli-kit': minor
---

Only use custom cli-hydrogen package in CLI development environments
43 changes: 23 additions & 20 deletions packages/cli-kit/src/public/node/custom-oclif-loader.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
import {fileExistsSync} from './fs.js'
import {cwd, joinPath, sniffForPath} from './path.js'
import {isDevelopment} from './context/local.js'
import {execaSync} from 'execa'
import {Command, Config} from '@oclif/core'
import {Options} from '@oclif/core/interfaces'

export class ShopifyConfig extends Config {
constructor(options: Options) {
const currentPath = cwd()
if (isDevelopment()) {
const currentPath = cwd()

let path = sniffForPath() ?? currentPath
// Hydrogen CI uses `hydrogen/hydrogen` path, while local dev uses `shopify/hydrogen`.
const currentPathMightBeHydrogenMonorepo = /(shopify|hydrogen)\/hydrogen/i.test(currentPath)
const ignoreHydrogenMonorepo = process.env.IGNORE_HYDROGEN_MONOREPO
if (currentPathMightBeHydrogenMonorepo && !ignoreHydrogenMonorepo) {
path = execaSync('npm', ['prefix']).stdout.trim()
}
if (fileExistsSync(joinPath(path, 'package.json'))) {
// Hydrogen is bundled, but we still want to support loading it as an external plugin for two reasons:
// 1. To allow users to use an older version of Hydrogen. (to not force upgrades)
// 2. To allow the Hydrogen team to load a local version for testing.
options.pluginAdditions = {
core: ['@shopify/cli-hydrogen'],
path,
let path = sniffForPath() ?? currentPath
// Hydrogen CI uses `hydrogen/hydrogen` path, while local dev uses `shopify/hydrogen`.
const currentPathMightBeHydrogenMonorepo = /(shopify|hydrogen)\/hydrogen/i.test(currentPath)
const ignoreHydrogenMonorepo = process.env.IGNORE_HYDROGEN_MONOREPO
if (currentPathMightBeHydrogenMonorepo && !ignoreHydrogenMonorepo) {
path = execaSync('npm', ['prefix']).stdout.trim()
}
}
super(options)
if (fileExistsSync(joinPath(path, 'package.json'))) {
// Hydrogen is bundled, but we still want to support loading it as an external plugin for two reasons:
// 1. To allow users to use an older version of Hydrogen. (to not force upgrades)
// 2. To allow the Hydrogen team to load a local version for testing.
options.pluginAdditions = {
core: ['@shopify/cli-hydrogen'],
path,
}
}
super(options)

// @ts-expect-error: This is a private method that we are overriding. OCLIF doesn't provide a way to extend it.
// eslint-disable-next-line @typescript-eslint/unbound-method
this.determinePriority = this.customPriority
// @ts-expect-error: This is a private method that we are overriding. OCLIF doesn't provide a way to extend it.
// eslint-disable-next-line @typescript-eslint/unbound-method
this.determinePriority = this.customPriority
}
}

customPriority(commands: Command.Loadable[]): Command.Loadable | undefined {
Expand Down