Skip to content
Open
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
92 changes: 92 additions & 0 deletions packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3063,6 +3063,98 @@
"strict": true,
"summary": "Trigger delivery of a sample webhook topic payload to a designated address."
},
"audit": {
"aliases": [
],
"args": {
},
"description": "Run CLI audit tests",
"enableJsonFlag": false,
"flags": {
},
"hasDynamicHelp": false,
"hidden": true,
"hiddenAliases": [
],
"id": "audit",
"pluginAlias": "@shopify/cli",
"pluginName": "@shopify/cli",
"pluginType": "core",
"strict": true
},
"audit:theme": {
"aliases": [
],
"args": {
},
"description": "Run all theme command audit tests",
"enableJsonFlag": false,
"flags": {
"environment": {
"char": "e",
"description": "The environment to use from shopify.theme.toml (required for store-connected tests).",
"env": "SHOPIFY_FLAG_ENVIRONMENT",
"hasDynamicHelp": false,
"multiple": false,
"name": "environment",
"required": true,
"type": "option"
},
"no-color": {
"allowNo": false,
"description": "Disable color output.",
"env": "SHOPIFY_FLAG_NO_COLOR",
"hidden": false,
"name": "no-color",
"type": "boolean"
},
"password": {
"description": "Password from Theme Access app (overrides environment).",
"env": "SHOPIFY_FLAG_PASSWORD",
"hasDynamicHelp": false,
"multiple": false,
"name": "password",
"type": "option"
},
"path": {
"char": "p",
"default": ".",
"description": "The path to run tests in. Defaults to current directory.",
"env": "SHOPIFY_FLAG_PATH",
"hasDynamicHelp": false,
"multiple": false,
"name": "path",
"type": "option"
},
"store": {
"char": "s",
"description": "Store URL (overrides environment).",
"env": "SHOPIFY_FLAG_STORE",
"hasDynamicHelp": false,
"multiple": false,
"name": "store",
"type": "option"
},
"verbose": {
"allowNo": false,
"description": "Increase the verbosity of the output.",
"env": "SHOPIFY_FLAG_VERBOSE",
"hidden": false,
"name": "verbose",
"type": "boolean"
}
},
"hasDynamicHelp": false,
"hidden": true,
"hiddenAliases": [
"audit theme"
],
"id": "audit:theme",
"pluginAlias": "@shopify/cli",
"pluginName": "@shopify/cli",
"pluginType": "core",
"strict": true
},
"auth:login": {
"aliases": [
],
Expand Down
21 changes: 21 additions & 0 deletions packages/cli/src/cli/commands/audit/audit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Command from '@shopify/cli-kit/node/base-command'
import {renderInfo} from '@shopify/cli-kit/node/ui'

export default class Audit extends Command {
static description = 'Run CLI audit tests'
static hidden = true

async run(): Promise<void> {
renderInfo({
headline: 'Shopify CLI Audit.',
body: [
'Available audit commands:',
'',
' shopify audit theme -e <environment> Run all theme command tests',
'',
'The -e/--environment flag is required to specify the store configuration.',
'Use --help with any command for more options.',
],
})
}
}
54 changes: 54 additions & 0 deletions packages/cli/src/cli/commands/audit/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {runThemeAudit} from '../../../services/audit/theme/runner.js'
import Command from '@shopify/cli-kit/node/base-command'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {Flags} from '@oclif/core'
import {resolvePath, cwd} from '@shopify/cli-kit/node/path'

export default class AuditTheme extends Command {
static description = 'Run all theme command audit tests'
static hidden = true
static hiddenAliases = ['audit theme']

static flags = {
...globalFlags,
path: Flags.string({
char: 'p',
description: 'The path to run tests in. Defaults to current directory.',
env: 'SHOPIFY_FLAG_PATH',
parse: async (input) => resolvePath(input),
default: async () => cwd(),
}),
environment: Flags.string({
char: 'e',
description: 'The environment to use from shopify.theme.toml (required for store-connected tests).',
env: 'SHOPIFY_FLAG_ENVIRONMENT',
required: true,
}),
store: Flags.string({
char: 's',
description: 'Store URL (overrides environment).',
env: 'SHOPIFY_FLAG_STORE',
}),
password: Flags.string({
description: 'Password from Theme Access app (overrides environment).',
env: 'SHOPIFY_FLAG_PASSWORD',
}),
}

async run(): Promise<void> {
const {flags} = await this.parse(AuditTheme)

const results = await runThemeAudit({
path: flags.path,
environment: flags.environment,
store: flags.store,
password: flags.password,
})

// Exit with error code if any tests failed
const failed = results.some((result) => result.status === 'failed')
if (failed) {
process.exitCode = 1
}
}
}
12 changes: 12 additions & 0 deletions packages/cli/src/cli/services/audit/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {cwd} from '@shopify/cli-kit/node/path'
import type {AuditContext, ThemeAuditOptions} from './types.js'

export function createAuditContext(options: ThemeAuditOptions): AuditContext {
return {
workingDirectory: options.path ?? cwd(),
environment: options.environment,
store: options.store,
password: options.password,
data: {},
}
}
Loading
Loading