Skip to content

Commit 70e93cf

Browse files
authored
Merge pull request #8776 from Shopify/codex/json-autoupgrade-off
Add typed JSON output to config autoupgrade off
2 parents 8a2a374 + 49a6ebe commit 70e93cf

9 files changed

Lines changed: 133 additions & 16 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/cli': minor
3+
---
4+
5+
Add typed JSON output to `config autoupgrade off`.

‎docs-shopify.dev/generated/generated_docs_data_v2.json‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4361,9 +4361,45 @@
43614361
"description": "Print the command's JSON schemas.",
43624362
"isOptional": true,
43634363
"environmentValue": "SHOPIFY_FLAG_JSON_SCHEMA"
4364+
},
4365+
{
4366+
"filePath": "docs-shopify.dev/commands/interfaces/config-autoupgrade-off.interface.ts",
4367+
"syntaxKind": "PropertySignature",
4368+
"name": "--no-color",
4369+
"value": "''",
4370+
"description": "Disable color output.",
4371+
"isOptional": true,
4372+
"environmentValue": "SHOPIFY_FLAG_NO_COLOR"
4373+
},
4374+
{
4375+
"filePath": "docs-shopify.dev/commands/interfaces/config-autoupgrade-off.interface.ts",
4376+
"syntaxKind": "PropertySignature",
4377+
"name": "--no-input",
4378+
"value": "''",
4379+
"description": "Disable interactive prompts and browser authentication.",
4380+
"isOptional": true,
4381+
"environmentValue": "SHOPIFY_FLAG_NO_INPUT"
4382+
},
4383+
{
4384+
"filePath": "docs-shopify.dev/commands/interfaces/config-autoupgrade-off.interface.ts",
4385+
"syntaxKind": "PropertySignature",
4386+
"name": "--verbose",
4387+
"value": "''",
4388+
"description": "Increase the verbosity of the output. May include sensitive data.",
4389+
"isOptional": true,
4390+
"environmentValue": "SHOPIFY_FLAG_VERBOSE"
4391+
},
4392+
{
4393+
"filePath": "docs-shopify.dev/commands/interfaces/config-autoupgrade-off.interface.ts",
4394+
"syntaxKind": "PropertySignature",
4395+
"name": "-j, --json",
4396+
"value": "''",
4397+
"description": "Output the result as JSON. Automatically disables color output.",
4398+
"isOptional": true,
4399+
"environmentValue": "SHOPIFY_FLAG_JSON"
43644400
}
43654401
],
4366-
"value": "export interface configautoupgradeoff {\n /**\n * Print the command's JSON schemas.\n * @environment SHOPIFY_FLAG_JSON_SCHEMA\n */\n '--json-schema'?: ''\n}"
4402+
"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}"
43674403
}
43684404
},
43694405
"configautoupgradeon": {

‎packages/cli/README.md‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3855,13 +3855,29 @@ Disable automatic upgrades for Shopify CLI.
38553855
38563856
```
38573857
USAGE
3858-
$ shopify config autoupgrade off [--json-schema]
3858+
$ shopify config autoupgrade off [-j] [--json-schema] [--no-color] [--no-input] [--verbose]
38593859

38603860
FLAGS
3861+
-j, --json
3862+
Output the result as JSON. Automatically disables color output.
3863+
[env: SHOPIFY_FLAG_JSON]
3864+
38613865
--json-schema
38623866
Print the command's JSON schemas.
38633867
[env: SHOPIFY_FLAG_JSON_SCHEMA]
38643868

3869+
--no-color
3870+
Disable color output.
3871+
[env: SHOPIFY_FLAG_NO_COLOR]
3872+
3873+
--no-input
3874+
Disable interactive prompts and browser authentication.
3875+
[env: SHOPIFY_FLAG_NO_INPUT]
3876+
3877+
--verbose
3878+
Increase the verbosity of the output. May include sensitive data.
3879+
[env: SHOPIFY_FLAG_VERBOSE]
3880+
38653881
DESCRIPTION
38663882
Disable automatic upgrades for Shopify CLI.
38673883

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

38723888
To enable auto-upgrade, run `shopify config autoupgrade on`.
3889+
3890+
3891+
Use `--json-schema` to print the result, error, and event schemas.
3892+
3893+
Output from `--json` conforms to the `AutoUpgradeResult` schema.
3894+
3895+
```json
3896+
{
3897+
"type": "object",
3898+
"properties": {
3899+
"enabled": {
3900+
"type": "boolean"
3901+
}
3902+
},
3903+
"required": [
3904+
"enabled"
3905+
],
3906+
"additionalProperties": false,
3907+
"title": "AutoUpgradeResult",
3908+
"$schema": "http://json-schema.org/draft-07/schema#"
3909+
}
3910+
```
38733911
```
38743912
38753913
## `shopify config autoupgrade on`

‎packages/cli/oclif.manifest.json‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5804,16 +5804,48 @@
58045804
],
58055805
"args": {
58065806
},
5807-
"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",
5807+
"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```",
58085808
"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",
58095809
"enableJsonFlag": false,
58105810
"flags": {
5811+
"json": {
5812+
"allowNo": false,
5813+
"char": "j",
5814+
"description": "Output the result as JSON. Automatically disables color output.",
5815+
"env": "SHOPIFY_FLAG_JSON",
5816+
"hidden": false,
5817+
"name": "json",
5818+
"type": "boolean"
5819+
},
58115820
"json-schema": {
58125821
"allowNo": false,
58135822
"description": "Print the command's JSON schemas.",
58145823
"env": "SHOPIFY_FLAG_JSON_SCHEMA",
58155824
"name": "json-schema",
58165825
"type": "boolean"
5826+
},
5827+
"no-color": {
5828+
"allowNo": false,
5829+
"description": "Disable color output.",
5830+
"env": "SHOPIFY_FLAG_NO_COLOR",
5831+
"hidden": false,
5832+
"name": "no-color",
5833+
"type": "boolean"
5834+
},
5835+
"no-input": {
5836+
"allowNo": false,
5837+
"description": "Disable interactive prompts and browser authentication.",
5838+
"env": "SHOPIFY_FLAG_NO_INPUT",
5839+
"name": "no-input",
5840+
"type": "boolean"
5841+
},
5842+
"verbose": {
5843+
"allowNo": false,
5844+
"description": "Increase the verbosity of the output. May include sensitive data.",
5845+
"env": "SHOPIFY_FLAG_VERBOSE",
5846+
"hidden": false,
5847+
"name": "verbose",
5848+
"type": "boolean"
58175849
}
58185850
},
58195851
"hasDynamicHelp": false,

