@sanity/cli 6.0.0-alpha.16 → 6.0.0-alpha.18

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 (152) hide show
  1. package/README.md +592 -470
  2. package/dist/SanityHelp.js +74 -21
  3. package/dist/SanityHelp.js.map +1 -1
  4. package/dist/actions/build/buildApp.js +42 -15
  5. package/dist/actions/build/buildApp.js.map +1 -1
  6. package/dist/actions/build/buildStudio.js +64 -45
  7. package/dist/actions/build/buildStudio.js.map +1 -1
  8. package/dist/actions/build/buildVendorDependencies.js +3 -16
  9. package/dist/actions/build/buildVendorDependencies.js.map +1 -1
  10. package/dist/actions/build/checkStudioDependencyVersions.js +7 -7
  11. package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -1
  12. package/dist/actions/build/createExternalFromImportMap.js +1 -1
  13. package/dist/actions/build/createExternalFromImportMap.js.map +1 -1
  14. package/dist/actions/build/determineBasePath.js +5 -2
  15. package/dist/actions/build/determineBasePath.js.map +1 -1
  16. package/dist/actions/build/handlePrereleaseVersions.js +44 -0
  17. package/dist/actions/build/handlePrereleaseVersions.js.map +1 -0
  18. package/dist/actions/build/types.js.map +1 -1
  19. package/dist/actions/dataset/create.js +7 -1
  20. package/dist/actions/dataset/create.js.map +1 -1
  21. package/dist/actions/dataset/resolveDataset.js +26 -0
  22. package/dist/actions/dataset/resolveDataset.js.map +1 -0
  23. package/dist/actions/deploy/deployApp.js +1 -8
  24. package/dist/actions/deploy/deployApp.js.map +1 -1
  25. package/dist/actions/deploy/deployStudio.js +1 -0
  26. package/dist/actions/deploy/deployStudio.js.map +1 -1
  27. package/dist/actions/dev/getDevServerConfig.js +5 -2
  28. package/dist/actions/dev/getDevServerConfig.js.map +1 -1
  29. package/dist/actions/dev/startStudioDevServer.js +8 -3
  30. package/dist/actions/dev/startStudioDevServer.js.map +1 -1
  31. package/dist/actions/documents/types.js.map +1 -1
  32. package/dist/actions/documents/validate.js +11 -2
  33. package/dist/actions/documents/validate.js.map +1 -1
  34. package/dist/actions/documents/validateDocuments.worker.js +2 -2
  35. package/dist/actions/documents/validateDocuments.worker.js.map +1 -1
  36. package/dist/actions/documents/validation/reporters/jsonReporter.js +1 -1
  37. package/dist/actions/documents/validation/reporters/jsonReporter.js.map +1 -1
  38. package/dist/actions/documents/validation/reporters/ndjsonReporter.js +1 -1
  39. package/dist/actions/documents/validation/reporters/ndjsonReporter.js.map +1 -1
  40. package/dist/actions/graphql/SchemaError.js +1 -1
  41. package/dist/actions/graphql/SchemaError.js.map +1 -1
  42. package/dist/actions/graphql/__tests__/fixtures/many-self-refs.js +540 -0
  43. package/dist/actions/graphql/__tests__/fixtures/many-self-refs.js.map +1 -0
  44. package/dist/actions/graphql/__tests__/fixtures/test-studio.js +1143 -0
  45. package/dist/actions/graphql/__tests__/fixtures/test-studio.js.map +1 -0
  46. package/dist/actions/graphql/__tests__/fixtures/union-refs.js +591 -0
  47. package/dist/actions/graphql/__tests__/fixtures/union-refs.js.map +1 -0
  48. package/dist/actions/graphql/__tests__/helpers.js +23 -0
  49. package/dist/actions/graphql/__tests__/helpers.js.map +1 -0
  50. package/dist/actions/graphql/extractFromSanitySchema.js +2 -1
  51. package/dist/actions/graphql/extractFromSanitySchema.js.map +1 -1
  52. package/dist/actions/graphql/gen1/generateTypeFilters.js +1 -1
  53. package/dist/actions/graphql/gen1/generateTypeFilters.js.map +1 -1
  54. package/dist/actions/graphql/gen1/generateTypeQueries.js +2 -1
  55. package/dist/actions/graphql/gen1/generateTypeQueries.js.map +1 -1
  56. package/dist/actions/graphql/gen2/generateTypeQueries.js +1 -1
  57. package/dist/actions/graphql/gen2/generateTypeQueries.js.map +1 -1
  58. package/dist/actions/graphql/gen3/generateTypeQueries.js +1 -1
  59. package/dist/actions/graphql/gen3/generateTypeQueries.js.map +1 -1
  60. package/dist/actions/graphql/getGraphQLAPIs.js +2 -10
  61. package/dist/actions/graphql/getGraphQLAPIs.js.map +1 -1
  62. package/dist/actions/graphql/getGraphQLAPIs.worker.js +1 -1
  63. package/dist/actions/graphql/getGraphQLAPIs.worker.js.map +1 -1
  64. package/dist/actions/graphql/types.js.map +1 -1
  65. package/dist/actions/init/bootstrapLocalTemplate.js +1 -1
  66. package/dist/actions/init/bootstrapLocalTemplate.js.map +1 -1
  67. package/dist/actions/manifest/extractAppManifest.js.map +1 -1
  68. package/dist/actions/manifest/extractManifest.js +3 -22
  69. package/dist/actions/manifest/extractManifest.js.map +1 -1
  70. package/dist/actions/manifest/extractManifest.worker.js +5 -1
  71. package/dist/actions/manifest/extractManifest.worker.js.map +1 -1
  72. package/dist/actions/manifest/types.js.map +1 -1
  73. package/dist/actions/schema/deploySchemas.js +57 -80
  74. package/dist/actions/schema/deploySchemas.js.map +1 -1
  75. package/dist/actions/schema/extractSanityWorkspace.worker.js +24 -0
  76. package/dist/actions/schema/extractSanityWorkspace.worker.js.map +1 -0
  77. package/dist/actions/schema/extractSchemaWatcher.js +1 -1
  78. package/dist/actions/schema/extractSchemaWatcher.js.map +1 -1
  79. package/dist/actions/schema/types.js +4 -0
  80. package/dist/actions/schema/types.js.map +1 -1
  81. package/dist/actions/schema/uniqueWorkspaces.worker.js +3 -1
  82. package/dist/actions/schema/uniqueWorkspaces.worker.js.map +1 -1
  83. package/dist/actions/schema/utils/schemaStoreValidation.js +1 -7
  84. package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
  85. package/dist/actions/schema/utils/uniqByProjectIdDataset.js +1 -1
  86. package/dist/actions/schema/utils/uniqByProjectIdDataset.js.map +1 -1
  87. package/dist/actions/schema/watchExtractSchema.js +2 -1
  88. package/dist/actions/schema/watchExtractSchema.js.map +1 -1
  89. package/dist/actions/versions/getFormatters.js +1 -1
  90. package/dist/actions/versions/getFormatters.js.map +1 -1
  91. package/dist/commands/backup/list.js +4 -1
  92. package/dist/commands/backup/list.js.map +1 -1
  93. package/dist/commands/dataset/copy.js +3 -1
  94. package/dist/commands/dataset/copy.js.map +1 -1
  95. package/dist/commands/dataset/create.js +12 -0
  96. package/dist/commands/dataset/create.js.map +1 -1
  97. package/dist/commands/dataset/embeddings/disable.js +62 -0
  98. package/dist/commands/dataset/embeddings/disable.js.map +1 -0
  99. package/dist/commands/dataset/embeddings/enable.js +128 -0
  100. package/dist/commands/dataset/embeddings/enable.js.map +1 -0
  101. package/dist/commands/dataset/embeddings/status.js +61 -0
  102. package/dist/commands/dataset/embeddings/status.js.map +1 -0
  103. package/dist/commands/debug.js +2 -1
  104. package/dist/commands/debug.js.map +1 -1
  105. package/dist/commands/documents/create.js +2 -1
  106. package/dist/commands/documents/create.js.map +1 -1
  107. package/dist/commands/graphql/deploy.js +1 -1
  108. package/dist/commands/graphql/deploy.js.map +1 -1
  109. package/dist/commands/hook/logs.js +1 -1
  110. package/dist/commands/hook/logs.js.map +1 -1
  111. package/dist/commands/init.js +13 -7
  112. package/dist/commands/init.js.map +1 -1
  113. package/dist/commands/manage.js +0 -1
  114. package/dist/commands/manage.js.map +1 -1
  115. package/dist/commands/media/create-aspect.js +1 -1
  116. package/dist/commands/media/create-aspect.js.map +1 -1
  117. package/dist/commands/projects/list.js +2 -1
  118. package/dist/commands/projects/list.js.map +1 -1
  119. package/dist/commands/schema/deploy.js +11 -27
  120. package/dist/commands/schema/deploy.js.map +1 -1
  121. package/dist/commands/users/list.js +1 -1
  122. package/dist/commands/users/list.js.map +1 -1
  123. package/dist/commands/versions.js +1 -1
  124. package/dist/commands/versions.js.map +1 -1
  125. package/dist/exports/index.d.ts +62 -2
  126. package/dist/exports/index.js.map +1 -1
  127. package/dist/prompts/selectMediaLibrary.js +1 -1
  128. package/dist/prompts/selectMediaLibrary.js.map +1 -1
  129. package/dist/services/datasets.js +7 -5
  130. package/dist/services/datasets.js.map +1 -1
  131. package/dist/services/embeddings.js +25 -0
  132. package/dist/services/embeddings.js.map +1 -0
  133. package/dist/services/graphql.js.map +1 -1
  134. package/dist/services/schemas.js +1 -1
  135. package/dist/services/schemas.js.map +1 -1
  136. package/dist/types.js.map +1 -1
  137. package/dist/util/compareDependencyVersions.js +28 -7
  138. package/dist/util/compareDependencyVersions.js.map +1 -1
  139. package/dist/util/errorMessages.js +0 -1
  140. package/dist/util/errorMessages.js.map +1 -1
  141. package/dist/util/packageManager/getPeerDependencies.js +44 -0
  142. package/dist/util/packageManager/getPeerDependencies.js.map +1 -0
  143. package/oclif.manifest.json +325 -191
  144. package/package.json +19 -20
  145. package/dist/actions/schema/schemaStoreTypes.js +0 -19
  146. package/dist/actions/schema/schemaStoreTypes.js.map +0 -1
  147. package/dist/actions/schema/utils/manifestExtractor.js +0 -29
  148. package/dist/actions/schema/utils/manifestExtractor.js.map +0 -1
  149. package/dist/actions/schema/utils/manifestReader.js +0 -71
  150. package/dist/actions/schema/utils/manifestReader.js.map +0 -1
  151. package/dist/util/workerChannels.js +0 -172
  152. package/dist/util/workerChannels.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "6.0.0-alpha.16",
