@sanity/cli 5.3.0-next.64 → 5.3.0-next.65

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/lib/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import {Answers} from 'inquirer'
2
2
  import type chalk from 'chalk'
3
3
  import {ChoiceCollection} from 'inquirer'
4
+ import {ClientConfig} from '@sanity/client'
4
5
  import {ConfigEnv} from 'vite'
5
6
  import {DistinctQuestion} from 'inquirer'
6
7
  import {InlineConfig} from 'vite'
@@ -34,13 +35,18 @@ export declare interface CliApiConfig {
34
35
  dataset?: string
35
36
  }
36
37
 
37
- export declare interface CliClientOptions {
38
+ /**
39
+ * `getCliClient` accepts all options the `ClientConfig` does but provides
40
+ * `projectId` and `dataset` from the `sanity.cli.ts` configuration file along
41
+ * with a token in certain scenarios (e.g. `sanity exec SCRIPT --with-user-token`)
42
+ */
43
+ export declare interface CliClientOptions extends ClientConfig {
44
+ /**
45
+ * If no `projectId` or `dataset` is provided, `getCliClient` will try to
46
+ * resolve these from the `sanity.cli.ts` configuration file. Use this option
47
+ * to specify the directory to look for this file.
48
+ */
38
49
  cwd?: string
39
- projectId?: string
40
- dataset?: string
41
- useCdn?: boolean
42
- token?: string
43
- apiVersion?: string
44
50
  }
45
51
 
46
52
  export declare type CliCommandAction<F = Record<string, unknown>> = (
package/lib/index.js CHANGED
@@ -10,10 +10,11 @@ function getCliClientImpl(options = {}) {
10
10
  apiVersion = "2022-06-06",
11
11
  projectId,
12
12
  dataset,
13
- token = getCliClient.__internal__getToken()
13
+ token = getCliClient.__internal__getToken(),
14
+ ...restOfOptions
14
15
  } = options;
15
16
  if (projectId && dataset)
16
- return client.createClient({ projectId, dataset, apiVersion, useCdn, token });
17
+ return client.createClient({ projectId, dataset, apiVersion, useCdn, token, ...restOfOptions });
17
18
  const rootDir = loadEnv.resolveRootDir(cwd), { config } = getCliConfig.getSanityCliConfig(rootDir) || {};
18
19
  if (!config)
19
20
  throw new Error("Unable to resolve CLI configuration");
@@ -25,7 +26,8 @@ function getCliClientImpl(options = {}) {
25
26
  dataset: apiConfig.dataset,
26
27
  apiVersion,
27
28
  useCdn,
28
- token
29
+ token,
30
+ ...restOfOptions
29
31
  });
30
32
  }
