Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/studio manifests cont #7403

Merged
merged 63 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
bbb2462
feat(sanity): allow `extractSchema` worker to emit schemas for all wo…
juice49 Apr 19, 2024
ca8f4c3
feat(sanity): include workspace and dataset names when extracting schema
juice49 Apr 22, 2024
4b1053b
feat(cli): add `manifest` commands
juice49 Apr 22, 2024
b3cc808
feat(manifest): add `@sanity/manifest` package
juice49 Apr 22, 2024
3fbdff4
refactor(sanity): use manifest schemas from `@sanity/manifest`
juice49 Apr 22, 2024
c3d6a57
chore: format files
juice49 Apr 23, 2024
0816925
feat(schema): include `title`, `description`, and `deprecated` attrib…
juice49 Apr 23, 2024
fb860b2
feat(sanity): add `direct` schema format to schema extractor
juice49 Apr 24, 2024
5b2f840
Revert "feat(schema): include `title`, `description`, and `deprecated…
juice49 Apr 24, 2024
c38fb41
feat(sanity): export `ConcreteRuleClass` class
juice49 Apr 26, 2024
9be3d90
feat(sanity): include validation rules in manifests
juice49 Apr 26, 2024
4e7aabf
refactor(sanity): move manifest extraction code
juice49 Apr 27, 2024
43beb96
feat(sanity): extract manifest during build
juice49 Apr 28, 2024
d35982c
feat(sanity): adopt `.studioschema.json` filename suffix for manifest…
juice49 Apr 28, 2024
aa8cf02
refactor(sanity): rename manifest extraction functions (remove plural)
juice49 Apr 29, 2024
cc3c3d3
fix(sanity): remove redundant success message
juice49 Apr 29, 2024
d96fe76
fix(sanity): stop build spinner before starting manifest extraction
juice49 Apr 29, 2024
116ca59
feat(sanity): add `unstable_extractManifestOnBuild` CLI config option
juice49 Apr 29, 2024
41b985b
feat(test-studio): enable `unstable_extractManifestOnBuild`
juice49 Apr 29, 2024
afa7e47
fix(sanity): switch to node crypto for node 18 compatibility
juice49 Apr 29, 2024
cf4cb7e
feat(cli): add `unstable_staticAssetsPath` CLI configuration option
juice49 Apr 29, 2024
3d8e070
chore(cli): refine `unstable_extractManifestOnBuild` CLI configuratio…
juice49 Apr 29, 2024
7019f26
feat(sanity): remove extraneous `types` wrapper from manifests
juice49 Apr 30, 2024
c4be77f
debug(test-studio): remove Mux plugin to unblock typegen
juice49 May 23, 2024
94b5844
feat(embedded-studio): enable manifest extraction
juice49 May 23, 2024
720dcd8
feat(starter-next-studio): enable manifest extraction
juice49 May 23, 2024
0ba3f72
wip
juice49 May 23, 2024
e7bcde1
feat(sanity): normalize type constraints in manifest validation
juice49 May 24, 2024
09a0aa0
wip
juice49 Jun 6, 2024
3ba96fe
chore: merge fix
snorrees Aug 22, 2024
f421749
feat: serialize userland properties and validation rules in manifest
snorrees Aug 28, 2024
71db59a
fix: remove @sanity/manifest package
snorrees Aug 28, 2024
09a2efc
chore: cleanup
snorrees Aug 29, 2024
9744332
fix: serialize fieldsets
snorrees Aug 29, 2024
8fada7b
fix: omit default titles on fields and array-members
snorrees Aug 29, 2024
3db46c3
fix: ensure manifest schema is restoreble and supports cross dataset …
snorrees Aug 29, 2024
0eb86c5
chore: mergefix
snorrees Aug 29, 2024
859b982
fix: serialization of type aliases no longer inlines fields and of props
snorrees Aug 29, 2024
bb811a9
fix: removes double dot in filename
snorrees Aug 29, 2024
3ef8f69
feat: manifest command
snorrees Sep 3, 2024
8da232c
chore: tweaks
snorrees Sep 4, 2024
f07e4e7
chore: revert redundant changes
snorrees Sep 6, 2024
b589036
fix: adds manifest group to CLI
snorrees Sep 6, 2024
4bad06e
chore: wording change
snorrees Sep 9, 2024
3e8fbaa
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 10, 2024
839b729
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 12, 2024
a2ba21c
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 16, 2024
bde80db
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 18, 2024
82cd327
fix: adds a 2-minute timeout to manifest extract
snorrees Sep 18, 2024
1524a82
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 18, 2024
2e2e622
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 19, 2024
31ca22b
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 23, 2024
0246fa6
fix: ensures error code when mainfest extract fails and changes faile…
snorrees Sep 26, 2024
73f8bb2
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 26, 2024
0b8081a
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 26, 2024
22e1ac9
Merge branch 'next' into feat/studio-manifests-cont
snorrees Sep 27, 2024
011610c
chore: use *ENABLED instead of *DISABLED for constant
snorrees Oct 1, 2024
a150e86
chore: defensive optional chaining for option extraction
snorrees Oct 1, 2024
7b96c23
Merge branch 'next' into feat/studio-manifests-cont
snorrees Oct 1, 2024
de125a7
chore: reworded EXTRACT_FAILURE_MESSAGE
snorrees Oct 1, 2024
c5f41c4
Merge branch 'next' into feat/studio-manifests-cont
snorrees Oct 1, 2024
6d05f49
Merge branch 'next' into feat/studio-manifests-cont
snorrees Oct 2, 2024
3e80992
Merge branch 'next' into feat/studio-manifests-cont
snorrees Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/embedded-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "3.59.0",
"private": true,
"scripts": {
"build": "tsc && vite build",
"build": "tsc && vite build && sanity manifest extract",
"dev": "vite",
"preview": "vite preview"
},
Expand Down
8 changes: 8 additions & 0 deletions dev/embedded-studio/sanity.cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
api: {
projectId: 'ppsg7ml5',
dataset: 'test',
},
})
34 changes: 34 additions & 0 deletions dev/embedded-studio/sanity.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {defineConfig, defineType} from 'sanity'
import {structureTool} from 'sanity/structure'

