@sanity/cli 8.36.0 → 8.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/undeploy/runUndeploy.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes, type Output, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage, JsonOutputError} from '@sanity/cli-core/errors'\nimport {\n type UndeployAdapter,\n type UndeployTarget,\n type UndeployTargetResolution,\n} from '@sanity/cli-core/undeploy'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport {fetchDeploySummaryDetails, getWorkbenchUrl} from '@sanity/workbench-cli/deploy'\nimport {formatUndeploySummary} from '@sanity/workbench-cli/undeploy'\n\nimport {type UndeployCommand} from '../../commands/undeploy.js'\nimport {\n type CheckReporter,\n createCollectingReporter,\n createFailFastReporter,\n} from '../../util/checks.js'\nimport {toStderrOutput} from '../../util/toStderrOutput.js'\nimport {\n describeUndeployTarget,\n renderUndeployPlan,\n undeployLabel,\n type UndeployPlan,\n undeployPlanToJson,\n} from './undeployPlan.js'\n\nconst undeployDebug = subdebug('undeploy')\n\ntype UndeployFlags = UndeployCommand['flags']\n\nexport interface UndeployOptions {\n flags: UndeployFlags\n isUnattended: boolean\n output: Output\n}\n\n/** What a real undeploy produced — the payload `--json` reports. */\ntype UndeployResult =\n | {application: null; payload: null; reason: string; undeployed: false}\n | {\n application: object | null\n deletes: UndeployTarget['deletes']\n payload: UndeployTarget['payload']\n reason: null\n undeployed: true\n url: string | null\n }\n\n/**\n * Runs an undeploy in the mode the flags select: a real undeploy fails fast,\n * confirms, and deletes; `--dry-run` drives the same target resolution\n * read-only and renders a plan instead. `--json` emits the same information as\n * machine-readable JSON.\n */\nexport async function runUndeploy(\n options: UndeployOptions,\n adapter: UndeployAdapter,\n): Promise<void> {\n const {flags, output} = options\n const json = !!flags.json\n const emitJson = (payload: unknown) => output.logJson(payload)\n let failurePayload: unknown\n\n // The JSON payload owns stdout, so the run's progress logs go to stderr; only\n // the final JSON.stringify writes to stdout.\n const runOptions = json ? {...options, output: toStderrOutput(output)} : options\n\n try {\n if (flags['dry-run']) {\n const reporter = createCollectingReporter()\n const resolution = await resolveTarget(adapter, reporter)\n const plan: UndeployPlan = {\n checks: reporter.results,\n reason: resolution?.type === 'none' ? resolution.message : null,\n target: resolution?.type === 'found' ? resolution.target : null,\n type: adapter.type,\n }\n if (json) {\n const payload = undeployPlanToJson(plan)\n if (plan.checks.some((check) => check.status === 'fail')) failurePayload = payload\n else emitJson(payload)\n } else renderUndeployPlan(plan, output)\n // A blocked plan exits like a real (fail-fast) undeploy would.\n const failed = plan.checks.find((check) => check.status === 'fail')\n if (failed) output.error('Undeploy blocked by failing checks.', {exit: failed.exitCode ?? 1})\n return\n }\n\n const result = await undeployApp(runOptions, adapter)\n if (json && result) emitJson(result)\n } catch (error) {\n const failure = normalizeFailure(error, adapter.type)\n // Preserve the blocked plan or the existing undeployment failure envelope.\n if (json && !flags['dry-run']) {\n failurePayload = {\n application: null,\n error: {message: failure.message},\n payload: null,\n reason: failure.message,\n undeployed: false,\n }\n }\n if (json && failurePayload !== undefined) {\n throw new JsonOutputError(failure.message, failurePayload, failure.exit)\n }\n output.error(failure.message, {exit: failure.exit})\n }\n}\n\n/** The real run: resolve the target, confirm, delete, report. */\nasync function undeployApp(\n options: UndeployOptions,\n adapter: UndeployAdapter,\n): Promise<UndeployResult | undefined> {\n const {flags, output} = options\n const startedAt = Date.now()\n\n const resolution = await resolveTarget(adapter, createFailFastReporter(output))\n // A resolve failure never lands here: the fail-fast reporter already exited.\n if (!resolution) return undefined\n if (resolution.type === 'none') {\n output.log(`${resolution.message}.`)\n if (resolution.solution) output.log(`${resolution.solution}.`)\n output.log('Nothing to undeploy.')\n return {application: null, payload: null, reason: resolution.message, undeployed: false}\n }\n\n const {target} = resolution\n const summaryDetails =\n target.deletes === 'config' && !flags.json\n ? fetchDeploySummaryDetails(target.organizationId)\n : undefined\n\n if (!flags.yes && options.isUnattended) {\n throw new CLIError('Undeploy requires confirmation. Pass --yes to continue.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n\n if (!flags.yes) {\n const shouldUndeploy = await confirm({\n default: false,\n message: confirmUndeployMessage(target),\n })\n if (!shouldUndeploy) {\n throw new CLIError('Undeploy cancelled', {exit: exitCodes.USER_ABORT})\n }\n }\n\n const label = undeployLabel(target, adapter.type)\n const spin = spinner(`Undeploying ${label}`).start()\n try {\n await adapter.undeploy(target)\n } catch (error) {\n spin.fail()\n undeployDebug(`Error undeploying ${label}`, error)\n // Labeled here, where the target is known — `normalizeFailure` only sees the adapter type.\n throw new CLIError(`Error undeploying ${label}: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n spin.succeed()\n\n printUndeployed(target, output, {\n ...(await summaryDetails),\n durationMs: Date.now() - startedAt,\n })\n return {\n application: target.application ?? null,\n deletes: target.deletes,\n payload: target.payload,\n reason: null,\n undeployed: true,\n url: target.url,\n }\n}\n\n/**\n * Resolves the undeploy target and reports the verdict as a check, shared by\n * both modes so a real run and a dry run can't diverge.\n */\nasync function resolveTarget(\n adapter: UndeployAdapter,\n reporter: CheckReporter,\n): Promise<UndeployTargetResolution | null> {\n const spin = spinner('Checking application info').start()\n\n let resolution: UndeployTargetResolution\n try {\n resolution = await adapter.resolveTarget()\n } catch (error) {\n spin.fail()\n undeployDebug('Failed to resolve undeploy target', error)\n reporter.report({\n message: `Failed to resolve undeploy target: ${getErrorMessage(error)}`,\n status: 'fail',\n })\n return null\n }\n\n spin[resolution.type === 'found' ? 'succeed' : 'fail']()\n reporter.report(describeUndeployTarget(resolution))\n return resolution\n}\n\nfunction confirmUndeployMessage(target: UndeployTarget): string {\n if (target.deletes === 'config') {\n return `This will delete the ${styleText('yellow', target.title ?? 'deployed config')}.\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n }\n\n if (target.type === 'coreApp') {\n return `This will undeploy the following application:\n\n Title: ${styleText('yellow', target.title || '(untitled application)')}\n ID: ${styleText('yellow', target.id)}\n\nThe application will no longer be available for any of your users if you proceed.\n\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n }\n\n return `This will undeploy ${styleText('yellow', target.url ?? target.id)} and make it unavailable for your users.\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n}\n\nfunction printUndeployed(\n target: UndeployTarget,\n output: Output,\n summary: {durationMs: number; organizationName?: string | null},\n): void {\n if (target.deletes === 'config') {\n output.log(\n formatUndeploySummary({\n ...summary,\n organizationId: target.organizationId,\n title: target.title ?? 'Deployed config',\n url: target.url ?? getWorkbenchUrl(target.organizationId),\n }),\n )\n return\n }\n\n if (target.type === 'coreApp') {\n output.log(\n `\\n${styleText('bold', '⏱️ Application undeploy scheduled.')} It might be a few minutes until ${\n target.title ? styleText('italic', `'${target.title}'`) : 'your application'\n } is unavailable.`,\n )\n output.log(\n `\\n${styleText('bold', 'Remember to remove `deployment.appId` from your application configuration')} to avoid errors when redeploying.`,\n )\n return\n }\n\n output.log(\n `\\nStudio undeploy scheduled. It might be a few minutes until ${target.url ?? 'your studio'} is unavailable.`,\n )\n}\n\n/** The one failure diagnosis both the stderr message and the `--json` envelope read. */\nfunction normalizeFailure(\n error: unknown,\n type: UndeployAdapter['type'],\n): {exit: number; message: string} {\n // Ctrl+C on the confirmation prompt isn't a real failure\n if (error instanceof Error && error.name === 'ExitPromptError') {\n return {exit: exitCodes.USER_ABORT, message: 'Undeploy cancelled'}\n }\n // A failed check already carries its own message and exit code\n if (error instanceof CLIError) {\n return {exit: error.oclif?.exit ?? 1, message: error.message}\n }\n const label = type === 'coreApp' ? 'application' : 'studio'\n undeployDebug(`Error undeploying ${label}`, error)\n return {\n exit: exitCodes.RUNTIME_ERROR,\n message: `Error undeploying ${label}: ${getErrorMessage(error)}`,\n }\n}\n"],"names":["styleText","CLIError","exitCodes","subdebug","getErrorMessage","JsonOutputError","confirm","spinner","fetchDeploySummaryDetails","getWorkbenchUrl","formatUndeploySummary","createCollectingReporter","createFailFastReporter","toStderrOutput","describeUndeployTarget","renderUndeployPlan","undeployLabel","undeployPlanToJson","undeployDebug","runUndeploy","options","adapter","flags","output","json","emitJson","payload","logJson","failurePayload","runOptions","reporter","resolution","resolveTarget","plan","checks","results","reason","type","message","target","some","check","status","failed","find","error","exit","exitCode","result","undeployApp","failure","normalizeFailure","application","undeployed","undefined","startedAt","Date","now","log","solution","summaryDetails","deletes","organizationId","yes","isUnattended","USAGE_ERROR","shouldUndeploy","default","confirmUndeployMessage","USER_ABORT","label","spin","start","undeploy","fail","RUNTIME_ERROR","succeed","printUndeployed","durationMs","url","report","title","id","summary","Error","name","oclif"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,SAAS,EAAeC,QAAQ,QAAO,mBAAkB;AACjE,SAAQC,eAAe,EAAEC,eAAe,QAAO,0BAAyB;AAMxE,SAAQC,OAAO,EAAEC,OAAO,QAAO,sBAAqB;AACpD,SAAQC,yBAAyB,EAAEC,eAAe,QAAO,+BAA8B;AACvF,SAAQC,qBAAqB,QAAO,iCAAgC;AAGpE,SAEEC,wBAAwB,EACxBC,sBAAsB,QACjB,uBAAsB;AAC7B,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SACEC,sBAAsB,EACtBC,kBAAkB,EAClBC,aAAa,EAEbC,kBAAkB,QACb,oBAAmB;AAE1B,MAAMC,gBAAgBf,SAAS;AAsB/B;;;;;CAKC,GACD,OAAO,eAAegB,YACpBC,OAAwB,EACxBC,OAAwB;IAExB,MAAM,EAACC,KAAK,EAAEC,MAAM,EAAC,GAAGH;IACxB,MAAMI,OAAO,CAAC,CAACF,MAAME,IAAI;IACzB,MAAMC,WAAW,CAACC,UAAqBH,OAAOI,OAAO,CAACD;IACtD,IAAIE;IAEJ,8EAA8E;IAC9E,6CAA6C;IAC7C,MAAMC,a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,IAAI,cAAc,gBAAgB,CAAC;AAEjH;AAEA,sFAAsF,GACtF,SAAS5B,iBACPN,KAAc,EACdR,IAA6B;IAE7B,yDAAyD;IACzD,IAAIQ,iBAAiBuC,SAASvC,MAAMwC,IAAI,KAAK,mBAAmB;QAC9D,OAAO;YAACvC,MAAM5C,UAAUmE,UAAU;YAAE/B,SAAS;QAAoB;IACnE;IACA,+DAA+D;IAC/D,IAAIO,iBAAiB5C,UAAU;QAC7B,OAAO;YAAC6C,MAAMD,MAAMyC,KAAK,EAAExC,QAAQ;YAAGR,SAASO,MAAMP,OAAO;QAAA;IAC9D;IACA,MAAMgC,QAAQjC,SAAS,YAAY,gBAAgB;IACnDnB,cAAc,CAAC,kBAAkB,EAAEoD,OAAO,EAAEzB;IAC5C,OAAO;QACLC,MAAM5C,UAAUyE,aAAa;QAC7BrC,SAAS,CAAC,kBAAkB,EAAEgC,MAAM,EAAE,EAAElE,gBAAgByC,QAAQ;IAClE;AACF"}
1
+ {"version":3,"sources":["../../../src/actions/undeploy/runUndeploy.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {CLIError} from '@oclif/core/errors'\nimport {exitCodes, type Output, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage, JsonOutputError} from '@sanity/cli-core/errors'\nimport {\n type UndeployAdapter,\n type UndeployTarget,\n type UndeployTargetResolution,\n} from '@sanity/cli-core/undeploy'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport {fetchDeploySummaryDetails, getWorkbenchUrl} from '@sanity/workbench-cli/deploy'\nimport {formatUndeploySummary} from '@sanity/workbench-cli/undeploy'\n\nimport {type UndeployCommand} from '../../commands/undeploy.js'\nimport {\n type CheckReporter,\n createCollectingReporter,\n createFailFastReporter,\n} from '../../util/checks.js'\nimport {toStderrOutput} from '../../util/toStderrOutput.js'\nimport {\n describeUndeployTarget,\n renderUndeployPlan,\n undeployLabel,\n type UndeployPlan,\n undeployPlanToJson,\n} from './undeployPlan.js'\n\nconst undeployDebug = subdebug('undeploy')\n\ntype UndeployFlags = UndeployCommand['flags']\n\nexport interface UndeployOptions {\n flags: UndeployFlags\n isUnattended: boolean\n output: Output\n}\n\n/** What a real undeploy produced — the payload `--json` reports. */\ntype UndeployResult =\n | {application: null; payload: null; reason: string; undeployed: false}\n | {\n application: object | null\n deletes: UndeployTarget['deletes']\n organizationId?: string\n organizationName?: string | null\n payload: UndeployTarget['payload']\n reason: null\n undeployed: true\n undeployedBy?: string | null\n url: string | null\n }\n\n/**\n * Runs an undeploy in the mode the flags select: a real undeploy fails fast,\n * confirms, and deletes; `--dry-run` drives the same target resolution\n * read-only and renders a plan instead. `--json` emits the same information as\n * machine-readable JSON.\n */\nexport async function runUndeploy(\n options: UndeployOptions,\n adapter: UndeployAdapter,\n): Promise<void> {\n const {flags, output} = options\n const json = !!flags.json\n const emitJson = (payload: unknown) => output.logJson(payload)\n let failurePayload: unknown\n\n // The JSON payload owns stdout, so the run's progress logs go to stderr; only\n // the final JSON.stringify writes to stdout.\n const runOptions = json ? {...options, output: toStderrOutput(output)} : options\n\n try {\n if (flags['dry-run']) {\n const reporter = createCollectingReporter()\n const resolution = await resolveTarget(adapter, reporter)\n const plan: UndeployPlan = {\n checks: reporter.results,\n reason: resolution?.type === 'none' ? resolution.message : null,\n target: resolution?.type === 'found' ? resolution.target : null,\n type: adapter.type,\n }\n if (json) {\n const payload = undeployPlanToJson(plan)\n if (plan.checks.some((check) => check.status === 'fail')) failurePayload = payload\n else emitJson(payload)\n } else renderUndeployPlan(plan, output)\n // A blocked plan exits like a real (fail-fast) undeploy would.\n const failed = plan.checks.find((check) => check.status === 'fail')\n if (failed) output.error('Undeploy blocked by failing checks.', {exit: failed.exitCode ?? 1})\n return\n }\n\n const result = await undeployApp(runOptions, adapter)\n if (json && result) emitJson(result)\n } catch (error) {\n const failure = normalizeFailure(error, adapter.type)\n // Preserve the blocked plan or the existing undeployment failure envelope.\n if (json && !flags['dry-run']) {\n failurePayload = {\n application: null,\n error: {message: failure.message},\n payload: null,\n reason: failure.message,\n undeployed: false,\n }\n }\n if (json && failurePayload !== undefined) {\n throw new JsonOutputError(failure.message, failurePayload, failure.exit)\n }\n output.error(failure.message, {exit: failure.exit})\n }\n}\n\n/** The real run: resolve the target, confirm, delete, report. */\nasync function undeployApp(\n options: UndeployOptions,\n adapter: UndeployAdapter,\n): Promise<UndeployResult | undefined> {\n const {flags, output} = options\n const startedAt = Date.now()\n\n const resolution = await resolveTarget(adapter, createFailFastReporter(output))\n // A resolve failure never lands here: the fail-fast reporter already exited.\n if (!resolution) return undefined\n if (resolution.type === 'none') {\n output.log(`${resolution.message}.`)\n if (resolution.solution) output.log(`${resolution.solution}.`)\n output.log('Nothing to undeploy.')\n return {application: null, payload: null, reason: resolution.message, undeployed: false}\n }\n\n const {target} = resolution\n const summaryDetails = target.organizationId\n ? fetchDeploySummaryDetails(target.organizationId)\n : undefined\n\n if (!flags.yes && options.isUnattended) {\n throw new CLIError('Undeploy requires confirmation. Pass --yes to continue.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n\n if (!flags.yes) {\n const shouldUndeploy = await confirm({\n default: false,\n message: confirmUndeployMessage(target),\n })\n if (!shouldUndeploy) {\n throw new CLIError('Undeploy cancelled', {exit: exitCodes.USER_ABORT})\n }\n }\n\n const label = undeployLabel(target, adapter.type)\n const spin = spinner(`Undeploying ${label}`).start()\n try {\n await adapter.undeploy(target)\n } catch (error) {\n spin.fail()\n undeployDebug(`Error undeploying ${label}`, error)\n // Labeled here, where the target is known — `normalizeFailure` only sees the adapter type.\n throw new CLIError(`Error undeploying ${label}: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n spin.succeed()\n\n const details = await summaryDetails\n printUndeployed(target, output, {...details, durationMs: Date.now() - startedAt})\n\n return {\n application: target.application ?? null,\n deletes: target.deletes,\n payload: target.payload,\n reason: null,\n undeployed: true,\n url: target.url,\n ...(target.organizationId && {\n organizationId: target.organizationId,\n organizationName: details?.organizationName ?? null,\n undeployedBy: details?.userName ?? null,\n }),\n }\n}\n\n/**\n * Resolves the undeploy target and reports the verdict as a check, shared by\n * both modes so a real run and a dry run can't diverge.\n */\nasync function resolveTarget(\n adapter: UndeployAdapter,\n reporter: CheckReporter,\n): Promise<UndeployTargetResolution | null> {\n const spin = spinner('Checking application info').start()\n\n let resolution: UndeployTargetResolution\n try {\n resolution = await adapter.resolveTarget()\n } catch (error) {\n spin.fail()\n undeployDebug('Failed to resolve undeploy target', error)\n reporter.report({\n message: `Failed to resolve undeploy target: ${getErrorMessage(error)}`,\n status: 'fail',\n })\n return null\n }\n\n spin[resolution.type === 'found' ? 'succeed' : 'fail']()\n reporter.report(describeUndeployTarget(resolution))\n return resolution\n}\n\nfunction confirmUndeployMessage(target: UndeployTarget): string {\n if (target.deletes === 'config') {\n return `This will delete the ${styleText('yellow', target.title ?? 'deployed config')}.\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n }\n\n if (target.type === 'coreApp') {\n return `This will undeploy the following application:\n\n Title: ${styleText('yellow', target.title || '(untitled application)')}\n ID: ${styleText('yellow', target.id)}\n\nThe application will no longer be available for any of your users if you proceed.\n\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n }\n\n return `This will undeploy ${styleText('yellow', target.url ?? target.id)} and make it unavailable for your users.\nAre you ${styleText('red', 'sure')} you want to undeploy?`\n}\n\nfunction printUndeployed(\n target: UndeployTarget,\n output: Output,\n summary: {\n durationMs: number\n hostSlug?: string | null\n organizationName?: string | null\n userName?: string | null\n },\n): void {\n if (target.deletes === 'config') {\n output.log(\n formatUndeploySummary({\n ...summary,\n organizationId: target.organizationId,\n title: target.title ?? 'Deployed config',\n url: target.url ?? getWorkbenchUrl(target.organizationId),\n }),\n )\n return\n }\n\n if (target.organizationId) {\n output.log(\n formatUndeploySummary({\n ...summary,\n organizationId: target.organizationId,\n title: target.title ?? target.id,\n type: target.type,\n url: getWorkbenchUrl(target.organizationId, summary.hostSlug),\n }),\n )\n return\n }\n\n if (target.type === 'coreApp') {\n output.log(\n `\\n${styleText('bold', '⏱️ Application undeploy scheduled.')} It might be a few minutes until ${\n target.title ? styleText('italic', `'${target.title}'`) : 'your application'\n } is unavailable.`,\n )\n output.log(\n `\\n${styleText('bold', 'Remember to remove `deployment.appId` from your application configuration')} to avoid errors when redeploying.`,\n )\n return\n }\n\n output.log(\n `\\nStudio undeploy scheduled. It might be a few minutes until ${target.url ?? 'your studio'} is unavailable.`,\n )\n}\n\n/** The one failure diagnosis both the stderr message and the `--json` envelope read. */\nfunction normalizeFailure(\n error: unknown,\n type: UndeployAdapter['type'],\n): {exit: number; message: string} {\n // Ctrl+C on the confirmation prompt isn't a real failure\n if (error instanceof Error && error.name === 'ExitPromptError') {\n return {exit: exitCodes.USER_ABORT, message: 'Undeploy cancelled'}\n }\n // A failed check already carries its own message and exit code\n if (error instanceof CLIError) {\n return {exit: error.oclif?.exit ?? 1, message: error.message}\n }\n const label = type === 'coreApp' ? 'application' : 'studio'\n undeployDebug(`Error undeploying ${label}`, error)\n return {\n exit: exitCodes.RUNTIME_ERROR,\n message: `Error undeploying ${label}: ${getErrorMessage(error)}`,\n }\n}\n"],"names":["styleText","CLIError","exitCodes","subdebug","getErrorMessage","JsonOutputError","confirm","spinner","fetchDeploySummaryDetails","getWorkbenchUrl","formatUndeploySummary","createCollectingReporter","createFailFastReporter","toStderrOutput","describeUndeployTarget","renderUndeployPlan","undeployLabel","undeployPlanToJson","undeployDebug","runUndeploy","options","adapter","flags","output","json","emitJson","payload","logJson","failurePayload","runOptions","reporter","resolution","resolveTarget","plan","checks","results","reason","type","message","target","some","check","status","failed","find","error","exit","exitCode","result","undeployApp","failure","normalizeFailure","application","undeployed","undefined","startedAt","Date","now","log","solution","summaryDetails","organizationId","yes","isUnattended","USAGE_ERROR","shouldUndeploy","default","confirmUndeployMessage","USER_ABORT","label","spin","start","undeploy","fail","RUNTIME_ERROR","succeed","details","printUndeployed","durationMs","deletes","url","organizationName","undeployedBy","userName","report","title","id","summary","hostS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B,CAAC;AAEjH;AAEA,sFAAsF,GACtF,SAAS7B,iBACPN,KAAc,EACdR,IAA6B;IAE7B,yDAAyD;IACzD,IAAIQ,iBAAiB4C,SAAS5C,MAAM6C,IAAI,KAAK,mBAAmB;QAC9D,OAAO;YAAC5C,MAAM5C,UAAUkE,UAAU;YAAE9B,SAAS;QAAoB;IACnE;IACA,+DAA+D;IAC/D,IAAIO,iBAAiB5C,UAAU;QAC7B,OAAO;YAAC6C,MAAMD,MAAM8C,KAAK,EAAE7C,QAAQ;YAAGR,SAASO,MAAMP,OAAO;QAAA;IAC9D;IACA,MAAM+B,QAAQhC,SAAS,YAAY,gBAAgB;IACnDnB,cAAc,CAAC,kBAAkB,EAAEmD,OAAO,EAAExB;IAC5C,OAAO;QACLC,MAAM5C,UAAUwE,aAAa;QAC7BpC,SAAS,CAAC,kBAAkB,EAAE+B,MAAM,EAAE,EAAEjE,gBAAgByC,QAAQ;IAClE;AACF"}
@@ -1,5 +1,6 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { SanityCommand } from '@sanity/cli-core';
3
+ import { startBuildSummary } from '@sanity/workbench-cli/build';
3
4
  import { buildApp } from '../actions/build/buildApp.js';
4
5
  import { buildStudio } from '../actions/build/buildStudio.js';
5
6
  import { shouldAutoUpdate } from '../actions/build/shouldAutoUpdate.js';
@@ -51,8 +52,12 @@ export class BuildCommand extends SanityCommand {
51
52
  flags,
52
53
  output
53
54
  });
55
+ const summarize = startBuildSummary({
56
+ cliConfig,
57
+ isApp
58
+ });
54
59
  const buildFunc = isApp ? buildApp : buildStudio;
55
- await buildFunc({
60
+ const { mfManifest } = await buildFunc({
56
61
  autoUpdatesEnabled,
57
62
  cliConfig,
58
63
  flags,
@@ -60,6 +65,8 @@ export class BuildCommand extends SanityCommand {
60
65
  output,
61
66
  workDir
62
67
  });
68
+ // A Dashboard build without a manifest stopped at the version mismatch prompt.
69
+ if (summarize && mfManifest) output.log(await summarize());
63
70
  }
64
71
  }
65
72
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/build.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {buildApp} from '../actions/build/buildApp.js'\nimport {buildStudio} from '../actions/build/buildStudio.js'\nimport {shouldAutoUpdate} from '../actions/build/shouldAutoUpdate.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\n\nexport class BuildCommand extends SanityCommand<typeof BuildCommand> {\n static override args = {\n outputDir: Args.directory({description: 'Output directory'}),\n }\n\n static override description = 'Build Sanity Studio into a static bundle'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %>',\n '<%= config.bin %> <%= command.id %> --no-minify --source-maps',\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n description: 'Enable/disable auto updates of studio versions',\n }),\n minify: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Enable/disable minifying of built bundles',\n }),\n 'source-maps': Flags.boolean({\n allowNo: true,\n default: false,\n description: 'Enable source maps for built bundles (increases size of bundle)',\n }),\n stats: Flags.boolean({\n default: false,\n description: 'Show stats about the built bundles',\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description:\n 'Unattended mode, answers \"yes\" to any \"yes/no\" prompt and otherwise uses defaults',\n }),\n }\n\n public async run(): Promise<void> {\n const cliConfig = await this.getCliConfig()\n\n const {flags} = await this.parse(BuildCommand)\n\n const isApp = determineIsApp(cliConfig)\n\n const workDir = (await this.getProjectRoot()).directory\n\n const output = this.output\n\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n const buildFunc = isApp ? buildApp : buildStudio\n await buildFunc({\n autoUpdatesEnabled,\n cliConfig,\n flags,\n outDir: this.args.outputDir,\n output,\n workDir,\n })\n }\n}\n"],"names":["Args","Flags","SanityCommand","buildApp","buildStudio","shouldAutoUpdate","determineIsApp","BuildCommand","args","outputDir","directory","description","examples","flags","boolean","allowNo","minify","default","stats","yes","char","run","cliConfig","getCliConfig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ACrC,MAAM0B,UAAU;YACdD;YACAP;YACAT;YACAkB,QAAQ,IAAI,CAACvB,IAAI,CAACC,SAAS;YAC3BmB;YACAF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/commands/build.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\nimport {startBuildSummary} from '@sanity/workbench-cli/build'\n\nimport {buildApp} from '../actions/build/buildApp.js'\nimport {buildStudio} from '../actions/build/buildStudio.js'\nimport {shouldAutoUpdate} from '../actions/build/shouldAutoUpdate.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\n\nexport class BuildCommand extends SanityCommand<typeof BuildCommand> {\n static override args = {\n outputDir: Args.directory({description: 'Output directory'}),\n }\n\n static override description = 'Build Sanity Studio into a static bundle'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %>',\n '<%= config.bin %> <%= command.id %> --no-minify --source-maps',\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n description: 'Enable/disable auto updates of studio versions',\n }),\n minify: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Enable/disable minifying of built bundles',\n }),\n 'source-maps': Flags.boolean({\n allowNo: true,\n default: false,\n description: 'Enable source maps for built bundles (increases size of bundle)',\n }),\n stats: Flags.boolean({\n default: false,\n description: 'Show stats about the built bundles',\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description:\n 'Unattended mode, answers \"yes\" to any \"yes/no\" prompt and otherwise uses defaults',\n }),\n }\n\n public async run(): Promise<void> {\n const cliConfig = await this.getCliConfig()\n\n const {flags} = await this.parse(BuildCommand)\n\n const isApp = determineIsApp(cliConfig)\n\n const workDir = (await this.getProjectRoot()).directory\n\n const output = this.output\n\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n const summarize = startBuildSummary({cliConfig, isApp})\n const buildFunc = isApp ? buildApp : buildStudio\n const {mfManifest} = await buildFunc({\n autoUpdatesEnabled,\n cliConfig,\n flags,\n outDir: this.args.outputDir,\n output,\n workDir,\n })\n\n // A Dashboard build without a manifest stopped at the version mismatch prompt.\n if (summarize && mfManifest) output.log(await summarize())\n }\n}\n"],"names":["Args","Flags","SanityCommand","startBuildSummary","buildApp","buildStudio","shouldAutoUpdate","determineIsApp","BuildCommand","args","outputDir","directory","description","examples","flags","boolean","allowNo","minify","default","stats","yes","char","run","cliConfig","getCliConfig","parse","isApp","workDir","getProjectRoot","output","autoUpdatesEnabled","summarize","buildFunc","mfManifest","outDir","log"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,SAAQC,iBAAiB,QAAO,8BAA6B;AAE7D,SAAQC,QAAQ,QAAO,+BAA8B;AACrD,SAAQC,WAAW,QAAO,kCAAiC;AAC3D,SAAQC,gBAAgB,QAAO,uCAAsC;AACrE,SAAQC,cAAc,QAAO,4BAA2B;AAExD,OAAO,MAAMC,qBAAqBN;IAChC,OAAgBO,OAAO;QACrBC,WAAWV,KAAKW,SAAS,CAAC;YAACC,aAAa;QAAkB;IAC5D,EAAC;IAED,OAAgBA,cAAc,2CAA0C;IAExE,OAAgBC,WAAW;QACzB;QACA;KACD,CAAA;IAED,OAAgBC,QAAQ;QACtB,gBAAgBb,MAAMc,OAAO,CAAC;YAC5BC,SAAS;YACTJ,aAAa;QACf;QACAK,QAAQhB,MAAMc,OAAO,CAAC;YACpBC,SAAS;YACTE,SAAS;YACTN,aAAa;QACf;QACA,eAAeX,MAAMc,OAAO,CAAC;YAC3BC,SAAS;YACTE,SAAS;YACTN,aAAa;QACf;QACAO,OAAOlB,MAAMc,OAAO,CAAC;YACnBG,SAAS;YACTN,aAAa;QACf;QACAQ,KAAKnB,MAAMc,OAAO,CAAC;YACjBM,MAAM;YACNH,SAAS;YACTN,aACE;QACJ;IACF,EAAC;IAED,MAAaU,MAAqB;QAChC,MAAMC,YAAY,MAAM,IAAI,CAACC,YAAY;QAEzC,MAAM,EAACV,KAAK,EAAC,GAAG,MAAM,IAAI,CAACW,KAAK,CAACjB;QAEjC,MAAMkB,QAAQnB,eAAegB;QAE7B,MAAMI,UAAU,AAAC,CAAA,MAAM,IAAI,CAACC,cAAc,EAAC,EAAGjB,SAAS;QAEvD,MAAMkB,SAAS,IAAI,CAACA,MAAM;QAE1B,MAAMC,qBAAqBxB,iBAAiB;YAACiB;YAAWT;YAAOe;QAAM;QAErE,MAAME,YAAY5B,kBAAkB;YAACoB;YAAWG;QAAK;QACrD,MAAMM,YAAYN,QAAQtB,WAAWC;QACrC,MAAM,EAAC4B,UAAU,EAAC,GAAG,MAAMD,UAAU;YACnCF;YACAP;YACAT;YACAoB,QAAQ,IAAI,CAACzB,IAAI,CAACC,SAAS;YAC3BmB;YACAF;QACF;QAEA,+EAA+E;QAC/E,IAAII,aAAaE,YAAYJ,OAAOM,GAAG,CAAC,MAAMJ;IAChD;AACF"}
@@ -2,8 +2,9 @@ import { Args, Flags } from '@oclif/core';
2
2
  import { colorizeJson, exitCodes, getProjectCliClient, SanityCommand, subdebug } from '@sanity/cli-core';
3
3
  import { getCliExecutionContext } from '@sanity/cli-core/executionContext';
4
4
  import { DOCUMENTS_API_VERSION } from '../../actions/documents/constants.js';
5
+ import { resolveCommandTarget } from '../../actions/targets/resolveCommandTarget.js';
5
6
  import { promptForProject } from '../../prompts/promptForProject.js';
6
- import { getDatasetFlag, getProjectIdFlag } from '../../util/sharedFlags.js';
7
+ import { getDatasetFlag, getProjectIdFlag, getWithBlueprintsFlag } from '../../util/sharedFlags.js';
7
8
  const queryDocumentDebug = subdebug('documents:query');
8
9
  export class QueryDocumentCommand extends SanityCommand {
9
10
  static args = {
@@ -40,6 +41,7 @@ export class QueryDocumentCommand extends SanityCommand {
40
41
  description: 'Dataset to query',
41
42
  semantics: 'override'
42
43
  }),
44
+ ...getWithBlueprintsFlag(),
43
45
  anonymous: Flags.boolean({
44
46
  default: false,
45
47
  description: 'Send the query without any authorization token'
@@ -59,17 +61,14 @@ export class QueryDocumentCommand extends SanityCommand {
59
61
  const { args, flags } = await this.parse(QueryDocumentCommand);
60
62
  const { query } = args;
61
63
  const { anonymous, 'api-version': apiVersion, dataset, pretty } = flags;
62
- const cliConfig = await this.tryGetCliConfig();
63
- const projectId = await this.getProjectId({
64
- fallback: ()=>promptForProject({})
65
- });
64
+ const { dataset: targetDataset, projectId } = flags['with-blueprints'] ? await resolveCommandTarget({
65
+ dataset,
66
+ loadCliConfig: ()=>this.tryGetCliConfig(),
67
+ needsDataset: true,
68
+ project: flags.project,
69
+ unattended: this.isUnattended()
70
+ }) : await this.resolveClassicTarget(dataset);
66
71
  const requireUser = !anonymous;
67
- if (!cliConfig.api?.dataset && !dataset) {
68
- this.error('Dataset is required. Pass it with `--dataset <name>` or configure it in `sanity.cli.ts`.', {
69
- exit: exitCodes.USAGE_ERROR
70
- });
71
- }
72
- const targetDataset = dataset || cliConfig.api?.dataset;
73
72
  const configuredApiVersion = apiVersion ?? (getCliExecutionContext() ? undefined : process.env.SANITY_CLI_QUERY_API_VERSION);
74
73
  const targetApiVersion = configuredApiVersion || DOCUMENTS_API_VERSION;
75
74
  if (!configuredApiVersion) {
@@ -104,6 +103,22 @@ export class QueryDocumentCommand extends SanityCommand {
104
103
  });
105
104
  }
106
105
  }
106
+ async resolveClassicTarget(datasetFlag) {
107
+ const cliConfig = await this.tryGetCliConfig();
108
+ const projectId = await this.getProjectId({
109
+ fallback: ()=>promptForProject({})
110
+ });
111
+ const dataset = datasetFlag || cliConfig.api?.dataset;
112
+ if (!dataset) {
113
+ this.error('Dataset is required. Pass it with `--dataset <name>` or configure it in `sanity.cli.ts`.', {
114
+ exit: exitCodes.USAGE_ERROR
115
+ });
116
+ }
117
+ return {
118
+ dataset,
119
+ projectId
120
+ };
121
+ }
107
122
  }
108
123
 
109
124
  //# sourceMappingURL=query.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/documents/query.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {\n colorizeJson,\n exitCodes,\n getProjectCliClient,\n SanityCommand,\n subdebug,\n} from '@sanity/cli-core'\nimport {getCliExecutionContext} from '@sanity/cli-core/executionContext'\n\nimport {DOCUMENTS_API_VERSION} from '../../actions/documents/constants.js'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {getDatasetFlag, getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst queryDocumentDebug = subdebug('documents:query')\n\nexport class QueryDocumentCommand extends SanityCommand<typeof QueryDocumentCommand> {\n static override args = {\n query: Args.string({\n description: 'GROQ query to run against the dataset',\n required: true,\n }),\n }\n\n static override description = 'Query for documents'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> \\'*[_type == \"movie\"][0..4]\\'',\n description: 'Fetch 5 documents of type \"movie\"',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> \\'*[_type == \"movie\"]|order(releaseDate asc)[0]{title}\\' --dataset staging',\n description: 'Fetch title of the oldest movie in the dataset named \"staging\"',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> \\'*[_id == \"header\"] { \"headerText\": pt::text(body) }\\' --api-version v2021-06-07',\n description: 'Use API version v2021-06-07 and do a query',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> \\'*[_type == \"post\"]\\' --project abc123 --dataset production',\n description: 'Query documents in a specific project and dataset',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({description: 'Project ID to query', semantics: 'override'}),\n ...getDatasetFlag({description: 'Dataset to query', semantics: 'override'}),\n anonymous: Flags.boolean({\n default: false,\n description: 'Send the query without any authorization token',\n }),\n 'api-version': Flags.string({\n description: `API version to use (defaults to ${DOCUMENTS_API_VERSION})`,\n }),\n pretty: Flags.boolean({\n default: false,\n description: 'Colorize JSON output',\n }),\n }\n\n static override hiddenAliases: string[] = ['document:query']\n\n public async run(): Promise<void> {\n const {args, flags} = await this.parse(QueryDocumentCommand)\n const {query} = args\n const {anonymous, 'api-version': apiVersion, dataset, pretty} = flags\n\n const cliConfig = await this.tryGetCliConfig()\n\n const projectId = await this.getProjectId({\n fallback: () => promptForProject({}),\n })\n\n const requireUser = !anonymous\n\n if (!cliConfig.api?.dataset && !dataset) {\n this.error(\n 'Dataset is required. Pass it with `--dataset <name>` or configure it in `sanity.cli.ts`.',\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n\n const targetDataset = dataset || cliConfig.api?.dataset\n const configuredApiVersion =\n apiVersion ??\n (getCliExecutionContext() ? undefined : process.env.SANITY_CLI_QUERY_API_VERSION)\n const targetApiVersion = configuredApiVersion || DOCUMENTS_API_VERSION\n\n if (!configuredApiVersion) {\n this.warn(`--api-version not specified, using \\`${DOCUMENTS_API_VERSION}\\``)\n }\n\n try {\n const projectClient = await getProjectCliClient({\n apiVersion: targetApiVersion,\n dataset: targetDataset,\n projectId,\n requireUser,\n })\n\n const docs = await projectClient.fetch(query)\n\n if (!docs) {\n this.error('Query returned no results', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n // Output the query results\n if (pretty) {\n this.log(colorizeJson(docs))\n } else {\n this.log(JSON.stringify(docs, null, 2))\n }\n } catch (error) {\n const err = error as Error\n\n queryDocumentDebug(`Error running query: ${query}`, err)\n\n // Provide more context in error messages\n const errorMsg = err.message.toLowerCase().includes('syntax')\n ? `Invalid GROQ query syntax: ${err.message}`\n : `Failed to run query: ${err.message}`\n\n this.error(`${errorMsg}\\nQuery: ${query}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n}\n"],"names":["Args","Flags","colorizeJson","exitCodes","getProjectCliClient","SanityCommand","subdebug","getCliExecutionContext","DOCUMENTS_API_VERSION","promptForProject","getDatasetFlag","getProjectIdFlag","queryDocumentDebug","QueryDocumentCommand","args","query","string","description","required","examples","command","flags","semantics","anonymous","boolean","default","pretty","hiddenAliases","run","parse","apiVersion","dataset","cliConfig","tryGetCliConfig","projectId","getProjectId","fallback","requireUser","api","error","exit","USAGE_ERROR","targetDataset","configuredApiVersion","undefined","process","env","SANITY_CLI_QUERY_API_VERSION","targetApiVersion","warn","projectClient","docs","fetch","RUNTIME_ERROR","log","JSON","stringify","err","errorMsg","message","toLowerCase","includes"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SACEC,YAAY,EACZC,SAAS,EACTC,mBAAmB,EACnBC,aAAa,EACbC,QAAQ,QACH,mBAAkB;AACzB,SAAQC,sBAAsB,QAAO,oCAAmC;AAExE,SAAQC,qBAAqB,QAAO,uCAAsC;AAC1E,SAAQC,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,cAAc,EAAEC,gBAAgB,QAAO,4BAA2B;AAE1E,MAAMC,qBAAqBN,SAAS;AAEpC,OAAO,MAAMO,6BAA6BR;IACxC,OAAgBS,OAAO;QACrBC,OAAOf,KAAKgB,MAAM,CAAC;YACjBC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cAAc,sBAAqB;IAEnD,OAAgBE,WAAW;QACzB;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SACE;YACFH,aAAa;QACf;QACA;YACEG,SACE;YACFH,aAAa;QACf;QACA;YACEG,SACE;YACFH,aAAa;QACf;KACD,CAAA;IAED,OAAgBI,QAAQ;QACtB,GAAGV,iBAAiB;YAACM,aAAa;YAAuBK,WAAW;QAAU,EAAE;QAChF,GAAGZ,eAAe;YAACO,aAAa;YAAoBK,WAAW;QAAU,EAAE;QAC3EC,WAAWtB,MAAMuB,OAAO,CAAC;YACvBC,SAAS;YACTR,aAAa;QACf;QACA,eAAehB,MAAMe,MAAM,CAAC;YAC1BC,aAAa,CAAC,gCAAgC,EAAET,sBAAsB,CAAC,CAAC;QAC1E;QACAkB,QAAQzB,MAAMuB,OAAO,CAAC;YACpBC,SAAS;YACTR,aAAa;QACf;IACF,EAAC;IAED,OAAgBU,gBAA0B;QAAC;KAAiB,CAAA;IAE5D,MAAaC,MAAqB;QAChC,MAAM,EAACd,IAAI,EAAEO,KAAK,EAAC,GAAG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EAAEG,OAAO,EAAE0C;YAEpD,yCAAyC;YACzC,MAAMC,WAAWD,IAAIE,OAAO,CAACC,WAAW,GAAGC,QAAQ,CAAC,YAChD,CAAC,2BAA2B,EAAEJ,IAAIE,OAAO,EAAE,GAC3C,CAAC,qBAAqB,EAAEF,IAAIE,OAAO,EAAE;YAEzC,IAAI,CAACpB,KAAK,CAAC,GAAGmB,SAAS,SAAS,EAAE3C,OAAO,EAAE;gBAACyB,MAAMrC,UAAUkD,aAAa;YAAA;QAC3E;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/documents/query.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {\n colorizeJson,\n exitCodes,\n getProjectCliClient,\n SanityCommand,\n subdebug,\n} from '@sanity/cli-core'\nimport {getCliExecutionContext} from '@sanity/cli-core/executionContext'\n\nimport {DOCUMENTS_API_VERSION} from '../../actions/documents/constants.js'\nimport {resolveCommandTarget} from '../../actions/targets/resolveCommandTarget.js'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {getDatasetFlag, getProjectIdFlag, getWithBlueprintsFlag} from '../../util/sharedFlags.js'\n\nconst queryDocumentDebug = subdebug('documents:query')\n\nexport class QueryDocumentCommand extends SanityCommand<typeof QueryDocumentCommand> {\n static override args = {\n query: Args.string({\n description: 'GROQ query to run against the dataset',\n required: true,\n }),\n }\n\n static override description = 'Query for documents'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> \\'*[_type == \"movie\"][0..4]\\'',\n description: 'Fetch 5 documents of type \"movie\"',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> \\'*[_type == \"movie\"]|order(releaseDate asc)[0]{title}\\' --dataset staging',\n description: 'Fetch title of the oldest movie in the dataset named \"staging\"',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> \\'*[_id == \"header\"] { \"headerText\": pt::text(body) }\\' --api-version v2021-06-07',\n description: 'Use API version v2021-06-07 and do a query',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> \\'*[_type == \"post\"]\\' --project abc123 --dataset production',\n description: 'Query documents in a specific project and dataset',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({description: 'Project ID to query', semantics: 'override'}),\n ...getDatasetFlag({description: 'Dataset to query', semantics: 'override'}),\n ...getWithBlueprintsFlag(),\n anonymous: Flags.boolean({\n default: false,\n description: 'Send the query without any authorization token',\n }),\n 'api-version': Flags.string({\n description: `API version to use (defaults to ${DOCUMENTS_API_VERSION})`,\n }),\n pretty: Flags.boolean({\n default: false,\n description: 'Colorize JSON output',\n }),\n }\n\n static override hiddenAliases: string[] = ['document:query']\n\n public async run(): Promise<void> {\n const {args, flags} = await this.parse(QueryDocumentCommand)\n const {query} = args\n const {anonymous, 'api-version': apiVersion, dataset, pretty} = flags\n\n const {dataset: targetDataset, projectId} = flags['with-blueprints']\n ? await resolveCommandTarget({\n dataset,\n loadCliConfig: () => this.tryGetCliConfig(),\n needsDataset: true,\n project: flags.project,\n unattended: this.isUnattended(),\n })\n : await this.resolveClassicTarget(dataset)\n\n const requireUser = !anonymous\n\n const configuredApiVersion =\n apiVersion ??\n (getCliExecutionContext() ? undefined : process.env.SANITY_CLI_QUERY_API_VERSION)\n const targetApiVersion = configuredApiVersion || DOCUMENTS_API_VERSION\n\n if (!configuredApiVersion) {\n this.warn(`--api-version not specified, using \\`${DOCUMENTS_API_VERSION}\\``)\n }\n\n try {\n const projectClient = await getProjectCliClient({\n apiVersion: targetApiVersion,\n dataset: targetDataset,\n projectId,\n requireUser,\n })\n\n const docs = await projectClient.fetch(query)\n\n if (!docs) {\n this.error('Query returned no results', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n // Output the query results\n if (pretty) {\n this.log(colorizeJson(docs))\n } else {\n this.log(JSON.stringify(docs, null, 2))\n }\n } catch (error) {\n const err = error as Error\n\n queryDocumentDebug(`Error running query: ${query}`, err)\n\n // Provide more context in error messages\n const errorMsg = err.message.toLowerCase().includes('syntax')\n ? `Invalid GROQ query syntax: ${err.message}`\n : `Failed to run query: ${err.message}`\n\n this.error(`${errorMsg}\\nQuery: ${query}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n private async resolveClassicTarget(datasetFlag?: string) {\n const cliConfig = await this.tryGetCliConfig()\n const projectId = await this.getProjectId({fallback: () => promptForProject({})})\n const dataset = datasetFlag || cliConfig.api?.dataset\n\n if (!dataset) {\n this.error(\n 'Dataset is required. Pass it with `--dataset <name>` or configure it in `sanity.cli.ts`.',\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n\n return {dataset, projectId}\n }\n}\n"],"names":["Args","Flags","colorizeJson","exitCodes","getProjectCliClient","SanityCommand","subdebug","getCliExecutionContext","DOCUMENTS_API_VERSION","resolveCommandTarget","promptForProject","getDatasetFlag","getProjectIdFlag","getWithBlueprintsFlag","queryDocumentDebug","QueryDocumentCommand","args","query","string","description","required","examples","command","flags","semantics","anonymous","boolean","default","pretty","hiddenAliases","run","parse","apiVersion","dataset","targetDataset","projectId","loadCliConfig","tryGetCliConfig","needsDataset","project","unattended","isUnattended","resolveClassicTarget","requireUser","configuredApiVersion","undefined","process","env","SANITY_CLI_QUERY_API_VERSION","targetApiVersion","warn","projectClient","docs","fetch","error","exit","RUNTIME_ERROR","log","JSON","stringify","err","errorMsg","message","toLowerCase","includes","datasetFlag","cliConfig","getProjectId","fallback","api","USAGE_ERROR"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SACEC,YAAY,EACZC,SAAS,EACTC,mBAAmB,EACnBC,aAAa,EACbC,QAAQ,QACH,mBAAkB;AACzB,SAAQC,sBAAsB,QAAO,oCAAmC;AAExE,SAAQC,qBAAqB,QAAO,uCAAsC;AAC1E,SAAQC,oBAAoB,QAAO,gDAA+C;AAClF,SAAQC,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,cAAc,EAAEC,gBAAgB,EAAEC,qBAAqB,QAAO,4BAA2B;AAEjG,MAAMC,qBAAqBR,SAAS;AAEpC,OAAO,M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,iBAAiB,CAAC;QAAE;QAC/E,MAAMuB,UAAUgC,eAAeC,UAAUG,GAAG,EAAEpC;QAE9C,IAAI,CAACA,SAAS;YACZ,IAAI,CAACqB,KAAK,CACR,4FACA;gBAACC,MAAMpD,UAAUmE,WAAW;YAAA;QAEhC;QAEA,OAAO;YAACrC;YAASE;QAAS;IAC5B;AACF"}
@@ -14,18 +14,24 @@ const debug = subdebug('prompt:project');
14
14
  if (!isInteractive()) {
15
15
  throw new NonInteractiveError('select');
16
16
  }
17
- const { requiredPermissions } = options;
17
+ const { organizationId, requiredPermissions } = options;
18
18
  debug('Fetching projects and grants');
19
19
  const spin = spinner('Fetching available projects').start();
20
- const [projects, grants] = await Promise.all([
21
- listProjects(),
20
+ const [availableProjects, grants] = await Promise.all([
21
+ organizationId ? listProjects({
22
+ onlyExplicitMembership: false
23
+ }) : listProjects(),
22
24
  requiredPermissions ? getUserGrants() : undefined
23
25
  ]).catch((error)=>{
24
26
  spin.fail(requiredPermissions ? 'Failed to fetch projects or permissions' : 'Failed to fetch projects');
25
27
  throw error;
26
28
  });
29
+ const projects = organizationId ? availableProjects.filter((project)=>project.organizationId === organizationId) : availableProjects;
27
30
  if (projects.length === 0) {
28
31
  spin.fail('No projects found');
32
+ if (organizationId) {
33
+ throw new Error(`No accessible projects found in organization ${organizationId}. Try again with \`--project <project-id>\`.`);
34
+ }
29
35
  throw new Error('No projects found. Create a project at https://www.sanity.io/manage');
30
36
  }
31
37
  spin.succeed();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/prompts/promptForProject.ts"],"sourcesContent":["import {isInteractive, NonInteractiveError, subdebug} from '@sanity/cli-core'\nimport {select, Separator, spinner} from '@sanity/cli-core/ux'\n\nimport {getUserGrants} from '../services/grants.js'\nimport {listProjects} from '../services/projects.js'\nimport {type RequiredPermission} from '../types/grants.js'\nimport {getProjectsWithPermissions} from '../util/checkProjectPermissions.js'\n\nconst debug = subdebug('prompt:project')\n\ninterface PromptForProjectOptions {\n requiredPermissions?: RequiredPermission[]\n}\n\n/**\n * Prompt the user to select a project from their available projects.\n *\n * When `requiredPermissions` is provided, projects are filtered by grants:\n * only permitted projects are shown as selectable, with a single disabled\n * summary item indicating how many projects were hidden due to insufficient permissions.\n */\nexport async function promptForProject(options: PromptForProjectOptions = {}): Promise<string> {\n if (!isInteractive()) {\n throw new NonInteractiveError('select')\n }\n\n const {requiredPermissions} = options\n\n debug('Fetching projects and grants')\n const spin = spinner('Fetching available projects').start()\n\n const [projects, grants] = await Promise.all([\n listProjects(),\n requiredPermissions ? getUserGrants() : undefined,\n ]).catch((error) => {\n spin.fail(\n requiredPermissions ? 'Failed to fetch projects or permissions' : 'Failed to fetch projects',\n )\n throw error\n })\n\n if (projects.length === 0) {\n spin.fail('No projects found')\n throw new Error('No projects found. Create a project at https://www.sanity.io/manage')\n }\n\n spin.succeed()\n\n const permittedIds =\n grants && requiredPermissions\n ? getProjectsWithPermissions(grants, requiredPermissions)\n : undefined\n\n const sorted = projects.toSorted((a, b) => b.createdAt.localeCompare(a.createdAt))\n\n const choices: Array<Separator | {disabled?: string; name: string; value: string}> = []\n let insufficientCount = 0\n\n for (const project of sorted) {\n const label = `${project.displayName} (${project.id})`\n if (permittedIds && !permittedIds.has(project.id)) {\n insufficientCount++\n } else {\n choices.push({name: label, value: project.id})\n }\n }\n\n if (insufficientCount > 0) {\n if (choices.length === 0) {\n throw new Error('None of your projects have sufficient permissions for this operation')\n }\n\n const suffix = insufficientCount === 1 ? 'project' : 'projects'\n choices.push(new Separator(), {\n disabled: '(insufficient permissions)',\n name: `${insufficientCount} other ${suffix} hidden`,\n value: '',\n })\n }\n\n return select({\n choices,\n message: 'Select project',\n })\n}\n"],"names":["isInteractive","NonInteractiveError","subdebug","select","Separator","spinner","getUserGrants","listProjects","getProjectsWithPermissions","debug","promptForProject","options","requiredPermissions","spin","start","projects","grants","Promise","all","undefined","catch","error","fail","length","Error","succeed","permittedIds","sorted","toSorted","a","b","createdAt","localeCompare","choices","insufficientCount","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G,EAAE,GAAG;YACjDJ;QACF,OAAO;YACLD,QAAQO,IAAI,CAAC;gBAACC,MAAML;gBAAOM,OAAOP,QAAQG,EAAE;YAAA;QAC9C;IACF;IAEA,IAAIJ,oBAAoB,GAAG;QACzB,IAAID,QAAQV,MAAM,KAAK,GAAG;YACxB,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMmB,SAAST,sBAAsB,IAAI,YAAY;QACrDD,QAAQO,IAAI,CAAC,IAAIpC,aAAa;YAC5BwC,UAAU;YACVH,MAAM,GAAGP,kBAAkB,OAAO,EAAES,OAAO,OAAO,CAAC;YACnDD,OAAO;QACT;IACF;IAEA,OAAOvC,OAAO;QACZ8B;QACAY,SAAS;IACX;AACF"}
1
+ {"version":3,"sources":["../../src/prompts/promptForProject.ts"],"sourcesContent":["import {isInteractive, NonInteractiveError, subdebug} from '@sanity/cli-core'\nimport {select, Separator, spinner} from '@sanity/cli-core/ux'\n\nimport {getUserGrants} from '../services/grants.js'\nimport {listProjects} from '../services/projects.js'\nimport {type RequiredPermission} from '../types/grants.js'\nimport {getProjectsWithPermissions} from '../util/checkProjectPermissions.js'\n\nconst debug = subdebug('prompt:project')\n\ninterface PromptForProjectOptions {\n organizationId?: string\n requiredPermissions?: RequiredPermission[]\n}\n\n/**\n * Prompt the user to select a project from their available projects.\n *\n * When `requiredPermissions` is provided, projects are filtered by grants:\n * only permitted projects are shown as selectable, with a single disabled\n * summary item indicating how many projects were hidden due to insufficient permissions.\n */\nexport async function promptForProject(options: PromptForProjectOptions = {}): Promise<string> {\n if (!isInteractive()) {\n throw new NonInteractiveError('select')\n }\n\n const {organizationId, requiredPermissions} = options\n\n debug('Fetching projects and grants')\n const spin = spinner('Fetching available projects').start()\n\n const [availableProjects, grants] = await Promise.all([\n organizationId ? listProjects({onlyExplicitMembership: false}) : listProjects(),\n requiredPermissions ? getUserGrants() : undefined,\n ]).catch((error) => {\n spin.fail(\n requiredPermissions ? 'Failed to fetch projects or permissions' : 'Failed to fetch projects',\n )\n throw error\n })\n\n const projects = organizationId\n ? availableProjects.filter((project) => project.organizationId === organizationId)\n : availableProjects\n if (projects.length === 0) {\n spin.fail('No projects found')\n if (organizationId) {\n throw new Error(\n `No accessible projects found in organization ${organizationId}. Try again with \\`--project <project-id>\\`.`,\n )\n }\n throw new Error('No projects found. Create a project at https://www.sanity.io/manage')\n }\n\n spin.succeed()\n\n const permittedIds =\n grants && requiredPermissions\n ? getProjectsWithPermissions(grants, requiredPermissions)\n : undefined\n\n const sorted = projects.toSorted((a, b) => b.createdAt.localeCompare(a.createdAt))\n\n const choices: Array<Separator | {disabled?: string; name: string; value: string}> = []\n let insufficientCount = 0\n\n for (const project of sorted) {\n const label = `${project.displayName} (${project.id})`\n if (permittedIds && !permittedIds.has(project.id)) {\n insufficientCount++\n } else {\n choices.push({name: label, value: project.id})\n }\n }\n\n if (insufficientCount > 0) {\n if (choices.length === 0) {\n throw new Error('None of your projects have sufficient permissions for this operation')\n }\n\n const suffix = insufficientCount === 1 ? 'project' : 'projects'\n choices.push(new Separator(), {\n disabled: '(insufficient permissions)',\n name: `${insufficientCount} other ${suffix} hidden`,\n value: '',\n })\n }\n\n return select({\n choices,\n message: 'Select project',\n })\n}\n"],"names":["isInteractive","NonInteractiveError","subdebug","select","Separator","spinner","getUserGrants","listProjects","getProjectsWithPermissions","debug","promptForProject","options","organizationId","requiredPermissions","spin","start","availableProjects","grants","Promise","all","onlyExplicitMembership","undefined","catch","error","fail","projects","filter","project","length","Error","succeed","permittedIds","sorted","toSorted","a","b","createdAt","localeCompare","choices","insufficientCount","label","displayName","id","has","push","name","value","suffix","disabled","message"],"mappings":"AAAA,SAAQA,aAAa,EAAEC,mBAAmB,EAAEC,QAAQ,QAAO,mBAAkB;AAC7E,SAAQC,MAAM,EAAEC,SAAS,EAAEC,OAAO,QAAO,sBAAqB;AAE9D,SAAQC,aAAa,QAAO,wBAAuB;AACnD,SAAQC,YAAY,QAAO,0BAAyB;AAEpD,SAAQC,0BAA0B,QAAO,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DH;QACF,OAAO;YACLD,QAAQM,IAAI,CAAC;gBAACC,MAAML;gBAAOM,OAAOnB,QAAQe,EAAE;YAAA;QAC9C;IACF;IAEA,IAAIH,oBAAoB,GAAG;QACzB,IAAID,QAAQV,MAAM,KAAK,GAAG;YACxB,MAAM,IAAIC,MAAM;QAClB;QAEA,MAAMkB,SAASR,sBAAsB,IAAI,YAAY;QACrDD,QAAQM,IAAI,CAAC,IAAIxC,aAAa;YAC5B4C,UAAU;YACVH,MAAM,GAAGN,kBAAkB,OAAO,EAAEQ,OAAO,OAAO,CAAC;YACnDD,OAAO;QACT;IACF;IAEA,OAAO3C,OAAO;QACZmC;QACAW,SAAS;IACX;AACF"}
@@ -0,0 +1,18 @@
1
+ import { DEFAULT_BLUEPRINTS_API_VERSION } from '@sanity/blueprints/resolve';
2
+ import { getGlobalCliClient } from '@sanity/cli-core';
3
+ export async function getDeployedStack({ scopeId, scopeType, stackId }) {
4
+ const client = await getGlobalCliClient({
5
+ apiVersion: process.env.SANITY_BLUEPRINTS_API_VERSION ?? DEFAULT_BLUEPRINTS_API_VERSION,
6
+ maxRetries: 0,
7
+ requireUser: true
8
+ });
9
+ return client.request({
10
+ headers: {
11
+ 'x-sanity-scope-id': scopeId,
12
+ 'x-sanity-scope-type': scopeType
13
+ },
14
+ url: `/blueprints/stacks/${encodeURIComponent(stackId)}`
15
+ });
16
+ }
17
+
18
+ //# sourceMappingURL=blueprints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/services/blueprints.ts"],"sourcesContent":["import {\n DEFAULT_BLUEPRINTS_API_VERSION,\n type DeployedStack,\n type ScopeType,\n} from '@sanity/blueprints/resolve'\nimport {getGlobalCliClient} from '@sanity/cli-core'\n\nexport async function getDeployedStack({\n scopeId,\n scopeType,\n stackId,\n}: {\n scopeId: string\n scopeType: ScopeType\n stackId: string\n}): Promise<DeployedStack> {\n const client = await getGlobalCliClient({\n apiVersion: process.env.SANITY_BLUEPRINTS_API_VERSION ?? DEFAULT_BLUEPRINTS_API_VERSION,\n maxRetries: 0,\n requireUser: true,\n })\n return client.request<DeployedStack>({\n headers: {'x-sanity-scope-id': scopeId, 'x-sanity-scope-type': scopeType},\n url: `/blueprints/stacks/${encodeURIComponent(stackId)}`,\n })\n}\n"],"names":["DEFAULT_BLUEPRINTS_API_VERSION","getGlobalCliClient","getDeployedStack","scopeId","scopeType","stackId","client","apiVersion","process","env","SANITY_BLUEPRINTS_API_VERSION","maxRetries","requireUser","request","headers","url","encodeURIComponent"],"mappings":"AAAA,SACEA,8BAA8B,QAGzB,6BAA4B;AACnC,SAAQC,kBAAkB,QAAO,mBAAkB;AAEnD,OAAO,eAAeC,iBAAiB,EACrCC,OAAO,EACPC,SAAS,EACTC,OAAO,EAKR;IACC,MAAMC,SAAS,MAAML,mBAAmB;QACtCM,YAAYC,QAAQC,GAAG,CAACC,6BAA6B,IAAIV;QACzDW,YAAY;QACZC,aAAa;IACf;IACA,OAAON,OAAOO,OAAO,CAAgB;QACnCC,SAAS;YAAC,qBAAqBX;YAAS,uBAAuBC;QAAS;QACxEW,KAAK,CAAC,mBAAmB,EAAEC,mBAAmBX,UAAU;IAC1D;AACF"}
@@ -0,0 +1,33 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { dirname, join, resolve } from 'node:path';
3
+ import { BLUEPRINT_FILE_NAMES, readStackConfigFile } from '@sanity/blueprints/resolve';
4
+ import { getCliExecutionContext } from '@sanity/cli-core/executionContext';
5
+ export function getCheckoutBlueprint(cwd = process.cwd()) {
6
+ if (getCliExecutionContext()) return;
7
+ let directory = resolve(cwd);
8
+ while(true){
9
+ const link = readStackConfigFile(directory);
10
+ if (link?.stackId && link.projectId) {
11
+ return {
12
+ scopeId: link.projectId,
13
+ scopeType: 'project',
14
+ stackId: link.stackId
15
+ };
16
+ }
17
+ if (link?.stackId && link.organizationId) {
18
+ return {
19
+ scopeId: link.organizationId,
20
+ scopeType: 'organization',
21
+ stackId: link.stackId
22
+ };
23
+ }
24
+ const parent = dirname(directory);
25
+ // An unlinked Blueprint or nested checkout must not inherit a parent's Stack.
26
+ if (link || directory === parent || existsSync(join(directory, '.git')) || BLUEPRINT_FILE_NAMES.some((name)=>existsSync(join(directory, name)))) {
27
+ return;
28
+ }
29
+ directory = parent;
30
+ }
31
+ }
32
+
33
+ //# sourceMappingURL=checkoutBlueprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/checkoutBlueprint.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {dirname, join, resolve} from 'node:path'\n\nimport {BLUEPRINT_FILE_NAMES, readStackConfigFile, type ScopeType} from '@sanity/blueprints/resolve'\nimport {getCliExecutionContext} from '@sanity/cli-core/executionContext'\n\nexport interface CheckoutStack {\n scopeId: string\n scopeType: ScopeType\n stackId: string\n}\n\nexport function getCheckoutBlueprint(cwd = process.cwd()): CheckoutStack | undefined {\n if (getCliExecutionContext()) return\n\n let directory = resolve(cwd)\n while (true) {\n const link = readStackConfigFile(directory)\n if (link?.stackId && link.projectId) {\n return {scopeId: link.projectId, scopeType: 'project', stackId: link.stackId}\n }\n if (link?.stackId && link.organizationId) {\n return {scopeId: link.organizationId, scopeType: 'organization', stackId: link.stackId}\n }\n\n const parent = dirname(directory)\n // An unlinked Blueprint or nested checkout must not inherit a parent's Stack.\n if (\n link ||\n directory === parent ||\n existsSync(join(directory, '.git')) ||\n BLUEPRINT_FILE_NAMES.some((name) => existsSync(join(directory, name)))\n ) {\n return\n }\n directory = parent\n }\n}\n"],"names":["existsSync","dirname","join","resolve","BLUEPRINT_FILE_NAMES","readStackConfigFile","getCliExecutionContext","getCheckoutBlueprint","cwd","process","directory","link","stackId","projectId","scopeId","scopeType","organizationId","parent","some","name"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,OAAO,EAAEC,IAAI,EAAEC,OAAO,QAAO,YAAW;AAEhD,SAAQC,oBAAoB,EAAEC,mBAAmB,QAAuB,6BAA4B;AACpG,SAAQC,sBAAsB,QAAO,oCAAmC;AAQxE,OAAO,SAASC,qBAAqBC,MAAMC,QAAQD,GAAG,EAAE;IACtD,IAAIF,0BAA0B;IAE9B,IAAII,YAAYP,QAAQK;IACxB,MAAO,KAAM;QACX,MAAMG,OAAON,oBAAoBK;QACjC,IAAIC,MAAMC,WAAWD,KAAKE,SAAS,EAAE;YACnC,OAAO;gBAACC,SAASH,KAAKE,SAAS;gBAAEE,WAAW;gBAAWH,SAASD,KAAKC,OAAO;YAAA;QAC9E;QACA,IAAID,MAAMC,WAAWD,KAAKK,cAAc,EAAE;YACxC,OAAO;gBAACF,SAASH,KAAKK,cAAc;gBAAED,WAAW;gBAAgBH,SAASD,KAAKC,OAAO;YAAA;QACxF;QAEA,MAAMK,SAAShB,QAAQS;QACvB,8EAA8E;QAC9E,IACEC,QACAD,cAAcO,UACdjB,WAAWE,KAAKQ,WAAW,YAC3BN,qBAAqBc,IAAI,CAAC,CAACC,OAASnB,WAAWE,KAAKQ,WAAWS,SAC/D;YACA;QACF;QACAT,YAAYO;IACd;AACF"}
@@ -78,5 +78,15 @@ const OVERRIDE_SUFFIX = ' (overrides CLI configuration)';
78
78
  })
79
79
  };
80
80
  }
