sanity 3.72.2-server-side-schemas-1.19 → 3.72.2-server-side-schemas.22

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.
@@ -74,14 +74,18 @@ async function deployStudioAction(args, context) {
74
74
  ...buildArgs,
75
75
  extOptions: {},
76
76
  extraArguments: []
77
- }, context), storeManifestSchemasArgs = {
77
+ }, context);
78
+ if (flags["schema-required"] && extractManifestError)
79
+ throw output.error(`Schema extraction error: ${extractManifestError.message}`), extractManifestError;
80
+ const storeManifestSchemasArgs = {
78
81
  ...args,
79
82
  extOptions: {
80
- path: `${sourceDir}/static`
83
+ path: `${sourceDir}/static`,
84
+ "schema-required": flags["schema-required"]
81
85
  },
82
86
  extraArguments: []
83
87
  };
84
- extractManifestError || await storeSchemasAction.default(storeManifestSchemasArgs, context);
88
+ await storeSchemasAction.default(storeManifestSchemasArgs, context);
85
89
  }
86
90
  spinner = output.spinner("Verifying local content").start();
87
91
  try {
@@ -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 checkDir,\n createDeployment,\n debug,\n dirIsEmptyOrNonExistent,\n getInstalledSanityVersion,\n getOrCreateUserApplication,\n getOrCreateUserApplicationFromConfig,\n type UserApplication,\n} from './helpers'\n\nexport interface DeployStudioActionFlags extends BuildSanityStudioCommandFlags {\n build?: boolean\n}\n\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\n const installedSanityVersion = await getInstalledSanityVersion()\n const configStudioHost = cliConfig && 'studioHost' in cliConfig && cliConfig.studioHost\n\n const client = apiClient({\n requireUser: true,\n requireProject: true,\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 // If the user has provided a studioHost in the config, use that\n if (configStudioHost) {\n userApplication = await getOrCreateUserApplicationFromConfig({\n client,\n context,\n spinner,\n appHost: configStudioHost,\n })\n } else {\n userApplication = await getOrCreateUserApplication({\n client,\n context,\n spinner,\n })\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 const extractManifestError = await extractManifestSafe(\n {\n ...buildArgs,\n extOptions: {},\n extraArguments: [],\n },\n context,\n )\n\n const storeManifestSchemasArgs = {\n ...args,\n extOptions: {\n path: `${sourceDir}/static`,\n },\n extraArguments: [],\n }\n\n if (!extractManifestError) 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 Sanity.Studio').start()\n try {\n const {location} = await createDeployment({\n client,\n applicationId: userApplication.id,\n version: installedSanityVersion,\n isAutoUpdating,\n tarball,\n })\n\n spinner.succeed()\n\n // And let the user know we're done\n output.print(`\\nSuccess! Studio deployed to ${chalk.cyan(location)}`)\n\n if (!configStudioHost) {\n output.print(`\\nAdd ${chalk.cyan(`studioHost: '${userApplication.appHost}'`)}`)\n output.print('to defineCliConfig root properties in sanity.cli.js or sanity.cli.ts')\n output.print('to avoid prompting 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","installedSanityVersion","getInstalledSanityVersion","configStudioHost","studioHost","client","requireUser","requireProject","withConfig","apiVersion","Error","relativeOutput","relative","dirIsEmptyOrNonExistent","single","type","message","default","print","spinner","start","userApplication","getOrCreateUserApplicationFromConfig","appHost","getOrCreateUserApplication","err","error","red","debug","buildArgs","filter","Boolean","didCompile","buildSanityStudio","basePath","extractManifestError","extractManifestSafe","extraArguments","storeManifestSchemasArgs","storeManifestSchemas","checkDir","succeed","fail","parentDir","dirname","base","basename","tarball","tar","pack","entries","pipe","zlib","createGzip","location","createDeployment","applicationId","id","version","cyan"],"mappings":";;;;;;AA0B8BA,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,GAEpDc,yBAAyB,MAAMC,QAA0B,0BAAA,GACzDC,mBAAmBhB,aAAa,gBAAgBA,aAAaA,UAAUiB,YAEvEC,SAASvB,UAAU;AAAA,IACvBwB,aAAa;AAAA,IACbC,gBAAgB;AAAA,EACjB,CAAA,EAAEC,WAAW;AAAA,IAACC,YAAY;AAAA,EAAA,CAAc;AAEzC,MAAIlB,oBAAoB;AAChB,UAAA,IAAImB,MAAM,uCAAuC;AAGzD,MAAInB,iBAAiB;AACnB,QAAIoB,iBAAiBjB,cAAAA,QAAKkB,SAAShB,QAAQC,OAAOJ,SAAS;AAc3D,QAbIkB,eAAe,CAAC,MAAM,QACxBA,iBAAiB,KAAKA,cAAc,KAYlC,EATY,MAAME,QAAwBpB,wBAAAA,SAAS,KAGpD,MAAMP,OAAO4B,OAAO;AAAA,MACnBC,MAAM;AAAA,MACNC,SAAS,IAAIL,cAAc;AAAA,MAC3BM,SAAS;AAAA,IACV,CAAA,IAEiB;AAClBhC,aAAOiC,MAAM,YAAY;AACzB;AAAA,IAAA;AAGKA,WAAAA,MAAM,eAAeP,cAAc;AAAA,CAAI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AQsB,QAAQ;AAAA,WACThB,KAAK;AACZN,UAAAA,QAAQuB,KAAK,GACbd,QAAM,MAAA,4BAA4BH,GAAG,GAC/BA;AAAAA,EAAAA;AAIR,QAAMkB,YAAYjD,cAAAA,QAAKkD,QAAQnD,SAAS,GAClCoD,OAAOnD,cAAAA,QAAKoD,SAASrD,SAAS,GAC9BsD,UAAUC,aAAAA,QAAIC,KAAKN,WAAW;AAAA,IAACO,SAAS,CAACL,IAAI;AAAA,EAAE,CAAA,EAAEM,KAAKC,sBAAKC,YAAY;AAE7ElC,YAAUlC,OAAOkC,QAAQ,4BAA4B,EAAEC,MAAM;AACzD,MAAA;AACI,UAAA;AAAA,MAACkC;AAAAA,IAAQ,IAAI,MAAMC,QAAAA,iBAAiB;AAAA,MACxClD;AAAAA,MACAmD,eAAenC,gBAAgBoC;AAAAA,MAC/BC,SAASzD;AAAAA,MACTF;AAAAA,MACAgD;AAAAA,IAAAA,CACD;AAEON,YAAAA,QAAAA,GAGRxD,OAAOiC,MAAM;AAAA,8BAAiClC,MAAM2E,KAAKL,QAAQ,CAAC,EAAE,GAE/DnD,qBACHlB,OAAOiC,MAAM;AAAA,MAASlC,MAAM2E,KAAK,gBAAgBtC,gBAAgBE,OAAO,GAAG,CAAC,EAAE,GAC9EtC,OAAOiC,MAAM,sEAAsE,GACnFjC,OAAOiC,MAAM,iDAAiD;AAAA,WAEzDO,KAAK;AACZN,UAAAA,QAAQuB,KAAK,GACbd,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 checkDir,\n createDeployment,\n debug,\n dirIsEmptyOrNonExistent,\n getInstalledSanityVersion,\n getOrCreateUserApplication,\n getOrCreateUserApplicationFromConfig,\n type UserApplication,\n} from './helpers'\n\nexport interface DeployStudioActionFlags extends BuildSanityStudioCommandFlags {\n 'build'?: boolean\n 'schema-required'?: boolean\n}\n\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\n const installedSanityVersion = await getInstalledSanityVersion()\n const configStudioHost = cliConfig && 'studioHost' in cliConfig && cliConfig.studioHost\n\n const client = apiClient({\n requireUser: true,\n requireProject: true,\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 // If the user has provided a studioHost in the config, use that\n if (configStudioHost) {\n userApplication = await getOrCreateUserApplicationFromConfig({\n client,\n context,\n spinner,\n appHost: configStudioHost,\n })\n } else {\n userApplication = await getOrCreateUserApplication({\n client,\n context,\n spinner,\n })\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 const extractManifestError = await extractManifestSafe(\n {\n ...buildArgs,\n extOptions: {},\n extraArguments: [],\n },\n context,\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 },\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 Sanity.Studio').start()\n try {\n const {location} = await createDeployment({\n client,\n applicationId: userApplication.id,\n version: installedSanityVersion,\n isAutoUpdating,\n tarball,\n })\n\n spinner.succeed()\n\n // And let the user know we're done\n output.print(`\\nSuccess! Studio deployed to ${chalk.cyan(location)}`)\n\n if (!configStudioHost) {\n output.print(`\\nAdd ${chalk.cyan(`studioHost: '${userApplication.appHost}'`)}`)\n output.print('to defineCliConfig root properties in sanity.cli.js or sanity.cli.ts')\n output.print('to avoid prompting 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","installedSanityVersion","getInstalledSanityVersion","configStudioHost","studioHost","client","requireUser","requireProject","withConfig","apiVersion","Error","relativeOutput","relative","dirIsEmptyOrNonExistent","single","type","message","default","print","spinner","start","userApplication","getOrCreateUserApplicationFromConfig","appHost","getOrCreateUserApplication","err","error","red","debug","buildArgs","filter","Boolean","didCompile","buildSanityStudio","basePath","extractManifestError","extractManifestSafe","extraArguments","storeManifestSchemasArgs","storeManifestSchemas","checkDir","succeed","fail","parentDir","dirname","base","basename","tarball","tar","pack","entries","pipe","zlib","createGzip","location","createDeployment","applicationId","id","version","cyan"],"mappings":";;;;;;AA2B8BA,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,GAEpDc,yBAAyB,MAAMC,QAA0B,0BAAA,GACzDC,mBAAmBhB,aAAa,gBAAgBA,aAAaA,UAAUiB,YAEvEC,SAASvB,UAAU;AAAA,IACvBwB,aAAa;AAAA,IACbC,gBAAgB;AAAA,EACjB,CAAA,EAAEC,WAAW;AAAA,IAACC,YAAY;AAAA,EAAA,CAAc;AAEzC,MAAIlB,oBAAoB;AA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KAAKL,QAAQ,CAAC,EAAE,GAE/DnD,qBACHlB,OAAOiC,MAAM;AAAA,MAASlC,MAAM2E,KAAK,gBAAgBtC,gBAAgBE,OAAO,GAAG,CAAC,EAAE,GAC9EtC,OAAOiC,MAAM,sEAAsE,GACnFjC,OAAOiC,MAAM,iDAAiD;AAAA,WAEzDO,KAAK;AACZN,UAAAA,QAAQuB,KAAK,GACbd,QAAM,MAAA,0BAA0BH,GAAG,GAC7BA;AAAAA,EAAAA;AAEV;;"}
@@ -5,7 +5,7 @@ function _interopDefaultCompat(e) {
5
5
  }
6
6
  var path__default = /* @__PURE__ */ _interopDefaultCompat(path);
7
7
  async function storeManifestSchemas(args, context) {
8
- const flags = args.extOptions, workspaceName = flags.workspace, customId = flags["custom-id"], {
8
+ const flags = args.extOptions, workspaceName = flags.workspace, idPrefix = flags["id-prefix"], {
9
9
  output,
10
10
  workDir,
11
11
  apiClient
@@ -17,10 +17,10 @@ async function storeManifestSchemas(args, context) {
17
17
  }).withConfig({
18
18
  apiVersion: "v2024-08-01"
19
19
  }), projectId = client.config().projectId, manifest = JSON.parse(fs.readFileSync(`${manifestPath}/create-manifest.json`, "utf-8")), saveSchema = async (workspace) => {
20
- const spinner = output.spinner({}).start("Storing schemas"), id = customId || `sanity.workspace.schema.${workspace.name}`;
20
+ const spinner = output.spinner({}).start("Storing schemas"), id = `${idPrefix || "sanity.workspace.schema"}.${workspace.name}`;
21
21
  try {
22
22
  if (workspace.projectId !== projectId && workspaceName !== workspace.name) {
23
- spinner.fail(`Cannot store schema for ${workspace.name} because manifest projectId does not match: ${projectId} !== ${workspace.projectId}`);
23
+ spinner.fail(`Mismatch between cli config and manifest projectId in workspace ${workspace.name}: ${projectId} !== ${workspace.projectId}`);
24
24
  return;
25
25
  }
26
26
  const schema = JSON.parse(fs.readFileSync(`${manifestPath}/${workspace.schema}`, "utf-8"));
@@ -32,20 +32,33 @@ async function storeManifestSchemas(args, context) {
32
32
  _id: id,
33
33
  workspace,
34
34
  schema
35
- }).commit(), spinner.succeed(`Schema stored for workspace ${workspace.name} (shcemaId: ${id}, projectId: ${projectId}, dataset: ${workspace.dataset})`);
35
+ }).commit(), spinner.succeed(`Schema stored for workspace ${workspace.name}`);
36
36
  } catch (error) {
37
- spinner.fail(`Error storing schema for workspace ${workspace.name}: ${error}`);
37
+ throw spinner.fail(`Error storing schema for workspace: ${error}`), error;
38
+ } finally {
39
+ output.print(JSON.stringify({
40
+ workspace: workspace.name,
41
+ schemaId: id,
42
+ projectId,
43
+ dataset: workspace.dataset
44
+ }, null, 2));
38
45
  }
39
46
  };
40
47
  if (workspaceName) {
41
- const schemaToSave = manifest.workspaces.find((workspace) => workspace.name === workspaceName);
42
- schemaToSave ? await saveSchema(schemaToSave) : output.error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`);
43
- } else
44
- await Promise.all(manifest.workspaces.map(async (workspace) => {
45
- await saveSchema(workspace);
46
- }));
48
+ const workspaceToSave = manifest.workspaces.find((workspace) => workspace.name === workspaceName);
49
+ if (!workspaceToSave)
50
+ return output.error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`), new Error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`);
51
+ await saveSchema(workspaceToSave);
52
+ return;
53
+ }
54
+ await Promise.all(manifest.workspaces.map(async (workspace) => {
55
+ await saveSchema(workspace);
56
+ }));
57
+ return;
47
58
  } catch (err) {
48
- output.error(err);
59
+ if (output.error(err), flags["schema-required"])
60
+ throw err;
61
+ return err;
49
62
  }
50
63
  }
51
64
  exports.default = storeManifestSchemas;
@@ -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'\n\nimport {\n type CreateManifest,\n type ManifestSchemaType,\n type ManifestWorkspaceFile,\n} from '../../../manifest/manifestTypes'\n\nexport interface StoreManifestSchemasFlags {\n 'path'?: string\n 'workspace'?: string\n 'custom-id'?: string\n}\n\nexport default async function storeManifestSchemas(\n args: CliCommandArguments<StoreManifestSchemasFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const flags = args.extOptions\n const workspaceName = flags.workspace\n const customId = flags['custom-id']\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 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 const manifest: CreateManifest = JSON.parse(\n readFileSync(`${manifestPath}/create-manifest.json`, 'utf-8'),\n )\n\n const saveSchema = async (workspace: ManifestWorkspaceFile) => {\n const spinner = output.spinner({}).start('Storing schemas')\n const id = customId || `sanity.workspace.schema.${workspace.name}`\n try {\n if (workspace.projectId !== projectId && workspaceName !== workspace.name) {\n spinner.fail(\n `Cannot store schema for ${workspace.name} because manifest projectId does not match: ${projectId} !== ${workspace.projectId}`,\n )\n return\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, workspace, schema})\n .commit()\n spinner.succeed(\n `Schema stored for workspace ${workspace.name} (shcemaId: ${id}, projectId: ${projectId}, dataset: ${workspace.dataset})`,\n )\n } catch (error) {\n spinner.fail(`Error storing schema for workspace ${workspace.name}: ${error}`)\n }\n }\n\n if (workspaceName) {\n const schemaToSave = manifest.workspaces.find((workspace) => workspace.name === workspaceName)\n if (schemaToSave) {\n await saveSchema(schemaToSave)\n } else {\n output.error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`)\n }\n } else {\n await Promise.all(\n manifest.workspaces.map(async (workspace): Promise<void> => {\n await saveSchema(workspace)\n }),\n )\n }\n } catch (err) {\n output.error(err)\n }\n}\n"],"names":["storeManifestSchemas","args","context","flags","extOptions","workspaceName","workspace","customId","output","workDir","apiClient","defaultOutputDir","resolve","join","outputDir","defaultStaticPath","staticPath","path","manifestPath","process","cwd","client","requireUser","requireProject","withConfig","apiVersion","projectId","config","manifest","JSON","parse","readFileSync","saveSchema","spinner","start","id","name","fail","schema","dataset","transaction","createOrReplace","_type","_id","commit","succeed","error","schemaToSave","workspaces","find","Promise","all","map","err"],"mappings":";;;;;;AAiB8BA,eAAAA,qBAC5BC,MACAC,SACe;AACTC,QAAAA,QAAQF,KAAKG,YACbC,gBAAgBF,MAAMG,WACtBC,WAAWJ,MAAM,WAAW,GAC5B;AAAA,IAACK;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,EAAAA,IAAaR,SAE/BS,mBAAmBC,aAAQC,KAAAA,KAAKJ,SAAS,MAAM,CAAC,GAEhDK,YAAYF,KAAAA,QAAQD,gBAAgB,GACpCI,oBAAoBF,KAAAA,KAAKC,WAAW,QAAQ,GAE5CE,aAAab,MAAMc,QAAQF;AAE7B,MAAA;AACIG,UAAAA,eAAeD,sBAAKL,QAAQO,QAAQC,OAAOJ,UAAU,GACrDK,SAASX,UAAU;AAAA,MACvBY,aAAa;AAAA,MACbC,gBAAgB;AAAA,IACjB,CAAA,EAAEC,WAAW;AAAA,MAACC,YAAY;AAAA,IAAA,CAAc,GAEnCC,YAAYL,OAAOM,OAAO,EAAED,WAE5BE,WAA2BC,KAAKC,MACpCC,GAAa,aAAA,GAAGb,YAAY,yBAAyB,OAAO,CAC9D,GAEMc,aAAa,OAAO1B,cAAqC;AAC7D,YAAM2B,UAAUzB,OAAOyB,QAAQ,CAAE,CAAA,EAAEC,MAAM,iBAAiB,GACpDC,KAAK5B,YAAY,2BAA2BD,UAAU8B,IAAI;AAC5D,UAAA;AACF,YAAI9B,UAAUoB,cAAcA,aAAarB,kBAAkBC,UAAU8B,MAAM;AACjEC,kBAAAA,KACN,2BAA2B/B,UAAU8B,IAAI,+CAA+CV,SAAS,QAAQpB,UAAUoB,SAAS,EAC9H;AACA;AAAA,QAAA;AAEIY,cAAAA,SAAST,KAAKC,MAClBC,GAAa,aAAA,GAAGb,YAAY,IAAIZ,UAAUgC,MAAM,IAAI,OAAO,CAC7D;AACA,cAAMjB,OACHG,WAAW;AAAA,UACVe,SAASjC,UAAUiC;AAAAA,UACnBb,WAAWpB,UAAUoB;AAAAA,QAAAA,CACtB,EACAc,YAAY,EACZC,gBAAgB;AAAA,UAACC,OAAO;AAAA,UAA2BC,KAAKR;AAAAA,UAAI7B;AAAAA,UAAWgC;AAAAA,QAAAA,CAAO,EAC9EM,OAAAA,GACHX,QAAQY,QACN,+BAA+BvC,UAAU8B,IAAI,eAAeD,EAAE,gBAAgBT,SAAS,cAAcpB,UAAUiC,OAAO,GACxH;AAAA,eACOO,OAAO;AACdb,gBAAQI,KAAK,sCAAsC/B,UAAU8B,IAAI,KAAKU,KAAK,EAAE;AAAA,MAAA;AAAA,IAEjF;AAEA,QAAIzC,eAAe;AACjB,YAAM0C,eAAenB,SAASoB,WAAWC,KAAM3C,CAAcA,cAAAA,UAAU8B,SAAS/B,aAAa;AACzF0C,qBACF,MAAMf,WAAWe,YAAY,IAE7BvC,OAAOsC,MAAM,aAAazC,aAAa,sCAAsCqB,SAAS,EAAE;AAAA,IAE5F;AACE,YAAMwB,QAAQC,IACZvB,SAASoB,WAAWI,IAAI,OAAO9C,cAA6B;AAC1D,cAAM0B,WAAW1B,SAAS;AAAA,MAAA,CAC3B,CACH;AAAA,WAEK+C,KAAK;AACZ7C,WAAOsC,MAAMO,GAAG;AAAA,EAAA;AAEpB;;"}
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'\n\nimport {\n type CreateManifest,\n type ManifestSchemaType,\n type ManifestWorkspaceFile,\n} from '../../../manifest/manifestTypes'\n\nexport interface StoreManifestSchemasFlags {\n 'path'?: string\n 'workspace'?: string\n 'id-prefix'?: string\n 'schema-required'?: boolean\n}\n\nexport default async function storeManifestSchemas(\n args: CliCommandArguments<StoreManifestSchemasFlags>,\n context: CliCommandContext,\n): Promise<Error | undefined> {\n const flags = args.extOptions\n const workspaceName = flags.workspace\n const idPrefix = flags['id-prefix']\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 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 const manifest: CreateManifest = JSON.parse(\n readFileSync(`${manifestPath}/create-manifest.json`, 'utf-8'),\n )\n\n const saveSchema = async (workspace: ManifestWorkspaceFile) => {\n const spinner = output.spinner({}).start('Storing schemas')\n const id = `${idPrefix || 'sanity.workspace.schema'}.${workspace.name}`\n try {\n if (workspace.projectId !== projectId && workspaceName !== workspace.name) {\n spinner.fail(\n `Mismatch between cli config and manifest projectId in workspace ${workspace.name}: ${projectId} !== ${workspace.projectId}`,\n )\n return\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, workspace, schema})\n .commit()\n spinner.succeed(`Schema stored for workspace ${workspace.name}`)\n } catch (error) {\n spinner.fail(`Error storing schema for workspace: ${error}`)\n throw error\n } finally {\n output.print(\n JSON.stringify(\n {workspace: workspace.name, schemaId: id, projectId, dataset: workspace.dataset},\n null,\n 2,\n ),\n )\n }\n }\n // If workspace name is provided, we only need to save one schema\n if (workspaceName) {\n const workspaceToSave = manifest.workspaces.find(\n (workspace) => workspace.name === workspaceName,\n )\n if (!workspaceToSave) {\n output.error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`)\n return new Error(\n `Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`,\n )\n }\n await saveSchema(workspaceToSave)\n return undefined\n }\n await Promise.all(\n manifest.workspaces.map(async (workspace): Promise<void> => {\n await saveSchema(workspace)\n }),\n )\n return undefined\n } catch (err) {\n output.error(err)\n if (flags['schema-required']) {\n throw err\n }\n return err\n }\n}\n"],"names":["storeManifestSchemas","args","context","flags","extOptions","workspaceName","workspace","idPrefix","output","workDir","apiClient","defaultOutputDir","resolve","join","outputDir","defaultStaticPath","staticPath","path","manifestPath","process","cwd","client","requireUser","requireProject","withConfig","apiVersion","projectId","config","manifest","JSON","parse","readFileSync","saveSchema","spinner","start","id","name","fail","schema","dataset","transaction","createOrReplace","_type","_id","commit","succeed","error","print","stringify","schemaId","workspaceToSave","workspaces","find","Error","Promise","all","map","err"],"mappings":";;;;;;AAkB8BA,eAAAA,qBAC5BC,MACAC,SAC4B;AACtBC,QAAAA,QAAQF,KAAKG,YACbC,gBAAgBF,MAAMG,WACtBC,WAAWJ,MAAM,WAAW,GAC5B;AAAA,IAACK;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,EAAAA,IAAaR,SAE/BS,mBAAmBC,aAAQC,KAAAA,KAAKJ,SAAS,MAAM,CAAC,GAEhDK,YAAYF,KAAAA,QAAQD,gBAAgB,GACpCI,oBAAoBF,KAAAA,KAAKC,WAAW,QAAQ,GAE5CE,aAAab,MAAMc,QAAQF;AAE7B,MAAA;AACIG,UAAAA,eAAeD,sBAAKL,QAAQO,QAAQC,OAAOJ,UAAU,GACrDK,SAASX,UAAU;AAAA,MACvBY,aAAa;AAAA,MAC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AAM6C,kBAAkBtB,SAASuB,WAAWC,KACzC9C,CAAcA,cAAAA,UAAU8B,SAAS/B,aACpC;AACA,UAAI,CAAC6C;AACH1C,eAAAA,OAAOsC,MAAM,aAAazC,aAAa,sCAAsCqB,SAAS,EAAE,GACjF,IAAI2B,MACT,aAAahD,aAAa,sCAAsCqB,SAAS,EAC3E;AAEF,YAAMM,WAAWkB,eAAe;AAChC;AAAA,IAAA;AAEF,UAAMI,QAAQC,IACZ3B,SAASuB,WAAWK,IAAI,OAAOlD,cAA6B;AAC1D,YAAM0B,WAAW1B,SAAS;AAAA,IAAA,CAC3B,CACH;AACA;AAAA,WACOmD,KAAK;AAEZ,QADAjD,OAAOsC,MAAMW,GAAG,GACZtD,MAAM,iBAAiB;AACnBsD,YAAAA;AAEDA,WAAAA;AAAAA,EAAAA;AAEX;;"}
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const SANITY_VERSION = "3.72.2-server-side-schemas-1.19+859744ea04";
2
+ const SANITY_VERSION = "3.72.2-server-side-schemas.22+aa667f171a";
3
3
  exports.SANITY_VERSION = SANITY_VERSION;
