Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/auto-upgrade-off-json.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli': minor
---

Add typed JSON output to `config autoupgrade off`.
38 changes: 37 additions & 1 deletion docs-shopify.dev/generated/generated_docs_data_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4361,9 +4361,45 @@
"description": "Print the command's JSON schemas.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_JSON_SCHEMA"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/config-autoupgrade-off.interface.ts",
"syntaxKind": "PropertySignature",
"name": "--no-color",
"value": "''",
"description": "Disable color output.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_NO_COLOR"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/config-autoupgrade-off.interface.ts",
"syntaxKind": "PropertySignature",
"name": "--no-input",
"value": "''",
"description": "Disable interactive prompts and browser authentication.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_NO_INPUT"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/config-autoupgrade-off.interface.ts",
"syntaxKind": "PropertySignature",
"name": "--verbose",
"value": "''",
"description": "Increase the verbosity of the output. May include sensitive data.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_VERBOSE"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/config-autoupgrade-off.interface.ts",
"syntaxKind": "PropertySignature",
"name": "-j, --json",
"value": "''",
"description": "Output the result as JSON. Automatically disables color output.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_JSON"
}
],
"value": "export interface configautoupgradeoff {\n /**\n * Print the command's JSON schemas.\n * @environment SHOPIFY_FLAG_JSON_SCHEMA\n */\n '--json-schema'?: ''\n}"
"value": "export interface configautoupgradeoff {\n /**\n * Output the result as JSON. Automatically disables color output.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Print the command's JSON schemas.\n * @environment SHOPIFY_FLAG_JSON_SCHEMA\n */\n '--json-schema'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Disable interactive prompts and browser authentication.\n * @environment SHOPIFY_FLAG_NO_INPUT\n */\n '--no-input'?: ''\n\n /**\n * Increase the verbosity of the output. May include sensitive data.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
}
},
"configautoupgradeon": {
Expand Down
40 changes: 39 additions & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3855,13 +3855,29 @@ Disable automatic upgrades for Shopify CLI.

```
USAGE
$ shopify config autoupgrade off [--json-schema]
$ shopify config autoupgrade off [-j] [--json-schema] [--no-color] [--no-input] [--verbose]

FLAGS
-j, --json
Output the result as JSON. Automatically disables color output.
[env: SHOPIFY_FLAG_JSON]

--json-schema
Print the command's JSON schemas.
[env: SHOPIFY_FLAG_JSON_SCHEMA]

--no-color
Disable color output.
[env: SHOPIFY_FLAG_NO_COLOR]

--no-input
Disable interactive prompts and browser authentication.
[env: SHOPIFY_FLAG_NO_INPUT]

--verbose
Increase the verbosity of the output. May include sensitive data.
[env: SHOPIFY_FLAG_VERBOSE]

DESCRIPTION
Disable automatic upgrades for Shopify CLI.

Expand All @@ -3870,6 +3886,28 @@ DESCRIPTION
When auto-upgrade is disabled, Shopify CLI won't automatically update. Run `shopify upgrade` to update manually.

To enable auto-upgrade, run `shopify config autoupgrade on`.


Use `--json-schema` to print the result, error, and event schemas.

Output from `--json` conforms to the `AutoUpgradeResult` schema.

```json
{
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
}
},
"required": [
"enabled"
],
"additionalProperties": false,
"title": "AutoUpgradeResult",
"$schema": "http://json-schema.org/draft-07/schema#"
}
```
```