3
+ "version": "6.0.0-alpha.18",
4
4
  "description": "Sanity CLI tool for managing Sanity projects and organizations",
5
5
  "keywords": [
6
6
  "sanity",
@@ -49,24 +49,25 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "@babel/traverse": "^7.29.0",
52
- "@oclif/core": "^4.8.0",
52
+ "@oclif/core": "^4.8.1",
53
53
  "@oclif/plugin-help": "^6.2.37",
54
54
  "@oclif/plugin-not-found": "^3.2.74",
55
55
  "@rexxars/gitconfiglocal": "^3.0.1",
56
- "@sanity/client": "^7.15.0",
57
- "@sanity/codegen": "^5.9.4",
56
+ "@sanity/client": "^7.16.0",
57
+ "@sanity/codegen": "^5.10.1",
58
58
  "@sanity/descriptors": "^1.3.0",
59
59
  "@sanity/export": "^6.0.5",
60
60
  "@sanity/generate-help-url": "^4.0.0",
61
61
  "@sanity/id-utils": "^1.0.0",
62
62
  "@sanity/import": "^4.1.2",
63
63
  "@sanity/migrate": "^5.2.5",
64
- "@sanity/runtime-cli": "^13.4.0",
65
- "@sanity/schema": "^5.11.0",
64
+ "@sanity/runtime-cli": "^14.1.0",
65
+ "@sanity/schema": "^5.12.0",
66
66
  "@sanity/telemetry": "^0.8.1",
67
67
  "@sanity/template-validator": "^3.0.0",
68
- "@sanity/types": "^5.11.0",
68
+ "@sanity/types": "^5.12.0",
69
69
  "@sanity/ui": "^3.1.11",
70
+ "@sanity/worker-channels": "^2.0.0",
70
71
  "@vercel/frameworks": "3.8.4",
71
72
  "@vercel/fs-detectors": "5.5.2",
72
73
  "@vitejs/plugin-react": "^5.1.4",
@@ -82,7 +83,6 @@
82
83
  "git-user-info": "^2.0.3",
83
84
  "gunzip-maybe": "^1.4.2",
84
85
  "import-meta-resolve": "^4.2.0",
85
- "install-peerdeps": "^3.0.7",
86
86
  "is-installed-globally": "^1.0.0",
87
87
  "is-tar": "^1.0.0",
88
88
  "isomorphic-dompurify": "^2.32.0",
@@ -111,7 +111,7 @@
111
111
  "semver": "^7.7.2",
112
112
  "semver-compare": "^1.0.0",
113
113
  "smol-toml": "^1.6.0",
114
- "tar": "^7.5.6",
114
+ "tar": "^7.5.9",
115
115
  "tar-fs": "^3.1.0",
116
116
  "tar-stream": "^3.1.7",
117
117
  "tinyglobby": "^0.2.15",
@@ -119,20 +119,20 @@
119
119
  "vite": "^7.3.1",
120
120
  "which": "^5.0.0",
121
121
  "zod": "^4.3.6",
122
- "@sanity/cli-core": "0.1.0-alpha.15"
122
+ "@sanity/cli-core": "0.1.0-alpha.17"
123
123
  },
