Skip to content

Commit ed0a5b4

Browse files
Default to pnpm/pnpx internally
1 parent 3bc44af commit ed0a5b4

11 files changed

Lines changed: 85 additions & 39 deletions

File tree

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ jobs:
7171
> If the versions don't match, you might have multiple global instances installed.
7272
7373
> Use `which shopify` to find out which one you are running and uninstall it."
74-
comment_package_manager: 'npm'
7574
comment_command_flags: '--@shopify:registry=https://registry.npmjs.org'
7675
build_script: "node bin/update-cli-kit-version.js && pnpm nx run-many --target=bundle --all --skip-nx-cache --output-style=stream && pnpm refresh-manifests"
7776
env:

.github/workflows/tests-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ jobs:
234234
- name: Build
235235
run: pnpm nx run-many --all --skip-nx-cache --target=build --output-style=stream
236236
- name: Install Playwright Chromium
237-
run: npx playwright install chromium
237+
run: pnpm exec playwright install chromium
238238
working-directory: packages/e2e
239239
- name: Rebuild node-pty
240240
run: pnpm rebuild node-pty
@@ -247,7 +247,7 @@ jobs:
247247
E2E_STORE_FQDN: ${{ secrets.E2E_STORE_FQDN }}
248248
E2E_SECONDARY_CLIENT_ID: ${{ secrets.E2E_SECONDARY_CLIENT_ID }}
249249
E2E_ORG_ID: ${{ secrets.E2E_ORG_ID }}
250-
run: npx playwright test
250+
run: pnpm exec playwright test
251251
- name: Upload Playwright report
252252
uses: actions/upload-artifact@v4
253253
if: ${{ !cancelled() }}

