@sanity/cli 3.79.1-media-library.124 → 3.79.1-media-library.102
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 +88 -92
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/index.d.mts +2 -2
- package/lib/index.d.ts +2 -2
- package/package.json +5 -5
- package/src/actions/init-project/bootstrapLocalTemplate.ts +10 -10
- package/src/actions/init-project/{createCoreAppCliConfig.ts → createAppCliConfig.ts} +4 -4
- package/src/actions/init-project/{determineCoreAppTemplate.ts → determineAppTemplate.ts} +3 -3
- package/src/actions/init-project/initProject.ts +8 -8
- package/src/actions/init-project/templates/{coreApp.ts → appQuickstart.ts} +4 -4
- package/src/actions/init-project/templates/index.ts +2 -2
- package/src/types.ts +2 -2
- package/templates/core-app/src/App.tsx +2 -2
package/lib/index.d.mts
CHANGED
@@ -119,8 +119,8 @@ export declare interface CliConfig {
|
|
119
119
|
* Signals to `sanity` commands that this is not a studio.
|
120
120
|
* @internal
|
121
121
|
*/
|
122
|
-
|
123
|
-
organizationId
|
122
|
+
__experimental_appConfiguration?: {
|
123
|
+
organizationId: string
|
124
124
|
appLocation?: string
|
125
125
|
appId?: string
|
126
126
|
}
|
package/lib/index.d.ts
CHANGED
@@ -119,8 +119,8 @@ export declare interface CliConfig {
|
|
119
119
|
* Signals to `sanity` commands that this is not a studio.
|
120
120
|
* @internal
|
121
121
|
*/
|
122
|
-
|
123
|
-
organizationId
|
122
|
+
__experimental_appConfiguration?: {
|
123
|
+
organizationId: string
|
124
124
|
appLocation?: string
|
125
125
|
appId?: string
|
126
126
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sanity/cli",
|
3
|
-
"version": "3.79.1-media-library.
|
3
|
+
"version": "3.79.1-media-library.102+d49d33b27d",
|
4
4
|
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
|
5
5
|
"keywords": [
|
6
6
|
"sanity",
|
@@ -58,11 +58,11 @@
|
|
58
58
|
"dependencies": {
|
59
59
|
"@babel/traverse": "^7.23.5",
|
60
60
|
"@sanity/client": "^6.28.3",
|
61
|
-
"@sanity/codegen": "3.79.1-media-library.
|
61
|
+
"@sanity/codegen": "3.79.1-media-library.102+d49d33b27d",
|
62
62
|
"@sanity/runtime-cli": "^1.1.1",
|
63
63
|
"@sanity/telemetry": "^0.7.7",
|
64
64
|
"@sanity/template-validator": "^2.4.0",
|
65
|
-
"@sanity/util": "3.79.1-media-library.
|
65
|
+
"@sanity/util": "3.79.1-media-library.102+d49d33b27d",
|
66
66
|
"chalk": "^4.1.2",
|
67
67
|
"debug": "^4.3.4",
|
68
68
|
"decompress": "^4.2.0",
|
@@ -82,7 +82,7 @@
|
|
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.79.1-media-library.
|
85
|
+
"@sanity/types": "3.79.1-media-library.102+d49d33b27d",
|
86
86
|
"@types/babel__traverse": "^7.20.5",
|
87
87
|
"@types/configstore": "^5.0.1",
|
88
88
|
"@types/cpx": "^1.5.2",
|
@@ -134,5 +134,5 @@
|
|
134
134
|
"engines": {
|
135
135
|
"node": ">=18"
|
136
136
|
},
|
137
|
-
"gitHead": "
|
137
|
+
"gitHead": "d49d33b27dce72cece4a4e25238316764fd6ca31"
|
138
138
|
}
|
@@ -9,11 +9,11 @@ import {type CliCommandContext} from '../../types'
|
|
9
9
|
import {copy} from '../../util/copy'
|
10
10
|
import {getAndWriteJourneySchemaWorker} from '../../util/journeyConfig'
|
11
11
|
import {resolveLatestVersions} from '../../util/resolveLatestVersions'
|
12
|
+
import {createAppCliConfig} from './createAppCliConfig'
|
12
13
|
import {createCliConfig} from './createCliConfig'
|
13
|
-
import {createCoreAppCliConfig} from './createCoreAppCliConfig'
|
14
14
|
import {createPackageManifest} from './createPackageManifest'
|
15
15
|
import {createStudioConfig, type GenerateConfigOptions} from './createStudioConfig'
|
16
|
-
import {
|
16
|
+
import {determineAppTemplate} from './determineAppTemplate'
|
17
17
|
import {type ProjectTemplate} from './initProject'
|
18
18
|
import templates from './templates'
|
19
19
|
import {updateInitialTemplateMetadata} from './updateInitialTemplateMetadata'
|
@@ -40,7 +40,7 @@ export async function bootstrapLocalTemplate(
|
|
40
40
|
const {outputPath, templateName, useTypeScript, packageName, variables} = opts
|
41
41
|
const sourceDir = path.join(templatesDir, templateName)
|
42
42
|
const sharedDir = path.join(templatesDir, 'shared')
|
43
|
-
const
|
43
|
+
const isAppTemplate = determineAppTemplate(templateName)
|
44
44
|
|
45
45
|
// Check that we have a template info file (dependencies, plugins etc)
|
46
46
|
const template = templates[templateName]
|
@@ -83,8 +83,8 @@ export async function bootstrapLocalTemplate(
|
|
83
83
|
// Resolve latest versions of Sanity-dependencies
|
84
84
|
spinner = output.spinner('Resolving latest module versions').start()
|
85
85
|
const dependencyVersions = await resolveLatestVersions({
|
86
|
-
...(
|
87
|
-
...(
|
86
|
+
...(isAppTemplate ? {} : studioDependencies.dependencies),
|
87
|
+
...(isAppTemplate ? {} : studioDependencies.devDependencies),
|
88
88
|
...(template.dependencies || {}),
|
89
89
|
...(template.devDependencies || {}),
|
90
90
|
})
|
@@ -92,7 +92,7 @@ export async function bootstrapLocalTemplate(
|
|
92
92
|
|
93
93
|
// Use the resolved version for the given dependency
|
94
94
|
const dependencies = Object.keys({
|
95
|
-
...(
|
95
|
+
...(isAppTemplate ? {} : studioDependencies.dependencies),
|
96
96
|
...template.dependencies,
|
97
97
|
}).reduce(
|
98
98
|
(deps, dependency) => {
|
@@ -103,7 +103,7 @@ export async function bootstrapLocalTemplate(
|
|
103
103
|
)
|
104
104
|
|
105
105
|
const devDependencies = Object.keys({
|
106
|
-
...(
|
106
|
+
...(isAppTemplate ? {} : studioDependencies.devDependencies),
|
107
107
|
...template.devDependencies,
|
108
108
|
}).reduce(
|
109
109
|
(deps, dependency) => {
|
@@ -129,8 +129,8 @@ export async function bootstrapLocalTemplate(
|
|
129
129
|
})
|
130
130
|
|
131
131
|
// ...and a CLI config (`sanity.cli.[ts|js]`)
|
132
|
-
const cliConfig =
|
133
|
-
?
|
132
|
+
const cliConfig = isAppTemplate
|
133
|
+
? createAppCliConfig({
|
134
134
|
appLocation: template.appLocation!,
|
135
135
|
organizationId: variables.organizationId,
|
136
136
|
})
|
@@ -145,7 +145,7 @@ export async function bootstrapLocalTemplate(
|
|
145
145
|
await Promise.all(
|
146
146
|
[
|
147
147
|
...[
|
148
|
-
|
148
|
+
isAppTemplate
|
149
149
|
? Promise.resolve(null)
|
150
150
|
: writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),
|
151
151
|
],
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import {processTemplate} from './processTemplate'
|
2
2
|
|
3
|
-
const
|
3
|
+
const defaultAppTemplate = `
|
4
4
|
import {defineCliConfig} from 'sanity/cli'
|
5
5
|
|
6
6
|
export default defineCliConfig({
|
7
|
-
|
7
|
+
__experimental_appConfiguration: {
|
8
8
|
organizationId: '%organizationId%',
|
9
9
|
appLocation: '%appLocation%',
|
10
10
|
},
|
@@ -16,9 +16,9 @@ export interface GenerateCliConfigOptions {
|
|
16
16
|
appLocation: string
|
17
17
|
}
|
18
18
|
|
19
|
-
export function
|
19
|
+
export function createAppCliConfig(options: GenerateCliConfigOptions): string {
|
20
20
|
return processTemplate({
|
21
|
-
template:
|
21
|
+
template: defaultAppTemplate,
|
22
22
|
variables: options,
|
23
23
|
})
|
24
24
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
const
|
1
|
+
const appTemplates = ['app-quickstart']
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Determine if a given template is a studio template.
|
@@ -8,6 +8,6 @@ const coreAppTemplates = ['core-app']
|
|
8
8
|
* @param templateName - Name of the template
|
9
9
|
* @returns boolean indicating if the template is a studio template
|
10
10
|
*/
|
11
|
-
export function
|
12
|
-
return
|
11
|
+
export function determineAppTemplate(templateName: string): boolean {
|
12
|
+
return appTemplates.includes(templateName)
|
13
13
|
}
|
@@ -49,7 +49,7 @@ import {createProject} from '../project/createProject'
|
|
49
49
|
import {bootstrapLocalTemplate} from './bootstrapLocalTemplate'
|
50
50
|
import {bootstrapRemoteTemplate} from './bootstrapRemoteTemplate'
|
51
51
|
import {type GenerateConfigOptions} from './createStudioConfig'
|
52
|
-
import {
|
52
|
+
import {determineAppTemplate} from './determineAppTemplate'
|
53
53
|
import {absolutify, validateEmptyPath} from './fsUtils'
|
54
54
|
import {tryGitInit} from './git'
|
55
55
|
import {promptForDatasetName} from './promptForDatasetName'
|
@@ -278,14 +278,14 @@ export default async function initSanity(
|
|
278
278
|
}
|
279
279
|
|
280
280
|
// skip project / dataset prompting
|
281
|
-
const
|
281
|
+
const isAppTemplate = cliFlags.template ? determineAppTemplate(cliFlags.template) : false // Default to false
|
282
282
|
|
283
283
|
let introMessage = 'Fetching existing projects'
|
284
284
|
if (cliFlags.quickstart) {
|
285
285
|
introMessage = "Eject your existing project's Sanity configuration"
|
286
286
|
}
|
287
287
|
|
288
|
-
if (!
|
288
|
+
if (!isAppTemplate) {
|
289
289
|
success(introMessage)
|
290
290
|
print('')
|
291
291
|
}
|
@@ -678,13 +678,13 @@ export default async function initSanity(
|
|
678
678
|
if (isCurrentDir) {
|
679
679
|
print(`\n${chalk.green('Success!')} Now, use this command to continue:\n`)
|
680
680
|
print(
|
681
|
-
`${chalk.cyan(devCommand)} - to run ${
|
681
|
+
`${chalk.cyan(devCommand)} - to run ${isAppTemplate ? 'your Sanity application' : 'Sanity Studio'}\n`,
|
682
682
|
)
|
683
683
|
} else {
|
684
684
|
print(`\n${chalk.green('Success!')} Now, use these commands to continue:\n`)
|
685
685
|
print(`First: ${chalk.cyan(`cd ${outputPath}`)} - to enter project’s directory`)
|
686
686
|
print(
|
687
|
-
`Then: ${chalk.cyan(devCommand)} -to run ${
|
687
|
+
`Then: ${chalk.cyan(devCommand)} -to run ${isAppTemplate ? 'your Sanity application' : 'Sanity Studio'}\n`,
|
688
688
|
)
|
689
689
|
}
|
690
690
|
|
@@ -748,18 +748,18 @@ export default async function initSanity(
|
|
748
748
|
return data
|
749
749
|
}
|
750
750
|
|
751
|
-
if (
|
751
|
+
if (isAppTemplate) {
|
752
752
|
const client = apiClient({requireUser: true, requireProject: false})
|
753
753
|
const organizations = await client.request({uri: '/organizations'})
|
754
754
|
|
755
|
-
const
|
755
|
+
const appOrganizationId = await getOrganizationId(organizations)
|
756
756
|
|
757
757
|
return {
|
758
758
|
projectId: '',
|
759
759
|
displayName: '',
|
760
760
|
datasetName: '',
|
761
761
|
isFirstProject: false,
|
762
|
-
organizationId:
|
762
|
+
organizationId: appOrganizationId,
|
763
763
|
}
|
764
764
|
}
|
765
765
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import {type ProjectTemplate} from '../initProject'
|
2
2
|
|
3
|
-
const
|
3
|
+
const appTemplate: ProjectTemplate = {
|
4
4
|
dependencies: {
|
5
|
-
'@sanity/sdk': '^0.0.0-
|
6
|
-
'@sanity/sdk-react': '^0.0.0-
|
5
|
+
'@sanity/sdk': '^0.0.0-rc',
|
6
|
+
'@sanity/sdk-react': '^0.0.0-rc',
|
7
7
|
'react': '^19',
|
8
8
|
'react-dom': '^19',
|
9
9
|
},
|
@@ -27,4 +27,4 @@ const coreAppTemplate: ProjectTemplate = {
|
|
27
27
|
},
|
28
28
|
}
|
29
29
|
|
30
|
-
export default
|
30
|
+
export default appTemplate
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import {type ProjectTemplate} from '../initProject'
|
2
|
+
import appTemplate from './appQuickstart'
|
2
3
|
import blog from './blog'
|
3
4
|
import clean from './clean'
|
4
|
-
import coreAppTemplate from './coreApp'
|
5
5
|
import getStartedTemplate from './getStarted'
|
6
6
|
import moviedb from './moviedb'
|
7
7
|
import quickstart from './quickstart'
|
@@ -11,7 +11,7 @@ import shopifyOnline from './shopifyOnline'
|
|
11
11
|
const templates: Record<string, ProjectTemplate | undefined> = {
|
12
12
|
blog,
|
13
13
|
clean,
|
14
|
-
'
|
14
|
+
'app-quickstart': appTemplate,
|
15
15
|
'get-started': getStartedTemplate,
|
16
16
|
moviedb,
|
17
17
|
shopify,
|
package/src/types.ts
CHANGED
@@ -351,8 +351,8 @@ export interface CliConfig {
|
|
351
351
|
* Signals to `sanity` commands that this is not a studio.
|
352
352
|
* @internal
|
353
353
|
*/
|
354
|
-
|
355
|
-
organizationId
|
354
|
+
__experimental_appConfiguration?: {
|
355
|
+
organizationId: string
|
356
356
|
appLocation?: string
|
357
357
|
appId?: string
|
358
358
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import {type SanityConfig} from '@sanity/sdk'
|
2
|
-
import {SanityApp} from '@sanity/sdk-react
|
2
|
+
import {SanityApp} from '@sanity/sdk-react'
|
3
3
|
import {ExampleComponent} from './ExampleComponent'
|
4
4
|
import './App.css'
|
5
5
|
|
@@ -14,7 +14,7 @@ export function App() {
|
|
14
14
|
|
15
15
|
return (
|
16
16
|
<div className="app-container">
|
17
|
-
<SanityApp sanityConfigs={sanityConfigs}>
|
17
|
+
<SanityApp sanityConfigs={sanityConfigs} fallback={<div>Loading...</div>}>
|
18
18
|
{/* add your own components here! */}
|
19
19
|
<ExampleComponent />
|
20
20
|
</SanityApp>
|