4
4
  //# sourceMappingURL=version.js.map
@@ -1,4 +1,4 @@
1
- const SANITY_VERSION = "3.72.2-server-side-schemas-1.19+859744ea04";
1
+ const SANITY_VERSION = "3.72.2-server-side-schemas.22+aa667f171a";
2
2
  export {
3
3
  SANITY_VERSION
4
4
  };
@@ -1,4 +1,4 @@
1
- const SANITY_VERSION = "3.72.2-server-side-schemas-1.19+859744ea04";
1
+ const SANITY_VERSION = "3.72.2-server-side-schemas.22+aa667f171a";
2
2
  export {
3
3
  SANITY_VERSION
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity",
3
- "version": "3.72.2-server-side-schemas-1.19+859744ea04",
3
+ "version": "3.72.2-server-side-schemas.22+aa667f171a",
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.72.2-server-side-schemas-1.19+859744ea04",
163
+ "@sanity/cli": "3.72.2-server-side-schemas.22+aa667f171a",
164
164
  "@sanity/client": "^6.27.2",
165
165
  "@sanity/color": "^3.0.0",
166
166
  "@sanity/comlink": "^3.0.1",
167
- "@sanity/diff": "3.72.2-server-side-schemas-1.19+859744ea04",
167
+ "@sanity/diff": "3.72.2-server-side-schemas.22+aa667f171a",
168
168
  "@sanity/diff-match-patch": "^3.1.1",
169
169
  "@sanity/eventsource": "^5.0.0",
170
170
  "@sanity/export": "^3.42.2",
@@ -173,15 +173,15 @@
173
173
  "@sanity/import": "^3.37.9",
174
174
  "@sanity/insert-menu": "1.0.20",
175
175
  "@sanity/logos": "^2.1.13",
176
- "@sanity/migrate": "3.72.2-server-side-schemas-1.19+859744ea04",
177
- "@sanity/mutator": "3.72.2-server-side-schemas-1.19+859744ea04",
176
+ "@sanity/migrate": "3.72.2-server-side-schemas.22+aa667f171a",
177
+ "@sanity/mutator": "3.72.2-server-side-schemas.22+aa667f171a",
178
178
  "@sanity/presentation-comlink": "^1.0.4",
179
179
  "@sanity/preview-url-secret": "^2.1.4",
180
- "@sanity/schema": "3.72.2-server-side-schemas-1.19+859744ea04",
180
+ "@sanity/schema": "3.72.2-server-side-schemas.22+aa667f171a",
181
181
  "@sanity/telemetry": "^0.7.7",
182
- "@sanity/types": "3.72.2-server-side-schemas-1.19+859744ea04",
182
+ "@sanity/types": "3.72.2-server-side-schemas.22+aa667f171a",
183
183
  "@sanity/ui": "^2.11.7",
184
- "@sanity/util": "3.72.2-server-side-schemas-1.19+859744ea04",
184
+ "@sanity/util": "3.72.2-server-side-schemas.22+aa667f171a",
185
185
  "@sanity/uuid": "^3.0.2",
186
186
  "@sentry/react": "^8.33.0",
187
187
  "@tanstack/react-table": "^8.16.0",
@@ -280,7 +280,7 @@
280
280
  "@repo/dev-aliases": "3.72.1",
281
281
  "@repo/package.config": "3.72.1",
282
282
  "@repo/test-config": "3.72.1",
283
- "@sanity/codegen": "3.72.2-server-side-schemas-1.19+859744ea04",
283
+ "@sanity/codegen": "3.72.2-server-side-schemas.22+aa667f171a",
284
284
  "@sanity/generate-help-url": "^3.0.0",
285
285
  "@sanity/pkg-utils": "6.13.4",
286
286
  "@sanity/tsdoc": "1.0.169",
@@ -324,5 +324,5 @@
324
324
  "engines": {
325
325
  "node": ">=18"
326
326
  },
327
- "gitHead": "859744ea0435d9fb9eb06195517f9c5f81049f4e"
327
+ "gitHead": "aa667f171a76847a9e510027671d4c823358628a"
328
328
  }
