@sanity/cli 3.57.2 → 3.57.4-memoized-form-state.18
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 +393 -391
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +6 -6
- package/src/actions/init-project/bootstrapTemplate.ts +1 -0
- package/src/actions/init-project/createCliConfig.ts +33 -4
- package/src/actions/init-project/createStudioConfig.ts +7 -2
- package/src/actions/init-project/initProject.ts +7 -0
- package/src/commands/init/initCommand.ts +2 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.57.
|
3
|
+
"version": "3.57.4-memoized-form-state.18+199df15e4c",
|
4
4
|
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
|
5
5
|
"keywords": [
|
6
6
|
"sanity",
|
@@ -58,9 +58,9 @@
|
|
58
58
|
"dependencies": {
|
59
59
|
"@babel/traverse": "^7.23.5",
|
60
60
|
"@sanity/client": "^6.21.3",
|
61
|
-
"@sanity/codegen": "3.57.
|
61
|
+
"@sanity/codegen": "3.57.4-memoized-form-state.18+199df15e4c",
|
62
62
|
"@sanity/telemetry": "^0.7.7",
|
63
|
-
"@sanity/util": "3.57.
|
63
|
+
"@sanity/util": "3.57.4-memoized-form-state.18+199df15e4c",
|
64
64
|
"chalk": "^4.1.2",
|
65
65
|
"debug": "^4.3.4",
|
66
66
|
"decompress": "^4.2.0",
|
@@ -77,12 +77,12 @@
|
|
77
77
|
},
|
78
78
|
"devDependencies": {
|
79
79
|
"@jest/globals": "^29.7.0",
|
80
|
-
"@repo/package.config": "3.57.
|
80
|
+
"@repo/package.config": "3.57.3",
|
81
81
|
"@rexxars/gitconfiglocal": "^3.0.1",
|
82
82
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
83
83
|
"@sanity/eslint-config-studio": "^4.0.0",
|
84
84
|
"@sanity/generate-help-url": "^3.0.0",
|
85
|
-
"@sanity/types": "3.57.
|
85
|
+
"@sanity/types": "3.57.4-memoized-form-state.18+199df15e4c",
|
86
86
|
"@types/babel__traverse": "^7.20.5",
|
87
87
|
"@types/configstore": "^5.0.1",
|
88
88
|
"@types/cpx": "^1.5.2",
|
@@ -135,5 +135,5 @@
|
|
135
135
|
"engines": {
|
136
136
|
"node": ">=18"
|
137
137
|
},
|
138
|
-
"gitHead": "
|
138
|
+
"gitHead": "199df15e4c7b3887daa1f3a122a44cbd1e4e6fc2"
|
139
139
|
}
|
@@ -9,19 +9,26 @@ export default defineCliConfig({
|
|
9
9
|
api: {
|
10
10
|
projectId: '%projectId%',
|
11
11
|
dataset: '%dataset%'
|
12
|
-
}
|
12
|
+
},
|
13
|
+
/**
|
14
|
+
* Enable auto-updates for studios.
|
15
|
+
* Learn more at https://www.sanity.io/docs/cli#auto-updates
|
16
|
+
*/
|
17
|
+
autoUpdates: __BOOL__autoUpdates__,
|
13
18
|
})
|
14
19
|
`
|
15
20
|
|
16
21
|
export interface GenerateCliConfigOptions {
|
17
22
|
projectId: string
|
18
23
|
dataset: string
|
24
|
+
autoUpdates: boolean
|
19
25
|
}
|
20
26
|
|
21
27
|
export function createCliConfig(options: GenerateCliConfigOptions): string {
|
22
28
|
const variables = options
|
23
29
|
const template = defaultTemplate.trimStart()
|
24
30
|
const ast = parse(template, {parser})
|
31
|
+
|
25
32
|
traverse(ast, {
|
26
33
|
StringLiteral: {
|
27
34
|
enter({node}) {
|
@@ -29,13 +36,35 @@ export function createCliConfig(options: GenerateCliConfigOptions): string {
|
|
29
36
|
if (!value.startsWith('%') || !value.endsWith('%')) {
|
30
37
|
return
|
31
38
|
}
|
32
|
-
|
33
39
|
const variableName = value.slice(1, -1) as keyof GenerateCliConfigOptions
|
34
40
|
if (!(variableName in variables)) {
|
35
41
|
throw new Error(`Template variable '${value}' not defined`)
|
36
42
|
}
|
37
|
-
|
38
|
-
|
43
|
+
const newValue = variables[variableName]
|
44
|
+
/*
|
45
|
+
* although there are valid non-strings in our config,
|
46
|
+
* they're not in StringLiteral nodes, so assume undefined
|
47
|
+
*/
|
48
|
+
node.value = typeof newValue === 'string' ? newValue : ''
|
49
|
+
},
|
50
|
+
},
|
51
|
+
Identifier: {
|
52
|
+
enter(path) {
|
53
|
+
if (!path.node.name.startsWith('__BOOL__')) {
|
54
|
+
return
|
55
|
+
}
|
56
|
+
const variableName = path.node.name.replace(
|
57
|
+
/^__BOOL__(.+?)__$/,
|
58
|
+
'$1',
|
59
|
+
) as keyof GenerateCliConfigOptions
|
60
|
+
if (!(variableName in variables)) {
|
61
|
+
throw new Error(`Template variable '${variableName}' not defined`)
|
62
|
+
}
|
63
|
+
const value = variables[variableName]
|
64
|
+
if (typeof value !== 'boolean') {
|
65
|
+
throw new Error(`Expected boolean value for '${variableName}'`)
|
66
|
+
}
|
67
|
+
path.replaceWith({type: 'BooleanLiteral', value})
|
39
68
|
},
|
40
69
|
},
|
41
70
|
})
|
@@ -34,6 +34,7 @@ export interface GenerateConfigOptions {
|
|
34
34
|
variables: {
|
35
35
|
projectId: string
|
36
36
|
dataset: string
|
37
|
+
autoUpdates: boolean
|
37
38
|
projectName?: string
|
38
39
|
sourceName?: string
|
39
40
|
sourceTitle?: string
|
@@ -60,8 +61,12 @@ export function createStudioConfig(options: GenerateConfigOptions): string {
|
|
60
61
|
if (!(variableName in variables)) {
|
61
62
|
throw new Error(`Template variable '${value}' not defined`)
|
62
63
|
}
|
63
|
-
|
64
|
-
|
64
|
+
const newValue = variables[variableName]
|
65
|
+
/*
|
66
|
+
* although there are valid non-strings in our config,
|
67
|
+
* they're not in this template, so assume undefined
|
68
|
+
*/
|
69
|
+
node.value = typeof newValue === 'string' ? newValue : ''
|
65
70
|
},
|
66
71
|
},
|
67
72
|
})
|
@@ -567,6 +567,12 @@ export default async function initSanity(
|
|
567
567
|
trace.log({step: 'useTypeScript', selectedOption: useTypeScript ? 'yes' : 'no'})
|
568
568
|
}
|
569
569
|
|
570
|
+
// we enable auto-updates by default, but allow users to specify otherwise
|
571
|
+
let autoUpdates = true
|
572
|
+
if (typeof cliFlags['auto-updates'] === 'boolean') {
|
573
|
+
autoUpdates = cliFlags['auto-updates']
|
574
|
+
}
|
575
|
+
|
570
576
|
// Build a full set of resolved options
|
571
577
|
const templateOptions: BootstrapOptions = {
|
572
578
|
outputPath,
|
@@ -575,6 +581,7 @@ export default async function initSanity(
|
|
575
581
|
schemaUrl,
|
576
582
|
useTypeScript,
|
577
583
|
variables: {
|
584
|
+
autoUpdates,
|
578
585
|
dataset: datasetName,
|
579
586
|
projectId,
|
580
587
|
projectName: displayName || answers.projectName,
|
@@ -27,6 +27,7 @@ Options
|
|
27
27
|
--coupon <name> Optionally select a coupon for a new project (cannot be used with --project-plan)
|
28
28
|
--no-typescript Do not use TypeScript for template files
|
29
29
|
--package-manager <name> Specify which package manager to use [allowed: ${allowedPackageManagersString}]
|
30
|
+
--no-auto-updates Disable auto updates of studio versions
|
30
31
|
|
31
32
|
Examples
|
32
33
|
# Initialize a new project, prompt for required information along the way
|
@@ -60,6 +61,7 @@ export interface InitFlags {
|
|
60
61
|
|
61
62
|
'visibility'?: string
|
62
63
|
'typescript'?: boolean
|
64
|
+
'auto-updates'?: boolean
|
63
65
|
/**
|
64
66
|
* Used for initializing a project from a server schema that is saved in the Journey API
|
65
67
|
* Overrides `project` option.
|