## `shopify config autoupgrade on`
Expand Down
34 changes: 33 additions & 1 deletion packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5804,16 +5804,48 @@
],
"args": {
},
"description": "Disable automatic upgrades for Shopify CLI.\n\n When auto-upgrade is disabled, Shopify CLI won't automatically update. Run `shopify upgrade` to update manually.\n\n To enable auto-upgrade, run `shopify config autoupgrade on`.\n",
"description": "Disable automatic upgrades for Shopify CLI.\n\n When auto-upgrade is disabled, Shopify CLI won't automatically update. Run `shopify upgrade` to update manually.\n\n To enable auto-upgrade, run `shopify config autoupgrade on`.\n\n\nUse `--json-schema` to print the result, error, and event schemas.\n\nOutput from `--json` conforms to the `AutoUpgradeResult` schema.\n\n```json\n{\n \"type\": \"object\",\n \"properties\": {\n \"enabled\": {\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"enabled\"\n ],\n \"additionalProperties\": false,\n \"title\": \"AutoUpgradeResult\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\"\n}\n```",
"descriptionWithMarkdown": "Disable automatic upgrades for Shopify CLI.\n\n When auto-upgrade is disabled, Shopify CLI won't automatically update. Run `shopify upgrade` to update manually.\n\n To enable auto-upgrade, run `shopify config autoupgrade on`.\n",
"enableJsonFlag": false,
"flags": {
"json": {
"allowNo": false,
"char": "j",
"description": "Output the result as JSON. Automatically disables color output.",
"env": "SHOPIFY_FLAG_JSON",
"hidden": false,
"name": "json",
"type": "boolean"
},
"json-schema": {
"allowNo": false,
"description": "Print the command's JSON schemas.",
"env": "SHOPIFY_FLAG_JSON_SCHEMA",
"name": "json-schema",
"type": "boolean"
},
"no-color": {
"allowNo": false,
"description": "Disable color output.",
"env": "SHOPIFY_FLAG_NO_COLOR",
"hidden": false,
"name": "no-color",
"type": "boolean"
},
"no-input": {
"allowNo": false,
"description": "Disable interactive prompts and browser authentication.",
"env": "SHOPIFY_FLAG_NO_INPUT",
"name": "no-input",
"type": "boolean"
},
"verbose": {
"allowNo": false,
"description": "Increase the verbosity of the output. May include sensitive data.",
"env": "SHOPIFY_FLAG_VERBOSE",
"hidden": false,
"name": "verbose",
"type": "boolean"
}
},
"hasDynamicHelp": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AutoupgradeOn from './on.js'
import AutoupgradeOff from './off.js'
import AutoupgradeStatus from './status.js'
import {autoUpgradeJsonOutputSchema} from '../../../services/commands/config/autoupgrade/types.js'
import {getAutoUpgradeEnabled, setAutoUpgradeEnabled} from '@shopify/cli-kit/node/upgrade'
Expand All @@ -25,6 +26,7 @@ afterEach(() => {
const commands = [
{name: 'status', command: AutoupgradeStatus, enabled: false},
{name: 'on', command: AutoupgradeOn, enabled: true},
{name: 'off', command: AutoupgradeOff, enabled: false},
]

test.each(commands)('$name exposes the result schema and JSON flags in help', ({command}) => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import AutoupgradeOff from './off.js'
import {setAutoUpgradeEnabled} from '@shopify/cli-kit/node/upgrade'
import {Config} from '@oclif/core'
import {describe, expect, vi, test} from 'vitest'
import {mockAndCaptureOutput} from '@shopify/cli-kit/node/testing/output'

Expand All @@ -9,11 +8,10 @@ vi.mock('@shopify/cli-kit/node/upgrade')
describe('AutoupgradeOff', () => {
test('disables auto-upgrade', async () => {
// Given
const config = new Config({root: __dirname})
const outputMock = mockAndCaptureOutput()

// When
await new AutoupgradeOff([], config).run()
await AutoupgradeOff.run([], import.meta.url)

// Then
expect(setAutoUpgradeEnabled).toBeCalledWith(false)
Expand Down
21 changes: 16 additions & 5 deletions packages/cli/src/cli/commands/config/autoupgrade/off.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {autoUpgradeStatus} from './constants.js'
import {setAutoUpgradeEnabled} from '@shopify/cli-kit/node/upgrade'
import {configureAutoUpgrade} from '../../../services/commands/config/autoupgrade/index.js'
import {presentAutoUpgradeResult} from '../../../services/commands/config/autoupgrade/result.js'
import {autoUpgradeJsonOutputSchema} from '../../../services/commands/config/autoupgrade/types.js'
import Command from '@shopify/cli-kit/node/base-command'
import {renderInfo} from '@shopify/cli-kit/node/ui'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'

export default class AutoupgradeOff extends Command {
static summary = 'Disable automatic upgrades for Shopify CLI.'
Expand All @@ -15,8 +16,18 @@ export default class AutoupgradeOff extends Command {

static description = this.descriptionForHelp()

static flags = {
...globalFlags,
...jsonFlag,
}

static get jsonOutputSchema() {
return autoUpgradeJsonOutputSchema
}

async run(): Promise<void> {
setAutoUpgradeEnabled(false)
renderInfo({body: autoUpgradeStatus.off})
const {flags} = await this.parse(AutoupgradeOff)
const result = configureAutoUpgrade(false)
presentAutoUpgradeResult(result, flags.json ? 'json' : 'text')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const commandExceptions = [
'packages/app/src/cli/commands/app/webhook/trigger.ts',
'packages/cli/src/cli/commands/auth/login.ts',
'packages/cli/src/cli/commands/auth/logout.ts',
'packages/cli/src/cli/commands/config/autoupgrade/off.ts',
'packages/cli/src/cli/commands/doc/fetch.ts',
'packages/cli/src/cli/commands/doc/search.ts',
'packages/cli/src/cli/commands/upgrade.ts',
Expand Down
Loading