sanity 3.77.2-server-side-schemas.13 → 3.77.2-server-side-schemas.21
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.
- package/lib/_chunks-cjs/_internal.js +1 -5
- package/lib/_chunks-cjs/_internal.js.map +1 -1
- package/lib/_chunks-cjs/deleteSchemaAction.js +9 -4
- package/lib/_chunks-cjs/deleteSchemaAction.js.map +1 -1
- package/lib/_chunks-cjs/deployAction.js +11 -10
- package/lib/_chunks-cjs/deployAction.js.map +1 -1
- package/lib/_chunks-cjs/schemaListAction.js +5 -3
- package/lib/_chunks-cjs/schemaListAction.js.map +1 -1
- package/lib/_chunks-cjs/storeSchemasAction.js +20 -12
- package/lib/_chunks-cjs/storeSchemasAction.js.map +1 -1
- package/lib/_chunks-cjs/version.js +1 -1
- package/lib/_chunks-es/version.mjs +1 -1
- package/lib/_legacy/version.esm.js +1 -1
- package/package.json +10 -10
- package/src/_internal/cli/actions/deploy/deployAction.ts +14 -22
- package/src/_internal/cli/actions/schema/deleteSchemaAction.ts +8 -3
- package/src/_internal/cli/actions/schema/schemaListAction.ts +2 -1
- package/src/_internal/cli/actions/schema/storeSchemasAction.ts +19 -14
- package/src/_internal/cli/commands/schema/deleteSchemaCommand.ts +0 -2
- package/src/_internal/cli/commands/schema/schemaListCommand.ts +0 -2
- package/src/_internal/cli/commands/schema/storeSchemaCommand.ts +1 -1
@@ -1,9 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
async function deleteSchemaAction(args, context) {
|
3
|
-
const
|
3
|
+
const flags = args.extOptions, {
|
4
4
|
apiClient,
|
5
5
|
output
|
6
|
-
} = context
|
6
|
+
} = context;
|
7
|
+
if (!flags.ids) {
|
8
|
+
output.error("No schema ids provided");
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
const schemaIds = flags.ids.split(","), client = apiClient({
|
7
12
|
requireUser: !0,
|
8
13
|
requireProject: !0
|
9
14
|
}).withConfig({
|
@@ -14,10 +19,10 @@ async function deleteSchemaAction(args, context) {
|
|
14
19
|
return;
|
15
20
|
}
|
16
21
|
schemaIds.forEach(async (schemaId) => {
|
17
|
-
if (!await client.withConfig({
|
22
|
+
if (!(await client.withConfig({
|
18
23
|
dataset,
|
19
24
|
projectId
|
20
|
-
}).delete(schemaId)) {
|
25
|
+
}).delete(schemaId.trim())).results.length) {
|
21
26
|
output.error(`No schema found with id: ${schemaId}`);
|
22
27
|
return;
|
23
28
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deleteSchemaAction.js","sources":["../../src/_internal/cli/actions/schema/deleteSchemaAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\n\nexport interface DeleteSchemaFlags {\n ids: string\n}\n\nexport default async function deleteSchemaAction(\n args: CliCommandArguments<DeleteSchemaFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const flags = args.extOptions\n //split ids by comma\n const schemaIds = flags.ids.split(',')\n\n const
|
1
|
+
{"version":3,"file":"deleteSchemaAction.js","sources":["../../src/_internal/cli/actions/schema/deleteSchemaAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\n\nexport interface DeleteSchemaFlags {\n ids: string\n}\n\nexport default async function deleteSchemaAction(\n args: CliCommandArguments<DeleteSchemaFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const flags = args.extOptions\n const {apiClient, output} = context\n\n if (!flags.ids) {\n output.error('No schema ids provided')\n return\n }\n //split ids by comma\n const schemaIds = flags.ids.split(',')\n\n const client = apiClient({\n requireUser: true,\n requireProject: true,\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n const projectId = client.config().projectId\n const dataset = client.config().dataset\n\n if (!projectId || !dataset) {\n output.error('Project ID and Dataset must be defined.')\n return\n }\n\n schemaIds.forEach(async (schemaId) => {\n const deletedSchema = await client\n .withConfig({\n dataset: dataset,\n projectId: projectId,\n })\n .delete(schemaId.trim())\n\n if (!deletedSchema.results.length) {\n output.error(`No schema found with id: ${schemaId}`)\n return\n }\n\n output.success(`Schema ${schemaId} deleted`)\n })\n}\n"],"names":["deleteSchemaAction","args","context","flags","extOptions","apiClient","output","ids","error","schemaIds","split","client","requireUser","requireProject","withConfig","apiVersion","projectId","config","dataset","forEach","schemaId","delete","trim","results","length","success"],"mappings":";AAM8BA,eAAAA,mBAC5BC,MACAC,SACe;AACTC,QAAAA,QAAQF,KAAKG,YACb;AAAA,IAACC;AAAAA,IAAWC;AAAAA,EAAAA,IAAUJ;AAExB,MAAA,CAACC,MAAMI,KAAK;AACdD,WAAOE,MAAM,wBAAwB;AACrC;AAAA,EAAA;AAGF,QAAMC,YAAYN,MAAMI,IAAIG,MAAM,GAAG,GAE/BC,SAASN,UAAU;AAAA,IACvBO,aAAa;AAAA,IACbC,gBAAgB;AAAA,EACjB,CAAA,EAAEC,WAAW;AAAA,IAACC,YAAY;AAAA,EAAA,CAAc,GAEnCC,YAAYL,OAAOM,SAASD,WAC5BE,UAAUP,OAAOM,OAAAA,EAASC;AAE5B,MAAA,CAACF,aAAa,CAACE,SAAS;AAC1BZ,WAAOE,MAAM,yCAAyC;AACtD;AAAA,EAAA;AAGQW,YAAAA,QAAQ,OAAOC,aAAa;AAQhC,QAAA,EAPkB,MAAMT,OACzBG,WAAW;AAAA,MACVI;AAAAA,MACAF;AAAAA,IAAAA,CACD,EACAK,OAAOD,SAASE,MAAM,GAENC,QAAQC,QAAQ;AAC1BhB,aAAAA,MAAM,4BAA4BY,QAAQ,EAAE;AACnD;AAAA,IAAA;AAGKK,WAAAA,QAAQ,UAAUL,QAAQ,UAAU;AAAA,EAAA,CAC5C;AACH;;"}
|
@@ -63,7 +63,6 @@ async function deployStudioAction(args, context) {
|
|
63
63
|
}
|
64
64
|
throw helpers.debug("Error creating user application", err), err;
|
65
65
|
}
|
66
|
-
let schemaStoringSuccess = !1;
|
67
66
|
if (flags.build) {
|
68
67
|
const buildArgs = {
|
69
68
|
...args,
|
@@ -84,16 +83,18 @@ async function deployStudioAction(args, context) {
|
|
84
83
|
}, context);
|
85
84
|
if (flags["schema-required"] && extractManifestError)
|
86
85
|
throw output.error(`Schema extraction error: ${extractManifestError.message}`), extractManifestError;
|
87
|
-
const storeManifestSchemasArgs = {
|
88
|
-
extOptions: {
|
89
|
-
path: `${sourceDir}/static`,
|
90
|
-
"schema-required": flags["schema-required"],
|
91
|
-
verbose: flags.verbose
|
92
|
-
}
|
93
|
-
};
|
94
|
-
await storeSchemasAction.default(storeManifestSchemasArgs, context) || (schemaStoringSuccess = !0);
|
95
86
|
}
|
96
87
|
}
|
88
|
+
if (!isCoreApp) {
|
89
|
+
const storeManifestSchemasArgs = {
|
90
|
+
extOptions: {
|
91
|
+
path: `${sourceDir}/static`,
|
92
|
+
"schema-required": flags["schema-required"],
|
93
|
+
verbose: flags.verbose
|
94
|
+
}
|
95
|
+
};
|
96
|
+
await storeSchemasAction.default(storeManifestSchemasArgs, context);
|
97
|
+
}
|
97
98
|
spinner = output.spinner("Verifying local content").start();
|
98
99
|
try {
|
99
100
|
await helpers.checkDir(sourceDir), spinner.succeed();
|
@@ -115,7 +116,7 @@ async function deployStudioAction(args, context) {
|
|
115
116
|
tarball,
|
116
117
|
isCoreApp
|
117
118
|
});
|
118
|
-
spinner.succeed(), output.print(),
|
119
|
+
spinner.succeed(), output.print(), output.print(`
|
119
120
|
Success! ${isCoreApp ? "Application deployed" : `Studio deployed to ${chalk.cyan(location)}`}`), (isCoreApp && !appId || !isCoreApp && !configStudioHost) && (output.print(`
|
120
121
|
Add ${chalk.cyan(isCoreApp ? `appId: '${userApplication.id}'` : `studioHost: '${userApplication.appHost}'`)}`), output.print(`to ${isCoreApp ? "__experimental_coreAppConfiguration" : "defineCliConfig root properties"} in sanity.cli.js or sanity.cli.ts`), output.print(`to avoid prompting ${isCoreApp ? "" : "for hostname"} on next deploy.`));
|
121
122
|
} catch (err) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deployAction.js","sources":["../../src/_internal/cli/actions/deploy/deployAction.ts"],"sourcesContent":["/* eslint-disable max-statements */\nimport path from 'node:path'\nimport zlib from 'node:zlib'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport tar from 'tar-fs'\n\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport buildSanityStudio, {type BuildSanityStudioCommandFlags} from '../build/buildAction'\nimport {extractManifestSafe} from '../manifest/extractManifestAction'\nimport storeManifestSchemas from '../schema/storeSchemasAction'\nimport {\n type BaseConfigOptions,\n checkDir,\n createDeployment,\n debug,\n dirIsEmptyOrNonExistent,\n getInstalledSanityVersion,\n getOrCreateCoreApplication,\n getOrCreateStudio,\n getOrCreateUserApplicationFromConfig,\n type UserApplication,\n} from './helpers'\n\nexport interface DeployStudioActionFlags extends BuildSanityStudioCommandFlags {\n 'build'?: boolean\n 'schema-required'?: boolean\n 'verbose'?: boolean\n}\n\n// eslint-disable-next-line complexity\nexport default async function deployStudioAction(\n args: CliCommandArguments<DeployStudioActionFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {apiClient, workDir, chalk, output, prompt, cliConfig} = context\n const flags = {build: true, ...args.extOptions}\n const customSourceDir = args.argsWithoutOptions[0]\n const sourceDir = path.resolve(process.cwd(), customSourceDir || path.join(workDir, 'dist'))\n const isAutoUpdating = shouldAutoUpdate({flags, cliConfig})\n const isCoreApp = cliConfig && '__experimental_coreAppConfiguration' in cliConfig\n\n const installedSanityVersion = await getInstalledSanityVersion()\n const configStudioHost = cliConfig && 'studioHost' in cliConfig && cliConfig.studioHost\n const appId =\n cliConfig &&\n '__experimental_coreAppConfiguration' in cliConfig &&\n cliConfig.__experimental_coreAppConfiguration?.appId\n\n const client = apiClient({\n requireUser: true,\n requireProject: !isCoreApp, // core apps are not project-specific\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n if (customSourceDir === 'graphql') {\n throw new Error('Did you mean `sanity graphql deploy`?')\n }\n\n if (customSourceDir) {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n const shouldProceed =\n isEmpty ||\n (await prompt.single({\n type: 'confirm',\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n default: false,\n }))\n\n if (!shouldProceed) {\n output.print('Cancelled.')\n return\n }\n\n output.print(`Building to ${relativeOutput}\\n`)\n }\n\n // Check that the project has a studio hostname\n let spinner = output.spinner('Checking project info').start()\n\n let userApplication: UserApplication\n\n try {\n const configParams: BaseConfigOptions & {\n appHost?: string\n appId?: string\n } = {\n client,\n context,\n spinner,\n }\n\n if (isCoreApp && appId) {\n configParams.appId = appId\n } else if (configStudioHost) {\n configParams.appHost = configStudioHost\n }\n // If the user has provided a studioHost / appId in the config, use that\n if (configStudioHost || appId) {\n userApplication = await getOrCreateUserApplicationFromConfig(configParams)\n } else {\n userApplication = isCoreApp\n ? await getOrCreateCoreApplication({client, context, spinner})\n : await getOrCreateStudio({client, context, spinner})\n }\n } catch (err) {\n if (err.message) {\n output.error(chalk.red(err.message))\n return\n }\n\n debug('Error creating user application', err)\n throw err\n }\n let schemaStoringSuccess = false\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n const buildArgs = {\n ...args,\n extOptions: flags,\n argsWithoutOptions: [customSourceDir].filter(Boolean),\n }\n const {didCompile} = await buildSanityStudio(buildArgs, context, {basePath: '/'})\n\n if (!didCompile) {\n return\n }\n\n if (!isCoreApp) {\n const extractManifestError = await extractManifestSafe(\n {\n ...buildArgs,\n extOptions: {},\n extraArguments: [],\n },\n context,\n )\n\n if (flags['schema-required'] && extractManifestError) {\n output.error(`Schema extraction error: ${extractManifestError.message}`)\n throw extractManifestError\n }\n\n const storeManifestSchemasArgs = {\n ...args,\n extOptions: {\n 'path': `${sourceDir}/static`,\n 'schema-required': flags['schema-required'],\n 'verbose': flags.verbose,\n },\n extraArguments: [],\n }\n\n const storeManifestSchemasError = await storeManifestSchemas(\n storeManifestSchemasArgs,\n context,\n )\n if (!storeManifestSchemasError) {\n schemaStoringSuccess = true\n }\n }\n }\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spinner = output.spinner('Verifying local content').start()\n try {\n await checkDir(sourceDir)\n spinner.succeed()\n } catch (err) {\n spinner.fail()\n debug('Error checking directory', err)\n throw err\n }\n\n // Now create a tarball of the given directory\n const parentDir = path.dirname(sourceDir)\n const base = path.basename(sourceDir)\n const tarball = tar.pack(parentDir, {entries: [base]}).pipe(zlib.createGzip())\n\n spinner = output.spinner(`Deploying to ${isCoreApp ? 'CORE' : 'Sanity.Studio'}`).start()\n try {\n const {location} = await createDeployment({\n client,\n applicationId: userApplication.id,\n version: installedSanityVersion,\n isAutoUpdating,\n tarball,\n isCoreApp,\n })\n\n spinner.succeed()\n\n output.print()\n\n if (schemaStoringSuccess) {\n output.print(`You can list stored schemas with ${chalk.cyan('sanity schema list')}`)\n }\n\n // And let the user know we're done\n output.print(\n `\\nSuccess! ${isCoreApp ? 'Application deployed' : `Studio deployed to ${chalk.cyan(location)}`}`,\n )\n\n if ((isCoreApp && !appId) || (!isCoreApp && !configStudioHost)) {\n output.print(\n `\\nAdd ${chalk.cyan(isCoreApp ? `appId: '${userApplication.id}'` : `studioHost: '${userApplication.appHost}'`)}`,\n )\n output.print(\n `to ${isCoreApp ? '__experimental_coreAppConfiguration' : 'defineCliConfig root properties'} in sanity.cli.js or sanity.cli.ts`,\n )\n output.print(`to avoid prompting ${isCoreApp ? '' : 'for hostname'} on next deploy.`)\n }\n } catch (err) {\n spinner.fail()\n debug('Error deploying studio', err)\n throw err\n }\n}\n"],"names":["deployStudioAction","args","context","apiClient","workDir","chalk","output","prompt","cliConfig","flags","build","extOptions","customSourceDir","argsWithoutOptions","sourceDir","path","resolve","process","cwd","join","isAutoUpdating","shouldAutoUpdate","isCoreApp","installedSanityVersion","getInstalledSanityVersion","configStudioHost","studioHost","appId","__experimental_coreAppConfiguration","client","requireUser","requireProject","withConfig","apiVersion","Error","relativeOutput","relative","dirIsEmptyOrNonExistent","single","type","message","default","print","spinner","start","userApplication","configParams","appHost","getOrCreateUserApplicationFromConfig","getOrCreateCoreApplication","getOrCreateStudio","err","error","red","debug","schemaStoringSuccess","buildArgs","filter","Boolean","didCompile","buildSanityStudio","basePath","extractManifestError","extractManifestSafe","extraArguments","storeManifestSchemasArgs","verbose","storeManifestSchemas","checkDir","succeed","fail","parentDir","dirname","base","basename","tarball","tar","pack","entries","pipe","zlib","createGzip","location","createDeployment","applicationId","id","version","cyan"],"mappings":";;;;;;AA+B8BA,eAAAA,mBAC5BC,MACAC,SACe;AACT,QAAA;AAAA,IAACC;AAAAA,IAAWC;AAAAA,IAASC;AAAAA,IAAOC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,EAAAA,IAAaN,SACzDO,QAAQ;AAAA,IAACC,OAAO;AAAA,IAAM,GAAGT,KAAKU;AAAAA,EAAAA,GAC9BC,kBAAkBX,KAAKY,mBAAmB,CAAC,GAC3CC,YAAYC,cAAAA,QAAKC,QAAQC,QAAQC,OAAON,mBAAmBG,sBAAKI,KAAKf,SAAS,MAAM,CAAC,GACrFgB,iBAAiBC,6BAAiB;AAAA,IAACZ;AAAAA,IAAOD;AAAAA,EAAU,CAAA,GACpDc,YAAYd,aAAa,yCAAyCA,WAElEe,yBAAyB,MAAMC,kCAA0B,GACzDC,mBAAmBjB,aAAa,gBAAgBA,aAAaA,UAAUkB,YACvEC,QACJnB,aACA,yCAAyCA,aACzCA,UAAUoB,qCAAqCD,OAE3CE,SAAS1B,UAAU;AAAA,IACvB2B,aAAa;AAAA,IACbC,gBAAgB,CAACT;AAAAA;AAAAA,EAClB,CAAA,EAAEU,WAAW;AAAA,IAACC,YAAY;AAAA,EAAA,CAAc;AAEzC,MAAIrB,oBAAoB;AAChB,UAAA,IAAIsB,MAAM,uCAAuC;AAGzD,MAAItB,iBAAiB;AACnB,QAAIuB,iBAAiBpB,cAAAA,QA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A,iBAAiB;AAAA,MACxCtD;AAAAA,MACAuD,eAAevC,gBAAgBwC;AAAAA,MAC/BC,SAAS/D;AAAAA,MACTH;AAAAA,MACAuD;AAAAA,MACArD;AAAAA,IAAAA,CACD;AAEDqB,YAAQ0B,WAER/D,OAAOoC,MAAM,GAETa,wBACFjD,OAAOoC,MAAM,oCAAoCrC,MAAMkF,KAAK,oBAAoB,CAAC,EAAE,GAIrFjF,OAAOoC,MACL;AAAA,WAAcpB,YAAY,yBAAyB,sBAAsBjB,MAAMkF,KAAKL,QAAQ,CAAC,EAAE,EACjG,IAEK5D,aAAa,CAACK,SAAW,CAACL,aAAa,CAACG,sBAC3CnB,OAAOoC,MACL;AAAA,MAASrC,MAAMkF,KAAKjE,YAAY,WAAWuB,gBAAgBwC,EAAE,MAAM,gBAAgBxC,gBAAgBE,OAAO,GAAG,CAAC,EAChH,GACAzC,OAAOoC,MACL,MAAMpB,YAAY,wCAAwC,iCAAiC,oCAC7F,GACAhB,OAAOoC,MAAM,sBAAsBpB,YAAY,KAAK,cAAc,kBAAkB;AAAA,WAE/E6B,KAAK;AACZR,UAAAA,QAAQ2B,KAAK,GACbhB,QAAM,MAAA,0BAA0BH,GAAG,GAC7BA;AAAAA,EAAAA;AAEV;;"}
|
1
|
+
{"version":3,"file":"deployAction.js","sources":["../../src/_internal/cli/actions/deploy/deployAction.ts"],"sourcesContent":["/* eslint-disable max-statements */\nimport path from 'node:path'\nimport zlib from 'node:zlib'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport tar from 'tar-fs'\n\nimport {shouldAutoUpdate} from '../../util/shouldAutoUpdate'\nimport buildSanityStudio, {type BuildSanityStudioCommandFlags} from '../build/buildAction'\nimport {extractManifestSafe} from '../manifest/extractManifestAction'\nimport storeManifestSchemas from '../schema/storeSchemasAction'\nimport {\n type BaseConfigOptions,\n checkDir,\n createDeployment,\n debug,\n dirIsEmptyOrNonExistent,\n getInstalledSanityVersion,\n getOrCreateCoreApplication,\n getOrCreateStudio,\n getOrCreateUserApplicationFromConfig,\n type UserApplication,\n} from './helpers'\n\nexport interface DeployStudioActionFlags extends BuildSanityStudioCommandFlags {\n 'build'?: boolean\n 'schema-required'?: boolean\n 'verbose'?: boolean\n}\n\n// eslint-disable-next-line complexity\nexport default async function deployStudioAction(\n args: CliCommandArguments<DeployStudioActionFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {apiClient, workDir, chalk, output, prompt, cliConfig} = context\n const flags = {build: true, ...args.extOptions}\n const customSourceDir = args.argsWithoutOptions[0]\n const sourceDir = path.resolve(process.cwd(), customSourceDir || path.join(workDir, 'dist'))\n const isAutoUpdating = shouldAutoUpdate({flags, cliConfig})\n const isCoreApp = cliConfig && '__experimental_coreAppConfiguration' in cliConfig\n\n const installedSanityVersion = await getInstalledSanityVersion()\n const configStudioHost = cliConfig && 'studioHost' in cliConfig && cliConfig.studioHost\n const appId =\n cliConfig &&\n '__experimental_coreAppConfiguration' in cliConfig &&\n cliConfig.__experimental_coreAppConfiguration?.appId\n\n const client = apiClient({\n requireUser: true,\n requireProject: !isCoreApp, // core apps are not project-specific\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n if (customSourceDir === 'graphql') {\n throw new Error('Did you mean `sanity graphql deploy`?')\n }\n\n if (customSourceDir) {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n const shouldProceed =\n isEmpty ||\n (await prompt.single({\n type: 'confirm',\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n default: false,\n }))\n\n if (!shouldProceed) {\n output.print('Cancelled.')\n return\n }\n\n output.print(`Building to ${relativeOutput}\\n`)\n }\n\n // Check that the project has a studio hostname\n let spinner = output.spinner('Checking project info').start()\n\n let userApplication: UserApplication\n\n try {\n const configParams: BaseConfigOptions & {\n appHost?: string\n appId?: string\n } = {\n client,\n context,\n spinner,\n }\n\n if (isCoreApp && appId) {\n configParams.appId = appId\n } else if (configStudioHost) {\n configParams.appHost = configStudioHost\n }\n // If the user has provided a studioHost / appId in the config, use that\n if (configStudioHost || appId) {\n userApplication = await getOrCreateUserApplicationFromConfig(configParams)\n } else {\n userApplication = isCoreApp\n ? await getOrCreateCoreApplication({client, context, spinner})\n : await getOrCreateStudio({client, context, spinner})\n }\n } catch (err) {\n if (err.message) {\n output.error(chalk.red(err.message))\n return\n }\n\n debug('Error creating user application', err)\n throw err\n }\n\n // Always build the project, unless --no-build is passed\n const shouldBuild = flags.build\n if (shouldBuild) {\n const buildArgs = {\n ...args,\n extOptions: flags,\n argsWithoutOptions: [customSourceDir].filter(Boolean),\n }\n const {didCompile} = await buildSanityStudio(buildArgs, context, {basePath: '/'})\n\n if (!didCompile) {\n return\n }\n\n if (!isCoreApp) {\n const extractManifestError = await extractManifestSafe(\n {\n ...buildArgs,\n extOptions: {},\n extraArguments: [],\n },\n context,\n )\n\n if (flags['schema-required'] && extractManifestError) {\n output.error(`Schema extraction error: ${extractManifestError.message}`)\n throw extractManifestError\n }\n }\n }\n\n if (!isCoreApp) {\n const storeManifestSchemasArgs = {\n ...args,\n extOptions: {\n 'path': `${sourceDir}/static`,\n 'schema-required': flags['schema-required'],\n 'verbose': flags.verbose,\n },\n extraArguments: [],\n }\n\n await storeManifestSchemas(storeManifestSchemasArgs, context)\n }\n\n // Ensure that the directory exists, is a directory and seems to have valid content\n spinner = output.spinner('Verifying local content').start()\n try {\n await checkDir(sourceDir)\n spinner.succeed()\n } catch (err) {\n spinner.fail()\n debug('Error checking directory', err)\n throw err\n }\n\n // Now create a tarball of the given directory\n const parentDir = path.dirname(sourceDir)\n const base = path.basename(sourceDir)\n const tarball = tar.pack(parentDir, {entries: [base]}).pipe(zlib.createGzip())\n\n spinner = output.spinner(`Deploying to ${isCoreApp ? 'CORE' : 'Sanity.Studio'}`).start()\n try {\n const {location} = await createDeployment({\n client,\n applicationId: userApplication.id,\n version: installedSanityVersion,\n isAutoUpdating,\n tarball,\n isCoreApp,\n })\n\n spinner.succeed()\n\n output.print()\n\n // And let the user know we're done\n output.print(\n `\\nSuccess! ${isCoreApp ? 'Application deployed' : `Studio deployed to ${chalk.cyan(location)}`}`,\n )\n\n if ((isCoreApp && !appId) || (!isCoreApp && !configStudioHost)) {\n output.print(\n `\\nAdd ${chalk.cyan(isCoreApp ? `appId: '${userApplication.id}'` : `studioHost: '${userApplication.appHost}'`)}`,\n )\n output.print(\n `to ${isCoreApp ? '__experimental_coreAppConfiguration' : 'defineCliConfig root properties'} in sanity.cli.js or sanity.cli.ts`,\n )\n output.print(`to avoid prompting ${isCoreApp ? '' : 'for hostname'} on next deploy.`)\n }\n } catch (err) {\n spinner.fail()\n debug('Error deploying studio', err)\n throw err\n }\n}\n"],"names":["deployStudioAction","args","context","apiClient","workDir","chalk","output","prompt","cliConfig","flags","build","extOptions","customSourceDir","argsWithoutOptions","sourceDir","path","resolve","process","cwd","join","isAutoUpdating","shouldAutoUpdate","isCoreApp","installedSanityVersion","getInstalledSanityVersion","configStudioHost","studioHost","appId","__experimental_coreAppConfiguration","client","requireUser","requireProject","withConfig","apiVersion","Error","relativeOutput","relative","dirIsEmptyOrNonExistent","single","type","message","default","print","spinner","start","userApplication","configParams","appHost","getOrCreateUserApplicationFromConfig","getOrCreateCoreApplication","getOrCreateStudio","err","error","red","debug","buildArgs","filter","Boolean","didCompile","buildSanityStudio","basePath","extractManifestError","extractManifestSafe","extraArguments","storeManifestSchemasArgs","verbose","storeManifestSchemas","checkDir","succeed","fail","parentDir","dirname","base","basename","tarball","tar","pack","entries","pipe","zlib","createGzip","location","createDeployment","applicationId","id","version","cyan"],"mappings":";;;;;;AA+B8BA,eAAAA,mBAC5BC,MACAC,SACe;AACT,QAAA;AAAA,IAACC;AAAAA,IAAWC;AAAAA,IAASC;AAAAA,IAAOC;AAAAA,IAAQC;AAAAA,IAAQC;AAAAA,EAAAA,IAAaN,SACzDO,QAAQ;AAAA,IAACC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BAAsBpB,YAAY,KAAK,cAAc,kBAAkB;AAAA,WAE/E6B,KAAK;AACZR,UAAAA,QAAQ0B,KAAK,GACbf,QAAM,MAAA,0BAA0BH,GAAG,GAC7BA;AAAAA,EAAAA;AAEV;;"}
|
@@ -17,8 +17,10 @@ const SANITY_WORKSPACE_SCHEMA_ID = "sanity.workspace.schema", printSchemaList =
|
|
17
17
|
}) => [id, workspace.title, dataset, projectId, createdAt].map(String)), ["createdAt"]), headings = ["Id", "Title", "Dataset", "ProjectId", "CreatedAt"], rows = ordered.reverse(), maxWidths = rows.reduce((max, row) => row.map((current, index) => Math.max(size__default.default(current), max[index])), headings.map((str) => size__default.default(str))), printRow = (row) => row.map((col, i) => `${col}`.padEnd(maxWidths[i])).join(" ");
|
18
18
|
output.print(chalk__default.default.cyan(printRow(headings))), rows.forEach((row) => output.print(printRow(row)));
|
19
19
|
};
|
20
|
-
async function
|
21
|
-
const flags = args.extOptions
|
20
|
+
async function storeSchemaAction(args, context) {
|
21
|
+
const flags = args.extOptions;
|
22
|
+
if (typeof flags.id == "boolean") throw new Error("Id is empty");
|
23
|
+
const {
|
22
24
|
apiClient,
|
23
25
|
output
|
24
26
|
} = context, client = apiClient({
|
@@ -55,5 +57,5 @@ async function fetchSchemaAction(args, context) {
|
|
55
57
|
});
|
56
58
|
}
|
57
59
|
exports.SANITY_WORKSPACE_SCHEMA_ID = SANITY_WORKSPACE_SCHEMA_ID;
|
58
|
-
exports.default =
|
60
|
+
exports.default = storeSchemaAction;
|
59
61
|
//# sourceMappingURL=schemaListAction.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schemaListAction.js","sources":["../../src/_internal/cli/actions/schema/schemaListAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext, type CliOutputter} from '@sanity/cli'\nimport {type SanityDocument} from '@sanity/client'\nimport chalk from 'chalk'\nimport {size, sortBy} from 'lodash'\n\nexport interface SchemaListFlags {\n json: boolean\n id: string\n}\n\ntype PrintSchemaListArgs = {\n schemas: SanityDocument[]\n output: CliOutputter\n dataset: string\n projectId: string\n}\n\nexport const SANITY_WORKSPACE_SCHEMA_ID = 'sanity.workspace.schema'\n\nconst printSchemaList = ({schemas, output, dataset, projectId}: PrintSchemaListArgs) => {\n const ordered = sortBy(\n schemas.map(({_createdAt: createdAt, _id: id, workspace}) => {\n return [id, workspace.title, dataset, projectId, createdAt].map(String)\n }),\n ['createdAt'],\n )\n const headings = ['Id', 'Title', 'Dataset', 'ProjectId', 'CreatedAt']\n const rows = ordered.reverse()\n\n const maxWidths = rows.reduce(\n (max, row) => row.map((current, index) => Math.max(size(current), max[index])),\n headings.map((str) => size(str)),\n )\n\n const printRow = (row: string[]) => row.map((col, i) => `${col}`.padEnd(maxWidths[i])).join(' ')\n\n output.print(chalk.cyan(printRow(headings)))\n rows.forEach((row) => output.print(printRow(row)))\n}\n\nexport default async function
|
1
|
+
{"version":3,"file":"schemaListAction.js","sources":["../../src/_internal/cli/actions/schema/schemaListAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext, type CliOutputter} from '@sanity/cli'\nimport {type SanityDocument} from '@sanity/client'\nimport chalk from 'chalk'\nimport {size, sortBy} from 'lodash'\n\nexport interface SchemaListFlags {\n json: boolean\n id: string\n}\n\ntype PrintSchemaListArgs = {\n schemas: SanityDocument[]\n output: CliOutputter\n dataset: string\n projectId: string\n}\n\nexport const SANITY_WORKSPACE_SCHEMA_ID = 'sanity.workspace.schema'\n\nconst printSchemaList = ({schemas, output, dataset, projectId}: PrintSchemaListArgs) => {\n const ordered = sortBy(\n schemas.map(({_createdAt: createdAt, _id: id, workspace}) => {\n return [id, workspace.title, dataset, projectId, createdAt].map(String)\n }),\n ['createdAt'],\n )\n const headings = ['Id', 'Title', 'Dataset', 'ProjectId', 'CreatedAt']\n const rows = ordered.reverse()\n\n const maxWidths = rows.reduce(\n (max, row) => row.map((current, index) => Math.max(size(current), max[index])),\n headings.map((str) => size(str)),\n )\n\n const printRow = (row: string[]) => row.map((col, i) => `${col}`.padEnd(maxWidths[i])).join(' ')\n\n output.print(chalk.cyan(printRow(headings)))\n rows.forEach((row) => output.print(printRow(row)))\n}\n\nexport default async function storeSchemaAction(\n args: CliCommandArguments<SchemaListFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const flags = args.extOptions\n if (typeof flags.id === 'boolean') throw new Error('Id is empty')\n const {apiClient, output} = context\n const client = apiClient({\n requireUser: true,\n requireProject: true,\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n const projectId = client.config().projectId\n const dataset = client.config().dataset\n\n if (!projectId || !dataset) {\n output.error('Project ID and Dataset must be defined.')\n return\n }\n\n let schemas: SanityDocument[]\n\n if (flags.id) {\n // Fetch a specific schema by id\n schemas = await client\n .withConfig({\n dataset: dataset,\n projectId: projectId,\n })\n .fetch<SanityDocument[]>(`*[_type == $type && _id == $id]`, {\n id: flags.id,\n type: SANITY_WORKSPACE_SCHEMA_ID,\n })\n } else {\n // Fetch all schemas\n schemas = await client\n .withConfig({\n dataset: dataset,\n projectId: projectId,\n })\n .fetch<SanityDocument[]>(`*[_type == $type]`, {\n type: SANITY_WORKSPACE_SCHEMA_ID,\n })\n }\n\n if (schemas.length === 0) {\n if (flags.id) {\n output.error(`No schema found with id: ${flags.id}`)\n } else {\n output.error(`No schemas found`)\n }\n return\n }\n\n if (flags.json) {\n output.print(`${JSON.stringify(flags.id ? schemas[0] : schemas, null, 2)}`)\n } else {\n printSchemaList({schemas, output, dataset, projectId})\n }\n}\n"],"names":["SANITY_WORKSPACE_SCHEMA_ID","printSchemaList","schemas","output","dataset","projectId","ordered","sortBy","map","_createdAt","createdAt","_id","id","workspace","title","String","headings","rows","reverse","maxWidths","reduce","max","row","current","index","Math","size","str","printRow","col","i","padEnd","join","print","chalk","cyan","forEach","storeSchemaAction","args","context","flags","extOptions","Error","apiClient","client","requireUser","requireProject","withConfig","apiVersion","config","error","fetch","type","length","json","JSON","stringify"],"mappings":";;;;;;AAiBO,MAAMA,6BAA6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OAAOK,SAAS5C,WAC5BD,UAAUwC,OAAOK,OAAAA,EAAS7C;AAE5B,MAAA,CAACC,aAAa,CAACD,SAAS;AAC1BD,WAAO+C,MAAM,yCAAyC;AACtD;AAAA,EAAA;AAGEhD,MAAAA;AAyBJ,MAvBIsC,MAAM5B,KAERV,UAAU,MAAM0C,OACbG,WAAW;AAAA,IACV3C;AAAAA,IACAC;AAAAA,EAAAA,CACD,EACA8C,MAAwB,mCAAmC;AAAA,IAC1DvC,IAAI4B,MAAM5B;AAAAA,IACVwC,MAAMpD;AAAAA,EACP,CAAA,IAGHE,UAAU,MAAM0C,OACbG,WAAW;AAAA,IACV3C;AAAAA,IACAC;AAAAA,EAAAA,CACD,EACA8C,MAAwB,qBAAqB;AAAA,IAC5CC,MAAMpD;AAAAA,EAAAA,CACP,GAGDE,QAAQmD,WAAW,GAAG;AACpBb,UAAM5B,KACRT,OAAO+C,MAAM,4BAA4BV,MAAM5B,EAAE,EAAE,IAEnDT,OAAO+C,MAAM,kBAAkB;AAEjC;AAAA,EAAA;AAGEV,QAAMc,OACRnD,OAAO8B,MAAM,GAAGsB,KAAKC,UAAUhB,MAAM5B,KAAKV,QAAQ,CAAC,IAAIA,SAAS,MAAM,CAAC,CAAC,EAAE,IAE1ED,gBAAgB;AAAA,IAACC;AAAAA,IAASC;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,EAAAA,CAAU;AAEzD;;;"}
|
@@ -4,8 +4,12 @@ function _interopDefaultCompat(e) {
|
|
4
4
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
5
5
|
}
|
6
6
|
var path__default = /* @__PURE__ */ _interopDefaultCompat(path), chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk);
|
7
|
-
async function
|
8
|
-
const flags = args.extOptions
|
7
|
+
async function storeSchemasAction(args, context) {
|
8
|
+
const flags = args.extOptions;
|
9
|
+
if (typeof flags.path == "boolean") throw new Error("Path is empty");
|
10
|
+
if (typeof flags["id-prefix"] == "boolean") throw new Error("Id prefix is empty");
|
11
|
+
if (typeof flags.workspace == "boolean") throw new Error("Workspace is empty");
|
12
|
+
const schemaRequired = flags["schema-required"], workspaceName = flags.workspace, idPrefix = flags["id-prefix"], verbose = flags.verbose, {
|
9
13
|
output,
|
10
14
|
workDir,
|
11
15
|
apiClient
|
@@ -25,10 +29,10 @@ async function storeManifestSchemas(args, context) {
|
|
25
29
|
}
|
26
30
|
let storedCount = 0, error;
|
27
31
|
const saveSchema = async (workspace) => {
|
28
|
-
const id = `${idPrefix
|
32
|
+
const id = `${idPrefix ? `${idPrefix}.` : ""}${schemaListAction.SANITY_WORKSPACE_SCHEMA_ID}.${workspace.name}`;
|
29
33
|
try {
|
30
34
|
if (workspace.projectId !== projectId)
|
31
|
-
throw new Error(
|
35
|
+
throw new Error(`\u21B3 No permissions to store schema for workspace ${workspace.name} with projectId: ${workspace.projectId}`);
|
32
36
|
const schema = JSON.parse(fs.readFileSync(`${manifestPath}/${workspace.schema}`, "utf-8"));
|
33
37
|
await client.withConfig({
|
34
38
|
dataset: workspace.dataset,
|
@@ -40,25 +44,29 @@ async function storeManifestSchemas(args, context) {
|
|
40
44
|
schema
|
41
45
|
}).commit(), storedCount++, spinner.text = `Stored ${storedCount} schemas so far...`, verbose && spinner.succeed(`Schema stored for workspace '${workspace.name}'`);
|
42
46
|
} catch (err) {
|
43
|
-
error = err, spinner.fail(`Error storing schema for workspace '${workspace.name}':
|
44
|
-
${chalk__default.default.red(
|
47
|
+
if (error = err, spinner.fail(`Error storing schema for workspace '${workspace.name}':
|
48
|
+
${chalk__default.default.red(`${err.message}`)}`), schemaRequired) throw err;
|
45
49
|
} finally {
|
46
|
-
verbose && output.print(
|
50
|
+
verbose && output.print(chalk__default.default.gray(`\u21B3 schemaId: ${id}, projectId: ${projectId}, dataset: ${workspace.dataset}`));
|
47
51
|
}
|
48
52
|
};
|
49
53
|
if (workspaceName) {
|
50
54
|
const workspaceToSave = manifest.workspaces.find((workspace) => workspace.name === workspaceName);
|
51
|
-
|
55
|
+
if (!workspaceToSave)
|
56
|
+
throw spinner.fail(`Workspace ${workspaceName} not found in manifest`), new Error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`);
|
57
|
+
await saveSchema(workspaceToSave), spinner.succeed("Stored 1 schemas");
|
52
58
|
} else
|
53
59
|
await Promise.all(manifest.workspaces.map(async (workspace) => {
|
54
60
|
await saveSchema(workspace);
|
55
|
-
}));
|
56
|
-
if (
|
61
|
+
})), spinner.succeed(`Stored ${storedCount}/${manifest.workspaces.length} schemas`);
|
62
|
+
if (error) throw error;
|
57
63
|
return;
|
58
64
|
} catch (err) {
|
59
|
-
if (
|
65
|
+
if (schemaRequired) throw err;
|
60
66
|
return err;
|
67
|
+
} finally {
|
68
|
+
output.print(`${chalk__default.default.gray("\u21B3 List stored schemas with:")} ${chalk__default.default.cyan("sanity schema list")}`);
|
61
69
|
}
|
62
70
|
}
|
63
|
-
exports.default =
|
71
|
+
exports.default = storeSchemasAction;
|
64
72
|
//# sourceMappingURL=storeSchemasAction.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"storeSchemasAction.js","sources":["../../src/_internal/cli/actions/schema/storeSchemasAction.ts"],"sourcesContent":["import {readFileSync} from 'node:fs'\nimport path, {join, resolve} from 'node:path'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport chalk from 'chalk'\n\nimport {\n type CreateManifest,\n type ManifestSchemaType,\n type ManifestWorkspaceFile,\n} from '../../../manifest/manifestTypes'\nimport {MANIFEST_FILENAME} from '../manifest/extractManifestAction'\nimport {SANITY_WORKSPACE_SCHEMA_ID} from './schemaListAction'\n\nexport interface StoreManifestSchemasFlags {\n 'path'?: string\n 'workspace'?: string\n 'id-prefix'?: string\n 'schema-required'?: boolean\n 'verbose'?: boolean\n}\n\nexport default async function
|
1
|
+
{"version":3,"file":"storeSchemasAction.js","sources":["../../src/_internal/cli/actions/schema/storeSchemasAction.ts"],"sourcesContent":["import {readFileSync} from 'node:fs'\nimport path, {join, resolve} from 'node:path'\n\nimport {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\nimport chalk from 'chalk'\n\nimport {\n type CreateManifest,\n type ManifestSchemaType,\n type ManifestWorkspaceFile,\n} from '../../../manifest/manifestTypes'\nimport {MANIFEST_FILENAME} from '../manifest/extractManifestAction'\nimport {SANITY_WORKSPACE_SCHEMA_ID} from './schemaListAction'\n\nexport interface StoreManifestSchemasFlags {\n 'path'?: string\n 'workspace'?: string\n 'id-prefix'?: string\n 'schema-required'?: boolean\n 'verbose'?: boolean\n}\n\nexport default async function storeSchemasAction(\n args: CliCommandArguments<StoreManifestSchemasFlags>,\n context: CliCommandContext,\n): Promise<Error | undefined> {\n const flags = args.extOptions\n if (typeof flags.path === 'boolean') throw new Error('Path is empty')\n if (typeof flags['id-prefix'] === 'boolean') throw new Error('Id prefix is empty')\n if (typeof flags.workspace === 'boolean') throw new Error('Workspace is empty')\n\n const schemaRequired = flags['schema-required']\n const workspaceName = flags.workspace\n const idPrefix = flags['id-prefix']\n const verbose = flags.verbose\n const {output, workDir, apiClient} = context\n\n const defaultOutputDir = resolve(join(workDir, 'dist'))\n\n const outputDir = resolve(defaultOutputDir)\n const defaultStaticPath = join(outputDir, 'static')\n\n const staticPath = flags.path ?? defaultStaticPath\n\n const spinner = output.spinner({}).start('Storing schemas')\n\n try {\n const manifestPath = path.resolve(process.cwd(), staticPath)\n const client = apiClient({\n requireUser: true,\n requireProject: true,\n }).withConfig({apiVersion: 'v2024-08-01'})\n\n const projectId = client.config().projectId\n\n let manifest: CreateManifest\n\n try {\n manifest = JSON.parse(readFileSync(`${manifestPath}/${MANIFEST_FILENAME}`, 'utf-8'))\n } catch (error) {\n spinner.fail(`Manifest not found at ${manifestPath}/${MANIFEST_FILENAME}`)\n output.error(error)\n throw error\n }\n\n let storedCount = 0\n\n let error: Error | undefined\n\n const saveSchema = async (workspace: ManifestWorkspaceFile) => {\n const id = `${idPrefix ? `${idPrefix}.` : ''}${SANITY_WORKSPACE_SCHEMA_ID}.${workspace.name}`\n try {\n if (workspace.projectId !== projectId) {\n throw new Error(\n `↳ No permissions to store schema for workspace ${workspace.name} with projectId: ${workspace.projectId}`,\n )\n }\n const schema = JSON.parse(\n readFileSync(`${manifestPath}/${workspace.schema}`, 'utf-8'),\n ) as ManifestSchemaType\n await client\n .withConfig({\n dataset: workspace.dataset,\n projectId: workspace.projectId,\n })\n .transaction()\n .createOrReplace({_type: SANITY_WORKSPACE_SCHEMA_ID, _id: id, workspace, schema})\n .commit()\n storedCount++\n spinner.text = `Stored ${storedCount} schemas so far...`\n if (verbose) spinner.succeed(`Schema stored for workspace '${workspace.name}'`)\n } catch (err) {\n error = err\n spinner.fail(\n `Error storing schema for workspace '${workspace.name}':\\n${chalk.red(`${err.message}`)}`,\n )\n if (schemaRequired) throw err\n } finally {\n if (verbose) {\n output.print(\n chalk.gray(`↳ schemaId: ${id}, projectId: ${projectId}, dataset: ${workspace.dataset}`),\n )\n }\n }\n }\n\n // If a workspace name is provided, only save the schema for that workspace\n if (workspaceName) {\n const workspaceToSave = manifest.workspaces.find(\n (workspace) => workspace.name === workspaceName,\n )\n if (!workspaceToSave) {\n spinner.fail(`Workspace ${workspaceName} not found in manifest`)\n throw new Error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`)\n }\n await saveSchema(workspaceToSave as ManifestWorkspaceFile)\n spinner.succeed(`Stored 1 schemas`)\n } else {\n await Promise.all(\n manifest.workspaces.map(async (workspace): Promise<void> => {\n await saveSchema(workspace)\n }),\n )\n spinner.succeed(`Stored ${storedCount}/${manifest.workspaces.length} schemas`)\n }\n\n if (error) throw error\n return undefined\n } catch (err) {\n // if this flag is set, throw the error and exit without deploying otherwise just log the error\n if (schemaRequired) throw err\n return err\n } finally {\n output.print(`${chalk.gray('↳ List stored schemas with:')} ${chalk.cyan('sanity schema list')}`)\n }\n}\n"],"names":["storeSchemasAction","args","context","flags","extOptions","path","Error","workspace","schemaRequired","workspaceName","idPrefix","verbose","output","workDir","apiClient","defaultOutputDir","resolve","join","outputDir","defaultStaticPath","staticPath","spinner","start","manifestPath","process","cwd","client","requireUser","requireProject","withConfig","apiVersion","projectId","config","manifest","JSON","parse","readFileSync","MANIFEST_FILENAME","error","fail","storedCount","saveSchema","id","SANITY_WORKSPACE_SCHEMA_ID","name","schema","dataset","transaction","createOrReplace","_type","_id","commit","text","succeed","err","chalk","red","message","print","gray","workspaceToSave","workspaces","find","Promise","all","map","length","cyan"],"mappings":";;;;;;AAsB8BA,eAAAA,mBAC5BC,MACAC,SAC4B;AAC5B,QAAMC,QAAQF,KAAKG;AACnB,MAAI,OAAOD,MAAME,QAAS,UAAiB,OAAA,IAAIC,MAAM,eAAe;AAChE,MAAA,OAAOH,MAAM,WAAW,KAAM,UAAiB,OAAA,IAAIG,MAAM,oBAAoB;AACjF,MAAI,OAAOH,MAAMI,aAAc,UAAiB,OAAA,IAAID,MAAM,oBAAoB;AAE9E,QAAME,iBAAiBL,MAAM,iBAAiB,GACxCM,gBAAgBN,MAAMI,WACtBG,WAAWP,MAAM,WAAW,GAC5BQ,UAAUR,MAAMQ,SAChB;AAAA,IAACC;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,EAAaZ,IAAAA,SAE/Ba,mBAAmBC,KAAAA,QAAQC,KAAKJ,KAAAA,SAAS,MAAM,CAAC,GAEhDK,YAAYF,KAAAA,QAAQD,gBAAgB,GACpCI,oBAAoBF,KAAAA,KAAKC,WAAW,QAAQ,GAE5CE,aAAajB,MAAME,QAAQc,mBAE3BE,UAAUT,OAAOS,QAAQ,CAAA,CAAE,EAAEC,MAAM,iBAAiB;AAEtD,MAAA;AACIC,UAAAA,eAAelB,sBAAKW,QAAQQ,QAAQC,OAAOL,UAAU,GACrDM,SAASZ,UAAU;AAAA,MACvBa,aAAa;AAAA,MACbC,gBAAgB;AAAA,IACjB,CAAA,EAAEC,WAAW;AAAA,MAACC,YAAY;AAAA,IAAc,CAAA,GAEnCC,YAAYL,OAAOM,OAASD,EA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AO8C,MACLH,eAAAA,QAAMI,KAAK,oBAAejB,EAAE,gBAAgBX,SAAS,cAAcxB,UAAUuC,OAAO,EAAE,CACxF;AAAA,MAAA;AAAA,IAGN;AAGA,QAAIrC,eAAe;AACjB,YAAMmD,kBAAkB3B,SAAS4B,WAAWC,KACzCvD,CAAcA,cAAAA,UAAUqC,SAASnC,aACpC;AACA,UAAI,CAACmD;AACKrB,cAAAA,QAAAA,KAAK,aAAa9B,aAAa,wBAAwB,GACzD,IAAIH,MAAM,aAAaG,aAAa,sCAAsCsB,SAAS,EAAE;AAE7F,YAAMU,WAAWmB,eAAwC,GACzDvC,QAAQgC,QAAQ,kBAAkB;AAAA,IACpC;AACE,YAAMU,QAAQC,IACZ/B,SAAS4B,WAAWI,IAAI,OAAO1D,cAA6B;AAC1D,cAAMkC,WAAWlC,SAAS;AAAA,MAC3B,CAAA,CACH,GACAc,QAAQgC,QAAQ,UAAUb,WAAW,IAAIP,SAAS4B,WAAWK,MAAM,UAAU;AAG/E,QAAI5B,MAAaA,OAAAA;AACjB;AAAA,WACOgB,KAAK;AAEZ,QAAI9C,eAAsB8C,OAAAA;AACnBA,WAAAA;AAAAA,EAAAA,UACC;AACDI,WAAAA,MAAM,GAAGH,eAAAA,QAAMI,KAAK,kCAA6B,CAAC,IAAIJ,eAAAA,QAAMY,KAAK,oBAAoB,CAAC,EAAE;AAAA,EAAA;AAEnG;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "sanity",
|
3
|
-
"version": "3.77.2-server-side-schemas.
|
3
|
+
"version": "3.77.2-server-side-schemas.21+15f4ca087f",
|
4
4
|
"description": "Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches",
|
5
5
|
"keywords": [
|
6
6
|
"sanity",
|
@@ -160,11 +160,11 @@
|
|
160
160
|
"@rexxars/react-json-inspector": "^9.0.1",
|
161
161
|
"@sanity/asset-utils": "^2.0.6",
|
162
162
|
"@sanity/bifur-client": "^0.4.1",
|
163
|
-
"@sanity/cli": "3.77.2-server-side-schemas.
|
163
|
+
"@sanity/cli": "3.77.2-server-side-schemas.21+15f4ca087f",
|
164
164
|
"@sanity/client": "^6.28.1",
|
165
165
|
"@sanity/color": "^3.0.0",
|
166
166
|
"@sanity/comlink": "^3.0.1",
|
167
|
-
"@sanity/diff": "3.77.2-server-side-schemas.
|
167
|
+
"@sanity/diff": "3.77.2-server-side-schemas.21+15f4ca087f",
|
168
168
|
"@sanity/diff-match-patch": "^3.1.1",
|
169
169
|
"@sanity/diff-patch": "^5.0.0",
|
170
170
|
"@sanity/eventsource": "^5.0.0",
|
@@ -174,15 +174,15 @@
|
|
174
174
|
"@sanity/import": "^3.37.9",
|
175
175
|
"@sanity/insert-menu": "^1.1.3",
|
176
176
|
"@sanity/logos": "^2.1.13",
|
177
|
-
"@sanity/migrate": "3.77.2-server-side-schemas.
|
178
|
-
"@sanity/mutator": "3.77.2-server-side-schemas.
|
177
|
+
"@sanity/migrate": "3.77.2-server-side-schemas.21+15f4ca087f",
|
178
|
+
"@sanity/mutator": "3.77.2-server-side-schemas.21+15f4ca087f",
|
179
179
|
"@sanity/presentation-comlink": "^1.0.8",
|
180
180
|
"@sanity/preview-url-secret": "^2.1.4",
|
181
|
-
"@sanity/schema": "3.77.2-server-side-schemas.
|
181
|
+
"@sanity/schema": "3.77.2-server-side-schemas.21+15f4ca087f",
|
182
182
|
"@sanity/telemetry": "^0.7.7",
|
183
|
-
"@sanity/types": "3.77.2-server-side-schemas.
|
183
|
+
"@sanity/types": "3.77.2-server-side-schemas.21+15f4ca087f",
|
184
184
|
"@sanity/ui": "^2.14.3",
|
185
|
-
"@sanity/util": "3.77.2-server-side-schemas.
|
185
|
+
"@sanity/util": "3.77.2-server-side-schemas.21+15f4ca087f",
|
186
186
|
"@sanity/uuid": "^3.0.2",
|
187
187
|
"@sentry/react": "^8.33.0",
|
188
188
|
"@tanstack/react-table": "^8.16.0",
|
@@ -280,7 +280,7 @@
|
|
280
280
|
"@repo/dev-aliases": "3.77.1",
|
281
281
|
"@repo/package.config": "3.77.1",
|
282
282
|
"@repo/test-config": "3.77.1",
|
283
|
-
"@sanity/codegen": "3.77.2-server-side-schemas.
|
283
|
+
"@sanity/codegen": "3.77.2-server-side-schemas.21+15f4ca087f",
|
284
284
|
"@sanity/generate-help-url": "^3.0.0",
|
285
285
|
"@sanity/pkg-utils": "6.13.4",
|
286
286
|
"@sanity/tsdoc": "1.0.169",
|
@@ -325,5 +325,5 @@
|
|
325
325
|
"engines": {
|
326
326
|
"node": ">=18"
|
327
327
|
},
|
328
|
-
"gitHead": "
|
328
|
+
"gitHead": "15f4ca087f91a9b547e7d8e79d0abe3020273898"
|
329
329
|
}
|
@@ -116,7 +116,7 @@ export default async function deployStudioAction(
|
|
116
116
|
debug('Error creating user application', err)
|
117
117
|
throw err
|
118
118
|
}
|
119
|
-
|
119
|
+
|
120
120
|
// Always build the project, unless --no-build is passed
|
121
121
|
const shouldBuild = flags.build
|
122
122
|
if (shouldBuild) {
|
@@ -145,25 +145,21 @@ export default async function deployStudioAction(
|
|
145
145
|
output.error(`Schema extraction error: ${extractManifestError.message}`)
|
146
146
|
throw extractManifestError
|
147
147
|
}
|
148
|
+
}
|
149
|
+
}
|
148
150
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
const storeManifestSchemasError = await storeManifestSchemas(
|
160
|
-
storeManifestSchemasArgs,
|
161
|
-
context,
|
162
|
-
)
|
163
|
-
if (!storeManifestSchemasError) {
|
164
|
-
schemaStoringSuccess = true
|
165
|
-
}
|
151
|
+
if (!isCoreApp) {
|
152
|
+
const storeManifestSchemasArgs = {
|
153
|
+
...args,
|
154
|
+
extOptions: {
|
155
|
+
'path': `${sourceDir}/static`,
|
156
|
+
'schema-required': flags['schema-required'],
|
157
|
+
'verbose': flags.verbose,
|
158
|
+
},
|
159
|
+
extraArguments: [],
|
166
160
|
}
|
161
|
+
|
162
|
+
await storeManifestSchemas(storeManifestSchemasArgs, context)
|
167
163
|
}
|
168
164
|
|
169
165
|
// Ensure that the directory exists, is a directory and seems to have valid content
|
@@ -197,10 +193,6 @@ export default async function deployStudioAction(
|
|
197
193
|
|
198
194
|
output.print()
|
199
195
|
|
200
|
-
if (schemaStoringSuccess) {
|
201
|
-
output.print(`You can list stored schemas with ${chalk.cyan('sanity schema list')}`)
|
202
|
-
}
|
203
|
-
|
204
196
|
// And let the user know we're done
|
205
197
|
output.print(
|
206
198
|
`\nSuccess! ${isCoreApp ? 'Application deployed' : `Studio deployed to ${chalk.cyan(location)}`}`,
|
@@ -9,10 +9,15 @@ export default async function deleteSchemaAction(
|
|
9
9
|
context: CliCommandContext,
|
10
10
|
): Promise<void> {
|
11
11
|
const flags = args.extOptions
|
12
|
+
const {apiClient, output} = context
|
13
|
+
|
14
|
+
if (!flags.ids) {
|
15
|
+
output.error('No schema ids provided')
|
16
|
+
return
|
17
|
+
}
|
12
18
|
//split ids by comma
|
13
19
|
const schemaIds = flags.ids.split(',')
|
14
20
|
|
15
|
-
const {apiClient, output} = context
|
16
21
|
const client = apiClient({
|
17
22
|
requireUser: true,
|
18
23
|
requireProject: true,
|
@@ -32,9 +37,9 @@ export default async function deleteSchemaAction(
|
|
32
37
|
dataset: dataset,
|
33
38
|
projectId: projectId,
|
34
39
|
})
|
35
|
-
.delete(schemaId)
|
40
|
+
.delete(schemaId.trim())
|
36
41
|
|
37
|
-
if (!deletedSchema) {
|
42
|
+
if (!deletedSchema.results.length) {
|
38
43
|
output.error(`No schema found with id: ${schemaId}`)
|
39
44
|
return
|
40
45
|
}
|
@@ -38,11 +38,12 @@ const printSchemaList = ({schemas, output, dataset, projectId}: PrintSchemaListA
|
|
38
38
|
rows.forEach((row) => output.print(printRow(row)))
|
39
39
|
}
|
40
40
|
|
41
|
-
export default async function
|
41
|
+
export default async function storeSchemaAction(
|
42
42
|
args: CliCommandArguments<SchemaListFlags>,
|
43
43
|
context: CliCommandContext,
|
44
44
|
): Promise<void> {
|
45
45
|
const flags = args.extOptions
|
46
|
+
if (typeof flags.id === 'boolean') throw new Error('Id is empty')
|
46
47
|
const {apiClient, output} = context
|
47
48
|
const client = apiClient({
|
48
49
|
requireUser: true,
|
@@ -20,11 +20,16 @@ export interface StoreManifestSchemasFlags {
|
|
20
20
|
'verbose'?: boolean
|
21
21
|
}
|
22
22
|
|
23
|
-
export default async function
|
23
|
+
export default async function storeSchemasAction(
|
24
24
|
args: CliCommandArguments<StoreManifestSchemasFlags>,
|
25
25
|
context: CliCommandContext,
|
26
26
|
): Promise<Error | undefined> {
|
27
27
|
const flags = args.extOptions
|
28
|
+
if (typeof flags.path === 'boolean') throw new Error('Path is empty')
|
29
|
+
if (typeof flags['id-prefix'] === 'boolean') throw new Error('Id prefix is empty')
|
30
|
+
if (typeof flags.workspace === 'boolean') throw new Error('Workspace is empty')
|
31
|
+
|
32
|
+
const schemaRequired = flags['schema-required']
|
28
33
|
const workspaceName = flags.workspace
|
29
34
|
const idPrefix = flags['id-prefix']
|
30
35
|
const verbose = flags.verbose
|
@@ -63,11 +68,11 @@ export default async function storeManifestSchemas(
|
|
63
68
|
let error: Error | undefined
|
64
69
|
|
65
70
|
const saveSchema = async (workspace: ManifestWorkspaceFile) => {
|
66
|
-
const id = `${idPrefix
|
71
|
+
const id = `${idPrefix ? `${idPrefix}.` : ''}${SANITY_WORKSPACE_SCHEMA_ID}.${workspace.name}`
|
67
72
|
try {
|
68
73
|
if (workspace.projectId !== projectId) {
|
69
74
|
throw new Error(
|
70
|
-
|
75
|
+
`↳ No permissions to store schema for workspace ${workspace.name} with projectId: ${workspace.projectId}`,
|
71
76
|
)
|
72
77
|
}
|
73
78
|
const schema = JSON.parse(
|
@@ -87,12 +92,13 @@ export default async function storeManifestSchemas(
|
|
87
92
|
} catch (err) {
|
88
93
|
error = err
|
89
94
|
spinner.fail(
|
90
|
-
`Error storing schema for workspace '${workspace.name}':\n${chalk.red(
|
95
|
+
`Error storing schema for workspace '${workspace.name}':\n${chalk.red(`${err.message}`)}`,
|
91
96
|
)
|
97
|
+
if (schemaRequired) throw err
|
92
98
|
} finally {
|
93
99
|
if (verbose) {
|
94
100
|
output.print(
|
95
|
-
|
101
|
+
chalk.gray(`↳ schemaId: ${id}, projectId: ${projectId}, dataset: ${workspace.dataset}`),
|
96
102
|
)
|
97
103
|
}
|
98
104
|
}
|
@@ -103,29 +109,28 @@ export default async function storeManifestSchemas(
|
|
103
109
|
const workspaceToSave = manifest.workspaces.find(
|
104
110
|
(workspace) => workspace.name === workspaceName,
|
105
111
|
)
|
106
|
-
if (workspaceToSave) {
|
107
|
-
await saveSchema(workspaceToSave)
|
108
|
-
} else {
|
112
|
+
if (!workspaceToSave) {
|
109
113
|
spinner.fail(`Workspace ${workspaceName} not found in manifest`)
|
110
|
-
|
111
|
-
`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`,
|
112
|
-
)
|
114
|
+
throw new Error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`)
|
113
115
|
}
|
116
|
+
await saveSchema(workspaceToSave as ManifestWorkspaceFile)
|
117
|
+
spinner.succeed(`Stored 1 schemas`)
|
114
118
|
} else {
|
115
119
|
await Promise.all(
|
116
120
|
manifest.workspaces.map(async (workspace): Promise<void> => {
|
117
121
|
await saveSchema(workspace)
|
118
122
|
}),
|
119
123
|
)
|
124
|
+
spinner.succeed(`Stored ${storedCount}/${manifest.workspaces.length} schemas`)
|
120
125
|
}
|
121
126
|
|
122
|
-
spinner.succeed(`Stored ${storedCount}/${manifest.workspaces.length} schemas`)
|
123
|
-
|
124
127
|
if (error) throw error
|
125
128
|
return undefined
|
126
129
|
} catch (err) {
|
127
130
|
// if this flag is set, throw the error and exit without deploying otherwise just log the error
|
128
|
-
if (
|
131
|
+
if (schemaRequired) throw err
|
129
132
|
return err
|
133
|
+
} finally {
|
134
|
+
output.print(`${chalk.gray('↳ List stored schemas with:')} ${chalk.cyan('sanity schema list')}`)
|
130
135
|
}
|
131
136
|
}
|
@@ -7,8 +7,6 @@ const description = 'Delete schemas by their IDs.'
|
|
7
7
|
const helpText = `
|
8
8
|
**Note**: This command is experimental and subject to change.
|
9
9
|
|
10
|
-
Delete schemas by their IDs.
|
11
|
-
|
12
10
|
Options
|
13
11
|
--ids <schema_id_1,schema_id_2,...> comma-separated list of schema IDs to delete
|
14
12
|
|
@@ -7,8 +7,6 @@ const description = 'Lists all schemas in the current dataset.'
|
|
7
7
|
const helpText = `
|
8
8
|
**Note**: This command is experimental and subject to change.
|
9
9
|
|
10
|
-
Lists all schemas in the current dataset.
|
11
|
-
|
12
10
|
Options
|
13
11
|
--json get schemas as json
|
14
12
|
--id <schema_id> fetch a specific schema by its ID
|
@@ -2,7 +2,7 @@ import {type CliCommandArguments, type CliCommandDefinition} from '@sanity/cli'
|
|
2
2
|
|
3
3
|
import {type StoreManifestSchemasFlags} from '../../actions/schema/storeSchemasAction'
|
4
4
|
|
5
|
-
const description = ''
|
5
|
+
const description = 'Store schemas into the current dataset.'
|
6
6
|
|
7
7
|
const helpText = `
|
8
8
|
**Note**: This command is experimental and subject to change.
|