Skip to content

Add production-mode flag to app dev command #5694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/co
export type DevSessionCreateMutationVariables = Types.Exact<{
appId: Types.Scalars['String']['input']
assetsUrl: Types.Scalars['String']['input']
productionMode: Types.Scalars['Boolean']['input']
}>

export type DevSessionCreateMutation = {
Expand All @@ -33,6 +34,11 @@ export const DevSessionCreate = {
variable: {kind: 'Variable', name: {kind: 'Name', value: 'assetsUrl'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'String'}}},
},
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'productionMode'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'Boolean'}}},
},
],
selectionSet: {
kind: 'SelectionSet',
Expand All @@ -51,6 +57,11 @@ export const DevSessionCreate = {
name: {kind: 'Name', value: 'assetsUrl'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'assetsUrl'}},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'productionMode'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'productionMode'}},
},
],
selectionSet: {
kind: 'SelectionSet',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/co
export type DevSessionUpdateMutationVariables = Types.Exact<{
appId: Types.Scalars['String']['input']
assetsUrl: Types.Scalars['String']['input']
productionMode: Types.Scalars['Boolean']['input']
}>

export type DevSessionUpdateMutation = {
Expand All @@ -33,6 +34,11 @@ export const DevSessionUpdate = {
variable: {kind: 'Variable', name: {kind: 'Name', value: 'assetsUrl'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'String'}}},
},
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'productionMode'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'Boolean'}}},
},
],
selectionSet: {
kind: 'SelectionSet',
Expand All @@ -51,6 +57,11 @@ export const DevSessionUpdate = {
name: {kind: 'Name', value: 'assetsUrl'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'assetsUrl'}},
},
{
kind: 'Argument',
name: {kind: 'Name', value: 'productionMode'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'productionMode'}},
},
],
selectionSet: {
kind: 'SelectionSet',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutation DevSessionCreate($appId: String!, $assetsUrl: String!) {
devSessionCreate(appId: $appId, assetsUrl: $assetsUrl) {
mutation DevSessionCreate($appId: String!, $assetsUrl: String!, $productionMode: Boolean!) {
devSessionCreate(appId: $appId, assetsUrl: $assetsUrl, productionMode: $productionMode) {
userErrors {
message
on
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutation DevSessionUpdate($appId: String!, $assetsUrl: String!) {
devSessionUpdate(appId: $appId, assetsUrl: $assetsUrl) {
mutation DevSessionUpdate($appId: String!, $assetsUrl: String!, $productionMode: Boolean!) {
devSessionUpdate(appId: $appId, assetsUrl: $assetsUrl, productionMode: $productionMode) {
userErrors {
message
on
Expand Down
7 changes: 7 additions & 0 deletions packages/app/src/cli/commands/app/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ If you're using the Ruby app template, then you need to complete the following s
'Key used to authenticate GraphiQL requests. Should be specified if exposing GraphiQL on a publicly accessible URL. By default, no key is required.',
env: 'SHOPIFY_FLAG_GRAPHIQL_KEY',
}),
'production-mode': Flags.boolean({
hidden: false,
description: 'Run the app in production mode.',
env: 'SHOPIFY_FLAG_PRODUCTION_MODE',
default: false,
}),
}

public static analyticsStopCommand(): string | undefined {
Expand Down Expand Up @@ -212,6 +218,7 @@ If you're using the Ruby app template, then you need to complete the following s
graphiqlPort: flags['graphiql-port'],
graphiqlKey: flags['graphiql-key'],
tunnel,
productionMode: flags['production-mode'],
}

await dev(devOptions)
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/cli/services/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export interface DevOptions {
notify?: string
graphiqlPort?: number
graphiqlKey?: string
productionMode: boolean
}

export async function dev(commandOptions: DevOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface DevSessionProcessOptions {
appPreviewURL: string
appLocalProxyURL: string
devSessionStatusManager: DevSessionStatusManager
productionMode: boolean
}

export interface DevSessionProcess extends BaseProcess<DevSessionProcessOptions> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
shopFqdn: string
appId: string
assetsUrl: string
productionMode: boolean
}

export interface UserError {
Expand Down Expand Up @@ -246,7 +247,12 @@
// Create or update the dev session
if (currentBundleController.signal.aborted) return {status: 'aborted'}
try {
const payload = {shopFqdn: this.options.storeFqdn, appId: this.options.appId, assetsUrl: signedURL}
const payload = {
shopFqdn: this.options.storeFqdn,

Check failure on line 251 in packages/app/src/cli/services/dev/processes/dev-session/dev-session.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/services/dev/processes/dev-session/dev-session.ts#L251

[prettier/prettier] Delete `·`
appId: this.options.appId,

Check failure on line 252 in packages/app/src/cli/services/dev/processes/dev-session/dev-session.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/services/dev/processes/dev-session/dev-session.ts#L252

[prettier/prettier] Delete `·`
assetsUrl: signedURL,
productionMode: this.options.productionMode

Check failure on line 254 in packages/app/src/cli/services/dev/processes/dev-session/dev-session.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/services/dev/processes/dev-session/dev-session.ts#L254

[prettier/prettier] Insert `,`
}
if (this.statusManager.status.isReady) {
return this.devSessionUpdateWithRetry(payload)
} else {
Expand Down Expand Up @@ -290,6 +296,7 @@
* @param payload - The payload to update the dev session with
*/
private async devSessionUpdateWithRetry(payload: DevSessionPayload): Promise<DevSessionResult> {
await this.logger.info(`Dev session update options: ${JSON.stringify(payload)}`)
const result = await performActionWithRetryAfterRecovery(
async () => this.options.developerPlatformClient.devSessionUpdate(payload),
() => this.options.developerPlatformClient.refreshToken(),
Expand All @@ -306,6 +313,7 @@
* @param payload - The payload to create the dev session with
*/
private async devSessionCreateWithRetry(payload: DevSessionPayload): Promise<DevSessionResult> {
await this.logger.info(`Dev session create options: ${JSON.stringify(payload)}`)
const result = await performActionWithRetryAfterRecovery(
async () => this.options.developerPlatformClient.devSessionCreate(payload),
() => this.options.developerPlatformClient.refreshToken(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export async function setupDevProcesses({
appPreviewURL: appPreviewUrl,
appLocalProxyURL: devConsoleURL,
devSessionStatusManager,
productionMode: commandOptions.productionMode,
})
: await setupDraftableExtensionsProcess({
localApp: reloadedApp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
shopFqdn: string
appId: string
assetsUrl: string
productionMode: boolean
}

type WithUserErrors<T> = T & {
Expand Down Expand Up @@ -299,6 +300,6 @@
appDeepLink: (app: MinimalAppIdentifiers) => Promise<string>
devSessionCreate: (input: DevSessionOptions) => Promise<DevSessionCreateMutation>
devSessionUpdate: (input: DevSessionOptions) => Promise<DevSessionUpdateMutation>
devSessionDelete: (input: Omit<DevSessionOptions, 'assetsUrl'>) => Promise<DevSessionDeleteMutation>
devSessionDelete: (input: Omit<DevSessionOptions, 'assetsUrl' | 'productionMode'>) => Promise<DevSessionDeleteMutation>

Check failure on line 303 in packages/app/src/cli/utilities/developer-platform-client.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/utilities/developer-platform-client.ts#L303

[prettier/prettier] Replace `input:·Omit<DevSessionOptions,·'assetsUrl'·|·'productionMode'>` with `⏎····input:·Omit<DevSessionOptions,·'assetsUrl'·|·'productionMode'>,⏎··`
getCreateDevStoreLink: (input: string) => Promise<string>
}
Original file line number Diff line number Diff line change
Expand Up @@ -940,17 +940,17 @@
return appDeepLink({id, organizationId})
}

async devSessionCreate({appId, assetsUrl, shopFqdn}: DevSessionOptions): Promise<DevSessionCreateMutation> {
async devSessionCreate({appId, assetsUrl, shopFqdn, productionMode}: DevSessionOptions): Promise<DevSessionCreateMutation> {

Check failure on line 943 in packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts#L943

[prettier/prettier] Replace `appId,·assetsUrl,·shopFqdn,·productionMode` with `⏎····appId,⏎····assetsUrl,⏎····shopFqdn,⏎····productionMode,⏎··`
const appIdNumber = String(numberFromGid(appId))
return appDevRequest(DevSessionCreate, shopFqdn, await this.token(), {appId: appIdNumber, assetsUrl})
return appDevRequest(DevSessionCreate, shopFqdn, await this.token(), {appId: appIdNumber, assetsUrl, productionMode})

Check failure on line 945 in packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts#L945

[prettier/prettier] Replace `appId:·appIdNumber,·assetsUrl,·productionMode` with `⏎······appId:·appIdNumber,⏎······assetsUrl,⏎······productionMode,⏎····`
}

async devSessionUpdate({appId, assetsUrl, shopFqdn}: DevSessionOptions): Promise<DevSessionUpdateMutation> {
async devSessionUpdate({appId, assetsUrl, shopFqdn, productionMode}: DevSessionOptions): Promise<DevSessionUpdateMutation> {

Check failure on line 948 in packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts#L948

[prettier/prettier] Replace `appId,·assetsUrl,·shopFqdn,·productionMode` with `⏎····appId,⏎····assetsUrl,⏎····shopFqdn,⏎····productionMode,⏎··`
const appIdNumber = String(numberFromGid(appId))
return appDevRequest(DevSessionUpdate, shopFqdn, await this.token(), {appId: appIdNumber, assetsUrl})
return appDevRequest(DevSessionUpdate, shopFqdn, await this.token(), {appId: appIdNumber, assetsUrl, productionMode})

Check failure on line 950 in packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts#L950

[prettier/prettier] Replace `appId:·appIdNumber,·assetsUrl,·productionMode` with `⏎······appId:·appIdNumber,⏎······assetsUrl,⏎······productionMode,⏎····`
}

async devSessionDelete({appId, shopFqdn}: Omit<DevSessionOptions, 'assetsUrl'>): Promise<DevSessionDeleteMutation> {
async devSessionDelete({appId, shopFqdn}: Omit<DevSessionOptions, 'assetsUrl' | 'productionMode'>): Promise<DevSessionDeleteMutation> {

Check failure on line 953 in packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts#L953

[prettier/prettier] Replace `appId,·shopFqdn` with `⏎····appId,⏎····shopFqdn,⏎··`
const appIdNumber = String(numberFromGid(appId))
return appDevRequest(DevSessionDelete, shopFqdn, await this.token(), {appId: appIdNumber})
}
Expand Down
Loading