@@ -21,7 +21,8 @@ import {
21
21
  } from './helpers'
22
22
 
23
23
  export interface DeployStudioActionFlags extends BuildSanityStudioCommandFlags {
24
- build?: boolean
24
+ 'build'?: boolean
25
+ 'schema-required'?: boolean
25
26
  }
26
27
 
27
28
  export default async function deployStudioAction(
@@ -122,16 +123,21 @@ export default async function deployStudioAction(
122
123
  },
123
124
  context,
124
125
  )
126
+ if (flags['schema-required'] && extractManifestError) {
127
+ output.error(`Schema extraction error: ${extractManifestError.message}`)
128
+ throw extractManifestError
129
+ }
125
130
 
126
131
  const storeManifestSchemasArgs = {
127
132
  ...args,
128
133
  extOptions: {
129
- path: `${sourceDir}/static`,
134
+ 'path': `${sourceDir}/static`,
135
+ 'schema-required': flags['schema-required'],
130
136
  },
131
137
  extraArguments: [],
132
138
  }
133
139
 
134
- if (!extractManifestError) await storeManifestSchemas(storeManifestSchemasArgs, context)
140
+ await storeManifestSchemas(storeManifestSchemasArgs, context)
135
141
  }
136
142
 
137
143
  // Ensure that the directory exists, is a directory and seems to have valid content
