@sanity/cli 3.88.3 → 3.89.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 +24933 -24961
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +10 -10
- package/src/actions/init-project/bootstrapLocalTemplate.ts +9 -4
- package/src/actions/init-project/createPackageManifest.ts +17 -8
- package/src/actions/init-project/initProject.ts +1 -1
- package/src/actions/init-project/templates/appQuickstart.ts +0 -7
- package/src/actions/init-project/templates/appSanityUi.ts +0 -7
- package/src/commands/blueprints/addBlueprintsCommand.ts +67 -19
- package/src/commands/blueprints/configBlueprintsCommand.ts +8 -10
- package/src/commands/blueprints/deployBlueprintsCommand.ts +8 -17
- package/src/commands/blueprints/destroyBlueprintsCommand.ts +8 -5
- package/src/commands/blueprints/infoBlueprintsCommand.ts +8 -15
- package/src/commands/blueprints/logsBlueprintsCommand.ts +8 -15
- package/src/commands/blueprints/planBlueprintsCommand.ts +8 -10
- package/src/commands/blueprints/stacksBlueprintsCommand.ts +8 -11
- package/src/commands/functions/devFunctionsCommand.ts +31 -7
- package/src/commands/functions/envFunctionsCommand.ts +39 -54
- package/src/commands/functions/functionsGroup.ts +1 -1
- package/src/commands/functions/logsFunctionsCommand.ts +29 -102
- package/src/commands/functions/testFunctionsCommand.ts +46 -52
- package/templates/app-quickstart/src/App.tsx +1 -1
- package/templates/app-sanity-ui/src/App.tsx +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.89.0",
|
4
4
|
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
|
5
5
|
"keywords": [
|
6
6
|
"sanity",
|
@@ -58,18 +58,18 @@
|
|
58
58
|
},
|
59
59
|
"dependencies": {
|
60
60
|
"@babel/traverse": "^7.23.5",
|
61
|
-
"@sanity/client": "^7.2.
|
62
|
-
"@sanity/codegen": "3.
|
63
|
-
"@sanity/runtime-cli": "^
|
61
|
+
"@sanity/client": "^7.2.2",
|
62
|
+
"@sanity/codegen": "3.89.0",
|
63
|
+
"@sanity/runtime-cli": "^7.3.2",
|
64
64
|
"@sanity/telemetry": "^0.8.0",
|
65
65
|
"@sanity/template-validator": "^2.4.3",
|
66
|
-
"@sanity/util": "3.
|
66
|
+
"@sanity/util": "3.89.0",
|
67
67
|
"chalk": "^4.1.2",
|
68
68
|
"debug": "^4.3.4",
|
69
69
|
"decompress": "^4.2.0",
|
70
70
|
"esbuild": "0.25.4",
|
71
71
|
"esbuild-register": "^3.5.0",
|
72
|
-
"get-it": "^8.6.
|
72
|
+
"get-it": "^8.6.9",
|
73
73
|
"groq-js": "^1.16.1",
|
74
74
|
"pkg-dir": "^5.0.0",
|
75
75
|
"prettier": "^3.3.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.89.0",
|
81
|
+
"@repo/test-config": "3.89.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.89.0",
|
87
87
|
"@types/babel__traverse": "^7.20.5",
|
88
88
|
"@types/configstore": "^5.0.1",
|
89
89
|
"@types/cpx": "^1.5.2",
|
@@ -135,5 +135,5 @@
|
|
135
135
|
"engines": {
|
136
136
|
"node": ">=18"
|
137
137
|
},
|
138
|
-
"gitHead": "
|
138
|
+
"gitHead": "88e2dda0aa6048eed31625c477c72814833a5443"
|
139
139
|
}
|
@@ -132,6 +132,7 @@ export async function bootstrapLocalTemplate(
|
|
132
132
|
dependencies,
|
133
133
|
devDependencies,
|
134
134
|
scripts: template.scripts,
|
135
|
+
isAppTemplate,
|
135
136
|
})
|
136
137
|
|
137
138
|
// ...and a studio config (`sanity.config.[ts|js]`)
|
@@ -163,10 +164,14 @@ export async function bootstrapLocalTemplate(
|
|
163
164
|
],
|
164
165
|
writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),
|
165
166
|
writeFileIfNotExists('package.json', packageManifest),
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
167
|
+
...[
|
168
|
+
isAppTemplate
|
169
|
+
? Promise.resolve(null)
|
170
|
+
: writeFileIfNotExists(
|
171
|
+
'eslint.config.mjs',
|
172
|
+
`import studio from '@sanity/eslint-config-studio'\n\nexport default [...studio]\n`,
|
173
|
+
),
|
174
|
+
],
|
170
175
|
].filter(Boolean),
|
171
176
|
)
|
172
177
|
|
@@ -17,13 +17,28 @@ const manifestPropOrder = [
|
|
17
17
|
]
|
18
18
|
|
19
19
|
export function createPackageManifest(
|
20
|
-
data: Omit<PackageJson, 'version'> & {gitRemote?: string},
|
20
|
+
data: Omit<PackageJson, 'version'> & {gitRemote?: string} & {isAppTemplate?: boolean},
|
21
21
|
): string {
|
22
|
+
const {isAppTemplate} = data
|
23
|
+
|
22
24
|
const dependencies = data.dependencies ? {dependencies: sortObject(data.dependencies)} : {}
|
25
|
+
|
23
26
|
const devDependencies = data.devDependencies
|
24
27
|
? {devDependencies: sortObject(data.devDependencies)}
|
25
28
|
: {}
|
26
29
|
|
30
|
+
// Don't write a prettier config for SDK apps; we want to allow developers to use their own
|
31
|
+
const prettierConfig = isAppTemplate
|
32
|
+
? {}
|
33
|
+
: {
|
34
|
+
prettier: {
|
35
|
+
semi: false,
|
36
|
+
printWidth: 100,
|
37
|
+
bracketSpacing: false,
|
38
|
+
singleQuote: true,
|
39
|
+
},
|
40
|
+
}
|
41
|
+
|
27
42
|
const pkg = {
|
28
43
|
...getCommonManifest(data),
|
29
44
|
|
@@ -39,13 +54,7 @@ export function createPackageManifest(
|
|
39
54
|
|
40
55
|
...dependencies,
|
41
56
|
...devDependencies,
|
42
|
-
|
43
|
-
prettier: {
|
44
|
-
semi: false,
|
45
|
-
printWidth: 100,
|
46
|
-
bracketSpacing: false,
|
47
|
-
singleQuote: true,
|
48
|
-
},
|
57
|
+
...prettierConfig,
|
49
58
|
}
|
50
59
|
|
51
60
|
return serializeManifest(pkg)
|
@@ -294,7 +294,7 @@ export default async function initSanity(
|
|
294
294
|
|
295
295
|
const flags = await prepareFlags()
|
296
296
|
|
297
|
-
// We're authenticated, now lets select or create a project (for studios) or org (for
|
297
|
+
// We're authenticated, now lets select or create a project (for studios) or org (for custom apps)
|
298
298
|
const {projectId, displayName, isFirstProject, datasetName, schemaUrl, organizationId} =
|
299
299
|
await getProjectDetails()
|
300
300
|
|
@@ -8,14 +8,7 @@ const appTemplate: ProjectTemplate = {
|
|
8
8
|
'react-dom': '^19',
|
9
9
|
},
|
10
10
|
devDependencies: {
|
11
|
-
/*
|
12
|
-
* this will be changed to eslint-config sanity,
|
13
|
-
* eslint.config generation will be a fast follow
|
14
|
-
*/
|
15
|
-
'@sanity/eslint-config-studio': '^5.0.1',
|
16
11
|
'@types/react': '^18.0.25',
|
17
|
-
'eslint': '^9.9.0',
|
18
|
-
'prettier': '^3.0.2',
|
19
12
|
'sanity': '^3',
|
20
13
|
'typescript': '^5.1.6',
|
21
14
|
},
|
@@ -10,14 +10,7 @@ const appSanityUiTemplate: ProjectTemplate = {
|
|
10
10
|
'styled-components': '^6.1.17',
|
11
11
|
},
|
12
12
|
devDependencies: {
|
13
|
-
/*
|
14
|
-
* this will be changed to eslint-config sanity,
|
15
|
-
* eslint.config generation will be a fast follow
|
16
|
-
*/
|
17
|
-
'@sanity/eslint-config-studio': '^5.0.1',
|
18
13
|
'@types/react': '^18.0.25',
|
19
|
-
'eslint': '^9.9.0',
|
20
|
-
'prettier': '^3.0.2',
|
21
14
|
'sanity': '^3',
|
22
15
|
'typescript': '^5.1.6',
|
23
16
|
},
|
@@ -5,37 +5,62 @@ Arguments
|
|
5
5
|
<type> Type of Resource to add (currently only 'function' is supported)
|
6
6
|
|
7
7
|
Options
|
8
|
-
--name <name>
|
9
|
-
--fn-type <type>
|
10
|
-
--fn-
|
11
|
-
--js, --javascript
|
8
|
+
--name, -n <name> Name of the Resource
|
9
|
+
--fn-type <type> Type of Function to add (e.g. document-publish)
|
10
|
+
--fn-language, --lang <ts|js> Language of the Function. Default: "ts"
|
11
|
+
--js, --javascript Shortcut for --fn-language=js
|
12
|
+
--fn-helpers, --helpers Add helpers to the Function
|
13
|
+
--no-fn-helpers Do not add helpers to the Function
|
14
|
+
--fn-installer, Package manager to use for Function helpers
|
15
|
+
--installer <npm|pnpm|yarn> sets --fn-helpers to true
|
16
|
+
--install, -i Shortcut for --fn-installer=npm
|
12
17
|
|
13
18
|
Examples:
|
14
|
-
# Add a Function
|
19
|
+
# Add a Function (TypeScript by default)
|
15
20
|
sanity blueprints add function
|
16
21
|
|
17
|
-
# Add a Function
|
18
|
-
sanity blueprints add function --name my-function
|
22
|
+
# Add a Function with a specific name and install helpers with npm
|
23
|
+
sanity blueprints add function --name my-function -i
|
19
24
|
|
20
|
-
# Add a Function
|
21
|
-
sanity blueprints add function --
|
25
|
+
# Add a Function with a specific type
|
26
|
+
sanity blueprints add function --fn-type document-publish
|
22
27
|
|
23
|
-
# Add a Function
|
24
|
-
sanity blueprints add function --
|
28
|
+
# Add a JavaScript Function
|
29
|
+
sanity blueprints add function --js
|
30
|
+
|
31
|
+
# Add a Function without helpers
|
32
|
+
sanity blueprints add function --no-fn-helpers
|
33
|
+
|
34
|
+
# Add a document-publish .js Function with helpers and install with npm
|
35
|
+
sanity blueprints add function -n roboto --fn-type document-publish --js -i
|
25
36
|
`
|
26
37
|
|
27
38
|
export interface BlueprintsAddFlags {
|
28
39
|
'name'?: string
|
40
|
+
'n'?: string
|
41
|
+
|
29
42
|
'fn-type'?: string
|
30
|
-
|
31
|
-
'language'?: string
|
43
|
+
|
44
|
+
'fn-language'?: string
|
32
45
|
'lang'?: string
|
46
|
+
|
33
47
|
'js'?: boolean
|
34
48
|
'javascript'?: boolean
|
49
|
+
|
50
|
+
'fn-helpers'?: boolean
|
51
|
+
'helpers'?: boolean
|
52
|
+
'no-fn-helpers'?: boolean
|
53
|
+
|
54
|
+
'fn-installer'?: string
|
55
|
+
'installer'?: string
|
56
|
+
|
57
|
+
'install'?: boolean
|
58
|
+
'i'?: boolean
|
35
59
|
}
|
36
60
|
|
37
61
|
const defaultFlags: BlueprintsAddFlags = {
|
38
|
-
|
62
|
+
'fn-language': 'ts',
|
63
|
+
// 'fn-helpers': true, // ask, for now
|
39
64
|
}
|
40
65
|
|
41
66
|
const addBlueprintsCommand: CliCommandDefinition<BlueprintsAddFlags> = {
|
@@ -47,9 +72,17 @@ const addBlueprintsCommand: CliCommandDefinition<BlueprintsAddFlags> = {
|
|
47
72
|
description: 'Add a Resource to a Blueprint',
|
48
73
|
|
49
74
|
async action(args, context) {
|
50
|
-
const {output} = context
|
75
|
+
const {output, apiClient} = context
|
51
76
|
const flags = {...defaultFlags, ...args.extOptions}
|
52
77
|
|
78
|
+
const client = apiClient({
|
79
|
+
requireUser: true,
|
80
|
+
requireProject: false,
|
81
|
+
})
|
82
|
+
const {token} = client.config()
|
83
|
+
|
84
|
+
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
85
|
+
|
53
86
|
const [resourceType] = args.argsWithoutOptions
|
54
87
|
|
55
88
|
if (!resourceType) {
|
@@ -57,16 +90,31 @@ const addBlueprintsCommand: CliCommandDefinition<BlueprintsAddFlags> = {
|
|
57
90
|
return
|
58
91
|
}
|
59
92
|
|
93
|
+
const {initBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
60
94
|
const {blueprintAddCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
61
|
-
|
95
|
+
|
96
|
+
const cmdConfig = await initBlueprintConfig({
|
62
97
|
bin: 'sanity',
|
63
|
-
log: (
|
98
|
+
log: (message) => output.print(message),
|
99
|
+
token,
|
100
|
+
})
|
101
|
+
|
102
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
103
|
+
|
104
|
+
let userWantsFnHelpers = flags.helpers || flags['fn-helpers']
|
105
|
+
if (flags['no-fn-helpers'] === true) userWantsFnHelpers = false // override
|
106
|
+
|
107
|
+
const {success, error} = await blueprintAddCore({
|
108
|
+
...cmdConfig.value,
|
64
109
|
args: {type: resourceType},
|
65
110
|
flags: {
|
66
|
-
'name': flags.name,
|
111
|
+
'name': flags.n ?? flags.name,
|
67
112
|
'fn-type': flags['fn-type'],
|
68
|
-
'language': flags['fn-
|
113
|
+
'language': flags.lang ?? flags['fn-language'],
|
69
114
|
'javascript': flags.js || flags.javascript,
|
115
|
+
'fn-helpers': userWantsFnHelpers,
|
116
|
+
'fn-installer': flags.installer ?? flags['fn-installer'],
|
117
|
+
'install': flags.i || flags.install,
|
70
118
|
},
|
71
119
|
})
|
72
120
|
|
@@ -57,21 +57,19 @@ const configBlueprintsCommand: CliCommandDefinition<BlueprintsConfigFlags> = {
|
|
57
57
|
|
58
58
|
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
59
59
|
|
60
|
+
const {initBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
60
61
|
const {blueprintConfigCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
61
|
-
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
62
|
-
const {display} = await import('@sanity/runtime-cli/utils')
|
63
62
|
|
64
|
-
const
|
63
|
+
const cmdConfig = await initBlueprintConfig({
|
64
|
+
bin: 'sanity',
|
65
|
+
log: (message) => output.print(message),
|
66
|
+
token,
|
67
|
+
})
|
65
68
|
|
66
|
-
if (
|
67
|
-
// print issues and continue
|
68
|
-
output.print(display.errors.presentBlueprintIssues(issues))
|
69
|
-
}
|
69
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
70
70
|
|
71
71
|
const {success, error} = await blueprintConfigCore({
|
72
|
-
|
73
|
-
log: (message) => output.print(message),
|
74
|
-
blueprint: localBlueprint,
|
72
|
+
...cmdConfig.value,
|
75
73
|
token,
|
76
74
|
flags: {
|
77
75
|
'project-id': flags['project-id'] ?? flags.projectId ?? flags.project,
|
@@ -38,28 +38,19 @@ const deployBlueprintsCommand: CliCommandDefinition<BlueprintsDeployFlags> = {
|
|
38
38
|
const {token} = client.config()
|
39
39
|
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
40
40
|
|
41
|
+
const {initDeployedBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
41
42
|
const {blueprintDeployCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
42
|
-
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
43
|
-
const {display} = await import('@sanity/runtime-cli/utils')
|
44
43
|
|
45
|
-
const
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
}
|
44
|
+
const cmdConfig = await initDeployedBlueprintConfig({
|
45
|
+
bin: 'sanity',
|
46
|
+
log: (message) => output.print(message),
|
47
|
+
token,
|
48
|
+
})
|
51
49
|
|
52
|
-
|
53
|
-
const auth = {token, projectId}
|
50
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
54
51
|
|
55
52
|
const {success, error} = await blueprintDeployCore({
|
56
|
-
|
57
|
-
log: (message) => output.print(message),
|
58
|
-
auth,
|
59
|
-
projectId,
|
60
|
-
stackId,
|
61
|
-
deployedStack,
|
62
|
-
blueprint: localBlueprint,
|
53
|
+
...cmdConfig.value,
|
63
54
|
flags: {
|
64
55
|
'no-wait': flags['no-wait'],
|
65
56
|
},
|
@@ -50,16 +50,19 @@ const destroyBlueprintsCommand: CliCommandDefinition<BlueprintsDestroyFlags> = {
|
|
50
50
|
const {token} = client.config()
|
51
51
|
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
52
52
|
|
53
|
+
const {initBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
53
54
|
const {blueprintDestroyCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
54
|
-
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
55
55
|
|
56
|
-
const
|
57
|
-
|
58
|
-
const {success, error} = await blueprintDestroyCore({
|
56
|
+
const cmdConfig = await initBlueprintConfig({
|
59
57
|
bin: 'sanity',
|
60
58
|
log: (message) => output.print(message),
|
61
59
|
token,
|
62
|
-
|
60
|
+
})
|
61
|
+
|
62
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
63
|
+
|
64
|
+
const {success, error} = await blueprintDestroyCore({
|
65
|
+
...cmdConfig.value,
|
63
66
|
flags: {
|
64
67
|
'no-wait': flags['no-wait'],
|
65
68
|
'force': flags.force ?? flags.f,
|
@@ -32,26 +32,19 @@ const infoBlueprintsCommand: CliCommandDefinition<BlueprintsInfoFlags> = {
|
|
32
32
|
const {token} = client.config()
|
33
33
|
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
34
34
|
|
35
|
+
const {initDeployedBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
35
36
|
const {blueprintInfoCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
36
|
-
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
37
|
-
const {display} = await import('@sanity/runtime-cli/utils')
|
38
37
|
|
39
|
-
const
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
}
|
38
|
+
const cmdConfig = await initDeployedBlueprintConfig({
|
39
|
+
bin: 'sanity',
|
40
|
+
log: (message) => output.print(message),
|
41
|
+
token,
|
42
|
+
})
|
45
43
|
|
46
|
-
|
47
|
-
const auth = {token, projectId}
|
44
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
48
45
|
|
49
46
|
const {success, error} = await blueprintInfoCore({
|
50
|
-
|
51
|
-
log: (message) => output.print(message),
|
52
|
-
auth,
|
53
|
-
stackId,
|
54
|
-
deployedStack,
|
47
|
+
...cmdConfig.value,
|
55
48
|
flags,
|
56
49
|
})
|
57
50
|
|
@@ -39,26 +39,19 @@ const logsBlueprintsCommand: CliCommandDefinition<BlueprintsLogsFlags> = {
|
|
39
39
|
const {token} = client.config()
|
40
40
|
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
41
41
|
|
42
|
+
const {initDeployedBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
42
43
|
const {blueprintLogsCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
43
|
-
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
44
|
-
const {display} = await import('@sanity/runtime-cli/utils')
|
45
44
|
|
46
|
-
const
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}
|
45
|
+
const cmdConfig = await initDeployedBlueprintConfig({
|
46
|
+
bin: 'sanity',
|
47
|
+
log: (message) => output.print(message),
|
48
|
+
token,
|
49
|
+
})
|
52
50
|
|
53
|
-
|
54
|
-
const auth = {token, projectId}
|
51
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
55
52
|
|
56
53
|
const {success, streaming, error} = await blueprintLogsCore({
|
57
|
-
|
58
|
-
log: (message) => output.print(message),
|
59
|
-
auth,
|
60
|
-
stackId,
|
61
|
-
deployedStack,
|
54
|
+
...cmdConfig.value,
|
62
55
|
flags: {
|
63
56
|
watch: flags.watch ?? flags.w,
|
64
57
|
},
|
@@ -29,21 +29,19 @@ const planBlueprintsCommand: CliCommandDefinition<BlueprintsPlanFlags> = {
|
|
29
29
|
const {token} = client.config()
|
30
30
|
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
31
31
|
|
32
|
+
const {initBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
32
33
|
const {blueprintPlanCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
33
|
-
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
34
|
-
const {display} = await import('@sanity/runtime-cli/utils')
|
35
34
|
|
36
|
-
const
|
35
|
+
const cmdConfig = await initBlueprintConfig({
|
36
|
+
bin: 'sanity',
|
37
|
+
log: (message) => output.print(message),
|
38
|
+
token,
|
39
|
+
})
|
37
40
|
|
38
|
-
if (
|
39
|
-
// print issues and continue
|
40
|
-
output.print(display.errors.presentBlueprintIssues(issues))
|
41
|
-
}
|
41
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
42
42
|
|
43
43
|
const {success, error} = await blueprintPlanCore({
|
44
|
-
|
45
|
-
log: (message) => output.print(message),
|
46
|
-
blueprint: localBlueprint,
|
44
|
+
...cmdConfig.value,
|
47
45
|
})
|
48
46
|
|
49
47
|
if (!success) throw new Error(error)
|
@@ -41,22 +41,19 @@ const stacksBlueprintsCommand: CliCommandDefinition<BlueprintsStacksFlags> = {
|
|
41
41
|
const {token} = client.config()
|
42
42
|
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
43
43
|
|
44
|
+
const {initBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
44
45
|
const {blueprintStacksCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
45
|
-
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
46
|
-
const {display} = await import('@sanity/runtime-cli/utils')
|
47
46
|
|
48
|
-
const
|
49
|
-
|
50
|
-
if (issues) {
|
51
|
-
// print issues and continue
|
52
|
-
output.print(display.errors.presentBlueprintIssues(issues))
|
53
|
-
}
|
54
|
-
|
55
|
-
const {success, error} = await blueprintStacksCore({
|
47
|
+
const cmdConfig = await initBlueprintConfig({
|
56
48
|
bin: 'sanity',
|
57
49
|
log: (message) => output.print(message),
|
58
50
|
token,
|
59
|
-
|
51
|
+
})
|
52
|
+
|
53
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
54
|
+
|
55
|
+
const {success, error} = await blueprintStacksCore({
|
56
|
+
...cmdConfig.value,
|
60
57
|
flags: {
|
61
58
|
projectId: flags['project-id'] ?? flags.projectId ?? flags.project,
|
62
59
|
},
|
@@ -14,25 +14,49 @@ Examples
|
|
14
14
|
sanity functions dev --port 3333
|
15
15
|
`
|
16
16
|
|
17
|
-
|
17
|
+
export interface FunctionsDevFlags {
|
18
|
+
port?: number
|
19
|
+
}
|
20
|
+
|
21
|
+
const defaultFlags: FunctionsDevFlags = {
|
18
22
|
port: 8080,
|
19
23
|
}
|
20
24
|
|
21
|
-
const devFunctionsCommand: CliCommandDefinition = {
|
25
|
+
const devFunctionsCommand: CliCommandDefinition<FunctionsDevFlags> = {
|
22
26
|
name: 'dev',
|
23
27
|
group: 'functions',
|
24
28
|
helpText,
|
25
29
|
signature: '[--port <port>]',
|
26
30
|
description: 'Start the Sanity Function emulator',
|
27
31
|
async action(args, context) {
|
28
|
-
const {output} = context
|
29
|
-
const {print} = output
|
32
|
+
const {apiClient, output} = context
|
30
33
|
const flags = {...defaultFlags, ...args.extOptions}
|
31
34
|
|
32
|
-
const {
|
33
|
-
|
35
|
+
const client = apiClient({requireUser: true, requireProject: false})
|
36
|
+
const {token} = client.config()
|
37
|
+
|
38
|
+
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
39
|
+
|
40
|
+
const {initBlueprintConfig} = await import('@sanity/runtime-cli/cores')
|
41
|
+
const {functionDevCore} = await import('@sanity/runtime-cli/cores/functions')
|
42
|
+
|
43
|
+
const cmdConfig = await initBlueprintConfig({
|
44
|
+
bin: 'sanity',
|
45
|
+
log: (message) => output.print(message),
|
46
|
+
token,
|
47
|
+
})
|
48
|
+
|
49
|
+
if (!cmdConfig.ok) throw new Error(cmdConfig.error)
|
50
|
+
|
51
|
+
const {success, error} = await functionDevCore({
|
52
|
+
...cmdConfig.value,
|
53
|
+
flags: {
|
54
|
+
port: flags.port,
|
55
|
+
},
|
56
|
+
})
|
57
|
+
|
58
|
+
if (!success) throw new Error(error)
|
34
59
|
|
35
|
-
print(`Server is running on port ${flags.port}\n`)
|
36
60
|
open(`http://localhost:${flags.port}`)
|
37
61
|
},
|
38
62
|
}
|