@sanity/cli 3.88.0 → 3.88.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/lib/_chunks-cjs/cli.js +58748 -56759
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +8 -8
- package/src/commands/blueprints/addBlueprintsCommand.ts +52 -56
- package/src/commands/blueprints/blueprintsGroup.ts +0 -1
- package/src/commands/blueprints/configBlueprintsCommand.ts +50 -74
- package/src/commands/blueprints/deployBlueprintsCommand.ts +41 -133
- package/src/commands/blueprints/destroyBlueprintsCommand.ts +76 -0
- package/src/commands/blueprints/infoBlueprintsCommand.ts +29 -51
- package/src/commands/blueprints/initBlueprintsCommand.ts +55 -73
- package/src/commands/blueprints/logsBlueprintsCommand.ts +43 -81
- package/src/commands/blueprints/planBlueprintsCommand.ts +26 -36
- package/src/commands/blueprints/stacksBlueprintsCommand.ts +43 -51
- package/src/commands/functions/devFunctionsCommand.ts +1 -2
- package/src/commands/functions/envFunctionsCommand.ts +55 -46
- package/src/commands/functions/functionsGroup.ts +1 -2
- package/src/commands/functions/logsFunctionsCommand.ts +101 -58
- package/src/commands/functions/testFunctionsCommand.ts +56 -36
- package/src/commands/index.ts +6 -4
- package/templates/app-sanity-ui/src/ExampleComponent.tsx +1 -1
@@ -1,29 +1,28 @@
|
|
1
1
|
import {type CliCommandDefinition} from '../../types'
|
2
2
|
|
3
3
|
const helpText = `
|
4
|
-
|
5
|
-
--id, -i Stack ID
|
6
|
-
|
7
|
-
Examples
|
4
|
+
Examples:
|
8
5
|
# Retrieve information about the current Stack
|
9
6
|
sanity blueprints info
|
10
|
-
|
11
|
-
# Retrieve information about a specific Stack
|
12
|
-
sanity blueprints info --id <stack-id>
|
13
7
|
`
|
14
8
|
|
15
|
-
|
9
|
+
export interface BlueprintsInfoFlags {
|
10
|
+
id?: string
|
11
|
+
}
|
12
|
+
|
13
|
+
const defaultFlags: BlueprintsInfoFlags = {
|
14
|
+
//
|
15
|
+
}
|
16
16
|
|
17
|
-
const infoBlueprintsCommand: CliCommandDefinition = {
|
17
|
+
const infoBlueprintsCommand: CliCommandDefinition<BlueprintsInfoFlags> = {
|
18
18
|
name: 'info',
|
19
19
|
group: 'blueprints',
|
20
20
|
helpText,
|
21
21
|
signature: '',
|
22
22
|
description: 'Retrieve information about a Blueprint Stack',
|
23
|
-
|
23
|
+
|
24
24
|
async action(args, context) {
|
25
25
|
const {apiClient, output} = context
|
26
|
-
const {print} = output
|
27
26
|
const flags = {...defaultFlags, ...args.extOptions}
|
28
27
|
|
29
28
|
const client = apiClient({
|
@@ -31,53 +30,32 @@ const infoBlueprintsCommand: CliCommandDefinition = {
|
|
31
30
|
requireProject: false,
|
32
31
|
})
|
33
32
|
const {token} = client.config()
|
34
|
-
|
35
|
-
|
36
|
-
)
|
33
|
+
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
34
|
+
|
35
|
+
const {blueprintInfoCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
36
|
+
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
37
37
|
const {display} = await import('@sanity/runtime-cli/utils')
|
38
38
|
|
39
|
-
|
40
|
-
try {
|
41
|
-
blueprint = await blueprintAction.readBlueprintOnDisk({token})
|
42
|
-
} catch (error) {
|
43
|
-
print('Unable to read Blueprint manifest file. Run `sanity blueprints init`')
|
44
|
-
return
|
45
|
-
}
|
39
|
+
const {localBlueprint, deployedStack, issues} = await getBlueprintAndStack({token})
|
46
40
|
|
47
|
-
if (
|
48
|
-
print(
|
49
|
-
|
41
|
+
if (issues) {
|
42
|
+
output.print(display.errors.presentBlueprintIssues(issues))
|
43
|
+
throw new Error('Unable to parse Blueprint file.')
|
50
44
|
}
|
51
45
|
|
52
|
-
const {
|
53
|
-
|
54
|
-
if (errors && errors.length > 0) {
|
55
|
-
print(errors)
|
56
|
-
return
|
57
|
-
}
|
46
|
+
const {projectId, stackId} = localBlueprint
|
47
|
+
const auth = {token, projectId}
|
58
48
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
print(error)
|
68
|
-
}
|
69
|
-
} else {
|
70
|
-
result = deployedStack
|
71
|
-
}
|
49
|
+
const {success, error} = await blueprintInfoCore({
|
50
|
+
bin: 'sanity',
|
51
|
+
log: (message) => output.print(message),
|
52
|
+
auth,
|
53
|
+
stackId,
|
54
|
+
deployedStack,
|
55
|
+
flags,
|
56
|
+
})
|
72
57
|
|
73
|
-
|
74
|
-
print(display.blueprintsFormatting.formatStackInfo(result))
|
75
|
-
} else {
|
76
|
-
print('No Stack found')
|
77
|
-
}
|
78
|
-
} else {
|
79
|
-
print('Cannot retrieve information for Blueprint: missing API token or Project ID')
|
80
|
-
}
|
58
|
+
if (!success) throw new Error(error)
|
81
59
|
},
|
82
60
|
}
|
83
61
|
|
@@ -1,95 +1,77 @@
|
|
1
|
-
import {join} from 'node:path'
|
2
|
-
import {cwd} from 'node:process'
|
3
|
-
|
4
1
|
import {type CliCommandDefinition} from '../../types'
|
5
2
|
|
6
3
|
const helpText = `
|
7
|
-
|
8
|
-
|
4
|
+
Arguments
|
5
|
+
[dir] Path to initialize the Blueprint in
|
6
|
+
|
7
|
+
Options
|
8
|
+
--blueprint-type, --type <json> Type of Blueprint to create
|
9
|
+
--project-id <id> Project ID to use
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
# Create a new Blueprint manifest file in the current directory
|
9
13
|
sanity blueprints init
|
14
|
+
|
15
|
+
# Create a new Blueprint manifest file in a specific directory
|
16
|
+
sanity blueprints init my-sanity-project --type json
|
10
17
|
`
|
11
18
|
|
12
|
-
|
19
|
+
export interface BlueprintsInitFlags {
|
20
|
+
'dir'?: string
|
21
|
+
'blueprint-type'?: string
|
22
|
+
'type'?: string
|
23
|
+
'project-id'?: string
|
24
|
+
'projectId'?: string
|
25
|
+
'project'?: string
|
26
|
+
'stack-id'?: string
|
27
|
+
'stackId'?: string
|
28
|
+
'stack'?: string
|
29
|
+
'stack-name'?: string
|
30
|
+
'name'?: string
|
31
|
+
}
|
32
|
+
|
33
|
+
const defaultFlags: BlueprintsInitFlags = {
|
34
|
+
//
|
35
|
+
}
|
36
|
+
|
37
|
+
const initBlueprintsCommand: CliCommandDefinition<BlueprintsInitFlags> = {
|
13
38
|
name: 'init',
|
14
39
|
group: 'blueprints',
|
15
40
|
helpText,
|
16
|
-
signature: '',
|
41
|
+
signature: '[dir] [--blueprint-type <type>] [--project-id <id>]',
|
17
42
|
description: 'Initialize a new Blueprint manifest file',
|
18
|
-
|
43
|
+
|
19
44
|
async action(args, context) {
|
20
|
-
const {apiClient, output
|
21
|
-
const
|
45
|
+
const {apiClient, output} = context
|
46
|
+
const flags = {...defaultFlags, ...args.extOptions}
|
47
|
+
|
48
|
+
const [dir] = args.argsWithoutOptions
|
22
49
|
|
23
50
|
const client = apiClient({
|
24
51
|
requireUser: true,
|
25
52
|
requireProject: false,
|
26
53
|
})
|
27
54
|
const {token} = client.config()
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
const blueprintExtension = await prompt.single({
|
46
|
-
type: 'list',
|
47
|
-
message: 'Choose a Blueprint manifest file type:',
|
48
|
-
choices: [
|
49
|
-
{value: 'json', name: 'JSON (Recommended)'},
|
50
|
-
{value: 'js', name: 'JavaScript (Available soon)', disabled: true},
|
51
|
-
{value: 'ts', name: 'TypeScript (Available soon)', disabled: true},
|
52
|
-
],
|
55
|
+
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
56
|
+
|
57
|
+
const {blueprintInitCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
58
|
+
|
59
|
+
const {success, error} = await blueprintInitCore({
|
60
|
+
bin: 'sanity',
|
61
|
+
log: (message) => output.print(message),
|
62
|
+
token,
|
63
|
+
args: {
|
64
|
+
dir: dir ?? flags.dir,
|
65
|
+
},
|
66
|
+
flags: {
|
67
|
+
'blueprint-type': flags['blueprint-type'] ?? flags.type,
|
68
|
+
'project-id': flags['project-id'] ?? flags.projectId ?? flags.project,
|
69
|
+
'stack-id': flags['stack-id'] ?? flags.stackId ?? flags.stack,
|
70
|
+
'stack-name': flags['stack-name'] ?? flags.name,
|
71
|
+
},
|
53
72
|
})
|
54
73
|
|
55
|
-
|
56
|
-
|
57
|
-
if (!ok) {
|
58
|
-
print(error)
|
59
|
-
return
|
60
|
-
}
|
61
|
-
|
62
|
-
if (!projects || projects.length === 0) {
|
63
|
-
print('No Projects found. Please create a Project in Sanity.io first.')
|
64
|
-
return
|
65
|
-
}
|
66
|
-
|
67
|
-
const projectChoices = projects.map(({displayName, id}) => ({
|
68
|
-
value: id,
|
69
|
-
name: `${displayName} <${id}>`,
|
70
|
-
}))
|
71
|
-
|
72
|
-
const projectId = await prompt.single({
|
73
|
-
type: 'list',
|
74
|
-
message: 'Select your Sanity Project:',
|
75
|
-
choices: projectChoices,
|
76
|
-
})
|
77
|
-
|
78
|
-
const fileName = `blueprint.${blueprintExtension}`
|
79
|
-
const filePath = join(cwd(), fileName)
|
80
|
-
|
81
|
-
blueprintAction.writeBlueprintToDisk({
|
82
|
-
path: filePath,
|
83
|
-
fileType: blueprintExtension as 'json' | 'js' | 'ts',
|
84
|
-
})
|
85
|
-
|
86
|
-
blueprintAction.writeConfigFile({projectId})
|
87
|
-
|
88
|
-
print(`Created new blueprint: ./${fileName}`)
|
89
|
-
|
90
|
-
if (blueprintExtension === 'ts') {
|
91
|
-
print('\nNote: TypeScript support requires "tsx" to be installed. Run: npm install -D tsx')
|
92
|
-
}
|
74
|
+
if (!success) throw new Error(error)
|
93
75
|
},
|
94
76
|
}
|
95
77
|
|
@@ -1,110 +1,72 @@
|
|
1
1
|
import {type CliCommandDefinition} from '../../types'
|
2
2
|
|
3
3
|
const helpText = `
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
Examples
|
4
|
+
Options
|
5
|
+
--watch, -w Watch for new logs (streaming mode)
|
6
|
+
|
7
|
+
Examples:
|
10
8
|
# Show logs for the current Stack
|
11
9
|
sanity blueprints logs
|
12
|
-
|
13
|
-
|
14
|
-
# Watch for new logs
|
10
|
+
|
11
|
+
# Watch for new logs (streaming mode)
|
15
12
|
sanity blueprints logs --watch
|
16
|
-
*/ ''
|
17
|
-
}
|
18
13
|
`
|
19
14
|
|
20
|
-
|
15
|
+
export interface BlueprintsLogsFlags {
|
16
|
+
watch?: boolean
|
17
|
+
w?: boolean
|
18
|
+
}
|
21
19
|
|
22
|
-
const
|
20
|
+
const defaultFlags: BlueprintsLogsFlags = {
|
21
|
+
//
|
22
|
+
}
|
23
|
+
|
24
|
+
const logsBlueprintsCommand: CliCommandDefinition<BlueprintsLogsFlags> = {
|
23
25
|
name: 'logs',
|
24
26
|
group: 'blueprints',
|
25
27
|
helpText,
|
26
|
-
signature: '[--watch]',
|
28
|
+
signature: '[--watch] [-w]',
|
27
29
|
description: 'Display logs for the current Blueprint Stack',
|
28
|
-
|
30
|
+
|
29
31
|
async action(args, context) {
|
30
32
|
const {apiClient, output} = context
|
31
|
-
const
|
32
|
-
// const flags = {...defaultFlags, ...args.extOptions}
|
33
|
-
// const watchMode = Boolean(flags.watch)
|
33
|
+
const flags = {...defaultFlags, ...args.extOptions}
|
34
34
|
|
35
|
-
const client = apiClient({
|
35
|
+
const client = apiClient({
|
36
|
+
requireUser: true,
|
37
|
+
requireProject: false,
|
38
|
+
})
|
36
39
|
const {token} = client.config()
|
40
|
+
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
return
|
41
|
-
}
|
42
|
-
|
43
|
-
const {blueprint: blueprintAction, logs: logsAction} = await import(
|
44
|
-
'@sanity/runtime-cli/actions/blueprints'
|
45
|
-
)
|
42
|
+
const {blueprintLogsCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
43
|
+
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
46
44
|
const {display} = await import('@sanity/runtime-cli/utils')
|
47
45
|
|
48
|
-
|
49
|
-
try {
|
50
|
-
blueprint = await blueprintAction.readBlueprintOnDisk({token})
|
51
|
-
} catch (error) {
|
52
|
-
print('Unable to read Blueprint manifest file. Run `sanity blueprints init`')
|
53
|
-
return
|
54
|
-
}
|
46
|
+
const {localBlueprint, deployedStack, issues} = await getBlueprintAndStack({token})
|
55
47
|
|
56
|
-
if (
|
57
|
-
print(
|
58
|
-
|
48
|
+
if (issues) {
|
49
|
+
output.print(display.errors.presentBlueprintIssues(issues))
|
50
|
+
throw new Error('Unable to parse Blueprint file.')
|
59
51
|
}
|
60
52
|
|
61
|
-
const {
|
62
|
-
|
63
|
-
if (errors && errors.length > 0) {
|
64
|
-
print(errors)
|
65
|
-
return
|
66
|
-
}
|
53
|
+
const {projectId, stackId} = localBlueprint
|
54
|
+
const auth = {token, projectId}
|
67
55
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
56
|
+
const {success, streaming, error} = await blueprintLogsCore({
|
57
|
+
bin: 'sanity',
|
58
|
+
log: (message) => output.print(message),
|
59
|
+
auth,
|
60
|
+
stackId,
|
61
|
+
deployedStack,
|
62
|
+
flags: {
|
63
|
+
watch: flags.watch ?? flags.w,
|
64
|
+
},
|
65
|
+
})
|
72
66
|
|
73
|
-
|
74
|
-
const auth = {token, projectId}
|
67
|
+
if (streaming) await streaming
|
75
68
|
|
76
|
-
|
77
|
-
|
78
|
-
// enable watch mode here
|
79
|
-
|
80
|
-
try {
|
81
|
-
const {ok, logs, error} = await logsAction.getLogs(stackId, auth)
|
82
|
-
|
83
|
-
if (!ok) {
|
84
|
-
print(`${display.colors.red('Failed')} to retrieve logs`)
|
85
|
-
print(`Error: ${error || 'Unknown error'}`)
|
86
|
-
return
|
87
|
-
}
|
88
|
-
|
89
|
-
if (logs.length === 0) {
|
90
|
-
print(`No logs found for Stack ${stackId}`)
|
91
|
-
return
|
92
|
-
}
|
93
|
-
|
94
|
-
print(`${display.blueprintsFormatting.formatTitle('Blueprint', name)} Logs`)
|
95
|
-
print(
|
96
|
-
`Found ${display.colors.bold(logs.length.toString())} log entries for stack ${display.colors.yellow(stackId)}\n`,
|
97
|
-
)
|
98
|
-
|
99
|
-
// Organize and format logs by day
|
100
|
-
const logsByDay = display.logsFormatting.organizeLogsByDay(logs)
|
101
|
-
print(display.logsFormatting.formatLogsByDay(logsByDay))
|
102
|
-
} catch (err) {
|
103
|
-
print('Failed to retrieve logs')
|
104
|
-
if (err instanceof Error) {
|
105
|
-
print(`Error: ${err.message}`)
|
106
|
-
}
|
107
|
-
}
|
69
|
+
if (!success) throw new Error(error)
|
108
70
|
},
|
109
71
|
}
|
110
72
|
|
@@ -3,60 +3,50 @@ import {type CliCommandDefinition} from '../../types'
|
|
3
3
|
const helpText = `
|
4
4
|
Safe to run at any time. Will not modify any Resources.
|
5
5
|
|
6
|
-
Examples
|
7
|
-
# Show deployment plan
|
6
|
+
Examples:
|
7
|
+
# Show deployment plan for the current Blueprint
|
8
8
|
sanity blueprints plan
|
9
9
|
`
|
10
10
|
|
11
|
-
|
11
|
+
export interface BlueprintsPlanFlags {
|
12
|
+
//
|
13
|
+
}
|
14
|
+
|
15
|
+
const planBlueprintsCommand: CliCommandDefinition<BlueprintsPlanFlags> = {
|
12
16
|
name: 'plan',
|
13
17
|
group: 'blueprints',
|
14
18
|
helpText,
|
15
19
|
signature: '',
|
16
20
|
description: 'Enumerate Resources to be deployed',
|
17
|
-
|
21
|
+
|
18
22
|
async action(args, context) {
|
19
23
|
const {apiClient, output} = context
|
20
|
-
const {print} = output
|
21
24
|
|
22
|
-
const client = apiClient({
|
25
|
+
const client = apiClient({
|
26
|
+
requireUser: true,
|
27
|
+
requireProject: false,
|
28
|
+
})
|
23
29
|
const {token} = client.config()
|
24
|
-
|
25
|
-
const {display} = await import('@sanity/runtime-cli/utils')
|
26
|
-
|
27
|
-
let blueprint = null
|
28
|
-
try {
|
29
|
-
blueprint = await blueprintAction.readBlueprintOnDisk({token})
|
30
|
-
} catch (error) {
|
31
|
-
print('Unable to read Blueprint manifest file. Run `sanity blueprints init`')
|
32
|
-
return
|
33
|
-
}
|
30
|
+
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
32
|
+
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')
|
39
35
|
|
40
|
-
const {
|
36
|
+
const {localBlueprint, issues} = await getBlueprintAndStack({token})
|
41
37
|
|
42
|
-
if (
|
43
|
-
print
|
38
|
+
if (issues) {
|
39
|
+
// print issues and continue
|
40
|
+
output.print(display.errors.presentBlueprintIssues(issues))
|
44
41
|
}
|
45
42
|
|
46
|
-
const
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
// continue to show the plan
|
52
|
-
}
|
43
|
+
const {success, error} = await blueprintPlanCore({
|
44
|
+
bin: 'sanity',
|
45
|
+
log: (message) => output.print(message),
|
46
|
+
blueprint: localBlueprint,
|
47
|
+
})
|
53
48
|
|
54
|
-
|
55
|
-
print(`${display.blueprintsFormatting.formatTitle('Blueprint', name)} Plan\n`)
|
56
|
-
print(`Blueprint document: (${fileInfo.fileName})`)
|
57
|
-
print('')
|
58
|
-
print(display.blueprintsFormatting.formatResourceTree(resources))
|
59
|
-
print('\nRun `sanity blueprints deploy` to deploy these changes')
|
49
|
+
if (!success) throw new Error(error)
|
60
50
|
},
|
61
51
|
}
|
62
52
|
|
@@ -1,75 +1,67 @@
|
|
1
1
|
import {type CliCommandDefinition} from '../../types'
|
2
2
|
|
3
3
|
const helpText = `
|
4
|
-
|
4
|
+
Options
|
5
|
+
--project-id <id> Project ID to use
|
6
|
+
|
7
|
+
Examples:
|
5
8
|
# List all Stacks for the current Project
|
6
9
|
sanity blueprints stacks
|
10
|
+
|
11
|
+
# List Stacks for a specific project
|
12
|
+
sanity blueprints stacks --project-id abc123
|
7
13
|
`
|
8
14
|
|
9
|
-
|
15
|
+
export interface BlueprintsStacksFlags {
|
16
|
+
'project-id'?: string
|
17
|
+
'projectId'?: string
|
18
|
+
'project'?: string
|
19
|
+
}
|
20
|
+
|
21
|
+
const defaultFlags: BlueprintsStacksFlags = {
|
22
|
+
//
|
23
|
+
}
|
24
|
+
|
25
|
+
const stacksBlueprintsCommand: CliCommandDefinition<BlueprintsStacksFlags> = {
|
10
26
|
name: 'stacks',
|
11
27
|
group: 'blueprints',
|
12
28
|
helpText,
|
13
|
-
signature: '',
|
29
|
+
signature: '[--project-id <id>]',
|
14
30
|
description: 'List all Blueprint Stacks for the current Project',
|
15
|
-
|
31
|
+
|
16
32
|
async action(args, context) {
|
17
33
|
const {apiClient, output} = context
|
18
|
-
const
|
19
|
-
const client = apiClient({requireUser: true, requireProject: false})
|
20
|
-
const {token} = client.config()
|
34
|
+
const flags = {...defaultFlags, ...args.extOptions}
|
21
35
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
36
|
+
const client = apiClient({
|
37
|
+
requireUser: true,
|
38
|
+
requireProject: false,
|
39
|
+
})
|
40
|
+
const {token} = client.config()
|
41
|
+
if (!token) throw new Error('No API token found. Please run `sanity login`.')
|
26
42
|
|
27
|
-
const {
|
28
|
-
|
29
|
-
)
|
43
|
+
const {blueprintStacksCore} = await import('@sanity/runtime-cli/cores/blueprints')
|
44
|
+
const {getBlueprintAndStack} = await import('@sanity/runtime-cli/actions/blueprints')
|
30
45
|
const {display} = await import('@sanity/runtime-cli/utils')
|
31
46
|
|
32
|
-
|
33
|
-
try {
|
34
|
-
blueprint = await blueprintAction.readBlueprintOnDisk({token})
|
35
|
-
} catch (error) {
|
36
|
-
print('Unable to read Blueprint manifest file. Run `sanity blueprints init`')
|
37
|
-
return
|
38
|
-
}
|
39
|
-
|
40
|
-
if (!blueprint) {
|
41
|
-
print('Unable to read Blueprint manifest file. Run `sanity blueprints init`')
|
42
|
-
return
|
43
|
-
}
|
44
|
-
|
45
|
-
const {errors, projectId, stackId} = blueprint
|
46
|
-
|
47
|
-
if (errors && errors.length > 0) {
|
48
|
-
print(errors)
|
49
|
-
return
|
50
|
-
}
|
47
|
+
const {localBlueprint, issues} = await getBlueprintAndStack({token})
|
51
48
|
|
52
|
-
if (
|
53
|
-
print
|
54
|
-
|
49
|
+
if (issues) {
|
50
|
+
// print issues and continue
|
51
|
+
output.print(display.errors.presentBlueprintIssues(issues))
|
55
52
|
}
|
56
53
|
|
57
|
-
const
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
print('No Stacks found')
|
67
|
-
return
|
68
|
-
}
|
54
|
+
const {success, error} = await blueprintStacksCore({
|
55
|
+
bin: 'sanity',
|
56
|
+
log: (message) => output.print(message),
|
57
|
+
token,
|
58
|
+
blueprint: localBlueprint,
|
59
|
+
flags: {
|
60
|
+
projectId: flags['project-id'] ?? flags.projectId ?? flags.project,
|
61
|
+
},
|
62
|
+
})
|
69
63
|
|
70
|
-
|
71
|
-
print(`${bold('Project')} <${yellow(projectId)}> ${bold('Stacks')}:\n`)
|
72
|
-
print(display.blueprintsFormatting.formatStacksListing(stacks, stackId))
|
64
|
+
if (!success) throw new Error(error)
|
73
65
|
},
|
74
66
|
}
|
75
67
|
|
@@ -22,9 +22,8 @@ const devFunctionsCommand: CliCommandDefinition = {
|
|
22
22
|
name: 'dev',
|
23
23
|
group: 'functions',
|
24
24
|
helpText,
|
25
|
-
signature: '',
|
25
|
+
signature: '[--port <port>]',
|
26
26
|
description: 'Start the Sanity Function emulator',
|
27
|
-
hideFromHelp: true,
|
28
27
|
async action(args, context) {
|
29
28
|
const {output} = context
|
30
29
|
const {print} = output
|