124
124
  "devDependencies": {
125
125
  "@eslint/compat": "^2.0.2",
126
126
  "@sanity/pkg-utils": "^10.4.4",
127
127
  "@swc/cli": "^0.8.0",
128
- "@swc/core": "^1.15.11",
128
+ "@swc/core": "^1.15.13",
129
129
  "@types/babel__traverse": "^7.28.0",
130
130
  "@types/debug": "^4.1.12",
131
131
  "@types/gunzip-maybe": "^1.4.3",
132
132
  "@types/lodash-es": "^4.17.12",
133
133
  "@types/minimist": "^1.2.5",
134
- "@types/node": "^20.19.33",
135
- "@types/react": "^19.2.9",
134
+ "@types/node": "^20.19.35",
135
+ "@types/react": "^19.2.14",
136
136
  "@types/react-dom": "^19.2.3",
137
137
  "@types/react-is": "^19.2.0",
138
138
  "@types/semver": "^7.7.1",
@@ -141,22 +141,21 @@
141
141
  "@types/tar-stream": "^3.1.4",
142
142
  "@types/which": "^3.0.4",
143
143
  "@vitest/coverage-istanbul": "^4.0.18",
144
- "@vitest/utils": "^4.0.18",
145
144
  "babel-plugin-react-compiler": "^1.0.0",
146
- "eslint": "^9.39.2",
145
+ "eslint": "^9.39.3",
147
146
  "nock": "^14.0.11",
148
- "oclif": "^4.22.79",
147
+ "oclif": "^4.22.81",
149
148
  "prettier": "^3.8.1",
150
149
  "publint": "^0.3.17",
151
150
  "rimraf": "^6.0.1",
152
- "sanity": "^5.11.0",
151
+ "sanity": "^5.12.0",
153
152
  "typescript": "^5.9.3",
154
- "vite-tsconfig-paths": "^6.0.4",
153
+ "vite-tsconfig-paths": "^6.1.1",
155
154
  "vitest": "^4.0.18",
156
155
  "@repo/package.config": "0.0.1",
157
156
  "@repo/tsconfig": "3.70.0",
158
- "@sanity/cli-test": "0.0.2-alpha.14",
159
- "@sanity/eslint-config-cli": "0.0.0-alpha.2"
157
+ "@sanity/cli-test": "0.0.2-alpha.16",
158
+ "@sanity/eslint-config-cli": "0.0.0-alpha.3"
160
159
  },