const BLOG_POST_SCHEMA = defineType({
type: 'document',
name: 'blogPost',
title: 'Blog post',
fields: [
{
type: 'string',
name: 'title',
title: 'Title',
},
],
})

export const SCHEMA_TYPES = [BLOG_POST_SCHEMA]

export default defineConfig({
projectId: 'ppsg7ml5',
dataset: 'test',

document: {
unstable_comments: {
enabled: true,
},
},

schema: {
types: SCHEMA_TYPES,
},

plugins: [structureTool()],
})
42 changes: 2 additions & 40 deletions dev/embedded-studio/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,8 @@
import {Button, Card, Flex, studioTheme, ThemeProvider, usePrefersDark} from '@sanity/ui'
import {useCallback, useMemo, useState} from 'react'
import {
defineConfig,
defineType,
Studio,
StudioLayout,
StudioProvider,
type StudioThemeColorSchemeKey,
} from 'sanity'
import {structureTool} from 'sanity/structure'
import {Studio, StudioLayout, StudioProvider, type StudioThemeColorSchemeKey} from 'sanity'

const BLOG_POST_SCHEMA = defineType({
type: 'document',
name: 'blogPost',
title: 'Blog post',
fields: [
{
type: 'string',
name: 'title',
title: 'Title',
},
],
})

const SCHEMA_TYPES = [BLOG_POST_SCHEMA]

const config = defineConfig({
projectId: 'ppsg7ml5',
dataset: 'test',

document: {
unstable_comments: {
enabled: true,
},
},

schema: {
types: SCHEMA_TYPES,
},

plugins: [structureTool()],
})
import config from '../sanity.config'