31
33
  getCliClientImpl.__internal__getToken = () => {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/cliClient.ts","../src/config.ts"],"sourcesContent":["import {createClient, type SanityClient} from '@sanity/client'\n\nimport {getSanityCliConfig} from './util/getCliConfig'\nimport {resolveRootDir} from './util/resolveRootDir'\n\nexport interface CliClientOptions {\n cwd?: string\n\n projectId?: string\n dataset?: string\n useCdn?: boolean\n token?: string\n apiVersion?: string\n}\n\ninterface GetCliClient {\n (options?: CliClientOptions): SanityClient\n /**\n * @internal\n * @deprecated This is only for INTERNAL use, and should not be relied upon outside of official Sanity modules\n * @returns A token to use when constructing a client without a `token` explicitly defined, or undefined\n */\n __internal__getToken: () => string | undefined\n}\n\nfunction getCliClientImpl(options: CliClientOptions = {}): SanityClient {\n if (typeof process !== 'object') {\n throw new Error('getCliClient() should only be called from node.js scripts')\n }\n\n const {\n cwd = process.env.SANITY_BASE_PATH || process.cwd(),\n useCdn = false,\n apiVersion = '2022-06-06',\n projectId,\n dataset,\n token = getCliClient.__internal__getToken(),\n } = options\n\n if (projectId && dataset) {\n return createClient({projectId, dataset, apiVersion, useCdn, token})\n }\n\n const rootDir = resolveRootDir(cwd)\n const {config} = getSanityCliConfig(rootDir) || {}\n if (!config) {\n throw new Error('Unable to resolve CLI configuration')\n }\n\n const apiConfig = config?.api || {}\n if (!apiConfig.projectId || !apiConfig.dataset) {\n throw new Error('Unable to resolve project ID/dataset from CLI configuration')\n }\n\n return createClient({\n projectId: apiConfig.projectId,\n dataset: apiConfig.dataset,\n apiVersion,\n useCdn,\n token,\n })\n}\n\n/* eslint-disable camelcase */\ngetCliClientImpl.__internal__getToken = (): string | undefined => undefined\n/* eslint-enable camelcase */\n\n/** @internal */\nexport const getCliClient: GetCliClient = getCliClientImpl\n","import {type CliConfig} from './types'\n\n/** @beta */\nexport function defineCliConfig(config: CliConfig): CliConfig {\n return config\n}\n\n/**\n * @deprecated Use `defineCliConfig` instead\n * @beta\n */\nexport function createCliConfig(config: CliConfig): CliConfig {\n return config\n}\n"],"names":["createClient","resolveRootDir","getSanityCliConfig"],"mappings":";;;AAyBA,SAAS,iBAAiB,UAA4B,IAAkB;AACtE,MAAI,OAAO,WAAY;AACrB,UAAM,IAAI,MAAM,2DAA2D;AAG7E,QAAM;AAAA,IACJ,MAAM,QAAQ,IAAI,oBAAoB,QAAQ,IAAA;AAAA,IAC9C,SAAS;AAAA,IACT,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,QAAQ,aAAa,qBAAA;AAAA,EAAqB,IACxC;AAEJ,MAAI,aAAa;AACf,WAAOA,OAAAA,aAAa,EAAC,WAAW,SAAS,YAAY,QAAQ,OAAM;AAGrE,QAAM,UAAUC,QAAAA,eAAe,GAAG,GAC5B,EAAC,WAAUC,aAAAA,mBAAmB,OAAO,KAAK,CAAA;AAChD,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,qCAAqC;AAGvD,QAAM,YAAY,QAAQ,OAAO,CAAA;AACjC,MAAI,CAAC,UAAU,aAAa,CAAC,UAAU;AACrC,UAAM,IAAI,MAAM,6DAA6D;AAG/E,SAAOF,oBAAa;AAAA,IAClB,WAAW,UAAU;AAAA,IACrB,SAAS,UAAU;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AACH;AAGA,iBAAiB,uBAAuB,MAAuB;AAAA;AAIxD,MAAM,eAA6B;ACjEnC,SAAS,gBAAgB,QAA8B;AAC5D,SAAO;AACT;AAMO,SAAS,gBAAgB,QAA8B;AAC5D,SAAO;AACT;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/cliClient.ts","../src/config.ts"],"sourcesContent":["import {type ClientConfig, createClient, type SanityClient} from '@sanity/client'\n\nimport {getSanityCliConfig} from './util/getCliConfig'\nimport {resolveRootDir} from './util/resolveRootDir'\n\n/**\n * `getCliClient` accepts all options the `ClientConfig` does but provides\n * `projectId` and `dataset` from the `sanity.cli.ts` configuration file along\n * with a token in certain scenarios (e.g. `sanity exec SCRIPT --with-user-token`)\n */\nexport interface CliClientOptions extends ClientConfig {\n /**\n * If no `projectId` or `dataset` is provided, `getCliClient` will try to\n * resolve these from the `sanity.cli.ts` configuration file. Use this option\n * to specify the directory to look for this file.\n */\n cwd?: string\n}\n\ninterface GetCliClient {\n (options?: CliClientOptions): SanityClient\n /**\n * @internal\n * @deprecated This is only for INTERNAL use, and should not be relied upon outside of official Sanity modules\n * @returns A token to use when constructing a client without a `token` explicitly defined, or undefined\n */\n __internal__getToken: () => string | undefined\n}\n\nfunction getCliClientImpl(options: CliClientOptions = {}): SanityClient {\n if (typeof process !== 'object') {\n throw new Error('getCliClient() should only be called from node.js scripts')\n }\n\n const {\n cwd = process.env.SANITY_BASE_PATH || process.cwd(),\n useCdn = false,\n apiVersion = '2022-06-06',\n projectId,\n dataset,\n token = getCliClient.__internal__getToken(),\n ...restOfOptions\n } = options\n\n if (projectId && dataset) {\n return createClient({projectId, dataset, apiVersion, useCdn, token, ...restOfOptions})\n }\n\n const rootDir = resolveRootDir(cwd)\n const {config} = getSanityCliConfig(rootDir) || {}\n if (!config) {\n throw new Error('Unable to resolve CLI configuration')\n }\n\n const apiConfig = config?.api || {}\n if (!apiConfig.projectId || !apiConfig.dataset) {\n throw new Error('Unable to resolve project ID/dataset from CLI configuration')\n }\n\n return createClient({\n projectId: apiConfig.projectId,\n dataset: apiConfig.dataset,\n apiVersion,\n useCdn,\n token,\n ...restOfOptions,\n })\n}\n\n/* eslint-disable camelcase */\ngetCliClientImpl.__internal__getToken = (): string | undefined => undefined\n/* eslint-enable camelcase */\n\n/** @internal */\nexport const getCliClient: GetCliClient = getCliClientImpl\n","import {type CliConfig} from './types'\n\n/** @beta */\nexport function defineCliConfig(config: CliConfig): CliConfig {\n return config\n}\n\n/**\n * @deprecated Use `defineCliConfig` instead\n * @beta\n */\nexport function createCliConfig(config: CliConfig): CliConfig {\n return config\n}\n"],"names":["createClient","resolveRootDir","getSanityCliConfig"],"mappings":";;;AA6BA,SAAS,iBAAiB,UAA4B,IAAkB;AACtE,MAAI,OAAO,WAAY;AACrB,UAAM,IAAI,MAAM,2DAA2D;AAG7E,QAAM;AAAA,IACJ,MAAM,QAAQ,IAAI,oBAAoB,QAAQ,IAAA;AAAA,IAC9C,SAAS;AAAA,IACT,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,QAAQ,aAAa,qBAAA;AAAA,IACrB,GAAG;AAAA,EAAA,IACD;AAEJ,MAAI,aAAa;AACf,WAAOA,OAAAA,aAAa,EAAC,WAAW,SAAS,YAAY,QAAQ,OAAO,GAAG,eAAc;AAGvF,QAAM,UAAUC,QAAAA,eAAe,GAAG,GAC5B,EAAC,WAAUC,aAAAA,mBAAmB,OAAO,KAAK,CAAA;AAChD,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,qCAAqC;AAGvD,QAAM,YAAY,QAAQ,OAAO,CAAA;AACjC,MAAI,CAAC,UAAU,aAAa,CAAC,UAAU;AACrC,UAAM,IAAI,MAAM,6DAA6D;AAG/E,SAAOF,oBAAa;AAAA,IAClB,WAAW,UAAU;AAAA,IACrB,SAAS,UAAU;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;AAGA,iBAAiB,uBAAuB,MAAuB;AAAA;AAIxD,MAAM,eAA6B;ACvEnC,SAAS,gBAAgB,QAA8B;AAC5D,SAAO;AACT;AAMO,SAAS,gBAAgB,QAA8B;AAC5D,SAAO;AACT;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli",
3
- "version": "5.3.0-next.64+110c6c75e0",
3
+ "version": "5.3.0-next.65+1e4e248f6a",
4
4
  "description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
5
5
  "keywords": [
6
6
  "sanity",
@@ -57,7 +57,7 @@
57
57
  "pkg-dir": "^5.0.0",
58
58
  "prettier": "^3.7.4",
59
59
  "semver": "^7.7.2",
60
- "@sanity/codegen": "5.3.0-next.64+110c6c75e0"
60
+ "@sanity/codegen": "5.3.0-next.65+1e4e248f6a"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@rexxars/gitconfiglocal": "^3.0.1",
@@ -111,11 +111,11 @@
111
111
  "vitest": "^4.0.16",
112
112
  "which": "^2.0.2",
113
113
  "xdg-basedir": "^4.0.0",
114
- "@repo/eslint-config": "5.3.0-next.64+110c6c75e0",
115
- "@repo/package.config": "5.3.0-next.64+110c6c75e0",
116
- "@repo/tsconfig": "5.3.0-next.64+110c6c75e0",
117
- "@sanity/types": "5.2.0",
118
- "@repo/test-config": "5.3.0-next.64+110c6c75e0"
114
+ "@repo/eslint-config": "5.3.0-next.65+1e4e248f6a",
115
+ "@repo/package.config": "5.3.0-next.65+1e4e248f6a",
116
+ "@repo/test-config": "5.3.0-next.65+1e4e248f6a",
117
+ "@repo/tsconfig": "5.3.0-next.65+1e4e248f6a",
118
+ "@sanity/types": "5.2.0"
119
119
  },
120
120
  "peerDependencies": {
121
121
  "babel-plugin-react-compiler": "*"