@sanity/cli 3.91.1-next.9.e9b861a7e3 → 3.92.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/lib/_chunks-cjs/cli.js +45 -27
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +11 -11
- package/src/actions/init-project/initProject.ts +19 -10
- package/src/actions/init-project/templates/appQuickstart.ts +1 -1
- package/src/actions/init-project/templates/appSanityUi.ts +1 -1
- package/src/commands/blueprints/stacksBlueprintsCommand.ts +1 -1
- package/src/commands/functions/devFunctionsCommand.ts +11 -2
- package/src/commands/functions/logsFunctionsCommand.ts +10 -6
- package/src/commands/functions/testFunctionsCommand.ts +4 -3
- package/src/studioDependencies.ts +7 -7
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.92.0",
|
4
4
|
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
|
5
5
|
"keywords": [
|
6
6
|
"sanity",
|
@@ -58,12 +58,12 @@
|
|
58
58
|
},
|
59
59
|
"dependencies": {
|
60
60
|
"@babel/traverse": "^7.23.5",
|
61
|
-
"@sanity/client": "^7.
|
62
|
-
"@sanity/codegen": "3.
|
63
|
-
"@sanity/runtime-cli": "^
|
61
|
+
"@sanity/client": "^7.5.0",
|
62
|
+
"@sanity/codegen": "3.92.0",
|
63
|
+
"@sanity/runtime-cli": "^8.0.0",
|
64
64
|
"@sanity/telemetry": "^0.8.0",
|
65
65
|
"@sanity/template-validator": "^2.4.3",
|
66
|
-
"@sanity/util": "3.
|
66
|
+
"@sanity/util": "3.92.0",
|
67
67
|
"chalk": "^4.1.2",
|
68
68
|
"debug": "^4.3.4",
|
69
69
|
"decompress": "^4.2.0",
|
@@ -77,13 +77,13 @@
|
|
77
77
|
"validate-npm-package-name": "^3.0.0"
|
78
78
|
},
|
79
79
|
"devDependencies": {
|
80
|
-
"@repo/package.config": "3.
|
81
|
-
"@repo/test-config": "3.
|
80
|
+
"@repo/package.config": "3.92.0",
|
81
|
+
"@repo/test-config": "3.92.0",
|
82
82
|
"@rexxars/gitconfiglocal": "^3.0.1",
|
83
83
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
84
84
|
"@sanity/eslint-config-studio": "^4.0.0",
|
85
85
|
"@sanity/generate-help-url": "^3.0.0",
|
86
|
-
"@sanity/types": "3.
|
86
|
+
"@sanity/types": "3.92.0",
|
87
87
|
"@types/babel__traverse": "^7.20.5",
|
88
88
|
"@types/configstore": "^5.0.1",
|
89
89
|
"@types/cpx": "^1.5.2",
|
@@ -127,13 +127,13 @@
|
|
127
127
|
"semver": "^7.3.5",
|
128
128
|
"semver-compare": "^1.0.0",
|
129
129
|
"tar": "^6.1.11",
|
130
|
-
"vite": "^6.
|
131
|
-
"vitest": "^3.
|
130
|
+
"vite": "^6.3.5",
|
131
|
+
"vitest": "^3.2.2",
|
132
132
|
"which": "^2.0.2",
|
133
133
|
"xdg-basedir": "^4.0.0"
|
134
134
|
},
|
135
135
|
"engines": {
|
136
136
|
"node": ">=18"
|
137
137
|
},
|
138
|
-
"gitHead": "
|
138
|
+
"gitHead": "eb72cd37f48adaa4ab7fd69245edf91838992eaa"
|
139
139
|
}
|
@@ -888,7 +888,7 @@ export default async function initSanity(
|
|
888
888
|
|
889
889
|
return createProject(apiClient, {
|
890
890
|
displayName: projectName,
|
891
|
-
organizationId: await getOrganizationId(organizations),
|
891
|
+
organizationId: cliFlags.organization || (await getOrganizationId(organizations)),
|
892
892
|
subscription: selectedPlan ? {planId: selectedPlan} : undefined,
|
893
893
|
metadata: {coupon: intendedCoupon},
|
894
894
|
}).then((response) => ({
|
@@ -924,7 +924,7 @@ export default async function initSanity(
|
|
924
924
|
message: 'Your project name:',
|
925
925
|
default: 'My Sanity Project',
|
926
926
|
}),
|
927
|
-
organizationId: await getOrganizationId(organizations),
|
927
|
+
organizationId: cliFlags.organization || (await getOrganizationId(organizations)),
|
928
928
|
subscription: selectedPlan ? {planId: selectedPlan} : undefined,
|
929
929
|
metadata: {coupon: intendedCoupon},
|
930
930
|
}).then((response) => ({
|
@@ -1237,13 +1237,29 @@ export default async function initSanity(
|
|
1237
1237
|
'`--project <id>` or `--create-project <name>` must be specified in unattended mode',
|
1238
1238
|
)
|
1239
1239
|
}
|
1240
|
+
|
1241
|
+
if (createProjectName && !cliFlags.organization) {
|
1242
|
+
throw new Error(
|
1243
|
+
'--create-project is not supported in unattended mode without an organization, please specify an organization with `--organization <id>`',
|
1244
|
+
)
|
1245
|
+
}
|
1240
1246
|
}
|
1241
1247
|
|
1242
1248
|
if (createProjectName) {
|
1243
1249
|
debug('--create-project specified, creating a new project')
|
1250
|
+
|
1251
|
+
let orgForCreateProjectFlag = cliFlags.organization
|
1252
|
+
if (!orgForCreateProjectFlag) {
|
1253
|
+
debug('no organization specified, selecting one')
|
1254
|
+
const client = apiClient({requireUser: true, requireProject: false})
|
1255
|
+
const organizations = await client.request({uri: '/organizations'})
|
1256
|
+
orgForCreateProjectFlag = await getOrganizationId(organizations)
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
debug('creating a new project')
|
1244
1260
|
const createdProject = await createProject(apiClient, {
|
1245
1261
|
displayName: createProjectName.trim(),
|
1246
|
-
organizationId:
|
1262
|
+
organizationId: orgForCreateProjectFlag,
|
1247
1263
|
subscription: selectedPlan ? {planId: selectedPlan} : undefined,
|
1248
1264
|
metadata: {coupon: intendedCoupon},
|
1249
1265
|
})
|
@@ -1335,13 +1351,6 @@ export default async function initSanity(
|
|
1335
1351
|
}
|
1336
1352
|
|
1337
1353
|
async function getOrganizationId(organizations: ProjectOrganization[]) {
|
1338
|
-
// In unattended mode, if the user hasn't specified an organization, sending null as
|
1339
|
-
// organization ID to the API will create a new organization for the user with their
|
1340
|
-
// user name. If they _have_ specified an organization, we'll use that.
|
1341
|
-
if (unattended || flags.organization) {
|
1342
|
-
return flags.organization || undefined
|
1343
|
-
}
|
1344
|
-
|
1345
1354
|
// If the user has no organizations, prompt them to create one with the same name as
|
1346
1355
|
// their user, but allow them to customize it if they want
|
1347
1356
|
if (organizations.length === 0) {
|
@@ -55,7 +55,7 @@ const stacksBlueprintsCommand: CliCommandDefinition<BlueprintsStacksFlags> = {
|
|
55
55
|
const {success, error} = await blueprintStacksCore({
|
56
56
|
...cmdConfig.value,
|
57
57
|
flags: {
|
58
|
-
|
58
|
+
'project-id': flags['project-id'] ?? flags.projectId ?? flags.project,
|
59
59
|
},
|
60
60
|
})
|
61
61
|
|
@@ -5,6 +5,7 @@ import {type CliCommandDefinition} from '../../types'
|
|
5
5
|
const helpText = `
|
6
6
|
Options
|
7
7
|
--port <port> Port to start emulator on
|
8
|
+
--open Open dev server in a new browser tab
|
8
9
|
|
9
10
|
Examples
|
10
11
|
# Start dev server on default port
|
@@ -12,13 +13,18 @@ Examples
|
|
12
13
|
|
13
14
|
# Start dev server on specific port
|
14
15
|
sanity functions dev --port 3333
|
16
|
+
|
17
|
+
# Start dev server and open a new browser tab
|
18
|
+
sanity functions dev --open
|
15
19
|
`
|
16
20
|
|
17
21
|
export interface FunctionsDevFlags {
|
22
|
+
open?: boolean
|
18
23
|
port?: number
|
19
24
|
}
|
20
25
|
|
21
26
|
const defaultFlags: FunctionsDevFlags = {
|
27
|
+
open: false,
|
22
28
|
port: 8080,
|
23
29
|
}
|
24
30
|
|
@@ -26,11 +32,12 @@ const devFunctionsCommand: CliCommandDefinition<FunctionsDevFlags> = {
|
|
26
32
|
name: 'dev',
|
27
33
|
group: 'functions',
|
28
34
|
helpText,
|
29
|
-
signature: '[--port <port>]',
|
35
|
+
signature: '[--port <port> --open]',
|
30
36
|
description: 'Start the Sanity Function emulator',
|
31
37
|
async action(args, context) {
|
32
38
|
const {apiClient, output} = context
|
33
39
|
const flags = {...defaultFlags, ...args.extOptions}
|
40
|
+
const {open: shouldOpen} = flags
|
34
41
|
|
35
42
|
const client = apiClient({requireUser: true, requireProject: false})
|
36
43
|
const {token} = client.config()
|
@@ -57,7 +64,9 @@ const devFunctionsCommand: CliCommandDefinition<FunctionsDevFlags> = {
|
|
57
64
|
|
58
65
|
if (!success) throw new Error(error)
|
59
66
|
|
60
|
-
|
67
|
+
if (shouldOpen) {
|
68
|
+
open(`http://localhost:${flags.port}`)
|
69
|
+
}
|
61
70
|
},
|
62
71
|
}
|
63
72
|
|
@@ -6,10 +6,11 @@ Arguments
|
|
6
6
|
|
7
7
|
Options
|
8
8
|
--limit <limit> The number of log entries to retrieve [default 50]
|
9
|
-
--json
|
10
|
-
--utc
|
11
|
-
--delete
|
12
|
-
--force
|
9
|
+
--json If set return json
|
10
|
+
--utc Use UTC dates in logs
|
11
|
+
--delete Delete all logs for the Function
|
12
|
+
--force Force delete all logs for the Function
|
13
|
+
--watch Watch for new logs (streaming mode)
|
13
14
|
|
14
15
|
Examples
|
15
16
|
# Retrieve logs for Sanity Function
|
@@ -19,10 +20,13 @@ Examples
|
|
19
20
|
sanity functions logs echo --limit 2
|
20
21
|
|
21
22
|
# Retrieve logs for Sanity Function in json format
|
22
|
-
sanity functions logs
|
23
|
+
sanity functions logs echo --json
|
23
24
|
|
24
25
|
# Delete all logs for Sanity Function
|
25
|
-
sanity functions logs
|
26
|
+
sanity functions logs echo --delete
|
27
|
+
|
28
|
+
# Watch for new logs (streaming mode)
|
29
|
+
sanity functions logs echo --watch
|
26
30
|
`
|
27
31
|
|
28
32
|
export interface FunctionsLogsFlags {
|
@@ -53,7 +53,8 @@ const testFunctionsCommand: CliCommandDefinition<FunctionsTestFlags> = {
|
|
53
53
|
requireUser: true,
|
54
54
|
requireProject: false,
|
55
55
|
})
|
56
|
-
const {token} = client.config()
|
56
|
+
const {dataset, projectId, token} = client.config()
|
57
|
+
const actualDataset = dataset === '~dummy-placeholder-dataset-' ? undefined : dataset
|
57
58
|
|
58
59
|
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
59
60
|
|
@@ -80,8 +81,8 @@ const testFunctionsCommand: CliCommandDefinition<FunctionsTestFlags> = {
|
|
80
81
|
'file': flags.file,
|
81
82
|
'timeout': flags.timeout,
|
82
83
|
'api': flags.api,
|
83
|
-
'dataset': flags.dataset,
|
84
|
-
'project-id': flags['project-id'],
|
84
|
+
'dataset': flags.dataset || actualDataset,
|
85
|
+
'project-id': flags['project-id'] || projectId,
|
85
86
|
},
|
86
87
|
})
|
87
88
|
|
@@ -8,18 +8,18 @@ export const studioDependencies = {
|
|
8
8
|
'@sanity/vision': 'latest',
|
9
9
|
|
10
10
|
// Non-Sanity dependencies
|
11
|
-
'react': '^
|
12
|
-
'react-dom': '^
|
13
|
-
'styled-components': '^6.1.
|
11
|
+
'react': '^19.1',
|
12
|
+
'react-dom': '^19.1',
|
13
|
+
'styled-components': '^6.1.18',
|
14
14
|
},
|
15
15
|
|
16
16
|
devDependencies: {
|
17
17
|
// Linting/tooling
|
18
18
|
'@sanity/eslint-config-studio': 'latest',
|
19
19
|
// When using typescript, we'll want the these types too, so might as well install them
|
20
|
-
'@types/react': '^
|
21
|
-
'eslint': '^9.
|
22
|
-
'prettier': '^3.
|
23
|
-
'typescript': '^5.
|
20
|
+
'@types/react': '^19.1',
|
21
|
+
'eslint': '^9.28',
|
22
|
+
'prettier': '^3.5',
|
23
|
+
'typescript': '^5.8', // Peer dependency of eslint-config-studio (implicitly)
|
24
24
|
},
|
25
25
|
}
|