@sanity/cli 3.86.0 → 3.86.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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.86.
|
3
|
+
"version": "3.86.1",
|
4
4
|
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
|
5
5
|
"keywords": [
|
6
6
|
"sanity",
|
@@ -59,11 +59,11 @@
|
|
59
59
|
"dependencies": {
|
60
60
|
"@babel/traverse": "^7.23.5",
|
61
61
|
"@sanity/client": "^6.29.0",
|
62
|
-
"@sanity/codegen": "3.86.
|
62
|
+
"@sanity/codegen": "3.86.1",
|
63
63
|
"@sanity/runtime-cli": "^3.0.0",
|
64
64
|
"@sanity/telemetry": "^0.8.0",
|
65
65
|
"@sanity/template-validator": "^2.4.3",
|
66
|
-
"@sanity/util": "3.86.
|
66
|
+
"@sanity/util": "3.86.1",
|
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": "
|
81
|
-
"@repo/test-config": "
|
80
|
+
"@repo/package.config": "0.0.0",
|
81
|
+
"@repo/test-config": "0.0.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.
|
86
|
+
"@sanity/types": "3.86.1",
|
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": "9b19a1ca740b0a62231d80d6e9daaa8651478d39"
|
139
139
|
}
|
@@ -5,25 +5,25 @@ import {type CliCommandDefinition} from '../../types'
|
|
5
5
|
type StackFunctionResource = types.StackFunctionResource
|
6
6
|
|
7
7
|
const helpText = `
|
8
|
+
Arguments
|
9
|
+
[add] Add or update an environment variable
|
10
|
+
[remove] Remove an environment variable
|
11
|
+
|
8
12
|
Options
|
9
13
|
--name <name> The name of the function
|
10
|
-
--add Add or update an environment variable
|
11
|
-
--remove Remove an environment variable
|
12
14
|
--key <key> The name of the environment variable
|
13
15
|
--value <value> The value of the environment variable
|
14
16
|
|
15
17
|
Examples
|
16
18
|
# Add or update an environment variable
|
17
|
-
sanity functions env --name echo --
|
19
|
+
sanity functions env add --name echo --key API_URL --value https://api.example.com/
|
18
20
|
|
19
21
|
# Remove an environment variable
|
20
|
-
sanity functions env --name echo --
|
22
|
+
sanity functions env remove --name echo --key API_URL
|
21
23
|
`
|
22
24
|
|
23
25
|
const defaultFlags = {
|
24
26
|
name: '',
|
25
|
-
add: false,
|
26
|
-
remove: false,
|
27
27
|
key: '',
|
28
28
|
value: '',
|
29
29
|
}
|
@@ -38,16 +38,20 @@ const envFunctionsCommand: CliCommandDefinition = {
|
|
38
38
|
async action(args, context) {
|
39
39
|
const {apiClient, output} = context
|
40
40
|
const {print} = output
|
41
|
+
const [subCommand] = args.argsWithoutOptions
|
41
42
|
const flags = {...defaultFlags, ...args.extOptions}
|
42
43
|
|
44
|
+
if (!subCommand || !['add', 'remove'].includes(subCommand)) {
|
45
|
+
throw new Error('You must specify if you wish to add or remove an environment variable')
|
46
|
+
}
|
47
|
+
|
43
48
|
const client = apiClient({
|
44
49
|
requireUser: true,
|
45
50
|
requireProject: false,
|
46
51
|
})
|
47
52
|
|
48
53
|
if (flags.name === '') {
|
49
|
-
|
50
|
-
return
|
54
|
+
throw new Error('You must provide a function name via the --name flag')
|
51
55
|
}
|
52
56
|
|
53
57
|
const token = client.config().token
|
@@ -61,8 +65,7 @@ const envFunctionsCommand: CliCommandDefinition = {
|
|
61
65
|
})
|
62
66
|
|
63
67
|
if (!deployedStack) {
|
64
|
-
|
65
|
-
return
|
68
|
+
throw new Error('Stack not found')
|
66
69
|
}
|
67
70
|
|
68
71
|
const blueprintConfig = blueprint.readConfigFile()
|
@@ -74,7 +77,7 @@ const envFunctionsCommand: CliCommandDefinition = {
|
|
74
77
|
) as StackFunctionResource
|
75
78
|
|
76
79
|
if (token && projectId) {
|
77
|
-
if (
|
80
|
+
if (subCommand === 'add') {
|
78
81
|
print(`Updating "${flags.key}" environment variable in "${flags.name}"`)
|
79
82
|
const result = await env.update.update(externalId, flags.key, flags.value, {
|
80
83
|
token,
|
@@ -86,7 +89,7 @@ const envFunctionsCommand: CliCommandDefinition = {
|
|
86
89
|
print(`Failed to update ${flags.key}`)
|
87
90
|
print(`Error: ${result.error || 'Unknown error'}`)
|
88
91
|
}
|
89
|
-
} else if (
|
92
|
+
} else if (subCommand === 'remove') {
|
90
93
|
print(`Removing "${flags.key}" environment variable in "${flags.name}"`)
|
91
94
|
const result = await env.remove.remove(externalId, flags.key, {
|
92
95
|
token,
|
@@ -7,8 +7,9 @@ type StackFunctionResource = types.StackFunctionResource
|
|
7
7
|
const helpText = `
|
8
8
|
Options
|
9
9
|
--name <name> The name of the function to retrieve logs for
|
10
|
-
--limit <limit> The number of log entries to retrieve
|
10
|
+
--limit <limit> The number of log entries to retrieve [default 50]
|
11
11
|
--json If set return json
|
12
|
+
--utc Use UTC dates in logs
|
12
13
|
|
13
14
|
Examples
|
14
15
|
# Retrieve logs for Sanity Function abcd1234
|
@@ -25,6 +26,7 @@ const defaultFlags = {
|
|
25
26
|
name: '',
|
26
27
|
limit: 50,
|
27
28
|
json: false,
|
29
|
+
utc: false,
|
28
30
|
}
|
29
31
|
|
30
32
|
const logsFunctionsCommand: CliCommandDefinition = {
|
@@ -45,8 +47,7 @@ const logsFunctionsCommand: CliCommandDefinition = {
|
|
45
47
|
})
|
46
48
|
|
47
49
|
if (flags.name === '') {
|
48
|
-
|
49
|
-
return
|
50
|
+
throw new Error('You must provide a function name via the --name flag')
|
50
51
|
}
|
51
52
|
|
52
53
|
const token = client.config().token
|
@@ -59,8 +60,7 @@ const logsFunctionsCommand: CliCommandDefinition = {
|
|
59
60
|
})
|
60
61
|
|
61
62
|
if (!deployedStack) {
|
62
|
-
|
63
|
-
return
|
63
|
+
throw new Error('Stack not found')
|
64
64
|
}
|
65
65
|
|
66
66
|
const blueprintConfig = blueprint.readConfigFile()
|
@@ -105,7 +105,10 @@ const logsFunctionsCommand: CliCommandDefinition = {
|
|
105
105
|
for (const log of filteredLogs) {
|
106
106
|
const {time, level, message} = log
|
107
107
|
const date = new Date(time)
|
108
|
-
|
108
|
+
const dateString = flags.utc
|
109
|
+
? date.toISOString().slice(0, 19).split('T').join(' ')
|
110
|
+
: `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
|
111
|
+
print(`${dateString} ${level} ${message}`)
|
109
112
|
}
|
110
113
|
}
|
111
114
|
} else {
|
@@ -38,8 +38,7 @@ const testFunctionsCommand: CliCommandDefinition = {
|
|
38
38
|
const flags = {...defaultFlags, ...args.extOptions}
|
39
39
|
|
40
40
|
if (flags.name === '') {
|
41
|
-
|
42
|
-
return
|
41
|
+
throw new Error('You must provide a function name via the --name flag')
|
43
42
|
}
|
44
43
|
|
45
44
|
const {test} = await import('@sanity/runtime-cli/actions/functions')
|
@@ -52,7 +51,7 @@ const testFunctionsCommand: CliCommandDefinition = {
|
|
52
51
|
|
53
52
|
const src = findFunction.getFunctionSource(parsedBlueprint, flags.name)
|
54
53
|
if (!src) {
|
55
|
-
|
54
|
+
throw new Error(`Error: Function ${flags.name} has no source code`)
|
56
55
|
}
|
57
56
|
|
58
57
|
const {json, logs, error} = await test.testAction(
|