From 40d7edc1b562d1966e3de1bbdd5613c7c45dbb7d Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 12:29:10 +0100 Subject: [PATCH 01/11] Skip notifications when using --json --- .../public/node/notifications-system.test.ts | 43 ++++++++++++++++++- .../src/public/node/notifications-system.ts | 12 +++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/packages/cli-kit/src/public/node/notifications-system.test.ts b/packages/cli-kit/src/public/node/notifications-system.test.ts index 974d522cc45..eb137383894 100644 --- a/packages/cli-kit/src/public/node/notifications-system.test.ts +++ b/packages/cli-kit/src/public/node/notifications-system.test.ts @@ -1,10 +1,12 @@ import {Notification, filterNotifications, showNotificationsIfNeeded} from './notifications-system.js' import {renderError, renderInfo, renderWarning} from './ui.js' +import {sniffForJson} from './path.js' import {cacheRetrieve, cacheRetrieveOrRepopulate} from '../../private/node/conf-store.js' import {afterEach, describe, expect, test, vi} from 'vitest' vi.mock('./ui.js') vi.mock('../../private/node/conf-store.js') +vi.mock('./path.js') const betweenVersins1and2: Notification = { id: 'betweenVersins1and2', @@ -258,7 +260,7 @@ afterEach(() => { vi.useRealTimers() }) -describe('notifications-system filter notifications', () => { +describe('filterNotifications', () => { test.each(testCases)('Filter for %name', ({input, commandId, version, date, surfaces, output}) => { // When const result = filterNotifications(input, commandId, surfaces, new Date(date), version) @@ -327,7 +329,7 @@ describe('notifications-system filter notifications', () => { }) }) -describe('notifications-system', () => { +describe('showNotificationsIfNeeded', () => { test('an info notification triggers a renderInfo call', async () => { // Given const notifications = [infoNotification] @@ -363,4 +365,41 @@ describe('notifications-system', () => { // Then expect(renderError).toHaveBeenCalled() }) + + test('notifications are skipped on CI', async () => { + // Given + const notifications = [infoNotification] + vi.mocked(cacheRetrieveOrRepopulate).mockResolvedValue(JSON.stringify({notifications})) + + // When + await showNotificationsIfNeeded(undefined, {SHOPIFY_UNIT_TEST: 'false', CI: 'true'}) + + // Then + expect(renderInfo).not.toHaveBeenCalled() + }) + + test('notifications are skipped on tests', async () => { + // Given + const notifications = [infoNotification] + vi.mocked(cacheRetrieveOrRepopulate).mockResolvedValue(JSON.stringify({notifications})) + + // When + await showNotificationsIfNeeded(undefined, {SHOPIFY_UNIT_TEST: 'true'}) + + // Then + expect(renderInfo).not.toHaveBeenCalled() + }) + + test('notifications are skipped when using --json flag', async () => { + // Given + const notifications = [infoNotification] + vi.mocked(cacheRetrieveOrRepopulate).mockResolvedValue(JSON.stringify({notifications})) + vi.mocked(sniffForJson).mockReturnValue(true) + + // When + await showNotificationsIfNeeded(undefined, {SHOPIFY_UNIT_TEST: 'false'}) + + // Then + expect(renderInfo).not.toHaveBeenCalled() + }) }) diff --git a/packages/cli-kit/src/public/node/notifications-system.ts b/packages/cli-kit/src/public/node/notifications-system.ts index b382dafb2a6..8df88247c88 100644 --- a/packages/cli-kit/src/public/node/notifications-system.ts +++ b/packages/cli-kit/src/public/node/notifications-system.ts @@ -5,6 +5,7 @@ import {outputDebug} from './output.js' import {zod} from './schema.js' import {AbortSilentError} from './error.js' import {isTruthy} from './context/utilities.js' +import {sniffForJson} from './path.js' import {CLI_KIT_VERSION} from '../common/version.js' import { NotificationKey, @@ -54,9 +55,12 @@ export type Notifications = zod.infer * @param environment - Process environment variables. * @returns - A promise that resolves when the notifications have been shown. */ -export async function showNotificationsIfNeeded(currentSurfaces?: string[], environment = process.env): Promise { +export async function showNotificationsIfNeeded( + currentSurfaces?: string[], + environment: NodeJS.ProcessEnv = process.env, +): Promise { try { - if (isTruthy(environment.CI) || isTruthy(environment.SHOPIFY_UNIT_TEST)) return + if (skipNotifications(environment)) return const notifications = await getNotifications() const commandId = getCurrentCommandId() @@ -74,6 +78,10 @@ export async function showNotificationsIfNeeded(currentSurfaces?: string[], envi } } +function skipNotifications(environment: NodeJS.ProcessEnv): boolean { + return isTruthy(environment.CI) || isTruthy(environment.SHOPIFY_UNIT_TEST) || sniffForJson() +} + /** * Renders the first 2 notifications to the user. * From 5531731c115d9363fc870f721827036424937c84 Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 12:29:48 +0100 Subject: [PATCH 02/11] Add changeset --- .changeset/sixty-years-stare.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sixty-years-stare.md diff --git a/.changeset/sixty-years-stare.md b/.changeset/sixty-years-stare.md new file mode 100644 index 00000000000..81214f830f8 --- /dev/null +++ b/.changeset/sixty-years-stare.md @@ -0,0 +1,5 @@ +--- +'@shopify/cli-kit': patch +--- + +Skip notifications when using --json From e67cf3bf5fff4c269b9af3bb6569ac0dc8cad43b Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 12:52:10 +0100 Subject: [PATCH 03/11] Skip notifications when using -j --- packages/cli-kit/src/public/node/path.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/cli-kit/src/public/node/path.ts b/packages/cli-kit/src/public/node/path.ts index 41fbcda42dd..1b064805c9c 100644 --- a/packages/cli-kit/src/public/node/path.ts +++ b/packages/cli-kit/src/public/node/path.ts @@ -172,12 +172,11 @@ export function sniffForPath(argv = process.argv): string | undefined { } /** - * Returns whether the `--json` flag is present in the arguments. + * Returns whether the `--json` or `-j` flags are present in the arguments. * - * @param argv - The arguments to search for the `--json` flag. - * @returns Whether the `--json` flag is present in the arguments. + * @param argv - The arguments to search for the `--json` and `-j` flags. + * @returns Whether the `--json` or `-j` flag is present in the arguments. */ export function sniffForJson(argv = process.argv): boolean { - const jsonFlagIndex = argv.indexOf('--json') - return jsonFlagIndex !== -1 + return argv.includes('--json') || argv.includes('-j') } From b47fdc347db7dcd12c80f571f572f27b8a804798 Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 12:52:46 +0100 Subject: [PATCH 04/11] Unify --json flag across commands --- packages/app/src/cli/commands/app/function/replay.ts | 9 ++------- packages/app/src/cli/commands/app/function/run.ts | 9 ++------- packages/app/src/cli/commands/app/info.ts | 8 ++------ packages/app/src/cli/commands/app/logs.ts | 8 ++------ packages/app/src/cli/commands/app/versions/list.ts | 8 ++------ packages/cli-kit/src/public/node/cli.ts | 10 ++++++++++ packages/theme/src/cli/commands/theme/info.ts | 8 ++------ packages/theme/src/cli/commands/theme/list.ts | 8 ++------ packages/theme/src/cli/commands/theme/push.ts | 8 ++------ 9 files changed, 26 insertions(+), 50 deletions(-) diff --git a/packages/app/src/cli/commands/app/function/replay.ts b/packages/app/src/cli/commands/app/function/replay.ts index 8352d9a71a1..ae86903fab2 100644 --- a/packages/app/src/cli/commands/app/function/replay.ts +++ b/packages/app/src/cli/commands/app/function/replay.ts @@ -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 { @@ -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", @@ -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, diff --git a/packages/app/src/cli/commands/app/function/run.ts b/packages/app/src/cli/commands/app/function/run.ts index 2c8d352f4d6..c655b0b4002 100644 --- a/packages/app/src/cli/commands/app/function/run.ts +++ b/packages/app/src/cli/commands/app/function/run.ts @@ -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' @@ -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.', @@ -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 { diff --git a/packages/app/src/cli/commands/app/info.ts b/packages/app/src/cli/commands/app/info.ts index 36ee9a08871..ca21952f589 100644 --- a/packages/app/src/cli/commands/app/info.ts +++ b/packages/app/src/cli/commands/app/info.ts @@ -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 { @@ -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/.', diff --git a/packages/app/src/cli/commands/app/logs.ts b/packages/app/src/cli/commands/app/logs.ts index 0e089f6d028..716a12607ad 100644 --- a/packages/app/src/cli/commands/app/logs.ts +++ b/packages/app/src/cli/commands/app/logs.ts @@ -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.' @@ -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({ @@ -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 { diff --git a/packages/app/src/cli/commands/app/versions/list.ts b/packages/app/src/cli/commands/app/versions/list.ts index 700673819a8..8b9d2c8f73f 100644 --- a/packages/app/src/cli/commands/app/versions/list.ts +++ b/packages/app/src/cli/commands/app/versions/list.ts @@ -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 { @@ -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.", @@ -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 = { diff --git a/packages/cli-kit/src/public/node/cli.ts b/packages/cli-kit/src/public/node/cli.ts index 999cdae5184..1150a546b50 100644 --- a/packages/cli-kit/src/public/node/cli.ts +++ b/packages/cli-kit/src/public/node/cli.ts @@ -135,6 +135,16 @@ export const globalFlags = { }), } +export const jsonFlag = { + json: Flags.boolean({ + char: 'j', + description: 'Output the result as JSON.', + hidden: false, + default: false, + env: 'SHOPIFY_FLAG_JSON', + }), +} + /** * Clear the CLI cache, used to store some API responses and handle notifications status */ diff --git a/packages/theme/src/cli/commands/theme/info.ts b/packages/theme/src/cli/commands/theme/info.ts index 18525ac49df..009715f7342 100644 --- a/packages/theme/src/cli/commands/theme/info.ts +++ b/packages/theme/src/cli/commands/theme/info.ts @@ -5,7 +5,7 @@ import ThemeCommand from '../../utilities/theme-command.js' import {Flags} from '@oclif/core' import {ensureAuthenticatedThemes} from '@shopify/cli-kit/node/session' import {AbortError} from '@shopify/cli-kit/node/error' -import {globalFlags} from '@shopify/cli-kit/node/cli' +import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli' import {formatSection, outputInfo} from '@shopify/cli-kit/node/output' export default class Info extends ThemeCommand { @@ -14,6 +14,7 @@ export default class Info extends ThemeCommand { static flags = { ...globalFlags, + ...jsonFlag, store: themeFlags.store, password: themeFlags.password, environment: themeFlags.environment, @@ -27,11 +28,6 @@ export default class Info extends ThemeCommand { description: 'Theme ID or name of the remote theme.', env: 'SHOPIFY_FLAG_THEME_ID', }), - json: Flags.boolean({ - description: 'Output the theme info as JSON.', - default: false, - env: 'SHOPIFY_FLAG_JSON', - }), } public async run(): Promise { diff --git a/packages/theme/src/cli/commands/theme/list.ts b/packages/theme/src/cli/commands/theme/list.ts index 24167e2e6b2..916fa8517eb 100644 --- a/packages/theme/src/cli/commands/theme/list.ts +++ b/packages/theme/src/cli/commands/theme/list.ts @@ -5,13 +5,14 @@ import {themeFlags} from '../../flags.js' import ThemeCommand from '../../utilities/theme-command.js' import {Flags} from '@oclif/core' import {ensureAuthenticatedThemes} from '@shopify/cli-kit/node/session' -import {globalFlags} from '@shopify/cli-kit/node/cli' +import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli' export default class List extends ThemeCommand { static description = 'Lists the themes in your store, along with their IDs and statuses.' static flags = { ...globalFlags, + ...jsonFlag, password: themeFlags.password, store: themeFlags.store, role: Flags.custom({ @@ -27,11 +28,6 @@ export default class List extends ThemeCommand { description: 'Only list theme with the given ID.', env: 'SHOPIFY_FLAG_ID', }), - json: Flags.boolean({ - description: 'Output the theme list as JSON.', - default: false, - env: 'SHOPIFY_FLAG_JSON', - }), environment: themeFlags.environment, } diff --git a/packages/theme/src/cli/commands/theme/push.ts b/packages/theme/src/cli/commands/theme/push.ts index 99cbf83c3c1..e2925507a79 100644 --- a/packages/theme/src/cli/commands/theme/push.ts +++ b/packages/theme/src/cli/commands/theme/push.ts @@ -2,7 +2,7 @@ import {themeFlags} from '../../flags.js' import ThemeCommand from '../../utilities/theme-command.js' import {push, PushFlags} from '../../services/push.js' import {Flags} from '@oclif/core' -import {globalFlags} from '@shopify/cli-kit/node/cli' +import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli' export default class Push extends ThemeCommand { static summary = 'Uploads your local theme files to the connected store, overwriting the remote version if specified.' @@ -43,6 +43,7 @@ export default class Push extends ThemeCommand { static flags = { ...globalFlags, ...themeFlags, + ...jsonFlag, theme: Flags.string({ char: 't', description: 'Theme ID or name of the remote theme.', @@ -80,11 +81,6 @@ export default class Push extends ThemeCommand { multiple: true, env: 'SHOPIFY_FLAG_IGNORE', }), - json: Flags.boolean({ - char: 'j', - description: 'Output JSON instead of a UI.', - env: 'SHOPIFY_FLAG_JSON', - }), 'allow-live': Flags.boolean({ char: 'a', description: 'Allow push to a live theme.', From db0391081e7d70e0696decff47192e5ebcc7bcd2 Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 13:03:25 +0100 Subject: [PATCH 05/11] Skip notifications when using SHOPIFY_FLAG_JSON --- packages/app/src/cli/models/app/loader.ts | 5 +++-- packages/cli-kit/src/public/node/environment.ts | 11 +++++++++++ .../cli-kit/src/public/node/notifications-system.ts | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/app/src/cli/models/app/loader.ts b/packages/app/src/cli/models/app/loader.ts index e8d04662e97..939597d6684 100644 --- a/packages/app/src/cli/models/app/loader.ts +++ b/packages/app/src/cli/models/app/loader.ts @@ -42,7 +42,7 @@ import { import {resolveFramework} from '@shopify/cli-kit/node/framework' import {hashString} from '@shopify/cli-kit/node/crypto' import {JsonMapType, decodeToml} from '@shopify/cli-kit/node/toml' -import {joinPath, dirname, basename, relativePath, relativizePath, sniffForJson} from '@shopify/cli-kit/node/path' +import {joinPath, dirname, basename, relativePath, relativizePath} from '@shopify/cli-kit/node/path' import {AbortError} from '@shopify/cli-kit/node/error' import {outputContent, outputDebug, OutputMessage, outputToken} from '@shopify/cli-kit/node/output' import {joinWithAnd, slugify} from '@shopify/cli-kit/common/string' @@ -52,6 +52,7 @@ import {renderInfo} from '@shopify/cli-kit/node/ui' import {currentProcessIsGlobal} from '@shopify/cli-kit/node/is-global' import {showNotificationsIfNeeded} from '@shopify/cli-kit/node/notifications-system' import {globalCLIVersion, localCLIVersion} from '@shopify/cli-kit/node/version' +import {jsonOutputEnabled} from '@shopify/cli-kit/node/environment' const defaultExtensionDirectory = 'extensions/*' @@ -401,7 +402,7 @@ class AppLoader Date: Wed, 27 Nov 2024 13:05:15 +0100 Subject: [PATCH 06/11] Update changeset --- .changeset/sixty-years-stare.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/sixty-years-stare.md b/.changeset/sixty-years-stare.md index 81214f830f8..ed503065bff 100644 --- a/.changeset/sixty-years-stare.md +++ b/.changeset/sixty-years-stare.md @@ -2,4 +2,4 @@ '@shopify/cli-kit': patch --- -Skip notifications when using --json +Skip notifications when using --json, -j or SHOPIFY_FLAG_JSON From 8e03a724d8beab1594d9b047a743c47d44782aec Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 13:10:36 +0100 Subject: [PATCH 07/11] Add test --- packages/cli-kit/src/public/node/environment.ts | 5 +++-- .../src/public/node/notifications-system.test.ts | 12 ++++++++++++ .../cli-kit/src/public/node/notifications-system.ts | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/cli-kit/src/public/node/environment.ts b/packages/cli-kit/src/public/node/environment.ts index a394c934508..4ae9e6bc10f 100644 --- a/packages/cli-kit/src/public/node/environment.ts +++ b/packages/cli-kit/src/public/node/environment.ts @@ -76,8 +76,9 @@ export function getIdentityTokenInformation(): {accessToken: string; refreshToke /** * Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON). * + * @param environment - Process environment variables. * @returns True if the JSON output is enabled, false otherwise. */ -export function jsonOutputEnabled(): boolean { - return sniffForJson() || isTruthy(getEnvironmentVariables().SHOPIFY_FLAG_JSON) +export function jsonOutputEnabled(environment = getEnvironmentVariables()): boolean { + return sniffForJson() || isTruthy(environment.SHOPIFY_FLAG_JSON) } diff --git a/packages/cli-kit/src/public/node/notifications-system.test.ts b/packages/cli-kit/src/public/node/notifications-system.test.ts index eb137383894..c7b44ec34ce 100644 --- a/packages/cli-kit/src/public/node/notifications-system.test.ts +++ b/packages/cli-kit/src/public/node/notifications-system.test.ts @@ -402,4 +402,16 @@ describe('showNotificationsIfNeeded', () => { // Then expect(renderInfo).not.toHaveBeenCalled() }) + + test('notifications are skipped when using SHOPIFY_FLAG_JSON', async () => { + // Given + const notifications = [infoNotification] + vi.mocked(cacheRetrieveOrRepopulate).mockResolvedValue(JSON.stringify({notifications})) + + // When + await showNotificationsIfNeeded(undefined, {SHOPIFY_UNIT_TEST: 'false', SHOPIFY_FLAG_JSON: 'true'}) + + // Then + expect(renderInfo).not.toHaveBeenCalled() + }) }) diff --git a/packages/cli-kit/src/public/node/notifications-system.ts b/packages/cli-kit/src/public/node/notifications-system.ts index f5c557485ef..8ca472a5d82 100644 --- a/packages/cli-kit/src/public/node/notifications-system.ts +++ b/packages/cli-kit/src/public/node/notifications-system.ts @@ -79,7 +79,7 @@ export async function showNotificationsIfNeeded( } function skipNotifications(environment: NodeJS.ProcessEnv): boolean { - return isTruthy(environment.CI) || isTruthy(environment.SHOPIFY_UNIT_TEST) || jsonOutputEnabled() + return isTruthy(environment.CI) || isTruthy(environment.SHOPIFY_UNIT_TEST) || jsonOutputEnabled(environment) } /** From 740d15d4df309b0108c16ab2450c763e147b99b6 Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 13:19:37 +0100 Subject: [PATCH 08/11] Refresh manifests --- packages/cli/README.md | 25 ++++++++++++------------- packages/cli/oclif.manifest.json | 25 +++++++++++++++++-------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index 9ec6d84f714..bcac5dbbde3 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -344,7 +344,7 @@ USAGE FLAGS -c, --config= The name of the app configuration. - -j, --json Output the function run result as a JSON object. + -j, --json Output the result as JSON. -l, --log= 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. -w, --[no-]watch Re-run the function when the source code changes. @@ -373,7 +373,7 @@ FLAGS -c, --config= The name of the app configuration. -e, --export= Name of the WebAssembly export to invoke. -i, --input= The input JSON to pass to the function. If omitted, standard input is used. - -j, --json Log the run result as a JSON object. + -j, --json Output the result as JSON. --no-color Disable color output. --path= The path to your function directory. --verbose Increase the verbosity of the output. @@ -496,11 +496,11 @@ Print basic information about your app and extensions. ``` USAGE - $ shopify app info [-c ] [--json] [--no-color] [--path ] [--verbose] [--web-env] + $ shopify app info [-c ] [-j] [--no-color] [--path ] [--verbose] [--web-env] FLAGS -c, --config= The name of the app configuration. - --json format output as JSON + -j, --json Output the result as JSON. --no-color Disable color output. --path= The path to your app directory. --verbose Increase the verbosity of the output. @@ -554,7 +554,7 @@ USAGE FLAGS -c, --config= The name of the app configuration. - -j, --json Log the run result as a JSON object. + -j, --json Output the result as JSON. -s, --store=... Store URL. Must be an existing development or Shopify Plus sandbox store. --client-id= The Client ID of your app. --no-color Disable color output. @@ -629,13 +629,12 @@ List deployed versions of your app. ``` USAGE - $ shopify app versions list [FILE] [--client-id | -c ] [--json] [--no-color] [--path ] - [--verbose] + $ shopify app versions list [FILE] [--client-id | -c ] [-j] [--no-color] [--path ] [--verbose] FLAGS -c, --config= The name of the app configuration. + -j, --json Output the result as JSON. --client-id= The Client ID to fetch versions for. - --json Output the versions list as JSON. --no-color Disable color output. --path= The path to your app directory. --verbose Increase the verbosity of the output. @@ -1871,16 +1870,16 @@ Displays information about your theme environment, including your current store. ``` USAGE - $ shopify theme info [-d] [-e ] [--json] [--no-color] [--password ] [-s ] [-t ] + $ shopify theme info [-d] [-e ] [-j] [--no-color] [--password ] [-s ] [-t ] [--verbose] FLAGS -d, --development Retrieve info from your development theme. -e, --environment= The environment to apply to the current command. + -j, --json Output the result as JSON. -s, --store= Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com). -t, --theme= Theme ID or name of the remote theme. - --json Output the theme info as JSON. --no-color Disable color output. --password= Password generated from the Theme Access app. --verbose Increase the verbosity of the output. @@ -1948,15 +1947,15 @@ Lists the themes in your store, along with their IDs and statuses. ``` USAGE - $ shopify theme list [-e ] [--id ] [--json] [--name ] [--no-color] [--password ] + $ shopify theme list [-e ] [--id ] [-j] [--name ] [--no-color] [--password ] [--role live|unpublished|development] [-s ] [--verbose] FLAGS -e, --environment= The environment to apply to the current command. + -j, --json Output the result as JSON. -s, --store= Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com). --id= Only list theme with the given ID. - --json Output the theme list as JSON. --name= Only list themes that contain the given name. --no-color Disable color output. --password= Password generated from the Theme Access app. @@ -2106,7 +2105,7 @@ FLAGS -a, --allow-live Allow push to a live theme. -d, --development Push theme files from your remote development theme. -e, --environment= The environment to apply to the current command. - -j, --json Output JSON instead of a UI. + -j, --json Output the result as JSON. -l, --live Push theme files from your remote live theme. -n, --nodelete Prevent deleting remote files that don't exist locally. -o, --only=... Download only the specified files (Multiple flags allowed). diff --git a/packages/cli/oclif.manifest.json b/packages/cli/oclif.manifest.json index f0485425515..cfdf8c26b40 100644 --- a/packages/cli/oclif.manifest.json +++ b/packages/cli/oclif.manifest.json @@ -767,7 +767,7 @@ "json": { "allowNo": false, "char": "j", - "description": "Output the function run result as a JSON object.", + "description": "Output the result as JSON.", "env": "SHOPIFY_FLAG_JSON", "hidden": false, "name": "json", @@ -869,7 +869,7 @@ "json": { "allowNo": false, "char": "j", - "description": "Log the run result as a JSON object.", + "description": "Output the result as JSON.", "env": "SHOPIFY_FLAG_JSON", "hidden": false, "name": "json", @@ -1383,7 +1383,8 @@ }, "json": { "allowNo": false, - "description": "format output as JSON", + "char": "j", + "description": "Output the result as JSON.", "env": "SHOPIFY_FLAG_JSON", "hidden": false, "name": "json", @@ -1583,8 +1584,9 @@ "json": { "allowNo": false, "char": "j", - "description": "Log the run result as a JSON object.", + "description": "Output the result as JSON.", "env": "SHOPIFY_FLAG_JSON", + "hidden": false, "name": "json", "type": "boolean" }, @@ -1877,8 +1879,10 @@ }, "json": { "allowNo": false, - "description": "Output the versions list as JSON.", + "char": "j", + "description": "Output the result as JSON.", "env": "SHOPIFY_FLAG_JSON", + "hidden": false, "name": "json", "type": "boolean" }, @@ -5047,8 +5051,10 @@ }, "json": { "allowNo": false, - "description": "Output the theme info as JSON.", + "char": "j", + "description": "Output the result as JSON.", "env": "SHOPIFY_FLAG_JSON", + "hidden": false, "name": "json", "type": "boolean" }, @@ -5236,8 +5242,10 @@ }, "json": { "allowNo": false, - "description": "Output the theme list as JSON.", + "char": "j", + "description": "Output the result as JSON.", "env": "SHOPIFY_FLAG_JSON", + "hidden": false, "name": "json", "type": "boolean" }, @@ -5710,8 +5718,9 @@ "json": { "allowNo": false, "char": "j", - "description": "Output JSON instead of a UI.", + "description": "Output the result as JSON.", "env": "SHOPIFY_FLAG_JSON", + "hidden": false, "name": "json", "type": "boolean" }, From 2ca99425e212e720344240c257843fb5f0548419 Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 13:23:09 +0100 Subject: [PATCH 09/11] Update documentation --- .../app-function-replay.interface.ts | 2 +- .../interfaces/app-function-run.interface.ts | 2 +- .../commands/interfaces/app-info.interface.ts | 4 +- .../commands/interfaces/app-logs.interface.ts | 2 +- .../interfaces/app-versions-list.interface.ts | 4 +- .../interfaces/theme-info.interface.ts | 4 +- .../interfaces/theme-list.interface.ts | 4 +- .../interfaces/theme-push.interface.ts | 2 +- .../generated/generated_docs_data.json | 96 +++++++++---------- 9 files changed, 60 insertions(+), 60 deletions(-) diff --git a/docs-shopify.dev/commands/interfaces/app-function-replay.interface.ts b/docs-shopify.dev/commands/interfaces/app-function-replay.interface.ts index eb67cce1cdc..f7ed1544468 100644 --- a/docs-shopify.dev/commands/interfaces/app-function-replay.interface.ts +++ b/docs-shopify.dev/commands/interfaces/app-function-replay.interface.ts @@ -13,7 +13,7 @@ export interface appfunctionreplay { '-c, --config '?: string /** - * Output the function run result as a JSON object. + * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON */ '-j, --json'?: '' diff --git a/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts b/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts index 9d1173fc23c..c61acf6c36e 100644 --- a/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts +++ b/docs-shopify.dev/commands/interfaces/app-function-run.interface.ts @@ -19,7 +19,7 @@ export interface appfunctionrun { '-i, --input '?: string /** - * Log the run result as a JSON object. + * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON */ '-j, --json'?: '' diff --git a/docs-shopify.dev/commands/interfaces/app-info.interface.ts b/docs-shopify.dev/commands/interfaces/app-info.interface.ts index 09989ff2e89..9c0de90ee96 100644 --- a/docs-shopify.dev/commands/interfaces/app-info.interface.ts +++ b/docs-shopify.dev/commands/interfaces/app-info.interface.ts @@ -7,10 +7,10 @@ export interface appinfo { '-c, --config '?: string /** - * format output as JSON + * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON */ - '--json'?: '' + '-j, --json'?: '' /** * Disable color output. diff --git a/docs-shopify.dev/commands/interfaces/app-logs.interface.ts b/docs-shopify.dev/commands/interfaces/app-logs.interface.ts index 954067bdf5e..3ba6d882ff2 100644 --- a/docs-shopify.dev/commands/interfaces/app-logs.interface.ts +++ b/docs-shopify.dev/commands/interfaces/app-logs.interface.ts @@ -13,7 +13,7 @@ export interface applogs { '-c, --config '?: string /** - * Log the run result as a JSON object. + * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON */ '-j, --json'?: '' diff --git a/docs-shopify.dev/commands/interfaces/app-versions-list.interface.ts b/docs-shopify.dev/commands/interfaces/app-versions-list.interface.ts index 0b1efb13b83..0638ef3d92b 100644 --- a/docs-shopify.dev/commands/interfaces/app-versions-list.interface.ts +++ b/docs-shopify.dev/commands/interfaces/app-versions-list.interface.ts @@ -13,10 +13,10 @@ export interface appversionslist { '-c, --config '?: string /** - * Output the versions list as JSON. + * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON */ - '--json'?: '' + '-j, --json'?: '' /** * Disable color output. diff --git a/docs-shopify.dev/commands/interfaces/theme-info.interface.ts b/docs-shopify.dev/commands/interfaces/theme-info.interface.ts index 5a41b25b932..3c6db433d56 100644 --- a/docs-shopify.dev/commands/interfaces/theme-info.interface.ts +++ b/docs-shopify.dev/commands/interfaces/theme-info.interface.ts @@ -13,10 +13,10 @@ export interface themeinfo { '-e, --environment '?: string /** - * Output the theme info as JSON. + * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON */ - '--json'?: '' + '-j, --json'?: '' /** * Disable color output. diff --git a/docs-shopify.dev/commands/interfaces/theme-list.interface.ts b/docs-shopify.dev/commands/interfaces/theme-list.interface.ts index f8c97259aff..9a50fdf5845 100644 --- a/docs-shopify.dev/commands/interfaces/theme-list.interface.ts +++ b/docs-shopify.dev/commands/interfaces/theme-list.interface.ts @@ -13,10 +13,10 @@ export interface themelist { '--id '?: 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. diff --git a/docs-shopify.dev/commands/interfaces/theme-push.interface.ts b/docs-shopify.dev/commands/interfaces/theme-push.interface.ts index 8d026193669..07e48fb9076 100644 --- a/docs-shopify.dev/commands/interfaces/theme-push.interface.ts +++ b/docs-shopify.dev/commands/interfaces/theme-push.interface.ts @@ -25,7 +25,7 @@ export interface themepush { '-x, --ignore '?: string /** - * Output JSON instead of a UI. + * Output the result as JSON. * @environment SHOPIFY_FLAG_JSON */ '-j, --json'?: '' diff --git a/docs-shopify.dev/generated/generated_docs_data.json b/docs-shopify.dev/generated/generated_docs_data.json index bac2f1c5399..afc8958649e 100644 --- a/docs-shopify.dev/generated/generated_docs_data.json +++ b/docs-shopify.dev/generated/generated_docs_data.json @@ -868,7 +868,7 @@ "syntaxKind": "PropertySignature", "name": "-j, --json", "value": "\"\"", - "description": "Output the function run result as a JSON object.", + "description": "Output the result as JSON.", "isOptional": true, "environmentValue": "SHOPIFY_FLAG_JSON" }, @@ -891,7 +891,7 @@ "environmentValue": "SHOPIFY_FLAG_WATCH" } ], - "value": "export interface appfunctionreplay {\n /**\n * Application's Client ID\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Output the function run result as a JSON object.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * 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.\n * @environment SHOPIFY_FLAG_LOG\n */\n '-l, --log '?: string\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your function directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n\n /**\n * Re-run the function when the source code changes.\n * @environment SHOPIFY_FLAG_WATCH\n */\n '-w, --watch'?: ''\n}" + "value": "export interface appfunctionreplay {\n /**\n * Application's Client ID\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * 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.\n * @environment SHOPIFY_FLAG_LOG\n */\n '-l, --log '?: string\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your function directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n\n /**\n * Re-run the function when the source code changes.\n * @environment SHOPIFY_FLAG_WATCH\n */\n '-w, --watch'?: ''\n}" } } } @@ -987,12 +987,12 @@ "syntaxKind": "PropertySignature", "name": "-j, --json", "value": "\"\"", - "description": "Log the run result as a JSON object.", + "description": "Output the result as JSON.", "isOptional": true, "environmentValue": "SHOPIFY_FLAG_JSON" } ], - "value": "export interface appfunctionrun {\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Name of the WebAssembly export to invoke.\n * @environment SHOPIFY_FLAG_EXPORT\n */\n '-e, --export '?: string\n\n /**\n * The input JSON to pass to the function. If omitted, standard input is used.\n * @environment SHOPIFY_FLAG_INPUT\n */\n '-i, --input '?: string\n\n /**\n * Log the run result as a JSON object.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your function directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" + "value": "export interface appfunctionrun {\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Name of the WebAssembly export to invoke.\n * @environment SHOPIFY_FLAG_EXPORT\n */\n '-e, --export '?: string\n\n /**\n * The input JSON to pass to the function. If omitted, standard input is used.\n * @environment SHOPIFY_FLAG_INPUT\n */\n '-i, --input '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your function directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" } } } @@ -1406,15 +1406,6 @@ "name": "appinfo", "description": "", "members": [ - { - "filePath": "docs-shopify.dev/commands/interfaces/app-info.interface.ts", - "syntaxKind": "PropertySignature", - "name": "--json", - "value": "\"\"", - "description": "format output as JSON", - "isOptional": true, - "environmentValue": "SHOPIFY_FLAG_JSON" - }, { "filePath": "docs-shopify.dev/commands/interfaces/app-info.interface.ts", "syntaxKind": "PropertySignature", @@ -1459,9 +1450,18 @@ "description": "The name of the app configuration.", "isOptional": true, "environmentValue": "SHOPIFY_FLAG_APP_CONFIG" + }, + { + "filePath": "docs-shopify.dev/commands/interfaces/app-info.interface.ts", + "syntaxKind": "PropertySignature", + "name": "-j, --json", + "value": "\"\"", + "description": "Output the result as JSON.", + "isOptional": true, + "environmentValue": "SHOPIFY_FLAG_JSON" } ], - "value": "export interface appinfo {\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * format output as JSON\n * @environment SHOPIFY_FLAG_JSON\n */\n '--json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your app directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n\n /**\n * Outputs environment variables necessary for running and deploying web/.\n * @environment SHOPIFY_FLAG_OUTPUT_WEB_ENV\n */\n '--web-env'?: ''\n}" + "value": "export interface appinfo {\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your app directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n\n /**\n * Outputs environment variables necessary for running and deploying web/.\n * @environment SHOPIFY_FLAG_OUTPUT_WEB_ENV\n */\n '--web-env'?: ''\n}" } } } @@ -1759,7 +1759,7 @@ "syntaxKind": "PropertySignature", "name": "-j, --json", "value": "\"\"", - "description": "Log the run result as a JSON object.", + "description": "Output the result as JSON.", "isOptional": true, "environmentValue": "SHOPIFY_FLAG_JSON" }, @@ -1773,7 +1773,7 @@ "environmentValue": "SHOPIFY_FLAG_STORE" } ], - "value": "export interface applogs {\n /**\n * The Client ID of your app.\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Log the run result as a JSON object.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your app directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Reset all your settings.\n * @environment SHOPIFY_FLAG_RESET\n */\n '--reset'?: ''\n\n /**\n * Filters output to the specified log source.\n * @environment SHOPIFY_FLAG_SOURCE\n */\n '--source '?: string\n\n /**\n * Filters output to the specified status (success or failure).\n * @environment SHOPIFY_FLAG_STATUS\n */\n '--status '?: string\n\n /**\n * Store URL. Must be an existing development or Shopify Plus sandbox store.\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" + "value": "export interface applogs {\n /**\n * The Client ID of your app.\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your app directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Reset all your settings.\n * @environment SHOPIFY_FLAG_RESET\n */\n '--reset'?: ''\n\n /**\n * Filters output to the specified log source.\n * @environment SHOPIFY_FLAG_SOURCE\n */\n '--source '?: string\n\n /**\n * Filters output to the specified status (success or failure).\n * @environment SHOPIFY_FLAG_STATUS\n */\n '--status '?: string\n\n /**\n * Store URL. Must be an existing development or Shopify Plus sandbox store.\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" } } } @@ -1928,15 +1928,6 @@ "isOptional": true, "environmentValue": "SHOPIFY_FLAG_CLIENT_ID" }, - { - "filePath": "docs-shopify.dev/commands/interfaces/app-versions-list.interface.ts", - "syntaxKind": "PropertySignature", - "name": "--json", - "value": "\"\"", - "description": "Output the versions list as JSON.", - "isOptional": true, - "environmentValue": "SHOPIFY_FLAG_JSON" - }, { "filePath": "docs-shopify.dev/commands/interfaces/app-versions-list.interface.ts", "syntaxKind": "PropertySignature", @@ -1972,9 +1963,18 @@ "description": "The name of the app configuration.", "isOptional": true, "environmentValue": "SHOPIFY_FLAG_APP_CONFIG" + }, + { + "filePath": "docs-shopify.dev/commands/interfaces/app-versions-list.interface.ts", + "syntaxKind": "PropertySignature", + "name": "-j, --json", + "value": "\"\"", + "description": "Output the result as JSON.", + "isOptional": true, + "environmentValue": "SHOPIFY_FLAG_JSON" } ], - "value": "export interface appversionslist {\n /**\n * The Client ID to fetch versions for.\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Output the versions list as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '--json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your app directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" + "value": "export interface appversionslist {\n /**\n * The Client ID to fetch versions for.\n * @environment SHOPIFY_FLAG_CLIENT_ID\n */\n '--client-id '?: string\n\n /**\n * The name of the app configuration.\n * @environment SHOPIFY_FLAG_APP_CONFIG\n */\n '-c, --config '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The path to your app directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" } } } @@ -4993,15 +4993,6 @@ "name": "themeinfo", "description": "", "members": [ - { - "filePath": "docs-shopify.dev/commands/interfaces/theme-info.interface.ts", - "syntaxKind": "PropertySignature", - "name": "--json", - "value": "\"\"", - "description": "Output the theme info as JSON.", - "isOptional": true, - "environmentValue": "SHOPIFY_FLAG_JSON" - }, { "filePath": "docs-shopify.dev/commands/interfaces/theme-info.interface.ts", "syntaxKind": "PropertySignature", @@ -5047,6 +5038,15 @@ "isOptional": true, "environmentValue": "SHOPIFY_FLAG_ENVIRONMENT" }, + { + "filePath": "docs-shopify.dev/commands/interfaces/theme-info.interface.ts", + "syntaxKind": "PropertySignature", + "name": "-j, --json", + "value": "\"\"", + "description": "Output the result as JSON.", + "isOptional": true, + "environmentValue": "SHOPIFY_FLAG_JSON" + }, { "filePath": "docs-shopify.dev/commands/interfaces/theme-info.interface.ts", "syntaxKind": "PropertySignature", @@ -5066,7 +5066,7 @@ "environmentValue": "SHOPIFY_FLAG_THEME_ID" } ], - "value": "export interface themeinfo {\n /**\n * Retrieve info from your development theme.\n * @environment SHOPIFY_FLAG_DEVELOPMENT\n */\n '-d, --development'?: ''\n\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment '?: string\n\n /**\n * Output the theme info as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '--json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Password generated from the Theme Access app.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password '?: string\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store '?: string\n\n /**\n * Theme ID or name of the remote theme.\n * @environment SHOPIFY_FLAG_THEME_ID\n */\n '-t, --theme '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" + "value": "export interface themeinfo {\n /**\n * Retrieve info from your development theme.\n * @environment SHOPIFY_FLAG_DEVELOPMENT\n */\n '-d, --development'?: ''\n\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Password generated from the Theme Access app.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password '?: string\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store '?: string\n\n /**\n * Theme ID or name of the remote theme.\n * @environment SHOPIFY_FLAG_THEME_ID\n */\n '-t, --theme '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" } } } @@ -5251,15 +5251,6 @@ "isOptional": true, "environmentValue": "SHOPIFY_FLAG_ID" }, - { - "filePath": "docs-shopify.dev/commands/interfaces/theme-list.interface.ts", - "syntaxKind": "PropertySignature", - "name": "--json", - "value": "\"\"", - "description": "Output the theme list as JSON.", - "isOptional": true, - "environmentValue": "SHOPIFY_FLAG_JSON" - }, { "filePath": "docs-shopify.dev/commands/interfaces/theme-list.interface.ts", "syntaxKind": "PropertySignature", @@ -5314,6 +5305,15 @@ "isOptional": true, "environmentValue": "SHOPIFY_FLAG_ENVIRONMENT" }, + { + "filePath": "docs-shopify.dev/commands/interfaces/theme-list.interface.ts", + "syntaxKind": "PropertySignature", + "name": "-j, --json", + "value": "\"\"", + "description": "Output the result as JSON.", + "isOptional": true, + "environmentValue": "SHOPIFY_FLAG_JSON" + }, { "filePath": "docs-shopify.dev/commands/interfaces/theme-list.interface.ts", "syntaxKind": "PropertySignature", @@ -5324,7 +5324,7 @@ "environmentValue": "SHOPIFY_FLAG_STORE" } ], - "value": "export interface themelist {\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment '?: string\n\n /**\n * Only list theme with the given ID.\n * @environment SHOPIFY_FLAG_ID\n */\n '--id '?: string\n\n /**\n * Output the theme list as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '--json'?: ''\n\n /**\n * Only list themes that contain the given name.\n * @environment SHOPIFY_FLAG_NAME\n */\n '--name '?: string\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Password generated from the Theme Access app.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password '?: string\n\n /**\n * Only list themes with the given role.\n * @environment SHOPIFY_FLAG_ROLE\n */\n '--role '?: string\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" + "value": "export interface themelist {\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment '?: string\n\n /**\n * Only list theme with the given ID.\n * @environment SHOPIFY_FLAG_ID\n */\n '--id '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Only list themes that contain the given name.\n * @environment SHOPIFY_FLAG_NAME\n */\n '--name '?: string\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Password generated from the Theme Access app.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password '?: string\n\n /**\n * Only list themes with the given role.\n * @environment SHOPIFY_FLAG_ROLE\n */\n '--role '?: string\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store '?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" } } } @@ -5860,7 +5860,7 @@ "syntaxKind": "PropertySignature", "name": "-j, --json", "value": "\"\"", - "description": "Output JSON instead of a UI.", + "description": "Output the result as JSON.", "isOptional": true, "environmentValue": "SHOPIFY_FLAG_JSON" }, @@ -5937,7 +5937,7 @@ "environmentValue": "SHOPIFY_FLAG_IGNORE" } ], - "value": "export interface themepush {\n /**\n * Allow push to a live theme.\n * @environment SHOPIFY_FLAG_ALLOW_LIVE\n */\n '-a, --allow-live'?: ''\n\n /**\n * Push theme files from your remote development theme.\n * @environment SHOPIFY_FLAG_DEVELOPMENT\n */\n '-d, --development'?: ''\n\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment '?: string\n\n /**\n * Skip downloading the specified files (Multiple flags allowed).\n * @environment SHOPIFY_FLAG_IGNORE\n */\n '-x, --ignore '?: string\n\n /**\n * Output JSON instead of a UI.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Push theme files from your remote live theme.\n * @environment SHOPIFY_FLAG_LIVE\n */\n '-l, --live'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Prevent deleting remote files that don't exist locally.\n * @environment SHOPIFY_FLAG_NODELETE\n */\n '-n, --nodelete'?: ''\n\n /**\n * Download only the specified files (Multiple flags allowed).\n * @environment SHOPIFY_FLAG_ONLY\n */\n '-o, --only '?: string\n\n /**\n * Password generated from the Theme Access app.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password '?: string\n\n /**\n * The path to your theme directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Publish as the live theme after uploading.\n * @environment SHOPIFY_FLAG_PUBLISH\n */\n '-p, --publish'?: ''\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store '?: string\n\n /**\n * Theme ID or name of the remote theme.\n * @environment SHOPIFY_FLAG_THEME_ID\n */\n '-t, --theme '?: string\n\n /**\n * Create a new unpublished theme and push to it.\n * @environment SHOPIFY_FLAG_UNPUBLISHED\n */\n '-u, --unpublished'?: ''\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" + "value": "export interface themepush {\n /**\n * Allow push to a live theme.\n * @environment SHOPIFY_FLAG_ALLOW_LIVE\n */\n '-a, --allow-live'?: ''\n\n /**\n * Push theme files from your remote development theme.\n * @environment SHOPIFY_FLAG_DEVELOPMENT\n */\n '-d, --development'?: ''\n\n /**\n * The environment to apply to the current command.\n * @environment SHOPIFY_FLAG_ENVIRONMENT\n */\n '-e, --environment '?: string\n\n /**\n * Skip downloading the specified files (Multiple flags allowed).\n * @environment SHOPIFY_FLAG_IGNORE\n */\n '-x, --ignore '?: string\n\n /**\n * Output the result as JSON.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Push theme files from your remote live theme.\n * @environment SHOPIFY_FLAG_LIVE\n */\n '-l, --live'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * Prevent deleting remote files that don't exist locally.\n * @environment SHOPIFY_FLAG_NODELETE\n */\n '-n, --nodelete'?: ''\n\n /**\n * Download only the specified files (Multiple flags allowed).\n * @environment SHOPIFY_FLAG_ONLY\n */\n '-o, --only '?: string\n\n /**\n * Password generated from the Theme Access app.\n * @environment SHOPIFY_CLI_THEME_TOKEN\n */\n '--password '?: string\n\n /**\n * The path to your theme directory.\n * @environment SHOPIFY_FLAG_PATH\n */\n '--path '?: string\n\n /**\n * Publish as the live theme after uploading.\n * @environment SHOPIFY_FLAG_PUBLISH\n */\n '-p, --publish'?: ''\n\n /**\n * Store URL. It can be the store prefix (example) or the full myshopify.com URL (example.myshopify.com, https://example.myshopify.com).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store '?: string\n\n /**\n * Theme ID or name of the remote theme.\n * @environment SHOPIFY_FLAG_THEME_ID\n */\n '-t, --theme '?: string\n\n /**\n * Create a new unpublished theme and push to it.\n * @environment SHOPIFY_FLAG_UNPUBLISHED\n */\n '-u, --unpublished'?: ''\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}" } } } From 21d6b33287b3e9f3e10905102eeeae46f92737d3 Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 14:04:25 +0100 Subject: [PATCH 10/11] Keep a single reference of SHOPIFY_FLAG_JSON --- packages/cli-kit/src/private/node/constants.ts | 1 + packages/cli-kit/src/public/node/cli.ts | 3 ++- packages/cli-kit/src/public/node/environment.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cli-kit/src/private/node/constants.ts b/packages/cli-kit/src/private/node/constants.ts index 6337664367c..faee18c688e 100644 --- a/packages/cli-kit/src/private/node/constants.ts +++ b/packages/cli-kit/src/private/node/constants.ts @@ -44,6 +44,7 @@ export const environmentVariables = { refreshToken: 'SHOPIFY_CLI_REFRESH_TOKEN', otelURL: 'SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT', themeKitAccessDomain: 'SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN', + json: 'SHOPIFY_FLAG_JSON', } export const defaultThemeKitAccessDomain = 'theme-kit-access.shopifyapps.com' diff --git a/packages/cli-kit/src/public/node/cli.ts b/packages/cli-kit/src/public/node/cli.ts index 1150a546b50..6e07c9b5459 100644 --- a/packages/cli-kit/src/public/node/cli.ts +++ b/packages/cli-kit/src/public/node/cli.ts @@ -1,5 +1,6 @@ import {isTruthy} from './context/utilities.js' import {cacheClear} from '../../private/node/conf-store.js' +import {environmentVariables} from '../../private/node/constants.js' import {Flags} from '@oclif/core' /** @@ -141,7 +142,7 @@ export const jsonFlag = { description: 'Output the result as JSON.', hidden: false, default: false, - env: 'SHOPIFY_FLAG_JSON', + env: environmentVariables.json, }), } diff --git a/packages/cli-kit/src/public/node/environment.ts b/packages/cli-kit/src/public/node/environment.ts index 4ae9e6bc10f..43dd9d465f8 100644 --- a/packages/cli-kit/src/public/node/environment.ts +++ b/packages/cli-kit/src/public/node/environment.ts @@ -80,5 +80,5 @@ export function getIdentityTokenInformation(): {accessToken: string; refreshToke * @returns True if the JSON output is enabled, false otherwise. */ export function jsonOutputEnabled(environment = getEnvironmentVariables()): boolean { - return sniffForJson() || isTruthy(environment.SHOPIFY_FLAG_JSON) + return sniffForJson() || isTruthy(environment[environmentVariables.json]) } From 9ed8458c4ec8a040c0aeadf3ae77f9ad57d8608b Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Wed, 27 Nov 2024 14:25:36 +0100 Subject: [PATCH 11/11] Fix lint issue --- packages/cli-kit/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli-kit/package.json b/packages/cli-kit/package.json index 720d2d14ba5..33f0d9366b2 100644 --- a/packages/cli-kit/package.json +++ b/packages/cli-kit/package.json @@ -82,7 +82,6 @@ "./context/local.js", "./custom-oclif-loader.js", "@oclif/core", - "../../private/node/constants.js", "./path.js", "./system.js", "./ui.js" @@ -91,6 +90,7 @@ "@oclif/core", "./context/utilities.js", "../../private/node/conf-store.js", + "../../private/node/constants.js", "url" ] }