@sanity/cli-test 0.0.2-alpha.1 → 0.0.2-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +228 -0
  2. package/dist/index.d.ts +516 -3
  3. package/dist/index.js +8 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/test/constants.js +21 -0
  6. package/dist/test/constants.js.map +1 -0
  7. package/dist/test/createTestClient.js +53 -0
  8. package/dist/test/createTestClient.js.map +1 -0
  9. package/dist/test/createTestToken.js +13 -0
  10. package/dist/test/createTestToken.js.map +1 -0
  11. package/dist/test/mockApi.js +5 -3
  12. package/dist/test/mockApi.js.map +1 -1
  13. package/dist/test/mockSanityCommand.js +68 -0
  14. package/dist/test/mockSanityCommand.js.map +1 -0
  15. package/dist/test/mockTelemetry.js +22 -0
  16. package/dist/test/mockTelemetry.js.map +1 -0
  17. package/dist/test/setupFixtures.js +138 -0
  18. package/dist/test/setupFixtures.js.map +1 -0
  19. package/dist/test/snapshotSerializer.js +12 -0
  20. package/dist/test/snapshotSerializer.js.map +1 -0
  21. package/dist/test/testCommand.js +11 -4
  22. package/dist/test/testCommand.js.map +1 -1
  23. package/dist/test/testFixture.js +112 -0
  24. package/dist/test/testFixture.js.map +1 -0
  25. package/dist/test/testHook.js +23 -7
  26. package/dist/test/testHook.js.map +1 -1
  27. package/dist/utils/fileExists.js +13 -0
  28. package/dist/utils/fileExists.js.map +1 -0
  29. package/dist/utils/paths.js +66 -0
  30. package/dist/utils/paths.js.map +1 -0
  31. package/dist/vitest.d.ts +116 -0
  32. package/dist/vitest.js +22 -0
  33. package/dist/vitest.js.map +1 -0
  34. package/dist/vitestWorker.js +135 -0
  35. package/dist/vitestWorker.js.map +1 -0
  36. package/fixtures/basic-app/package.json +26 -0
  37. package/fixtures/basic-app/sanity.cli.ts +12 -0
  38. package/fixtures/basic-app/src/App.css +20 -0
  39. package/fixtures/basic-app/src/App.tsx +26 -0
  40. package/fixtures/basic-app/src/ExampleComponent.css +84 -0
  41. package/fixtures/basic-app/src/ExampleComponent.tsx +38 -0
  42. package/fixtures/basic-app/tsconfig.json +17 -0
  43. package/fixtures/basic-studio/package.json +28 -0
  44. package/fixtures/basic-studio/sanity.cli.ts +11 -0
  45. package/fixtures/basic-studio/sanity.config.ts +18 -0
  46. package/fixtures/basic-studio/schemaTypes/author.ts +52 -0
  47. package/fixtures/basic-studio/schemaTypes/blockContent.ts +71 -0
  48. package/fixtures/basic-studio/schemaTypes/category.ts +20 -0
  49. package/fixtures/basic-studio/schemaTypes/index.ts +6 -0
  50. package/fixtures/basic-studio/schemaTypes/post.ts +67 -0
  51. package/fixtures/basic-studio/tsconfig.json +17 -0
  52. package/fixtures/multi-workspace-studio/package.json +28 -0
  53. package/fixtures/multi-workspace-studio/sanity.cli.ts +11 -0
  54. package/fixtures/multi-workspace-studio/sanity.config.ts +37 -0
  55. package/fixtures/multi-workspace-studio/schemaTypes/author.ts +52 -0
  56. package/fixtures/multi-workspace-studio/schemaTypes/blockContent.ts +70 -0
  57. package/fixtures/multi-workspace-studio/schemaTypes/category.ts +20 -0
  58. package/fixtures/multi-workspace-studio/schemaTypes/index.ts +6 -0
  59. package/fixtures/multi-workspace-studio/schemaTypes/post.ts +67 -0
  60. package/fixtures/multi-workspace-studio/tsconfig.json +17 -0
  61. package/fixtures/prebuilt-app/README.md +3 -0
  62. package/fixtures/prebuilt-app/dist/favicon.ico +0 -0
  63. package/fixtures/prebuilt-app/dist/index.html +102 -0
  64. package/fixtures/prebuilt-app/dist/static/sanity-CtOxKsdo.css +24 -0
  65. package/fixtures/prebuilt-app/dist/static/sanity-D4a4eOYZ.js +17 -0
  66. package/fixtures/prebuilt-app/package.json +26 -0
  67. package/fixtures/prebuilt-app/sanity.cli.ts +12 -0
  68. package/fixtures/prebuilt-app/src/App.css +20 -0
  69. package/fixtures/prebuilt-app/src/App.tsx +24 -0
  70. package/fixtures/prebuilt-app/tsconfig.json +17 -0
  71. package/fixtures/prebuilt-studio/README.md +3 -0
  72. package/fixtures/prebuilt-studio/dist/favicon.ico +0 -0
  73. package/fixtures/prebuilt-studio/dist/index.html +113 -0
  74. package/fixtures/prebuilt-studio/dist/static/sanity-DxH-rpFr.js +9 -0
  75. package/fixtures/prebuilt-studio/package.json +25 -0
  76. package/fixtures/prebuilt-studio/sanity.cli.ts +11 -0
  77. package/fixtures/prebuilt-studio/sanity.config.ts +11 -0
  78. package/fixtures/prebuilt-studio/tsconfig.json +17 -0
  79. package/fixtures/worst-case-studio/README.md +21 -0
  80. package/fixtures/worst-case-studio/package.json +32 -0
  81. package/fixtures/worst-case-studio/sanity.cli.ts +16 -0
  82. package/fixtures/worst-case-studio/sanity.config.tsx +49 -0
  83. package/fixtures/worst-case-studio/src/defines.ts +8 -0
  84. package/fixtures/worst-case-studio/src/descriptionIcon.svg +7 -0
  85. package/fixtures/worst-case-studio/src/descriptionInput.module.css +13 -0
  86. package/fixtures/worst-case-studio/src/descriptionInput.tsx +55 -0
  87. package/fixtures/worst-case-studio/src/schemaTypes/author.ts +52 -0
  88. package/fixtures/worst-case-studio/src/schemaTypes/blockContent.ts +70 -0
  89. package/fixtures/worst-case-studio/src/schemaTypes/category.ts +20 -0
  90. package/fixtures/worst-case-studio/src/schemaTypes/index.ts +6 -0
  91. package/fixtures/worst-case-studio/src/schemaTypes/post.ts +71 -0
  92. package/fixtures/worst-case-studio/src/typings.d.ts +37 -0
  93. package/fixtures/worst-case-studio/tsconfig.json +22 -0
  94. package/package.json +52 -22
  95. package/dist/test/captureOutput.d.ts +0 -33
  96. package/dist/test/mockApi.d.ts +0 -34
  97. package/dist/test/testCommand.d.ts +0 -6
  98. package/dist/test/testHook.d.ts +0 -8
