sanity 3.72.2-server-side-schemas.17 → 3.72.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 +12 -11
- package/lib/_chunks-cjs/_internal.js.map +1 -1
- package/lib/_chunks-cjs/deployAction.js +8 -4
- package/lib/_chunks-cjs/deployAction.js.map +1 -1
- package/lib/_chunks-cjs/fetchSchemaAction.js +2 -2
- package/lib/_chunks-cjs/fetchSchemaAction.js.map +1 -1
- package/lib/_chunks-cjs/{storeManifestSchemasAction.js → storeSchemasAction.js} +10 -7
- package/lib/_chunks-cjs/storeSchemasAction.js.map +1 -0
- 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 +9 -4
- package/src/_internal/cli/actions/schema/fetchSchemaAction.ts +3 -4
- package/src/_internal/cli/actions/{manifest/storeManifestSchemasAction.ts → schema/storeSchemasAction.ts} +23 -12
- package/src/_internal/cli/commands/deploy/deployCommand.ts +1 -1
- package/src/_internal/cli/commands/schema/fetchSchemaCommand.ts +2 -3
- package/src/_internal/cli/commands/schema/storeSchemaCommand.ts +11 -9
- package/lib/_chunks-cjs/storeManifestSchemasAction.js.map +0 -1
- package/lib/_chunks-cjs/storeSchemaAction.js +0 -7
- package/lib/_chunks-cjs/storeSchemaAction.js.map +0 -1
- package/src/_internal/cli/actions/schema/storeSchemaAction.ts +0 -17
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
var path = require("node:path"), zlib = require("node:zlib"), tar = require("tar-fs"), buildAction = require("./buildAction.js"), extractManifestAction = require("./extractManifestAction.js"),
|
2
|
+
var path = require("node:path"), zlib = require("node:zlib"), tar = require("tar-fs"), buildAction = require("./buildAction.js"), extractManifestAction = require("./extractManifestAction.js"), storeSchemasAction = require("./storeSchemasAction.js"), helpers = require("./helpers.js");
|
3
3
|
function _interopDefaultCompat(e) {
|
4
4
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
5
5
|
}
|
@@ -74,14 +74,18 @@ async function deployStudioAction(args, context) {
|
|
74
74
|
...buildArgs,
|
75
75
|
extOptions: {},
|
76
76
|
extraArguments: []
|
77
|
-
}, context)
|
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
|
-
|
83
|
+
path: `${sourceDir}/static`,
|
84
|
+
"schema-required": flags["schema-required"]
|
81
85
|
},
|
82
86
|
extraArguments: []
|
83
87
|
};
|
84
|
-
|
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
|
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;AAChB,UAAA,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AQ,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;;"}
|
@@ -3,12 +3,12 @@ async function fetchSchemaAction(args, context) {
|
|
3
3
|
const {
|
4
4
|
apiClient,
|
5
5
|
output
|
6
|
-
} = context,
|
6
|
+
} = context, schemaId = args.extOptions.id, spinner = output.spinner({}).start("Fetching schema"), client = apiClient({
|
7
7
|
requireUser: !0,
|
8
8
|
requireProject: !0
|
9
9
|
}).withConfig({
|
10
10
|
apiVersion: "v2024-08-01"
|
11
|
-
}), projectId = client.config().projectId, schema = await client.withConfig({
|
11
|
+
}), projectId = client.config().projectId, dataset = client.config().dataset, schema = await client.withConfig({
|
12
12
|
dataset,
|
13
13
|
projectId
|
14
14
|
}).fetch(`*[_type == "sanity.workspace.schema" && _id == "${schemaId}"]`);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetchSchemaAction.js","sources":["../../src/_internal/cli/actions/schema/fetchSchemaAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\n\nimport {type ManifestSchemaType} from '../../../manifest/manifestTypes'\n\nexport interface FetchSchemaFlags {\n
|
1
|
+
{"version":3,"file":"fetchSchemaAction.js","sources":["../../src/_internal/cli/actions/schema/fetchSchemaAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\n\nimport {type ManifestSchemaType} from '../../../manifest/manifestTypes'\n\nexport interface FetchSchemaFlags {\n id: string\n}\n\nexport default async function fetchSchemaAction(\n args: CliCommandArguments<FetchSchemaFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const {apiClient, output} = context\n const flags = args.extOptions\n const schemaId = flags.id\n const spinner = output.spinner({}).start('Fetching schema')\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 const schema = await client\n .withConfig({\n dataset: dataset,\n projectId: projectId,\n })\n .fetch<ManifestSchemaType>(`*[_type == \"sanity.workspace.schema\" && _id == \"${schemaId}\"]`)\n\n spinner.succeed('Schema fetched')\n // print schema as json\n output.success(JSON.stringify(schema, null, 2))\n}\n"],"names":["fetchSchemaAction","args","context","apiClient","output","schemaId","extOptions","id","spinner","start","client","requireUser","requireProject","withConfig","apiVersion","projectId","config","dataset","schema","fetch","succeed","success","JSON","stringify"],"mappings":";AAQ8BA,eAAAA,kBAC5BC,MACAC,SACe;AACT,QAAA;AAAA,IAACC;AAAAA,IAAWC;AAAAA,EAAAA,IAAUF,SAEtBG,WADQJ,KAAKK,WACIC,IACjBC,UAAUJ,OAAOI,QAAQ,CAAA,CAAE,EAAEC,MAAM,iBAAiB,GACpDC,SAASP,UAAU;AAAA,IACvBQ,aAAa;AAAA,IACbC,gBAAgB;AAAA,EACjB,CAAA,EAAEC,WAAW;AAAA,IAACC,YAAY;AAAA,EAAc,CAAA,GAEnCC,YAAYL,OAAOM,OAASD,EAAAA,WAC5BE,UAAUP,OAAOM,OAASC,EAAAA,SAE1BC,SAAS,MAAMR,OAClBG,WAAW;AAAA,IACVI;AAAAA,IACAF;AAAAA,EACD,CAAA,EACAI,MAA0B,mDAAmDd,QAAQ,IAAI;AAEpFe,UAAAA,QAAQ,gBAAgB,GAEhChB,OAAOiB,QAAQC,KAAKC,UAAUL,QAAQ,MAAM,CAAC,CAAC;AAChD;;"}
|
@@ -5,19 +5,19 @@ 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,
|
8
|
+
const flags = args.extOptions, workspaceName = flags.workspace, customId = flags["custom-id"], {
|
9
9
|
output,
|
10
10
|
workDir,
|
11
11
|
apiClient
|
12
|
-
} = context;
|
12
|
+
} = context, defaultOutputDir = path.resolve(path.join(workDir, "dist")), outputDir = path.resolve(defaultOutputDir), defaultStaticPath = path.join(outputDir, "static"), staticPath = flags.path ?? defaultStaticPath;
|
13
13
|
try {
|
14
|
-
const manifestPath = path__default.default.resolve(process.cwd(),
|
14
|
+
const manifestPath = path__default.default.resolve(process.cwd(), staticPath), client = apiClient({
|
15
15
|
requireUser: !0,
|
16
16
|
requireProject: !0
|
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 = `sanity.workspace.schema.${workspace.name}`;
|
20
|
+
const spinner = output.spinner({}).start("Storing schemas"), id = customId || `sanity.workspace.schema.${workspace.name}`;
|
21
21
|
try {
|
22
22
|
if (workspace.projectId !== projectId && workspaceName !== workspace.name) {
|
23
23
|
spinner.fail(`Cannot store schema for ${workspace.name} because manifest projectId does not match: ${projectId} !== ${workspace.projectId}`);
|
@@ -44,9 +44,12 @@ async function storeManifestSchemas(args, context) {
|
|
44
44
|
await Promise.all(manifest.workspaces.map(async (workspace) => {
|
45
45
|
await saveSchema(workspace);
|
46
46
|
}));
|
47
|
+
return;
|
47
48
|
} catch (err) {
|
48
|
-
output.error(err)
|
49
|
+
if (output.error(err), flags["schema-required"])
|
50
|
+
throw err;
|
51
|
+
return err;
|
49
52
|
}
|
50
53
|
}
|
51
|
-
exports.
|
52
|
-
//# sourceMappingURL=
|
54
|
+
exports.default = storeManifestSchemas;
|
55
|
+
//# sourceMappingURL=storeSchemasAction.js.map
|
@@ -0,0 +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 '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 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 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","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":";;;;;;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,MACbC,gBAAgB;AAAA,IACjB,CAAA,EAAEC,WAAW;AAAA,MAACC,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YAAMwB,QAAQC,IACZvB,SAASoB,WAAWI,IAAI,OAAO9C,cAA6B;AAC1D,cAAM0B,WAAW1B,SAAS;AAAA,MAAA,CAC3B,CACH;AAEF;AAAA,WACO+C,KAAK;AAEZ,QADA7C,OAAOsC,MAAMO,GAAG,GACZlD,MAAM,iBAAiB;AACnBkD,YAAAA;AAEDA,WAAAA;AAAAA,EAAAA;AAEX;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "sanity",
|
3
|
-
"version": "3.72.2-server-side-schemas.
|
3
|
+
"version": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
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.
|
163
|
+
"@sanity/cli": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
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.
|
167
|
+
"@sanity/diff": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
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.
|
177
|
-
"@sanity/mutator": "3.72.2-server-side-schemas.
|
176
|
+
"@sanity/migrate": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
177
|
+
"@sanity/mutator": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
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.
|
180
|
+
"@sanity/schema": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
181
181
|
"@sanity/telemetry": "^0.7.7",
|
182
|
-
"@sanity/types": "3.72.2-server-side-schemas.
|
182
|
+
"@sanity/types": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
183
183
|
"@sanity/ui": "^2.11.7",
|
184
|
-
"@sanity/util": "3.72.2-server-side-schemas.
|
184
|
+
"@sanity/util": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
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.
|
283
|
+
"@sanity/codegen": "3.72.2-server-side-schemas.21+d5aa085f9d",
|
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": "
|
327
|
+
"gitHead": "d5aa085f9d6ac08ff8661d5936f9ca228236bc73"
|
328
328
|
}
|
@@ -8,7 +8,7 @@ import tar from 'tar-fs'
|
|
8
8
|
import {shouldAutoUpdate} from '../../util/shouldAutoUpdate'
|
9
9
|
import buildSanityStudio, {type BuildSanityStudioCommandFlags} from '../build/buildAction'
|
10
10
|
import {extractManifestSafe} from '../manifest/extractManifestAction'
|
11
|
-
import
|
11
|
+
import storeManifestSchemas from '../schema/storeSchemasAction'
|
12
12
|
import {
|
13
13
|
checkDir,
|
14
14
|
createDeployment,
|
@@ -21,8 +21,8 @@ import {
|
|
21
21
|
} from './helpers'
|
22
22
|
|
23
23
|
export interface DeployStudioActionFlags extends BuildSanityStudioCommandFlags {
|
24
|
-
'schema-path'?: string
|
25
24
|
'build'?: boolean
|
25
|
+
'schema-required'?: boolean
|
26
26
|
}
|
27
27
|
|
28
28
|
export default async function deployStudioAction(
|
@@ -123,16 +123,21 @@ export default async function deployStudioAction(
|
|
123
123
|
},
|
124
124
|
context,
|
125
125
|
)
|
126
|
+
if (flags['schema-required'] && extractManifestError) {
|
127
|
+
output.error(`Schema extraction error: ${extractManifestError.message}`)
|
128
|
+
throw extractManifestError
|
129
|
+
}
|
126
130
|
|
127
131
|
const storeManifestSchemasArgs = {
|
128
132
|
...args,
|
129
133
|
extOptions: {
|
130
|
-
'
|
134
|
+
'path': `${sourceDir}/static`,
|
135
|
+
'schema-required': flags['schema-required'],
|
131
136
|
},
|
132
137
|
extraArguments: [],
|
133
138
|
}
|
134
139
|
|
135
|
-
|
140
|
+
await storeManifestSchemas(storeManifestSchemasArgs, context)
|
136
141
|
}
|
137
142
|
|
138
143
|
// Ensure that the directory exists, is a directory and seems to have valid content
|
@@ -3,8 +3,7 @@ import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'
|
|
3
3
|
import {type ManifestSchemaType} from '../../../manifest/manifestTypes'
|
4
4
|
|
5
5
|
export interface FetchSchemaFlags {
|
6
|
-
|
7
|
-
'dataset': string
|
6
|
+
id: string
|
8
7
|
}
|
9
8
|
|
10
9
|
export default async function fetchSchemaAction(
|
@@ -13,8 +12,7 @@ export default async function fetchSchemaAction(
|
|
13
12
|
): Promise<void> {
|
14
13
|
const {apiClient, output} = context
|
15
14
|
const flags = args.extOptions
|
16
|
-
const schemaId = flags
|
17
|
-
const dataset = flags.dataset
|
15
|
+
const schemaId = flags.id
|
18
16
|
const spinner = output.spinner({}).start('Fetching schema')
|
19
17
|
const client = apiClient({
|
20
18
|
requireUser: true,
|
@@ -22,6 +20,7 @@ export default async function fetchSchemaAction(
|
|
22
20
|
}).withConfig({apiVersion: 'v2024-08-01'})
|
23
21
|
|
24
22
|
const projectId = client.config().projectId
|
23
|
+
const dataset = client.config().dataset
|
25
24
|
|
26
25
|
const schema = await client
|
27
26
|
.withConfig({
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import {readFileSync} from 'node:fs'
|
2
|
-
import path from 'node:path'
|
2
|
+
import path, {join, resolve} from 'node:path'
|
3
3
|
|
4
4
|
import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'
|
5
5
|
|
@@ -10,24 +10,30 @@ import {
|
|
10
10
|
} from '../../../manifest/manifestTypes'
|
11
11
|
|
12
12
|
export interface StoreManifestSchemasFlags {
|
13
|
-
'
|
14
|
-
'workspace
|
13
|
+
'path'?: string
|
14
|
+
'workspace'?: string
|
15
|
+
'custom-id'?: string
|
16
|
+
'schema-required'?: boolean
|
15
17
|
}
|
16
18
|
|
17
|
-
export async function storeManifestSchemas(
|
19
|
+
export default async function storeManifestSchemas(
|
18
20
|
args: CliCommandArguments<StoreManifestSchemasFlags>,
|
19
21
|
context: CliCommandContext,
|
20
|
-
): Promise<
|
22
|
+
): Promise<Error | undefined> {
|
21
23
|
const flags = args.extOptions
|
22
|
-
const
|
23
|
-
const
|
24
|
+
const workspaceName = flags.workspace
|
25
|
+
const customId = flags['custom-id']
|
24
26
|
const {output, workDir, apiClient} = context
|
25
27
|
|
28
|
+
const defaultOutputDir = resolve(join(workDir, 'dist'))
|
29
|
+
|
30
|
+
const outputDir = resolve(defaultOutputDir)
|
31
|
+
const defaultStaticPath = join(outputDir, 'static')
|
32
|
+
|
33
|
+
const staticPath = flags.path ?? defaultStaticPath
|
34
|
+
|
26
35
|
try {
|
27
|
-
const manifestPath = path.resolve(
|
28
|
-
process.cwd(),
|
29
|
-
schemaPath || path.join(workDir, 'dist/static'),
|
30
|
-
)
|
36
|
+
const manifestPath = path.resolve(process.cwd(), staticPath)
|
31
37
|
const client = apiClient({
|
32
38
|
requireUser: true,
|
33
39
|
requireProject: true,
|
@@ -41,7 +47,7 @@ export async function storeManifestSchemas(
|
|
41
47
|
|
42
48
|
const saveSchema = async (workspace: ManifestWorkspaceFile) => {
|
43
49
|
const spinner = output.spinner({}).start('Storing schemas')
|
44
|
-
const id = `sanity.workspace.schema.${workspace.name}`
|
50
|
+
const id = customId || `sanity.workspace.schema.${workspace.name}`
|
45
51
|
try {
|
46
52
|
if (workspace.projectId !== projectId && workspaceName !== workspace.name) {
|
47
53
|
spinner.fail(
|
@@ -82,7 +88,12 @@ export async function storeManifestSchemas(
|
|
82
88
|
}),
|
83
89
|
)
|
84
90
|
}
|
91
|
+
return undefined
|
85
92
|
} catch (err) {
|
86
93
|
output.error(err)
|
94
|
+
if (flags['schema-required']) {
|
95
|
+
throw err
|
96
|
+
}
|
97
|
+
return err
|
87
98
|
}
|
88
99
|
}
|
@@ -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
|
@@ -8,12 +8,11 @@ const helpText = `
|
|
8
8
|
**Note**: This command is experimental and subject to change.
|
9
9
|
|
10
10
|
Options
|
11
|
-
--
|
12
|
-
--dataset The dataset to fetch the schema from
|
11
|
+
--id id of the schema to fetch
|
13
12
|
|
14
13
|
Examples
|
15
14
|
# Fetch the stored schema for the workspace 'default' in the dataset 'sanity-test'
|
16
|
-
sanity schema fetch --
|
15
|
+
sanity schema fetch --id sanity.workspace.schema.default
|
17
16
|
`
|
18
17
|
|
19
18
|
const fetchSchemaCommand = {
|
@@ -1,20 +1,22 @@
|
|
1
1
|
import {type CliCommandArguments, type CliCommandDefinition} from '@sanity/cli'
|
2
2
|
|
3
|
-
import {type
|
3
|
+
import {type StoreManifestSchemasFlags} from '../../actions/schema/storeSchemasAction'
|
4
4
|
|
5
5
|
const description = ''
|
6
6
|
|
7
7
|
const helpText = `
|
8
8
|
**Note**: This command is experimental and subject to change.
|
9
9
|
|
10
|
-
|
11
|
-
--workspace
|
12
|
-
|
13
|
-
--
|
10
|
+
Options:
|
11
|
+
--workspace The name of the workspace to fetch the stored schema for
|
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.
|
14
14
|
|
15
15
|
Examples
|
16
|
-
#
|
17
|
-
sanity schema store
|
16
|
+
# if no options are provided all workspace schemas will be stored
|
17
|
+
sanity schema store
|
18
|
+
# Store the schema for only the workspace 'default'
|
19
|
+
sanity schema store --workspace default
|
18
20
|
`
|
19
21
|
|
20
22
|
const storeSchemaCommand = {
|
@@ -24,9 +26,9 @@ const storeSchemaCommand = {
|
|
24
26
|
description,
|
25
27
|
helpText,
|
26
28
|
action: async (args, context) => {
|
27
|
-
const mod = await import('../../actions/schema/
|
29
|
+
const mod = await import('../../actions/schema/storeSchemasAction')
|
28
30
|
|
29
|
-
return mod.default(args as unknown as CliCommandArguments<
|
31
|
+
return mod.default(args as unknown as CliCommandArguments<StoreManifestSchemasFlags>, context)
|
30
32
|
},
|
31
33
|
} satisfies CliCommandDefinition
|
32
34
|
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"storeManifestSchemasAction.js","sources":["../../src/_internal/cli/actions/manifest/storeManifestSchemasAction.ts"],"sourcesContent":["import {readFileSync} from 'node:fs'\nimport path 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 'schema-path'?: string\n 'workspace-name'?: string\n}\n\nexport async function storeManifestSchemas(\n args: CliCommandArguments<StoreManifestSchemasFlags>,\n context: CliCommandContext,\n): Promise<void> {\n const flags = args.extOptions\n const schemaPath = flags['schema-path']\n const workspaceName = flags['workspace-name']\n const {output, workDir, apiClient} = context\n\n try {\n const manifestPath = path.resolve(\n process.cwd(),\n schemaPath || path.join(workDir, 'dist/static'),\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\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 = `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","schemaPath","workspaceName","output","workDir","apiClient","manifestPath","path","resolve","process","cwd","join","client","requireUser","requireProject","withConfig","apiVersion","projectId","config","manifest","JSON","parse","readFileSync","saveSchema","workspace","spinner","start","id","name","fail","schema","dataset","transaction","createOrReplace","_type","_id","commit","succeed","error","schemaToSave","workspaces","find","Promise","all","map","err"],"mappings":";;;;;;AAgBsBA,eAAAA,qBACpBC,MACAC,SACe;AACTC,QAAAA,QAAQF,KAAKG,YACbC,aAAaF,MAAM,aAAa,GAChCG,gBAAgBH,MAAM,gBAAgB,GACtC;AAAA,IAACI;AAAAA,IAAQC;AAAAA,IAASC;AAAAA,EAAAA,IAAaP;AAEjC,MAAA;AACF,UAAMQ,eAAeC,cAAAA,QAAKC,QACxBC,QAAQC,OACRT,cAAcM,cAAAA,QAAKI,KAAKP,SAAS,aAAa,CAChD,GACMQ,SAASP,UAAU;AAAA,MACvBQ,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,GAAGhB,YAAY,yBAAyB,OAAO,CAC9D,GAEMiB,aAAa,OAAOC,cAAqC;AAC7D,YAAMC,UAAUtB,OAAOsB,QAAQ,CAAA,CAAE,EAAEC,MAAM,iBAAiB,GACpDC,KAAK,2BAA2BH,UAAUI,IAAI;AAChD,UAAA;AACF,YAAIJ,UAAUP,cAAcA,aAAaf,kBAAkBsB,UAAUI,MAAM;AACjEC,kBAAAA,KACN,2BAA2BL,UAAUI,IAAI,+CAA+CX,SAAS,QAAQO,UAAUP,SAAS,EAC9H;AACA;AAAA,QAAA;AAEIa,cAAAA,SAASV,KAAKC,MAClBC,GAAa,aAAA,GAAGhB,YAAY,IAAIkB,UAAUM,MAAM,IAAI,OAAO,CAC7D;AACA,cAAMlB,OACHG,WAAW;AAAA,UACVgB,SAASP,UAAUO;AAAAA,UACnBd,WAAWO,UAAUP;AAAAA,QAAAA,CACtB,EACAe,YAAY,EACZC,gBAAgB;AAAA,UAACC,OAAO;AAAA,UAA2BC,KAAKR;AAAAA,UAAIH;AAAAA,UAAWM;AAAAA,QAAAA,CAAO,EAC9EM,OAAAA,GACHX,QAAQY,QACN,+BAA+Bb,UAAUI,IAAI,eAAeD,EAAE,gBAAgBV,SAAS,cAAcO,UAAUO,OAAO,GACxH;AAAA,eACOO,OAAO;AACdb,gBAAQI,KAAK,sCAAsCL,UAAUI,IAAI,KAAKU,KAAK,EAAE;AAAA,MAAA;AAAA,IAEjF;AAEA,QAAIpC,eAAe;AACjB,YAAMqC,eAAepB,SAASqB,WAAWC,KAAMjB,CAAcA,cAAAA,UAAUI,SAAS1B,aAAa;AACzFqC,qBACF,MAAMhB,WAAWgB,YAAY,IAE7BpC,OAAOmC,MAAM,aAAapC,aAAa,sCAAsCe,SAAS,EAAE;AAAA,IAE5F;AACE,YAAMyB,QAAQC,IACZxB,SAASqB,WAAWI,IAAI,OAAOpB,cAA6B;AAC1D,cAAMD,WAAWC,SAAS;AAAA,MAAA,CAC3B,CACH;AAAA,WAEKqB,KAAK;AACZ1C,WAAOmC,MAAMO,GAAG;AAAA,EAAA;AAEpB;;"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var storeManifestSchemasAction = require("./storeManifestSchemasAction.js");
|
3
|
-
async function storeSchemaAction(args, context) {
|
4
|
-
storeManifestSchemasAction.storeManifestSchemas(args, context);
|
5
|
-
}
|
6
|
-
exports.default = storeSchemaAction;
|
7
|
-
//# sourceMappingURL=storeSchemaAction.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"storeSchemaAction.js","sources":["../../src/_internal/cli/actions/schema/storeSchemaAction.ts"],"sourcesContent":["import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'\n\nimport {\n storeManifestSchemas,\n type StoreManifestSchemasFlags,\n} from '../manifest/storeManifestSchemasAction'\n\nexport interface StoreSchemaFlags extends StoreManifestSchemasFlags {\n 'workspace-name': string\n}\n\nexport default async function storeSchemaAction(\n args: CliCommandArguments<StoreSchemaFlags>,\n context: CliCommandContext,\n): Promise<void> {\n storeManifestSchemas(args, context)\n}\n"],"names":["storeSchemaAction","args","context","storeManifestSchemas"],"mappings":";;AAW8BA,eAAAA,kBAC5BC,MACAC,SACe;AACfC,6BAAAA,qBAAqBF,MAAMC,OAAO;AACpC;;"}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import {type CliCommandArguments, type CliCommandContext} from '@sanity/cli'
|
2
|
-
|
3
|
-
import {
|
4
|
-
storeManifestSchemas,
|
5
|
-
type StoreManifestSchemasFlags,
|
6
|
-
} from '../manifest/storeManifestSchemasAction'
|
7
|
-
|
8
|
-
export interface StoreSchemaFlags extends StoreManifestSchemasFlags {
|
9
|
-
'workspace-name': string
|
10
|
-
}
|
11
|
-
|
12
|
-
export default async function storeSchemaAction(
|
13
|
-
args: CliCommandArguments<StoreSchemaFlags>,
|
14
|
-
context: CliCommandContext,
|
15
|
-
): Promise<void> {
|
16
|
-
storeManifestSchemas(args, context)
|
17
|
-
}
|