Skip to content
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
42 changes: 21 additions & 21 deletions packages/app/src/cli/commands/app/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {validateVersion} from '../../validations/version-name.js'
import {validateMessage} from '../../validations/message.js'
import metadata from '../../metadata.js'
import AppLinkedCommand, {AppLinkedCommandOutput} from '../../utilities/app-linked-command.js'
import {deprecated} from '@shopify/cli-kit/node/base-command'
import {linkedAppContext} from '../../services/app-context.js'
import {Flags} from '@oclif/core'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {addPublicMetadata} from '@shopify/cli-kit/node/metadata'
import {renderWarning} from '@shopify/cli-kit/node/ui'


export default class Deploy extends AppLinkedCommand {
static summary = 'Deploy your Shopify app.'
Expand All @@ -25,13 +26,25 @@ export default class Deploy extends AppLinkedCommand {
static flags = {
...globalFlags,
...appFlags,
force: Flags.boolean({
hidden: false,
description:
'[Deprecated] Deploy without asking for confirmation. Equivalent to --allow-updates --allow-deletes. Use --allow-updates for CI/CD environments instead.',
env: 'SHOPIFY_FLAG_FORCE',
char: 'f',
}),
force: deprecated(
Flags.boolean({
hidden: false,
description:
'[Deprecated] Deploy without asking for confirmation. Equivalent to --allow-updates --allow-deletes. Use --allow-updates for CI/CD environments instead.',
env: 'SHOPIFY_FLAG_FORCE',
char: 'f',
}),
{
headline: ['The', {command: '--force'}, 'flag is deprecated and will be removed in the next major release.'],
body: [
'Use',
{command: '--allow-updates'},
'for CI/CD environments, or',
{command: '--allow-updates --allow-deletes'},
'if you also want to allow removals.',
],
},
),
'allow-updates': Flags.boolean({
hidden: false,
description:
Expand Down Expand Up @@ -80,19 +93,6 @@ export default class Deploy extends AppLinkedCommand {
async run(): Promise<AppLinkedCommandOutput> {
const {flags} = await this.parse(Deploy)

if (flags.force) {
renderWarning({
headline: ['The', {command: '--force'}, 'flag is deprecated and will be removed in the next major release.'],
body: [
'Use',
{command: '--allow-updates'},
'for CI/CD environments, or',
{command: '--allow-updates --allow-deletes'},
'if you also want to allow removals.',
],
})
}

await metadata.addPublicMetadata(() => ({
cmd_deploy_flag_message_used: Boolean(flags.message),
cmd_deploy_flag_version_used: Boolean(flags.version),
Expand Down
42 changes: 21 additions & 21 deletions packages/app/src/cli/commands/app/release.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {appFlags} from '../../flags.js'
import {release} from '../../services/release.js'
import AppLinkedCommand, {AppLinkedCommandOutput} from '../../utilities/app-linked-command.js'
import {deprecated} from '@shopify/cli-kit/node/base-command'
import {linkedAppContext} from '../../services/app-context.js'
import {Flags} from '@oclif/core'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {addPublicMetadata} from '@shopify/cli-kit/node/metadata'
import {renderWarning} from '@shopify/cli-kit/node/ui'


export default class Release extends AppLinkedCommand {
static summary = 'Release an app version.'
Expand All @@ -19,13 +20,25 @@ export default class Release extends AppLinkedCommand {
static flags = {
...globalFlags,
...appFlags,
force: Flags.boolean({
hidden: false,
description:
'[Deprecated] Release without asking for confirmation. Equivalent to --allow-updates --allow-deletes. Use --allow-updates for CI/CD environments instead.',
env: 'SHOPIFY_FLAG_FORCE',
char: 'f',
}),
force: deprecated(
Flags.boolean({
hidden: false,
description:
'[Deprecated] Release without asking for confirmation. Equivalent to --allow-updates --allow-deletes. Use --allow-updates for CI/CD environments instead.',
env: 'SHOPIFY_FLAG_FORCE',
char: 'f',
}),
{
headline: ['The', {command: '--force'}, 'flag is deprecated and will be removed in the next major release.'],
body: [
'Use',
{command: '--allow-updates'},
'for CI/CD environments, or',
{command: '--allow-updates --allow-deletes'},
'if you also want to allow removals.',
],
},
),
'allow-updates': Flags.boolean({
hidden: false,
description:
Expand All @@ -50,19 +63,6 @@ export default class Release extends AppLinkedCommand {
const {flags} = await this.parse(Release)
const clientId = flags['client-id']

if (flags.force) {
renderWarning({
headline: ['The', {command: '--force'}, 'flag is deprecated and will be removed in the next major release.'],
body: [
'Use',
{command: '--allow-updates'},
'for CI/CD environments, or',
{command: '--allow-updates --allow-deletes'},
'if you also want to allow removals.',
],
})
}

await addPublicMetadata(() => ({
cmd_app_reset_used: flags.reset,
}))
Expand Down
17 changes: 16 additions & 1 deletion packages/cli-kit/src/public/node/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {loadEnvironment, environmentFilePath} from './environments.js'
import {isDevelopment} from './context/local.js'
import {addPublicMetadata} from './metadata.js'
import {AbortError} from './error.js'
import {renderInfo, renderWarning} from './ui.js'
import {renderInfo, renderWarning, RenderAlertOptions} from './ui.js'
import {outputContent, outputResult, outputToken} from './output.js'
import {terminalSupportsPrompting} from './system.js'
import {hashString} from './crypto.js'
Expand All @@ -26,6 +26,10 @@ interface EnvironmentFlags {
path?: string
}

export function deprecated<T>(flag: T, warning: RenderAlertOptions): T {
return Object.assign(flag as object, {deprecationWarning: warning}) as T
}

abstract class BaseCommand extends Command {
static baseFlags: FlagInput<{}> = {}

Expand Down Expand Up @@ -104,6 +108,7 @@ abstract class BaseCommand extends Command {
let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)
result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)
await addFromParsedFlags(result.flags)
this.showDeprecatedFlagWarnings(result.flags)
return {...result, ...{argv: result.argv as string[]}}
}

Expand All @@ -129,6 +134,16 @@ This flag is required in non-interactive terminal environments, such as a CI env
})
}

private showDeprecatedFlagWarnings(parsedFlags: FlagOutput): void {
const commandVariables = this.constructor as unknown as {flags: JsonMap}
for (const [name, def] of Object.entries(commandVariables.flags ?? {})) {
const warning = (def as {deprecationWarning?: RenderAlertOptions}).deprecationWarning
if (warning && parsedFlags[name]) {
renderWarning(warning)
}
}
}

private async resultWithEnvironment<
TFlags extends FlagOutput & {path?: string; verbose?: boolean},
TGlobalFlags extends FlagOutput,
Expand Down
Loading