@@ -0,0 +1,116 @@
1
+ import {TestProject} from 'vitest/node'
2
+
3
+ /**
4
+ * Global setup function for initializing test fixtures.
5
+ *
6
+ * Copies fixtures from the bundled location to a temp directory
7
+ * and installs dependencies.
8
+ *
9
+ * Note: Fixtures are NOT built during setup. Tests that need built
10
+ * fixtures should build them as part of the test.
11
+ *
12
+ * This function is designed to be used with vitest globalSetup.
13
+ *
14
+ * @public
15
+ *
16
+ * @param options - Configuration options
17
+ * @example
18
+ * ```typescript
19
+ * // In vitest.config.ts
20
+ * export default defineConfig({
21
+ * test: {
22
+ * globalSetup: ['@sanity/cli-test/vitest']
23
+ * }
24
+ * })
25
+ * ```
26
+ */
27
+ export declare function setup(_: TestProject, options?: SetupTestFixturesOptions): Promise<void>
28
+
29
+ /**
30
+ * Options for setupTestFixtures
31
+ *
32
+ * @public
33
+ */
34
+ declare interface SetupTestFixturesOptions {
35
+ /**
36
+ * Glob patterns for additional fixture directories to set up.
37
+ *
38
+ * Each pattern is matched against directories in the current working directory.
39
+ * Only directories containing a `package.json` file are included.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * ['fixtures/*', 'dev/*']
44
+ * ```
45
+ */
46
+ additionalFixtures?: string[]
47
+ /**
48
+ * Custom temp directory path. Defaults to process.cwd()/tmp
49
+ */
50
+ tempDir?: string
51
+ }
52
+
53
+ /**
54
+ * Setup function to build the worker files with esbuild.
55
+ *
56
+ * Bundles the worker files with esbuild and sets up watch mode if in watch mode.
57
+ * All npm packages are automatically marked as external (loaded from node_modules at runtime).
58
+ * Only internal project code is bundled inline.
59
+ *
60
+ * @public
61
+ *
62
+ * @param filePaths - The paths to the worker files to build
63
+ * @returns A promise that resolves when the worker build is setup
64
+ * @throws If the worker files cannot be bundled
65
+ * @throws If the watcher cannot be set up
66
+ */
67
+ export declare function setupWorkerBuild(filePaths: string[]): Promise<void>
68
+
69
+ /**
70
+ * Serializer for snapshot tests to normalize line endings and Windows ^ to Unix `\`
71
+ * @public
72
+ */
73
+ export declare const snapshotSerializer: {
74
+ serialize: (val: string) => string
75
+ test: (val: unknown) => val is string
76
+ }
77
+
78
+ /**
79
+ * Teardown function to clean up test fixtures.
80
+ *
81
+ * Removes the temp directory created by setupTestFixtures.
82
+ *
83
+ * This function is designed to be used with vitest globalSetup.
84
+ *
85
+ * @public
86
+ *
87
+ * @param options - Configuration options
88
+ */
89
+ export declare function teardown(options?: TeardownTestFixturesOptions): Promise<void>
90
+
91
+ /**
92
+ * Options for teardownTestFixtures
93
+ *
94
+ * @public
95
+ */
96
+ declare interface TeardownTestFixturesOptions {
97
+ /**
98
+ * Custom temp directory path. Defaults to process.cwd()/tmp
99
+ */
100
+ tempDir?: string
101
+ }
102
+
103
+ /**
104
+ * Teardown function to clean up the worker build.
105
+ *
106
+ * Closes all build contexts and deletes the compiled JavaScript files.
107
+ *
108
+ * @public
109
+ *
110
+ * @returns A promise that resolves when the worker build is teared down
111
+ * @throws If the build contexts cannot be disposed
112
+ * @throws If the compiled JavaScript files cannot be deleted
113
+ */
114
+ export declare function teardownWorkerBuild(): Promise<void>
115
+
116
+ export {}
package/dist/vitest.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Vitest global setup entry point.
3
+ *
4
+ * Import this in your vitest.config.ts globalSetup array for automatic
5
+ * test fixture setup and teardown.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // vitest.config.ts
10
+ * import {defineConfig} from 'vitest/config'
11
+ *
12
+ * export default defineConfig({
13
+ * test: {
14
+ * globalSetup: ['@sanity/cli-test/vitest']
15
+ * }
16
+ * })
17
+ * ```
18
+ */ export { setup, teardown } from './test/setupFixtures.js';
19
+ export { snapshotSerializer } from './test/snapshotSerializer.js';
20
+ export { setupWorkerBuild, teardownWorkerBuild } from './vitestWorker.js';
21
+
22
+ //# sourceMappingURL=vitest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vitest.ts"],"sourcesContent":["/**\n * Vitest global setup entry point.\n *\n * Import this in your vitest.config.ts globalSetup array for automatic\n * test fixture setup and teardown.\n *\n * @example\n * ```typescript\n * // vitest.config.ts\n * import {defineConfig} from 'vitest/config'\n *\n * export default defineConfig({\n * test: {\n * globalSetup: ['@sanity/cli-test/vitest']\n * }\n * })\n * ```\n */\nexport {setup, teardown} from './test/setupFixtures.js'\nexport {snapshotSerializer} from './test/snapshotSerializer.js'\n\nexport {setupWorkerBuild, teardownWorkerBuild} from './vitestWorker.js'\n"],"names":["setup","teardown","snapshotSerializer","setupWorkerBuild","teardownWorkerBuild"],"mappings":"AAAA;;;;;;;;;;;;;;;;;CAiBC,GACD,SAAQA,KAAK,EAAEC,QAAQ,QAAO,0BAAyB;AACvD,SAAQC,kBAAkB,QAAO,+BAA8B;AAE/D,SAAQC,gBAAgB,EAAEC,mBAAmB,QAAO,oBAAmB"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Vitest worker setup for the Sanity CLI.
3
+ *
4
+ * This builds the worker TS files into JS files using esbuild bundling.
5
+ * All internal dependencies are bundled inline, while npm packages remain external.
6
+ */ import { unlink } from 'node:fs/promises';
7
+ import { build, context } from 'esbuild';
8
+ const compiledFiles = new Set();
9
+ let buildContexts = [];
10
+ /**
11
+ * Generate esbuild configuration for bundling worker files.
12
+ *
13
+ * @param filePath - The worker file path to bundle
14
+ * @param outputFile - The output file path for the bundled worker
15
+ * @returns esbuild configuration object
16
+ */ function esbuildOptions(filePath, outputFile) {
17
+ return {
18
+ bundle: true,
19
+ conditions: [
20
+ 'node',
21
+ 'import'
22
+ ],
23
+ entryPoints: [
24
+ filePath
25
+ ],
26
+ // Marks cli-core as external to avoid bundling it inline
27
+ // this is mostly necessary for the monorepo.
28
+ external: [
29
+ '@sanity/cli-core'
30
+ ],
31
+ format: 'esm',
32
+ loader: {
33
+ '.json': 'json'
34
+ },
35
+ logLevel: 'warning',
36
+ mainFields: [
37
+ 'module',
38
+ 'main'
39
+ ],
40
+ outfile: outputFile,
41
+ packages: 'external',
42
+ platform: 'node',
43
+ sourcemap: false,
44
+ target: 'node20'
45
+ };
46
+ }
47
+ /**
48
+ * Bundle a single worker file with esbuild.
49
+ *
50
+ * @param filePath - The worker file path to bundle
51
+ * @param external - Array of package names to keep external
52
+ * @returns The output file path
53
+ */ async function bundleWorkerFile(filePath) {
54
+ const outputFile = filePath.replace(/\.ts$/, '.js');
55
+ await build(esbuildOptions(filePath, outputFile));
56
+ compiledFiles.add(outputFile);
57
+ return outputFile;
58
+ }
59
+ /**
60
+ * Bundle all worker files with esbuild (non-watch mode).
61
+ *
62
+ * @param filePaths - Array of worker file paths to bundle
63
+ */ async function setupBundling(filePaths) {
64
+ console.log(`Found ${filePaths.length} worker files to bundle`);
65
+ for (const workerFile of filePaths){
66
+ try {
67
+ await bundleWorkerFile(workerFile);
68
+ console.log(`✓ Bundled ${workerFile}`);
69
+ } catch (error) {
70
+ console.error(`✗ Failed to bundle ${workerFile}:`, error);
71
+ throw error;
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * Set up watch mode for worker files using esbuild's native watch API.
77
+ *
78
+ * @param files - Array of worker file paths to watch
79
+ */ async function setupWatchMode(files) {
80
+ for (const filePath of files){
81
+ const outputFile = filePath.replace(/\.ts$/, '.js');
82
+ const ctx = await context(esbuildOptions(filePath, outputFile));
83
+ await ctx.watch();
84
+ buildContexts.push(ctx);
85
+ compiledFiles.add(outputFile);
86
+ console.log(`👀 Watching ${filePath}`);
87
+ }
88
+ }
89
+ /**
90
+ * Setup function to build the worker files with esbuild.
91
+ *
92
+ * Bundles the worker files with esbuild and sets up watch mode if in watch mode.
93
+ * All npm packages are automatically marked as external (loaded from node_modules at runtime).
94
+ * Only internal project code is bundled inline.
95
+ *
96
+ * @public
97
+ *
98
+ * @param filePaths - The paths to the worker files to build
99
+ * @returns A promise that resolves when the worker build is setup
100
+ * @throws If the worker files cannot be bundled
101
+ * @throws If the watcher cannot be set up
102
+ */ export async function setupWorkerBuild(filePaths) {
103
+ const isWatchMode = (process.env.VITEST_WATCH === 'true' || !process.argv.includes('run')) && process.env.CI !== 'true';
104
+ await (isWatchMode ? setupWatchMode(filePaths) : setupBundling(filePaths));
105
+ }
106
+ /**
107
+ * Teardown function to clean up the worker build.
108
+ *
109
+ * Closes all build contexts and deletes the compiled JavaScript files.
110
+ *
111
+ * @public
112
+ *
113
+ * @returns A promise that resolves when the worker build is teared down
114
+ * @throws If the build contexts cannot be disposed
115
+ * @throws If the compiled JavaScript files cannot be deleted
116
+ */ export async function teardownWorkerBuild() {
117
+ // Dispose all build contexts (for watch mode)
118
+ for (const ctx of buildContexts){
119
+ await ctx.dispose();
120
+ }
121
+ buildContexts = [];
122
+ // Clean up compiled JavaScript files
123
+ console.log('Cleaning up compiled JavaScript files...');
124
+ for (const filePath of compiledFiles){
125
+ try {
126
+ await unlink(filePath);
127
+ console.log(`✓ Deleted ${filePath}`);
128
+ } catch (error) {
129
+ console.error(`Failed to delete ${filePath}:`, error);
130
+ }
131
+ }
132
+ compiledFiles.clear();
133
+ }
134
+
135
+ //# sourceMappingURL=vitestWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vitestWorker.ts"],"sourcesContent":["/**\n * Vitest worker setup for the Sanity CLI.\n *\n * This builds the worker TS files into JS files using esbuild bundling.\n * All internal dependencies are bundled inline, while npm packages remain external.\n */\nimport {unlink} from 'node:fs/promises'\n\nimport {build, type BuildContext, type BuildOptions, context} from 'esbuild'\n\nconst compiledFiles: Set<string> = new Set()\nlet buildContexts: BuildContext[] = []\n\n/**\n * Generate esbuild configuration for bundling worker files.\n *\n * @param filePath - The worker file path to bundle\n * @param outputFile - The output file path for the bundled worker\n * @returns esbuild configuration object\n */\nfunction esbuildOptions(filePath: string, outputFile: string): BuildOptions {\n return {\n bundle: true,\n conditions: ['node', 'import'],\n entryPoints: [filePath],\n // Marks cli-core as external to avoid bundling it inline\n // this is mostly necessary for the monorepo.\n external: ['@sanity/cli-core'],\n format: 'esm',\n loader: {'.json': 'json'},\n logLevel: 'warning',\n mainFields: ['module', 'main'],\n outfile: outputFile,\n packages: 'external',\n platform: 'node',\n sourcemap: false,\n target: 'node20',\n }\n}\n\n/**\n * Bundle a single worker file with esbuild.\n *\n * @param filePath - The worker file path to bundle\n * @param external - Array of package names to keep external\n * @returns The output file path\n */\nasync function bundleWorkerFile(filePath: string): Promise<string> {\n const outputFile = filePath.replace(/\\.ts$/, '.js')\n\n await build(esbuildOptions(filePath, outputFile))\n\n compiledFiles.add(outputFile)\n return outputFile\n}\n\n/**\n * Bundle all worker files with esbuild (non-watch mode).\n *\n * @param filePaths - Array of worker file paths to bundle\n */\nasync function setupBundling(filePaths: string[]) {\n console.log(`Found ${filePaths.length} worker files to bundle`)\n\n for (const workerFile of filePaths) {\n try {\n await bundleWorkerFile(workerFile)\n console.log(`✓ Bundled ${workerFile}`)\n } catch (error) {\n console.error(`✗ Failed to bundle ${workerFile}:`, error)\n throw error\n }\n }\n}\n\n/**\n * Set up watch mode for worker files using esbuild's native watch API.\n *\n * @param files - Array of worker file paths to watch\n */\nasync function setupWatchMode(files: string[]) {\n for (const filePath of files) {\n const outputFile = filePath.replace(/\\.ts$/, '.js')\n\n const ctx = await context(esbuildOptions(filePath, outputFile))\n\n await ctx.watch()\n buildContexts.push(ctx)\n compiledFiles.add(outputFile)\n\n console.log(`👀 Watching ${filePath}`)\n }\n}\n\n/**\n * Setup function to build the worker files with esbuild.\n *\n * Bundles the worker files with esbuild and sets up watch mode if in watch mode.\n * All npm packages are automatically marked as external (loaded from node_modules at runtime).\n * Only internal project code is bundled inline.\n *\n * @public\n *\n * @param filePaths - The paths to the worker files to build\n * @returns A promise that resolves when the worker build is setup\n * @throws If the worker files cannot be bundled\n * @throws If the watcher cannot be set up\n */\nexport async function setupWorkerBuild(filePaths: string[]) {\n const isWatchMode =\n (process.env.VITEST_WATCH === 'true' || !process.argv.includes('run')) &&\n process.env.CI !== 'true'\n\n await (isWatchMode ? setupWatchMode(filePaths) : setupBundling(filePaths))\n}\n\n/**\n * Teardown function to clean up the worker build.\n *\n * Closes all build contexts and deletes the compiled JavaScript files.\n *\n * @public\n *\n * @returns A promise that resolves when the worker build is teared down\n * @throws If the build contexts cannot be disposed\n * @throws If the compiled JavaScript files cannot be deleted\n */\nexport async function teardownWorkerBuild(): Promise<void> {\n // Dispose all build contexts (for watch mode)\n for (const ctx of buildContexts) {\n await ctx.dispose()\n }\n buildContexts = []\n\n // Clean up compiled JavaScript files\n console.log('Cleaning up compiled JavaScript files...')\n for (const filePath of compiledFiles) {\n try {\n await unlink(filePath)\n console.log(`✓ Deleted ${filePath}`)\n } catch (error) {\n console.error(`Failed to delete ${filePath}:`, error)\n }\n }\n compiledFiles.clear()\n}\n"],"names":["unlink","build","context","compiledFiles","Set","buildContexts","esbuildOptions","filePath","outputFile","bundle","conditions","entryPoints","external","format","loader","logLevel","mainFields","outfile","packages","platform","sourcemap","target","bundleWorkerFile","replace","add","setupBundling","filePaths","console","log","length","workerFile","error","setupWatchMode","files","ctx","watch","push","setupWorkerBuild","isWatchMode","process","env","VITEST_WATCH","argv","includes","CI","teardownWorkerBuild","dispose","clear"],"mappings":"AAAA;;;;;CAKC,GACD,SAAQA,MAAM,QAAO,mBAAkB;AAEvC,SAAQC,KAAK,EAAwCC,OAAO,QAAO,UAAS;AAE5E,MAAMC,gBAA6B,IAAIC;AACvC,IAAIC,gBAAgC,EAAE;AAEtC;;;;;;CAMC,GACD,SAASC,eAAeC,QAAgB,EAAEC,UAAkB;IAC1D,OAAO;QACLC,QAAQ;QACRC,YAAY;YAAC;YAAQ;SAAS;QAC9BC,aAAa;YAACJ;SAAS;QACvB,yDAAyD;QACzD,6CAA6C;QAC7CK,UAAU;YAAC;SAAmB;QAC9BC,QAAQ;QACRC,QAAQ;YAAC,SAAS;QAAM;QACxBC,UAAU;QACVC,YAAY;YAAC;YAAU;SAAO;QAC9BC,SAAST;QACTU,UAAU;QACVC,UAAU;QACVC,WAAW;QACXC,QAAQ;IACV;AACF;AAEA;;;;;;CAMC,GACD,eAAeC,iBAAiBf,QAAgB;IAC9C,MAAMC,aAAaD,SAASgB,OAAO,CAAC,SAAS;IAE7C,MAAMtB,MAAMK,eAAeC,UAAUC;IAErCL,cAAcqB,GAAG,CAAChB;IAClB,OAAOA;AACT;AAEA;;;;CAIC,GACD,eAAeiB,cAAcC,SAAmB;IAC9CC,QAAQC,GAAG,CAAC,CAAC,MAAM,EAAEF,UAAUG,MAAM,CAAC,uBAAuB,CAAC;IAE9D,KAAK,MAAMC,cAAcJ,UAAW;QAClC,IAAI;YACF,MAAMJ,iBAAiBQ;YACvBH,QAAQC,GAAG,CAAC,CAAC,UAAU,EAAEE,YAAY;QACvC,EAAE,OAAOC,OAAO;YACdJ,QAAQI,KAAK,CAAC,CAAC,mBAAmB,EAAED,WAAW,CAAC,CAAC,EAAEC;YACnD,MAAMA;QACR;IACF;AACF;AAEA;;;;CAIC,GACD,eAAeC,eAAeC,KAAe;IAC3C,KAAK,MAAM1B,YAAY0B,MAAO;QAC5B,MAAMzB,aAAaD,SAASgB,OAAO,CAAC,SAAS;QAE7C,MAAMW,MAAM,MAAMhC,QAAQI,eAAeC,UAAUC;QAEnD,MAAM0B,IAAIC,KAAK;QACf9B,cAAc+B,IAAI,CAACF;QACnB/B,cAAcqB,GAAG,CAAChB;QAElBmB,QAAQC,GAAG,CAAC,CAAC,YAAY,EAAErB,UAAU;IACvC;AACF;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,eAAe8B,iBAAiBX,SAAmB;IACxD,MAAMY,cACJ,AAACC,CAAAA,QAAQC,GAAG,CAACC,YAAY,KAAK,UAAU,CAACF,QAAQG,IAAI,CAACC,QAAQ,CAAC,MAAK,KACpEJ,QAAQC,GAAG,CAACI,EAAE,KAAK;IAErB,MAAON,CAAAA,cAAcN,eAAeN,aAAaD,cAAcC,UAAS;AAC1E;AAEA;;;;;;;;;;CAUC,GACD,OAAO,eAAemB;IACpB,8CAA8C;IAC9C,KAAK,MAAMX,OAAO7B,cAAe;QAC/B,MAAM6B,IAAIY,OAAO;IACnB;IACAzC,gBAAgB,EAAE;IAElB,qCAAqC;IACrCsB,QAAQC,GAAG,CAAC;IACZ,KAAK,MAAMrB,YAAYJ,cAAe;QACpC,IAAI;YACF,MAAMH,OAAOO;YACboB,QAAQC,GAAG,CAAC,CAAC,UAAU,EAAErB,UAAU;QACrC,EAAE,OAAOwB,OAAO;YACdJ,QAAQI,KAAK,CAAC,CAAC,iBAAiB,EAAExB,SAAS,CAAC,CAAC,EAAEwB;QACjD;IACF;IACA5B,cAAc4C,KAAK;AACrB"}
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "basic-app",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "keywords": [
6
+ "sanity"
7
+ ],
8
+ "license": "UNLICENSED",
9
+ "main": "package.json",
10
+ "scripts": {
11
+ "dev": "sanity dev",
12
+ "start": "sanity start"
13
+ },
14
+ "dependencies": {
15
+ "@sanity/sdk": "^2.6.0",
16
+ "@sanity/sdk-react": "^2.6.0",
17
+ "react": "^19.2.3",
18
+ "react-dom": "^19.2.3",
19
+ "sanity": "^5.9.0"
20
+ },
21
+ "devDependencies": {
22
+ "@types/react": "^19.2.9",
23
+ "sanity": "^5.9.0",
24
+ "typescript": "^5.9.3"
25
+ }
26
+ }
@@ -0,0 +1,12 @@
1
+ import {defineCliConfig} from 'sanity/cli'
2
+
3
+ export default defineCliConfig({
4
+ app: {
5
+ entry: './src/App.tsx',
6
+ organizationId: 'org-id',
7
+ },
8
+ deployment: {
9
+ appId: 'app-id',
10
+ autoUpdates: true,
11
+ },
12
+ })
@@ -0,0 +1,20 @@
1
+ /* Container styling for the app */
2
+ .app-container {
3
+ max-width: 1200px;
4
+ margin: 0 auto;
5
+ padding: 2rem;
6
+ font-family:
7
+ -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
8
+ 'Helvetica Neue', sans-serif;
9
+ }
10
+
11
+ /* Basic reset */
12
+ * {
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ body {
17
+ margin: 0;
18
+ padding: 0;
19
+ background-color: #f9f9f9;
20
+ }
@@ -0,0 +1,26 @@
1
+ import {type SanityConfig} from '@sanity/sdk'
2
+ import {SanityApp} from '@sanity/sdk-react'
3
+
4
+ import {ExampleComponent} from './ExampleComponent'
5
+ import './App.css'
6
+
7
+ function App() {
8
+ // apps can access many different projects or other sources of data
9
+ const sanityConfigs: SanityConfig[] = [
10
+ {
11
+ dataset: 'dataset-name',
12
+ projectId: 'project-id',
13
+ },
14
+ ]
15
+
16
+ return (
17
+ <div className="app-container">
18
+ <SanityApp config={sanityConfigs} fallback={<div>Loading...</div>}>
19
+ {/* add your own components here! */}
20
+ <ExampleComponent />
21
+ </SanityApp>
22
+ </div>
23
+ )
24
+ }
25
+
26
+ export default App
@@ -0,0 +1,84 @@
1
+ .example-container {
2
+ background-color: white;
3
+ border-radius: 8px;
4
+ padding: 2rem;
5
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
6
+ }
7
+
8
+ .example-avatar-container {
9
+ position: relative;
10
+ margin-block-end: 1rem;
11
+ }
12
+
13
+ @keyframes wave {
14
+ 0% {
15
+ rotate: 0deg;
16
+ }
17
+ 2% {
18
+ rotate: 20deg;
19
+ filter: blur(1px);
20
+ }
21
+ 4% {
22
+ rotate: 0deg;
23
+ }
24
+ 6% {
25
+ rotate: -20deg;
26
+ }
27
+ 8% {
28
+ rotate: 0deg;
29
+ }
30
+ 10% {
31
+ rotate: 20deg;
32
+ }
33
+ 12% {
34
+ rotate: 0deg;
35
+ }
36
+ 14% {
37
+ rotate: -20deg;
38
+ }
39
+ 16% {
40
+ rotate: 0deg;
41
+ filter: blur(0);
42
+ }
43
+ }
44
+
45
+ .example-avatar-container:after {
46
+ content: '👋';
47
+ position: absolute;
48
+ font-size: 1.5rem;
49
+ display: flex;
50
+ align-items: center;
51
+ justify-container: center;
52
+ inset-inline-start: 0;
53
+ inset-block-start: 0;
54
+ translate: -25% -25%;
55
+ transform-origin: 100% 100%;
56
+ animation: wave 4s infinite linear;
57
+ }
58
+
59
+ .example-avatar {
60
+ inline-size: 4rem;
61
+ aspect-ratio: 1;
62
+ border-radius: 50%;
63
+ }
64
+
65
+ .example-heading {
66
+ color: #333;
67
+ margin-top: 0;
68
+ font-size: 2rem;
69
+ }
70
+
71
+ p {
72
+ color: #666;
73
+ line-height: 1.6;
74
+ }
75
+
76
+ .code-hint {
77
+ background-color: #f5f5f5;
78
+ padding: 1rem;
79
+ border-radius: 4px;
80
+ font-family: monospace;
81
+ margin-top: 1.5rem;
82
+ border-left: 3px solid #e0e0e0;
83
+ line-height: 1.5;
84
+ }
@@ -0,0 +1,38 @@
1
+ import {type CurrentUser, useCurrentUser} from '@sanity/sdk-react'
2
+
3
+ import './ExampleComponent.css'
4
+
5
+ export function ExampleComponent() {
6
+ const user: CurrentUser | null = useCurrentUser()
7
+
8
+ return (
9
+ <div className="example-container">
10
+ {user?.profileImage ? (
11
+ <div className="example-avatar-container">
12
+ <img alt="" className="example-avatar" src={user.profileImage} />
13
+ </div>
14
+ ) : (
15
+ ''
16
+ )}
17
+ <h1 className="example-heading">
18
+ Welcome to your Sanity App{user?.name ? `, ${user.name}` : ''}!
19
+ </h1>
20
+ <p className="example-text">
21
+ This is an example component. You can replace this with your own content by creating a new
22
+ component and importing it in App.tsx.
23
+ </p>
24
+ <div className="code-hint">
25
+ <p>
26
+ Quick tip: Create new components in separate files and import them like this in App.tsx /
27
+ App.jsx:
28
+ </p>
29
+ <pre>{`import {YourComponent} from './YourComponent'
30
+
31
+ // Then use it in your JSX
32
+ <SanityApp config={sanityConfigs}>
33
+ <YourComponent />
34
+ </SanityApp>`}</pre>
35
+ </div>
36
+ </div>
37
+ )
38
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "module": "Preserve",
10
+ "moduleDetection": "force",
11
+ "isolatedModules": true,
12
+ "jsx": "preserve",
13
+ "incremental": true
14
+ },
15
+ "include": ["**/*.ts", "**/*.tsx"],
16
+ "exclude": ["node_modules"]
17
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "basic-studio",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "keywords": [
6
+ "sanity"
7
+ ],
8
+ "license": "MIT",
9
+ "type": "module",
10
+ "main": "package.json",
11
+ "scripts": {
12
+ "deploy": "sanity deploy",
13
+ "deploy-graphql": "sanity graphql deploy",
14
+ "dev": "sanity dev",
15
+ "start": "sanity start"
16
+ },
17
+ "dependencies": {
18
+ "@sanity/vision": "^5.9.0",
19
+ "react": "^19.2.3",
20
+ "react-dom": "^19.2.3",
21
+ "sanity": "^5.9.0",
22
+ "styled-components": "^6.3.8"
23
+ },
24
+ "devDependencies": {
25
+ "@types/react": "^19.2.9",
26
+ "typescript": "^5.9.3"
27
+ }
28
+ }
@@ -0,0 +1,11 @@
1
+ import {defineCliConfig} from 'sanity/cli'
2
+
3
+ export default defineCliConfig({
4
+ api: {
5
+ dataset: 'test',
6
+ projectId: 'ppsg7ml5',
7
+ },
8
+ deployment: {
9
+ autoUpdates: true,
10
+ },
11
+ })
@@ -0,0 +1,18 @@
1
+ import {visionTool} from '@sanity/vision'
2
+ import {defineConfig} from 'sanity'
3
+ import {structureTool} from 'sanity/structure'
4
+
5
+ import {schemaTypes} from './schemaTypes'
6
+
7
+ export default defineConfig({
8
+ title: 'Basic Studio',
9
+
10
+ dataset: 'test',
11
+ projectId: 'ppsg7ml5',
12
+
13
+ plugins: [structureTool(), visionTool()],
14
+
15
+ schema: {
16
+ types: schemaTypes,
17
+ },
18
+ })
@@ -0,0 +1,52 @@
1
+ import {defineField, defineType} from 'sanity'
2
+
3
+ export default defineType({
4
+ name: 'author',
5
+ title: 'Author',
6
+ type: 'document',
7
+
8
+ fields: [
9
+ defineField({
10
+ name: 'name',
11
+ title: 'Name',
12
+ type: 'string',
13
+ }),
14
+ defineField({
15
+ name: 'slug',
16
+ options: {
17
+ maxLength: 96,
18
+ source: 'name',
19
+ },
20
+ title: 'Slug',
21
+ type: 'slug',
22
+ }),
23
+ defineField({
24
+ name: 'image',
25
+ options: {
26
+ hotspot: true,
27
+ },
28
+ title: 'Image',
29
+ type: 'image',
30
+ }),
31
+ defineField({
32
+ name: 'bio',
33
+ of: [
34
+ {
35
+ lists: [],
36
+ styles: [{title: 'Normal', value: 'normal'}],
37
+ title: 'Block',
38
+ type: 'block',
39
+ },
40
+ ],
41
+ title: 'Bio',
42
+ type: 'array',
43
+ }),
44
+ ],
45
+
46
+ preview: {
47
+ select: {
48
+ media: 'image',
49
+ title: 'name',
50
+ },
51
+ },
52
+ })