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
20 changes: 20 additions & 0 deletions packages/app/src/cli/commands/app/config/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ describe('app config validate command', () => {
await expectValidationMetadataCalls({cmd_app_validate_json: true})
})

test('accepts --client-id with --config to validate a specific linked app configuration', async () => {
const app = testAppLinked()
mockHealthyProject()
vi.mocked(linkedAppContext).mockResolvedValue({app} as Awaited<ReturnType<typeof linkedAppContext>>)
vi.mocked(validateApp).mockResolvedValue()

await Validate.run(['--client-id', 'api-key', '--config', 'staging'], import.meta.url)

expect(selectActiveConfig).toHaveBeenCalledWith(expect.anything(), 'staging')
expect(linkedAppContext).toHaveBeenCalledWith({
directory: expect.any(String),
clientId: 'api-key',
forceRelink: false,
userProvidedConfigName: 'staging',
unsafeTolerateErrors: true,
})
expect(validateApp).toHaveBeenCalledWith(app, {json: false})
await expectValidationMetadataCalls({cmd_app_validate_json: false})
})

test('outputs JSON issues when active config has TOML parse errors', async () => {
vi.mocked(Project.load).mockResolvedValue({errors: []} as unknown as Project)
vi.mocked(selectActiveConfig).mockResolvedValue({file: new TomlFile('shopify.app.toml', {})} as any)
Expand Down
6 changes: 6 additions & 0 deletions packages/app/src/cli/commands/app/config/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
import {AbortError, AbortSilentError} from '@shopify/cli-kit/node/error'
import {outputResult, stringifyMessage, unstyled} from '@shopify/cli-kit/node/output'
import {renderError} from '@shopify/cli-kit/node/ui'
import {Flags} from '@oclif/core'

async function recordValidationFailure(issueCount: number, fileCount: number) {
await metadata.addPublicMetadata(() => ({
Expand All @@ -29,6 +30,11 @@ export default class Validate extends AppLinkedCommand {
static flags = {
...globalFlags,
...appFlags,
'client-id': Flags.string({
hidden: false,
description: 'The Client ID of your app.',
env: 'SHOPIFY_FLAG_CLIENT_ID',
}),
...jsonFlag,
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Validate your app configuration and extensions.

```
USAGE
$ shopify app config validate [--client-id <value> | -c <value>] [-j] [--no-color] [--path <value>] [--reset | ]
$ shopify app config validate [--client-id <value>] [-j] [--no-color] [--path <value>] [--reset | -c <value>]
[--verbose]

FLAGS
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,6 @@
"client-id": {
"description": "The Client ID of your app.",
"env": "SHOPIFY_FLAG_CLIENT_ID",
"exclusive": [
"config"
],
"hasDynamicHelp": false,
"hidden": false,
"multiple": false,
Expand Down
Loading