@sanity/cli-test 24.0.3 → 25.0.1

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as testFixture, c as createMockWatcher, d as DEFAULT_FIXTURES, f as ExampleName, h as FixtureOptions, i as testExample, l as createMockSpinner, m as FixtureName, n as TestFixtureOptions, o as createTestToken, p as FIXTURE_WORKSPACE_FILE, r as testCopyDirectory, s as MockWatcher, t as TestExampleOptions, u as createMockHttpServer } from "./testFixture-BSYY9y-u.js";
1
+ import { a as testFixture, c as createMockWatcher, d as DEFAULT_FIXTURES, f as ExampleName, h as FixtureOptions, i as testExample, l as createMockSpinner, m as FixtureName, n as TestFixtureOptions, o as createTestToken, p as FIXTURE_WORKSPACE_FILE, r as testCopyDirectory, s as MockWatcher, t as TestExampleOptions, u as createMockHttpServer } from "./testFixture-DKy-0AbB.js";
2
2
  import { CreateTestClientOptions, createTestClient } from "./test/createTestClient.js";
3
3
  import { MockApiOptions, mockApi } from "./test/mockApi.js";
4
4
  import { c as mockSanityCommand, n as TestCommandOptions, r as testCommand, s as MockSanityCommandOptions, t as testHook } from "./testHook-CG6GhHGq.js";
@@ -4,9 +4,9 @@
4
4
  */ /**
5
5
  * Name of the `pnpm-workspace.yaml` template bundled alongside the fixtures.
6
6
  *
7
- * The build generates it from the repository's own `pnpm-workspace.yaml` so fixture
8
- * installs apply the same install policy as the repository, and fixture setup writes
9
- * it into each fixture as its `pnpm-workspace.yaml`.
7
+ * The build generates it from the repository's `allowBuilds` and excludes the packages
8
+ * a Studio release publishes. Fixture setup writes it into each fixture as its
9
+ * `pnpm-workspace.yaml`.
10
10
  *
11
11
  * @internal
12
12
  */ export const FIXTURE_WORKSPACE_FILE = 'fixture-workspace.yaml';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/constants.ts"],"sourcesContent":["/**\n * Options for each fixture.\n * @public\n */\nexport interface FixtureOptions {\n includeDist?: boolean\n}\n\n/**\n * Name of the `pnpm-workspace.yaml` template bundled alongside the fixtures.\n *\n * The build generates it from the repository's own `pnpm-workspace.yaml` so fixture\n * installs apply the same install policy as the repository, and fixture setup writes\n * it into each fixture as its `pnpm-workspace.yaml`.\n *\n * @internal\n */\nexport const FIXTURE_WORKSPACE_FILE = 'fixture-workspace.yaml'\n\n/**\n * Default fixtures bundled with the package and their options.\n *\n * @public\n */\nexport const DEFAULT_FIXTURES: Record<FixtureName, FixtureOptions> = {\n 'basic-app': {},\n 'basic-functions': {},\n 'basic-studio': {},\n 'federated-studio': {},\n 'graphql-studio': {},\n 'multi-workspace-studio': {},\n 'nextjs-app': {},\n 'prebuilt-app': {includeDist: true},\n 'prebuilt-studio': {includeDist: true},\n 'worst-case-studio': {},\n} as const\n\n/**\n * Valid fixture name type.\n * @public\n */\nexport type FixtureName =\n | 'basic-app'\n | 'basic-functions'\n | 'basic-studio'\n | 'federated-studio'\n | 'graphql-studio'\n | 'multi-workspace-studio'\n | 'nextjs-app'\n | 'prebuilt-app'\n | 'prebuilt-studio'\n | 'worst-case-studio'\n\n/**\n * @deprecated Use {@link FixtureName} instead. This type alias will be removed in a future release.\n * @public\n */\nexport type ExampleName = FixtureName\n"],"names":["FIXTURE_WORKSPACE_FILE","DEFAULT_FIXTURES","includeDist"],"mappings":"AAAA;;;CAGC,GAKD;;;;;;;;CAQC,GACD,OAAO,MAAMA,yBAAyB,yBAAwB;AAE9D;;;;CAIC,GACD,OAAO,MAAMC,mBAAwD;IACnE,aAAa,CAAC;IACd,mBAAmB,CAAC;IACpB,gBAAgB,CAAC;IACjB,oBAAoB,CAAC;IACrB,kBAAkB,CAAC;IACnB,0BAA0B,CAAC;IAC3B,cAAc,CAAC;IACf,gBAAgB;QAACC,aAAa;IAAI;IAClC,mBAAmB;QAACA,aAAa;IAAI;IACrC,qBAAqB,CAAC;AACxB,EAAU"}
