diff --git a/packages/cli/bin/bundle.js b/packages/cli/bin/bundle.js index 9a467ebf003..6f4c3ac631e 100644 --- a/packages/cli/bin/bundle.js +++ b/packages/cli/bin/bundle.js @@ -47,9 +47,9 @@ const hookEntryPoints = glob.sync('./src/hooks/*.ts', { }) // Build esbuild entry points for app/theme commands so they get bundled into -// the CLI's own dist/ with all imports resolved. This is needed because -// @shopify/app and @shopify/theme are devDependencies (private packages) and -// won't exist as real node_modules in the published snapshot. +// the CLI's own dist/ with all imports resolved. These entrypoints use the +// app/theme dist outputs so package imports and per-command imports share the +// same module graph. const manifest = JSON.parse(readFileSync(joinPath(process.cwd(), 'oclif.manifest.json'), 'utf8')) const commandEntryPointOverrides = { 'app:logs:sources': 'cli/commands/app/app-logs/sources', @@ -58,13 +58,13 @@ const commandEntryPointOverrides = { 'doctor-release': 'cli/commands/doctor-release/doctor-release', 'doctor-release:theme': 'cli/commands/doctor-release/theme/index', } -const externalPackageDirs = {'@shopify/app': '../app/', '@shopify/theme': '../theme/'} +const externalPackageDirs = {'@shopify/app': '../app/dist/', '@shopify/theme': '../theme/dist/'} const externalCommandEntryPoints = Object.entries(manifest.commands) .filter(([, cmd]) => externalPackageDirs[cmd.customPluginName]) .map(([id, cmd]) => { const out = commandEntryPointOverrides[id] ?? `cli/commands/${id.replace(/:/g, '/')}` - const inPath = externalPackageDirs[cmd.customPluginName] + `src/${out}.ts` + const inPath = externalPackageDirs[cmd.customPluginName] + `${out}.js` return {in: inPath, out} }) diff --git a/packages/e2e/setup/env.ts b/packages/e2e/setup/env.ts index b0e7b023e65..4ed7602724e 100644 --- a/packages/e2e/setup/env.ts +++ b/packages/e2e/setup/env.ts @@ -150,6 +150,7 @@ export const envFixture = base.extend<{testSection: void}, {env: E2EEnv}>({ ...xdgEnv, SHOPIFY_CLI_CLOUDFLARED_PATH: cloudflaredPath, SHOPIFY_RUN_AS_USER: '0', + SHOPIFY_CLI_NO_ANALYTICS: '1', NODE_OPTIONS: '', CI: '1', SHOPIFY_CLI_1P_DEV: undefined, diff --git a/packages/e2e/setup/global-auth.ts b/packages/e2e/setup/global-auth.ts index 739cebccbd5..31403aed304 100644 --- a/packages/e2e/setup/global-auth.ts +++ b/packages/e2e/setup/global-auth.ts @@ -52,6 +52,7 @@ export default async function globalSetup() { ...process.env, ...xdgEnv, SHOPIFY_RUN_AS_USER: '0', + SHOPIFY_CLI_NO_ANALYTICS: '1', NODE_OPTIONS: '', CI: '1', SHOPIFY_CLI_1P_DEV: undefined, diff --git a/packages/e2e/tests/app-deploy.spec.ts b/packages/e2e/tests/app-deploy.spec.ts index 9637c94a2bb..5ef2dce1bc5 100644 --- a/packages/e2e/tests/app-deploy.spec.ts +++ b/packages/e2e/tests/app-deploy.spec.ts @@ -2,6 +2,7 @@ import {appTestFixture as test, createApp, deployApp, versionsList, configLink} import {teardownAll} from '../setup/teardown.js' import {TEST_TIMEOUT} from '../setup/constants.js' import {requireEnv} from '../setup/env.js' +import {stripAnsi} from '../helpers/strip-ansi.js' import {expect} from '@playwright/test' import * as fs from 'fs' // eslint-disable-next-line no-restricted-imports @@ -30,6 +31,13 @@ interface VersionLine { status: string } +function assertDeployAnalytics(opts: {output: string; appName: string; step: string}) { + const output = stripAnsi(opts.output) + expect(output, `${opts.step} - expected deploy analytics command`).toContain('"command": "app deploy"') + expect(output, `${opts.step} - expected deploy analytics success`).toContain('"success": true') + expect(output, `${opts.step} - expected deploy analytics app name`).toContain(`"app_name": "${opts.appName}"`) +} + /** * Asserts a `versions list --json` result shows: * - `expectedTag` is present and `active` @@ -85,9 +93,26 @@ test.describe('App deploy', () => { // Step 2: Deploy with a tagged version const versionTag = `E2E-v1-${Date.now()}` - const deployResult = await deployApp({cli, appDir, version: versionTag, message: 'E2E A primary deployment'}) + const deployResult = await cli.exec( + [ + 'app', + 'deploy', + '--version', + versionTag, + '--message', + 'E2E A primary deployment', + '--allow-updates', + '--path', + appDir, + ], + { + env: {SHOPIFY_FLAG_VERBOSE: '1'}, + timeout: TEST_TIMEOUT.long, + }, + ) const deployOutput = deployResult.stdout + deployResult.stderr expect(deployResult.exitCode, `Step 2 - deploy failed:\n${deployOutput}`).toBe(0) + assertDeployAnalytics({output: deployOutput, appName, step: 'Step 2'}) // Step 3: Verify the primary tag is active and no other version is stuck active. const listResult = await versionsList({cli, appDir})