‎packages/cli/src/cli/commands/config/autoupgrade/autoupgrade.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import AutoupgradeOn from './on.js'
2+
import AutoupgradeOff from './off.js'
23
import AutoupgradeStatus from './status.js'
34
import {autoUpgradeJsonOutputSchema} from '../../../services/commands/config/autoupgrade/types.js'
45
import {getAutoUpgradeEnabled, setAutoUpgradeEnabled} from '@shopify/cli-kit/node/upgrade'
@@ -25,6 +26,7 @@ afterEach(() => {
2526
const commands = [
2627
{name: 'status', command: AutoupgradeStatus, enabled: false},
2728
{name: 'on', command: AutoupgradeOn, enabled: true},
29+
{name: 'off', command: AutoupgradeOff, enabled: false},
2830
]
2931

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

‎packages/cli/src/cli/commands/config/autoupgrade/constants.ts‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎packages/cli/src/cli/commands/config/autoupgrade/off.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import AutoupgradeOff from './off.js'
22
import {setAutoUpgradeEnabled} from '@shopify/cli-kit/node/upgrade'
3-
import {Config} from '@oclif/core'
43
import {describe, expect, vi, test} from 'vitest'
54
import {mockAndCaptureOutput} from '@shopify/cli-kit/node/testing/output'
65

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

1513
// When
16-
await new AutoupgradeOff([], config).run()
14+
await AutoupgradeOff.run([], import.meta.url)
1715

1816
// Then
1917
expect(setAutoUpgradeEnabled).toBeCalledWith(false)

‎packages/cli/src/cli/commands/config/autoupgrade/off.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {autoUpgradeStatus} from './constants.js'
2-
import {setAutoUpgradeEnabled} from '@shopify/cli-kit/node/upgrade'
1+
import {configureAutoUpgrade} from '../../../services/commands/config/autoupgrade/index.js'
2+
import {presentAutoUpgradeResult} from '../../../services/commands/config/autoupgrade/result.js'
3+
import {autoUpgradeJsonOutputSchema} from '../../../services/commands/config/autoupgrade/types.js'
34
import Command from '@shopify/cli-kit/node/base-command'
4-
import {renderInfo} from '@shopify/cli-kit/node/ui'
5+
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
56

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

1617
static description = this.descriptionForHelp()
1718

19+
static flags = {
20+
...globalFlags,
21+
...jsonFlag,
22+
}
23+
24+
static get jsonOutputSchema() {
25+
return autoUpgradeJsonOutputSchema
26+
}
27+
1828
async run(): Promise<void> {
19-
setAutoUpgradeEnabled(false)
20-
renderInfo({body: autoUpgradeStatus.off})
29+
const {flags} = await this.parse(AutoupgradeOff)
30+
const result = configureAutoUpgrade(false)
31+
presentAutoUpgradeResult(result, flags.json ? 'json' : 'text')
2132
}
2233
}

‎packages/eslint-plugin-cli/rules/json-output-command-exceptions.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const commandExceptions = [
3434
'packages/app/src/cli/commands/app/webhook/trigger.ts',
3535
'packages/cli/src/cli/commands/auth/login.ts',
3636
'packages/cli/src/cli/commands/auth/logout.ts',
37-
'packages/cli/src/cli/commands/config/autoupgrade/off.ts',
3837
'packages/cli/src/cli/commands/doc/fetch.ts',
3938
'packages/cli/src/cli/commands/doc/search.ts',
4039
'packages/cli/src/cli/commands/upgrade.ts',

0 commit comments

Comments
 (0)