@sanity/cli-test 0.0.2-alpha.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sanity.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @sanity/cli-test
2
+
3
+ Provides test helpers for the Sanity CLI.
4
+
5
+ ## API
6
+
7
+ ### `testCommand(command: Command, args?: string[])`
8
+
9
+ Runs the given command with the given arguments and returns the output.
10
+
11
+ ```ts
12
+ const {stdout} = await testCommand(DevCommand, ['--host', '0.0.0.0', '--port', '3000'])
13
+ ```
14
+
15
+ ### `mockApi(api: ApiClient)`
16
+
17
+ Mocks the sanity/client calls.
18
+
19
+ ```ts
20
+ mockApi({
21
+ apiVersion: '2024-01-17',
22
+ method: 'get',
23
+ uri: '/users/me',
24
+ query: {
25
+ recordType: 'user',
26
+ },
27
+ }).reply(200, {
28
+ id: 'user-id',
29
+ name: 'John Doe',
30
+ email: 'john.doe@example.com',
31
+ })
32
+ ```
@@ -0,0 +1,3 @@
1
+ export * from './test/mockApi.js';
2
+ export * from './test/testCommand.js';
3
+ export * from './test/testHook.js';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './test/mockApi.js';
2
+ export * from './test/testCommand.js';
3
+ export * from './test/testHook.js';
4
+
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './test/mockApi.js'\nexport * from './test/testCommand.js'\nexport * from './test/testHook.js'\n"],"names":[],"mappings":"AAAA,cAAc,oBAAmB;AACjC,cAAc,wBAAuB;AACrC,cAAc,qBAAoB"}
@@ -0,0 +1,33 @@
1
+ import { type Errors } from '@oclif/core';
2
+ export interface CaptureOptions {
3
+ /**
4
+ * Whether to print the output to the console
5
+ */
6
+ print?: boolean;
7
+ /**
8
+ * Whether to strip ANSI escape codes from the output
9
+ */
10
+ stripAnsi?: boolean;
11
+ testNodeEnv?: string;
12
+ }
13
+ export interface CaptureResult<T = unknown> {
14
+ stderr: string;
15
+ stdout: string;
16
+ error?: Error & Partial<Errors.CLIError>;
17
+ result?: T;
18
+ }
19
+ /**
20
+ * Capture the output of a command and return the result
21
+ *
22
+ * @param fn - The function to capture the output of
23
+ * @param opts - The options for the capture
24
+ * @returns The result of the command
25
+ * @internal
26
+ *
27
+ * Credits to oclif for the original implementation:
28
+ * https://github.com/oclif/test/blob/2a5407e6fc80d388043d10f6b7b8eaa586483015/src/index.ts
29
+ *
30
+ * We are not using the library directly since it does not support mocking code inside of the command
31
+ * possibly because the commands run in a different thread
32
+ */
33
+ export declare function captureOutput<T>(fn: () => Promise<T>, opts?: CaptureOptions): Promise<CaptureResult<T>>;
@@ -0,0 +1,83 @@
1
+ import ansis from 'ansis';
2
+ /**
3
+ * Capture the output of a command and return the result
4
+ *
5
+ * @param fn - The function to capture the output of
6
+ * @param opts - The options for the capture
7
+ * @returns The result of the command
8
+ * @internal
9
+ *
10
+ * Credits to oclif for the original implementation:
11
+ * https://github.com/oclif/test/blob/2a5407e6fc80d388043d10f6b7b8eaa586483015/src/index.ts
12
+ *
13
+ * We are not using the library directly since it does not support mocking code inside of the command
14
+ * possibly because the commands run in a different thread
15
+ */ export async function captureOutput(fn, opts) {
16
+ const print = opts?.print ?? false;
17
+ const stripAnsi = opts?.stripAnsi ?? true;
18
+ const testNodeEnv = opts?.testNodeEnv || 'test';
19
+ const originals = {
20
+ NODE_ENV: process.env.NODE_ENV,
21
+ stderrWrite: process.stderr.write,
22
+ stdoutWrite: process.stdout.write
23
+ };
24
+ const output = {
25
+ stderr: [],
26
+ stdout: []
27
+ };
28
+ const toString = (str)=>stripAnsi ? ansis.strip(str.toString()) : str.toString();
29
+ const getStderr = ()=>output.stderr.map((b)=>toString(b)).join('');
30
+ const getStdout = ()=>output.stdout.map((b)=>toString(b)).join('');
31
+ const mockWrite = (std)=>(chunk, encodingOrCb, cb)=>{
32
+ output[std].push(chunk.toString());
33
+ if (print) {
34
+ let callback = cb;
35
+ let encoding;
36
+ if (typeof encodingOrCb === 'function') {
37
+ callback = encodingOrCb;
38
+ } else {
39
+ encoding = encodingOrCb;
40
+ }
41
+ originals[`${std}Write`].apply(process[std], [
42
+ chunk,
43
+ encoding,
44
+ callback
45
+ ]);
46
+ } else if (typeof cb === 'function') {
47
+ cb();
48
+ } else if (typeof encodingOrCb === 'function') {
49
+ encodingOrCb();
50
+ }
51
+ return true;
52
+ };
53
+ process.stdout.write = mockWrite('stdout');
54
+ process.stderr.write = mockWrite('stderr');
55
+ process.env.NODE_ENV = testNodeEnv;
56
+ try {
57
+ const result = await fn();
58
+ return {
59
+ result,
60
+ stderr: getStderr(),
61
+ stdout: getStdout()
62
+ };
63
+ } catch (error) {
64
+ // Check if it's an oclif CLIError or a regular error
65
+ const processedError = error instanceof Error // Check if it's an Error (this includes CLIError)
66
+ ? Object.assign(error, {
67
+ message: toString(error.message)
68
+ }) // If so, process its message
69
+ : new Error(toString(String(error))) // Otherwise, create a new Error from string representation
70
+ ;
71
+ return {
72
+ error: processedError,
73
+ stderr: getStderr(),
74
+ stdout: getStdout()
75
+ };
76
+ } finally{
77
+ process.stdout.write = originals.stdoutWrite;
78
+ process.stderr.write = originals.stderrWrite;
79
+ process.env.NODE_ENV = originals.NODE_ENV;
80
+ }
81
+ }
82
+
83
+ //# sourceMappingURL=captureOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/captureOutput.ts"],"sourcesContent":["import {type Errors} from '@oclif/core'\nimport ansis from 'ansis'\n\nexport interface CaptureOptions {\n /**\n * Whether to print the output to the console\n */\n print?: boolean\n /**\n * Whether to strip ANSI escape codes from the output\n */\n stripAnsi?: boolean\n testNodeEnv?: string\n}\n\nexport interface CaptureResult<T = unknown> {\n stderr: string\n stdout: string\n\n error?: Error & Partial<Errors.CLIError>\n result?: T\n}\n\n/**\n * Capture the output of a command and return the result\n *\n * @param fn - The function to capture the output of\n * @param opts - The options for the capture\n * @returns The result of the command\n * @internal\n *\n * Credits to oclif for the original implementation:\n * https://github.com/oclif/test/blob/2a5407e6fc80d388043d10f6b7b8eaa586483015/src/index.ts\n *\n * We are not using the library directly since it does not support mocking code inside of the command\n * possibly because the commands run in a different thread\n */\nexport async function captureOutput<T>(\n fn: () => Promise<T>,\n opts?: CaptureOptions,\n): Promise<CaptureResult<T>> {\n const print = opts?.print ?? false\n const stripAnsi = opts?.stripAnsi ?? true\n const testNodeEnv = opts?.testNodeEnv || 'test'\n\n const originals = {\n NODE_ENV: process.env.NODE_ENV,\n stderrWrite: process.stderr.write,\n stdoutWrite: process.stdout.write,\n }\n\n const output: Record<'stderr' | 'stdout', string[]> = {\n stderr: [],\n stdout: [],\n }\n\n const toString = (str: string | Uint8Array): string =>\n stripAnsi ? ansis.strip(str.toString()) : str.toString()\n\n const getStderr = (): string => output.stderr.map((b) => toString(b)).join('')\n const getStdout = (): string => output.stdout.map((b) => toString(b)).join('')\n\n const mockWrite =\n (std: 'stderr' | 'stdout'): typeof process.stderr.write =>\n (\n chunk: string | Uint8Array,\n encodingOrCb?: ((err?: Error | null) => void) | BufferEncoding,\n cb?: (err?: Error | null) => void,\n ) => {\n output[std].push(chunk.toString())\n\n if (print) {\n let callback: ((err?: Error | null) => void) | undefined = cb\n let encoding: BufferEncoding | undefined\n if (typeof encodingOrCb === 'function') {\n callback = encodingOrCb\n } else {\n encoding = encodingOrCb\n }\n originals[`${std}Write`].apply(process[std], [chunk, encoding, callback])\n } else if (typeof cb === 'function') {\n cb()\n } else if (typeof encodingOrCb === 'function') {\n encodingOrCb()\n }\n return true\n }\n\n process.stdout.write = mockWrite('stdout')\n process.stderr.write = mockWrite('stderr')\n process.env.NODE_ENV = testNodeEnv\n\n try {\n const result = await fn()\n return {\n result,\n stderr: getStderr(),\n stdout: getStdout(),\n }\n } catch (error) {\n // Check if it's an oclif CLIError or a regular error\n const processedError =\n error instanceof Error // Check if it's an Error (this includes CLIError)\n ? Object.assign(error, {message: toString(error.message)}) // If so, process its message\n : new Error(toString(String(error))) // Otherwise, create a new Error from string representation\n\n return {\n error: processedError,\n stderr: getStderr(),\n stdout: getStdout(),\n }\n } finally {\n process.stdout.write = originals.stdoutWrite\n process.stderr.write = originals.stderrWrite\n process.env.NODE_ENV = originals.NODE_ENV\n }\n}\n"],"names":["ansis","captureOutput","fn","opts","print","stripAnsi","testNodeEnv","originals","NODE_ENV","process","env","stderrWrite","stderr","write","stdoutWrite","stdout","output","toString","str","strip","getStderr","map","b","join","getStdout","mockWrite","std","chunk","encodingOrCb","cb","push","callback","encoding","apply","result","error","processedError","Error","Object","assign","message","String"],"mappings":"AACA,OAAOA,WAAW,QAAO;AAsBzB;;;;;;;;;;;;;CAaC,GACD,OAAO,eAAeC,cACpBC,EAAoB,EACpBC,IAAqB;IAErB,MAAMC,QAAQD,MAAMC,SAAS;IAC7B,MAAMC,YAAYF,MAAME,aAAa;IACrC,MAAMC,cAAcH,MAAMG,eAAe;IAEzC,MAAMC,YAAY;QAChBC,UAAUC,QAAQC,GAAG,CAACF,QAAQ;QAC9BG,aAAaF,QAAQG,MAAM,CAACC,KAAK;QACjCC,aAAaL,QAAQM,MAAM,CAACF,KAAK;IACnC;IAEA,MAAMG,SAAgD;QACpDJ,QAAQ,EAAE;QACVG,QAAQ,EAAE;IACZ;IAEA,MAAME,WAAW,CAACC,MAChBb,YAAYL,MAAMmB,KAAK,CAACD,IAAID,QAAQ,MAAMC,IAAID,QAAQ;IAExD,MAAMG,YAAY,IAAcJ,OAAOJ,MAAM,CAACS,GAAG,CAAC,CAACC,IAAML,SAASK,IAAIC,IAAI,CAAC;IAC3E,MAAMC,YAAY,IAAcR,OAAOD,MAAM,CAACM,GAAG,CAAC,CAACC,IAAML,SAASK,IAAIC,IAAI,CAAC;IAE3E,MAAME,YACJ,CAACC,MACD,CACEC,OACAC,cACAC;YAEAb,MAAM,CAACU,IAAI,CAACI,IAAI,CAACH,MAAMV,QAAQ;YAE/B,IAAIb,OAAO;gBACT,IAAI2B,WAAuDF;gBAC3D,IAAIG;gBACJ,IAAI,OAAOJ,iBAAiB,YAAY;oBACtCG,WAAWH;gBACb,OAAO;oBACLI,WAAWJ;gBACb;gBACArB,SAAS,CAAC,GAAGmB,IAAI,KAAK,CAAC,CAAC,CAACO,KAAK,CAACxB,OAAO,CAACiB,IAAI,EAAE;oBAACC;oBAAOK;oBAAUD;iBAAS;YAC1E,OAAO,IAAI,OAAOF,OAAO,YAAY;gBACnCA;YACF,OAAO,IAAI,OAAOD,iBAAiB,YAAY;gBAC7CA;YACF;YACA,OAAO;QACT;IAEFnB,QAAQM,MAAM,CAACF,KAAK,GAAGY,UAAU;IACjChB,QAAQG,MAAM,CAACC,KAAK,GAAGY,UAAU;IACjChB,QAAQC,GAAG,CAACF,QAAQ,GAAGF;IAEvB,IAAI;QACF,MAAM4B,SAAS,MAAMhC;QACrB,OAAO;YACLgC;YACAtB,QAAQQ;YACRL,QAAQS;QACV;IACF,EAAE,OAAOW,OAAO;QACd,qDAAqD;QACrD,MAAMC,iBACJD,iBAAiBE,MAAM,kDAAkD;WACrEC,OAAOC,MAAM,CAACJ,OAAO;YAACK,SAASvB,SAASkB,MAAMK,OAAO;QAAC,GAAG,6BAA6B;WACtF,IAAIH,MAAMpB,SAASwB,OAAON,SAAS,2DAA2D;;QAEpG,OAAO;YACLA,OAAOC;YACPxB,QAAQQ;YACRL,QAAQS;QACV;IACF,SAAU;QACRf,QAAQM,MAAM,CAACF,KAAK,GAAGN,UAAUO,WAAW;QAC5CL,QAAQG,MAAM,CAACC,KAAK,GAAGN,UAAUI,WAAW;QAC5CF,QAAQC,GAAG,CAACF,QAAQ,GAAGD,UAAUC,QAAQ;IAC3C;AACF"}
@@ -0,0 +1,34 @@
1
+ import nock from 'nock';
2
+ /**
3
+ * @internal
4
+ */
5
+ export interface MockApiOptions {
6
+ /**
7
+ * Uri to mock
8
+ */
9
+ uri: string;
10
+ /**
11
+ * Api host to mock, defaults to `https://api.sanity.io`
12
+ */
13
+ apiHost?: string;
14
+ /**
15
+ * Api version to mock, defaults to `v2025-05-14`
16
+ */
17
+ apiVersion?: string;
18
+ /**
19
+ * HTTP method to mock
20
+ *
21
+ * Defaults to 'get'
22
+ */
23
+ method?: 'delete' | 'get' | 'post' | 'put';
24
+ /**
25
+ * Query parameters to mock
26
+ */
27
+ query?: Record<string, string>;
28
+ }
29
+ /**
30
+ * Mocks the API calls, add some defaults so it doesn't cause too much friction
31
+ *
32
+ * @internal
33
+ */
34
+ export declare function mockApi({ apiHost, apiVersion, method, query, uri, }: MockApiOptions): nock.Interceptor;
@@ -0,0 +1,14 @@
1
+ import nock from 'nock';
2
+ /**
3
+ * Mocks the API calls, add some defaults so it doesn't cause too much friction
4
+ *
5
+ * @internal
6
+ */ export function mockApi({ apiHost = 'https://api.sanity.io', apiVersion = 'v2025-05-14', method = 'get', query = {}, uri }) {
7
+ const version = apiVersion.startsWith('v') ? apiVersion : `v${apiVersion}`;
8
+ return nock(apiHost)[method](`/${version}${uri}`).query({
9
+ tag: 'sanity.cli',
10
+ ...query
11
+ });
12
+ }
13
+
14
+ //# sourceMappingURL=mockApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/mockApi.ts"],"sourcesContent":["import nock from 'nock'\n\n/**\n * @internal\n */\nexport interface MockApiOptions {\n /**\n * Uri to mock\n */\n uri: string\n\n /**\n * Api host to mock, defaults to `https://api.sanity.io`\n */\n apiHost?: string\n\n /**\n * Api version to mock, defaults to `v2025-05-14`\n */\n apiVersion?: string\n\n /**\n * HTTP method to mock\n *\n * Defaults to 'get'\n */\n method?: 'delete' | 'get' | 'post' | 'put'\n\n /**\n * Query parameters to mock\n */\n query?: Record<string, string>\n}\n\n/**\n * Mocks the API calls, add some defaults so it doesn't cause too much friction\n *\n * @internal\n */\nexport function mockApi({\n apiHost = 'https://api.sanity.io',\n apiVersion = 'v2025-05-14',\n method = 'get',\n query = {},\n uri,\n}: MockApiOptions) {\n const version = apiVersion.startsWith('v') ? apiVersion : `v${apiVersion}`\n\n return nock(apiHost)\n [method](`/${version}${uri}`)\n .query({tag: 'sanity.cli', ...query})\n}\n"],"names":["nock","mockApi","apiHost","apiVersion","method","query","uri","version","startsWith","tag"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAkCvB;;;;CAIC,GACD,OAAO,SAASC,QAAQ,EACtBC,UAAU,uBAAuB,EACjCC,aAAa,aAAa,EAC1BC,SAAS,KAAK,EACdC,QAAQ,CAAC,CAAC,EACVC,GAAG,EACY;IACf,MAAMC,UAAUJ,WAAWK,UAAU,CAAC,OAAOL,aAAa,CAAC,CAAC,EAAEA,YAAY;IAE1E,OAAOH,KAAKE,QACV,CAACE,OAAO,CAAC,CAAC,CAAC,EAAEG,UAAUD,KAAK,EAC3BD,KAAK,CAAC;QAACI,KAAK;QAAc,GAAGJ,KAAK;IAAA;AACvC"}
@@ -0,0 +1,6 @@
1
+ import { Command, Config } from '@oclif/core';
2
+ import { type CaptureOptions, type CaptureResult } from './captureOutput.js';
3
+ export declare function testCommand(command: (new (argv: string[], config: Config) => Command) & typeof Command, args?: string[], options?: {
4
+ capture?: CaptureOptions;
5
+ config?: Partial<Config>;
6
+ }): Promise<CaptureResult<unknown>>;
@@ -0,0 +1,12 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { captureOutput } from './captureOutput.js';
4
+ export async function testCommand(command, args, options) {
5
+ const commandInstancePromise = ()=>command.run(args || [], {
6
+ root: path.resolve(fileURLToPath(import.meta.url), '../../../../cli'),
7
+ ...options?.config
8
+ });
9
+ return captureOutput(commandInstancePromise, options?.capture);
10
+ }
11
+
12
+ //# sourceMappingURL=testCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/testCommand.ts"],"sourcesContent":["import path from 'node:path'\nimport {fileURLToPath} from 'node:url'\n\nimport {Command, Config} from '@oclif/core'\n\nimport {type CaptureOptions, captureOutput, type CaptureResult} from './captureOutput.js'\n\nexport async function testCommand(\n command: (new (argv: string[], config: Config) => Command) & typeof Command,\n args?: string[],\n options?: {capture?: CaptureOptions; config?: Partial<Config>},\n): Promise<CaptureResult<unknown>> {\n const commandInstancePromise = () =>\n command.run(args || [], {\n root: path.resolve(fileURLToPath(import.meta.url), '../../../../cli'),\n ...options?.config,\n })\n\n return captureOutput(commandInstancePromise, options?.capture)\n}\n"],"names":["path","fileURLToPath","captureOutput","testCommand","command","args","options","commandInstancePromise","run","root","resolve","url","config","capture"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAC5B,SAAQC,aAAa,QAAO,WAAU;AAItC,SAA6BC,aAAa,QAA2B,qBAAoB;AAEzF,OAAO,eAAeC,YACpBC,OAA2E,EAC3EC,IAAe,EACfC,OAA8D;IAE9D,MAAMC,yBAAyB,IAC7BH,QAAQI,GAAG,CAACH,QAAQ,EAAE,EAAE;YACtBI,MAAMT,KAAKU,OAAO,CAACT,cAAc,YAAYU,GAAG,GAAG;YACnD,GAAGL,SAASM,MAAM;QACpB;IAEF,OAAOV,cAAcK,wBAAwBD,SAASO;AACxD"}
@@ -0,0 +1,8 @@
1
+ import { Command } from '@oclif/core';
2
+ import { type Hook, type Hooks } from '@oclif/core/hooks';
3
+ interface Options {
4
+ Command?: Command.Loadable;
5
+ context?: Hook.Context;
6
+ }
7
+ export declare function testHook<T extends keyof Hooks>(hook: Hook<T>, options?: Options): Promise<import("./captureOutput.js").CaptureResult<Hooks[T]["return"]>>;
8
+ export {};
@@ -0,0 +1,27 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { Config } from '@oclif/core';
4
+ import { captureOutput } from './captureOutput.js';
5
+ export async function testHook(hook, options) {
6
+ const config = await Config.load({
7
+ root: path.resolve(fileURLToPath(import.meta.url), '../../../../cli')
8
+ });
9
+ const contextDefault = {
10
+ config,
11
+ debug: console.log,
12
+ error: console.error,
13
+ exit: process.exit,
14
+ log: console.log,
15
+ warn: console.warn
16
+ };
17
+ const { Command, context = contextDefault } = options ?? {};
18
+ const commandInstancePromise = ()=>hook.call(context, {
19
+ argv: [],
20
+ Command,
21
+ config,
22
+ context
23
+ });
24
+ return captureOutput(commandInstancePromise);
25
+ }
26
+
27
+ //# sourceMappingURL=testHook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/test/testHook.ts"],"sourcesContent":["import path from 'node:path'\nimport {fileURLToPath} from 'node:url'\n\nimport {Command, Config} from '@oclif/core'\nimport {type Hook, type Hooks} from '@oclif/core/hooks'\n\nimport {captureOutput} from './captureOutput.js'\n\ninterface Options {\n Command?: Command.Loadable\n context?: Hook.Context\n}\n\nexport async function testHook<T extends keyof Hooks>(hook: Hook<T>, options?: Options) {\n const config = await Config.load({\n root: path.resolve(fileURLToPath(import.meta.url), '../../../../cli'),\n })\n\n const contextDefault = {\n config,\n debug: console.log,\n error: console.error,\n exit: process.exit,\n log: console.log,\n warn: console.warn,\n }\n\n const {Command, context = contextDefault} = options ?? {}\n\n const commandInstancePromise = () =>\n hook.call(context, {\n argv: [],\n Command,\n config,\n context,\n })\n\n return captureOutput(commandInstancePromise)\n}\n"],"names":["path","fileURLToPath","Config","captureOutput","testHook","hook","options","config","load","root","resolve","url","contextDefault","debug","console","log","error","exit","process","warn","Command","context","commandInstancePromise","call","argv"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAC5B,SAAQC,aAAa,QAAO,WAAU;AAEtC,SAAiBC,MAAM,QAAO,cAAa;AAG3C,SAAQC,aAAa,QAAO,qBAAoB;AAOhD,OAAO,eAAeC,SAAgCC,IAAa,EAAEC,OAAiB;IACpF,MAAMC,SAAS,MAAML,OAAOM,IAAI,CAAC;QAC/BC,MAAMT,KAAKU,OAAO,CAACT,cAAc,YAAYU,GAAG,GAAG;IACrD;IAEA,MAAMC,iBAAiB;QACrBL;QACAM,OAAOC,QAAQC,GAAG;QAClBC,OAAOF,QAAQE,KAAK;QACpBC,MAAMC,QAAQD,IAAI;QAClBF,KAAKD,QAAQC,GAAG;QAChBI,MAAML,QAAQK,IAAI;IACpB;IAEA,MAAM,EAACC,OAAO,EAAEC,UAAUT,cAAc,EAAC,GAAGN,WAAW,CAAC;IAExD,MAAMgB,yBAAyB,IAC7BjB,KAAKkB,IAAI,CAACF,SAAS;YACjBG,MAAM,EAAE;YACRJ;YACAb;YACAc;QACF;IAEF,OAAOlB,cAAcmB;AACvB"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@sanity/cli-test",
3
+ "version": "0.0.2-alpha.0",
4
+ "description": "Sanity CLI test helpers and utilities",
5
+ "keywords": [
6
+ "sanity",
7
+ "cms",
8
+ "headless",
9
+ "realtime",
10
+ "content",
11
+ "cli",
12
+ "tool"
13
+ ],
14
+ "homepage": "https://github.com/sanity-io/cli",
15
+ "bugs": "https://github.com/sanity-io/cli/issues",
16
+ "repository": "sanity-io/cli",
17
+ "license": "MIT",
18
+ "author": "Sanity.io <hello@sanity.io>",
19
+ "type": "module",
20
+ "exports": {
21
+ ".": {
22
+ "source": "./src/index.ts",
23
+ "require": "./dist/index.js",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "main": "dist/index.js",
29
+ "types": "dist/index.d.ts",
30
+ "files": [
31
+ "./dist"
32
+ ],
33
+ "dependencies": {
34
+ "@oclif/core": "^4.5.3",
35
+ "ansis": "^3.17.0",
36
+ "nock": "^14.0.5"
37
+ },
38
+ "devDependencies": {
39
+ "@eslint/compat": "^1.3.1",
40
+ "@swc/cli": "^0.7.8",
41
+ "@swc/core": "^1.13.2",
42
+ "@types/debug": "^4.1.12",
43
+ "@types/node": "^20.17.23",
44
+ "eslint": "^9.30.1",
45
+ "typescript": "^5.8.3",
46
+ "vitest": "^3.1.3",
47
+ "@repo/eslint-config": "0.0.0",
48
+ "@repo/tsconfig": "3.70.0"
49
+ },
50
+ "engines": {
51
+ "node": ">=20.19.1 <22 || >=22.12"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "scripts": {
57
+ "build": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ src",
58
+ "build:types": "tsc --project tsconfig.lib.json",
59
+ "check:types": "tsc --noEmit",
60
+ "lint": "eslint .",
61
+ "test": "vitest run",
62
+ "posttest": "pnpm run lint",
63
+ "test:coverage": "vitest run --coverage",
64
+ "test:watch": "vitest",
65
+ "watch": "swc --delete-dir-on-start --strip-leading-paths --out-dir dist/ --watch src"
66
+ }
67
+ }