Skip to content

Commit

Permalink
Merge pull request Shopify#1903 from Shopify/remove-label
Browse files Browse the repository at this point in the history
Remove label prompt
  • Loading branch information
matteodepalo authored May 4, 2023
2 parents 35b25ab + 6f3e986 commit 1978fb2
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 143 deletions.
7 changes: 0 additions & 7 deletions packages/app/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@
"description": "Deploy without asking for confirmation.",
"hidden": false,
"allowNo": false
},
"label": {
"name": "label",
"type": "option",
"description": "The deployment label. Will be shown in the Partners Dashboard.",
"hidden": true,
"multiple": false
}
},
"args": {}
Expand Down
13 changes: 2 additions & 11 deletions packages/app/src/cli/api/graphql/create_deployment.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import {gql} from 'graphql-request'

export const CreateDeployment = gql`
mutation CreateDeployment(
$apiKey: String!
$uuid: String!
$bundleUrl: String
$extensions: [ExtensionSettings!]
$label: String
) {
deploymentCreate(
input: {apiKey: $apiKey, uuid: $uuid, bundleUrl: $bundleUrl, extensions: $extensions, label: $label}
) {
mutation CreateDeployment($apiKey: String!, $uuid: String!, $bundleUrl: String, $extensions: [ExtensionSettings!]) {
deploymentCreate(input: {apiKey: $apiKey, uuid: $uuid, bundleUrl: $bundleUrl, extensions: $extensions}) {
deployment {
uuid
id
Expand Down Expand Up @@ -44,7 +36,6 @@ export interface CreateDeploymentVariables {
uuid: string
bundleUrl?: string
extensions?: ExtensionSettings[]
label?: string
}

export interface CreateDeploymentSchema {
Expand Down
8 changes: 1 addition & 7 deletions packages/app/src/cli/commands/app/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ export default class Deploy extends Command {
char: 'f',
default: false,
}),
label: Flags.string({
// we can make this visible once we've rolled out unified deployments
hidden: true,
description: 'The deployment label. Will be shown in the Partners Dashboard.',
env: 'SHOPIFY_FLAG_LABEL',
}),
}

async run(): Promise<void> {
Expand All @@ -49,6 +43,6 @@ export default class Deploy extends Command {

const specifications = await loadExtensionsSpecifications(this.config)
const app: AppInterface = await loadApp({specifications, directory: flags.path})
await deploy({app, apiKey: flags['api-key'], reset: flags.reset, force: flags.force, label: flags.label})
await deploy({app, apiKey: flags['api-key'], reset: flags.reset, force: flags.force})
}
}
89 changes: 0 additions & 89 deletions packages/app/src/cli/services/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,93 +208,6 @@ describe('deploy', () => {
expect(fetchAppExtensionRegistrations).toHaveBeenCalledOnce()
})

test('passes a label to the deployment mutation', async () => {
// Given
const uiExtension = await testUIExtension({type: 'web_pixel_extension'})
const app = testApp({
extensions: {ui: [uiExtension], theme: [], function: []},
})
vi.mocked(renderTextPrompt).mockResolvedValue('Deployed from CLI')

// When
await testDeployBundle(app, {
id: 'app-id',
organizationId: 'org-id',
title: 'app-title',
grantedScopes: [],
betas: {unifiedAppDeployment: true},
})

// Then
expect(uploadExtensionsBundle).toHaveBeenCalledWith(
expect.objectContaining({
label: 'Deployed from CLI',
}),
)
})

test("doesn't ask for a label if force is used", async () => {
// Given
const uiExtension = await testUIExtension({type: 'web_pixel_extension'})
const app = testApp({
extensions: {ui: [uiExtension], theme: [], function: []},
})

// When
await testDeployBundle(
app,
{
id: 'app-id',
organizationId: 'org-id',
title: 'app-title',
grantedScopes: [],
betas: {unifiedAppDeployment: true},
},
{
force: true,
},
)

// Then
expect(vi.mocked(renderTextPrompt)).not.toHaveBeenCalled()
expect(uploadExtensionsBundle).toHaveBeenCalledWith(
expect.objectContaining({
label: undefined,
}),
)
})

test('passes a label to the deployment mutation with a flag', async () => {
// Given
const uiExtension = await testUIExtension({type: 'web_pixel_extension'})
const app = testApp({
extensions: {ui: [uiExtension], theme: [], function: []},
})

// When
await testDeployBundle(
app,
{
id: 'app-id',
organizationId: 'org-id',
title: 'app-title',
grantedScopes: [],
betas: {unifiedAppDeployment: true},
},
{
label: 'Deployed from CLI with flag',
},
)

// Then
expect(renderTextPrompt).not.toHaveBeenCalled()
expect(uploadExtensionsBundle).toHaveBeenCalledWith(
expect.objectContaining({
label: 'Deployed from CLI with flag',
}),
)
})

test('shows a success message', async () => {
// Given
const uiExtension = await testUIExtension({type: 'web_pixel_extension'})
Expand Down Expand Up @@ -370,7 +283,6 @@ async function testDeployBundle(
app: AppInterface,
partnersApp?: Omit<OrganizationApp, 'apiSecretKeys' | 'apiKey'>,
options?: {
label?: string
force?: boolean
},
) {
Expand Down Expand Up @@ -408,6 +320,5 @@ async function testDeployBundle(
app,
reset: false,
force: Boolean(options?.force),
label: options?.label,
})
}
22 changes: 1 addition & 21 deletions packages/app/src/cli/services/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {Extension} from '../models/app/extensions.js'
import {OrganizationApp} from '../models/organization.js'
import {validateExtensions} from '../validators/extensions.js'
import {AllAppExtensionRegistrationsQuerySchema} from '../api/graphql/all_app_extension_registrations.js'
import {renderInfo, renderSuccess, renderTasks, renderTextPrompt} from '@shopify/cli-kit/node/ui'
import {renderInfo, renderSuccess, renderTasks} from '@shopify/cli-kit/node/ui'
import {inTemporaryDirectory, mkdir} from '@shopify/cli-kit/node/fs'
import {joinPath, dirname} from '@shopify/cli-kit/node/path'
import {outputNewline, outputInfo} from '@shopify/cli-kit/node/output'
Expand All @@ -34,9 +34,6 @@ interface DeployOptions {

/** If true, proceed with deploy without asking for confirmation */
force: boolean

/** The deployment label */
label?: string
}

interface TasksContext {
Expand All @@ -54,22 +51,6 @@ export async function deploy(options: DeployOptions) {
return
}

let label: string | undefined

if (partnersApp.betas?.unifiedAppDeployment) {
label = options.force
? options.label
: options.label ??
(await renderTextPrompt({
message: 'Deployment label',
allowEmpty: true,
}))

if (label?.length === 0) {
label = undefined
}
}

outputNewline()
outputInfo(`Deploying your work to Shopify Partners. It will be part of ${partnersApp.title}`)
outputNewline()
Expand Down Expand Up @@ -129,7 +110,6 @@ export async function deploy(options: DeployOptions) {
bundlePath,
extensions,
token,
label,
}))
}

Expand Down
4 changes: 0 additions & 4 deletions packages/app/src/cli/services/deploy/upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ describe('uploadExtensionsBundle', () => {
bundlePath: joinPath(tmpDir, 'test.zip'),
extensions: [{uuid: '123', config: '{}', context: ''}],
token: 'api-token',
label: 'Deployed with CLI',
})

// Then
Expand All @@ -747,7 +746,6 @@ describe('uploadExtensionsBundle', () => {
uuid: '123',
},
],
label: 'Deployed with CLI',
uuid: 'random-uuid',
})
})
Expand All @@ -772,13 +770,11 @@ describe('uploadExtensionsBundle', () => {
bundlePath: undefined,
extensions: [],
token: 'api-token',
label: 'Deployed with CLI',
})

// Then
expect(vi.mocked(partnersRequest).mock.calls[0]![2]!).toEqual({
apiKey: 'app-id',
label: 'Deployed with CLI',
uuid: 'random-uuid',
})
expect(partnersRequest).toHaveBeenCalledOnce()
Expand Down
4 changes: 0 additions & 4 deletions packages/app/src/cli/services/deploy/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ interface UploadExtensionsBundleOptions {

/** Extensions extra data */
extensions: ExtensionSettings[]

/** Deployment label */
label?: string
}

export interface UploadExtensionValidationError {
Expand Down Expand Up @@ -125,7 +122,6 @@ export async function uploadExtensionsBundle(
const variables: CreateDeploymentVariables = {
apiKey: options.apiKey,
uuid: deploymentUUID,
label: options.label,
}

if (signedURL) {
Expand Down

0 comments on commit 1978fb2

Please sign in to comment.