Skip to content

Commit

Permalink
Merge branch 'main' into upgrade-pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloriestra committed Nov 27, 2024
2 parents fdf0d22 + a1af910 commit 984670a
Show file tree
Hide file tree
Showing 52 changed files with 512 additions and 243 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-years-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli-kit': patch
---

Skip notifications when using --json, -j or SHOPIFY_FLAG_JSON
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface appfunctionreplay {
'-c, --config <value>'?: string

/**
* Output the function run result as a JSON object.
* Output the result as JSON.
* @environment SHOPIFY_FLAG_JSON
*/
'-j, --json'?: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface appfunctionrun {
'-i, --input <value>'?: string

/**
* Log the run result as a JSON object.
* Output the result as JSON.
* @environment SHOPIFY_FLAG_JSON
*/
'-j, --json'?: ''
Expand Down
4 changes: 2 additions & 2 deletions docs-shopify.dev/commands/interfaces/app-info.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export interface appinfo {
'-c, --config <value>'?: string

/**
* format output as JSON
* Output the result as JSON.
* @environment SHOPIFY_FLAG_JSON
*/
'--json'?: ''
'-j, --json'?: ''

/**
* Disable color output.
Expand Down
2 changes: 1 addition & 1 deletion docs-shopify.dev/commands/interfaces/app-logs.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface applogs {
'-c, --config <value>'?: string

/**
* Log the run result as a JSON object.
* Output the result as JSON.
* @environment SHOPIFY_FLAG_JSON
*/
'-j, --json'?: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export interface appversionslist {
'-c, --config <value>'?: string

/**
* Output the versions list as JSON.
* Output the result as JSON.
* @environment SHOPIFY_FLAG_JSON
*/
'--json'?: ''
'-j, --json'?: ''

/**
* Disable color output.
Expand Down
4 changes: 2 additions & 2 deletions docs-shopify.dev/commands/interfaces/theme-info.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export interface themeinfo {
'-e, --environment <value>'?: string

/**
* Output the theme info as JSON.
* Output the result as JSON.
* @environment SHOPIFY_FLAG_JSON
*/
'--json'?: ''
'-j, --json'?: ''

/**
* Disable color output.
Expand Down
4 changes: 2 additions & 2 deletions docs-shopify.dev/commands/interfaces/theme-list.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export interface themelist {
'--id <value>'?: string

/**
* Output the theme list as JSON.
* Output the result as JSON.
* @environment SHOPIFY_FLAG_JSON
*/
'--json'?: ''
'-j, --json'?: ''

/**
* Only list themes that contain the given name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface themepush {
'-x, --ignore <value>'?: string

/**
* Output JSON instead of a UI.
* Output the result as JSON.
* @environment SHOPIFY_FLAG_JSON
*/
'-j, --json'?: ''
Expand Down
96 changes: 48 additions & 48 deletions docs-shopify.dev/generated/generated_docs_data.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"graphql-request": "5.2.0",
"h3": "0.7.21",
"http-proxy": "1.18.1",
"ignore": "6.0.2",
"proper-lockfile": "4.1.2",
"react": "^18.2.0",
"react-dom": "18.2.0",
Expand Down
9 changes: 2 additions & 7 deletions packages/app/src/cli/commands/app/function/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {replay} from '../../../services/function/replay.js'
import {appFlags} from '../../../flags.js'
import {showApiKeyDeprecationWarning} from '../../../prompts/deprecation-warnings.js'
import AppCommand, {AppCommandOutput} from '../../../utilities/app-command.js'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
import {Flags} from '@oclif/core'

export default class FunctionReplay extends AppCommand {
Expand All @@ -17,6 +17,7 @@ export default class FunctionReplay extends AppCommand {
...globalFlags,
...appFlags,
...functionFlags,
...jsonFlag,
'api-key': Flags.string({
hidden: true,
description: "Application's API key",
Expand All @@ -35,12 +36,6 @@ export default class FunctionReplay extends AppCommand {
'Specifies a log identifier to replay instead of selecting from a list. The identifier is provided in the output of `shopify app dev` and is the suffix of the log file name.',
env: 'SHOPIFY_FLAG_LOG',
}),
json: Flags.boolean({
char: 'j',
hidden: false,
description: 'Output the function run result as a JSON object.',
env: 'SHOPIFY_FLAG_JSON',
}),
watch: Flags.boolean({
char: 'w',
hidden: false,
Expand Down
9 changes: 2 additions & 7 deletions packages/app/src/cli/commands/app/function/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {functionFlags, inFunctionContext, getOrGenerateSchemaPath} from '../../.
import {runFunction} from '../../../services/function/runner.js'
import {appFlags} from '../../../flags.js'
import AppCommand, {AppCommandOutput} from '../../../utilities/app-command.js'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
import {Flags} from '@oclif/core'
import {renderAutocompletePrompt, isTTY} from '@shopify/cli-kit/node/ui'
import {outputDebug} from '@shopify/cli-kit/node/output'
Expand All @@ -20,6 +20,7 @@ export default class FunctionRun extends AppCommand {
...globalFlags,
...appFlags,
...functionFlags,
...jsonFlag,
input: Flags.string({
char: 'i',
description: 'The input JSON to pass to the function. If omitted, standard input is used.',
Expand All @@ -31,12 +32,6 @@ export default class FunctionRun extends AppCommand {
description: 'Name of the WebAssembly export to invoke.',
env: 'SHOPIFY_FLAG_EXPORT',
}),
json: Flags.boolean({
char: 'j',
hidden: false,
description: 'Log the run result as a JSON object.',
env: 'SHOPIFY_FLAG_JSON',
}),
}

public async run(): Promise<AppCommandOutput> {
Expand Down
7 changes: 6 additions & 1 deletion packages/app/src/cli/commands/app/import-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {appFlags} from '../../flags.js'
import {importExtensions} from '../../services/import-extensions.js'
import AppCommand, {AppCommandOutput} from '../../utilities/app-command.js'
import {linkedAppContext} from '../../services/app-context.js'
import {CurrentAppConfiguration} from '../../models/app/app.js'
import {renderSelectPrompt, renderFatalError} from '@shopify/cli-kit/node/ui'
import {Flags} from '@oclif/core'
import {globalFlags} from '@shopify/cli-kit/node/cli'
Expand All @@ -17,7 +18,11 @@ interface MigrationChoice {
label: string
value: string
extensionTypes: string[]
buildTomlObject: (ext: ExtensionRegistration, allExtensions: ExtensionRegistration[]) => string
buildTomlObject: (
ext: ExtensionRegistration,
allExtensions: ExtensionRegistration[],
appConfiguration: CurrentAppConfiguration,
) => string
}

const getMigrationChoices = (): MigrationChoice[] => [
Expand Down
8 changes: 2 additions & 6 deletions packages/app/src/cli/commands/app/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Format, info} from '../../services/info.js'
import AppCommand, {AppCommandOutput} from '../../utilities/app-command.js'
import {linkedAppContext} from '../../services/app-context.js'
import {Flags} from '@oclif/core'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
import {outputInfo} from '@shopify/cli-kit/node/output'

export default class AppInfo extends AppCommand {
Expand All @@ -21,11 +21,7 @@ export default class AppInfo extends AppCommand {
static flags = {
...globalFlags,
...appFlags,
json: Flags.boolean({
hidden: false,
description: 'format output as JSON',
env: 'SHOPIFY_FLAG_JSON',
}),
...jsonFlag,
'web-env': Flags.boolean({
hidden: false,
description: 'Outputs environment variables necessary for running and deploying web/.',
Expand Down
8 changes: 2 additions & 6 deletions packages/app/src/cli/commands/app/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {linkedAppContext} from '../../services/app-context.js'
import {storeContext} from '../../services/store-context.js'
import {Flags} from '@oclif/core'
import {normalizeStoreFqdn} from '@shopify/cli-kit/node/context/fqdn'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'

export default class Logs extends AppCommand {
static summary = 'Stream detailed logs for your Shopify app.'
Expand All @@ -26,6 +26,7 @@ export default class Logs extends AppCommand {
static flags = {
...globalFlags,
...appFlags,
...jsonFlag,
'api-key': Dev.flags['api-key'],
'client-id': Dev.flags['client-id'],
store: Flags.string({
Expand All @@ -46,11 +47,6 @@ export default class Logs extends AppCommand {
options: ['success', 'failure'],
env: 'SHOPIFY_FLAG_STATUS',
}),
json: Flags.boolean({
char: 'j',
description: 'Log the run result as a JSON object.',
env: 'SHOPIFY_FLAG_JSON',
}),
}

public async run(): Promise<AppCommandOutput> {
Expand Down
8 changes: 2 additions & 6 deletions packages/app/src/cli/commands/app/versions/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import versionList from '../../../services/versions-list.js'
import {showApiKeyDeprecationWarning} from '../../../prompts/deprecation-warnings.js'
import AppCommand, {AppCommandOutput} from '../../../utilities/app-command.js'
import {linkedAppContext} from '../../../services/app-context.js'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
import {Args, Flags} from '@oclif/core'

export default class VersionsList extends AppCommand {
Expand All @@ -18,6 +18,7 @@ export default class VersionsList extends AppCommand {
static flags = {
...globalFlags,
...appFlags,
...jsonFlag,
'api-key': Flags.string({
hidden: true,
description: "Application's API key to fetch versions for.",
Expand All @@ -30,11 +31,6 @@ export default class VersionsList extends AppCommand {
env: 'SHOPIFY_FLAG_CLIENT_ID',
exclusive: ['config'],
}),
json: Flags.boolean({
description: 'Output the versions list as JSON.',
default: false,
env: 'SHOPIFY_FLAG_JSON',
}),
}

static args = {
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/cli/models/app/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const CORRECT_CURRENT_APP_SCHEMA: CurrentAppConfiguration = {
},
},
application_url: 'http://example.com',
embedded: false,
auth: {
redirect_urls: ['https://google.com'],
},
Expand Down
40 changes: 39 additions & 1 deletion packages/app/src/cli/models/app/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2353,6 +2353,7 @@ wrong = "property"
devDependencies: {},
})
await writeFile(joinPath(webDirectory, 'package.json'), JSON.stringify({}))
await writeFile(joinPath(tmpDir, '.gitignore'), '')

await loadTestingApp()

Expand All @@ -2364,7 +2365,7 @@ wrong = "property"
cmd_app_all_configs_any: true,
cmd_app_all_configs_clients: JSON.stringify({'shopify.app.toml': '1234567890'}),
cmd_app_linked_config_name: 'shopify.app.toml',
cmd_app_linked_config_git_tracked: false,
cmd_app_linked_config_git_tracked: true,
cmd_app_linked_config_source: 'cached',
cmd_app_warning_api_key_deprecation_displayed: false,
app_extensions_any: false,
Expand All @@ -2388,6 +2389,43 @@ wrong = "property"
app_web_frontend_count: 0,
})
})

test.skipIf(runningOnWindows)(`git_tracked metadata is false when ignored by the gitignore`, async () => {
const {webDirectory} = await writeConfig(linkedAppConfiguration, {
workspaces: ['packages/*'],
name: 'my_app',
dependencies: {},
devDependencies: {},
})
await writeFile(joinPath(webDirectory, 'package.json'), JSON.stringify({}))
await writeFile(joinPath(tmpDir, '.gitignore'), 'shopify.app.toml')

await loadTestingApp()

expect(metadata.getAllPublicMetadata()).toEqual(
expect.objectContaining({
cmd_app_linked_config_git_tracked: false,
}),
)
})

test.skipIf(runningOnWindows)(`git_tracked metadata is true when there is no gitignore`, async () => {
const {webDirectory} = await writeConfig(linkedAppConfiguration, {
workspaces: ['packages/*'],
name: 'my_app',
dependencies: {},
devDependencies: {},
})
await writeFile(joinPath(webDirectory, 'package.json'), JSON.stringify({}))

await loadTestingApp()

expect(metadata.getAllPublicMetadata()).toEqual(
expect.objectContaining({
cmd_app_linked_config_git_tracked: true,
}),
)
})
})

describe('getAppConfigurationFileName', () => {
Expand Down
Loading

0 comments on commit 984670a

Please sign in to comment.