bin/create-notification-pr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async function createPR() {
6565
'**Please update the release highlights before merging.**',
6666
'',
6767
'### How to test',
68-
'- `npx http-server ~/src/github.com/Shopify/static-cdn-assets`',
68+
'- `pnpx http-server ~/src/github.com/Shopify/static-cdn-assets`',
6969
'- `SHOPIFY_CLI_NOTIFICATIONS_URL=http://127.0.0.1:8080/static-24h/cli/notifications.json shopify version`',
7070
"- You may need to clear the CLI cache with `shopify cache clear` and run the command twice to see the notification (it's fetched in the background).",
7171
'',

bin/docs/build-dev-docs.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
echo "STARTING"
2-
COMPILE_DOCS="npx tsc --project bin/docs/tsconfig.docs.json --moduleResolution node --target esNext && npx generate-docs --overridePath ./bin/docs/typeOverride.json --input ./docs-shopify.dev/commands --output ./docs-shopify.dev/generated && rm -rf docs-shopify.dev/commands/**/*.doc.js docs-shopify.dev/commands/*.doc.js"
3-
COMPILE_STATIC_PAGES="npx tsc docs-shopify.dev/static/*.doc.ts --moduleResolution node --target esNext && npx generate-docs --isLandingPage --input ./docs-shopify.dev/static --output ./docs-shopify.dev/generated && rm -rf docs-shopify.dev/static/*.doc.js"
4-
COMPILE_CATEGORY_PAGES="npx tsc docs-shopify.dev/categories/*.doc.ts --moduleResolution node --target esNext && generate-docs --isCategoryPage --input ./docs-shopify.dev/categories --output ./docs-shopify.dev/generated && rm -rf docs-shopify.dev/categories/*.doc.js"
2+
COMPILE_DOCS="pnpx tsc --project bin/docs/tsconfig.docs.json --moduleResolution node --target esNext && pnpx generate-docs --overridePath ./bin/docs/typeOverride.json --input ./docs-shopify.dev/commands --output ./docs-shopify.dev/generated && rm -rf docs-shopify.dev/commands/**/*.doc.js docs-shopify.dev/commands/*.doc.js"
3+
COMPILE_STATIC_PAGES="pnpx tsc docs-shopify.dev/static/*.doc.ts --moduleResolution node --target esNext && pnpx generate-docs --isLandingPage --input ./docs-shopify.dev/static --output ./docs-shopify.dev/generated && rm -rf docs-shopify.dev/static/*.doc.js"
4+
COMPILE_CATEGORY_PAGES="pnpx tsc docs-shopify.dev/categories/*.doc.ts --moduleResolution node --target esNext && pnpx generate-docs --isCategoryPage --input ./docs-shopify.dev/categories --output ./docs-shopify.dev/generated && rm -rf docs-shopify.dev/categories/*.doc.js"
55

66
if [ "$1" = "isTest" ];
77
then
8-
COMPILE_DOCS="npx tsc --project bin/docs/tsconfig.docs.json --moduleResolution node --target esNext && npx generate-docs --overridePath ./bin/docs/typeOverride.json --input ./docs-shopify.dev/commands --output ./docs-shopify.dev/static/temp && rm -rf docs-shopify.dev/commands/**/*.doc.js docs-shopify.dev/commands/*.doc.js"
9-
COMPILE_STATIC_PAGES="npx tsc docs-shopify.dev/static/*.doc.ts --moduleResolution node --target esNext && npx generate-docs --isLandingPage --input ./docs-shopify.dev/static/docs-shopify.dev --output ./docs-shopify.dev/static/temp && rm -rf docs-shopify.dev/static/*.doc.js"
8+
COMPILE_DOCS="pnpx tsc --project bin/docs/tsconfig.docs.json --moduleResolution node --target esNext && pnpx generate-docs --overridePath ./bin/docs/typeOverride.json --input ./docs-shopify.dev/commands --output ./docs-shopify.dev/static/temp && rm -rf docs-shopify.dev/commands/**/*.doc.js docs-shopify.dev/commands/*.doc.js"
9+
COMPILE_STATIC_PAGES="pnpx tsc docs-shopify.dev/static/*.doc.ts --moduleResolution node --target esNext && pnpx generate-docs --isLandingPage --input ./docs-shopify.dev/static/docs-shopify.dev --output ./docs-shopify.dev/static/temp && rm -rf docs-shopify.dev/static/*.doc.js"
1010
fi
1111

1212
echo $1

dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ up:
2323
meet: 'true'
2424
- custom:
2525
name: 'Install Playwright Chromium'
26-
met?: cd packages/e2e && npx playwright install chromium
26+
met?: cd packages/e2e && pnpx playwright install chromium
2727
meet: 'true'
2828
- custom:
2929
name: 'Rebuild node-pty'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"bundle-for-release": "nx run-many --target=bundle --all --skip-nx-cache",
1111
"changeset-manifests": "changeset version && pnpm install --no-frozen-lockfile && pnpm refresh-manifests && pnpm refresh-readme && pnpm refresh-code-documentation && bin/update-cli-kit-version.js",
1212
"clean": "nx run-many --target=clean --all --skip-nx-cache && nx reset",
13-
"create-app": "nx build create-app && node packages/create-app/bin/dev.js --package-manager npm",
13+
"create-app": "nx build create-app && node packages/create-app/bin/dev.js --package-manager pnpm",
1414
"deploy-experimental": "node bin/deploy-experimental.js",
1515
"graph": "nx graph",
1616
"graphql-codegen:get-graphql-schemas": "bin/get-graphql-schemas.js",

packages/app/src/cli/services/function/build.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ import {
2121
} from './binaries.js'
2222
import {testApp, testFunctionExtension} from '../../models/app/app.test-data.js'
2323
import {beforeEach, describe, expect, test, vi} from 'vitest'
24+
import {getPackageManager} from '@shopify/cli-kit/node/node-package-manager'
2425
import {exec} from '@shopify/cli-kit/node/system'
2526
import {dirname, joinPath} from '@shopify/cli-kit/node/path'
2627
import {inTemporaryDirectory, mkdir, readFileSync, writeFile, removeFile} from '@shopify/cli-kit/node/fs'
2728
import {build as esBuild} from 'esbuild'
2829

2930
vi.mock('@shopify/cli-kit/node/fs')
3031
vi.mock('@shopify/cli-kit/node/system')
32+
vi.mock('@shopify/cli-kit/node/node-package-manager', async (importOriginal) => {
33+
const actual = await importOriginal<typeof import('@shopify/cli-kit/node/node-package-manager')>()
34+
return {
35+
...actual,
36+
getPackageManager: vi.fn(),
37+
}
38+
})
3139

3240
vi.mock('./binaries.js', async (importOriginal) => {
3341
const actual: any = await importOriginal()
@@ -76,6 +84,7 @@ beforeEach(async () => {
7684
stderr = {write: vi.fn()}
7785
stdout = {write: vi.fn()}
7886
signal = vi.fn()
87+
vi.mocked(getPackageManager).mockResolvedValue('npm')
7988
})
8089

8190
describe('buildGraphqlTypes', () => {
@@ -95,6 +104,34 @@ describe('buildGraphqlTypes', () => {
95104
})
96105
})
97106

107+
test('generate types uses pnpm exec when package manager is pnpm', {timeout: 20000}, async () => {
108+
vi.mocked(getPackageManager).mockResolvedValueOnce('pnpm')
109+
const ourFunction = await testFunctionExtension({entryPath: 'src/index.js'})
110+
111+
const got = buildGraphqlTypes(ourFunction, {stdout, stderr, signal, app})
112+
113+
await expect(got).resolves.toBeUndefined()
114+
expect(exec).toHaveBeenCalledWith('pnpm', ['exec', '--', 'graphql-code-generator', '--config', 'package.json'], {
115+
cwd: ourFunction.directory,
116+
stderr,
117+
signal,
118+
})
119+
})
120+
121+
test('generate types uses yarn without exec subcommand when package manager is yarn', {timeout: 20000}, async () => {
122+
vi.mocked(getPackageManager).mockResolvedValueOnce('yarn')
123+
const ourFunction = await testFunctionExtension({entryPath: 'src/index.js'})
124+
125+
const got = buildGraphqlTypes(ourFunction, {stdout, stderr, signal, app})
126+
127+
await expect(got).resolves.toBeUndefined()
128+
expect(exec).toHaveBeenCalledWith('yarn', ['--', 'graphql-code-generator', '--config', 'package.json'], {
129+
cwd: ourFunction.directory,
130+
stderr,
131+
signal,
132+
})
133+
})
134+
98135
test('errors if function is not a JS function and no typegen_command', async () => {
99136
// Given
100137
const ourFunction = await testFunctionExtension()

packages/app/src/cli/services/function/build.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {renderTasks} from '@shopify/cli-kit/node/ui'
2424
import {pickBy} from '@shopify/cli-kit/common/object'
2525
import {runWithTimer} from '@shopify/cli-kit/node/metadata'
2626
import {AbortError} from '@shopify/cli-kit/node/error'
27+
import {getPackageManager} from '@shopify/cli-kit/node/node-package-manager'
2728
import {Writable} from 'stream'
2829

2930
export const PREFERRED_FUNCTION_NPM_PACKAGE_MAJOR_VERSION = '2'
@@ -144,7 +145,12 @@ export async function buildGraphqlTypes(
144145
}
145146

146147
return runWithTimer('cmd_all_timing_network_ms')(async () => {
147-
return exec('npm', ['exec', '--', 'graphql-code-generator', '--config', 'package.json'], {
148+
const packageManager = await getPackageManager(fun.directory)
149+
const execArgs = ['--', 'graphql-code-generator', '--config', 'package.json']
150+
if (packageManager !== 'yarn') {
151+
execArgs.unshift('exec')
152+
}
153+
return exec(packageManager, execArgs, {
148154
cwd: fun.directory,
149155
stderr: options.stderr,
150156
signal: options.signal,

packages/e2e/scripts/cleanup-test-apps.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Deletes all test apps from the dev dashboard via browser automation.
3-
* Run: npx tsx packages/e2e/scripts/cleanup-test-apps.ts
3+
* Run: pnpx tsx packages/e2e/scripts/cleanup-test-apps.ts
44
*
55
* Pass --dry-run to list apps without deleting.
66
* Pass --filter <pattern> to only delete apps matching the pattern.
@@ -128,15 +128,18 @@ async function main() {
128128
await page.waitForTimeout(2000)
129129

130130
// Check for 500 error and retry
131-
const pageText = await page.textContent('body') ?? ''
131+
const pageText = (await page.textContent('body')) ?? ''
132132
if (pageText.includes('500') || pageText.includes('Internal Server Error')) {
133133
console.log('Got 500 error, retrying...')
134134
await page.reload({waitUntil: 'domcontentloaded'})
135135
await page.waitForTimeout(3000)
136136
}
137137

138138
// Check for org selection page
139-
const orgLink = page.locator('a, button').filter({hasText: /core-build|cli-e2e/i}).first()
139+
const orgLink = page
140+
.locator('a, button')
141+
.filter({hasText: /core-build|cli-e2e/i})
142+
.first()
140143
if (await orgLink.isVisible({timeout: 3000}).catch(() => false)) {
141144
console.log('Org selection detected, clicking...')
142145
await orgLink.click()

packages/e2e/scripts/create-test-apps.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Creates test apps in the authenticated org and prints their client IDs.
3-
* Run: npx tsx packages/e2e/scripts/create-test-apps.ts
3+
* Run: pnpx tsx packages/e2e/scripts/create-test-apps.ts
44
*/
55

66
import * as fs from 'fs'
@@ -39,7 +39,7 @@ if (!email || !password) {
3939
}
4040

4141
const baseEnv: Record<string, string> = {
42-
...process.env as Record<string, string>,
42+
...(process.env as Record<string, string>),
4343
NODE_OPTIONS: '',
4444
SHOPIFY_RUN_AS_USER: '0',
4545
FORCE_COLOR: '0',
@@ -86,16 +86,16 @@ async function createAppInteractive(tmpDir: string, appName: string): Promise<st
8686
fs.mkdirSync(appDir)
8787

8888
const nodePty = await import('node-pty')
89-
const pty = nodePty.spawn('node', [
90-
createAppPath,
91-
'--name', appName,
92-
'--path', appDir,
93-
'--template', 'none',
94-
'--package-manager', 'npm',
95-
'--local',
96-
], {
97-
name: 'xterm-color', cols: 120, rows: 30, env: baseEnv,
98-
})
89+
const pty = nodePty.spawn(
90+
'node',
91+
[createAppPath, '--name', appName, '--path', appDir, '--template', 'none', '--package-manager', 'pnpm', '--local'],
92+
{
93+
name: 'xterm-color',
94+
cols: 120,
95+
rows: 30,
96+
env: baseEnv,
97+
},
98+
)
9999

100100
let output = ''
101101
pty.onData((data: string) => {
@@ -104,11 +104,7 @@ async function createAppInteractive(tmpDir: string, appName: string): Promise<st
104104
})
105105

106106
// Answer each interactive prompt as it appears
107-
const prompts = [
108-
'Which organization',
109-
'Create this project as a new app',
110-
'App name',
111-
]
107+
const prompts = ['Which organization', 'Create this project as a new app', 'App name']
112108
for (const prompt of prompts) {
113109
try {
114110
await waitForText(() => output, prompt, 60_000)
@@ -130,9 +126,7 @@ async function createAppInteractive(tmpDir: string, appName: string): Promise<st
130126

131127
// Find the app dir and extract client_id
132128
const entries = fs.readdirSync(appDir, {withFileTypes: true})
133-
const created = entries.find(
134-
(e) => e.isDirectory() && fs.existsSync(path.join(appDir, e.name, 'shopify.app.toml')),
135-
)
129+
const created = entries.find((e) => e.isDirectory() && fs.existsSync(path.join(appDir, e.name, 'shopify.app.toml')))
136130
if (!created) throw new Error(`No app directory found in ${appDir}`)
137131

138132
const tomlPath = path.join(appDir, created.name, 'shopify.app.toml')
@@ -147,11 +141,16 @@ async function oauthLogin() {
147141
const nodePty = await import('node-pty')
148142
const spawnEnv = {...baseEnv, BROWSER: 'none'}
149143
const pty = nodePty.spawn('node', [cliPath, 'auth', 'login'], {
150-
name: 'xterm-color', cols: 120, rows: 30, env: spawnEnv,
144+
name: 'xterm-color',
145+
cols: 120,
146+
rows: 30,
147+
env: spawnEnv,
151148
})
152149

153150
let output = ''
154-
pty.onData((data: string) => { output += data })
151+
pty.onData((data: string) => {
152+
output += data
153+
})
155154

156155
await waitForText(() => output, 'Press any key to open the login page', 30_000)
157156
pty.write(' ')
@@ -169,7 +168,9 @@ async function oauthLogin() {
169168
await completeLogin(page, urlMatch[0], email!, password!)
170169

171170
await waitForText(() => output, 'Logged in', 60_000)
172-
try { pty.kill() } catch {}
171+
try {
172+
pty.kill()
173+
} catch {}
173174
await browser.close()
174175
}
175176

0 commit comments

Comments
 (0)