81
+ /**
82
+ * Opt in to Blueprint-aware behavior for this invocation.
83
+ */ export function getWithBlueprintsFlag() {
84
+ return {
85
+ 'with-blueprints': Flags.boolean({
86
+ description: 'Use Blueprint-aware behavior',
87
+ hidden: true
88
+ })
89
+ };
90
+ }
81
91
 
82
92
  //# sourceMappingURL=sharedFlags.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/sharedFlags.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\n\n/**\n * Controls how the flag relates to CLI configuration:\n *\n * - `'override'` — The command falls back to CLI config (sanity.cli.ts) when the flag is not\n * provided. The flag description automatically gets an \" (overrides CLI configuration)\" suffix,\n * and `helpGroup` defaults to `'OVERRIDE'`.\n *\n * - `'specify'` — The command does NOT fall back to CLI config; the flag is simply how the user\n * provides the value. No suffix is appended, and no default `helpGroup` is set.\n */\ntype FlagSemantics = 'override' | 'specify'\n\n/**\n * Options accepted by the shared flag getters.\n * Locked properties (char, parse, name, helpValue) are excluded to ensure\n * consistent behavior across all commands.\n */\ninterface SharedFlagOptions {\n /**\n * Controls description suffix and default helpGroup.\n * @see {@link FlagSemantics}\n */\n semantics: FlagSemantics\n\n atLeastOne?: string[]\n dependsOn?: string[]\n description?: string\n env?: string\n exclusive?: string[]\n helpGroup?: string\n hidden?: boolean\n required?: boolean\n}\n\nconst OVERRIDE_SUFFIX = ' (overrides CLI configuration)'\n\n/**\n * Returns a `--project` / `-p` flag definition with a deprecated `--project-id` alias.\n *\n * Locked: flag name (`project`), char (`p`), `helpValue` (`<id>`), and parse (trims + validates non-empty).\n */\nexport function getProjectIdFlag(options: SharedFlagOptions) {\n const {description: baseDescription, helpGroup, semantics, ...rest} = options\n const isOverride = semantics === 'override'\n const description = (baseDescription ?? 'Project ID to use') + (isOverride ? OVERRIDE_SUFFIX : '')\n\n return {\n project: Flags.string({\n aliases: ['project-id'],\n deprecateAliases: true,\n description,\n helpGroup: helpGroup ?? (isOverride ? 'OVERRIDE' : undefined),\n helpValue: '<id>',\n ...rest,\n char: 'p',\n parse: async (input: string) => {\n const trimmed = input.trim()\n if (trimmed === '') {\n throw new Error('`--project` cannot be empty if provided')\n }\n return trimmed\n },\n }),\n }\n}\n\n/**\n * Returns an `--organization` flag definition.\n *\n * Locked: flag name (`organization`), `helpValue` (`<id>`), and parse (trims + validates non-empty).\n */\nexport function getOrganizationFlag(options: SharedFlagOptions) {\n const {description: baseDescription, helpGroup, semantics, ...rest} = options\n const isOverride = semantics === 'override'\n const description =\n (baseDescription ?? 'Organization ID to use') + (isOverride ? OVERRIDE_SUFFIX : '')\n\n return {\n organization: Flags.string({\n description,\n helpGroup: helpGroup ?? (isOverride ? 'OVERRIDE' : undefined),\n helpValue: '<id>',\n ...rest,\n parse: async (input: string) => {\n const trimmed = input.trim()\n if (trimmed === '') {\n throw new Error('`--organization` cannot be empty if provided')\n }\n return trimmed\n },\n }),\n }\n}\n\n/**\n * Returns a `--dataset` / `-d` flag definition.\n *\n * Locked: flag name (`dataset`), char (`d`), `helpValue` (`<name>`), and parse (trims + validates non-empty).\n */\nexport function getDatasetFlag(options: SharedFlagOptions) {\n const {description: baseDescription, helpGroup, semantics, ...rest} = options\n const isOverride = semantics === 'override'\n const description = (baseDescription ?? 'Dataset to use') + (isOverride ? OVERRIDE_SUFFIX : '')\n\n return {\n dataset: Flags.string({\n description,\n helpGroup: helpGroup ?? (isOverride ? 'OVERRIDE' : undefined),\n helpValue: '<name>',\n ...rest,\n char: 'd',\n parse: async (input: string) => {\n const trimmed = input.trim()\n if (trimmed === '') {\n throw new Error('`--dataset` cannot be empty if provided')\n }\n return trimmed\n },\n }),\n }\n}\n"],"names":["Flags","OVERRIDE_SUFFIX","getProjectIdFlag","options","description","baseDescription","helpGroup","semantics","rest","isOverride","project","string","aliases","deprecateAliases","undefined","helpValue","char","parse","input","trimmed","trim","Error","getOrganizationFlag","organization","getDatasetFlag","dataset"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AAoCjC,MAAMC,kBAAkB;AAExB;;;;CAIC,GACD,OAAO,SAASC,iBAAiBC,OAA0B;IACzD,MAAM,EAACC,aAAaC,eAAe,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGC,MAAK,GAAGL;IACtE,MAAMM,aAAaF,cAAc;IACjC,MAAMH,cAAc,AAACC,CAAAA,mBAAmB,mBAAkB,IAAMI,CAAAA,aAAaR,kBAAkB,EAAC;IAEhG,OAAO;QACLS,SAASV,MAAMW,MAAM,CAAC;YACpBC,SAAS;gBAAC;aAAa;YACvBC,kBAAkB;YAClBT;YACAE,WAAWA,aAAcG,CAAAA,aAAa,aAAaK,SAAQ;YAC3DC,WAAW;YACX,GAAGP,IAAI;YACPQ,MAAM;YACNC,OAAO,OAAOC;gBACZ,MAAMC,UAAUD,MAAME,IAAI;gBAC1B,IAAID,YAAY,IAAI;oBAClB,MAAM,IAAIE,MAAM;gBAClB;gBACA,OAAOF;YACT;QACF;IACF;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASG,oBAAoBnB,OAA0B;IAC5D,MAAM,EAACC,aAAaC,eAAe,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGC,MAAK,GAAGL;IACtE,MAAMM,aAAaF,cAAc;IACjC,MAAMH,cACJ,AAACC,CAAAA,mBAAmB,wBAAuB,IAAMI,CAAAA,aAAaR,kBAAkB,EAAC;IAEnF,OAAO;QACLsB,cAAcvB,MAAMW,MAAM,CAAC;YACzBP;YACAE,WAAWA,aAAcG,CAAAA,aAAa,aAAaK,SAAQ;YAC3DC,WAAW;YACX,GAAGP,IAAI;YACPS,OAAO,OAAOC;gBACZ,MAAMC,UAAUD,MAAME,IAAI;gBAC1B,IAAID,YAAY,IAAI;oBAClB,MAAM,IAAIE,MAAM;gBAClB;gBACA,OAAOF;YACT;QACF;IACF;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASK,eAAerB,OAA0B;IACvD,MAAM,EAACC,aAAaC,eAAe,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGC,MAAK,GAAGL;IACtE,MAAMM,aAAaF,cAAc;IACjC,MAAMH,cAAc,AAACC,CAAAA,mBAAmB,gBAAe,IAAMI,CAAAA,aAAaR,kBAAkB,EAAC;IAE7F,OAAO;QACLwB,SAASzB,MAAMW,MAAM,CAAC;YACpBP;YACAE,WAAWA,aAAcG,CAAAA,aAAa,aAAaK,SAAQ;YAC3DC,WAAW;YACX,GAAGP,IAAI;YACPQ,MAAM;YACNC,OAAO,OAAOC;gBACZ,MAAMC,UAAUD,MAAME,IAAI;gBAC1B,IAAID,YAAY,IAAI;oBAClB,MAAM,IAAIE,MAAM;gBAClB;gBACA,OAAOF;YACT;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/util/sharedFlags.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\n\n/**\n * Controls how the flag relates to CLI configuration:\n *\n * - `'override'` — The command falls back to CLI config (sanity.cli.ts) when the flag is not\n * provided. The flag description automatically gets an \" (overrides CLI configuration)\" suffix,\n * and `helpGroup` defaults to `'OVERRIDE'`.\n *\n * - `'specify'` — The command does NOT fall back to CLI config; the flag is simply how the user\n * provides the value. No suffix is appended, and no default `helpGroup` is set.\n */\ntype FlagSemantics = 'override' | 'specify'\n\n/**\n * Options accepted by the shared flag getters.\n * Locked properties (char, parse, name, helpValue) are excluded to ensure\n * consistent behavior across all commands.\n */\ninterface SharedFlagOptions {\n /**\n * Controls description suffix and default helpGroup.\n * @see {@link FlagSemantics}\n */\n semantics: FlagSemantics\n\n atLeastOne?: string[]\n dependsOn?: string[]\n description?: string\n env?: string\n exclusive?: string[]\n helpGroup?: string\n hidden?: boolean\n required?: boolean\n}\n\nconst OVERRIDE_SUFFIX = ' (overrides CLI configuration)'\n\n/**\n * Returns a `--project` / `-p` flag definition with a deprecated `--project-id` alias.\n *\n * Locked: flag name (`project`), char (`p`), `helpValue` (`<id>`), and parse (trims + validates non-empty).\n */\nexport function getProjectIdFlag(options: SharedFlagOptions) {\n const {description: baseDescription, helpGroup, semantics, ...rest} = options\n const isOverride = semantics === 'override'\n const description = (baseDescription ?? 'Project ID to use') + (isOverride ? OVERRIDE_SUFFIX : '')\n\n return {\n project: Flags.string({\n aliases: ['project-id'],\n deprecateAliases: true,\n description,\n helpGroup: helpGroup ?? (isOverride ? 'OVERRIDE' : undefined),\n helpValue: '<id>',\n ...rest,\n char: 'p',\n parse: async (input: string) => {\n const trimmed = input.trim()\n if (trimmed === '') {\n throw new Error('`--project` cannot be empty if provided')\n }\n return trimmed\n },\n }),\n }\n}\n\n/**\n * Returns an `--organization` flag definition.\n *\n * Locked: flag name (`organization`), `helpValue` (`<id>`), and parse (trims + validates non-empty).\n */\nexport function getOrganizationFlag(options: SharedFlagOptions) {\n const {description: baseDescription, helpGroup, semantics, ...rest} = options\n const isOverride = semantics === 'override'\n const description =\n (baseDescription ?? 'Organization ID to use') + (isOverride ? OVERRIDE_SUFFIX : '')\n\n return {\n organization: Flags.string({\n description,\n helpGroup: helpGroup ?? (isOverride ? 'OVERRIDE' : undefined),\n helpValue: '<id>',\n ...rest,\n parse: async (input: string) => {\n const trimmed = input.trim()\n if (trimmed === '') {\n throw new Error('`--organization` cannot be empty if provided')\n }\n return trimmed\n },\n }),\n }\n}\n\n/**\n * Returns a `--dataset` / `-d` flag definition.\n *\n * Locked: flag name (`dataset`), char (`d`), `helpValue` (`<name>`), and parse (trims + validates non-empty).\n */\nexport function getDatasetFlag(options: SharedFlagOptions) {\n const {description: baseDescription, helpGroup, semantics, ...rest} = options\n const isOverride = semantics === 'override'\n const description = (baseDescription ?? 'Dataset to use') + (isOverride ? OVERRIDE_SUFFIX : '')\n\n return {\n dataset: Flags.string({\n description,\n helpGroup: helpGroup ?? (isOverride ? 'OVERRIDE' : undefined),\n helpValue: '<name>',\n ...rest,\n char: 'd',\n parse: async (input: string) => {\n const trimmed = input.trim()\n if (trimmed === '') {\n throw new Error('`--dataset` cannot be empty if provided')\n }\n return trimmed\n },\n }),\n }\n}\n\n/**\n * Opt in to Blueprint-aware behavior for this invocation.\n */\nexport function getWithBlueprintsFlag() {\n return {\n 'with-blueprints': Flags.boolean({\n description: 'Use Blueprint-aware behavior',\n hidden: true,\n }),\n }\n}\n"],"names":["Flags","OVERRIDE_SUFFIX","getProjectIdFlag","options","description","baseDescription","helpGroup","semantics","rest","isOverride","project","string","aliases","deprecateAliases","undefined","helpValue","char","parse","input","trimmed","trim","Error","getOrganizationFlag","organization","getDatasetFlag","dataset","getWithBlueprintsFlag","boolean","hidden"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AAoCjC,MAAMC,kBAAkB;AAExB;;;;CAIC,GACD,OAAO,SAASC,iBAAiBC,OAA0B;IACzD,MAAM,EAACC,aAAaC,eAAe,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGC,MAAK,GAAGL;IACtE,MAAMM,aAAaF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