@sanity/cli 8.3.0 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/build/buildApp.js +14 -7
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStudio.js +3 -3
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/actions/deploy/deployApp.js +32 -25
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +2 -1
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js +2 -4
- package/dist/actions/deploy/deployStudioSchemasAndManifests.worker.js.map +1 -1
- package/dist/actions/deploy/deploymentPlan.js.map +1 -1
- package/dist/actions/dev/devAction.js +6 -4
- package/dist/actions/dev/devAction.js.map +1 -1
- package/dist/actions/dev/servers/getDevServerConfig.js +13 -6
- package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
- package/dist/actions/dev/servers/startAppDevServer.js +4 -2
- package/dist/actions/dev/servers/startAppDevServer.js.map +1 -1
- package/dist/actions/graphql/gen1/generateTypeFilters.js +1 -2
- package/dist/actions/graphql/gen1/generateTypeFilters.js.map +1 -1
- package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js +5 -2
- package/dist/actions/graphql/resolveGraphQLApisFromWorkspaces.js.map +1 -1
- package/dist/actions/init/templates/shopify.js +2 -1
- package/dist/actions/init/templates/shopify.js.map +1 -1
- package/dist/actions/manifest/extractManifest.js +5 -37
- package/dist/actions/manifest/extractManifest.js.map +1 -1
- package/dist/actions/manifest/extractStudioManifest.js +1 -1
- package/dist/actions/manifest/extractStudioManifest.js.map +1 -1
- package/dist/actions/preview/previewAction.js +1 -1
- package/dist/actions/preview/previewAction.js.map +1 -1
- package/dist/actions/schema/deleteSchemaAction.js +1 -1
- package/dist/actions/schema/deleteSchemaAction.js.map +1 -1
- package/dist/actions/schema/deploySchemas.js.map +1 -1
- package/dist/actions/schema/extractSanityWorkspace.worker.js +1 -1
- package/dist/actions/schema/extractSanityWorkspace.worker.js.map +1 -1
- package/dist/actions/schema/listSchemas.js +1 -1
- package/dist/actions/schema/listSchemas.js.map +1 -1
- package/dist/actions/schema/schemaTypeHelpers.js +5 -0
- package/dist/actions/schema/schemaTypeHelpers.js.map +1 -0
- package/dist/actions/schema/updateWorkspaceSchema.js +1 -1
- package/dist/actions/schema/updateWorkspaceSchema.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreValidation.js +2 -2
- package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
- package/dist/actions/schema/utils/workspaceSchemaId.js +1 -1
- package/dist/actions/schema/utils/workspaceSchemaId.js.map +1 -1
- package/dist/actions/versions/getFormatters.js +1 -2
- package/dist/actions/versions/getFormatters.js.map +1 -1
- package/dist/commands/documents/create.js +4 -4
- package/dist/commands/documents/create.js.map +1 -1
- package/dist/commands/hooks/logs.js +1 -2
- package/dist/commands/hooks/logs.js.map +1 -1
- package/dist/commands/projects/list.js +3 -5
- package/dist/commands/projects/list.js.map +1 -1
- package/dist/commands/undeploy.js +7 -5
- package/dist/commands/undeploy.js.map +1 -1
- package/dist/commands/users/list.js +3 -5
- package/dist/commands/users/list.js.map +1 -1
- package/dist/commands/versions.js +1 -2
- package/dist/commands/versions.js.map +1 -1
- package/dist/exports/_internal.d.ts +1 -67
- package/dist/exports/_internal.js +1 -1
- package/dist/exports/_internal.js.map +1 -1
- package/dist/exports/index.d.ts +2 -2
- package/dist/exports/index.js +2 -1
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/runtime.d.ts +2 -2
- package/dist/exports/runtime.js +1 -1
- package/dist/exports/runtime.js.map +1 -1
- package/dist/generated/apiRoutes.js +4 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/prompts/selectMediaLibrary.js +2 -3
- package/dist/prompts/selectMediaLibrary.js.map +1 -1
- package/dist/services/mintProject.js +27 -14
- package/dist/services/mintProject.js.map +1 -1
- package/dist/services/schemas.js.map +1 -1
- package/dist/services/userApplications.js.map +1 -1
- package/dist/util/determineIsApp.js +1 -1
- package/dist/util/determineIsApp.js.map +1 -1
- package/dist/util/sortRowsByColumn.js +23 -0
- package/dist/util/sortRowsByColumn.js.map +1 -0
- package/oclif.manifest.json +353 -353
- package/package.json +7 -10
- package/dist/actions/manifest/blockTypeTransformer.js +0 -67
- package/dist/actions/manifest/blockTypeTransformer.js.map +0 -1
- package/dist/actions/manifest/extractCoreAppManifest.js +0 -111
- package/dist/actions/manifest/extractCoreAppManifest.js.map +0 -1
- package/dist/actions/manifest/extractManifest.worker.js +0 -30
- package/dist/actions/manifest/extractManifest.worker.js.map +0 -1
- package/dist/actions/manifest/extractWorkspaceManifest.js +0 -72
- package/dist/actions/manifest/extractWorkspaceManifest.js.map +0 -1
- package/dist/actions/manifest/iconResolver.js +0 -36
- package/dist/actions/manifest/iconResolver.js.map +0 -1
- package/dist/actions/manifest/purifyConfig.js +0 -307
- package/dist/actions/manifest/purifyConfig.js.map +0 -1
- package/dist/actions/manifest/referenceTransformer.js +0 -51
- package/dist/actions/manifest/referenceTransformer.js.map +0 -1
- package/dist/actions/manifest/resolveSchemaIcon.js +0 -43
- package/dist/actions/manifest/resolveSchemaIcon.js.map +0 -1
- package/dist/actions/manifest/sanitizeIcon.js +0 -13
- package/dist/actions/manifest/sanitizeIcon.js.map +0 -1
- package/dist/actions/manifest/schemaTypeHelpers.js +0 -110
- package/dist/actions/manifest/schemaTypeHelpers.js.map +0 -1
- package/dist/actions/manifest/schemaTypeTransformer.js +0 -169
- package/dist/actions/manifest/schemaTypeTransformer.js.map +0 -1
- package/dist/actions/manifest/transformerUtils.js +0 -40
- package/dist/actions/manifest/transformerUtils.js.map +0 -1
- package/dist/actions/manifest/types.js +0 -13
- package/dist/actions/manifest/types.js.map +0 -1
- package/dist/actions/manifest/validationTransformer.js +0 -84
- package/dist/actions/manifest/validationTransformer.js.map +0 -1
- package/dist/actions/manifest/writeManifestFile.js +0 -29
- package/dist/actions/manifest/writeManifestFile.js.map +0 -1
- package/dist/actions/manifest/writeWorkspaceFiles.js +0 -30
- package/dist/actions/manifest/writeWorkspaceFiles.js.map +0 -1
- package/dist/actions/schema/uploadSchemaToLexicon.js +0 -91
- package/dist/actions/schema/uploadSchemaToLexicon.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"description": "Sanity CLI tool for managing Sanity projects and organizations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -87,7 +87,6 @@
|
|
|
87
87
|
"gunzip-maybe": "^1.4.2",
|
|
88
88
|
"import-meta-resolve": "^4.2.0",
|
|
89
89
|
"is-installed-globally": "^1.0.0",
|
|
90
|
-
"isomorphic-dompurify": "^2.36.0",
|
|
91
90
|
"json5": "^2.2.3",
|
|
92
91
|
"jsonc-parser": "^3.3.1",
|
|
93
92
|
"lodash-es": "^4.18.1",
|
|
@@ -102,7 +101,7 @@
|
|
|
102
101
|
"pretty-ms": "^9.3.0",
|
|
103
102
|
"promise-props-recursive": "^2.0.2",
|
|
104
103
|
"react": "^19.2.7",
|
|
105
|
-
"react-
|
|
104
|
+
"react-dom": "^19.2.7",
|
|
106
105
|
"rxjs": "^7.8.2",
|
|
107
106
|
"semver": "^7.8.1",
|
|
108
107
|
"skills": "^1.5.9",
|
|
@@ -120,14 +119,13 @@
|
|
|
120
119
|
"wrap-ansi": "^9.0.2",
|
|
121
120
|
"yaml": "^2.9.0",
|
|
122
121
|
"zod": "^4.4.3",
|
|
123
|
-
"@sanity/cli-build": "^
|
|
124
|
-
"@sanity/cli-core": "^3.
|
|
125
|
-
"@sanity/workbench-cli": "^2.
|
|
122
|
+
"@sanity/cli-build": "^6.0.1",
|
|
123
|
+
"@sanity/cli-core": "^3.4.0",
|
|
124
|
+
"@sanity/workbench-cli": "^2.2.2"
|
|
126
125
|
},
|
|
127
126
|
"devDependencies": {
|
|
128
127
|
"@eslint/compat": "^2.1.0",
|
|
129
128
|
"@sanity/pkg-utils": "^12.2.0",
|
|
130
|
-
"@sanity/ui": "^3.5.0",
|
|
131
129
|
"@swc/cli": "^0.8.1",
|
|
132
130
|
"@swc/core": "^1.15.43",
|
|
133
131
|
"@types/gunzip-maybe": "^1.4.3",
|
|
@@ -138,7 +136,6 @@
|
|
|
138
136
|
"@types/picomatch": "^4.0.3",
|
|
139
137
|
"@types/react": "^19.2.17",
|
|
140
138
|
"@types/react-dom": "^19.2.3",
|
|
141
|
-
"@types/react-is": "^19.2.0",
|
|
142
139
|
"@types/semver": "^7.7.1",
|
|
143
140
|
"@types/tar-fs": "^2.0.4",
|
|
144
141
|
"@types/tar-stream": "^3.1.4",
|
|
@@ -158,8 +155,8 @@
|
|
|
158
155
|
"vitest": "^4.1.11",
|
|
159
156
|
"@repo/package.config": "0.0.1",
|
|
160
157
|
"@repo/tsconfig": "3.70.0",
|
|
161
|
-
"@sanity/cli
|
|
162
|
-
"@sanity/
|
|
158
|
+
"@sanity/eslint-config-cli": "1.1.3",
|
|
159
|
+
"@sanity/cli-test": "14.0.0"
|
|
163
160
|
},
|
|
164
161
|
"peerDependencies": {
|
|
165
162
|
"babel-plugin-react-compiler": "*",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { isRecord, isString, isType } from './schemaTypeHelpers.js';
|
|
2
|
-
import { ensureString } from './transformerUtils.js';
|
|
3
|
-
/**
|
|
4
|
-
* Transforms a block schema type (Portable Text) to its manifest representation
|
|
5
|
-
*/ export function transformBlockType(blockType, context, transformType) {
|
|
6
|
-
if (blockType.jsonType !== 'object' || !isType(blockType, 'block')) {
|
|
7
|
-
return {};
|
|
8
|
-
}
|
|
9
|
-
const childrenField = blockType.fields?.find((field)=>field.name === 'children');
|
|
10
|
-
if (!childrenField) {
|
|
11
|
-
return {};
|
|
12
|
-
}
|
|
13
|
-
const ofType = childrenField.type.of;
|
|
14
|
-
if (!ofType) {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
const spanType = ofType.find((memberType)=>memberType.name === 'span');
|
|
18
|
-
if (!spanType) {
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
const inlineObjectTypes = ofType.filter((memberType)=>memberType.name !== 'span') || [];
|
|
22
|
-
return {
|
|
23
|
-
lists: resolveEnabledListItems(blockType),
|
|
24
|
-
marks: {
|
|
25
|
-
annotations: spanType.annotations.map((t)=>transformType(t, context)),
|
|
26
|
-
decorators: resolveEnabledDecorators(spanType)
|
|
27
|
-
},
|
|
28
|
-
of: inlineObjectTypes.map((t)=>transformType(t, context)),
|
|
29
|
-
styles: resolveEnabledStyles(blockType)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Resolves enabled styles from a block type
|
|
34
|
-
*/ function resolveEnabledStyles(blockType) {
|
|
35
|
-
const styleField = blockType.fields?.find((btField)=>btField.name === 'style');
|
|
36
|
-
return resolveTitleValueArray(styleField?.type?.options?.list);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Resolves enabled decorators from a span type
|
|
40
|
-
*/ function resolveEnabledDecorators(spanType) {
|
|
41
|
-
return 'decorators' in spanType ? resolveTitleValueArray(spanType.decorators) : undefined;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Resolves enabled list items from a block type
|
|
45
|
-
*/ function resolveEnabledListItems(blockType) {
|
|
46
|
-
const listField = blockType.fields?.find((btField)=>btField.name === 'listItem');
|
|
47
|
-
return resolveTitleValueArray(listField?.type?.options?.list);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Resolves an array of title/value objects
|
|
51
|
-
*/ function resolveTitleValueArray(possibleArray) {
|
|
52
|
-
if (!possibleArray || !Array.isArray(possibleArray)) {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
const titledValues = possibleArray.filter((d)=>isRecord(d) && !!d.value && isString(d.value)).map((item)=>{
|
|
56
|
-
return {
|
|
57
|
-
value: item.value,
|
|
58
|
-
...ensureString('title', item.title)
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
if (!titledValues?.length) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
return titledValues;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
//# sourceMappingURL=blockTypeTransformer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/manifest/blockTypeTransformer.ts"],"sourcesContent":["import {\n type ArraySchemaType,\n type ObjectSchemaType,\n type SchemaType,\n type SpanSchemaType,\n} from '@sanity/types'\n\nimport {isRecord, isString, isType} from './schemaTypeHelpers.js'\nimport {type Context, ensureString} from './transformerUtils.js'\nimport {type ManifestSchemaType, type ManifestTitledValue} from './types.js'\n\ntype TransformTypeFn = (type: SchemaType, context: Context) => ManifestSchemaType\n\n/**\n * Transforms a block schema type (Portable Text) to its manifest representation\n */\nexport function transformBlockType(\n blockType: SchemaType,\n context: Context,\n transformType: TransformTypeFn,\n): Pick<ManifestSchemaType, 'lists' | 'marks' | 'of' | 'styles'> | Record<string, never> {\n if (blockType.jsonType !== 'object' || !isType(blockType, 'block')) {\n return {}\n }\n\n const childrenField = blockType.fields?.find((field) => field.name === 'children') as\n | {type: ArraySchemaType}\n | undefined\n\n if (!childrenField) {\n return {}\n }\n const ofType = childrenField.type.of\n if (!ofType) {\n return {}\n }\n const spanType = ofType.find((memberType) => memberType.name === 'span') as\n | ObjectSchemaType\n | undefined\n if (!spanType) {\n return {}\n }\n const inlineObjectTypes = (ofType.filter((memberType) => memberType.name !== 'span') ||\n []) as ObjectSchemaType[]\n\n return {\n lists: resolveEnabledListItems(blockType),\n marks: {\n annotations: (spanType as SpanSchemaType).annotations.map((t) => transformType(t, context)),\n decorators: resolveEnabledDecorators(spanType),\n },\n of: inlineObjectTypes.map((t) => transformType(t, context)),\n styles: resolveEnabledStyles(blockType),\n }\n}\n\n/**\n * Resolves enabled styles from a block type\n */\nfunction resolveEnabledStyles(blockType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n const styleField = blockType.fields?.find((btField) => btField.name === 'style')\n return resolveTitleValueArray(styleField?.type?.options?.list)\n}\n\n/**\n * Resolves enabled decorators from a span type\n */\nfunction resolveEnabledDecorators(spanType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n return 'decorators' in spanType ? resolveTitleValueArray(spanType.decorators) : undefined\n}\n\n/**\n * Resolves enabled list items from a block type\n */\nfunction resolveEnabledListItems(blockType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n const listField = blockType.fields?.find((btField) => btField.name === 'listItem')\n return resolveTitleValueArray(listField?.type?.options?.list)\n}\n\n/**\n * Resolves an array of title/value objects\n */\nfunction resolveTitleValueArray(possibleArray: unknown): ManifestTitledValue[] | undefined {\n if (!possibleArray || !Array.isArray(possibleArray)) {\n return undefined\n }\n const titledValues = possibleArray\n .filter(\n (d): d is {title?: string; value: string} => isRecord(d) && !!d.value && isString(d.value),\n )\n .map((item) => {\n return {\n value: item.value,\n ...ensureString('title', item.title),\n } satisfies ManifestTitledValue\n })\n if (!titledValues?.length) {\n return undefined\n }\n\n return titledValues\n}\n"],"names":["isRecord","isString","isType","ensureString","transformBlockType","blockType","context","transformType","jsonType","childrenField","fields","find","field","name","ofType","type","of","spanType","memberType","inlineObjectTypes","filter","lists","resolveEnabledListItems","marks","annotations","map","t","decorators","resolveEnabledDecorators","styles","resolveEnabledStyles","styleField","btField","resolveTitleValueArray","options","list","undefined","listField","possibleArray","Array","isArray","titledValues","d","value","item","title","length"],"mappings":"AAOA,SAAQA,QAAQ,EAAEC,QAAQ,EAAEC,MAAM,QAAO,yBAAwB;AACjE,SAAsBC,YAAY,QAAO,wBAAuB;AAKhE;;CAEC,GACD,OAAO,SAASC,mBACdC,SAAqB,EACrBC,OAAgB,EAChBC,aAA8B;IAE9B,IAAI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,SAASC;AAC1D;AAEA;;CAEC,GACD,SAASF,uBAAuBK,aAAsB;IACpD,IAAI,CAACA,iBAAiB,CAACC,MAAMC,OAAO,CAACF,gBAAgB;QACnD,OAAOF;IACT;IACA,MAAMK,eAAeH,cAClBlB,MAAM,CACL,CAACsB,IAA4C1C,SAAS0C,MAAM,CAAC,CAACA,EAAEC,KAAK,IAAI1C,SAASyC,EAAEC,KAAK,GAE1FlB,GAAG,CAAC,CAACmB;QACJ,OAAO;YACLD,OAAOC,KAAKD,KAAK;YACjB,GAAGxC,aAAa,SAASyC,KAAKC,KAAK,CAAC;QACtC;IACF;IACF,IAAI,CAACJ,cAAcK,QAAQ;QACzB,OAAOV;IACT;IAEA,OAAOK;AACT"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { relative, resolve } from 'node:path';
|
|
3
|
-
import { doImport, getCliConfigUncached } from '@sanity/cli-core';
|
|
4
|
-
import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
5
|
-
import { spinner } from '@sanity/cli-core/ux';
|
|
6
|
-
import { isWorkbenchApp } from '@sanity/workbench-cli';
|
|
7
|
-
import { coreAppManifestSchema } from './types.js';
|
|
8
|
-
/**
|
|
9
|
-
* The title change a deploy would sync from the manifest to the user
|
|
10
|
-
* application, or null when the titles already match (or none is set).
|
|
11
|
-
*
|
|
12
|
-
* @internal
|
|
13
|
-
*/ export function resolveTitleUpdate(manifest, application) {
|
|
14
|
-
if (manifest?.title === undefined || manifest.title === application.title) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
from: application.title,
|
|
19
|
-
to: manifest.title
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
const sanitizeIconPath = new URL('sanitizeIcon.js', import.meta.url).href;
|
|
23
|
-
/**
|
|
24
|
-
* Lazy-load {@link sanitizeIconFn} so `isomorphic-dompurify` (and its jsdom
|
|
25
|
-
* dependency) stays out of the CLI's eager import graph. The studio manifest
|
|
26
|
-
* resolver lazy-loads its icon machinery for the same reason; this path runs in
|
|
27
|
-
* the main process (not the manifest worker), so only an app deploy that
|
|
28
|
-
* actually has an icon pays the cost.
|
|
29
|
-
*/ async function lazySanitizeIcon() {
|
|
30
|
-
const mod = await doImport(sanitizeIconPath);
|
|
31
|
-
return mod.sanitizeIcon;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Resolves app.icon from config (a file path) to a sanitized SVG string. Used
|
|
35
|
-
* both for the manifest and, on deploy, for the icon shipped to Brett — the
|
|
36
|
-
* manifest expects the SVG inline, not a path.
|
|
37
|
-
*
|
|
38
|
-
* The file is sanitized through the same allowlist as the studio manifest's
|
|
39
|
-
* icon resolver (see {@link lazySanitizeIcon}) so both manifest paths inline the
|
|
40
|
-
* same trusted subset of SVG markup.
|
|
41
|
-
* @internal
|
|
42
|
-
*/ export async function readIconFromPath(workDir, iconPath) {
|
|
43
|
-
const resolvedPath = resolve(workDir, iconPath);
|
|
44
|
-
const pathRelativeToWorkDir = relative(workDir, resolvedPath);
|
|
45
|
-
if (pathRelativeToWorkDir.startsWith('..')) {
|
|
46
|
-
throw new Error(`Icon path "${iconPath}" resolves outside the project directory and is not allowed.`);
|
|
47
|
-
}
|
|
48
|
-
let content;
|
|
49
|
-
try {
|
|
50
|
-
content = await readFile(resolvedPath, 'utf8');
|
|
51
|
-
} catch (err) {
|
|
52
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
53
|
-
throw new Error(`Could not read icon file at "${iconPath}" (resolved: ${resolvedPath}): ${message}`, {
|
|
54
|
-
cause: err
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const trimmed = content.trim();
|
|
58
|
-
if (!/<svg[\s>]/i.test(trimmed)) {
|
|
59
|
-
throw new Error(`Icon file at "${iconPath}" does not contain an SVG element. App manifest icons must be SVG files.`);
|
|
60
|
-
}
|
|
61
|
-
const sanitizeIcon = await lazySanitizeIcon();
|
|
62
|
-
return sanitizeIcon(trimmed);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Unlike studio manifest extraction, skips schema/tool parsing. The config's
|
|
66
|
-
* `app.icon` is a file path; its content is read and inlined in the manifest.
|
|
67
|
-
*/ export async function extractCoreAppManifest(options) {
|
|
68
|
-
const { workDir } = options;
|
|
69
|
-
const { app } = await getCliConfigUncached(workDir);
|
|
70
|
-
if (!app) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
const spin = spinner('Extracting manifest').start();
|
|
74
|
-
try {
|
|
75
|
-
let icon;
|
|
76
|
-
if (app.icon) {
|
|
77
|
-
icon = await readIconFromPath(workDir, app.icon);
|
|
78
|
-
}
|
|
79
|
-
if (!icon && !app.title) {
|
|
80
|
-
spin.info('Manifest creation skipped: no icon or title found in app configuration');
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
const workbench = isWorkbenchApp(app) ? app : undefined;
|
|
84
|
-
const manifest = coreAppManifestSchema.parse({
|
|
85
|
-
version: '1',
|
|
86
|
-
...icon ? {
|
|
87
|
-
icon
|
|
88
|
-
} : {},
|
|
89
|
-
...app.title ? {
|
|
90
|
-
title: app.title
|
|
91
|
-
} : {},
|
|
92
|
-
...workbench?.group ? {
|
|
93
|
-
group: workbench.group
|
|
94
|
-
} : {},
|
|
95
|
-
...workbench?.priority === undefined ? {} : {
|
|
96
|
-
priority: workbench.priority
|
|
97
|
-
},
|
|
98
|
-
...workbench?.slug ? {
|
|
99
|
-
slug: workbench.slug
|
|
100
|
-
} : {}
|
|
101
|
-
});
|
|
102
|
-
spin.succeed(`Extracted manifest`);
|
|
103
|
-
return manifest;
|
|
104
|
-
} catch (err) {
|
|
105
|
-
const message = getErrorMessage(err);
|
|
106
|
-
spin.fail(message);
|
|
107
|
-
throw err;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//# sourceMappingURL=extractCoreAppManifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/manifest/extractCoreAppManifest.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {relative, resolve} from 'node:path'\n\nimport {doImport, getCliConfigUncached} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {isWorkbenchApp} from '@sanity/workbench-cli'\n\nimport {type sanitizeIcon as sanitizeIconFn} from './sanitizeIcon.js'\nimport {type CoreAppManifest, coreAppManifestSchema} from './types.js'\n\ninterface ExtractCoreAppManifestOptions {\n workDir: string\n}\n\n/**\n * The title change a deploy would sync from the manifest to the user\n * application, or null when the titles already match (or none is set).\n *\n * @internal\n */\nexport function resolveTitleUpdate(\n manifest: CoreAppManifest | undefined,\n application: {title: string | null},\n): {from: string | null; to: string} | null {\n if (manifest?.title === undefined || manifest.title === application.title) {\n return null\n }\n return {from: application.title, to: manifest.title}\n}\n\nconst sanitizeIconPath = new URL('sanitizeIcon.js', import.meta.url).href\n\n/**\n * Lazy-load {@link sanitizeIconFn} so `isomorphic-dompurify` (and its jsdom\n * dependency) stays out of the CLI's eager import graph. The studio manifest\n * resolver lazy-loads its icon machinery for the same reason; this path runs in\n * the main process (not the manifest worker), so only an app deploy that\n * actually has an icon pays the cost.\n */\nasync function lazySanitizeIcon(): Promise<typeof sanitizeIconFn> {\n const mod = await doImport(sanitizeIconPath)\n return mod.sanitizeIcon\n}\n\n/**\n * Resolves app.icon from config (a file path) to a sanitized SVG string. Used\n * both for the manifest and, on deploy, for the icon shipped to Brett — the\n * manifest expects the SVG inline, not a path.\n *\n * The file is sanitized through the same allowlist as the studio manifest's\n * icon resolver (see {@link lazySanitizeIcon}) so both manifest paths inline the\n * same trusted subset of SVG markup.\n * @internal\n */\nexport async function readIconFromPath(workDir: string, iconPath: string): Promise<string> {\n const resolvedPath = resolve(workDir, iconPath)\n const pathRelativeToWorkDir = relative(workDir, resolvedPath)\n if (pathRelativeToWorkDir.startsWith('..')) {\n throw new Error(\n `Icon path \"${iconPath}\" resolves outside the project directory and is not allowed.`,\n )\n }\n\n let content: string\n try {\n content = await readFile(resolvedPath, 'utf8')\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(\n `Could not read icon file at \"${iconPath}\" (resolved: ${resolvedPath}): ${message}`,\n {cause: err},\n )\n }\n\n const trimmed = content.trim()\n if (!/<svg[\\s>]/i.test(trimmed)) {\n throw new Error(\n `Icon file at \"${iconPath}\" does not contain an SVG element. App manifest icons must be SVG files.`,\n )\n }\n\n const sanitizeIcon = await lazySanitizeIcon()\n return sanitizeIcon(trimmed)\n}\n\n/**\n * Unlike studio manifest extraction, skips schema/tool parsing. The config's\n * `app.icon` is a file path; its content is read and inlined in the manifest.\n */\nexport async function extractCoreAppManifest(\n options: ExtractCoreAppManifestOptions,\n): Promise<CoreAppManifest | undefined> {\n const {workDir} = options\n const {app} = await getCliConfigUncached(workDir)\n if (!app) {\n return undefined\n }\n\n const spin = spinner('Extracting manifest').start()\n\n try {\n let icon: string | undefined\n if (app.icon) {\n icon = await readIconFromPath(workDir, app.icon)\n }\n\n if (!icon && !app.title) {\n spin.info('Manifest creation skipped: no icon or title found in app configuration')\n return undefined\n }\n\n const workbench = isWorkbenchApp(app) ? app : undefined\n\n const manifest: CoreAppManifest = coreAppManifestSchema.parse({\n version: '1',\n ...(icon ? {icon} : {}),\n ...(app.title ? {title: app.title} : {}),\n ...(workbench?.group ? {group: workbench.group} : {}),\n ...(workbench?.priority === undefined ? {} : {priority: workbench.priority}),\n ...(workbench?.slug ? {slug: workbench.slug} : {}),\n })\n\n spin.succeed(`Extracted manifest`)\n\n return manifest\n } catch (err) {\n const message = getErrorMessage(err)\n spin.fail(message)\n throw err\n }\n}\n"],"names":["readFile","relative","resolve","doImport","getCliConfigUncached","getErrorMessage","spinner","isWorkbenchApp","coreAppManifestSchema","resolveTitleUpdate","manifest","application","title","undefined","from","to","sanitizeIconPath","URL","url","href","lazySanitizeIcon","mod","sanitizeIcon","readIconFromPath","workDir","iconPath","resolvedPath","pathRelativeToWorkDir","startsWith","Error","content","err","message","String","cause","trimmed","trim","test","extractCoreAppManifest","options","app","spin","start","icon","info","workbench","parse","version","group","priority","slug","succeed","fail"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,QAAQ,EAAEC,OAAO,QAAO,YAAW;AAE3C,SAAQC,QAAQ,EAAEC,oBAAoB,QAAO,mBAAkB;AAC/D,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,cAAc,QAAO,wBAAuB;AAGpD,SAA8BC,qBAAqB,QAAO,aAAY;AAMtE;;;;;CAKC,GACD,OAAO,SAASC,mBACdC,QAAqC,EACrCC,WAAmC;IAEnC,IAAID,UAAUE,UAAUC,aAAaH,SAASE,KAAK,KAAKD,YAAYC,KAAK,EAAE;QACzE,OAAO;IACT;IACA,OAAO;QAACE,MAAMH,YAAYC,KAAK;QAAEG,IAAIL,SAASE,KAAK;IAAA;AACrD;AAEA,MAAMI,mBAAmB,IAAIC,IAAI,mBAAmB,YAAYC,GAAG,EAAEC,IAAI;AAEzE;;;;;;CAMC,GACD,eAAeC;IACb,MAAMC,MAAM,MAAMlB,SAASa;IAC3B,OAAOK,IAAIC,YAAY;AACzB;AAEA;;;;;;;;;CASC,GACD,OAAO,eAAeC,iBAAiBC,OAAe,EAAEC,QAAgB;IACtE,MAAMC,eAAexB,QAAQsB,SAASC;IACtC,MAAME,wBAAwB1B,SAASuB,SAASE;IAChD,IAAIC,sBAAsBC,UAAU,CAAC,OAAO;QAC1C,MAAM,IAAIC,MACR,CAAC,WAAW,EAAEJ,SAAS,4DAA4D,CAAC;IAExF;IAEA,IAAIK;IACJ,IAAI;QACFA,UAAU,MAAM9B,SAAS0B,cAAc;IACzC,EAAE,OAAOK,KAAK;QACZ,MAAMC,UAAUD,eAAeF,QAAQE,IAAIC,OAAO,GAAGC,OAAOF;QA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UK,IAAI;YAAA,IAAI,CAAC,CAAC;QACnD;QAEAT,KAAKU,OAAO,CAAC,CAAC,kBAAkB,CAAC;QAEjC,OAAOzC;IACT,EAAE,OAAOqB,KAAK;QACZ,MAAMC,UAAU3B,gBAAgB0B;QAChCU,KAAKW,IAAI,CAACpB;QACV,MAAMD;IACR;AACF"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
|
|
2
|
-
import { extractValidationFromSchemaError } from '@sanity/cli-build/_internal/extract';
|
|
3
|
-
import { getStudioWorkspaces, subdebug } from '@sanity/cli-core';
|
|
4
|
-
import { extractWorkspaceManifest } from './extractWorkspaceManifest.js';
|
|
5
|
-
import { extractManifestWorkerData } from './types.js';
|
|
6
|
-
if (isMainThread || !parentPort) {
|
|
7
|
-
throw new Error('Should only be run in a worker!');
|
|
8
|
-
}
|
|
9
|
-
const debug = subdebug('extractManifest.worker');
|
|
10
|
-
const { configPath, workDir } = extractManifestWorkerData.parse(workerData);
|
|
11
|
-
try {
|
|
12
|
-
debug('Extracting workspace manifests from config path %s', configPath);
|
|
13
|
-
const workspaces = await getStudioWorkspaces(configPath);
|
|
14
|
-
debug('Workspaces %o', workspaces);
|
|
15
|
-
const workspaceManifests = await extractWorkspaceManifest(workspaces, workDir);
|
|
16
|
-
parentPort.postMessage({
|
|
17
|
-
type: 'success',
|
|
18
|
-
workspaceManifests
|
|
19
|
-
});
|
|
20
|
-
} catch (error) {
|
|
21
|
-
debug('Error extracting workspace manifests', error);
|
|
22
|
-
const validation = await extractValidationFromSchemaError(error, workDir);
|
|
23
|
-
parentPort.postMessage({
|
|
24
|
-
error: error instanceof Error ? error.message : String(error),
|
|
25
|
-
type: 'error',
|
|
26
|
-
validation
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=extractManifest.worker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/manifest/extractManifest.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {extractValidationFromSchemaError} from '@sanity/cli-build/_internal/extract'\nimport {getStudioWorkspaces, subdebug} from '@sanity/cli-core'\n\nimport {extractWorkspaceManifest} from './extractWorkspaceManifest.js'\nimport {extractManifestWorkerData} from './types.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst debug = subdebug('extractManifest.worker')\n\nconst {configPath, workDir} = extractManifestWorkerData.parse(workerData)\n\ntry {\n debug('Extracting workspace manifests from config path %s', configPath)\n const workspaces = await getStudioWorkspaces(configPath)\n debug('Workspaces %o', workspaces)\n const workspaceManifests = await extractWorkspaceManifest(workspaces, workDir)\n\n parentPort.postMessage({\n type: 'success',\n workspaceManifests,\n })\n} catch (error) {\n debug('Error extracting workspace manifests', 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","extractValidationFromSchemaError","getStudioWorkspaces","subdebug","extractWorkspaceManifest","extractManifestWorkerData","Error","debug","configPath","workDir","parse","workspaces","workspaceManifests","postMessage","type","error","validation","message","String"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,gCAAgC,QAAO,sCAAqC;AACpF,SAAQC,mBAAmB,EAAEC,QAAQ,QAAO,mBAAkB;AAE9D,SAAQC,wBAAwB,QAAO,gCAA+B;AACtE,SAAQC,yBAAyB,QAAO,aAAY;AAEpD,IAAIP,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIO,MAAM;AAClB;AAEA,MAAMC,QAAQJ,SAAS;AAEvB,MAAM,EAACK,UAAU,EAAEC,OAAO,EAAC,GAAGJ,0BAA0BK,KAAK,CAACV;AAE9D,IAAI;IACFO,MAAM,sDAAsDC;IAC5D,MAAMG,aAAa,MAAMT,oBAAoBM;IAC7CD,MAAM,iBAAiBI;IACvB,MAAMC,qBAAqB,MAAMR,yBAAyBO,YAAYF;IAEtEV,WAAWc,WAAW,CAAC;QACrBC,MAAM;QACNF;IACF;AACF,EAAE,OAAOG,OAAO;IACdR,MAAM,wCAAwCQ;IAC9C,MAAMC,aAAa,MAAMf,iCAAiCc,OAAON;IACjEV,WAAWc,WAAW,CAAC;QACrBE,OAAOA,iBAAiBT,QAAQS,MAAME,OAAO,GAAGC,OAAOH;QACvDD,MAAM;QACNE;IACF;AACF"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { doImport, resolveLocalPackage } from '@sanity/cli-core';
|
|
2
|
-
import { transformType } from './schemaTypeTransformer.js';
|
|
3
|
-
const iconResolverPath = new URL('iconResolver.js', import.meta.url).href;
|
|
4
|
-
async function lazyResolveIcon() {
|
|
5
|
-
const mod = await doImport(iconResolverPath);
|
|
6
|
-
return mod.resolveIcon;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Extracts manifest data from an array of workspaces
|
|
10
|
-
*/ export async function extractWorkspaceManifest(workspaces, workDir) {
|
|
11
|
-
const resolveIcon = await lazyResolveIcon();
|
|
12
|
-
return Promise.all(workspaces.map(async (workspace)=>{
|
|
13
|
-
const [icon, serializedSchema, serializedTools] = await Promise.all([
|
|
14
|
-
resolveIcon({
|
|
15
|
-
icon: workspace.icon,
|
|
16
|
-
subtitle: workspace.subtitle,
|
|
17
|
-
title: workspace.title,
|
|
18
|
-
workDir
|
|
19
|
-
}),
|
|
20
|
-
extractManifestSchemaTypes(workspace.schema, workDir),
|
|
21
|
-
extractManifestTools(workspace.tools, workDir, resolveIcon)
|
|
22
|
-
]);
|
|
23
|
-
return {
|
|
24
|
-
basePath: workspace.basePath,
|
|
25
|
-
dataset: workspace.dataset,
|
|
26
|
-
icon,
|
|
27
|
-
mediaLibrary: workspace.mediaLibrary,
|
|
28
|
-
name: workspace.name,
|
|
29
|
-
projectId: workspace.projectId,
|
|
30
|
-
schema: serializedSchema,
|
|
31
|
-
subtitle: workspace.subtitle,
|
|
32
|
-
title: workspace.title,
|
|
33
|
-
tools: serializedTools
|
|
34
|
-
};
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Extracts all serializable properties from userland schema types,
|
|
39
|
-
* so they best-effort can be used as definitions for Schema.compile.
|
|
40
|
-
*
|
|
41
|
-
* @internal
|
|
42
|
-
*/ export async function extractManifestSchemaTypes(schema, workDir) {
|
|
43
|
-
const typeNames = schema.getTypeNames();
|
|
44
|
-
const context = {
|
|
45
|
-
schema
|
|
46
|
-
};
|
|
47
|
-
const { createSchema } = await resolveLocalPackage('sanity', workDir);
|
|
48
|
-
const studioDefaultTypeNames = createSchema({
|
|
49
|
-
name: 'default',
|
|
50
|
-
types: []
|
|
51
|
-
}).getTypeNames();
|
|
52
|
-
return typeNames.filter((typeName)=>!studioDefaultTypeNames.includes(typeName)).map((typeName)=>schema.get(typeName)).filter((type)=>type !== undefined).map((type)=>transformType(type, context));
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Extracts tool information from workspace tools
|
|
56
|
-
*/ const extractManifestTools = async (tools, workDir, resolveIcon)=>{
|
|
57
|
-
return Promise.all(tools.map(async (tool)=>{
|
|
58
|
-
const { __internalApplicationType: type, icon, name, title } = tool;
|
|
59
|
-
return {
|
|
60
|
-
icon: await resolveIcon({
|
|
61
|
-
icon: icon,
|
|
62
|
-
title,
|
|
63
|
-
workDir
|
|
64
|
-
}),
|
|
65
|
-
name,
|
|
66
|
-
title,
|
|
67
|
-
type: type || null
|
|
68
|
-
};
|
|
69
|
-
}));
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
//# sourceMappingURL=extractWorkspaceManifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/manifest/extractWorkspaceManifest.ts"],"sourcesContent":["import {doImport, resolveLocalPackage} from '@sanity/cli-core'\nimport {type Schema} from '@sanity/types'\nimport {type Workspace} from 'sanity'\n\nimport {type resolveIcon as resolveIconFn} from './iconResolver.js'\nimport {type SchemaIconProps} from './resolveSchemaIcon.js'\nimport {transformType} from './schemaTypeTransformer.js'\nimport {type CreateWorkspaceManifest, type ManifestSchemaType, type ManifestTool} from './types.js'\n\nconst iconResolverPath = new URL('iconResolver.js', import.meta.url).href\n\nasync function lazyResolveIcon(): Promise<typeof resolveIconFn> {\n const mod = await doImport(iconResolverPath)\n return mod.resolveIcon\n}\n\n/**\n * Extracts manifest data from an array of workspaces\n */\nexport async function extractWorkspaceManifest(\n workspaces: Workspace[],\n workDir: string,\n): Promise<CreateWorkspaceManifest[]> {\n const resolveIcon = await lazyResolveIcon()\n return Promise.all(\n workspaces.map(async (workspace) => {\n const [icon, serializedSchema, serializedTools] = await Promise.all([\n resolveIcon({\n icon: workspace.icon,\n subtitle: workspace.subtitle,\n title: workspace.title,\n workDir,\n }),\n extractManifestSchemaTypes(workspace.schema as Schema, workDir),\n extractManifestTools(workspace.tools, workDir, resolveIcon),\n ])\n\n return {\n basePath: workspace.basePath,\n dataset: workspace.dataset,\n icon,\n mediaLibrary: workspace.mediaLibrary,\n name: workspace.name,\n projectId: workspace.projectId,\n schema: serializedSchema,\n subtitle: workspace.subtitle,\n title: workspace.title,\n tools: serializedTools,\n }\n }),\n )\n}\n\n/**\n * Extracts all serializable properties from userland schema types,\n * so they best-effort can be used as definitions for Schema.compile.\n *\n * @internal\n */\nexport async function extractManifestSchemaTypes(\n schema: Schema,\n workDir: string,\n): Promise<ManifestSchemaType[]> {\n const typeNames = schema.getTypeNames()\n const context = {schema}\n\n const {createSchema} = await resolveLocalPackage<typeof import('sanity')>('sanity', workDir)\n\n const studioDefaultTypeNames = createSchema({name: 'default', types: []}).getTypeNames()\n\n return typeNames\n .filter((typeName) => !studioDefaultTypeNames.includes(typeName))\n .map((typeName) => schema.get(typeName))\n .filter((type): type is NonNullable<typeof type> => type !== undefined)\n .map((type) => transformType(type, context))\n}\n\n/**\n * Extracts tool information from workspace tools\n */\nconst extractManifestTools = async (\n tools: Workspace['tools'],\n workDir: string,\n resolveIcon: typeof resolveIconFn,\n): Promise<ManifestTool[]> => {\n return Promise.all(\n tools.map(async (tool) => {\n const {\n __internalApplicationType: type,\n icon,\n name,\n title,\n } = tool as Workspace['tools'][number] & {__internalApplicationType: string}\n return {\n icon: await resolveIcon({\n icon: icon as SchemaIconProps['icon'],\n title,\n workDir,\n }),\n name,\n title,\n type: type || null,\n } satisfies ManifestTool\n }),\n )\n}\n"],"names":["doImport","resolveLocalPackage","transformType","iconResolverPath","URL","url","href","lazyResolveIcon","mod","resolveIcon","extractWorkspaceManifest","workspaces","workDir","Promise","all","map","workspace","icon","serializedSchema","serializedTools","subtitle","title","extractManifestSchemaTypes","schema","extractManifestTools","tools","basePath","dataset","mediaLibrary","name","projectId","typeNames","getTypeNames","context","createSchema","studioDefaultTypeNames","types","filter","typeName","includes","get","type","undefined","tool","__internalApplicationType"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,mBAAmB,QAAO,mBAAkB;AAM9D,SAAQC,aAAa,QAAO,6BAA4B;AAGxD,MAAMC,mBAAmB,IAAIC,IAAI,mBAAmB,YAAYC,GAAG,EAAEC,IAAI;AAEzE,eAAeC;IACb,MAAMC,MAAM,MAAMR,SAASG;IAC3B,OAAOK,IAAIC,WAAW;AACxB;AAEA;;CAEC,GACD,OAAO,eAAeC,yBACpBC,UAAuB,EACvBC,OAAe;IAEf,MAAMH,cAAc,MAAMF;IAC1B,OAAOM,QAAQC,GAAG,CAChBH,WAAWI,GAAG,CAAC,OAAOC;QACpB,MAAM,CAACC,MAAMC,kBAAkBC,gBAAgB,GAAG,MAAMN,QAAQC,GAAG,CAAC;YAClEL,YAAY;gBACVQ,MAAMD,UAAUC,IAAI;gBACpBG,UAAUJ,UAAUI,QAAQ;gBAC5BC,OAAOL,UAAUK,KAAK;gBACtBT;YACF;YACAU,2BAA2BN,UAAUO,MA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-
import { manifestDebug } from './debug.js';
|
|
3
|
-
import { resolveSchemaIcon } from './resolveSchemaIcon.js';
|
|
4
|
-
import { sanitizeIcon } from './sanitizeIcon.js';
|
|
5
|
-
/**
|
|
6
|
-
* Resolves an icon to a sanitized HTML string.
|
|
7
|
-
* Uses react-dom/server to capture styles during SSR.
|
|
8
|
-
*
|
|
9
|
-
* react-dom/server is resolved from the studio's working directory to ensure
|
|
10
|
-
* the same React instance is used by both the server renderer and the studio's
|
|
11
|
-
* components. Using the CLI's own react-dom/server would cause a dual-React
|
|
12
|
-
* instance problem where the dispatcher set by one instance is invisible to the other.
|
|
13
|
-
*/ export const resolveIcon = async (props)=>{
|
|
14
|
-
try {
|
|
15
|
-
const [{ renderToReadableStream }, element] = await Promise.all([
|
|
16
|
-
resolveLocalPackage('react-dom/server', props.workDir),
|
|
17
|
-
resolveSchemaIcon(props)
|
|
18
|
-
]);
|
|
19
|
-
const stream = await renderToReadableStream(element);
|
|
20
|
-
await stream.allReady;
|
|
21
|
-
const reader = stream.getReader();
|
|
22
|
-
const chunks = [];
|
|
23
|
-
while(true){
|
|
24
|
-
const { done, value } = await reader.read();
|
|
25
|
-
if (done) break;
|
|
26
|
-
chunks.push(value);
|
|
27
|
-
}
|
|
28
|
-
const html = new TextDecoder().decode(Buffer.concat(chunks));
|
|
29
|
-
return sanitizeIcon(html);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
manifestDebug('Error resolving icon', error);
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=iconResolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/manifest/iconResolver.tsx"],"sourcesContent":["import {resolveLocalPackage} from '@sanity/cli-core'\n\nimport {manifestDebug} from './debug.js'\nimport {resolveSchemaIcon, type SchemaIconProps} from './resolveSchemaIcon.js'\nimport {sanitizeIcon} from './sanitizeIcon.js'\n\n/**\n * Resolves an icon to a sanitized HTML string.\n * Uses react-dom/server to capture styles during SSR.\n *\n * react-dom/server is resolved from the studio's working directory to ensure\n * the same React instance is used by both the server renderer and the studio's\n * components. Using the CLI's own react-dom/server would cause a dual-React\n * instance problem where the dispatcher set by one instance is invisible to the other.\n */\nexport const resolveIcon = async (props: SchemaIconProps): Promise<string | null> => {\n try {\n const [{renderToReadableStream}, element] = await Promise.all([\n resolveLocalPackage<typeof import('react-dom/server')>('react-dom/server', props.workDir),\n resolveSchemaIcon(props),\n ])\n const stream = await renderToReadableStream(element)\n await stream.allReady\n\n const reader = stream.getReader()\n const chunks: Uint8Array[] = []\n while (true) {\n const {done, value} = await reader.read()\n if (done) break\n chunks.push(value)\n }\n const html = new TextDecoder().decode(Buffer.concat(chunks))\n return sanitizeIcon(html)\n } catch (error) {\n manifestDebug('Error resolving icon', error)\n return null\n }\n}\n"],"names":["resolveLocalPackage","manifestDebug","resolveSchemaIcon","sanitizeIcon","resolveIcon","props","renderToReadableStream","element","Promise","all","workDir","stream","allReady","reader","getReader","chunks","done","value","read","push","html","TextDecoder","decode","Buffer","concat","error"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mBAAkB;AAEpD,SAAQC,aAAa,QAAO,aAAY;AACxC,SAAQC,iBAAiB,QAA6B,yBAAwB;AAC9E,SAAQC,YAAY,QAAO,oBAAmB;AAE9C;;;;;;;;CAQC,GACD,OAAO,MAAMC,cAAc,OAAOC;IAChC,IAAI;QACF,MAAM,CAAC,EAACC,sBAAsB,EAAC,EAAEC,QAAQ,GAAG,MAAMC,QAAQC,GAAG,CAAC;YAC5DT,oBAAuD,oBAAoBK,MAAMK,OAAO;YACxFR,kBAAkBG;SACnB;QACD,MAAMM,SAAS,MAAML,uBAAuBC;QAC5C,MAAMI,OAAOC,QAAQ;QAErB,MAAMC,SAASF,OAAOG,SAAS;QAC/B,MAAMC,SAAuB,EAAE;QAC/B,MAAO,KAAM;YACX,MAAM,EAACC,IAAI,EAAEC,KAAK,EAAC,GAAG,MAAMJ,OAAOK,IAAI;YACvC,IAAIF,MAAM;YACVD,OAAOI,IAAI,CAACF;QACd;QACA,MAAMG,OAAO,IAAIC,cAAcC,MAAM,CAACC,OAAOC,MAAM,CAACT;QACpD,OAAOZ,aAAaiB;IACtB,EAAE,OAAOK,OAAO;QACdxB,cAAc,wBAAwBwB;QACtC,OAAO;IACT;AACF,EAAC"}
|