export function App() {
const prefersDark = usePrefersDark()
Expand Down
3 changes: 3 additions & 0 deletions dev/starter-next-studio/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.next

public/static/*.create-schema.json
public/static/create-manifest.json
36 changes: 4 additions & 32 deletions dev/starter-next-studio/components/Studio.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,13 @@
import {useMemo} from 'react'
import {defineConfig, Studio} from 'sanity'
import {structureTool} from 'sanity/structure'
import {Studio} from 'sanity'

import config from '../sanity.config'

const wrapperStyles = {height: '100vh', width: '100vw'}

export default function StudioRoot({basePath}: {basePath: string}) {
const config = useMemo(
() =>
defineConfig({
basePath,
plugins: [structureTool()],
title: 'Next.js Starter',
projectId: 'ppsg7ml5',
dataset: 'test',
schema: {
types: [
{
type: 'document',
name: 'post',
title: 'Post',
fields: [
{
type: 'string',
name: 'title',
title: 'Title',
},
],
},
],
},
}),
[basePath],
)

return (
<div style={wrapperStyles}>
<Studio config={config} />
<Studio config={{...config, basePath}} />
</div>
)
}
2 changes: 1 addition & 1 deletion dev/starter-next-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"author": "Sanity.io <[email protected]>",
"scripts": {
"build": "next build",
"build": "sanity manifest extract --path public/static && next build",
"dev": "next dev",
"start": "next start"
},
Expand Down
8 changes: 8 additions & 0 deletions dev/starter-next-studio/sanity.cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {defineCliConfig} from 'sanity/cli'

export default defineCliConfig({
api: {
projectId: 'ppsg7ml5',
dataset: 'test',
},
})
25 changes: 25 additions & 0 deletions dev/starter-next-studio/sanity.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'

export default defineConfig({
plugins: [structureTool()],
title: 'Next.js Starter',
projectId: 'ppsg7ml5',
dataset: 'test',
schema: {
types: [
{
type: 'document',
name: 'post',
title: 'Post',
fields: [
{
type: 'string',
name: 'title',
title: 'Title',
},
],
},
],
},
})
1 change: 1 addition & 0 deletions packages/@sanity/cli/src/util/noSuchCommandText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const coreCommands = [
'graphql',
'hook',
'migration',
'manifest',
'preview',
'schema',
'start',
Expand Down
5 changes: 5 additions & 0 deletions packages/sanity/package.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export default defineConfig({
require: './lib/_internal/cli/threads/extractSchema.js',
runtime: 'node',
},
{
source: './src/_internal/cli/threads/extractManifest.ts',
require: './lib/_internal/cli/threads/extractManifest.js',
runtime: 'node',
},
],

extract: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export default async function buildSanityStudio(

spin.text = `Build Sanity Studio (${buildDuration.toFixed()}ms)`
spin.succeed()

trace.complete()
if (flags.stats) {
output.print('\nLargest module files:')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import tar from 'tar-fs'

import {shouldAutoUpdate} from '../../util/shouldAutoUpdate'
import buildSanityStudio, {type BuildSanityStudioCommandFlags} from '../build/buildAction'
import {extractManifestSafe} from '../manifest/extractManifestAction'
import {
checkDir,
createDeployment,
Expand Down Expand Up @@ -101,16 +102,25 @@ export default async function deployStudioAction(
// Always build the project, unless --no-build is passed
const shouldBuild = flags.build
if (shouldBuild) {
const buildArgs = [customSourceDir].filter(Boolean)
const {didCompile} = await buildSanityStudio(
{...args, extOptions: flags, argsWithoutOptions: buildArgs},
context,
{basePath: '/'},
)
const buildArgs = {
...args,
extOptions: flags,
argsWithoutOptions: [customSourceDir].filter(Boolean),
}
const {didCompile} = await buildSanityStudio(buildArgs, context, {basePath: '/'})

if (!didCompile) {
return
}

await extractManifestSafe(
{
...buildArgs,
extOptions: {},
extraArguments: [],
ricokahler marked this conversation as resolved.
Show resolved Hide resolved
},
context,
)
}

// Ensure that the directory exists, is a directory and seems to have valid content
Expand Down
Loading
Loading