Skip to content

Commit

Permalink
Merge pull request #426 from Shopify/fix-local-package-resolution-for…
Browse files Browse the repository at this point in the history
…-ngrok-plugin

Resolve @shopify/plugin-ngrok locally
  • Loading branch information
amcaplan committed Sep 6, 2022
2 parents da0da65 + 2761545 commit 4265aec
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions packages/create-app/src/utils/template/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,11 @@ export async function updateCLIDependencies({
packageJSON.dependencies['@shopify/app'] = cliKitVersion

if (local) {
// CLI path
const cliAbsolutePath = (await path.findUp('packages/cli-main', {
type: 'directory',
cwd: moduleDirectory,
})) as string
const cliPath = `file:${cliAbsolutePath}`

// App path
const appAbsolutePath = (await path.findUp('packages/app', {type: 'directory', cwd: moduleDirectory})) as string
const appPath = `file:${appAbsolutePath}`

// CLI Kit path
const cliKitAbsolutePath = (await path.findUp('packages/cli-kit', {
type: 'directory',
cwd: moduleDirectory,
})) as string
const cliKitPath = `file:${cliKitAbsolutePath}`

// UI Extensions CLI path
const extensionsCliAbsolutePath = (await path.findUp('packages/ui-extensions-cli', {
type: 'directory',
cwd: moduleDirectory,
})) as string
const extensionsCliPath = `file:${extensionsCliAbsolutePath}`
const cliPath = await packagePath('cli-main')
const appPath = await packagePath('app')
const cliKitPath = await packagePath('cli-kit')
const uiExtensionsCliPath = await packagePath('ui-extensions-cli')
const pluginNgrokPath = await packagePath('plugin-ngrok')

// eslint-disable-next-line require-atomic-updates
packageJSON.dependencies['@shopify/cli'] = cliPath
Expand All @@ -55,7 +36,8 @@ export async function updateCLIDependencies({
'@shopify/cli': cliPath,
'@shopify/app': appPath,
'@shopify/cli-kit': cliKitPath,
'@shopify/shopify-cli-extensions': extensionsCliPath,
'@shopify/shopify-cli-extensions': uiExtensionsCliPath,
'@shopify/plugin-ngrok': pluginNgrokPath,
}

packageJSON.overrides = packageJSON.overrides
Expand All @@ -70,6 +52,14 @@ export async function updateCLIDependencies({
return packageJSON
}

async function packagePath(packageName: string): Promise<string> {
const packageAbsolutePath = (await path.findUp(`packages/${packageName}`, {
type: 'directory',
cwd: path.moduleDirectory(import.meta.url),
})) as string
return `file:${packageAbsolutePath}`
}

export async function getDeepInstallNPMTasks({
from,
packageManager,
Expand Down

0 comments on commit 4265aec

Please sign in to comment.