161
160
  "engines": {
162
161
  "node": ">=20.19.1 <22 || >=22.12"
@@ -1,19 +0,0 @@
1
- /**
2
- * There is more context locally to decide how and when to log, depending on flags;
3
- * we therefore let actions log as soon as possible, possibly stopping stack unwinding.
4
- * This gives us more control over the color and detail of the error message, as well as ensuring
5
- * we dont double-log errors up the chain.
6
- *
7
- * Depending on flags, store actions can fail without throwing; to allow control flow to continue,
8
- * even in the face of failure (--schema-required ture/false for store)
9
- *
10
- * It is up to action to make this distinction based on flags.
11
- *
12
- * However, we _do_ want to ensure correct exit code on commands (0 vs 1), so
13
- * CLI command chains are stopped if a store command fails.
14
- *
15
- * Invalid flags will always throw.
16
- *
17
- */ export { };
18
-
19
- //# sourceMappingURL=schemaStoreTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/actions/schema/schemaStoreTypes.ts"],"sourcesContent":["/**\n * There is more context locally to decide how and when to log, depending on flags;\n * we therefore let actions log as soon as possible, possibly stopping stack unwinding.\n * This gives us more control over the color and detail of the error message, as well as ensuring\n * we dont double-log errors up the chain.\n *\n * Depending on flags, store actions can fail without throwing; to allow control flow to continue,\n * even in the face of failure (--schema-required ture/false for store)\n *\n * It is up to action to make this distinction based on flags.\n *\n * However, we _do_ want to ensure correct exit code on commands (0 vs 1), so\n * CLI command chains are stopped if a store command fails.\n *\n * Invalid flags will always throw.\n *\n */\nexport type SchemaStoreActionResult = 'failure' | 'success'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;CAgBC,GACD,WAA2D"}
@@ -1,29 +0,0 @@
1
- import { styleText } from 'node:util';
2
- import { extractManifestSafe } from '../../manifest/extractManifest.js';
3
- import { FlagValidationError } from './schemaStoreValidation.js';
4
- export async function ensureManifestExtractSatisfied(args) {
5
- const { extractManifest, manifestDir, manifestSafe, output, schemaRequired } = args;
6
- if (!extractManifest) {
7
- return true;
8
- }
9
- try {
10
- // a successful manifest extract will write a new manifest file, which manifestReader will then read from disk
11
- const error = await extractManifestSafe({
12
- outPath: manifestDir,
13
- output
14
- });
15
- if (!manifestSafe && error) {
16
- throw error;
17
- }
18
- return true;
19
- } catch (err) {
20
- if (schemaRequired || err instanceof FlagValidationError) {
21
- throw err;
22
- } else {
23
- output.log(styleText('gray', `↳ Failed to extract manifest:\n ${err.message}`));
24
- return false;
25
- }
26
- }
27
- }
28
-
29
- //# sourceMappingURL=manifestExtractor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/schema/utils/manifestExtractor.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\n\nimport {extractManifestSafe} from '../../manifest/extractManifest.js'\nimport {FlagValidationError} from './schemaStoreValidation.js'\n\nexport async function ensureManifestExtractSatisfied(args: {\n extractManifest: boolean\n manifestDir: string\n manifestSafe?: boolean\n output: Output\n schemaRequired?: boolean\n workDir: string\n}) {\n const {extractManifest, manifestDir, manifestSafe, output, schemaRequired} = args\n if (!extractManifest) {\n return true\n }\n try {\n // a successful manifest extract will write a new manifest file, which manifestReader will then read from disk\n const error = await extractManifestSafe({\n outPath: manifestDir,\n output,\n })\n\n if (!manifestSafe && error) {\n throw error\n }\n\n return true\n } catch (err) {\n if (schemaRequired || err instanceof FlagValidationError) {\n throw err\n } else {\n output.log(styleText('gray', `↳ Failed to extract manifest:\\n ${err.message}`))\n return false\n }\n }\n}\n"],"names":["styleText","extractManifestSafe","FlagValidationError","ensureManifestExtractSatisfied","args","extractManifest","manifestDir","manifestSafe","output","schemaRequired","error","outPath","err","log","message"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAInC,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,mBAAmB,QAAO,6BAA4B;AAE9D,OAAO,eAAeC,+BAA+BC,IAOpD;IACC,MAAM,EAACC,eAAe,EAAEC,WAAW,EAAEC,YAAY,EAAEC,MAAM,EAAEC,cAAc,EAAC,GAAGL;IAC7E,IAAI,CAACC,iBAAiB;QACpB,OAAO;IACT;IACA,IAAI;QACF,8GAA8G;QAC9G,MAAMK,QAAQ,MAAMT,oBAAoB;YACtCU,SAASL;YACTE;QACF;QAEA,IAAI,CAACD,gBAAgBG,OAAO;YAC1B,MAAMA;QACR;QAEA,OAAO;IACT,EAAE,OAAOE,KAAK;QACZ,IAAIH,kBAAkBG,eAAeV,qBAAqB;YACxD,MAAMU;QACR,OAAO;YACLJ,OAAOK,GAAG,CAACb,UAAU,QAAQ,CAAC,iCAAiC,EAAEY,IAAIE,OAAO,EAAE;YAC9E,OAAO;QACT;IACF;AACF"}
@@ -1,71 +0,0 @@
1
- import { readFile, stat } from 'node:fs/promises';
2
- import path, { join, resolve } from 'node:path';
3
- import { styleText } from 'node:util';
4
- import { MANIFEST_FILENAME } from '../../manifest/extractManifest.js';
5
- /**
6
- * The manifest reader will try to read manifest and workspace schema files _once_ and cache a successful result.
7
- * If you need to re-read the manifest from disk, create a new instance.
8
- */ export const createManifestReader = ({ manifestDir, output, workDir })=>{
9
- let parsedManifest;
10
- const parsedWorkspaces = {};
11
- const getManifest = async ()=>{
12
- if (parsedManifest) {
13
- return parsedManifest?.parsedJson;
14
- }
15
- const staticPath = resolve(join(workDir, manifestDir));
16
- const manifestFile = path.join(staticPath, MANIFEST_FILENAME);
17
- const result = await parseJsonFile(manifestFile);
18
- if (!result) {
19
- throw new Error(`Manifest does not exist at ${manifestFile}. To create the manifest file, omit --no-extract-manifest or run "sanity manifest extract" first.`);
20
- }
21
- output.log(styleText('gray', `↳ Read manifest from ${manifestFile} (last modified: ${result.lastModified})`));
22
- parsedManifest = result;
23
- return result.parsedJson;
24
- };
25
- const getWorkspaceSchema = async (workspaceName)=>{
26
- if (parsedWorkspaces[workspaceName]) {
27
- return parsedWorkspaces[workspaceName]?.parsedJson;
28
- }
29
- const manifest = await getManifest();
30
- if (!manifest) {
31
- throw new Error('Manifest is required to read workspace schema.');
32
- }
33
- const workspaceManifest = manifest.workspaces.find((workspace)=>workspace.name === workspaceName);
34
- if (!workspaceManifest) {
35
- throw new Error(`No workspace named "${workspaceName}" found in manifest.`);
36
- }
37
- const workspaceSchemaFile = path.join(manifestDir, workspaceManifest.schema);
38
- const result = await parseJsonFile(workspaceSchemaFile);
39
- if (!result) {
40
- throw new Error(`Workspace schema file at "${workspaceSchemaFile}" does not exist.`);
41
- }
42
- parsedWorkspaces[workspaceName] = result;
43
- return result.parsedJson;
44
- };
45
- return {
46
- getManifest,
47
- getWorkspaceSchema
48
- };
49
- };
50
- async function parseJsonFile(filePath) {
51
- let stats;
52
- try {
53
- stats = await stat(filePath);
54
- } catch {
55
- // file does not exist
56
- return undefined;
57
- }
58
- const content = await readFile(filePath, 'utf8');
59
- const lastModified = stats.mtime.toISOString();
60
- const json = JSON.parse(content);
61
- if (!json) {
62
- throw new Error(`JSON file "${filePath}" was empty.`);
63
- }
64
- return {
65
- lastModified,
66
- parsedJson: json,
67
- path: filePath
68
- };
69
- }
70
-
71
- //# sourceMappingURL=manifestReader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/actions/schema/utils/manifestReader.ts"],"sourcesContent":["import {type Stats} from 'node:fs'\nimport {readFile, stat} from 'node:fs/promises'\nimport path, {join, resolve} from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\n\nimport {MANIFEST_FILENAME} from '../../manifest/extractManifest.js'\nimport {type CreateManifest, type ManifestSchemaType} from '../../manifest/types.js'\n\ntype CreateManifestReaderFactory = (args: {\n manifestDir: string\n output: Output\n workDir: string\n}) => CreateManifestReader\n\nexport interface CreateManifestReader {\n getManifest: () => Promise<CreateManifest>\n getWorkspaceSchema: (workspaceName: string) => Promise<ManifestSchemaType[]>\n}\n\ninterface JsonFileParseSuccess<T> {\n lastModified: string\n parsedJson: T\n path: string\n}\n\n/**\n * The manifest reader will try to read manifest and workspace schema files _once_ and cache a successful result.\n * If you need to re-read the manifest from disk, create a new instance.\n */\nexport const createManifestReader: CreateManifestReaderFactory = ({\n manifestDir,\n output,\n workDir,\n}) => {\n let parsedManifest: JsonFileParseSuccess<CreateManifest>\n const parsedWorkspaces: Record<string, JsonFileParseSuccess<ManifestSchemaType[]> | undefined> =\n {}\n\n const getManifest: CreateManifestReader['getManifest'] = async () => {\n if (parsedManifest) {\n return parsedManifest?.parsedJson\n }\n\n const staticPath = resolve(join(workDir, manifestDir))\n const manifestFile = path.join(staticPath, MANIFEST_FILENAME)\n\n const result = await parseJsonFile<CreateManifest>(manifestFile)\n if (!result) {\n throw new Error(\n `Manifest does not exist at ${manifestFile}. To create the manifest file, omit --no-extract-manifest or run \"sanity manifest extract\" first.`,\n )\n }\n\n output.log(\n styleText(\n 'gray',\n `↳ Read manifest from ${manifestFile} (last modified: ${result.lastModified})`,\n ),\n )\n\n parsedManifest = result\n return result.parsedJson\n }\n\n const getWorkspaceSchema: CreateManifestReader['getWorkspaceSchema'] = async (workspaceName) => {\n if (parsedWorkspaces[workspaceName]) {\n return parsedWorkspaces[workspaceName]?.parsedJson\n }\n const manifest = await getManifest()\n if (!manifest) {\n throw new Error('Manifest is required to read workspace schema.')\n }\n\n const workspaceManifest = manifest.workspaces.find(\n (workspace) => workspace.name === workspaceName,\n )\n\n if (!workspaceManifest) {\n throw new Error(`No workspace named \"${workspaceName}\" found in manifest.`)\n }\n\n const workspaceSchemaFile = path.join(manifestDir, workspaceManifest.schema)\n const result = await parseJsonFile<ManifestSchemaType[]>(workspaceSchemaFile)\n if (!result) {\n throw new Error(`Workspace schema file at \"${workspaceSchemaFile}\" does not exist.`)\n }\n parsedWorkspaces[workspaceName] = result\n return result.parsedJson\n }\n return {\n getManifest,\n getWorkspaceSchema,\n }\n}\n\nasync function parseJsonFile<T>(filePath: string): Promise<JsonFileParseSuccess<T> | undefined> {\n let stats: Stats\n try {\n stats = await stat(filePath)\n } catch {\n // file does not exist\n return undefined\n }\n const content = await readFile(filePath, 'utf8')\n const lastModified = stats.mtime.toISOString()\n const json = JSON.parse(content) as T\n if (!json) {\n throw new Error(`JSON file \"${filePath}\" was empty.`)\n }\n return {\n lastModified,\n parsedJson: json,\n path: filePath,\n }\n}\n"],"names":["readFile","stat","path","join","resolve","styleText","MANIFEST_FILENAME","createManifestReader","manifestDir","output","workDir","parsedManifest","parsedWorkspaces","getManifest","parsedJson","staticPath","manifestFile","result","parseJsonFile","Error","log","lastModified","getWorkspaceSchema","workspaceName","manifest","workspaceManifest","workspaces","find","workspace","name","workspaceSchemaFile","schema","filePath","stats","undefined","content","mtime","toISOString","json","JSON","parse"],"mappings":"AACA,SAAQA,QAAQ,EAAEC,IAAI,QAAO,mBAAkB;AAC/C,OAAO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M,CAAC,0BAA0B,EAAEW,oBAAoB,iBAAiB,CAAC;QACrF;QACAlB,gBAAgB,CAACW,cAAc,GAAGN;QAClC,OAAOA,OAAOH,UAAU;IAC1B;IACA,OAAO;QACLD;QACAS;IACF;AACF,EAAC;AAED,eAAeJ,cAAiBc,QAAgB;IAC9C,IAAIC;IACJ,IAAI;QACFA,QAAQ,MAAMhC,KAAK+B;IACrB,EAAE,OAAM;QACN,sBAAsB;QACtB,OAAOE;IACT;IACA,MAAMC,UAAU,MAAMnC,SAASgC,UAAU;IACzC,MAAMX,eAAeY,MAAMG,KAAK,CAACC,WAAW;IAC5C,MAAMC,OAAOC,KAAKC,KAAK,CAACL;IACxB,IAAI,CAACG,MAAM;QACT,MAAM,IAAInB,MAAM,CAAC,WAAW,EAAEa,SAAS,YAAY,CAAC;IACtD;IACA,OAAO;QACLX;QACAP,YAAYwB;QACZpC,MAAM8B;IACR;AACF"}
@@ -1,172 +0,0 @@
1
- /**
2
- * A simple queue that has two primary methods: `push(message)` and
3
- * `await next()`. This message queue is used by the "receiver" of the worker
4
- * channel and this class handles buffering incoming messages if the worker is
5
- * producing faster than the parent as well as returning a promise if there is
6
- * no message yet in the queue when the parent awaits `next()`.
7
- */ class MessageQueue {
8
- queue = [];
9
- resolver = null;
10
- end() {
11
- if (this.resolver) {
12
- this.resolver({
13
- done: true,
14
- value: undefined
15
- });
16
- }
17
- }
18
- next() {
19
- if (this.queue.length > 0) {
20
- return Promise.resolve({
21
- done: false,
22
- value: this.queue.shift()
23
- });
24
- }
25
- return new Promise((resolve)=>this.resolver = resolve);
26
- }
27
- push(message) {
28
- if (this.resolver) {
29
- this.resolver({
30
- done: false,
31
- value: message
32
- });
33
- this.resolver = null;
34
- } else {
35
- this.queue.push(message);
36
- }
37
- }
38
- }
39
- function isWorkerChannelMessage(message) {
40
- if (typeof message !== 'object') return false;
41
- if (!message) return false;
42
- if (!('type' in message)) return false;
43
- if (typeof message.type !== 'string') return false;
44
- const types = [
45
- 'event',
46
- 'emission',
47
- 'end'
48
- ];
49
- return types.includes(message.type);
50
- }
51
- /**
52
- * Creates a "worker channel receiver" that subscribes to incoming messages
53
- * from the given worker and returns promises for worker channel events and
54
- * async iterators for worker channel streams.
55
- */ export function createReceiver(worker) {
56
- const _events = new Map();
57
- const _streams = new Map();
58
- const errors = new MessageQueue();
59
- const eventQueue = (name)=>{
60
- const queue = _events.get(name) ?? new MessageQueue();
61
- if (!_events.has(name)) _events.set(name, queue);
62
- return queue;
63
- };
64
- const streamQueue = (name)=>{
65
- const queue = _streams.get(name) ?? new MessageQueue();
66
- if (!_streams.has(name)) _streams.set(name, queue);
67
- return queue;
68
- };
69
- const handleMessage = (message)=>{
70
- if (!isWorkerChannelMessage(message)) return;
71
- if (message.type === 'event') eventQueue(message.name).push(message);
72
- if (message.type === 'emission') streamQueue(message.name).push(message);
73
- if (message.type === 'end') streamQueue(message.name).end();
74
- };
75
- const handleError = (error)=>{
76
- errors.push({
77
- error,
78
- type: 'error'
79
- });
80
- };
81
- worker.addListener('message', handleMessage);
82
- worker.addListener('error', handleError);
83
- return {
84
- dispose: ()=>{
85
- worker.removeListener('message', handleMessage);
86
- worker.removeListener('error', handleError);
87
- return worker.terminate();
88
- },
89
- event: new Proxy({}, {
90
- get: (target, name)=>{
91
- if (typeof name !== 'string') return target[name];
92
- const eventReceiver = async ()=>{
93
- const { value } = await Promise.race([
94
- eventQueue(name).next(),
95
- errors.next()
96
- ]);
97
- if (value.type === 'error') throw value.error;
98
- return value.payload;
99
- };
100
- return eventReceiver;
101
- }
102
- }),
103
- stream: new Proxy({}, {
104
- get: (target, prop)=>{
105
- if (typeof prop !== 'string') return target[prop];
106
- const name = prop // alias for better typescript narrowing
107
- ;
108
- async function* streamReceiver() {
109
- while(true){
110
- const { done, value } = await Promise.race([
111
- streamQueue(name).next(),
112
- errors.next()
113
- ]);
114
- if (done) return;
115
- if (value.type === 'error') throw value.error;
116
- yield value.payload;
117
- }
118
- }
119
- return streamReceiver;
120
- }
121
- })
122
- };
123
- }
124
- /**
125
- * Creates a "worker channel reporter" that sends messages to the given
126
- * `parentPort` to be received by a worker channel receiver.
127
- */ export function createReporter(parentPort) {
128
- if (!parentPort) {
129
- throw new Error('parentPart was falsy');
130
- }
131
- return {
132
- event: new Proxy({}, {
133
- get: (target, name)=>{
134
- if (typeof name !== 'string') return target[name];
135
- const eventReporter = (payload)=>{
136
- const message = {
137
- name,
138
- payload,
139
- type: 'event'
140
- };
141
- parentPort.postMessage(message);
142
- };
143
- return eventReporter;
144
- }
145
- }),
146
- stream: new Proxy({}, {
147
- get: (target, name)=>{
148
- if (typeof name !== 'string') return target[name];
149
- const streamReporter = {
150
- emit: (payload)=>{
151
- const message = {
152
- name,
153
- payload,
154
- type: 'emission'
155
- };
156
- parentPort.postMessage(message);
157
- },
158
- end: ()=>{
159
- const message = {
160
- name,
161
- type: 'end'
162
- };
163
- parentPort.postMessage(message);
164
- }
165
- };
166
- return streamReporter;
167
- }
168
- })
169
- };
170
- }
171
-
172
- //# sourceMappingURL=workerChannels.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/workerChannels.ts"],"sourcesContent":["import {type MessagePort, type Worker} from 'node:worker_threads'\n\ntype StreamReporter<TPayload = unknown> = {emit: (payload: TPayload) => void; end: () => void}\ntype EventReporter<TPayload = unknown> = (payload: TPayload) => void\ntype EventReceiver<TPayload = unknown> = () => Promise<TPayload>\ntype StreamReceiver<TPayload = unknown> = () => AsyncIterable<TPayload>\n\ntype EventKeys<TWorkerChannel extends WorkerChannel> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof TWorkerChannel]: TWorkerChannel[K] extends WorkerChannelEvent<any> ? K : never\n}[keyof TWorkerChannel]\ntype StreamKeys<TWorkerChannel extends WorkerChannel> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof TWorkerChannel]: TWorkerChannel[K] extends WorkerChannelStream<any> ? K : never\n}[keyof TWorkerChannel]\n\ntype EventMessage<TPayload = unknown> = {name: string; payload: TPayload; type: 'event'}\ntype StreamEmissionMessage<TPayload = unknown> = {name: string; payload: TPayload; type: 'emission'}\ntype StreamEndMessage = {name: string; type: 'end'}\ntype WorkerChannelMessage = EventMessage | StreamEmissionMessage | StreamEndMessage\n\n/**\n * Represents the definition of a \"worker channel\" to report progress from the\n * worker to the parent. Worker channels can define named events or streams and\n * the worker will report events and streams while the parent will await them.\n * This allows the control flow of the parent to follow the control flow of the\n * worker 1-to-1.\n */\nexport type WorkerChannel<\n TWorkerChannel extends Record<\n string,\n WorkerChannelEvent<unknown> | WorkerChannelStream<unknown>\n > = Record<string, WorkerChannelEvent<unknown> | WorkerChannelStream<unknown>>,\n> = TWorkerChannel\n\nexport type WorkerChannelEvent<TPayload = void> = {payload: TPayload; type: 'event'}\nexport type WorkerChannelStream<TPayload = void> = {\n payload: TPayload\n type: 'stream'\n}\n\ninterface WorkerChannelReporter<TWorkerChannel extends WorkerChannel> {\n event: {\n [K in EventKeys<TWorkerChannel>]: TWorkerChannel[K] extends WorkerChannelEvent<infer TPayload>\n ? EventReporter<TPayload>\n : void\n }\n stream: {\n [K in StreamKeys<TWorkerChannel>]: TWorkerChannel[K] extends WorkerChannelStream<infer TPayload>\n ? StreamReporter<TPayload>\n : void\n }\n}\n\nexport interface WorkerChannelReceiver<TWorkerChannel extends WorkerChannel> {\n // TODO: good candidate for [Symbol.asyncDispose] when our tooling better supports it\n dispose: () => Promise<number>\n event: {\n [K in EventKeys<TWorkerChannel>]: TWorkerChannel[K] extends WorkerChannelEvent<infer TPayload>\n ? EventReceiver<TPayload>\n : void\n }\n stream: {\n [K in StreamKeys<TWorkerChannel>]: TWorkerChannel[K] extends WorkerChannelStream<infer TPayload>\n ? StreamReceiver<TPayload>\n : void\n }\n}\n\n/**\n * A simple queue that has two primary methods: `push(message)` and\n * `await next()`. This message queue is used by the \"receiver\" of the worker\n * channel and this class handles buffering incoming messages if the worker is\n * producing faster than the parent as well as returning a promise if there is\n * no message yet in the queue when the parent awaits `next()`.\n */\nclass MessageQueue<T> {\n queue: T[] = []\n resolver: ((result: IteratorResult<T>) => void) | null = null\n\n end() {\n if (this.resolver) {\n this.resolver({done: true, value: undefined})\n }\n }\n\n next(): Promise<IteratorResult<T>> {\n if (this.queue.length > 0) {\n return Promise.resolve({done: false, value: this.queue.shift()!})\n }\n\n return new Promise((resolve) => (this.resolver = resolve))\n }\n\n push(message: T) {\n if (this.resolver) {\n this.resolver({done: false, value: message})\n this.resolver = null\n } else {\n this.queue.push(message)\n }\n }\n}\n\nfunction isWorkerChannelMessage(message: unknown): message is WorkerChannelMessage {\n if (typeof message !== 'object') return false\n if (!message) return false\n if (!('type' in message)) return false\n if (typeof message.type !== 'string') return false\n const types: string[] = ['event', 'emission', 'end'] satisfies WorkerChannelMessage['type'][]\n return types.includes(message.type)\n}\n\n/**\n * Creates a \"worker channel receiver\" that subscribes to incoming messages\n * from the given worker and returns promises for worker channel events and\n * async iterators for worker channel streams.\n */\nexport function createReceiver<TWorkerChannel extends WorkerChannel>(\n worker: Worker,\n): WorkerChannelReceiver<TWorkerChannel> {\n const _events = new Map<string, MessageQueue<EventMessage>>()\n const _streams = new Map<string, MessageQueue<StreamEmissionMessage>>()\n const errors = new MessageQueue<{error: unknown; type: 'error'}>()\n\n const eventQueue = (name: string) => {\n const queue = _events.get(name) ?? new MessageQueue()\n if (!_events.has(name)) _events.set(name, queue)\n return queue\n }\n\n const streamQueue = (name: string) => {\n const queue = _streams.get(name) ?? new MessageQueue()\n if (!_streams.has(name)) _streams.set(name, queue)\n return queue\n }\n\n const handleMessage = (message: unknown) => {\n if (!isWorkerChannelMessage(message)) return\n if (message.type === 'event') eventQueue(message.name).push(message)\n if (message.type === 'emission') streamQueue(message.name).push(message)\n if (message.type === 'end') streamQueue(message.name).end()\n }\n\n const handleError = (error: unknown) => {\n errors.push({error, type: 'error'})\n }\n\n worker.addListener('message', handleMessage)\n worker.addListener('error', handleError)\n\n return {\n dispose: () => {\n worker.removeListener('message', handleMessage)\n worker.removeListener('error', handleError)\n return worker.terminate()\n },\n event: new Proxy({} as WorkerChannelReceiver<TWorkerChannel>['event'], {\n get: (target, name) => {\n if (typeof name !== 'string') return target[name as keyof typeof target]\n\n const eventReceiver: EventReceiver = async () => {\n const {value} = await Promise.race([eventQueue(name).next(), errors.next()])\n if (value.type === 'error') throw value.error\n return value.payload\n }\n\n return eventReceiver\n },\n }),\n stream: new Proxy({} as WorkerChannelReceiver<TWorkerChannel>['stream'], {\n get: (target, prop) => {\n if (typeof prop !== 'string') return target[prop as keyof typeof target]\n const name = prop // alias for better typescript narrowing\n\n async function* streamReceiver() {\n while (true) {\n const {done, value} = await Promise.race([streamQueue(name).next(), errors.next()])\n if (done) return\n if (value.type === 'error') throw value.error\n yield value.payload\n }\n }\n\n return streamReceiver satisfies StreamReceiver\n },\n }),\n }\n}\n\n/**\n * Creates a \"worker channel reporter\" that sends messages to the given\n * `parentPort` to be received by a worker channel receiver.\n */\nexport function createReporter<TWorkerChannel extends WorkerChannel>(\n parentPort: MessagePort | null,\n): WorkerChannelReporter<TWorkerChannel> {\n if (!parentPort) {\n throw new Error('parentPart was falsy')\n }\n\n return {\n event: new Proxy({} as WorkerChannelReporter<TWorkerChannel>['event'], {\n get: (target, name) => {\n if (typeof name !== 'string') return target[name as keyof typeof target]\n\n const eventReporter: EventReporter = (payload) => {\n const message: EventMessage = {name, payload, type: 'event'}\n parentPort.postMessage(message)\n }\n\n return eventReporter\n },\n }),\n stream: new Proxy({} as WorkerChannelReporter<TWorkerChannel>['stream'], {\n get: (target, name) => {\n if (typeof name !== 'string') return target[name as keyof typeof target]\n\n const streamReporter: StreamReporter = {\n emit: (payload) => {\n const message: StreamEmissionMessage = {name, payload, type: 'emission'}\n parentPort.postMessage(message)\n },\n end: () => {\n const message: StreamEndMessage = {name, type: 'end'}\n parentPort.postMessage(message)\n },\n }\n\n return streamReporter\n },\n }),\n }\n}\n"],"names":["MessageQueue","queue","resolver","end","done","value","undefined","next","length","Promise","resolve","shift","push","message","isWorkerChannelMessage","type","types","includes","createReceiver","worker","_events","Map","_streams","errors","eventQueue","name","get","has","set","streamQueue","handleMessage","handleError","error","addListener","dispose","removeListener","terminate","event","Proxy","target","eventReceiver","race","payload","stream","prop","streamReceiver","createReporter","parentPort","Error","eventReporter","postMessage","streamReporter","emit"],"mappings":"AAqEA;;;;;;CAMC,GACD,MAAMA;IACJC,QAAa,EAAE,CAAA;IACfC,WAAyD,KAAI;IAE7DC,MAAM;QACJ,IAAI,IAAI,CAACD,QAAQ,EAAE;YACjB,IAAI,CAACA,QAAQ,CAAC;gBAACE,MAAM;gBAAMC,OAAOC;YAAS;QAC7C;IACF;IAEAC,OAAmC;QACjC,IAAI,IAAI,CAACN,KAAK,CAACO,MAAM,GAAG,GAAG;YACzB,OAAOC,QAAQC,OAAO,CAAC;gBAACN,MAAM;gBAAOC,OAAO,IAAI,CAACJ,KAAK,CAACU,KAAK;YAAG;QACjE;QAEA,OAAO,IAAIF,QAAQ,CAACC,UAAa,IAAI,CAACR,QAAQ,GAAGQ;IACnD;IAEAE,KAAKC,OAAU,EAAE;QACf,IAAI,IAAI,CAACX,QAAQ,EAAE;YACjB,IAAI,CAACA,QAAQ,CAAC;gBAACE,MAAM;gBAAOC,OAAOQ;YAAO;YAC1C,IAAI,CAACX,QAAQ,GAAG;QAClB,OAAO;YACL,IAAI,CAACD,KAAK,CAACW,IAAI,CAACC;QAClB;IACF;AACF;AAEA,SAASC,uBAAuBD,OAAgB;IAC9C,IAAI,OAAOA,YAAY,UAAU,OAAO;IACxC,IAAI,CAACA,SAAS,OAAO;IACrB,IAAI,CAAE,CAAA,UAAUA,OAAM,GAAI,OAAO;IACjC,IAAI,OAAOA,QAAQE,IAAI,KAAK,UAAU,OAAO;IAC7C,MAAMC,QAAkB;QAAC;QAAS;QAAY;KAAM;IACpD,OAAOA,MAAMC,QAAQ,CAACJ,QAAQE,IAAI;AACpC;AAEA;;;;CAIC,GACD,OAAO,SAASG,eACdC,MAAc;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