@sanity/cli-test 0.0.0-20260410130107

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 (118) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +260 -0
  3. package/dist/index.d.ts +531 -0
  4. package/dist/index.js +13 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/test/captureOutput.js +83 -0
  7. package/dist/test/captureOutput.js.map +1 -0
  8. package/dist/test/constants.js +24 -0
  9. package/dist/test/constants.js.map +1 -0
  10. package/dist/test/createTestClient.js +53 -0
  11. package/dist/test/createTestClient.js.map +1 -0
  12. package/dist/test/createTestToken.js +13 -0
  13. package/dist/test/createTestToken.js.map +1 -0
  14. package/dist/test/mockApi.js +16 -0
  15. package/dist/test/mockApi.js.map +1 -0
  16. package/dist/test/mockSanityCommand.js +71 -0
  17. package/dist/test/mockSanityCommand.js.map +1 -0
  18. package/dist/test/mockTelemetry.js +24 -0
  19. package/dist/test/mockTelemetry.js.map +1 -0
  20. package/dist/test/setupFixtures.js +140 -0
  21. package/dist/test/setupFixtures.js.map +1 -0
  22. package/dist/test/snapshotSerializer.js +12 -0
  23. package/dist/test/snapshotSerializer.js.map +1 -0
  24. package/dist/test/testCommand.js +19 -0
  25. package/dist/test/testCommand.js.map +1 -0
  26. package/dist/test/testFixture.js +112 -0
  27. package/dist/test/testFixture.js.map +1 -0
  28. package/dist/test/testHook.js +43 -0
  29. package/dist/test/testHook.js.map +1 -0
  30. package/dist/utils/fileExists.js +13 -0
  31. package/dist/utils/fileExists.js.map +1 -0
  32. package/dist/utils/paths.js +66 -0
  33. package/dist/utils/paths.js.map +1 -0
  34. package/dist/vitest.d.ts +121 -0
  35. package/dist/vitest.js +22 -0
  36. package/dist/vitest.js.map +1 -0
  37. package/dist/vitestWorker.js +135 -0
  38. package/dist/vitestWorker.js.map +1 -0
  39. package/fixtures/basic-app/package.json +25 -0
  40. package/fixtures/basic-app/sanity.cli.ts +12 -0
  41. package/fixtures/basic-app/src/App.css +20 -0
  42. package/fixtures/basic-app/src/App.tsx +26 -0
  43. package/fixtures/basic-app/src/ExampleComponent.css +84 -0
  44. package/fixtures/basic-app/src/ExampleComponent.tsx +38 -0
  45. package/fixtures/basic-app/tsconfig.json +17 -0
  46. package/fixtures/basic-functions/functions/test-function/index.ts +7 -0
  47. package/fixtures/basic-functions/package.json +14 -0
  48. package/fixtures/basic-functions/sanity.blueprint.ts +5 -0
  49. package/fixtures/basic-studio/package.json +28 -0
  50. package/fixtures/basic-studio/sanity.cli.ts +11 -0
  51. package/fixtures/basic-studio/sanity.config.ts +18 -0
  52. package/fixtures/basic-studio/schemaTypes/author.ts +52 -0
  53. package/fixtures/basic-studio/schemaTypes/blockContent.ts +71 -0
  54. package/fixtures/basic-studio/schemaTypes/category.ts +20 -0
  55. package/fixtures/basic-studio/schemaTypes/index.ts +6 -0
  56. package/fixtures/basic-studio/schemaTypes/post.ts +67 -0
  57. package/fixtures/basic-studio/tsconfig.json +17 -0
  58. package/fixtures/federated-studio/package.json +24 -0
  59. package/fixtures/federated-studio/sanity.cli.ts +14 -0
  60. package/fixtures/federated-studio/sanity.config.ts +17 -0
  61. package/fixtures/federated-studio/schemaTypes/index.ts +1 -0
  62. package/fixtures/federated-studio/tsconfig.json +17 -0
  63. package/fixtures/graphql-studio/package.json +25 -0
  64. package/fixtures/graphql-studio/sanity.cli.ts +20 -0
  65. package/fixtures/graphql-studio/sanity.config.ts +37 -0
  66. package/fixtures/graphql-studio/schemaTypes/author.ts +52 -0
  67. package/fixtures/graphql-studio/schemaTypes/blockContent.ts +71 -0
  68. package/fixtures/graphql-studio/schemaTypes/category.ts +20 -0
  69. package/fixtures/graphql-studio/schemaTypes/event.ts +25 -0
  70. package/fixtures/graphql-studio/schemaTypes/index.ts +10 -0
  71. package/fixtures/graphql-studio/schemaTypes/post.ts +67 -0
  72. package/fixtures/graphql-studio/tsconfig.json +17 -0
  73. package/fixtures/multi-workspace-studio/package.json +28 -0
  74. package/fixtures/multi-workspace-studio/sanity.cli.ts +11 -0
  75. package/fixtures/multi-workspace-studio/sanity.config.ts +37 -0
  76. package/fixtures/multi-workspace-studio/schemaTypes/author.ts +52 -0
  77. package/fixtures/multi-workspace-studio/schemaTypes/blockContent.ts +70 -0
  78. package/fixtures/multi-workspace-studio/schemaTypes/category.ts +20 -0
  79. package/fixtures/multi-workspace-studio/schemaTypes/index.ts +6 -0
  80. package/fixtures/multi-workspace-studio/schemaTypes/post.ts +67 -0
  81. package/fixtures/multi-workspace-studio/tsconfig.json +17 -0
  82. package/fixtures/prebuilt-app/README.md +3 -0
  83. package/fixtures/prebuilt-app/dist/favicon.ico +0 -0
  84. package/fixtures/prebuilt-app/dist/index.html +102 -0
  85. package/fixtures/prebuilt-app/dist/static/sanity-CtOxKsdo.css +24 -0
  86. package/fixtures/prebuilt-app/dist/static/sanity-D4a4eOYZ.js +17 -0
  87. package/fixtures/prebuilt-app/package.json +25 -0
  88. package/fixtures/prebuilt-app/sanity.cli.ts +12 -0
  89. package/fixtures/prebuilt-app/src/App.css +20 -0
  90. package/fixtures/prebuilt-app/src/App.tsx +24 -0
  91. package/fixtures/prebuilt-app/tsconfig.json +17 -0
  92. package/fixtures/prebuilt-studio/README.md +3 -0
  93. package/fixtures/prebuilt-studio/dist/favicon.ico +0 -0
  94. package/fixtures/prebuilt-studio/dist/index.html +113 -0
  95. package/fixtures/prebuilt-studio/dist/static/sanity-DxH-rpFr.js +9 -0
  96. package/fixtures/prebuilt-studio/package.json +25 -0
  97. package/fixtures/prebuilt-studio/sanity.cli.ts +11 -0
  98. package/fixtures/prebuilt-studio/sanity.config.ts +11 -0
  99. package/fixtures/prebuilt-studio/tsconfig.json +17 -0
  100. package/fixtures/worst-case-studio/.env +1 -0
  101. package/fixtures/worst-case-studio/README.md +22 -0
  102. package/fixtures/worst-case-studio/fieldComponentsTest.tsx +80 -0
  103. package/fixtures/worst-case-studio/package.json +33 -0
  104. package/fixtures/worst-case-studio/sanity.cli.ts +16 -0
  105. package/fixtures/worst-case-studio/sanity.config.tsx +55 -0
  106. package/fixtures/worst-case-studio/src/browserGlobalsCheck.ts +14 -0
  107. package/fixtures/worst-case-studio/src/defines.ts +8 -0
  108. package/fixtures/worst-case-studio/src/descriptionIcon.svg +7 -0
  109. package/fixtures/worst-case-studio/src/descriptionInput.module.css +13 -0
  110. package/fixtures/worst-case-studio/src/descriptionInput.tsx +55 -0
  111. package/fixtures/worst-case-studio/src/schemaTypes/author.ts +52 -0
  112. package/fixtures/worst-case-studio/src/schemaTypes/blockContent.ts +70 -0
  113. package/fixtures/worst-case-studio/src/schemaTypes/category.ts +20 -0
  114. package/fixtures/worst-case-studio/src/schemaTypes/index.ts +6 -0
  115. package/fixtures/worst-case-studio/src/schemaTypes/post.ts +71 -0
  116. package/fixtures/worst-case-studio/src/typings.d.ts +37 -0
  117. package/fixtures/worst-case-studio/tsconfig.json +22 -0
  118. package/package.json +97 -0