1
+ {"version":3,"sources":["../../src/test/constants.ts"],"sourcesContent":["/**\n * Options for each fixture.\n * @public\n */\nexport interface FixtureOptions {\n includeDist?: boolean\n}\n\n/**\n * Name of the `pnpm-workspace.yaml` template bundled alongside the fixtures.\n *\n * The build generates it from the repository's `allowBuilds` and excludes the packages\n * a Studio release publishes. Fixture setup writes it into each fixture as its\n * `pnpm-workspace.yaml`.\n *\n * @internal\n */\nexport const FIXTURE_WORKSPACE_FILE = 'fixture-workspace.yaml'\n\n/**\n * Default fixtures bundled with the package and their options.\n *\n * @public\n */\nexport const DEFAULT_FIXTURES: Record<FixtureName, FixtureOptions> = {\n 'basic-app': {},\n 'basic-functions': {},\n 'basic-studio': {},\n 'federated-studio': {},\n 'graphql-studio': {},\n 'multi-workspace-studio': {},\n 'nextjs-app': {},\n 'prebuilt-app': {includeDist: true},\n 'prebuilt-studio': {includeDist: true},\n 'worst-case-studio': {},\n} as const\n\n/**\n * Valid fixture name type.\n * @public\n */\nexport type FixtureName =\n | 'basic-app'\n | 'basic-functions'\n | 'basic-studio'\n | 'federated-studio'\n | 'graphql-studio'\n | 'multi-workspace-studio'\n | 'nextjs-app'\n | 'prebuilt-app'\n | 'prebuilt-studio'\n | 'worst-case-studio'\n\n/**\n * @deprecated Use {@link FixtureName} instead. This type alias will be removed in a future release.\n * @public\n */\nexport type ExampleName = FixtureName\n"],"names":["FIXTURE_WORKSPACE_FILE","DEFAULT_FIXTURES","includeDist"],"mappings":"AAAA;;;CAGC,GAKD;;;;;;;;CAQC,GACD,OAAO,MAAMA,yBAAyB,yBAAwB;AAE9D;;;;CAIC,GACD,OAAO,MAAMC,mBAAwD;IACnE,aAAa,CAAC;IACd,mBAAmB,CAAC;IACpB,gBAAgB,CAAC;IACjB,oBAAoB,CAAC;IACrB,kBAAkB,CAAC;IACnB,0BAA0B,CAAC;IAC3B,cAAc,CAAC;IACf,gBAAgB;QAACC,aAAa;IAAI;IAClC,mBAAmB;QAACA,aAAa;IAAI;IACrC,qBAAqB,CAAC;AACxB,EAAU"}
@@ -11,7 +11,7 @@ const exec = promisify(execNode);
11
11
  /**
12
12
  * Reads the bundled `pnpm-workspace.yaml` template that fixture installs run under.
13
13
  *
14
- * It is generated from the repository's own workspace config by the package build, so a
14
+ * It is generated from the repository's `allowBuilds` by the package build, so a
15
15
  * missing file means the package was not built rather than a misconfigured consumer.
16
16
  */ async function readFixtureWorkspace() {
17
17
  const workspacePath = join(getFixturesPath(), FIXTURE_WORKSPACE_FILE);
@@ -110,8 +110,7 @@ async function getAdditionalFixturePaths(fixtures) {
110
110
  await writeFile(packageJsonPath, JSON.stringify(packageJsonData, null, 2));
111
111
  if (ignoreWorkspace) {
112
112
  // pnpm 11 reads build-script policy from pnpm-workspace.yaml.
113
- // A fixture-local workspace both isolates the install and applies the repository's policy,
114
- // which the build generated from the repository's own pnpm-workspace.yaml.
113
+ // The bundled file supplies `allowBuilds`, admits a fresh Studio release, and isolates the install.
115
114
  await writeFile(join(toPath, 'pnpm-workspace.yaml'), await readFixtureWorkspace());
116
115
  }
117
116
  // Run pnpm install --no-lockfile in the temp directory
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/setupFixtures.ts"],"sourcesContent":["import {exec as execNode} from 'node:child_process'\nimport {readFile, rm, writeFile} from 'node:fs/promises'\nimport {basename, join} from 'node:path'\nimport {promisify} from 'node:util'\n\nimport {glob} from 'tinyglobby'\nimport {type TestProject} from 'vitest/node'\n\nimport {fileExists} from '../utils/fileExists.js'\nimport {getFixturesPath, getTempPath} from '../utils/paths.js'\nimport {DEFAULT_FIXTURES, FIXTURE_WORKSPACE_FILE} from './constants.js'\nimport {testCopyDirectory} from './testFixture.js'\n\nconst exec = promisify(execNode)\n\n/**\n * Reads the bundled `pnpm-workspace.yaml` template that fixture installs run under.\n *\n * It is generated from the repository's own workspace config by the package build, so a\n * missing file means the package was not built rather than a misconfigured consumer.\n */\nasync function readFixtureWorkspace(): Promise<string> {\n const workspacePath = join(getFixturesPath(), FIXTURE_WORKSPACE_FILE)\n\n try {\n return await readFile(workspacePath, 'utf8')\n } catch (error) {\n throw new Error(\n `Could not read the fixture workspace config at ${workspacePath}. Build @sanity/cli-test before running fixture setup.`,\n {cause: error},\n )\n }\n}\n\n/**\n * Options for setupTestFixtures\n *\n * @public\n */\nexport interface SetupTestFixturesOptions {\n /**\n * Glob patterns for additional fixture directories to set up.\n *\n * Each pattern is matched against directories in the current working directory.\n * Only directories containing a `package.json` file are included.\n *\n * @example\n * ```typescript\n * ['fixtures/*', 'dev/*']\n * ```\n */\n additionalFixtures?: string[]\n\n /**\n * Creates an isolated pnpm workspace so fixtures get their own node_modules even\n * when the temp directory is inside another pnpm workspace. Defaults to true:\n * fixtures copied into this repository's tmp directory are not workspace members,\n * so pnpm would otherwise resolve the install to the repository root and leave the\n * fixture without node_modules.\n */\n ignoreWorkspace?: boolean\n\n /**\n * Custom temp directory path. Defaults to process.cwd()/tmp\n */\n tempDir?: string\n}\n\nasync function getAdditionalFixturePaths(fixtures: string[]): Promise<FixtureDetails[]> {\n const paths = await glob(fixtures, {\n absolute: true,\n ignore: ['**/node_modules/**', '**/dist/**'],\n onlyDirectories: true,\n })\n\n const additionalFixtures: FixtureDetails[] = []\n\n for (const path of paths) {\n if (await fileExists(join(`${path}/package.json`))) {\n additionalFixtures.push({\n fixture: basename(path),\n fromPath: path,\n includeDist: false,\n })\n }\n }\n\n return additionalFixtures\n}\n\ninterface FixtureDetails {\n fixture: string\n fromPath: string\n includeDist: boolean\n}\n\n/**\n * Global setup function for initializing test fixtures.\n *\n * Copies fixtures from the bundled location to a temp directory\n * and installs dependencies.\n *\n * Note: Fixtures are NOT built during setup. Tests that need built\n * fixtures should build them as part of the test.\n *\n * This function is designed to be used with vitest globalSetup.\n *\n * @public\n *\n * @param options - Configuration options\n * @example\n * ```typescript\n * // In vitest.config.ts\n * export default defineConfig({\n * test: {\n * globalSetup: ['@sanity/cli-test/vitest']\n * }\n * })\n * ```\n */\nexport async function setup(_: TestProject, options: SetupTestFixturesOptions = {}): Promise<void> {\n const {additionalFixtures, ignoreWorkspace = true, tempDir} = options\n console.log('Initializing test environment...')\n const timerLabel = 'Test environment initialization'\n console.time(timerLabel)\n\n try {\n const fixturesDir = getFixturesPath()\n const tempDirectory = getTempPath(tempDir)\n\n const allFixturePaths: FixtureDetails[] = []\n\n // Add the default fixtures\n for (const [fixture, options] of Object.entries(DEFAULT_FIXTURES)) {\n allFixturePaths.push({\n fixture,\n fromPath: join(fixturesDir, fixture),\n includeDist: 'includeDist' in options && options.includeDist ? options.includeDist : false,\n })\n }\n\n // Add the additional fixtures\n if (additionalFixtures && additionalFixtures.length > 0) {\n const additionalFixturePaths = await getAdditionalFixturePaths(additionalFixtures)\n\n if (additionalFixturePaths.length > 0) {\n allFixturePaths.push(...additionalFixturePaths)\n } else {\n console.warn(\n `No additional fixtures found, check the glob pattern: ${additionalFixtures.join(', ')}`,\n )\n }\n }\n\n for (const {fixture, fromPath, includeDist} of allFixturePaths) {\n const toPath = join(tempDirectory, `fixture-${fixture}`)\n // Copy the fixture, excluding node_modules and dist\n await testCopyDirectory(fromPath, toPath, ['node_modules', ...(includeDist ? [] : ['dist'])])\n\n // Replace the package.json name with a temp name\n const packageJsonPath = join(toPath, 'package.json')\n const packageJson = await readFile(packageJsonPath, 'utf8')\n const packageJsonData = JSON.parse(packageJson)\n packageJsonData.name = `${packageJsonData.name}-test`\n await writeFile(packageJsonPath, JSON.stringify(packageJsonData, null, 2))\n\n if (ignoreWorkspace) {\n // pnpm 11 reads build-script policy from pnpm-workspace.yaml.\n // A fixture-local workspace both isolates the install and applies the repository's policy,\n // which the build generated from the repository's own pnpm-workspace.yaml.\n await writeFile(join(toPath, 'pnpm-workspace.yaml'), await readFixtureWorkspace())\n }\n\n // Run pnpm install --no-lockfile in the temp directory\n try {\n await exec(`pnpm install --prefer-offline --no-lockfile`, {\n cwd: toPath,\n })\n } catch (error) {\n const execError = error as {message: string; stderr?: string; stdout?: string}\n console.error('Failed to install dependencies')\n console.error(execError.stderr || execError.stdout || execError.message)\n throw new Error(\n `Error installing dependencies in ${toPath}: ${execError.stderr || execError.stdout || execError.message}`,\n {cause: error},\n )\n }\n }\n } catch (error) {\n console.error('Failed to initialize test environment!')\n throw error\n } finally {\n console.timeEnd(timerLabel)\n }\n}\n\n/**\n * Options for teardownTestFixtures\n *\n * @public\n */\nexport interface TeardownTestFixturesOptions {\n /**\n * Custom temp directory path. Defaults to process.cwd()/tmp\n */\n tempDir?: string\n}\n\n/**\n * Teardown function to clean up test fixtures.\n *\n * Removes the temp directory created by setupTestFixtures.\n *\n * This function is designed to be used with vitest globalSetup.\n *\n * @public\n *\n * @param options - Configuration options\n */\nexport async function teardown(options: TeardownTestFixturesOptions = {}): Promise<void> {\n const {tempDir} = options\n const tempDirectory = getTempPath(tempDir)\n\n // Remove the tmp directory\n await rm(tempDirectory, {force: true, maxRetries: 3, recursive: true}).catch(() => {})\n}\n"],"names":["exec","execNode","readFile","rm","writeFile","basename","join","promisify","glob","fileExists","getFixturesPath","getTempPath","DEFAULT_FIXTURES","FIXTURE_WORKSPACE_FILE","testCopyDirectory","readFixtureWorkspace","workspacePath","error","Error","cause","getAdditionalFixturePaths","fixtures","paths","absolute","ignore","onlyDirectories","additionalFixtures","path","push","fixture","fromPath","includeDist","setup","_","options","ignoreWorkspace","tempDir","console","log","timerLabel","time","fixturesDir","tempDirectory","allFixturePaths","Object","entries","length","additionalFixturePaths","warn","toPath","packageJsonPath","packageJson","packageJsonData","JSON","parse","name","stringify","cwd","execError","stderr","stdout","message","timeEnd","teardown","force","maxRetries","recursive","catch"],"mappings":"AAAA,SAAQA,QAAQC,QAAQ,QAAO,qBAAoB;AACnD,SAAQC,QAAQ,EAAEC,EAAE,EAAEC,SAAS,QAAO,mBAAkB;AACxD,SAAQC,QAAQ,EAAEC,IAAI,QAAO,YAAW;AACxC,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,IAAI,QAAO,aAAY;AAG/B,SAAQC,UAAU,QAAO,yBAAwB;AACjD,SAAQC,eAAe,EAAEC,WAAW,QAAO,oBAAmB;A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CAACyC,UAAUC,MAAM,IAAID,UAAUE,MAAM,IAAIF,UAAUG,OAAO;gBACvE,MAAM,IAAI3C,MACR,CAAC,iCAAiC,EAAE+B,OAAO,EAAE,EAAES,UAAUC,MAAM,IAAID,UAAUE,MAAM,IAAIF,UAAUG,OAAO,EAAE,EAC1G;oBAAC1C,OAAOF;gBAAK;YAEjB;QACF;IACF,EAAE,OAAOA,OAAO;QACdoB,QAAQpB,KAAK,CAAC;QACd,MAAMA;IACR,SAAU;QACRoB,QAAQyB,OAAO,CAACvB;IAClB;AACF;AAcA;;;;;;;;;;CAUC,GACD,OAAO,eAAewB,SAAS7B,UAAuC,CAAC,CAAC;IACtE,MAAM,EAACE,OAAO,EAAC,GAAGF;IAClB,MAAMQ,gBAAgB/B,YAAYyB;IAElC,2BAA2B;IAC3B,MAAMjC,GAAGuC,eAAe;QAACsB,OAAO;QAAMC,YAAY;QAAGC,WAAW;IAAI,GAAGC,KAAK,CAAC,KAAO;AACtF"}
1
+ {"version":3,"sources":["../../src/test/setupFixtures.ts"],"sourcesContent":["import {exec as execNode} from 'node:child_process'\nimport {readFile, rm, writeFile} from 'node:fs/promises'\nimport {basename, join} from 'node:path'\nimport {promisify} from 'node:util'\n\nimport {glob} from 'tinyglobby'\nimport {type TestProject} from 'vitest/node'\n\nimport {fileExists} from '../utils/fileExists.js'\nimport {getFixturesPath, getTempPath} from '../utils/paths.js'\nimport {DEFAULT_FIXTURES, FIXTURE_WORKSPACE_FILE} from './constants.js'\nimport {testCopyDirectory} from './testFixture.js'\n\nconst exec = promisify(execNode)\n\n/**\n * Reads the bundled `pnpm-workspace.yaml` template that fixture installs run under.\n *\n * It is generated from the repository's `allowBuilds` by the package build, so a\n * missing file means the package was not built rather than a misconfigured consumer.\n */\nasync function readFixtureWorkspace(): Promise<string> {\n const workspacePath = join(getFixturesPath(), FIXTURE_WORKSPACE_FILE)\n\n try {\n return await readFile(workspacePath, 'utf8')\n } catch (error) {\n throw new Error(\n `Could not read the fixture workspace config at ${workspacePath}. Build @sanity/cli-test before running fixture setup.`,\n {cause: error},\n )\n }\n}\n\n/**\n * Options for setupTestFixtures\n *\n * @public\n */\nexport interface SetupTestFixturesOptions {\n /**\n * Glob patterns for additional fixture directories to set up.\n *\n * Each pattern is matched against directories in the current working directory.\n * Only directories containing a `package.json` file are included.\n *\n * @example\n * ```typescript\n * ['fixtures/*', 'dev/*']\n * ```\n */\n additionalFixtures?: string[]\n\n /**\n * Creates an isolated pnpm workspace so fixtures get their own node_modules even\n * when the temp directory is inside another pnpm workspace. Defaults to true:\n * fixtures copied into this repository's tmp directory are not workspace members,\n * so pnpm would otherwise resolve the install to the repository root and leave the\n * fixture without node_modules.\n */\n ignoreWorkspace?: boolean\n\n /**\n * Custom temp directory path. Defaults to process.cwd()/tmp\n */\n tempDir?: string\n}\n\nasync function getAdditionalFixturePaths(fixtures: string[]): Promise<FixtureDetails[]> {\n const paths = await glob(fixtures, {\n absolute: true,\n ignore: ['**/node_modules/**', '**/dist/**'],\n onlyDirectories: true,\n })\n\n const additionalFixtures: FixtureDetails[] = []\n\n for (const path of paths) {\n if (await fileExists(join(`${path}/package.json`))) {\n additionalFixtures.push({\n fixture: basename(path),\n fromPath: path,\n includeDist: false,\n })\n }\n }\n\n return additionalFixtures\n}\n\ninterface FixtureDetails {\n fixture: string\n fromPath: string\n includeDist: boolean\n}\n\n/**\n * Global setup function for initializing test fixtures.\n *\n * Copies fixtures from the bundled location to a temp directory\n * and installs dependencies.\n *\n * Note: Fixtures are NOT built during setup. Tests that need built\n * fixtures should build them as part of the test.\n *\n * This function is designed to be used with vitest globalSetup.\n *\n * @public\n *\n * @param options - Configuration options\n * @example\n * ```typescript\n * // In vitest.config.ts\n * export default defineConfig({\n * test: {\n * globalSetup: ['@sanity/cli-test/vitest']\n * }\n * })\n * ```\n */\nexport async function setup(_: TestProject, options: SetupTestFixturesOptions = {}): Promise<void> {\n const {additionalFixtures, ignoreWorkspace = true, tempDir} = options\n console.log('Initializing test environment...')\n const timerLabel = 'Test environment initialization'\n console.time(timerLabel)\n\n try {\n const fixturesDir = getFixturesPath()\n const tempDirectory = getTempPath(tempDir)\n\n const allFixturePaths: FixtureDetails[] = []\n\n // Add the default fixtures\n for (const [fixture, options] of Object.entries(DEFAULT_FIXTURES)) {\n allFixturePaths.push({\n fixture,\n fromPath: join(fixturesDir, fixture),\n includeDist: 'includeDist' in options && options.includeDist ? options.includeDist : false,\n })\n }\n\n // Add the additional fixtures\n if (additionalFixtures && additionalFixtures.length > 0) {\n const additionalFixturePaths = await getAdditionalFixturePaths(additionalFixtures)\n\n if (additionalFixturePaths.length > 0) {\n allFixturePaths.push(...additionalFixturePaths)\n } else {\n console.warn(\n `No additional fixtures found, check the glob pattern: ${additionalFixtures.join(', ')}`,\n )\n }\n }\n\n for (const {fixture, fromPath, includeDist} of allFixturePaths) {\n const toPath = join(tempDirectory, `fixture-${fixture}`)\n // Copy the fixture, excluding node_modules and dist\n await testCopyDirectory(fromPath, toPath, ['node_modules', ...(includeDist ? [] : ['dist'])])\n\n // Replace the package.json name with a temp name\n const packageJsonPath = join(toPath, 'package.json')\n const packageJson = await readFile(packageJsonPath, 'utf8')\n const packageJsonData = JSON.parse(packageJson)\n packageJsonData.name = `${packageJsonData.name}-test`\n await writeFile(packageJsonPath, JSON.stringify(packageJsonData, null, 2))\n\n if (ignoreWorkspace) {\n // pnpm 11 reads build-script policy from pnpm-workspace.yaml.\n // The bundled file supplies `allowBuilds`, admits a fresh Studio release, and isolates the install.\n await writeFile(join(toPath, 'pnpm-workspace.yaml'), await readFixtureWorkspace())\n }\n\n // Run pnpm install --no-lockfile in the temp directory\n try {\n await exec(`pnpm install --prefer-offline --no-lockfile`, {\n cwd: toPath,\n })\n } catch (error) {\n const execError = error as {message: string; stderr?: string; stdout?: string}\n console.error('Failed to install dependencies')\n console.error(execError.stderr || execError.stdout || execError.message)\n throw new Error(\n `Error installing dependencies in ${toPath}: ${execError.stderr || execError.stdout || execError.message}`,\n {cause: error},\n )\n }\n }\n } catch (error) {\n console.error('Failed to initialize test environment!')\n throw error\n } finally {\n console.timeEnd(timerLabel)\n }\n}\n\n/**\n * Options for teardownTestFixtures\n *\n * @public\n */\nexport interface TeardownTestFixturesOptions {\n /**\n * Custom temp directory path. Defaults to process.cwd()/tmp\n */\n tempDir?: string\n}\n\n/**\n * Teardown function to clean up test fixtures.\n *\n * Removes the temp directory created by setupTestFixtures.\n *\n * This function is designed to be used with vitest globalSetup.\n *\n * @public\n *\n * @param options - Configuration options\n */\nexport async function teardown(options: TeardownTestFixturesOptions = {}): Promise<void> {\n const {tempDir} = options\n const tempDirectory = getTempPath(tempDir)\n\n // Remove the tmp directory\n await rm(tempDirectory, {force: true, maxRetries: 3, recursive: true}).catch(() => {})\n}\n"],"names":["exec","execNode","readFile","rm","writeFile","basename","join","promisify","glob","fileExists","getFixturesPath","getTempPath","DEFAULT_FIXTURES","FIXTURE_WORKSPACE_FILE","testCopyDirectory","readFixtureWorkspace","workspacePath","error","Error","cause","getAdditionalFixturePaths","fixtures","paths","absolute","ignore","onlyDirectories","additionalFixtures","path","push","fixture","fromPath","includeDist","setup","_","options","ignoreWorkspace","tempDir","console","log","timerLabel","time","fixturesDir","tempDirectory","allFixturePaths","Object","entries","length","additionalFixturePaths","warn","toPath","packageJsonPath","packageJson","packageJsonData","JSON","parse","name","stringify","cwd","execError","stderr","stdout","message","timeEnd","teardown","force","maxRetries","recursive","catch"],"mappings":"AAAA,SAAQA,QAAQC,QAAQ,QAAO,qBAAoB;AACnD,SAAQC,QAAQ,EAAEC,EAAE,EAAEC,SAAS,QAAO,mBAAkB;AACxD,SAAQC,QAAQ,EAAEC,IAAI,QAAO,YAAW;AACxC,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,IAAI,QAAO,aAAY;AAG/B,SAAQC,UAAU,QAAO,yBAAwB;AACjD,SAAQC,eAAe,EAAEC,WAAW,QAAO,oBAAmB;AAC9D,SAAQC,gBAAgB,EAAEC,sBAAsB,QAAO,iBAAgB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AAM,IAAI3C,MACR,CAAC,iCAAiC,EAAE+B,OAAO,EAAE,EAAES,UAAUC,MAAM,IAAID,UAAUE,MAAM,IAAIF,UAAUG,OAAO,EAAE,EAC1G;oBAAC1C,OAAOF;gBAAK;YAEjB;QACF;IACF,EAAE,OAAOA,OAAO;QACdoB,QAAQpB,KAAK,CAAC;QACd,MAAMA;IACR,SAAU;QACRoB,QAAQyB,OAAO,CAACvB;IAClB;AACF;AAcA;;;;;;;;;;CAUC,GACD,OAAO,eAAewB,SAAS7B,UAAuC,CAAC,CAAC;IACtE,MAAM,EAACE,OAAO,EAAC,GAAGF;IAClB,MAAMQ,gBAAgB/B,YAAYyB;IAElC,2BAA2B;IAC3B,MAAMjC,GAAGuC,eAAe;QAACsB,OAAO;QAAMC,YAAY;QAAGC,WAAW;IAAI,GAAGC,KAAK,CAAC,KAAO;AACtF"}
@@ -1,4 +1,4 @@
1
- import { a as testFixture, c as createMockWatcher, d as DEFAULT_FIXTURES, f as ExampleName, h as FixtureOptions, i as testExample, l as createMockSpinner, m as FixtureName, n as TestFixtureOptions, o as createTestToken, p as FIXTURE_WORKSPACE_FILE, r as testCopyDirectory, s as MockWatcher, t as TestExampleOptions, u as createMockHttpServer } from "../testFixture-BSYY9y-u.js";
1
+ import { a as testFixture, c as createMockWatcher, d as DEFAULT_FIXTURES, f as ExampleName, h as FixtureOptions, i as testExample, l as createMockSpinner, m as FixtureName, n as TestFixtureOptions, o as createTestToken, p as FIXTURE_WORKSPACE_FILE, r as testCopyDirectory, s as MockWatcher, t as TestExampleOptions, u as createMockHttpServer } from "../testFixture-DKy-0AbB.js";
2
2
  import { n as mockTelemetry, t as MockTelemetryOptions } from "../mockTelemetry-Bh1va02-.js";
3
3
  import { t as snapshotSerializer } from "../snapshotSerializer-B3X8EXGX.js";
4
4
  export { DEFAULT_FIXTURES, ExampleName, FIXTURE_WORKSPACE_FILE, FixtureName, FixtureOptions, MockTelemetryOptions, MockWatcher, TestExampleOptions, TestFixtureOptions, createMockHttpServer, createMockSpinner, createMockWatcher, createTestToken, mockTelemetry, snapshotSerializer, testCopyDirectory, testExample, testFixture };
@@ -10,9 +10,9 @@ interface FixtureOptions {
10
10
  /**
11
11
  * Name of the `pnpm-workspace.yaml` template bundled alongside the fixtures.
12
12
  *
13
- * The build generates it from the repository's own `pnpm-workspace.yaml` so fixture
14
- * installs apply the same install policy as the repository, and fixture setup writes
15
- * it into each fixture as its `pnpm-workspace.yaml`.
13
+ * The build generates it from the repository's `allowBuilds` and excludes the packages
14
+ * a Studio release publishes. Fixture setup writes it into each fixture as its
15
+ * `pnpm-workspace.yaml`.
16
16
  *
17
17
  * @internal
18
18
  */
@@ -147,4 +147,4 @@ declare function testFixture(fixtureName: FixtureName | (string & {}), options?:
147
147
  */
148
148
  declare function testExample(exampleName: FixtureName | (string & {}), options?: TestFixtureOptions): Promise<string>;
149
149
  export { testFixture as a, createMockWatcher as c, DEFAULT_FIXTURES as d, ExampleName as f, FixtureOptions as h, testExample as i, createMockSpinner as l, FixtureName as m, TestFixtureOptions as n, createTestToken as o, FIXTURE_WORKSPACE_FILE as p, testCopyDirectory as r, MockWatcher as s, TestExampleOptions as t, createMockHttpServer as u };
150
- //# sourceMappingURL=testFixture-BSYY9y-u.d.ts.map
150
+ //# sourceMappingURL=testFixture-DKy-0AbB.d.ts.map
@@ -4,45 +4,9 @@ allowBuilds:
4
4
  node-pty: true
5
5
  sharp: false
6
6
  unrs-resolver: false
7
- minimumReleaseAge: 4320
8
7
  minimumReleaseAgeExclude:
9
8
  - "@portabletext/*"
10
9
  - "@sanity/*"
11
10
  - "@sanity-labs/*"
12
- - "@types/*"
13
- - eventsource
14
- - eventsource-parser
15
- - get-it
16
- - groq-js
17
- - groq
18
- - lodash-es
19
- - react-rx
20
11
  - sanity
21
12
  - sanity-plugin-media
22
- - use-effect-event
23
- - oxfmt
24
- - "@oxfmt/*"
25
- - vite
26
- - "@vitejs/*"
27
- - rolldown
28
- - "@rolldown/*"
29
- - oxc-transform-react
30
- - "@oxc-transform-react/*"
31
- - vitest
32
- - postcss
33
- - "@vitest/*"
34
- - "@codemirror/search@6.7.2"
35
- - "@codemirror/state@6.7.2"
36
- - "@codemirror/view@6.43.10"
37
- - "@sentry/browser-utils@10.73.0"
38
- - "@sentry/browser@10.73.0"
39
- - "@sentry/core@10.73.0"
40
- - "@sentry/feedback@10.73.0"
41
- - "@sentry/react@10.73.0"
42
- - "@sentry/replay-canvas@10.73.0"
43
- - "@sentry/replay@10.73.0"
44
- - i18next@26.4.1
45
- - react-i18next@17.0.13
46
- - smol-toml@1.9.0
47
- - dompurify@3.4.17
48
- - zod@4.6.6
@@ -28,6 +28,6 @@
28
28
  "@sanity/color": "^3.0.6",
29
29
  "@types/react": "^19.2.14",
30
30
  "typescript": "^6.0.3",
31
- "vite": "^8.3.6"
31
+ "vite": "^8.3.8"
32
32
  }
33
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-test",
3
- "version": "24.0.3",
3
+ "version": "25.0.1",
4
4
  "description": "Sanity CLI test helpers and utilities",
5
5
  "keywords": [
6
6
  "cli",
@@ -111,35 +111,35 @@
111
111
  "access": "public"
112
112
  },
113
113
  "dependencies": {
114
- "@sanity/cli-core": "3.14.2",
115
- "@swc/core": "^1.15.43",
114
+ "@sanity/cli-core": "3.15.1",
115
+ "@swc/core": "^1.16.22",
116
116
  "ansis": "^4.2.0",
117
117
  "esbuild": "^0.28.2",
118
- "get-it": "^9.5.4",
119
- "nock": "^14.0.15",
118
+ "get-it": "^9.7.0",
119
+ "nock": "^14.0.17",
120
120
  "tinyglobby": "^0.2.17"
121
121
  },
122
122
  "devDependencies": {
123
123
  "@eslint/compat": "^2.1.0",
124
- "@oclif/core": "^4.11.14",
124
+ "@oclif/core": "^4.14.0",
125
125
  "@repo/package.config": "0.0.1",
126
126
  "@repo/tsconfig": "3.70.0",
127
127
  "@sanity/client": "^8.15.0",
128
128
  "@sanity/eslint-config-cli": "1.1.3",
129
129
  "@sanity/pkg-utils": "^12.3.4",
130
- "@swc/cli": "^0.8.1",
130
+ "@swc/cli": "^0.8.2",
131
131
  "@types/node": "^22.20.5",
132
132
  "eslint": "^10.7.0",
133
133
  "publint": "^0.3.21",
134
134
  "rimraf": "^6.0.1",
135
- "tsx": "^4.23.12",
135
+ "tsx": "^4.23.15",
136
136
  "typescript": "^6.0.3",
137
137
  "vitest": "^5.1.0",
138
138
  "yaml": "^2.9.0"
139
139
  },
140
140
  "peerDependencies": {
141
141
  "@oclif/core": "^4.0.0",
142
- "@sanity/cli-core": "3.14.2",
142
+ "@sanity/cli-core": "3.15.1",
143
143
  "@sanity/client": "^8.15.0",
144
144
  "vitest": ">=3.0.0 <6.0.0"
145
145
  },