@@ -12,16 +12,17 @@ import {
12
12
  export interface StoreManifestSchemasFlags {
13
13
  'path'?: string
14
14
  'workspace'?: string
15
- 'custom-id'?: string
15
+ 'id-prefix'?: string
16
+ 'schema-required'?: boolean
16
17
  }
17
18
 
18
19
  export default async function storeManifestSchemas(
19
20
  args: CliCommandArguments<StoreManifestSchemasFlags>,
20
21
  context: CliCommandContext,
21
- ): Promise<void> {
22
+ ): Promise<Error | undefined> {
22
23
  const flags = args.extOptions
23
24
  const workspaceName = flags.workspace
24
- const customId = flags['custom-id']
25
+ const idPrefix = flags['id-prefix']
25
26
  const {output, workDir, apiClient} = context
26
27
 
27
28
  const defaultOutputDir = resolve(join(workDir, 'dist'))
@@ -46,11 +47,11 @@ export default async function storeManifestSchemas(
46
47
 
47
48
  const saveSchema = async (workspace: ManifestWorkspaceFile) => {
48
49
  const spinner = output.spinner({}).start('Storing schemas')
49
- const id = customId || `sanity.workspace.schema.${workspace.name}`
50
+ const id = `${idPrefix || 'sanity.workspace.schema'}.${workspace.name}`
50
51
  try {
51
52
  if (workspace.projectId !== projectId && workspaceName !== workspace.name) {
52
53
  spinner.fail(
53
- `Cannot store schema for ${workspace.name} because manifest projectId does not match: ${projectId} !== ${workspace.projectId}`,
54
+ `Mismatch between cli config and manifest projectId in workspace ${workspace.name}: ${projectId} !== ${workspace.projectId}`,
54
55
  )
55
56
  return
56
57
  }
@@ -65,29 +66,45 @@ export default async function storeManifestSchemas(
65
66
  .transaction()
66
67
  .createOrReplace({_type: 'sanity.workspace.schema', _id: id, workspace, schema})
67
68
  .commit()
68
- spinner.succeed(
69
- `Schema stored for workspace ${workspace.name} (shcemaId: ${id}, projectId: ${projectId}, dataset: ${workspace.dataset})`,
70
- )
69
+ spinner.succeed(`Schema stored for workspace ${workspace.name}`)
71
70
  } catch (error) {
72
- spinner.fail(`Error storing schema for workspace ${workspace.name}: ${error}`)
71
+ spinner.fail(`Error storing schema for workspace: ${error}`)
72
+ throw error
73
+ } finally {
74
+ output.print(
75
+ JSON.stringify(
76
+ {workspace: workspace.name, schemaId: id, projectId, dataset: workspace.dataset},
77
+ null,
78
+ 2,
79
+ ),
80
+ )
73
81
  }
74
82
  }
75
-
83
+ // If workspace name is provided, we only need to save one schema
76
84
  if (workspaceName) {
77
- const schemaToSave = manifest.workspaces.find((workspace) => workspace.name === workspaceName)
78
- if (schemaToSave) {
79
- await saveSchema(schemaToSave)
80
- } else {
85
+ const workspaceToSave = manifest.workspaces.find(
86
+ (workspace) => workspace.name === workspaceName,
87
+ )
88
+ if (!workspaceToSave) {
81
89
  output.error(`Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`)
90
+ return new Error(
91
+ `Workspace ${workspaceName} not found in manifest: projectID: ${projectId}`,
92
+ )
82
93
  }
83
- } else {
84
- await Promise.all(
85
- manifest.workspaces.map(async (workspace): Promise<void> => {
86
- await saveSchema(workspace)
87
- }),
88
- )
94
+ await saveSchema(workspaceToSave)
95
+ return undefined
89
96
  }
97
+ await Promise.all(
98
+ manifest.workspaces.map(async (workspace): Promise<void> => {
99
+ await saveSchema(workspace)
100
+ }),
101
+ )
102
+ return undefined
90
103
  } catch (err) {
91
104
  output.error(err)
105
+ if (flags['schema-required']) {
106
+ throw err
107
+ }
108
+ return err
92
109
  }
93
110
  }
@@ -10,9 +10,9 @@ const helpText = `
10
10
  Options
11
11
  --source-maps Enable source maps for built bundles (increases size of bundle)
12
12
  --auto-updates / --no-auto-updates Enable/disable auto updates of studio versions
13
- --schema-path / path to schema folder if custom schema folder is used
14
13
  --no-minify Skip minifying built JavaScript (speeds up build, increases size of bundle)
15
14
  --no-build Don't build the studio prior to deploy, instead deploying the version currently in \`dist/\`
15
+ --schema-required Require schema extraction and storing to be successful
16
16
  -y, --yes Unattended mode, answers "yes" to any "yes/no" prompt and otherwise uses defaults
17
17
 
18
18
  Examples
@@ -10,7 +10,7 @@ const helpText = `
10
10
  Options:
11
11
  --workspace The name of the workspace to fetch the stored schema for
12
12
  --path If you are not using the default static file path, you can specify it here.
13
- --custom-id you can specify a custom id for the schema. Useful if you want to store the schema in a different path than the default one.
13
+ --id-prefix you can specify a custom id prefix for the stored schemas. Useful if you want to store the schema in a different path than the default one.
14
14
 
15
15
  Examples
16
16
  # if no options are provided all workspace schemas will be stored