@@ -0,0 +1,71 @@
1
+ import {defineField, defineType} from 'sanity'
2
+
3
+ export default defineType({
4
+ name: 'post',
5
+ title: 'Post',
6
+ type: 'document',
7
+
8
+ fields: [
9
+ defineField({
10
+ name: 'title',
11
+ title: 'Title',
12
+ type: 'string',
13
+ }),
14
+ defineField({
15
+ name: 'slug',
16
+ options: {
17
+ maxLength: 96,
18
+ source: 'title',
19
+ },
20
+ title: 'Slug',
21
+ type: 'slug',
22
+ }),
23
+ defineField({
24
+ name: 'author',
25
+ title: 'Author',
26
+ to: {type: 'author'},
27
+ type: 'reference',
28
+ }),
29
+ defineField({
30
+ name: 'mainImage',
31
+ options: {
32
+ hotspot: true,
33
+ },
34
+ title: 'Main image',
35
+ type: 'image',
36
+ }),
37
+ defineField({
38
+ name: 'code',
39
+ type: 'code',
40
+ }),
41
+ defineField({
42
+ name: 'categories',
43
+ of: [{to: {type: 'category'}, type: 'reference'}],
44
+ title: 'Categories',
45
+ type: 'array',
46
+ }),
47
+ defineField({
48
+ name: 'publishedAt',
49
+ title: 'Published at',
50
+ type: 'datetime',
51
+ }),
52
+ defineField({
53
+ name: 'body',
54
+ title: 'Body',
55
+ type: 'blockContent',
56
+ }),
57
+ ],
58
+
59
+ preview: {
60
+ select: {
61
+ author: 'author.name',
62
+ media: 'mainImage',
63
+ title: 'title',
64
+ },
65
+
66
+ prepare(selection) {
67
+ const {author} = selection
68
+ return {...selection, subtitle: author && `by ${author}`}
69
+ },
70
+ },
71
+ })
@@ -0,0 +1,37 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly SANITY_STUDIO_PREFIXED_VAR: string
5
+ }
6
+
7
+ interface ImportMeta {
8
+ readonly env: ImportMetaEnv
9
+ }
10
+
11
+ declare module 'https://themer.sanity.build/api/hues?*' {
12
+ interface Hue extends Omit<import('@sanity/color').ColorHueConfig, 'midPoint' | 'title'> {
13
+ midPoint: 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950
14
+ }
15
+ interface Hues {
16
+ caution: Hue
17
+ critical: Hue
18
+ default: Hue
19
+ positive: Hue
20
+ primary: Hue
21
+ transparent: Hue
22
+ }
23
+ export const hues: Hues
24
+ type Theme = import('sanity').StudioTheme
25
+ export function createTheme(_hues: Hues): Theme
26
+ export const theme: Theme
27
+ }
28
+
29
+ declare module '*.module.css' {
30
+ const classes: {[key: string]: string}
31
+ export default classes
32
+ }
33
+
34
+ declare module '*.svg' {
35
+ const path: string
36
+ export default path
37
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ES2017",
5
+ "lib": ["dom", "dom.iterable", "esnext"],
6
+ "allowJs": true,
7
+ "skipLibCheck": true,
8
+ "strict": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "module": "Preserve",
11
+ "moduleDetection": "force",
12
+ "isolatedModules": true,
13
+ "jsx": "preserve",
14
+ "incremental": true,
15
+ "noEmit": true,
16
+ "paths": {
17
+ "@/*": ["./src/*"]
18
+ }
19
+ },
20
+ "include": ["**/*.ts", "**/*.tsx"],
21
+ "exclude": ["node_modules"],
22
+ }
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@sanity/cli-test",
3
+ "version": "0.0.0-20260410130107",
4
+ "description": "Sanity CLI test helpers and utilities",
5
+ "keywords": [
6
+ "cli",
7
+ "cms",
8
+ "content",
9
+ "headless",
10
+ "realtime",
11
+ "sanity",
12
+ "tool"
13
+ ],
14
+ "homepage": "https://github.com/sanity-io/cli",
15
+ "bugs": "https://github.com/sanity-io/cli/issues",
16
+ "license": "MIT",
17
+ "author": "Sanity.io <hello@sanity.io>",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/sanity-io/cli.git",
21
+ "directory": "packages/@sanity/cli-test"
22
+ },
23
+ "files": [
24
+ "./dist",
25
+ "./fixtures"
26
+ ],
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "source": "./src/index.ts",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "./vitest": {
37
+ "source": "./src/vitest.ts",
38
+ "default": "./dist/vitest.js"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "dependencies": {
46
+ "@swc/core": "^1.15.24",
47
+ "ansis": "^4.2.0",
48
+ "esbuild": "^0.27.4",
49
+ "nock": "^14.0.11",
50
+ "ora": "^9.0.0",
51
+ "tinyglobby": "^0.2.15"
52
+ },
53
+ "devDependencies": {
54
+ "@eslint/compat": "^2.0.3",
55
+ "@oclif/core": "^4.10.3",
56
+ "@sanity/client": "^7.20.0",
57
+ "@sanity/pkg-utils": "^10.4.13",
58
+ "@swc/cli": "^0.8.1",
59
+ "@types/node": "^20.19.39",
60
+ "eslint": "^10.1.0",
61
+ "publint": "^0.3.18",
62
+ "rimraf": "^6.0.1",
63
+ "tsx": "^4.21.0",
64
+ "typescript": "^5.9.3",
65
+ "vitest": "^4.1.2",
66
+ "yaml": "^2.8.3",
67
+ "@repo/package.config": "0.0.1",
68
+ "@repo/tsconfig": "3.70.0",
69
+ "@sanity/cli-core": "0.0.0-20260410130107",
70
+ "@sanity/eslint-config-cli": "1.1.0"
71
+ },
72
+ "peerDependencies": {
73
+ "@oclif/core": "^4.0.0",
74
+ "@sanity/client": "^7.0.0",
75
+ "vitest": ">=3.0.0 <5.0.0",
76
+ "@sanity/cli-core": "0.0.0-20260410130107"
77
+ },
78
+ "engines": {
79
+ "node": ">=20.19.1 <22 || >=22.12"
80
+ },
81
+ "scripts": {
82
+ "prebuild": "pnpm run clean",
83
+ "build": "pnpm run build:js && pnpm run copy:fixtures",
84
+ "build:js": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ src",
85
+ "build:types": "pkg-utils build --emitDeclarationOnly",
86
+ "check:types": "tsc --noEmit",
87
+ "clean": "rimraf dist fixtures",
88
+ "copy:fixtures": "tsx scripts/copy-fixtures.ts",
89
+ "lint": "eslint .",
90
+ "publint": "publint",
91
+ "test": "vitest run",
92
+ "posttest": "pnpm run lint",
93
+ "test:coverage": "vitest run --coverage",
94
+ "test:watch": "vitest",
95
+ "watch": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ --watch src"
96
+ }
97
+ }