@sanity/cli 6.6.0 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +12 -4
  2. package/dist/actions/auth/login/login.js +4 -1
  3. package/dist/actions/auth/login/login.js.map +1 -1
  4. package/dist/actions/build/buildApp.js +4 -5
  5. package/dist/actions/build/buildApp.js.map +1 -1
  6. package/dist/actions/build/buildStaticFiles.js +12 -4
  7. package/dist/actions/build/buildStaticFiles.js.map +1 -1
  8. package/dist/actions/build/buildStudio.js +6 -14
  9. package/dist/actions/build/buildStudio.js.map +1 -1
  10. package/dist/actions/build/{getStudioEnvironmentVariables.js → getEnvironmentVariables.js} +15 -19
  11. package/dist/actions/build/getEnvironmentVariables.js.map +1 -0
  12. package/dist/actions/deploy/deployStudio.js +1 -2
  13. package/dist/actions/deploy/deployStudio.js.map +1 -1
  14. package/dist/actions/deploy/deployStudioSchemasAndManifests.js +1 -2
  15. package/dist/actions/deploy/deployStudioSchemasAndManifests.js.map +1 -1
  16. package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js +1 -1
  17. package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js.map +1 -1
  18. package/dist/actions/dev/startStudioDevServer.js +1 -1
  19. package/dist/actions/dev/startStudioDevServer.js.map +1 -1
  20. package/dist/actions/documents/validateDocuments.worker.js +1 -2
  21. package/dist/actions/documents/validateDocuments.worker.js.map +1 -1
  22. package/dist/actions/graphql/SchemaError.js +1 -1
  23. package/dist/actions/graphql/SchemaError.js.map +1 -1
  24. package/dist/actions/init/initAction.js +32 -1
  25. package/dist/actions/init/initAction.js.map +1 -1
  26. package/dist/actions/init/scaffoldTemplate.js +32 -18
  27. package/dist/actions/init/scaffoldTemplate.js.map +1 -1
  28. package/dist/actions/init/templates/index.js +2 -0
  29. package/dist/actions/init/templates/index.js.map +1 -1
  30. package/dist/actions/init/templates/pageBuilder.js +32 -0
  31. package/dist/actions/init/templates/pageBuilder.js.map +1 -0
  32. package/dist/actions/init/types.js +2 -1
  33. package/dist/actions/init/types.js.map +1 -1
  34. package/dist/actions/manifest/extractManifest.js +1 -1
  35. package/dist/actions/manifest/extractManifest.js.map +1 -1
  36. package/dist/actions/manifest/extractManifest.worker.js +1 -1
  37. package/dist/actions/manifest/extractManifest.worker.js.map +1 -1
  38. package/dist/actions/mcp/editorConfigs.js +51 -11
  39. package/dist/actions/mcp/editorConfigs.js.map +1 -1
  40. package/dist/actions/mcp/promptForMCPSetup.js +16 -11
  41. package/dist/actions/mcp/promptForMCPSetup.js.map +1 -1
  42. package/dist/actions/mcp/setupMCP.js +180 -61
  43. package/dist/actions/mcp/setupMCP.js.map +1 -1
  44. package/dist/actions/mcp/types.js.map +1 -1
  45. package/dist/actions/schema/deploySchemas.js +1 -1
  46. package/dist/actions/schema/deploySchemas.js.map +1 -1
  47. package/dist/actions/schema/extractSanityWorkspace.worker.js +1 -1
  48. package/dist/actions/schema/extractSanityWorkspace.worker.js.map +1 -1
  49. package/dist/actions/schema/extractSchema.js +1 -4
  50. package/dist/actions/schema/extractSchema.js.map +1 -1
  51. package/dist/actions/schema/extractSchemaWatcher.js +1 -4
  52. package/dist/actions/schema/extractSchemaWatcher.js.map +1 -1
  53. package/dist/actions/schema/getExtractOptions.js +8 -18
  54. package/dist/actions/schema/getExtractOptions.js.map +1 -1
  55. package/dist/actions/schema/types.js +0 -6
  56. package/dist/actions/schema/types.js.map +1 -1
  57. package/dist/actions/schema/validateAction.js +1 -1
  58. package/dist/actions/schema/validateAction.js.map +1 -1
  59. package/dist/actions/schema/validateSchema.worker.js +1 -2
  60. package/dist/actions/schema/validateSchema.worker.js.map +1 -1
  61. package/dist/actions/schema/watchExtractSchema.js +1 -1
  62. package/dist/actions/schema/watchExtractSchema.js.map +1 -1
  63. package/dist/actions/skills/readSkillState.js +54 -0
  64. package/dist/actions/skills/readSkillState.js.map +1 -0
  65. package/dist/actions/skills/setupSkills.js +73 -0
  66. package/dist/actions/skills/setupSkills.js.map +1 -0
  67. package/dist/commands/build.js +9 -22
  68. package/dist/commands/build.js.map +1 -1
  69. package/dist/commands/cors/add.js +5 -5
  70. package/dist/commands/cors/add.js.map +1 -1
  71. package/dist/commands/datasets/export.js +9 -0
  72. package/dist/commands/datasets/export.js.map +1 -1
  73. package/dist/commands/docs/read.js +33 -12
  74. package/dist/commands/docs/read.js.map +1 -1
  75. package/dist/commands/init.js +12 -1
  76. package/dist/commands/init.js.map +1 -1
  77. package/dist/commands/manifest/extract.js +1 -2
  78. package/dist/commands/manifest/extract.js.map +1 -1
  79. package/dist/commands/mcp/configure.js +2 -1
  80. package/dist/commands/mcp/configure.js.map +1 -1
  81. package/dist/commands/schemas/deploy.js +1 -2
  82. package/dist/commands/schemas/deploy.js.map +1 -1
  83. package/dist/exports/_internal.d.ts +2 -1
  84. package/dist/exports/_internal.js +1 -1
  85. package/dist/exports/_internal.js.map +1 -1
  86. package/dist/server/devServer.js +25 -4
  87. package/dist/server/devServer.js.map +1 -1
  88. package/dist/server/previewServer.js +1 -1
  89. package/dist/server/previewServer.js.map +1 -1
  90. package/dist/services/mcp.js +1 -1
  91. package/dist/services/mcp.js.map +1 -1
  92. package/dist/telemetry/init.telemetry.js.map +1 -1
  93. package/oclif.manifest.json +134 -118
  94. package/package.json +15 -16
  95. package/templates/page-builder/README.md +9 -0
  96. package/templates/page-builder/schemaTypes/hero.js +31 -0
  97. package/templates/page-builder/schemaTypes/index.js +19 -0
  98. package/templates/page-builder/static/.gitkeep +0 -0
  99. package/dist/actions/build/buildDebug.js +0 -4
  100. package/dist/actions/build/buildDebug.js.map +0 -1
  101. package/dist/actions/build/buildVendorDependencies.js +0 -149
  102. package/dist/actions/build/buildVendorDependencies.js.map +0 -1
  103. package/dist/actions/build/checkStudioDependencyVersions.js +0 -155
  104. package/dist/actions/build/checkStudioDependencyVersions.js.map +0 -1
  105. package/dist/actions/build/createExternalFromImportMap.js +0 -11
  106. package/dist/actions/build/createExternalFromImportMap.js.map +0 -1
  107. package/dist/actions/build/decorateIndexWithAutoGeneratedWarning.js +0 -13
  108. package/dist/actions/build/decorateIndexWithAutoGeneratedWarning.js.map +0 -1
  109. package/dist/actions/build/decorateIndexWithBridgeScript.js +0 -17
  110. package/dist/actions/build/decorateIndexWithBridgeScript.js.map +0 -1
  111. package/dist/actions/build/decorateIndexWithStagingScript.js +0 -16
  112. package/dist/actions/build/decorateIndexWithStagingScript.js.map +0 -1
  113. package/dist/actions/build/getAppEnvVars.js +0 -9
  114. package/dist/actions/build/getAppEnvVars.js.map +0 -1
  115. package/dist/actions/build/getEntryModule.js +0 -46
  116. package/dist/actions/build/getEntryModule.js.map +0 -1
  117. package/dist/actions/build/getPossibleDocumentComponentLocations.js +0 -11
  118. package/dist/actions/build/getPossibleDocumentComponentLocations.js.map +0 -1
  119. package/dist/actions/build/getStudioEnvVars.js +0 -9
  120. package/dist/actions/build/getStudioEnvVars.js.map +0 -1
  121. package/dist/actions/build/getStudioEnvironmentVariables.js.map +0 -1
  122. package/dist/actions/build/getViteConfig.js +0 -219
  123. package/dist/actions/build/getViteConfig.js.map +0 -1
  124. package/dist/actions/build/normalizeBasePath.js +0 -9
  125. package/dist/actions/build/normalizeBasePath.js.map +0 -1
  126. package/dist/actions/build/renderDocument.js +0 -50
  127. package/dist/actions/build/renderDocument.js.map +0 -1
  128. package/dist/actions/build/renderDocument.worker.js +0 -9
  129. package/dist/actions/build/renderDocument.worker.js.map +0 -1
  130. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js +0 -79
  131. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js.map +0 -1
  132. package/dist/actions/build/renderDocumentWorker/components/BasicDocument.js +0 -61
  133. package/dist/actions/build/renderDocumentWorker/components/BasicDocument.js.map +0 -1
  134. package/dist/actions/build/renderDocumentWorker/components/DefaultDocument.js +0 -165
  135. package/dist/actions/build/renderDocumentWorker/components/DefaultDocument.js.map +0 -1
  136. package/dist/actions/build/renderDocumentWorker/components/Favicons.js +0 -28
  137. package/dist/actions/build/renderDocumentWorker/components/Favicons.js.map +0 -1
  138. package/dist/actions/build/renderDocumentWorker/components/GlobalErrorHandler.js +0 -178
  139. package/dist/actions/build/renderDocumentWorker/components/GlobalErrorHandler.js.map +0 -1
  140. package/dist/actions/build/renderDocumentWorker/components/NoJavascript.js +0 -51
  141. package/dist/actions/build/renderDocumentWorker/components/NoJavascript.js.map +0 -1
  142. package/dist/actions/build/renderDocumentWorker/getDocumentComponent.js +0 -41
  143. package/dist/actions/build/renderDocumentWorker/getDocumentComponent.js.map +0 -1
  144. package/dist/actions/build/renderDocumentWorker/getDocumentHtml.js +0 -55
  145. package/dist/actions/build/renderDocumentWorker/getDocumentHtml.js.map +0 -1
  146. package/dist/actions/build/renderDocumentWorker/renderDocumentWorker.js +0 -31
  147. package/dist/actions/build/renderDocumentWorker/renderDocumentWorker.js.map +0 -1
  148. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js +0 -30
  149. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js.map +0 -1
  150. package/dist/actions/build/renderDocumentWorker/types.js +0 -5
  151. package/dist/actions/build/renderDocumentWorker/types.js.map +0 -1
  152. package/dist/actions/build/writeSanityRuntime.js +0 -64
  153. package/dist/actions/build/writeSanityRuntime.js.map +0 -1
  154. package/dist/actions/docs/normalizeDocsPath.js +0 -15
  155. package/dist/actions/docs/normalizeDocsPath.js.map +0 -1
  156. package/dist/actions/schema/extractSanitySchema.worker.js +0 -33
  157. package/dist/actions/schema/extractSanitySchema.worker.js.map +0 -1
  158. package/dist/actions/schema/formatSchemaValidation.js +0 -78
  159. package/dist/actions/schema/formatSchemaValidation.js.map +0 -1
  160. package/dist/actions/schema/matchSchemaPattern.js +0 -22
  161. package/dist/actions/schema/matchSchemaPattern.js.map +0 -1
  162. package/dist/actions/schema/runSchemaExtraction.js +0 -39
  163. package/dist/actions/schema/runSchemaExtraction.js.map +0 -1
  164. package/dist/actions/schema/utils/SchemaExtractionError.js +0 -10
  165. package/dist/actions/schema/utils/SchemaExtractionError.js.map +0 -1
  166. package/dist/actions/schema/utils/extractValidationFromSchemaError.js +0 -12
  167. package/dist/actions/schema/utils/extractValidationFromSchemaError.js.map +0 -1
  168. package/dist/constants.js +0 -8
  169. package/dist/constants.js.map +0 -1
  170. package/dist/server/vite/plugin-sanity-build-entries.js +0 -67
  171. package/dist/server/vite/plugin-sanity-build-entries.js.map +0 -1
  172. package/dist/server/vite/plugin-sanity-favicons.js +0 -72
  173. package/dist/server/vite/plugin-sanity-favicons.js.map +0 -1
  174. package/dist/server/vite/plugin-sanity-runtime-rewrite.js +0 -18
  175. package/dist/server/vite/plugin-sanity-runtime-rewrite.js.map +0 -1
  176. package/dist/server/vite/plugin-schema-extraction.js +0 -201
  177. package/dist/server/vite/plugin-schema-extraction.js.map +0 -1
  178. package/dist/telemetry/build.telemetry.js +0 -13
  179. package/dist/telemetry/build.telemetry.js.map +0 -1
  180. package/dist/telemetry/extractSchema.telemetry.js +0 -18
  181. package/dist/telemetry/extractSchema.telemetry.js.map +0 -1
  182. package/dist/util/getWorkspace.js +0 -18
  183. package/dist/util/getWorkspace.js.map +0 -1
