Skip to content

Commit

Permalink
Get tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkham committed Sep 15, 2023
1 parent ef0d877 commit 652d21e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {DevConfig, setupDevProcesses, startProxyServer} from './setup-dev-processes.js'
import {sendWebhook} from './uninstall-webhook.js'
import {WebProcess} from './web.js'
import {WebProcess, launchWebProcess} from './web.js'
import {PreviewableExtensionProcess, launchPreviewableExtensionProcess} from './previewable-extension.js'
import {GraphiQLServerProcess, launchGraphiQLServer} from './graphiql.js'
import {pushUpdatesForDraftableExtensions} from './draftable-extension.js'
Expand All @@ -11,7 +11,6 @@ import {
testThemeExtensions,
testUIExtension,
} from '../../../models/app/app.test-data.js'
import {launchWebProcess} from '../../dev.js'
import {WebType} from '../../../models/app/app.js'
import {ensureDeploymentIdsPresence} from '../../context/identifiers.js'
import {urlNamespaces} from '../../../constants.js'
Expand Down
72 changes: 71 additions & 1 deletion packages/app/src/cli/services/dev/processes/web.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import {BaseProcess} from './types.js'
import {frontAndBackendConfig} from './utils.js'
import {LaunchWebOptions, launchWebProcess} from '../../dev.js'
import {Web, WebType} from '../../../models/app/app.js'
import {isWebType} from '../../../models/app/loader.js'
import {AbortSignal} from '@shopify/cli-kit/node/abort'
import {isSpinEnvironment, spinFqdn} from '@shopify/cli-kit/node/context/spin'
import {getAvailableTCPPort} from '@shopify/cli-kit/node/tcp'
import {exec} from '@shopify/cli-kit/node/system'
import {Writable} from 'stream'

export interface LaunchWebOptions {
port: number
apiKey: string
apiSecret?: string
hostname?: string
backendPort: number
frontendServerPort?: number
directory: string
devCommand: string
scopes?: string
shopCustomDomain?: string
hmrServerOptions?: {port: number; httpPaths: string[]}
portFromConfig?: number
}

export interface WebProcess extends BaseProcess<LaunchWebOptions> {
type: 'web'
Expand Down Expand Up @@ -84,3 +101,56 @@ async function getWebProcessPort({
return getAvailableTCPPort()
}
}

export async function launchWebProcess(
{stdout, stderr, abortSignal}: {stdout: Writable; stderr: Writable; abortSignal: AbortSignal},
{
port,
apiKey,
apiSecret,
hostname,
backendPort,
frontendServerPort,
directory,
devCommand,
scopes,
shopCustomDomain,
hmrServerOptions,
}: LaunchWebOptions,
) {
const hmrServerPort = hmrServerOptions?.port
const [cmd, ...args] = devCommand.split(' ')

const env = {
SHOPIFY_API_KEY: apiKey,
SHOPIFY_API_SECRET: apiSecret,
HOST: hostname,
SCOPES: scopes,
NODE_ENV: `development`,
...(shopCustomDomain && {
SHOP_CUSTOM_DOMAIN: shopCustomDomain,
}),
BACKEND_PORT: `${backendPort}`,
FRONTEND_PORT: `${frontendServerPort}`,
...(hmrServerPort && {
HMR_SERVER_PORT: `${hmrServerPort}`,
}),
APP_URL: hostname,
APP_ENV: 'development',
// Note: These are Remix-specific variables
REMIX_DEV_ORIGIN: hostname,
}

await exec(cmd!, args, {
cwd: directory,
stdout,
stderr,
signal: abortSignal,
env: {
...env,
PORT: `${port}`,
// Note: These are Laravel variables for backwards compatibility with 2.0 templates.
SERVER_PORT: `${port}`,
},
})
}

0 comments on commit 652d21e

Please sign in to comment.