@sanity/cli 6.5.1 → 6.5.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/buildStaticFiles.js +1 -2
- package/dist/actions/build/buildStaticFiles.js.map +1 -1
- package/dist/actions/build/getViteConfig.js +2 -8
- package/dist/actions/build/getViteConfig.js.map +1 -1
- package/dist/server/vite/plugin-sanity-favicons.js +1 -1
- package/dist/server/vite/plugin-sanity-favicons.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +3 -4
- package/dist/actions/build/generateWebManifest.js +0 -27
- package/dist/actions/build/generateWebManifest.js.map +0 -1
- package/dist/actions/build/writeFavicons.js +0 -24
- package/dist/actions/build/writeFavicons.js.map +0 -1
- package/dist/actions/build/writeWebManifest.js +0 -12
- package/dist/actions/build/writeWebManifest.js.map +0 -1
- package/dist/util/copyDir.js +0 -63
- package/dist/util/copyDir.js.map +0 -1
- package/static/favicons/apple-touch-icon.png +0 -0
- package/static/favicons/favicon-192.png +0 -0
- package/static/favicons/favicon-512.png +0 -0
- package/static/favicons/favicon-96.png +0 -0
- package/static/favicons/favicon.ico +0 -0
- package/static/favicons/favicon.svg +0 -12
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { copyDir, writeFavicons } from '@sanity/cli-build/_internal';
|
|
2
3
|
import { build } from 'vite';
|
|
3
|
-
import { copyDir } from '../../util/copyDir.js';
|
|
4
4
|
import { buildDebug } from './buildDebug.js';
|
|
5
5
|
import { extendViteConfigWithUserConfig, finalizeViteConfig, getViteConfig } from './getViteConfig.js';
|
|
6
|
-
import { writeFavicons } from './writeFavicons.js';
|
|
7
6
|
import { writeSanityRuntime } from './writeSanityRuntime.js';
|
|
8
7
|
/**
|
|
9
8
|
* Builds static files
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/buildStaticFiles.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {type CliConfig, type UserViteConfig} from '@sanity/cli-core'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {build} from 'vite'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildStaticFiles.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {copyDir, writeFavicons} from '@sanity/cli-build/_internal'\nimport {type CliConfig, type UserViteConfig} from '@sanity/cli-core'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {build} from 'vite'\n\nimport {buildDebug} from './buildDebug.js'\nimport {extendViteConfigWithUserConfig, finalizeViteConfig, getViteConfig} from './getViteConfig.js'\nimport {writeSanityRuntime} from './writeSanityRuntime.js'\n\nexport interface ChunkModule {\n name: string\n originalLength: number\n renderedLength: number\n}\n\nexport interface ChunkStats {\n modules: ChunkModule[]\n name: string\n}\n\ninterface StaticBuildOptions {\n basePath: string\n cwd: string\n outputDir: string\n\n appTitle?: string\n autoUpdatesCssUrls?: string[]\n entry?: string\n importMap?: {imports?: Record<string, string>}\n isApp?: boolean\n minify?: boolean\n profile?: boolean\n reactCompiler?: ReactCompilerConfig\n schemaExtraction?: CliConfig['schemaExtraction']\n sourceMap?: boolean\n vite?: UserViteConfig\n}\n\n/**\n * Builds static files\n *\n * @internal\n */\nexport async function buildStaticFiles(\n options: StaticBuildOptions,\n): Promise<{chunks: ChunkStats[]}> {\n const {\n appTitle,\n autoUpdatesCssUrls,\n basePath,\n cwd,\n entry,\n importMap,\n isApp,\n minify = true,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap = false,\n vite: extendViteConfig,\n } = options\n\n buildDebug('Writing Sanity runtime files')\n await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n reactStrictMode: false,\n watch: false,\n })\n\n buildDebug('Resolving vite config')\n const mode = 'production'\n let viteConfig = await getViteConfig({\n autoUpdatesCssUrls,\n basePath,\n cwd,\n importMap,\n isApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n })\n\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n viteConfig = await finalizeViteConfig(viteConfig)\n }\n\n const fromPath = path.join(cwd, 'static')\n // Copy files placed in /static to the built /static\n buildDebug(`Copying static files from ${fromPath} to output dir`)\n const staticPath = path.join(outputDir, 'static')\n await copyDir(fromPath, staticPath)\n\n // Write favicons, not overwriting ones that already exist, to static folder\n buildDebug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n\n buildDebug('Bundling using vite')\n const bundle = await build(viteConfig)\n buildDebug('Bundling complete')\n\n // For typescript only - this shouldn't ever be the case given we're not watching\n if (Array.isArray(bundle) || !('output' in bundle)) {\n return {chunks: []}\n }\n\n const stats: ChunkStats[] = []\n for (const chunk of bundle.output) {\n if (chunk.type !== 'chunk') {\n continue\n }\n\n stats.push({\n modules: Object.entries(chunk.modules).map(([rawFilePath, chunkModule]) => {\n const filePath = rawFilePath.startsWith('\\u0000')\n ? rawFilePath.slice('\\u0000'.length)\n : rawFilePath\n\n return {\n name: path.isAbsolute(filePath) ? path.relative(cwd, filePath) : filePath,\n originalLength: chunkModule.originalLength,\n renderedLength: chunkModule.renderedLength,\n }\n }),\n name: chunk.name,\n })\n }\n\n return {chunks: stats}\n}\n"],"names":["path","copyDir","writeFavicons","build","buildDebug","extendViteConfigWithUserConfig","finalizeViteConfig","getViteConfig","writeSanityRuntime","buildStaticFiles","options","appTitle","autoUpdatesCssUrls","basePath","cwd","entry","importMap","isApp","minify","outputDir","reactCompiler","schemaExtraction","sourceMap","vite","extendViteConfig","reactStrictMode","watch","mode","viteConfig","command","fromPath","join","staticPath","faviconBasePath","replace","bundle","Array","isArray","chunks","stats","chunk","output","type","push","modules","Object","entries","map","rawFilePath","chunkModule","filePath","startsWith","slice","length","name","isAbsol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BD;IAErC5B,WAAW;IACX,MAAM+B,SAAS,MAAMhC,MAAMyB;IAC3BxB,WAAW;IAEX,iFAAiF;IACjF,IAAIgC,MAAMC,OAAO,CAACF,WAAW,CAAE,CAAA,YAAYA,MAAK,GAAI;QAClD,OAAO;YAACG,QAAQ,EAAE;QAAA;IACpB;IAEA,MAAMC,QAAsB,EAAE;IAC9B,KAAK,MAAMC,SAASL,OAAOM,MAAM,CAAE;QACjC,IAAID,MAAME,IAAI,KAAK,SAAS;YAC1B;QACF;QAEAH,MAAMI,IAAI,CAAC;YACTC,SAASC,OAAOC,OAAO,CAACN,MAAMI,OAAO,EAAEG,GAAG,CAAC,CAAC,CAACC,aAAaC,YAAY;gBACpE,MAAMC,WAAWF,YAAYG,UAAU,CAAC,YACpCH,YAAYI,KAAK,CAAC,SAASC,MAAM,IACjCL;gBAEJ,OAAO;oBACLM,MAAMtD,KAAKuD,UAAU,CAACL,YAAYlD,KAAKwD,QAAQ,CAAC1C,KAAKoC,YAAYA;oBACjEO,gBAAgBR,YAAYQ,cAAc;oBAC1CC,gBAAgBT,YAAYS,cAAc;gBAC5C;YACF;YACAJ,MAAMd,MAAMc,IAAI;QAClB;IACF;IAEA,OAAO;QAAChB,QAAQC;IAAK;AACvB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { getDefaultFaviconsPath } from '@sanity/cli-build/_internal';
|
|
2
3
|
import { findProjectRoot, getCliTelemetry } from '@sanity/cli-core';
|
|
3
4
|
import viteReact from '@vitejs/plugin-react';
|
|
4
5
|
import debug from 'debug';
|
|
5
|
-
import { readPackageUp } from 'read-package-up';
|
|
6
6
|
import { mergeConfig } from 'vite';
|
|
7
7
|
import { SANITY_CACHE_DIR } from '../../constants.js';
|
|
8
8
|
import { sanityBuildEntries } from '../../server/vite/plugin-sanity-build-entries.js';
|
|
@@ -21,15 +21,9 @@ import { normalizeBasePath } from './normalizeBasePath.js';
|
|
|
21
21
|
const { autoUpdatesCssUrls, basePath: rawBasePath = '/', cwd, importMap, isApp, minify, mode, outputDir, reactCompiler, schemaExtraction, server, // default to `true` when `mode=development`
|
|
22
22
|
sourceMap = options.mode === 'development', typegen } = options;
|
|
23
23
|
const basePath = normalizeBasePath(rawBasePath);
|
|
24
|
-
const sanityCliPkgPath = (await readPackageUp({
|
|
25
|
-
cwd: import.meta.dirname
|
|
26
|
-
}))?.path;
|
|
27
|
-
if (!sanityCliPkgPath) {
|
|
28
|
-
throw new Error('Unable to resolve `@sanity/cli` module root');
|
|
29
|
-
}
|
|
30
24
|
const configPath = (await findProjectRoot(cwd)).path;
|
|
31
25
|
const customFaviconsPath = path.join(cwd, 'static');
|
|
32
|
-
const defaultFaviconsPath =
|
|
26
|
+
const defaultFaviconsPath = await getDefaultFaviconsPath();
|
|
33
27
|
const staticPath = `${basePath}static`;
|
|
34
28
|
const envVars = isApp ? getAppEnvironmentVariables({
|
|
35
29
|
jsonEncode: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/getViteConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {\n type CliConfig,\n findProjectRoot,\n getCliTelemetry,\n type UserViteConfig,\n} from '@sanity/cli-core'\nimport viteReact from '@vitejs/plugin-react'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport debug from 'debug'\nimport {readPackageUp} from 'read-package-up'\nimport {type ConfigEnv, type InlineConfig, mergeConfig, type Rollup} from 'vite'\n\nimport {SANITY_CACHE_DIR} from '../../constants.js'\nimport {sanityBuildEntries} from '../../server/vite/plugin-sanity-build-entries.js'\nimport {sanityFaviconsPlugin} from '../../server/vite/plugin-sanity-favicons.js'\nimport {sanityRuntimeRewritePlugin} from '../../server/vite/plugin-sanity-runtime-rewrite.js'\nimport {sanitySchemaExtractionPlugin} from '../../server/vite/plugin-schema-extraction.js'\nimport {sanityTypegenPlugin} from '../../server/vite/plugin-typegen.js'\nimport {createExternalFromImportMap} from './createExternalFromImportMap.js'\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from './getStudioEnvironmentVariables.js'\nimport {normalizeBasePath} from './normalizeBasePath.js'\n\ninterface ViteOptions {\n /**\n * Root path of the studio/sanity app\n */\n cwd: string\n\n /**\n * Mode to run vite in - eg development or production\n */\n mode: 'development' | 'production'\n\n reactCompiler: ReactCompilerConfig | undefined\n\n /**\n * CSS URLs for auto-updated packages (loaded via module server)\n */\n autoUpdatesCssUrls?: string[]\n\n /**\n * Base path (eg under where to serve the app - `/studio` or similar)\n * Will be normalized to ensure it starts and ends with a `/`\n */\n basePath?: string\n\n importMap?: {imports?: Record<string, string>}\n\n isApp?: boolean\n\n /**\n * Whether or not to minify the output (only used in `mode: 'production'`)\n */\n minify?: boolean\n\n /**\n * Output directory (eg where to place the built files, if any)\n */\n outputDir?: string\n /**\n * Schema extraction configuration\n */\n schemaExtraction?: CliConfig['schemaExtraction']\n /**\n * HTTP development server configuration\n */\n server?: {host?: string; port?: number}\n /**\n * Whether or not to enable source maps\n */\n sourceMap?: boolean\n /**\n * Typegen configuration\n */\n typegen?: CliConfig['typegen']\n}\n\n/**\n * Get a configuration object for Vite based on the passed options\n *\n * @internal Only meant for consumption inside of Sanity modules, do not depend on this externally\n */\nexport async function getViteConfig(options: ViteOptions): Promise<InlineConfig> {\n const {\n autoUpdatesCssUrls,\n basePath: rawBasePath = '/',\n cwd,\n importMap,\n isApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n server,\n // default to `true` when `mode=development`\n sourceMap = options.mode === 'development',\n typegen,\n } = options\n\n const basePath = normalizeBasePath(rawBasePath)\n\n const sanityCliPkgPath = (await readPackageUp({cwd: import.meta.dirname}))?.path\n if (!sanityCliPkgPath) {\n throw new Error('Unable to resolve `@sanity/cli` module root')\n }\n\n const configPath = (await findProjectRoot(cwd)).path\n\n const customFaviconsPath = path.join(cwd, 'static')\n const defaultFaviconsPath = path.join(path.dirname(sanityCliPkgPath), 'static', 'favicons')\n const staticPath = `${basePath}static`\n\n const envVars = isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n\n const viteConfig: InlineConfig = {\n base: basePath,\n build: {\n outDir: outputDir || path.resolve(cwd, 'dist'),\n sourcemap: sourceMap,\n },\n // Define a custom cache directory so that sanity's vite cache\n // does not conflict with any potential local vite projects\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n configFile: false,\n define: {\n __SANITY_BUILD_TIMESTAMP__: JSON.stringify(Date.now()),\n __SANITY_STAGING__: process.env.SANITY_INTERNAL_ENV === 'staging',\n 'process.env.MODE': JSON.stringify(mode),\n 'process.env.PKG_BUILD_VERSION': JSON.stringify(process.env.PKG_BUILD_VERSION),\n /**\n * Yes, double negatives are confusing.\n * The default value of `SC_DISABLE_SPEEDY` is `process.env.NODE_ENV === 'production'`: https://github.com/styled-components/styled-components/blob/99c02f52d69e8e509c0bf012cadee7f8e819a6dd/packages/styled-components/src/constants.ts#L34\n * Which means that in production, use the much faster way of inserting CSS rules, based on the CSSStyleSheet API (https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule)\n * while in dev mode, use the slower way of inserting CSS rules, which appends text nodes to the `<style>` tag: https://github.com/styled-components/styled-components/blob/99c02f52d69e8e509c0bf012cadee7f8e819a6dd/packages/styled-components/src/sheet/Tag.ts#L74-L76\n * There are historical reasons for this, primarily that browsers initially did not support editing CSS rules in the DevTools inspector if `CSSStyleSheet.insetRule` were used.\n * However, that's no longer the case (since Chrome 81 back in April 2020: https://developer.chrome.com/docs/css-ui/css-in-js), the latest version of FireFox also supports it,\n * and there is no longer any reason to use the much slower method in dev mode.\n */\n 'process.env.SC_DISABLE_SPEEDY': JSON.stringify('false'),\n ...envVars,\n },\n envPrefix: isApp ? 'SANITY_APP_' : 'SANITY_STUDIO_',\n logLevel: mode === 'production' ? 'silent' : 'info',\n mode,\n plugins: [\n viteReact(\n reactCompiler\n ? {\n babel: {\n generatorOpts: {compact: true},\n plugins: [['babel-plugin-react-compiler', reactCompiler]],\n },\n }\n : {},\n ),\n sanityFaviconsPlugin({customFaviconsPath, defaultFaviconsPath, staticUrlPath: staticPath}),\n sanityRuntimeRewritePlugin(),\n sanityBuildEntries({autoUpdatesCssUrls, basePath, cwd, importMap, isApp}),\n // Add schema extraction when enabled\n ...(schemaExtraction?.enabled\n ? [\n sanitySchemaExtractionPlugin({\n additionalPatterns: schemaExtraction.watchPatterns,\n configPath,\n enforceRequiredFields: schemaExtraction.enforceRequiredFields,\n outputPath: schemaExtraction.path,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n workspaceName: schemaExtraction.workspace,\n }),\n ]\n : []),\n // Add typegen when enabled\n ...(typegen?.enabled\n ? [\n sanityTypegenPlugin({\n config: typegen,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n }),\n ]\n : []),\n ],\n resolve: {\n dedupe: ['react', 'react-dom', 'sanity', 'styled-components'],\n },\n root: cwd,\n server: {\n host: server?.host,\n port: server?.port || 3333,\n // Only enable strict port for studio,\n // since apps can run on any port\n strictPort: isApp ? false : true,\n\n /**\n * Significantly speed up startup time,\n * and most importantly eliminates the `new dependencies optimized: foobar. optimized dependencies changed. reloading`\n * types of initial reload loops that otherwise happen as vite discovers deps that need to be optimized.\n * This option starts the traversal up front, and warms up the dep tree required to render the userland sanity.config.ts file,\n * and thus avoids frustrating reload loops.\n */\n warmup: {\n clientFiles: ['./.sanity/runtime/app.js'],\n },\n },\n }\n\n if (mode === 'production') {\n viteConfig.build = {\n ...viteConfig.build,\n\n assetsDir: 'static',\n emptyOutDir: false, // Rely on CLI to do this\n minify: minify ? 'esbuild' : false,\n\n rollupOptions: {\n external: createExternalFromImportMap(importMap),\n input: {\n sanity: path.join(cwd, '.sanity', 'runtime', 'app.js'),\n },\n onwarn: onRollupWarn,\n },\n }\n }\n\n return viteConfig\n}\n\nfunction onRollupWarn(warning: Rollup.RollupLog, warn: Rollup.LoggingFunction) {\n if (suppressUnusedImport(warning)) {\n return\n }\n\n warn(warning)\n}\n\nfunction suppressUnusedImport(warning: Rollup.RollupLog & {ids?: string[]}): boolean {\n if (warning.code !== 'UNUSED_EXTERNAL_IMPORT') return false\n\n // Suppress:\n // ```\n // \"useDebugValue\" is imported from external module \"react\"…\n // ```\n if (warning.names?.includes('useDebugValue')) {\n warning.names = warning.names.filter((n) => n !== 'useDebugValue')\n if (warning.names.length === 0) return true\n }\n\n // If some library does something unexpected, we suppress since it isn't actionable\n if (warning.ids?.every((id) => id.includes('/node_modules/') || id.includes('\\\\node_modules\\\\')))\n return true\n\n return false\n}\n\n/**\n * Ensure Sanity entry chunk is always loaded\n *\n * @param config - User-modified configuration\n * @returns Merged configuration\n * @internal\n */\nexport async function finalizeViteConfig(config: InlineConfig): Promise<InlineConfig> {\n if (typeof config.build?.rollupOptions?.input !== 'object') {\n throw new TypeError(\n 'Vite config must contain `build.rollupOptions.input`, and it must be an object',\n )\n }\n\n if (!config.root) {\n throw new Error(\n 'Vite config must contain `root` property, and must point to the Sanity root directory',\n )\n }\n\n return mergeConfig(config, {\n build: {\n rollupOptions: {\n input: {\n sanity: path.join(config.root, '.sanity', 'runtime', 'app.js'),\n },\n },\n },\n })\n}\n\n/**\n * Merge user-provided Vite configuration object or function\n *\n * @param defaultConfig - Default configuration object\n * @param userConfig - User-provided configuration object or function\n * @returns Merged configuration\n * @internal\n */\nexport async function extendViteConfigWithUserConfig(\n env: ConfigEnv,\n defaultConfig: InlineConfig,\n userConfig: UserViteConfig,\n): Promise<InlineConfig> {\n let config = defaultConfig\n\n if (typeof userConfig === 'function') {\n debug('Extending vite config using user-specified function')\n config = await userConfig(config, env)\n } else if (typeof userConfig === 'object') {\n debug('Merging vite config using user-specified object')\n config = mergeConfig(config, userConfig)\n }\n\n return config\n}\n"],"names":["path","findProjectRoot","getCliTelemetry","viteReact","debug","readPackageUp","mergeConfig","SANITY_CACHE_DIR","sanityBuildEntries","sanityFaviconsPlugin","sanityRuntimeRewritePlugin","sanitySchemaExtractionPlugin","sanityTypegenPlugin","createExternalFromImportMap","getAppEnvironmentVariables","getStudioEnvironmentVariables","normalizeBasePath","getViteConfig","options","autoUpdatesCssUrls","basePath","rawBasePath","cwd","importMap","isApp","minify","mode","outputDir","reactCompiler","schemaExtraction","server","sourceMap","typegen","sanityCliPkgPath","dirname","Error","configPath","customFaviconsPath","join","defaultFaviconsPath","staticPath","envVars","jsonEncode","prefix","viteConfig","base","build","outDir","resolve","sourcemap","cacheDir","configFile","define","__SANITY_BUILD_TIMESTAMP__","JSON","stringify","Date","now","__SANITY_STAGING__","process","env","SANITY_INTERNAL_ENV","PKG_BUILD_VERSION","envPrefix","logLevel","plugins","babel","generatorOpts","compact","staticUrlPath","enabled","additionalPatterns","watchPatterns","enforceRequiredFields","outputPath","telemetryLogger","workDir","workspaceName","workspace","config","dedupe","root","host","port","strictPort","warmup","clientFiles","assetsDir","emptyOutDir","rollupOptions","external","input","sanity","onwarn","onRollupWarn","warning","warn","suppressUnusedImport","code","names","includes","filter","n","length","ids","every","id","finalizeViteConfig","TypeError","extendViteConfigWithUserConfig","defaultConfig","userConfig"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAEEC,eAAe,EACfC,eAAe,QAEV,mBAAkB;AACzB,OAAOC,eAAe,uBAAsB;AAE5C,OAAOC,WAAW,QAAO;AACzB,SAAQC,aAAa,QAAO,kBAAiB;AAC7C,SAA2CC,WAAW,QAAoB,OAAM;AAEhF,SAAQC,gBAAgB,QAAO,qBAAoB;AACnD,SAAQC,kBAAkB,QAAO,mDAAkD;AACnF,SAAQC,oBAAoB,QAAO,8CAA6C;AAChF,SAAQC,0BAA0B,QAAO,qDAAoD;AAC7F,SAAQC,4BAA4B,QAAO,gDAA+C;AAC1F,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SACEC,0BAA0B,EAC1BC,6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OE,IAAI,EAAE,WAAW,WAAW;gBACvD;YACF;QACF;IACF;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAe4B,+BACpBjD,GAAc,EACdkD,aAA2B,EAC3BC,UAA0B;IAE1B,IAAIhC,SAAS+B;IAEb,IAAI,OAAOC,eAAe,YAAY;QACpC3G,MAAM;QACN2E,SAAS,MAAMgC,WAAWhC,QAAQnB;IACpC,OAAO,IAAI,OAAOmD,eAAe,UAAU;QACzC3G,MAAM;QACN2E,SAASzE,YAAYyE,QAAQgC;IAC/B;IAEA,OAAOhC;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/getViteConfig.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {getDefaultFaviconsPath} from '@sanity/cli-build/_internal'\nimport {\n type CliConfig,\n findProjectRoot,\n getCliTelemetry,\n type UserViteConfig,\n} from '@sanity/cli-core'\nimport viteReact from '@vitejs/plugin-react'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport debug from 'debug'\nimport {type ConfigEnv, type InlineConfig, mergeConfig, type Rollup} from 'vite'\n\nimport {SANITY_CACHE_DIR} from '../../constants.js'\nimport {sanityBuildEntries} from '../../server/vite/plugin-sanity-build-entries.js'\nimport {sanityFaviconsPlugin} from '../../server/vite/plugin-sanity-favicons.js'\nimport {sanityRuntimeRewritePlugin} from '../../server/vite/plugin-sanity-runtime-rewrite.js'\nimport {sanitySchemaExtractionPlugin} from '../../server/vite/plugin-schema-extraction.js'\nimport {sanityTypegenPlugin} from '../../server/vite/plugin-typegen.js'\nimport {createExternalFromImportMap} from './createExternalFromImportMap.js'\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from './getStudioEnvironmentVariables.js'\nimport {normalizeBasePath} from './normalizeBasePath.js'\n\ninterface ViteOptions {\n /**\n * Root path of the studio/sanity app\n */\n cwd: string\n\n /**\n * Mode to run vite in - eg development or production\n */\n mode: 'development' | 'production'\n\n reactCompiler: ReactCompilerConfig | undefined\n\n /**\n * CSS URLs for auto-updated packages (loaded via module server)\n */\n autoUpdatesCssUrls?: string[]\n\n /**\n * Base path (eg under where to serve the app - `/studio` or similar)\n * Will be normalized to ensure it starts and ends with a `/`\n */\n basePath?: string\n\n importMap?: {imports?: Record<string, string>}\n\n isApp?: boolean\n\n /**\n * Whether or not to minify the output (only used in `mode: 'production'`)\n */\n minify?: boolean\n\n /**\n * Output directory (eg where to place the built files, if any)\n */\n outputDir?: string\n /**\n * Schema extraction configuration\n */\n schemaExtraction?: CliConfig['schemaExtraction']\n /**\n * HTTP development server configuration\n */\n server?: {host?: string; port?: number}\n /**\n * Whether or not to enable source maps\n */\n sourceMap?: boolean\n /**\n * Typegen configuration\n */\n typegen?: CliConfig['typegen']\n}\n\n/**\n * Get a configuration object for Vite based on the passed options\n *\n * @internal Only meant for consumption inside of Sanity modules, do not depend on this externally\n */\nexport async function getViteConfig(options: ViteOptions): Promise<InlineConfig> {\n const {\n autoUpdatesCssUrls,\n basePath: rawBasePath = '/',\n cwd,\n importMap,\n isApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n server,\n // default to `true` when `mode=development`\n sourceMap = options.mode === 'development',\n typegen,\n } = options\n\n const basePath = normalizeBasePath(rawBasePath)\n\n const configPath = (await findProjectRoot(cwd)).path\n\n const customFaviconsPath = path.join(cwd, 'static')\n const defaultFaviconsPath = await getDefaultFaviconsPath()\n const staticPath = `${basePath}static`\n\n const envVars = isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n\n const viteConfig: InlineConfig = {\n base: basePath,\n build: {\n outDir: outputDir || path.resolve(cwd, 'dist'),\n sourcemap: sourceMap,\n },\n // Define a custom cache directory so that sanity's vite cache\n // does not conflict with any potential local vite projects\n cacheDir: `${SANITY_CACHE_DIR}/vite`,\n configFile: false,\n define: {\n __SANITY_BUILD_TIMESTAMP__: JSON.stringify(Date.now()),\n __SANITY_STAGING__: process.env.SANITY_INTERNAL_ENV === 'staging',\n 'process.env.MODE': JSON.stringify(mode),\n 'process.env.PKG_BUILD_VERSION': JSON.stringify(process.env.PKG_BUILD_VERSION),\n /**\n * Yes, double negatives are confusing.\n * The default value of `SC_DISABLE_SPEEDY` is `process.env.NODE_ENV === 'production'`: https://github.com/styled-components/styled-components/blob/99c02f52d69e8e509c0bf012cadee7f8e819a6dd/packages/styled-components/src/constants.ts#L34\n * Which means that in production, use the much faster way of inserting CSS rules, based on the CSSStyleSheet API (https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule)\n * while in dev mode, use the slower way of inserting CSS rules, which appends text nodes to the `<style>` tag: https://github.com/styled-components/styled-components/blob/99c02f52d69e8e509c0bf012cadee7f8e819a6dd/packages/styled-components/src/sheet/Tag.ts#L74-L76\n * There are historical reasons for this, primarily that browsers initially did not support editing CSS rules in the DevTools inspector if `CSSStyleSheet.insetRule` were used.\n * However, that's no longer the case (since Chrome 81 back in April 2020: https://developer.chrome.com/docs/css-ui/css-in-js), the latest version of FireFox also supports it,\n * and there is no longer any reason to use the much slower method in dev mode.\n */\n 'process.env.SC_DISABLE_SPEEDY': JSON.stringify('false'),\n ...envVars,\n },\n envPrefix: isApp ? 'SANITY_APP_' : 'SANITY_STUDIO_',\n logLevel: mode === 'production' ? 'silent' : 'info',\n mode,\n plugins: [\n viteReact(\n reactCompiler\n ? {\n babel: {\n generatorOpts: {compact: true},\n plugins: [['babel-plugin-react-compiler', reactCompiler]],\n },\n }\n : {},\n ),\n sanityFaviconsPlugin({customFaviconsPath, defaultFaviconsPath, staticUrlPath: staticPath}),\n sanityRuntimeRewritePlugin(),\n sanityBuildEntries({autoUpdatesCssUrls, basePath, cwd, importMap, isApp}),\n // Add schema extraction when enabled\n ...(schemaExtraction?.enabled\n ? [\n sanitySchemaExtractionPlugin({\n additionalPatterns: schemaExtraction.watchPatterns,\n configPath,\n enforceRequiredFields: schemaExtraction.enforceRequiredFields,\n outputPath: schemaExtraction.path,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n workspaceName: schemaExtraction.workspace,\n }),\n ]\n : []),\n // Add typegen when enabled\n ...(typegen?.enabled\n ? [\n sanityTypegenPlugin({\n config: typegen,\n telemetryLogger: getCliTelemetry(),\n workDir: cwd,\n }),\n ]\n : []),\n ],\n resolve: {\n dedupe: ['react', 'react-dom', 'sanity', 'styled-components'],\n },\n root: cwd,\n server: {\n host: server?.host,\n port: server?.port || 3333,\n // Only enable strict port for studio,\n // since apps can run on any port\n strictPort: isApp ? false : true,\n\n /**\n * Significantly speed up startup time,\n * and most importantly eliminates the `new dependencies optimized: foobar. optimized dependencies changed. reloading`\n * types of initial reload loops that otherwise happen as vite discovers deps that need to be optimized.\n * This option starts the traversal up front, and warms up the dep tree required to render the userland sanity.config.ts file,\n * and thus avoids frustrating reload loops.\n */\n warmup: {\n clientFiles: ['./.sanity/runtime/app.js'],\n },\n },\n }\n\n if (mode === 'production') {\n viteConfig.build = {\n ...viteConfig.build,\n\n assetsDir: 'static',\n emptyOutDir: false, // Rely on CLI to do this\n minify: minify ? 'esbuild' : false,\n\n rollupOptions: {\n external: createExternalFromImportMap(importMap),\n input: {\n sanity: path.join(cwd, '.sanity', 'runtime', 'app.js'),\n },\n onwarn: onRollupWarn,\n },\n }\n }\n\n return viteConfig\n}\n\nfunction onRollupWarn(warning: Rollup.RollupLog, warn: Rollup.LoggingFunction) {\n if (suppressUnusedImport(warning)) {\n return\n }\n\n warn(warning)\n}\n\nfunction suppressUnusedImport(warning: Rollup.RollupLog & {ids?: string[]}): boolean {\n if (warning.code !== 'UNUSED_EXTERNAL_IMPORT') return false\n\n // Suppress:\n // ```\n // \"useDebugValue\" is imported from external module \"react\"…\n // ```\n if (warning.names?.includes('useDebugValue')) {\n warning.names = warning.names.filter((n) => n !== 'useDebugValue')\n if (warning.names.length === 0) return true\n }\n\n // If some library does something unexpected, we suppress since it isn't actionable\n if (warning.ids?.every((id) => id.includes('/node_modules/') || id.includes('\\\\node_modules\\\\')))\n return true\n\n return false\n}\n\n/**\n * Ensure Sanity entry chunk is always loaded\n *\n * @param config - User-modified configuration\n * @returns Merged configuration\n * @internal\n */\nexport async function finalizeViteConfig(config: InlineConfig): Promise<InlineConfig> {\n if (typeof config.build?.rollupOptions?.input !== 'object') {\n throw new TypeError(\n 'Vite config must contain `build.rollupOptions.input`, and it must be an object',\n )\n }\n\n if (!config.root) {\n throw new Error(\n 'Vite config must contain `root` property, and must point to the Sanity root directory',\n )\n }\n\n return mergeConfig(config, {\n build: {\n rollupOptions: {\n input: {\n sanity: path.join(config.root, '.sanity', 'runtime', 'app.js'),\n },\n },\n },\n })\n}\n\n/**\n * Merge user-provided Vite configuration object or function\n *\n * @param defaultConfig - Default configuration object\n * @param userConfig - User-provided configuration object or function\n * @returns Merged configuration\n * @internal\n */\nexport async function extendViteConfigWithUserConfig(\n env: ConfigEnv,\n defaultConfig: InlineConfig,\n userConfig: UserViteConfig,\n): Promise<InlineConfig> {\n let config = defaultConfig\n\n if (typeof userConfig === 'function') {\n debug('Extending vite config using user-specified function')\n config = await userConfig(config, env)\n } else if (typeof userConfig === 'object') {\n debug('Merging vite config using user-specified object')\n config = mergeConfig(config, userConfig)\n }\n\n return config\n}\n"],"names":["path","getDefaultFaviconsPath","findProjectRoot","getCliTelemetry","viteReact","debug","mergeConfig","SANITY_CACHE_DIR","sanityBuildEntries","sanityFaviconsPlugin","sanityRuntimeRewritePlugin","sanitySchemaExtractionPlugin","sanityTypegenPlugin","createExternalFromImportMap","getAppEnvironmentVariables","getStudioEnvironmentVariables","normalizeBasePath","getViteConfig","options","autoUpdatesCssUrls","basePath","rawBasePath","cwd","importMap","isApp","minify","mode","outputDir","reactCompiler","schemaExtraction","server","sourceMap","typegen","configPath","customFaviconsPath","join","defaultFaviconsPath","staticPath","envVars","jsonEncode","prefix","viteConfig","base","build","outDir","resolve","sourcemap","cacheDir","configFile","define","__SANITY_BUILD_TIMESTAMP__","JSON","stringify","Date","now","__SANITY_STAGING__","process","env","SANITY_INTERNAL_ENV","PKG_BUILD_VERSION","envPrefix","logLevel","plugins","babel","generatorOpts","compact","staticUrlPath","enabled","additionalPatterns","watchPatterns","enforceRequiredFields","outputPath","telemetryLogger","workDir","workspaceName","workspace","config","dedupe","root","host","port","strictPort","warmup","clientFiles","assetsDir","emptyOutDir","rollupOptions","external","input","sanity","onwarn","onRollupWarn","warning","warn","suppressUnusedImport","code","names","includes","filter","n","length","ids","every","id","finalizeViteConfig","TypeError","Error","extendViteConfigWithUserConfig","defaultConfig","userConfig"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAQC,sBAAsB,QAAO,8BAA6B;AAClE,SAEEC,eAAe,EACfC,eAAe,QAEV,mBAAkB;AACzB,OAAOC,eAAe,uBAAsB;AAE5C,OAAOC,WAAW,QAAO;AACzB,SAA2CC,WAAW,QAAoB,OAAM;AAEhF,SAAQC,gBAAgB,QAAO,qBAAoB;AACnD,SAAQC,kBAAkB,QAAO,mDAAkD;AACnF,SAAQC,oBAAoB,QAAO,8CAA6C;AAChF,SAAQC,0BAA0B,QAAO,qDAAoD;AAC7F,SAAQC,4BAA4B,QAAO,gDAA+C;AAC1F,SAAQC,mBAAmB,QAAO,sCAAqC;AACvE,SAAQC,2BAA2B,QAAO,mCAAkC;AAC5E,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,qCAAoC;AAC3C,SAAQC,iBAAiB,QAAO,yBAAwB;AAyDxD;;;;CAIC,GACD,OAAO,eAAeC,cAAcC,OAAoB;IACtD,MAAM,EACJC,kBAAkB,EAClBC,UAAUC,cAAc,GAAG,EAC3BC,GAAG,EACHC,SAAS,EACTC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBC,MAAM,EACN,4CAA4C;IAC5CC,YAAYb,QAAQQ,IAAI,KAAK,aAAa,EAC1CM,OAAO,EACR,GAAGd;IAEJ,MAAME,WAAW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,SAAS,kBAAkB;QAC5CL,QAAQI,KAAK,GAAGJ,QAAQI,KAAK,CAACE,MAAM,CAAC,CAACC,IAAMA,MAAM;QAClD,IAAIP,QAAQI,KAAK,CAACI,MAAM,KAAK,GAAG,OAAO;IACzC;IAEA,mFAAmF;IACnF,IAAIR,QAAQS,GAAG,EAAEC,MAAM,CAACC,KAAOA,GAAGN,QAAQ,CAAC,qBAAqBM,GAAGN,QAAQ,CAAC,sBAC1E,OAAO;IAET,OAAO;AACT;AAEA;;;;;;CAMC,GACD,OAAO,eAAeO,mBAAmB5B,MAAoB;IAC3D,IAAI,OAAOA,OAAOjC,KAAK,EAAE2C,eAAeE,UAAU,UAAU;QAC1D,MAAM,IAAIiB,UACR;IAEJ;IAEA,IAAI,CAAC7B,OAAOE,IAAI,EAAE;QAChB,MAAM,IAAI4B,MACR;IAEJ;IAEA,OAAOpG,YAAYsE,QAAQ;QACzBjC,OAAO;YACL2C,eAAe;gBACbE,OAAO;oBACLC,QAAQzF,KAAKmC,IAAI,CAACyC,OAAOE,IAAI,EAAE,WAAW,WAAW;gBACvD;YACF;QACF;IACF;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAe6B,+BACpBlD,GAAc,EACdmD,aAA2B,EAC3BC,UAA0B;IAE1B,IAAIjC,SAASgC;IAEb,IAAI,OAAOC,eAAe,YAAY;QACpCxG,MAAM;QACNuE,SAAS,MAAMiC,WAAWjC,QAAQnB;IACpC,OAAO,IAAI,OAAOoD,eAAe,UAAU;QACzCxG,MAAM;QACNuE,SAAStE,YAAYsE,QAAQiC;IAC/B;IAEA,OAAOjC;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { generateWebManifest } from '
|
|
3
|
+
import { generateWebManifest } from '@sanity/cli-build/_internal';
|
|
4
4
|
const mimeTypes = {
|
|
5
5
|
'.ico': 'image/x-icon',
|
|
6
6
|
'.png': 'image/png',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/vite/plugin-sanity-favicons.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {type Plugin} from 'vite'\n\nimport {generateWebManifest} from '
|
|
1
|
+
{"version":3,"sources":["../../../src/server/vite/plugin-sanity-favicons.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {type Plugin} from 'vite'\n\nimport {generateWebManifest} from '@sanity/cli-build/_internal'\n\nconst mimeTypes: Record<string, string | undefined> = {\n '.ico': 'image/x-icon',\n '.png': 'image/png',\n '.svg': 'image/svg+xml',\n}\n\n/**\n * Fallback favicons plugin for Sanity.\n *\n * If a favicon is not found in the static folder, this plugin will serve the default\n * Sanity favicons from the npm bundle. If a custom `favicon.ico` is found in the static\n * folder, it will also be served for a root `/favicon.ico` request.\n *\n * @param options - Options for the plugin\n * @returns A Vite plugin\n * @internal\n */\nexport function sanityFaviconsPlugin({\n customFaviconsPath,\n defaultFaviconsPath,\n staticUrlPath,\n}: {\n customFaviconsPath: string\n defaultFaviconsPath: string\n staticUrlPath: string\n}): Plugin {\n const cache: {favicons?: string[]} = {}\n\n async function getFavicons(): Promise<string[]> {\n if (cache.favicons) {\n return cache.favicons\n }\n\n cache.favicons = await fs.readdir(defaultFaviconsPath)\n return cache.favicons\n }\n\n async function hasCustomFavicon(fileName: string): Promise<boolean> {\n try {\n await fs.access(path.join(customFaviconsPath, fileName))\n return true\n } catch {\n return false\n }\n }\n\n return {\n apply: 'serve',\n configureServer(viteDevServer) {\n const webManifest = JSON.stringify(generateWebManifest(staticUrlPath), null, 2)\n const webManifestPath = `${staticUrlPath}/manifest.webmanifest`\n\n viteDevServer.middlewares.use(async (req, res, next) => {\n if (req.url?.endsWith(webManifestPath)) {\n res.writeHead(200, 'OK', {'content-type': 'application/manifest+json'})\n res.write(webManifest)\n res.end()\n return\n }\n\n const parsedUrl =\n typeof req === 'object' &&\n req !== null &&\n '_parsedUrl' in req &&\n req._parsedUrl instanceof URL\n ? req._parsedUrl\n : new URL(req.url || '/', 'http://localhost:3333')\n\n const pathName = parsedUrl.pathname || ''\n const fileName = path.basename(pathName || '')\n const icons = await getFavicons()\n const isIconRequest =\n pathName.startsWith('/favicon.ico') ||\n (icons.includes(fileName) && pathName.includes(staticUrlPath))\n\n if (!isIconRequest) {\n next()\n return\n }\n\n const faviconPath = (await hasCustomFavicon(fileName))\n ? path.join(customFaviconsPath, fileName)\n : path.join(defaultFaviconsPath, fileName)\n\n const mimeType = mimeTypes[path.extname(fileName)] || 'application/octet-stream'\n res.writeHead(200, 'OK', {'content-type': mimeType})\n res.write(await fs.readFile(faviconPath))\n res.end()\n })\n },\n name: 'sanity/server/sanity-favicons',\n }\n}\n"],"names":["fs","path","generateWebManifest","mimeTypes","sanityFaviconsPlugin","customFaviconsPath","defaultFaviconsPath","staticUrlPath","cache","getFavicons","favicons","readdir","hasCustomFavicon","fileName","access","join","apply","configureServer","viteDevServer","webManifest","JSON","stringify","webManifestPath","middlewares","use","req","res","next","url","endsWith","writeHead","write","end","parsedUrl","_parsedUrl","URL","pathName","pathname","basename","icons","isIconRequest","startsWith","includes","faviconPath","mimeType","extname","readFile","name"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAI5B,SAAQC,mBAAmB,QAAO,8BAA6B;AAE/D,MAAMC,YAAgD;IACpD,QAAQ;IACR,QAAQ;IACR,QAAQ;AACV;AAEA;;;;;;;;;;CAUC,GACD,OAAO,SAASC,qBAAqB,EACnCC,kBAAkB,EAClBC,mBAAmB,EACnBC,aAAa,EAKd;IACC,MAAMC,QAA+B,CAAC;IAEtC,eAAeC;QACb,IAAID,MAAME,QAAQ,EAAE;YAClB,OAAOF,MAAME,QAAQ;QACvB;QAEAF,MAAME,QAAQ,GAAG,MAAMV,GAAGW,OAAO,CAACL;QAClC,OAAOE,MAAME,QAAQ;IACvB;IAEA,eAAeE,iBAA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lB,IAAIK,KAAK,CAAC,MAAM/B,GAAG8C,QAAQ,CAACH;gBAC5BjB,IAAIM,GAAG;YACT;QACF;QACAe,MAAM;IACR;AACF"}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.2",
|
|
4
4
|
"description": "Sanity CLI tool for managing Sanity projects and organizations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"!./dist/**/__tests__",
|
|
31
31
|
"./oclif.config.js",
|
|
32
32
|
"./oclif.manifest.json",
|
|
33
|
-
"./static",
|
|
34
33
|
"./templates"
|
|
35
34
|
],
|
|
36
35
|
"type": "module",
|
|
@@ -104,7 +103,6 @@
|
|
|
104
103
|
"react": "^19.2.4",
|
|
105
104
|
"react-dom": "^19.2.4",
|
|
106
105
|
"react-is": "^19.2.4",
|
|
107
|
-
"read-package-up": "^12.0.0",
|
|
108
106
|
"rxjs": "^7.8.2",
|
|
109
107
|
"semver": "^7.7.4",
|
|
110
108
|
"smol-toml": "^1.6.1",
|
|
@@ -118,6 +116,7 @@
|
|
|
118
116
|
"which": "^6.0.1",
|
|
119
117
|
"yaml": "^2.8.4",
|
|
120
118
|
"zod": "^4.3.6",
|
|
119
|
+
"@sanity/cli-build": "^0.1.0",
|
|
121
120
|
"@sanity/cli-core": "^1.3.2"
|
|
122
121
|
},
|
|
123
122
|
"devDependencies": {
|
|
@@ -151,8 +150,8 @@
|
|
|
151
150
|
"typescript": "^5.9.3",
|
|
152
151
|
"vite-tsconfig-paths": "^6.1.1",
|
|
153
152
|
"vitest": "^4.1.5",
|
|
154
|
-
"@repo/tsconfig": "3.70.0",
|
|
155
153
|
"@repo/package.config": "0.0.1",
|
|
154
|
+
"@repo/tsconfig": "3.70.0",
|
|
156
155
|
"@sanity/cli-test": "0.3.3",
|
|
157
156
|
"@sanity/eslint-config-cli": "1.1.1"
|
|
158
157
|
},
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/ /**
|
|
4
|
-
* @internal
|
|
5
|
-
*/ export function generateWebManifest(basePath) {
|
|
6
|
-
return {
|
|
7
|
-
icons: [
|
|
8
|
-
{
|
|
9
|
-
sizes: '96x96',
|
|
10
|
-
src: `${basePath}/favicon-96.png`,
|
|
11
|
-
type: 'image/png'
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
sizes: '192x192',
|
|
15
|
-
src: `${basePath}/favicon-192.png`,
|
|
16
|
-
type: 'image/png'
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
sizes: '512x512',
|
|
20
|
-
src: `${basePath}/favicon-512.png`,
|
|
21
|
-
type: 'image/png'
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=generateWebManifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/generateWebManifest.ts"],"sourcesContent":["/**\n * @internal\n */\ninterface WebManifest {\n icons: {\n sizes: string\n src: string\n type: string\n }[]\n}\n\n/**\n * @internal\n */\nexport function generateWebManifest(basePath: string): WebManifest {\n return {\n icons: [\n {sizes: '96x96', src: `${basePath}/favicon-96.png`, type: 'image/png'},\n {sizes: '192x192', src: `${basePath}/favicon-192.png`, type: 'image/png'},\n {sizes: '512x512', src: `${basePath}/favicon-512.png`, type: 'image/png'},\n ],\n }\n}\n"],"names":["generateWebManifest","basePath","icons","sizes","src","type"],"mappings":"AAAA;;CAEC,GASD;;CAEC,GACD,OAAO,SAASA,oBAAoBC,QAAgB;IAClD,OAAO;QACLC,OAAO;YACL;gBAACC,OAAO;gBAASC,KAAK,GAAGH,SAAS,eAAe,CAAC;gBAAEI,MAAM;YAAW;YACrE;gBAACF,OAAO;gBAAWC,KAAK,GAAGH,SAAS,gBAAgB,CAAC;gBAAEI,MAAM;YAAW;YACxE;gBAACF,OAAO;gBAAWC,KAAK,GAAGH,SAAS,gBAAgB,CAAC;gBAAEI,MAAM;YAAW;SACzE;IACH;AACF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { readPackageUp } from 'read-package-up';
|
|
4
|
-
import { copyDir } from '../../util/copyDir.js';
|
|
5
|
-
import { writeWebManifest } from './writeWebManifest.js';
|
|
6
|
-
export async function writeFavicons(basePath, destDir) {
|
|
7
|
-
const sanityPkgPath = (await readPackageUp({
|
|
8
|
-
cwd: import.meta.dirname
|
|
9
|
-
}))?.path;
|
|
10
|
-
const faviconsPath = sanityPkgPath ? path.join(path.dirname(sanityPkgPath), 'static', 'favicons') : undefined;
|
|
11
|
-
if (!faviconsPath) {
|
|
12
|
-
throw new Error('Unable to resolve `@sanity/cli` module root');
|
|
13
|
-
}
|
|
14
|
-
await fs.mkdir(destDir, {
|
|
15
|
-
recursive: true
|
|
16
|
-
});
|
|
17
|
-
await copyDir(faviconsPath, destDir, true);
|
|
18
|
-
await writeWebManifest(basePath, destDir);
|
|
19
|
-
// Copy the /static/favicon.ico to /favicon.ico as well, because some tools/browsers
|
|
20
|
-
// blindly expects it to be there before requesting the HTML containing the actual path
|
|
21
|
-
await fs.copyFile(path.join(destDir, 'favicon.ico'), path.join(destDir, '..', 'favicon.ico'));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=writeFavicons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/writeFavicons.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {readPackageUp} from 'read-package-up'\n\nimport {copyDir} from '../../util/copyDir.js'\nimport {writeWebManifest} from './writeWebManifest.js'\n\nexport async function writeFavicons(basePath: string, destDir: string): Promise<void> {\n const sanityPkgPath = (await readPackageUp({cwd: import.meta.dirname}))?.path\n\n const faviconsPath = sanityPkgPath\n ? path.join(path.dirname(sanityPkgPath), 'static', 'favicons')\n : undefined\n\n if (!faviconsPath) {\n throw new Error('Unable to resolve `@sanity/cli` module root')\n }\n\n await fs.mkdir(destDir, {recursive: true})\n await copyDir(faviconsPath, destDir, true)\n await writeWebManifest(basePath, destDir)\n\n // Copy the /static/favicon.ico to /favicon.ico as well, because some tools/browsers\n // blindly expects it to be there before requesting the HTML containing the actual path\n await fs.copyFile(path.join(destDir, 'favicon.ico'), path.join(destDir, '..', 'favicon.ico'))\n}\n"],"names":["fs","path","readPackageUp","copyDir","writeWebManifest","writeFavicons","basePath","destDir","sanityPkgPath","cwd","dirname","faviconsPath","join","undefined","Error","mkdir","recursive","copyFile"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAE5B,SAAQC,aAAa,QAAO,kBAAiB;AAE7C,SAAQC,OAAO,QAAO,wBAAuB;AAC7C,SAAQC,gBAAgB,QAAO,wBAAuB;AAEtD,OAAO,eAAeC,cAAcC,QAAgB,EAAEC,OAAe;IACnE,MAAMC,gBAAiB,CAAA,MAAMN,cAAc;QAACO,KAAK,YAAYC,OAAO;IAAA,EAAC,GAAIT;IAEzE,MAAMU,eAAeH,gBACjBP,KAAKW,IAAI,CAACX,KAAKS,OAAO,CAACF,gBAAgB,UAAU,cACjDK;IAEJ,IAAI,CAACF,cAAc;QACjB,MAAM,IAAIG,MAAM;IAClB;IAEA,MAAMd,GAAGe,KAAK,CAACR,SAAS;QAACS,WAAW;IAAI;IACxC,MAAMb,QAAQQ,cAAcJ,SAAS;IACrC,MAAMH,iBAAiBE,UAAUC;IAEjC,oFAAoF;IACpF,uFAAuF;IACvF,MAAMP,GAAGiB,QAAQ,CAAChB,KAAKW,IAAI,CAACL,SAAS,gBAAgBN,KAAKW,IAAI,CAACL,SAAS,MAAM;AAChF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { skipIfExistsError } from '../../util/copyDir.js';
|
|
4
|
-
import { generateWebManifest } from './generateWebManifest.js';
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/ export async function writeWebManifest(basePath, destDir) {
|
|
8
|
-
const content = JSON.stringify(generateWebManifest(basePath), null, 2);
|
|
9
|
-
await fs.writeFile(path.join(destDir, 'manifest.webmanifest'), content, 'utf8').catch(skipIfExistsError);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=writeWebManifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/writeWebManifest.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport path from 'node:path'\n\nimport {skipIfExistsError} from '../../util/copyDir.js'\nimport {generateWebManifest} from './generateWebManifest.js'\n\n/**\n * @internal\n */\nexport async function writeWebManifest(basePath: string, destDir: string): Promise<void> {\n const content = JSON.stringify(generateWebManifest(basePath), null, 2)\n await fs\n .writeFile(path.join(destDir, 'manifest.webmanifest'), content, 'utf8')\n .catch(skipIfExistsError)\n}\n"],"names":["fs","path","skipIfExistsError","generateWebManifest","writeWebManifest","basePath","destDir","content","JSON","stringify","writeFile","join","catch"],"mappings":"AAAA,OAAOA,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAE5B,SAAQC,iBAAiB,QAAO,wBAAuB;AACvD,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D;;CAEC,GACD,OAAO,eAAeC,iBAAiBC,QAAgB,EAAEC,OAAe;IACtE,MAAMC,UAAUC,KAAKC,SAAS,CAACN,oBAAoBE,WAAW,MAAM;IACpE,MAAML,GACHU,SAAS,CAACT,KAAKU,IAAI,CAACL,SAAS,yBAAyBC,SAAS,QAC/DK,KAAK,CAACV;AACX"}
|
package/dist/util/copyDir.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { constants as fsConstants } from 'node:fs';
|
|
2
|
-
import fs from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
/**
|
|
5
|
-
* Tries to read a directory, and returns an empty array if the directory does not exist
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*
|
|
9
|
-
* @param dir - Directory to read
|
|
10
|
-
* @returns List of files in the directory
|
|
11
|
-
*/ async function tryReadDir(dir) {
|
|
12
|
-
try {
|
|
13
|
-
const content = await fs.readdir(dir);
|
|
14
|
-
return content;
|
|
15
|
-
} catch (err) {
|
|
16
|
-
if (err.code === 'ENOENT') {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
throw err;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Skips an error if the file already exists
|
|
24
|
-
*
|
|
25
|
-
* @internal
|
|
26
|
-
*
|
|
27
|
-
* @param err - Error to check
|
|
28
|
-
*/ export function skipIfExistsError(err) {
|
|
29
|
-
if (err.code === 'EEXIST') {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
throw err;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Copies a directory from one location to another
|
|
36
|
-
*
|
|
37
|
-
* @internal
|
|
38
|
-
*
|
|
39
|
-
* @param srcDir - Source directory
|
|
40
|
-
* @param destDir - Destination directory
|
|
41
|
-
* @param skipExisting - Skip existing files
|
|
42
|
-
*/ export async function copyDir(srcDir, destDir, skipExisting) {
|
|
43
|
-
await fs.mkdir(destDir, {
|
|
44
|
-
recursive: true
|
|
45
|
-
});
|
|
46
|
-
for (const file of (await tryReadDir(srcDir))){
|
|
47
|
-
const srcFile = path.resolve(srcDir, file);
|
|
48
|
-
if (srcFile === destDir) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const destFile = path.resolve(destDir, file);
|
|
52
|
-
const stat = await fs.stat(srcFile);
|
|
53
|
-
if (stat.isDirectory()) {
|
|
54
|
-
await copyDir(srcFile, destFile, skipExisting);
|
|
55
|
-
} else if (skipExisting) {
|
|
56
|
-
await fs.copyFile(srcFile, destFile, fsConstants.COPYFILE_EXCL).catch(skipIfExistsError);
|
|
57
|
-
} else {
|
|
58
|
-
await fs.copyFile(srcFile, destFile);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=copyDir.js.map
|
package/dist/util/copyDir.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/copyDir.ts"],"sourcesContent":["import {constants as fsConstants} from 'node:fs'\nimport fs from 'node:fs/promises'\nimport path from 'node:path'\n\n/**\n * Tries to read a directory, and returns an empty array if the directory does not exist\n *\n * @internal\n *\n * @param dir - Directory to read\n * @returns List of files in the directory\n */\nasync function tryReadDir(dir: string): Promise<string[]> {\n try {\n const content = await fs.readdir(dir)\n return content\n } catch (err) {\n if (err.code === 'ENOENT') {\n return []\n }\n\n throw err\n }\n}\n\n/**\n * Skips an error if the file already exists\n *\n * @internal\n *\n * @param err - Error to check\n */\nexport function skipIfExistsError(err: Error & {code: string}) {\n if (err.code === 'EEXIST') {\n return\n }\n\n throw err\n}\n\n/**\n * Copies a directory from one location to another\n *\n * @internal\n *\n * @param srcDir - Source directory\n * @param destDir - Destination directory\n * @param skipExisting - Skip existing files\n */\nexport async function copyDir(\n srcDir: string,\n destDir: string,\n skipExisting?: boolean,\n): Promise<void> {\n await fs.mkdir(destDir, {recursive: true})\n\n for (const file of await tryReadDir(srcDir)) {\n const srcFile = path.resolve(srcDir, file)\n if (srcFile === destDir) {\n continue\n }\n\n const destFile = path.resolve(destDir, file)\n const stat = await fs.stat(srcFile)\n\n if (stat.isDirectory()) {\n await copyDir(srcFile, destFile, skipExisting)\n } else if (skipExisting) {\n await fs.copyFile(srcFile, destFile, fsConstants.COPYFILE_EXCL).catch(skipIfExistsError)\n } else {\n await fs.copyFile(srcFile, destFile)\n }\n }\n}\n"],"names":["constants","fsConstants","fs","path","tryReadDir","dir","content","readdir","err","code","skipIfExistsError","copyDir","srcDir","destDir","skipExisting","mkdir","recursive","file","srcFile","resolve","destFile","stat","isDirectory","copyFile","COPYFILE_EXCL","catch"],"mappings":"AAAA,SAAQA,aAAaC,WAAW,QAAO,UAAS;AAChD,OAAOC,QAAQ,mBAAkB;AACjC,OAAOC,UAAU,YAAW;AAE5B;;;;;;;CAOC,GACD,eAAeC,WAAWC,GAAW;IACnC,IAAI;QACF,MAAMC,UAAU,MAAMJ,GAAGK,OAAO,CAACF;QACjC,OAAOC;IACT,EAAE,OAAOE,KAAK;QACZ,IAAIA,IAAIC,IAAI,KAAK,UAAU;YACzB,OAAO,EAAE;QACX;QAEA,MAAMD;IACR;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASE,kBAAkBF,GAA2B;IAC3D,IAAIA,IAAIC,IAAI,KAAK,UAAU;QACzB;IACF;IAEA,MAAMD;AACR;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeG,QACpBC,MAAc,EACdC,OAAe,EACfC,YAAsB;IAEtB,MAAMZ,GAAGa,KAAK,CAACF,SAAS;QAACG,WAAW;IAAI;IAExC,KAAK,MAAMC,QAAQ,CAAA,MAAMb,WAAWQ,OAAM,EAAG;QAC3C,MAAMM,UAAUf,KAAKgB,OAAO,CAACP,QAAQK;QACrC,IAAIC,YAAYL,SAAS;YACvB;QACF;QAEA,MAAMO,WAAWjB,KAAKgB,OAAO,CAACN,SAASI;QACvC,MAAMI,OAAO,MAAMnB,GAAGmB,IAAI,CAACH;QAE3B,IAAIG,KAAKC,WAAW,IAAI;YACtB,MAAMX,QAAQO,SAASE,UAAUN;QACnC,OAAO,IAAIA,cAAc;YACvB,MAAMZ,GAAGqB,QAAQ,CAACL,SAASE,UAAUnB,YAAYuB,aAAa,EAAEC,KAAK,CAACf;QACxE,OAAO;YACL,MAAMR,GAAGqB,QAAQ,CAACL,SAASE;QAC7B;IACF;AACF"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<rect width="512" height="512" fill="#0B0B0B"/>
|
|
3
|
-
<rect width="256" height="256" fill="#0B0B0B"/>
|
|
4
|
-
<g clip-path="url(#clip0_261_6485)">
|
|
5
|
-
<path d="M431.519 304.966L417.597 280.733L350.26 321.759L425.051 226.504L436.358 219.867L433.56 215.662L438.697 209.096L415.097 189.445L404.295 203.215L186.253 330.829L266.869 233.849L417.024 151.513L402.758 123.926L320.972 168.755L361.246 120.336L338.174 100L247.535 209.026L157.515 258.413L226.435 167.267L269.621 144.782L255.906 116.888L130.085 182.407L164.396 136.987L140.429 117.785L68 213.678L69.1238 214.576L82.6554 242.139L162.951 200.31L89.7653 297.077L101.76 306.69L108.893 320.484L193.431 274.12L100.338 386.121L123.411 406.457L128.044 400.883L352.623 269.018L278.061 364.014L279.277 365.029L279.162 365.1L294.62 392.002L393.791 331.561L355.604 393.207L381.199 410L442 311.863L431.519 304.966Z" fill="white"/>
|
|
6
|
-
</g>
|
|
7
|
-
<defs>
|
|
8
|
-
<clipPath id="clip0_261_6485">
|
|
9
|
-
<rect width="374" height="310" fill="white" transform="translate(68 100)"/>
|
|
10
|
-
</clipPath>
|
|
11
|
-
</defs>
|
|
12
|
-
</svg>
|