@@ -1,51 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- const NoJsStyles = `
3
- .sanity-app-no-js__root {
4
- position: absolute;
5
- top: 0;
6
- right: 0;
7
- left: 0;
8
- bottom: 0;
9
- background: #fff;
10
- }
11
-
12
- .sanity-app-no-js__content {
13
- position: absolute;
14
- top: 50%;
15
- left: 50%;
16
- transform: translate(-50%, -50%);
17
- text-align: center;
18
- font-family: helvetica, arial, sans-serif;
19
- }
20
- `;
21
- /** @internal */ export function NoJavascript() {
22
- return /*#__PURE__*/ _jsx("noscript", {
23
- children: /*#__PURE__*/ _jsx("div", {
24
- className: "sanity-app-no-js__root",
25
- children: /*#__PURE__*/ _jsxs("div", {
26
- className: "sanity-app-no-js__content",
27
- children: [
28
- /*#__PURE__*/ _jsx("style", {
29
- type: "text/css",
30
- children: NoJsStyles
31
- }),
32
- /*#__PURE__*/ _jsx("h1", {
33
- children: "JavaScript disabled"
34
- }),
35
- /*#__PURE__*/ _jsxs("p", {
36
- children: [
37
- "Please ",
38
- /*#__PURE__*/ _jsx("a", {
39
- href: "https://www.enable-javascript.com/",
40
- children: "enable JavaScript"
41
- }),
42
- " in your browser and reload the page to proceed."
43
- ]
44
- })
45
- ]
46
- })
47
- })
48
- });
49
- }
50
-
51
- //# sourceMappingURL=NoJavascript.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../src/actions/build/renderDocumentWorker/components/NoJavascript.tsx"],"sourcesContent":["import {type JSX} from 'react'\n\nconst NoJsStyles = `\n.sanity-app-no-js__root {\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n bottom: 0;\n background: #fff;\n}\n\n.sanity-app-no-js__content {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n text-align: center;\n font-family: helvetica, arial, sans-serif;\n}\n`\n\n/** @internal */\nexport function NoJavascript(): JSX.Element {\n return (\n <noscript>\n <div className=\"sanity-app-no-js__root\">\n <div className=\"sanity-app-no-js__content\">\n <style type=\"text/css\">{NoJsStyles}</style>\n <h1>JavaScript disabled</h1>\n <p>\n Please <a href=\"https://www.enable-javascript.com/\">enable JavaScript</a> in your\n browser and reload the page to proceed.\n </p>\n </div>\n </div>\n </noscript>\n )\n}\n"],"names":["NoJsStyles","NoJavascript","noscript","div","className","style","type","h1","p","a","href"],"mappings":";AAEA,MAAMA,aAAa,CAAC;;;;;;;;;;;;;;;;;;AAkBpB,CAAC;AAED,cAAc,GACd,OAAO,SAASC;IACd,qBACE,KAACC;kBACC,cAAA,KAACC;YAAIC,WAAU;sBACb,cAAA,MAACD;gBAAIC,WAAU;;kCACb,KAACC;wBAAMC,MAAK;kCAAYN;;kCACxB,KAACO;kCAAG;;kCACJ,MAACC;;4BAAE;0CACM,KAACC;gCAAEC,MAAK;0CAAqC;;4BAAqB;;;;;;;AAOrF"}
@@ -1,41 +0,0 @@
1
- import path from 'node:path';
2
- import { buildDebug } from '../buildDebug.js';
3
- import { BasicDocument } from './components/BasicDocument.js';
4
- import { DefaultDocument } from './components/DefaultDocument.js';
5
- import { tryLoadDocumentComponent } from './tryLoadDocumentComponent.js';
6
- /**
7
- * @internal
8
- */ export async function getDocumentComponent(parent, studioRootPath, isApp) {
9
- buildDebug('Loading default document component from `sanity` module');
10
- const Document = isApp ? BasicDocument : DefaultDocument;
11
- buildDebug('Attempting to load user-defined document component from %s', studioRootPath);
12
- const userDefined = await tryLoadDocumentComponent(studioRootPath);
13
- if (!userDefined) {
14
- buildDebug('Using default document component');
15
- return Document;
16
- }
17
- buildDebug('Found user defined document component at %s', userDefined.path);
18
- const DocumentComp = userDefined.component.default || userDefined.component // CommonJS
19
- ;
20
- if (typeof DocumentComp === 'function') {
21
- buildDebug('User defined document component is a function, assuming valid');
22
- return DocumentComp;
23
- }
24
- buildDebug('User defined document component did not have a default export');
25
- const userExports = Object.keys(userDefined.component).join(', ') || 'None';
26
- const relativePath = path.relative(process.cwd(), userDefined.path);
27
- const typeHint = userDefined.component.default === undefined ? '' : ` (type was ${typeof userDefined.component.default})`;
28
- const warnKey = `${relativePath}/${userDefined.modified}`;
29
- parent.postMessage({
30
- message: [
31
- `${relativePath} did not have a default export that is a React component${typeHint}`,
32
- `Named exports/properties found: ${userExports}`.trim(),
33
- `Using default document component from "sanity".`
34
- ],
35
- type: 'warning',
36
- warnKey
37
- });
38
- return DefaultDocument;
39
- }
40
-
41
- //# sourceMappingURL=getDocumentComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/build/renderDocumentWorker/getDocumentComponent.ts"],"sourcesContent":["import path from 'node:path'\nimport {type MessagePort} from 'node:worker_threads'\n\nimport {buildDebug} from '../buildDebug.js'\nimport {BasicDocument} from './components/BasicDocument.js'\nimport {DefaultDocument} from './components/DefaultDocument.js'\nimport {tryLoadDocumentComponent} from './tryLoadDocumentComponent.js'\n\n/**\n * @internal\n */\nexport async function getDocumentComponent(\n parent: MessagePort,\n studioRootPath: string,\n isApp?: boolean,\n) {\n buildDebug('Loading default document component from `sanity` module')\n\n const Document = isApp ? BasicDocument : DefaultDocument\n\n buildDebug('Attempting to load user-defined document component from %s', studioRootPath)\n const userDefined = await tryLoadDocumentComponent(studioRootPath)\n\n if (!userDefined) {\n buildDebug('Using default document component')\n return Document\n }\n\n buildDebug('Found user defined document component at %s', userDefined.path)\n\n const DocumentComp = userDefined.component.default || userDefined.component // CommonJS\n if (typeof DocumentComp === 'function') {\n buildDebug('User defined document component is a function, assuming valid')\n return DocumentComp\n }\n\n buildDebug('User defined document component did not have a default export')\n const userExports = Object.keys(userDefined.component).join(', ') || 'None'\n const relativePath = path.relative(process.cwd(), userDefined.path)\n const typeHint =\n userDefined.component.default === undefined\n ? ''\n : ` (type was ${typeof userDefined.component.default})`\n\n const warnKey = `${relativePath}/${userDefined.modified}`\n\n parent.postMessage({\n message: [\n `${relativePath} did not have a default export that is a React component${typeHint}`,\n `Named exports/properties found: ${userExports}`.trim(),\n `Using default document component from \"sanity\".`,\n ],\n type: 'warning',\n warnKey,\n })\n\n return DefaultDocument\n}\n"],"names":["path","buildDebug","BasicDocument","DefaultDocument","tryLoadDocumentComponent","getDocumentComponent","parent","studioRootPath","isApp","Document","userDefined","DocumentComp","component","default","userExports","Object","keys","join","relativePath","relative","process","cwd","typeHint","undefined","warnKey","modified","postMessage","message","trim","type"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAG5B,SAAQC,UAAU,QAAO,mBAAkB;AAC3C,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,eAAe,QAAO,kCAAiC;AAC/D,SAAQC,wBAAwB,QAAO,gCAA+B;AAEtE;;CAEC,GACD,OAAO,eAAeC,qBACpBC,MAAmB,EACnBC,cAAsB,EACtBC,KAAe;IAEfP,WAAW;IAEX,MAAMQ,WAAWD,QAAQN,gBAAgBC;IAEzCF,WAAW,8DAA8DM;IACzE,MAAMG,cAAc,MAAMN,yBAAyBG;IAEnD,IAAI,CAACG,aAAa;QAChBT,WAAW;QACX,OAAOQ;IACT;IAEAR,WAAW,+CAA+CS,YAAYV,IAAI;IAE1E,MAAMW,eAAeD,YAAYE,SAAS,CAACC,OAAO,IAAIH,YAAYE,SAAS,CAAC,WAAW;;IACvF,IAAI,OAAOD,iBAAiB,YAAY;QACtCV,WAAW;QACX,OAAOU;IACT;IAEAV,WAAW;IACX,MAAMa,cAAcC,OAAOC,IAAI,CAACN,YAAYE,SAAS,EAAEK,IAAI,CAAC,SAAS;IACrE,MAAMC,eAAelB,KAAKmB,QAAQ,CAACC,QAAQC,GAAG,IAAIX,YAAYV,IAAI;IAClE,MAAMsB,WACJZ,YAAYE,SAAS,CAACC,OAAO,KAAKU,YAC9B,KACA,CAAC,WAAW,EAAE,OAAOb,YAAYE,SAAS,CAACC,OAAO,CAAC,CAAC,CAAC;IAE3D,MAAMW,UAAU,GAAGN,aAAa,CAAC,EAAER,YAAYe,QAAQ,EAAE;IAEzDnB,OAAOoB,WAAW,CAAC;QACjBC,SAAS;YACP,GAAGT,aAAa,wDAAwD,EAAEI,UAAU;YACpF,CAAC,gCAAgC,EAAER,aAAa,CAACc,IAAI;YACrD,CAAC,+CAA+C,CAAC;SAClD;QACDC,MAAM;QACNL;IACF;IAEA,OAAOrB;AACT"}
@@ -1,55 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { renderToStaticMarkup } from 'react-dom/server';
3
- import { buildDebug } from '../buildDebug.js';
4
- import { addTimestampedImportMapScriptToHtml } from './addTimestampImportMapScriptToHtml.js';
5
- import { getDocumentComponent } from './getDocumentComponent.js';
6
- /**
7
- * Adds a base path to a URL if necessary, and returns the resulting URL.
8
- * @param url - The URL to prefix with a base path.
9
- * @param basePath - The base path to prefix the URL with. Default value is `/`.
10
- * @returns The resulting URL with the base path.
11
- * @internal
12
- */ function _prefixUrlWithBasePath(url, basePath) {
13
- // Normalize basePath by adding a leading slash if it's missing.
14
- const normalizedBasePath = basePath.startsWith('/') ? basePath : `/${basePath}`;
15
- // If the URL starts with a slash, append it to the basePath, removing any trailing slash if present.
16
- if (url.startsWith('/')) {
17
- if (normalizedBasePath.endsWith('/')) {
18
- return `${normalizedBasePath.slice(0, -1)}${url}`;
19
- }
20
- return `${normalizedBasePath}${url}`;
21
- }
22
- // If the URL doesn't start with a slash, append it to the basePath with a slash in between.
23
- if (normalizedBasePath.endsWith('/')) {
24
- return `${normalizedBasePath}${url}`;
25
- }
26
- return `${normalizedBasePath}/${url}`;
27
- }
28
- /**
29
- * @internal
30
- */ export async function getDocumentHtml(parent, studioRootPath, props, importMap, isApp, autoUpdatesCssUrls) {
31
- const Document = await getDocumentComponent(parent, studioRootPath, isApp);
32
- const defaultProps = {
33
- entryPath: './.sanity/runtime/app.js'
34
- };
35
- // NOTE: Validate the list of CSS paths so implementers of `_document.tsx` don't have to
36
- // - If the path is not a full URL, check if it starts with `/`
37
- // - If not, then prepend a `/` to the string
38
- const css = props?.css?.map((url)=>{
39
- try {
40
- // If the URL is absolute, we don't need to prefix it
41
- return new URL(url).toString();
42
- } catch {
43
- return _prefixUrlWithBasePath(url, props.basePath);
44
- }
45
- });
46
- buildDebug('Rendering document component using React');
47
- const result = addTimestampedImportMapScriptToHtml(renderToStaticMarkup(/*#__PURE__*/ _jsx(Document, {
48
- ...defaultProps,
49
- ...props,
50
- css: css
51
- })), importMap, autoUpdatesCssUrls);
52
- return `<!DOCTYPE html>${result}`;
53
- }
54
-
55
- //# sourceMappingURL=getDocumentHtml.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/build/renderDocumentWorker/getDocumentHtml.tsx"],"sourcesContent":["import {type MessagePort} from 'node:worker_threads'\n\nimport {renderToStaticMarkup} from 'react-dom/server'\n\nimport {buildDebug} from '../buildDebug.js'\nimport {addTimestampedImportMapScriptToHtml} from './addTimestampImportMapScriptToHtml.js'\nimport {getDocumentComponent} from './getDocumentComponent.js'\nimport {type DocumentProps} from './types.js'\n\n/**\n * Adds a base path to a URL if necessary, and returns the resulting URL.\n * @param url - The URL to prefix with a base path.\n * @param basePath - The base path to prefix the URL with. Default value is `/`.\n * @returns The resulting URL with the base path.\n * @internal\n */\nfunction _prefixUrlWithBasePath(url: string, basePath: string): string {\n // Normalize basePath by adding a leading slash if it's missing.\n const normalizedBasePath = basePath.startsWith('/') ? basePath : `/${basePath}`\n\n // If the URL starts with a slash, append it to the basePath, removing any trailing slash if present.\n if (url.startsWith('/')) {\n if (normalizedBasePath.endsWith('/')) {\n return `${normalizedBasePath.slice(0, -1)}${url}`\n }\n return `${normalizedBasePath}${url}`\n }\n\n // If the URL doesn't start with a slash, append it to the basePath with a slash in between.\n if (normalizedBasePath.endsWith('/')) {\n return `${normalizedBasePath}${url}`\n }\n return `${normalizedBasePath}/${url}`\n}\n\n/**\n * @internal\n */\nexport async function getDocumentHtml(\n parent: MessagePort,\n studioRootPath: string,\n props?: DocumentProps,\n importMap?: {imports?: Record<string, string>},\n isApp?: boolean,\n autoUpdatesCssUrls?: string[],\n): Promise<string> {\n const Document = await getDocumentComponent(parent, studioRootPath, isApp)\n\n const defaultProps = {\n entryPath: './.sanity/runtime/app.js',\n }\n\n // NOTE: Validate the list of CSS paths so implementers of `_document.tsx` don't have to\n // - If the path is not a full URL, check if it starts with `/`\n // - If not, then prepend a `/` to the string\n const css = props?.css?.map((url) => {\n try {\n // If the URL is absolute, we don't need to prefix it\n return new URL(url).toString()\n } catch {\n return _prefixUrlWithBasePath(url, props.basePath)\n }\n })\n\n buildDebug('Rendering document component using React')\n const result = addTimestampedImportMapScriptToHtml(\n renderToStaticMarkup(<Document {...defaultProps} {...props} css={css} />),\n importMap,\n autoUpdatesCssUrls,\n )\n\n return `<!DOCTYPE html>${result}`\n}\n"],"names":["renderToStaticMarkup","buildDebug","addTimestampedImportMapScriptToHtml","getDocumentComponent","_prefixUrlWithBasePath","url","basePath","normalizedBasePath","startsWith","endsWith","slice","getDocumentHtml","parent","studioRootPath","props","importMap","isApp","autoUpdatesCssUrls","Document","defaultProps","entryPath","css","map","URL","toString","result"],"mappings":";AAEA,SAAQA,oBAAoB,QAAO,mBAAkB;AAErD,SAAQC,UAAU,QAAO,mBAAkB;AAC3C,SAAQC,mCAAmC,QAAO,yCAAwC;AAC1F,SAAQC,oBAAoB,QAAO,4BAA2B;AAG9D;;;;;;CAMC,GACD,SAASC,uBAAuBC,GAAW,EAAEC,QAAgB;IAC3D,gEAAgE;IAChE,MAAMC,qBAAqBD,SAASE,UAAU,CAAC,OAAOF,WAAW,CAAC,CAAC,EAAEA,UAAU;IAE/E,qGAAqG;IACrG,IAAID,IAAIG,UAAU,CAAC,MAAM;QACvB,IAAID,mBAAmBE,QAAQ,CAAC,MAAM;YACpC,OAAO,GAAGF,mBAAmBG,KAAK,CAAC,GAAG,CAAC,KAAKL,KAAK;QACnD;QACA,OAAO,GAAGE,qBAAqBF,KAAK;IACtC;IAEA,4FAA4F;IAC5F,IAAIE,mBAAmBE,QAAQ,CAAC,MAAM;QACpC,OAAO,GAAGF,qBAAqBF,KAAK;IACtC;IACA,OAAO,GAAGE,mBAAmB,CAAC,EAAEF,KAAK;AACvC;AAEA;;CAEC,GACD,OAAO,eAAeM,gBACpBC,MAAmB,EACnBC,cAAsB,EACtBC,KAAqB,EACrBC,SAA8C,EAC9CC,KAAe,EACfC,kBAA6B;IAE7B,MAAMC,WAAW,MAAMf,qBAAqBS,QAAQC,gBAAgBG;IAEpE,MAAMG,eAAe;QACnBC,WAAW;IACb;IAEA,wFAAwF;IACxF,+DAA+D;IAC/D,+CAA+C;IAC/C,MAAMC,MAAMP,OAAOO,KAAKC,IAAI,CAACjB;QAC3B,IAAI;YACF,qDAAqD;YACrD,OAAO,IAAIkB,IAAIlB,KAAKmB,QAAQ;QAC9B,EAAE,OAAM;YACN,OAAOpB,uBAAuBC,KAAKS,MAAMR,QAAQ;QACnD;IACF;IAEAL,WAAW;IACX,MAAMwB,SAASvB,oCACbF,mCAAqB,KAACkB;QAAU,GAAGC,YAAY;QAAG,GAAGL,KAAK;QAAEO,KAAKA;SACjEN,WACAE;IAGF,OAAO,CAAC,eAAe,EAAEQ,QAAQ;AACnC"}
@@ -1,31 +0,0 @@
1
- import { getDocumentHtml } from './getDocumentHtml.js';
2
- /**
3
- * Renders a document in a worker thread
4
- *
5
- * @param parent - The parent port to send messages to
6
- * @param options - The options for the document to render
7
- * @returns - The rendered document
8
- */ export async function renderDocumentWorker(parent, options) {
9
- const { autoUpdatesCssUrls, importMap, isApp, props, studioRootPath } = options;
10
- if (typeof studioRootPath !== 'string') {
11
- parent.postMessage({
12
- message: 'Missing/invalid `studioRootPath` option',
13
- type: 'error'
14
- });
15
- return;
16
- }
17
- if (props && typeof props !== 'object') {
18
- parent.postMessage({
19
- message: '`props` must be an object if provided',
20
- type: 'error'
21
- });
22
- return;
23
- }
24
- const html = await getDocumentHtml(parent, studioRootPath, props, importMap, isApp, autoUpdatesCssUrls);
25
- parent.postMessage({
26
- html,
27
- type: 'result'
28
- });
29
- }
30
-
31
- //# sourceMappingURL=renderDocumentWorker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/build/renderDocumentWorker/renderDocumentWorker.ts"],"sourcesContent":["import {type MessagePort} from 'node:worker_threads'\n\nimport {getDocumentHtml} from './getDocumentHtml.js'\nimport {type DocumentProps} from './types.js'\n\n/**\n * @internal\n */\nexport interface RenderDocumentWorkerOptions {\n studioRootPath: string\n\n autoUpdatesCssUrls?: string[]\n importMap?: {\n imports?: Record<string, string>\n }\n isApp?: boolean\n props?: DocumentProps\n}\n\n/**\n * Renders a document in a worker thread\n *\n * @param parent - The parent port to send messages to\n * @param options - The options for the document to render\n * @returns - The rendered document\n */\nexport async function renderDocumentWorker(\n parent: MessagePort,\n options: RenderDocumentWorkerOptions,\n) {\n const {autoUpdatesCssUrls, importMap, isApp, props, studioRootPath} = options\n\n if (typeof studioRootPath !== 'string') {\n parent.postMessage({\n message: 'Missing/invalid `studioRootPath` option',\n type: 'error',\n })\n return\n }\n\n if (props && typeof props !== 'object') {\n parent.postMessage({\n message: '`props` must be an object if provided',\n type: 'error',\n })\n return\n }\n\n const html = await getDocumentHtml(\n parent,\n studioRootPath,\n props,\n importMap,\n isApp,\n autoUpdatesCssUrls,\n )\n\n parent.postMessage({\n html,\n type: 'result',\n })\n}\n"],"names":["getDocumentHtml","renderDocumentWorker","parent","options","autoUpdatesCssUrls","importMap","isApp","props","studioRootPath","postMessage","message","type","html"],"mappings":"AAEA,SAAQA,eAAe,QAAO,uBAAsB;AAiBpD;;;;;;CAMC,GACD,OAAO,eAAeC,qBACpBC,MAAmB,EACnBC,OAAoC;IAEpC,MAAM,EAACC,kBAAkB,EAAEC,SAAS,EAAEC,KAAK,EAAEC,KAAK,EAAEC,cAAc,EAAC,GAAGL;IAEtE,IAAI,OAAOK,mBAAmB,UAAU;QACtCN,OAAOO,WAAW,CAAC;YACjBC,SAAS;YACTC,MAAM;QACR;QACA;IACF;IAEA,IAAIJ,SAAS,OAAOA,UAAU,UAAU;QACtCL,OAAOO,WAAW,CAAC;YACjBC,SAAS;YACTC,MAAM;QACR;QACA;IACF;IAEA,MAAMC,OAAO,MAAMZ,gBACjBE,QACAM,gBACAD,OACAF,WACAC,OACAF;IAGFF,OAAOO,WAAW,CAAC;QACjBG;QACAD,MAAM;IACR;AACF"}
@@ -1,30 +0,0 @@
1
- import fs from 'node:fs';
2
- import { doImport } from '@sanity/cli-core';
3
- import { buildDebug } from '../buildDebug.js';
4
- import { getPossibleDocumentComponentLocations } from '../getPossibleDocumentComponentLocations.js';
5
- /**
6
- * @internal
7
- */ export async function tryLoadDocumentComponent(studioRootPath) {
8
- const locations = getPossibleDocumentComponentLocations(studioRootPath);
9
- for (const componentPath of locations){
10
- buildDebug('Trying to load document component from %s', componentPath);
11
- try {
12
- const component = await doImport(componentPath);
13
- return {
14
- component,
15
- modified: Math.floor(fs.statSync(componentPath)?.mtimeMs),
16
- path: componentPath
17
- };
18
- } catch (err) {
19
- // Allow "not found" errors
20
- if (err.code !== 'ERR_MODULE_NOT_FOUND') {
21
- buildDebug('Failed to load document component: %s', err.message);
22
- throw err;
23
- }
24
- buildDebug('Document component not found at %s', componentPath);
25
- }
26
- }
27
- return null;
28
- }
29
-
30
- //# sourceMappingURL=tryLoadDocumentComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/build/renderDocumentWorker/tryLoadDocumentComponent.ts"],"sourcesContent":["import fs from 'node:fs'\n\nimport {doImport} from '@sanity/cli-core'\n\nimport {buildDebug} from '../buildDebug.js'\nimport {getPossibleDocumentComponentLocations} from '../getPossibleDocumentComponentLocations.js'\n\n/**\n * @internal\n */\nexport async function tryLoadDocumentComponent(studioRootPath: string) {\n const locations = getPossibleDocumentComponentLocations(studioRootPath)\n\n for (const componentPath of locations) {\n buildDebug('Trying to load document component from %s', componentPath)\n try {\n const component = await doImport(componentPath)\n\n return {\n component,\n modified: Math.floor(fs.statSync(componentPath)?.mtimeMs),\n path: componentPath,\n }\n } catch (err) {\n // Allow \"not found\" errors\n if (err.code !== 'ERR_MODULE_NOT_FOUND') {\n buildDebug('Failed to load document component: %s', err.message)\n throw err\n }\n\n buildDebug('Document component not found at %s', componentPath)\n }\n }\n\n return null\n}\n"],"names":["fs","doImport","buildDebug","getPossibleDocumentComponentLocations","tryLoadDocumentComponent","studioRootPath","locations","componentPath","component","modified","Math","floor","statSync","mtimeMs","path","err","code","message"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AAExB,SAAQC,QAAQ,QAAO,mBAAkB;AAEzC,SAAQC,UAAU,QAAO,mBAAkB;AAC3C,SAAQC,qCAAqC,QAAO,8CAA6C;AAEjG;;CAEC,GACD,OAAO,eAAeC,yBAAyBC,cAAsB;IACnE,MAAMC,YAAYH,sCAAsCE;IAExD,KAAK,MAAME,iBAAiBD,UAAW;QACrCJ,WAAW,6CAA6CK;QACxD,IAAI;YACF,MAAMC,YAAY,MAAMP,SAASM;YAEjC,OAAO;gBACLC;gBACAC,UAAUC,KAAKC,KAAK,CAACX,GAAGY,QAAQ,CAACL,gBAAgBM;gBACjDC,MAAMP;YACR;QACF,EAAE,OAAOQ,KAAK;YACZ,2BAA2B;YAC3B,IAAIA,IAAIC,IAAI,KAAK,wBAAwB;gBACvCd,WAAW,yCAAyCa,IAAIE,OAAO;gBAC/D,MAAMF;YACR;YAEAb,WAAW,sCAAsCK;QACnD;IACF;IAEA,OAAO;AACT"}
@@ -1,5 +0,0 @@
1
- /**
2
- * @internal
3
- */ export { };
4
-
5
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/build/renderDocumentWorker/types.ts"],"sourcesContent":["/**\n * @internal\n */\nexport interface DocumentProps {\n basePath: string\n\n css?: string[]\n entryPath?: string\n title?: string\n}\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAMC"}
@@ -1,64 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { tryFindStudioConfigPath } from '@sanity/cli-core';
4
- import { watch as chokidarWatch } from 'chokidar';
5
- import { toForwardSlashes } from '../../util/toForwardSlashes.js';
6
- import { buildDebug } from './buildDebug.js';
7
- import { decorateIndexWithAutoGeneratedWarning } from './decorateIndexWithAutoGeneratedWarning.js';
8
- import { decorateIndexWithBridgeScript } from './decorateIndexWithBridgeScript.js';
9
- import { decorateIndexWithStagingScript } from './decorateIndexWithStagingScript.js';
10
- import { getEntryModule } from './getEntryModule.js';
11
- import { getPossibleDocumentComponentLocations } from './getPossibleDocumentComponentLocations.js';
12
- import { renderDocument } from './renderDocument.js';
13
- /**
14
- * Generates the `.sanity/runtime` directory, and optionally watches for custom
15
- * document files, rebuilding when they change
16
- *
17
- * @param options - Current working directory (Sanity root dir), and whether or not to watch
18
- * @returns A watcher instance if watch is enabled, undefined otherwise
19
- * @internal
20
- */ export async function writeSanityRuntime(options) {
21
- const { appTitle, basePath, cwd, entry, isApp, reactStrictMode, watch } = options;
22
- const runtimeDir = path.join(cwd, '.sanity', 'runtime');
23
- buildDebug('Making runtime directory');
24
- await fs.mkdir(runtimeDir, {
25
- recursive: true
26
- });
27
- async function renderAndWriteDocument() {
28
- buildDebug('Rendering document template');
29
- const indexHtml = decorateIndexWithStagingScript(decorateIndexWithBridgeScript(decorateIndexWithAutoGeneratedWarning(await renderDocument({
30
- isApp,
31
- props: {
32
- basePath: basePath || '/',
33
- entryPath: `/${toForwardSlashes(path.relative(cwd, path.join(runtimeDir, 'app.js')))}`,
34
- title: appTitle
35
- },
36
- studioRootPath: cwd
37
- }))));
38
- buildDebug('Writing index.html to runtime directory');
39
- await fs.writeFile(path.join(runtimeDir, 'index.html'), indexHtml);
40
- }
41
- let watcher;
42
- if (watch) {
43
- watcher = chokidarWatch(getPossibleDocumentComponentLocations(cwd)).on('all', ()=>renderAndWriteDocument());
44
- }
45
- await renderAndWriteDocument();
46
- buildDebug('Writing app.js to runtime directory');
47
- let relativeConfigLocation = null;
48
- if (!isApp) {
49
- const studioConfigPath = await tryFindStudioConfigPath(cwd);
50
- relativeConfigLocation = studioConfigPath ? toForwardSlashes(path.relative(runtimeDir, studioConfigPath)) : null;
51
- }
52
- const relativeEntry = toForwardSlashes(path.relative(runtimeDir, path.resolve(cwd, entry || './src/App')));
53
- const appJsContent = getEntryModule({
54
- basePath,
55
- entry: relativeEntry,
56
- isApp,
57
- reactStrictMode,
58
- relativeConfigLocation
59
- });
60
- await fs.writeFile(path.join(runtimeDir, 'app.js'), appJsContent);
61
- return watcher;
62
- }
63
-
64
- //# sourceMappingURL=writeSanityRuntime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/build/writeSanityRuntime.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {tryFindStudioConfigPath} from '@sanity/cli-core'\nimport {watch as chokidarWatch, type FSWatcher} from 'chokidar'\n\nimport {toForwardSlashes} from '../../util/toForwardSlashes.js'\nimport {buildDebug} from './buildDebug.js'\nimport {decorateIndexWithAutoGeneratedWarning} from './decorateIndexWithAutoGeneratedWarning.js'\nimport {decorateIndexWithBridgeScript} from './decorateIndexWithBridgeScript.js'\nimport {decorateIndexWithStagingScript} from './decorateIndexWithStagingScript.js'\nimport {getEntryModule} from './getEntryModule.js'\nimport {getPossibleDocumentComponentLocations} from './getPossibleDocumentComponentLocations.js'\nimport {renderDocument} from './renderDocument.js'\n\ninterface RuntimeOptions {\n cwd: string\n reactStrictMode: boolean\n watch: boolean\n\n appTitle?: string\n basePath?: string\n entry?: string\n isApp?: boolean\n}\n\n/**\n * Generates the `.sanity/runtime` directory, and optionally watches for custom\n * document files, rebuilding when they change\n *\n * @param options - Current working directory (Sanity root dir), and whether or not to watch\n * @returns A watcher instance if watch is enabled, undefined otherwise\n * @internal\n */\nexport async function writeSanityRuntime(options: RuntimeOptions): Promise<FSWatcher | undefined> {\n const {appTitle, basePath, cwd, entry, isApp, reactStrictMode, watch} = options\n const runtimeDir = path.join(cwd, '.sanity', 'runtime')\n\n buildDebug('Making runtime directory')\n await fs.mkdir(runtimeDir, {recursive: true})\n\n async function renderAndWriteDocument() {\n buildDebug('Rendering document template')\n const indexHtml = decorateIndexWithStagingScript(\n decorateIndexWithBridgeScript(\n decorateIndexWithAutoGeneratedWarning(\n await renderDocument({\n isApp,\n props: {\n basePath: basePath || '/',\n entryPath: `/${toForwardSlashes(path.relative(cwd, path.join(runtimeDir, 'app.js')))}`,\n title: appTitle,\n },\n studioRootPath: cwd,\n }),\n ),\n ),\n )\n\n buildDebug('Writing index.html to runtime directory')\n await fs.writeFile(path.join(runtimeDir, 'index.html'), indexHtml)\n }\n\n let watcher: FSWatcher | undefined\n\n if (watch) {\n watcher = chokidarWatch(getPossibleDocumentComponentLocations(cwd)).on('all', () =>\n renderAndWriteDocument(),\n )\n }\n\n await renderAndWriteDocument()\n\n buildDebug('Writing app.js to runtime directory')\n let relativeConfigLocation: string | null = null\n if (!isApp) {\n const studioConfigPath = await tryFindStudioConfigPath(cwd)\n relativeConfigLocation = studioConfigPath\n ? toForwardSlashes(path.relative(runtimeDir, studioConfigPath))\n : null\n }\n\n const relativeEntry = toForwardSlashes(\n path.relative(runtimeDir, path.resolve(cwd, entry || './src/App')),\n )\n const appJsContent = getEntryModule({\n basePath,\n entry: relativeEntry,\n isApp,\n reactStrictMode,\n relativeConfigLocation,\n })\n await fs.writeFile(path.join(runtimeDir, 'app.js'), appJsContent)\n\n return watcher\n}\n"],"names":["fs","path","tryFindStudioConfigPath","watch","chokidarWatch","toForwardSlashes","buildDebug","decorateIndexWithAutoGeneratedWarning","decorateIndexWithBridgeScript","decorateIndexWithStagingScript","getEntryModule","getPossibleDocumentComponentLocations","renderDocument","writeSanityRuntime","options","appTitle","basePath","cwd","entry","isApp","reactStrictMode","runtimeDir","join","mkdir","recursive","renderAndWriteDocument","indexHtml","props","entryPath","relative","title","studioRootPath","writeFile","watcher","on","relativeConfigLocation","studioConfigPath","relativeEntry","resolve","appJsContent"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAE5B,SAAQC,uBAAuB,QAAO,mBAAkB;AACxD,SAAQC,SAASC,aAAa,QAAuB,WAAU;AAE/D,SAAQC,gBAAgB,QAAO,iCAAgC;AAC/D,SAAQC,UAAU,QAAO,kBAAiB;AAC1C,SAAQC,qCAAqC,QAAO,6CAA4C;AAChG,SAAQC,6BAA6B,QAAO,qCAAoC;AAChF,SAAQC,8BAA8B,QAAO,sCAAqC;AAClF,SAAQC,cAAc,QAAO,sBAAqB;AAClD,SAAQC,qCAAqC,QAAO,6CAA4C;AAChG,SAAQC,cAAc,QAAO,sBAAqB;AAalD;;;;;;;CAOC,GACD,OAAO,eAAeC,mBAAmBC,OAAuB;IAC9D,MAAM,EAACC,QAAQ,EAAEC,QAAQ,EAAEC,GAAG,EAAEC,KAAK,EAAEC,KAAK,EAAEC,eAAe,EAAEjB,KAAK,EAAC,GAAGW;IACxE,MAAMO,aAAapB,KAAKqB,IAAI,CAACL,KAAK,WAAW;IAE7CX,WAAW;IACX,MAAMN,GAAGuB,KAAK,CAACF,YAAY;QAACG,WAAW;IAAI;IAE3C,eAAeC;QACbnB,WAAW;QACX,MAAMoB,YAAYjB,+BAChBD,8BACED,sCACE,MAAMK,eAAe;YACnBO;YACAQ,OAAO;gBACLX,UAAUA,YAAY;gBACtBY,WAAW,CAAC,CAAC,EAAEvB,iBAAiBJ,KAAK4B,QAAQ,CAACZ,KAAKhB,KAAKqB,IAAI,CAACD,YAAY,aAAa;gBACtFS,OAAOf;YACT;YACAgB,gBAAgBd;QAClB;QAKNX,WAAW;QACX,MAAMN,GAAGgC,SAAS,CAAC/B,KAAKqB,IAAI,CAACD,YAAY,eAAeK;IAC1D;IAEA,IAAIO;IAEJ,IAAI9B,OAAO;QACT8B,UAAU7B,cAAcO,sCAAsCM,MAAMiB,EAAE,CAAC,OAAO,IAC5ET;IAEJ;IAEA,MAAMA;IAENnB,WAAW;IACX,IAAI6B,yBAAwC;IAC5C,IAAI,CAAChB,OAAO;QACV,MAAMiB,mBAAmB,MAAMlC,wBAAwBe;QACvDkB,yBAAyBC,mBACrB/B,iBAAiBJ,KAAK4B,QAAQ,CAACR,YAAYe,qBAC3C;IACN;IAEA,MAAMC,gBAAgBhC,iBACpBJ,KAAK4B,QAAQ,CAACR,YAAYpB,KAAKqC,OAAO,CAACrB,KAAKC,SAAS;IAEvD,MAAMqB,eAAe7B,eAAe;QAClCM;QACAE,OAAOmB;QACPlB;QACAC;QACAe;IACF;IACA,MAAMnC,GAAGgC,SAAS,CAAC/B,KAAKqB,IAAI,CAACD,YAAY,WAAWkB;IAEpD,OAAON;AACT"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Normalizes input to a path, handling both paths and full Sanity docs URLs
3
- * @param input - Either a path like "/docs/studio" or full URL like "https://www.sanity.io/docs/studio"
4
- * @returns Normalized path starting with "/"
5
- *
6
- * @internal
7
- */ export function normalizeDocsPath(input) {
8
- const sanityDocsPrefix = 'https://www.sanity.io';
9
- if (input.startsWith(sanityDocsPrefix)) {
10
- return input.replace(sanityDocsPrefix, '');
11
- }
12
- return input;
13
- }
14
-
15
- //# sourceMappingURL=normalizeDocsPath.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/docs/normalizeDocsPath.ts"],"sourcesContent":["/**\n * Normalizes input to a path, handling both paths and full Sanity docs URLs\n * @param input - Either a path like \"/docs/studio\" or full URL like \"https://www.sanity.io/docs/studio\"\n * @returns Normalized path starting with \"/\"\n *\n * @internal\n */\nexport function normalizeDocsPath(input: string): string {\n const sanityDocsPrefix = 'https://www.sanity.io'\n if (input.startsWith(sanityDocsPrefix)) {\n return input.replace(sanityDocsPrefix, '')\n }\n return input\n}\n"],"names":["normalizeDocsPath","input","sanityDocsPrefix","startsWith","replace"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,SAASA,kBAAkBC,KAAa;IAC7C,MAAMC,mBAAmB;IACzB,IAAID,MAAME,UAAU,CAACD,mBAAmB;QACtC,OAAOD,MAAMG,OAAO,CAACF,kBAAkB;IACzC;IACA,OAAOD;AACT"}
@@ -1,33 +0,0 @@
1
- import { isMainThread, parentPort, workerData } from 'node:worker_threads';
2
- import { getStudioWorkspaces } from '@sanity/cli-core';
3
- import { extractSchema } from '@sanity/schema/_internal';
4
- import { getWorkspace } from '../../util/getWorkspace.js';
5
- import { extractSchemaWorkerData } from './types.js';
6
- import { extractValidationFromSchemaError } from './utils/extractValidationFromSchemaError.js';
7
- if (isMainThread || !parentPort) {
8
- throw new Error('Should only be run in a worker!');
9
- }
10
- const { configPath, enforceRequiredFields, workDir, workspaceName } = extractSchemaWorkerData.parse(workerData);
11
- try {
12
- const workspaces = await getStudioWorkspaces(configPath);
13
- if (workspaces.length === 0) {
14
- throw new Error('Failed to resolve configuration');
15
- }
16
- const workspace = getWorkspace(workspaces, workspaceName);
17
- const schema = extractSchema(workspace.schema, {
18
- enforceRequiredFields
19
- });
20
- parentPort.postMessage({
21
- schema,
22
- type: 'success'
23
- });
24
- } catch (error) {
25
- const validation = await extractValidationFromSchemaError(error, workDir);
26
- parentPort.postMessage({
27
- error: error instanceof Error ? error.message : String(error),
28
- type: 'error',
29
- validation
30
- });
31
- }
32
-
33
- //# sourceMappingURL=extractSanitySchema.worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/schema/extractSanitySchema.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {getStudioWorkspaces} from '@sanity/cli-core'\nimport {extractSchema} from '@sanity/schema/_internal'\n\nimport {getWorkspace} from '../../util/getWorkspace.js'\nimport {extractSchemaWorkerData} from './types.js'\nimport {extractValidationFromSchemaError} from './utils/extractValidationFromSchemaError.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath, enforceRequiredFields, workDir, workspaceName} =\n extractSchemaWorkerData.parse(workerData)\n\ntry {\n const workspaces = await getStudioWorkspaces(configPath)\n if (workspaces.length === 0) {\n throw new Error('Failed to resolve configuration')\n }\n\n const workspace = getWorkspace(workspaces, workspaceName)\n const schema = extractSchema(workspace.schema, {\n enforceRequiredFields,\n })\n\n parentPort.postMessage({\n schema,\n type: 'success',\n })\n} catch (error) {\n const validation = await extractValidationFromSchemaError(error, workDir)\n parentPort.postMessage({\n error: error instanceof Error ? error.message : String(error),\n type: 'error',\n validation,\n })\n}\n"],"names":["isMainThread","parentPort","workerData","getStudioWorkspaces","extractSchema","getWorkspace","extractSchemaWorkerData","extractValidationFromSchemaError","Error","configPath","enforceRequiredFields","workDir","workspaceName","parse","workspaces","length","workspace","schema","postMessage","type","error","validation","message","String"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,mBAAmB,QAAO,mBAAkB;AACpD,SAAQC,aAAa,QAAO,2BAA0B;AAEtD,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,uBAAuB,QAAO,aAAY;AAClD,SAAQC,gCAAgC,QAAO,8CAA6C;AAE5F,IAAIP,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIO,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAEC,qBAAqB,EAAEC,OAAO,EAAEC,aAAa,EAAC,GAC/DN,wBAAwBO,KAAK,CAACX;AAEhC,IAAI;IACF,MAAMY,aAAa,MAAMX,oBAAoBM;IAC7C,IAAIK,WAAWC,MAAM,KAAK,GAAG;QAC3B,MAAM,IAAIP,MAAM;IAClB;IAEA,MAAMQ,YAAYX,aAAaS,YAAYF;IAC3C,MAAMK,SAASb,cAAcY,UAAUC,MAAM,EAAE;QAC7CP;IACF;IAEAT,WAAWiB,WAAW,CAAC;QACrBD;QACAE,MAAM;IACR;AACF,EAAE,OAAOC,OAAO;IACd,MAAMC,aAAa,MAAMd,iCAAiCa,OAAOT;IACjEV,WAAWiB,WAAW,CAAC;QACrBE,OAAOA,iBAAiBZ,QAAQY,MAAME,OAAO,GAAGC,OAAOH;QACvDD,MAAM;QACNE;IACF;AACF"}
@@ -1,78 +0,0 @@
1
- import { isatty } from 'node:tty';
2
- import { styleText } from 'node:util';
3
- import { logSymbols } from '@sanity/cli-core/ux';
4
- import { generateHelpUrl } from '@sanity/generate-help-url';
5
- const isTty = isatty(1);
6
- const headers = {
7
- error: isTty ? styleText([
8
- 'bold',
9
- 'bgRed',
10
- 'black'
11
- ], ' ERROR ') : styleText('red', '[ERROR]'),
12
- warning: isTty ? styleText([
13
- 'bold',
14
- 'bgYellow',
15
- 'black'
16
- ], ' WARN ') : styleText('yellow', '[WARN]')
17
- };
18
- const severityValues = {
19
- error: 0,
20
- warning: 1
21
- };
22
- function formatPath(pathSegments) {
23
- const format = ([curr, ...next], mode = 'object')=>{
24
- if (!curr) return '';
25
- if (curr.kind === 'property') return format(next, curr.name === 'of' ? 'array' : 'object');
26
- const name = curr.name || `<anonymous_${curr.type}>`;
27
- return `${mode === 'array' ? `[${name}]` : `.${name}`}${format(next)}`;
28
- };
29
- return format(pathSegments.slice(1)).slice(1) // removes the top-level type and leading `.`
30
- ;
31
- }
32
- export function getAggregatedSeverity(groupOrGroups) {
33
- const groups = Array.isArray(groupOrGroups) ? groupOrGroups : [
34
- groupOrGroups
35
- ];
36
- return groups.flatMap((group)=>group.problems.map((problem)=>problem.severity)).includes('error') ? 'error' : 'warning';
37
- }
38
- export function formatSchemaValidation(validation) {
39
- let unnamedTopLevelTypeCount = 0;
40
- const validationByTypeMap = {};
41
- for (const group of validation){
42
- const [firstSegment] = group.path;
43
- if (!firstSegment) continue;
44
- if (firstSegment.kind !== 'type') continue;
45
- const topLevelType = firstSegment.name || `<unnamed_${firstSegment.type}_type_${unnamedTopLevelTypeCount++}>`;
46
- if (!validationByTypeMap[topLevelType]) {
47
- validationByTypeMap[topLevelType] = [];
48
- }
49
- validationByTypeMap[topLevelType].push(group);
50
- }
51
- const validationByType = Object.entries(validationByTypeMap);
52
- const formatted = validationByType.toSorted((a, b)=>{
53
- const [aType, aGroups] = a;
54
- const [bType, bGroups] = b;
55
- const aValue = severityValues[getAggregatedSeverity(aGroups)];
56
- const bValue = severityValues[getAggregatedSeverity(bGroups)];
57
- if (aValue === bValue) return aType.localeCompare(bType, 'en-US');
58
- return aValue - bValue;
59
- }).map(([topLevelType, groups])=>{
60
- const formattedTopLevelType = isTty ? styleText([
61
- 'bgWhite',
62
- 'black'
63
- ], ` ${topLevelType} `) : `[${topLevelType}]`;
64
- const header = `${headers[getAggregatedSeverity(groups)]} ${formattedTopLevelType}`;
65
- const body = groups.toSorted((a, b)=>severityValues[getAggregatedSeverity(a)] - severityValues[getAggregatedSeverity(b)]).map((group)=>{
66
- const formattedPath = ` ${styleText('bold', formatPath(group.path) || '(root)')}`;
67
- const formattedMessages = group.problems.toSorted((a, b)=>severityValues[a.severity] - severityValues[b.severity]).map(({ helpId, message, severity })=>{
68
- const help = helpId ? `\n See ${generateHelpUrl(helpId)}` : '';
69
- return ` ${logSymbols[severity]} ${message}${help}`;
70
- }).join('\n');
71
- return `${formattedPath}\n${formattedMessages}`;
72
- }).join('\n');
73
- return `${header}\n${body}`;
74
- }).join('\n\n');
75
- return formatted;
76
- }
77
-
78
- //# sourceMappingURL=formatSchemaValidation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/schema/formatSchemaValidation.ts"],"sourcesContent":["import {isatty} from 'node:tty'\nimport {styleText} from 'node:util'\n\nimport {logSymbols} from '@sanity/cli-core/ux'\nimport {generateHelpUrl} from '@sanity/generate-help-url'\nimport {type SchemaValidationProblemGroup, type SchemaValidationProblemPath} from '@sanity/types'\n\nconst isTty = isatty(1)\n\nconst headers = {\n error: isTty ? styleText(['bold', 'bgRed', 'black'], ' ERROR ') : styleText('red', '[ERROR]'),\n warning: isTty\n ? styleText(['bold', 'bgYellow', 'black'], ' WARN ')\n : styleText('yellow', '[WARN]'),\n}\n\nconst severityValues = {error: 0, warning: 1}\n\nfunction formatPath(pathSegments: SchemaValidationProblemPath) {\n const format = (\n [curr, ...next]: SchemaValidationProblemPath,\n mode: 'array' | 'object' = 'object',\n ): string => {\n if (!curr) return ''\n if (curr.kind === 'property') return format(next, curr.name === 'of' ? 'array' : 'object')\n\n const name = curr.name || `<anonymous_${curr.type}>`\n return `${mode === 'array' ? `[${name}]` : `.${name}`}${format(next)}`\n }\n\n return format(pathSegments.slice(1)).slice(1) // removes the top-level type and leading `.`\n}\n\nexport function getAggregatedSeverity(\n groupOrGroups: SchemaValidationProblemGroup | SchemaValidationProblemGroup[],\n): 'error' | 'warning' {\n const groups = Array.isArray(groupOrGroups) ? groupOrGroups : [groupOrGroups]\n return groups\n .flatMap((group) => group.problems.map((problem) => problem.severity))\n .includes('error')\n ? 'error'\n : 'warning'\n}\n\nexport function formatSchemaValidation(validation: SchemaValidationProblemGroup[]): string {\n let unnamedTopLevelTypeCount = 0\n const validationByTypeMap: Record<string, SchemaValidationProblemGroup[]> = {}\n\n for (const group of validation) {\n const [firstSegment] = group.path\n if (!firstSegment) continue\n if (firstSegment.kind !== 'type') continue\n\n const topLevelType =\n firstSegment.name || `<unnamed_${firstSegment.type}_type_${unnamedTopLevelTypeCount++}>`\n\n if (!validationByTypeMap[topLevelType]) {\n validationByTypeMap[topLevelType] = []\n }\n\n validationByTypeMap[topLevelType].push(group)\n }\n\n const validationByType = Object.entries(validationByTypeMap)\n\n const formatted = validationByType\n .toSorted((a, b) => {\n const [aType, aGroups] = a\n const [bType, bGroups] = b\n const aValue = severityValues[getAggregatedSeverity(aGroups)]\n const bValue = severityValues[getAggregatedSeverity(bGroups)]\n if (aValue === bValue) return aType.localeCompare(bType, 'en-US')\n return aValue - bValue\n })\n .map(([topLevelType, groups]) => {\n const formattedTopLevelType = isTty\n ? styleText(['bgWhite', 'black'], ` ${topLevelType} `)\n : `[${topLevelType}]`\n\n const header = `${headers[getAggregatedSeverity(groups)]} ${formattedTopLevelType}`\n const body = groups\n .toSorted(\n (a, b) =>\n severityValues[getAggregatedSeverity(a)] - severityValues[getAggregatedSeverity(b)],\n )\n .map((group) => {\n const formattedPath = ` ${styleText('bold', formatPath(group.path) || '(root)')}`\n const formattedMessages = group.problems\n .toSorted((a, b) => severityValues[a.severity] - severityValues[b.severity])\n .map(({helpId, message, severity}) => {\n const help = helpId ? `\\n See ${generateHelpUrl(helpId)}` : ''\n return ` ${logSymbols[severity]} ${message}${help}`\n })\n .join('\\n')\n\n return `${formattedPath}\\n${formattedMessages}`\n })\n .join('\\n')\n\n return `${header}\\n${body}`\n })\n .join('\\n\\n')\n\n return formatted\n}\n"],"names":["isatty","styleText","logSymbols","generateHelpUrl","isTty","headers","error","warning","severityValues","formatPath","pathSegments","format","curr","next","mode","kind","name","type","slice","getAggregatedSeverity","groupOrGroups","groups","Array","isArray","flatMap","group","problems","map","problem","severity","includes","formatSchemaValidation","validation","unnamedTopLevelTypeCount","validationByTypeMap","firstSegment","path","topLevelType","push","validationByType","Object","entries","formatted","toSorted","a","b","aType","aGroups","bType","bGroups","aValue","bValue","localeCompare","formattedTopLevelType","header","body","formattedPath","formattedMessages","helpId","message","help","join"],"mappings":"AAAA,SAAQA,MAAM,QAAO,WAAU;AAC/B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SAAQC,eAAe,QAAO,4BAA2B;AAGzD,MAAMC,QAAQJ,OAAO;AAErB,MAAMK,UAAU;IACdC,OAAOF,QAAQH,UAAU;QAAC;QAAQ;QAAS;KAAQ,EAAE,aAAaA,UAAU,OAAO;IACnFM,SAASH,QACLH,UAAU;QAAC;QAAQ;QAAY;KAAQ,EAAE,YACzCA,UAAU,UAAU;AAC1B;AAEA,MAAMO,iBAAiB;IAACF,OAAO;IAAGC,SAAS;AAAC;AAE5C,SAASE,WAAWC,YAAyC;IAC3D,MAAMC,SAAS,CACb,CAACC,MAAM,GAAGC,KAAkC,EAC5CC,OAA2B,QAAQ;QAEnC,IAAI,CAACF,MAAM,OAAO;QAClB,IAAIA,KAAKG,IAAI,KAAK,YAAY,OAAOJ,OAAOE,MAAMD,KAAKI,IAAI,KAAK,OAAO,UAAU;QAEjF,MAAMA,OAAOJ,KAAKI,IAAI,IAAI,CAAC,WAAW,EAAEJ,KAAKK,IAAI,CAAC,CAAC,CAAC;QACpD,OAAO,GAAGH,SAAS,UAAU,CAAC,CAAC,EAAEE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAEA,MAAM,GAAGL,OAAOE,OAAO;IACxE;IAEA,OAAOF,OAAOD,aAAaQ,KAAK,CAAC,IAAIA,KAAK,CAAC,GAAG,6CAA6C;;AAC7F;AAEA,OAAO,SAASC,sBACdC,aAA4E;IAE5E,MAAMC,SAASC,MAAMC,OAAO,CAACH,iBAAiBA,gBAAgB;QAACA;KAAc;IAC7E,OAAOC,OACJG,OAAO,CAAC,CAACC,QAAUA,MAAMC,QAAQ,CAACC,GAAG,CAAC,CAACC,UAAYA,QAAQC,QAAQ,GACnEC,QAAQ,CAAC,WACR,UACA;AACN;AAEA,OAAO,SAASC,uBAAuBC,UAA0C;IAC/E,IAAIC,2BAA2B;IAC/B,MAAMC,sBAAsE,CAAC;IAE7E,KAAK,MAAMT,SAASO,WAAY;QAC9B,MAAM,CAACG,aAAa,GAAGV,MAAMW,IAAI;QACjC,IAAI,CAACD,cAAc;QACnB,IAAIA,aAAapB,IAAI,KAAK,QAAQ;QAElC,MAAMsB,eACJF,aAAanB,IAAI,IAAI,CAAC,SAAS,EAAEmB,aAAalB,IAAI,CAAC,MAAM,EAAEgB,2BAA2B,CAAC,CAAC;QAE1F,IAAI,CAACC,mBAAmB,CAACG,aAAa,EAAE;YACtCH,mBAAmB,CAACG,aAAa,GAAG,EAAE;QACxC;QAEAH,mBAAmB,CAACG,aAAa,CAACC,IAAI,CAACb;IACzC;IAEA,MAAMc,mBAAmBC,OAAOC,OAAO,CAACP;IAExC,MAAMQ,YAAYH,iBACfI,QAAQ,CAAC,CAACC,GAAGC;QACZ,MAAM,CAACC,OAAOC,QAAQ,GAAGH;QACzB,MAAM,CAACI,OAAOC,QAAQ,GAAGJ;QACzB,MAAMK,SAAS1C,cAAc,CAACW,sBAAsB4B,SAAS;QAC7D,MAAMI,SAAS3C,cAAc,CAACW,sBAAsB8B,SAAS;QAC7D,IAAIC,WAAWC,QAAQ,OAAOL,MAAMM,aAAa,CAACJ,OAAO;QACzD,OAAOE,SAASC;IAClB,GACCxB,GAAG,CAAC,CAAC,CAACU,cAAchB,OAAO;QAC1B,MAAMgC,wBAAwBjD,QAC1BH,UAAU;YAAC;YAAW;SAAQ,EAAE,CAAC,CAAC,EAAEoC,aAAa,CAAC,CAAC,IACnD,CAAC,CAAC,EAAEA,aAAa,CAAC,CAAC;QAEvB,MAAMiB,SAAS,GAAGjD,OAAO,CAACc,sBAAsBE,QAAQ,CAAC,CAAC,EAAEgC,uBAAuB;QACnF,MAAME,OAAOlC,OACVsB,QAAQ,CACP,CAACC,GAAGC,IACFrC,cAAc,CAACW,sBAAsByB,GAAG,GAAGpC,cAAc,CAACW,sBAAsB0B,GAAG,EAEtFlB,GAAG,CAAC,CAACF;YACJ,MAAM+B,gBAAgB,CAAC,EAAE,EAAEvD,UAAU,QAAQQ,WAAWgB,MAAMW,IAAI,KAAK,WAAW;YAClF,MAAMqB,oBAAoBhC,MAAMC,QAAQ,CACrCiB,QAAQ,CAAC,CAACC,GAAGC,IAAMrC,cAAc,CAACoC,EAAEf,QAAQ,CAAC,GAAGrB,cAAc,CAACqC,EAAEhB,QAAQ,CAAC,EAC1EF,GAAG,CAAC,CAAC,EAAC+B,MAAM,EAAEC,OAAO,EAAE9B,QAAQ,EAAC;gBAC/B,MAAM+B,OAAOF,SAAS,CAAC,YAAY,EAAEvD,gBAAgBuD,SAAS,GAAG;gBACjE,OAAO,CAAC,IAAI,EAAExD,UAAU,CAAC2B,SAAS,CAAC,CAAC,EAAE8B,UAAUC,MAAM;YACxD,GACCC,IAAI,CAAC;YAER,OAAO,GAAGL,cAAc,EAAE,EAAEC,mBAAmB;QACjD,GACCI,IAAI,CAAC;QAER,OAAO,GAAGP,OAAO,EAAE,EAAEC,MAAM;IAC7B,GACCM,IAAI,CAAC;IAER,OAAOnB;AACT"}
@@ -1,22 +0,0 @@
1
- import { isAbsolute, relative } from 'node:path';
2
- import picomatch from 'picomatch';
3
- import { toForwardSlashes } from '../../util/toForwardSlashes.js';
4
- /**
5
- * Creates a pattern matcher function for schema watch patterns.
6
- * Normalizes file paths to forward slashes and makes them relative before matching.
7
- *
8
- * @param patterns - Array of glob patterns to match against
9
- * @returns Function that takes a file path and workDir, returns true if file matches any pattern
10
- * @internal
11
- */ export function createSchemaPatternMatcher(patterns) {
12
- const matcher = picomatch(patterns);
13
- return {
14
- isMatch: (filePath, workDir)=>{
15
- const relativePath = isAbsolute(filePath) ? relative(workDir, filePath) : filePath;
16
- const normalizedPath = toForwardSlashes(relativePath);
17
- return matcher(normalizedPath);
18
- }
19
- };
20
- }
21
-
22
- //# sourceMappingURL=matchSchemaPattern.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/schema/matchSchemaPattern.ts"],"sourcesContent":["import {isAbsolute, relative} from 'node:path'\n\nimport picomatch from 'picomatch'\n\nimport {toForwardSlashes} from '../../util/toForwardSlashes.js'\n\n/**\n * Creates a pattern matcher function for schema watch patterns.\n * Normalizes file paths to forward slashes and makes them relative before matching.\n *\n * @param patterns - Array of glob patterns to match against\n * @returns Function that takes a file path and workDir, returns true if file matches any pattern\n * @internal\n */\nexport function createSchemaPatternMatcher(patterns: string[]): {\n isMatch: (filePath: string, workDir: string) => boolean\n} {\n const matcher = picomatch(patterns)\n\n return {\n isMatch: (filePath: string, workDir: string): boolean => {\n const relativePath = isAbsolute(filePath) ? relative(workDir, filePath) : filePath\n const normalizedPath = toForwardSlashes(relativePath)\n return matcher(normalizedPath)\n },\n }\n}\n"],"names":["isAbsolute","relative","picomatch","toForwardSlashes","createSchemaPatternMatcher","patterns","matcher","isMatch","filePath","workDir","relativePath","normalizedPath"],"mappings":"AAAA,SAAQA,UAAU,EAAEC,QAAQ,QAAO,YAAW;AAE9C,OAAOC,eAAe,YAAW;AAEjC,SAAQC,gBAAgB,QAAO,iCAAgC;AAE/D;;;;;;;CAOC,GACD,OAAO,SAASC,2BAA2BC,QAAkB;IAG3D,MAAMC,UAAUJ,UAAUG;IAE1B,OAAO;QACLE,SAAS,CAACC,UAAkBC;YAC1B,MAAMC,eAAeV,WAAWQ,YAAYP,SAASQ,SAASD,YAAYA;YAC1E,MAAMG,iBAAiBR,iBAAiBO;YACxC,OAAOJ,QAAQK;QACjB;IACF;AACF"}
@@ -1,39 +0,0 @@
1
- import { mkdir, writeFile } from 'node:fs/promises';
2
- import { dirname } from 'node:path';
3
- import { studioWorkerTask } from '@sanity/cli-core';
4
- import { SchemaExtractionError } from './utils/SchemaExtractionError.js';
5
- /**
6
- * Core schema extraction logic.
7
- * Performs the extraction via worker and writes to file.
8
- * Throws SchemaExtractionError on failure.
9
- */ export async function runSchemaExtraction(extractOptions) {
10
- const { configPath, enforceRequiredFields, format, outputPath, workspace } = extractOptions;
11
- if (format !== 'groq-type-nodes') {
12
- throw new Error(`Unsupported format: "${format}"`);
13
- }
14
- const workDir = dirname(configPath);
15
- const outputDir = dirname(outputPath);
16
- const result = await studioWorkerTask(new URL('extractSanitySchema.worker.js', import.meta.url), {
17
- name: 'extractSanitySchema',
18
- studioRootPath: workDir,
19
- workerData: {
20
- configPath,
21
- enforceRequiredFields,
22
- workDir,
23
- workspaceName: workspace
24
- }
25
- });
26
- if (result.type === 'error') {
27
- throw new SchemaExtractionError(result.error, result.validation);
28
- }
29
- const schema = result.schema;
30
- // Ensure output directory exists
31
- await mkdir(outputDir, {
32
- recursive: true
33
- });
34
- // Write schema to file
35
- await writeFile(outputPath, `${JSON.stringify(schema, null, 2)}\n`);
36
- return schema;
37
- }
38
-
39
- //# sourceMappingURL=runSchemaExtraction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/schema/runSchemaExtraction.ts"],"sourcesContent":["import {mkdir, writeFile} from 'node:fs/promises'\nimport {dirname} from 'node:path'\n\nimport {studioWorkerTask} from '@sanity/cli-core'\nimport {type extractSchema as extractSchemaInternal} from '@sanity/schema/_internal'\n\nimport {type ExtractOptions} from './getExtractOptions.js'\nimport {type ExtractSchemaWorkerData, type ExtractSchemaWorkerError} from './types.js'\nimport {SchemaExtractionError} from './utils/SchemaExtractionError.js'\n\ninterface ExtractSchemaWorkerResult {\n schema: ReturnType<typeof extractSchemaInternal>\n type: 'success'\n}\n\ntype ExtractSchemaWorkerMessage = ExtractSchemaWorkerError | ExtractSchemaWorkerResult\n\n/**\n * Core schema extraction logic.\n * Performs the extraction via worker and writes to file.\n * Throws SchemaExtractionError on failure.\n */\nexport async function runSchemaExtraction(\n extractOptions: Omit<ExtractOptions, 'watchPatterns'>,\n): Promise<ReturnType<typeof extractSchemaInternal>> {\n const {configPath, enforceRequiredFields, format, outputPath, workspace} = extractOptions\n\n if (format !== 'groq-type-nodes') {\n throw new Error(`Unsupported format: \"${format}\"`)\n }\n\n const workDir = dirname(configPath)\n const outputDir = dirname(outputPath)\n\n const result = await studioWorkerTask<ExtractSchemaWorkerMessage>(\n new URL('extractSanitySchema.worker.js', import.meta.url),\n {\n name: 'extractSanitySchema',\n studioRootPath: workDir,\n workerData: {\n configPath,\n enforceRequiredFields,\n workDir,\n workspaceName: workspace,\n } satisfies ExtractSchemaWorkerData,\n },\n )\n\n if (result.type === 'error') {\n throw new SchemaExtractionError(result.error, result.validation)\n }\n\n const schema = result.schema\n\n // Ensure output directory exists\n await mkdir(outputDir, {recursive: true})\n\n // Write schema to file\n await writeFile(outputPath, `${JSON.stringify(schema, null, 2)}\\n`)\n\n return schema\n}\n"],"names":["mkdir","writeFile","dirname","studioWorkerTask","SchemaExtractionError","runSchemaExtraction","extractOptions","configPath","enforceRequiredFields","format","outputPath","workspace","Error","workDir","outputDir","result","URL","url","name","studioRootPath","workerData","workspaceName","type","error","validation","schema","recursive","JSON","stringify"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,SAAS,QAAO,mBAAkB;AACjD,SAAQC,OAAO,QAAO,YAAW;AAEjC,SAAQC,gBAAgB,QAAO,mBAAkB;AAKjD,SAAQC,qBAAqB,QAAO,mCAAkC;AAStE;;;;CAIC,GACD,OAAO,eAAeC,oBACpBC,cAAqD;IAErD,MAAM,EAACC,UAAU,EAAEC,qBAAqB,EAAEC,MAAM,EAAEC,UAAU,EAAEC,SAAS,EAAC,GAAGL;IAE3E,IAAIG,WAAW,mBAAmB;QAChC,MAAM,IAAIG,MAAM,CAAC,qBAAqB,EAAEH,OAAO,CAAC,CAAC;IACnD;IAEA,MAAMI,UAAUX,QAAQK;IACxB,MAAMO,YAAYZ,QAAQQ;IAE1B,MAAMK,SAAS,MAAMZ,iBACnB,IAAIa,IAAI,iCAAiC,YAAYC,GAAG,GACxD;QACEC,MAAM;QACNC,gBAAgBN;QAChBO,YAAY;YACVb;YACAC;YACAK;YACAQ,eAAeV;QACjB;IACF;IAGF,IAAII,OAAOO,IAAI,KAAK,SAAS;QAC3B,MAAM,IAAIlB,sBAAsBW,OAAOQ,KAAK,EAAER,OAAOS,UAAU;IACjE;IAEA,MAAMC,SAASV,OAAOU,MAAM;IAE5B,iCAAiC;IACjC,MAAMzB,MAAMc,WAAW;QAACY,WAAW;IAAI;IAEvC,uBAAuB;IACvB,MAAMzB,UAAUS,YAAY,GAAGiB,KAAKC,SAAS,CAACH,QAAQ,MAAM,GAAG,EAAE,CAAC;IAElE,OAAOA;AACT"}
@@ -1,10 +0,0 @@
1
- export class SchemaExtractionError extends Error {
2
- validation;
3
- constructor(message, validation){
4
- super(message);
5
- this.name = 'SchemaExtractionError';
6
- this.validation = validation;
7
- }
8
- }
9
-
10
- //# sourceMappingURL=SchemaExtractionError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/schema/utils/SchemaExtractionError.ts"],"sourcesContent":["import {type SchemaValidationProblemGroup} from '@sanity/types'\n\nexport class SchemaExtractionError extends Error {\n validation?: SchemaValidationProblemGroup[]\n\n constructor(message: string, validation?: SchemaValidationProblemGroup[]) {\n super(message)\n this.name = 'SchemaExtractionError'\n this.validation = validation\n }\n}\n"],"names":["SchemaExtractionError","Error","validation","message","name"],"mappings":"AAEA,OAAO,MAAMA,8BAA8BC;IACzCC,WAA2C;IAE3C,YAAYC,OAAe,EAAED,UAA2C,CAAE;QACxE,KAAK,CAACC;QACN,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACF,UAAU,GAAGA;IACpB;AACF"}
@@ -1,12 +0,0 @@
1
- import { resolveLocalPackage } from '@sanity/cli-core';
2
- /**
3
- * Extracts validation problem groups from a SchemaError.
4
- */ export async function extractValidationFromSchemaError(error, workDir) {
5
- const { SchemaError } = await resolveLocalPackage('sanity', workDir);
6
- if (error instanceof SchemaError) {
7
- return error.schema._validation;
8
- }
9
- return undefined;
10
- }
11
-
12
- //# sourceMappingURL=extractValidationFromSchemaError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/schema/utils/extractValidationFromSchemaError.ts"],"sourcesContent":["import {resolveLocalPackage} from '@sanity/cli-core'\nimport {type SchemaValidationProblemGroup} from '@sanity/types'\n\n/**\n * Extracts validation problem groups from a SchemaError.\n */\nexport async function extractValidationFromSchemaError(\n error: unknown,\n workDir: string,\n): Promise<SchemaValidationProblemGroup[] | undefined> {\n const {SchemaError} = await resolveLocalPackage<typeof import('sanity')>('sanity', workDir)\n\n if (error instanceof SchemaError) {\n return error.schema._validation\n }\n\n return undefined\n}\n"],"names":["resolveLocalPackage","extractValidationFromSchemaError","error","workDir","SchemaError","schema","_validation","undefined"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mBAAkB;AAGpD;;CAEC,GACD,OAAO,eAAeC,iCACpBC,KAAc,EACdC,OAAe;IAEf,MAAM,EAACC,WAAW,EAAC,GAAG,MAAMJ,oBAA6C,UAAUG;IAEnF,IAAID,iBAAiBE,aAAa;QAChC,OAAOF,MAAMG,MAAM,CAACC,WAAW;IACjC;IAEA,OAAOC;AACT"}