Skip to content

Commit e987aba

Browse files
authored
Merge pull request #6574 from Shopify/fix-invalid-json-parsing-issue-take-2
Only use custom cli-hydrogen package in development
2 parents 0314e56 + c30af25 commit e987aba

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

.changeset/modern-coins-cross.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/cli-kit': minor
3+
---
4+
5+
Only use custom cli-hydrogen package in CLI development environments

packages/cli-kit/src/public/node/custom-oclif-loader.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
import {fileExistsSync} from './fs.js'
22
import {cwd, joinPath, sniffForPath} from './path.js'
3+
import {isDevelopment} from './context/local.js'
34
import {execaSync} from 'execa'
45
import {Command, Config} from '@oclif/core'
56
import {Options} from '@oclif/core/interfaces'
67

78
export class ShopifyConfig extends Config {
89
constructor(options: Options) {
9-
const currentPath = cwd()
10+
if (isDevelopment()) {
11+
const currentPath = cwd()
1012

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

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

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

0 commit comments

Comments
 (0)