Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
feat: v3 updates (#275)
Browse files Browse the repository at this point in the history
Co-authored-by: Rico Kahler <[email protected]>
  • Loading branch information
ricokahler and Rico Kahler authored Jan 19, 2023
1 parent 0a1855a commit 9d3f3bb
Show file tree
Hide file tree
Showing 44 changed files with 34,839 additions and 22,045 deletions.
5 changes: 1 addition & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": "react-app",
"rules": {
"import/no-anonymous-default-export": "off"
}
"extends": "@sanity/eslint-config-studio"
}
54,600 changes: 33,431 additions & 21,169 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@
"typecheck": "tsc -b"
},
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/node": "^7.14.7",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.16.7",
"@types/jest": "26.0.21",
"@types/node": "14.14.35",
"@types/node-fetch": "^2.5.9",
"common-tags": "^1.8.0",
"eslint": "8.7.0",
"eslint-config-react-app": "7.0.0",
"fast-glob": "^3.2.7",
"jest": "^27.0.6",
"lerna": "^4.0.0",
"node-fetch": "^2.6.1",
"prettier": "^2.3.2",
"rollup": "^2.66.1",
"semver": "^5.7.1",
"sort-package-json": "^1.49.0",
"typescript": "^4.5.5"
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/node": "^7.20.7",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@sanity/eslint-config-studio": "^2.0.1",
"@types/jest": "^29.2.6",
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.2",
"common-tags": "^1.8.2",
"eslint": "^8.32.0",
"fast-glob": "^3.2.12",
"jest": "^29.3.1",
"lerna": "^6.4.1",
"node-fetch": "^3.3.0",
"prettier": "^2.8.3",
"rollup": "^3.10.0",
"semver": "^7.3.8",
"sort-package-json": "^2.1.0",
"typescript": "^4.9.4"
}
}
15 changes: 10 additions & 5 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const config: SanityCodegenConfig = {
* Optionally provide the path to your sanity schema entry point. If not
* provided, the CLI will try to get this value from your `sanity.json` file.
*/
schemaPath: './schema',
// sanityConfigPath: './sanity.config.ts',
/**
* Specify a glob (powered by
* [`globby`](https://github.com/sindresorhus/globby)), a list of globs, or a
Expand Down Expand Up @@ -113,14 +113,16 @@ export default config;
```

<!-- toc -->
* [@sanity-codegen/cli](#sanity-codegencli)
* [Usage](#usage)
* [Commands](#commands)

- [@sanity-codegen/cli](#sanity-codegencli)
- [Usage](#usage)
- [Commands](#commands)
<!-- tocstop -->

# Usage

<!-- usage -->

```sh-session
$ npm install -g @sanity-codegen/cli
$ sanity-codegen COMMAND
Expand All @@ -132,12 +134,14 @@ USAGE
$ sanity-codegen COMMAND
...
```

<!-- usagestop -->

# Commands

<!-- commands -->
* [`sanity-codegen help [COMMAND]`](#sanity-codegen-help-command)

- [`sanity-codegen help [COMMAND]`](#sanity-codegen-help-command)

## `sanity-codegen help [COMMAND]`

Expand All @@ -155,4 +159,5 @@ OPTIONS
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.3.1/src/commands/help.ts)_

<!-- commandsstop -->
20 changes: 10 additions & 10 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@
}
},
"dependencies": {
"@babel/core": "^7.14.8",
"@oclif/command": "^1.8.0",
"@oclif/config": "^1.17.0",
"@oclif/plugin-help": "^3.2.2",
"@babel/core": "^7.20.12",
"@oclif/command": "^1.8.21",
"@oclif/config": "^1.18.6",
"@oclif/plugin-help": "^5.2.0",
"@sanity-codegen/groq-codegen": "^1.0.0-alpha.26",
"@sanity-codegen/schema-codegen": "^1.0.0-alpha.26",
"@sanity-codegen/types": "^1.0.0-alpha.25",
"babel-merge": "^3.0.0",
"chalk": "^4.1.2",
"common-tags": "^1.8.0",
"common-tags": "^1.8.2",
"ora": "^5.4.1",
"rxjs": "^7.3.0"
"rxjs": "^7.8.0"
},
"devDependencies": {
"@oclif/dev-cli": "^1.26.0",
"@types/common-tags": "^1.8.0",
"@types/node": "^10.17.56",
"globby": "^10.0.2"
"@oclif/dev-cli": "^1.26.10",
"@types/common-tags": "^1.8.1",
"@types/node": "^18.11.18",
"globby": "~11.0.0"
},
"engines": {
"node": ">=12.22.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/groq-codegen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('groq-codegen command', () => {
.map((call) => call[0])
.map((message: string) => message.replace(/:\s[\w/\\.-]+/g, ' <PATH>')),
).toMatchInlineSnapshot(`
Array [
[
"Using sanity-codegen config found at <PATH>",
"Finding files to extract queries from…",
"Found 2 candidate files from \`groqCodegenInclude\` and \`groqCodegenExclude\`",
Expand All @@ -57,8 +57,8 @@ describe('groq-codegen command', () => {
(call: [string, string]) => call[1],
),
).toMatchInlineSnapshot(`
Array [
"/// <reference types=\\"@sanity-codegen/types\\" />
[
"/// <reference types="@sanity-codegen/types" />
declare namespace Sanity {
namespace Queries {
Expand Down
132 changes: 77 additions & 55 deletions packages/cli/src/commands/schema-codegen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('schema-codegen command', () => {
.map((call) => call[0])
.map((message: string) => message.replace(/:\s[\w/\\.-]+/g, ' <PATH>')),
).toMatchInlineSnapshot(`
Array [
[
"Using sanity-codegen config found at <PATH>",
"Wrote schema types output to <PATH>",
"Wrote schema JSON output to <PATH>",
Expand All @@ -49,16 +49,16 @@ describe('schema-codegen command', () => {
(call: [string, string]) => call[1],
),
).toMatchInlineSnapshot(`
Array [
"/// <reference types=\\"@sanity-codegen/types\\" />
[
"/// <reference types="@sanity-codegen/types" />
declare namespace Sanity {
namespace Schema {
/**
* Book
*/
interface Book extends Sanity.Document {
_type: \\"book\\";
_type: "book";
/**
* Title - \`String\`
Expand All @@ -76,72 +76,94 @@ describe('schema-codegen command', () => {
}
",
"{
\\"type\\": \\"SchemaRoot\\",
\\"documents\\": [
"type": "SchemaRoot",
"documents": [
{
\\"codegen\\": {
\\"required\\": false
"codegen": {
"required": false
},
\\"description\\": null,
\\"hidden\\": false,
\\"readOnly\\": false,
\\"hasValidation\\": false,
\\"name\\": \\"book\\",
\\"title\\": \\"Book\\",
\\"type\\": \\"Document\\",
\\"fields\\": [
"description": null,
"hidden": false,
"readOnly": false,
"hasValidation": false,
"originalNode": {
"name": "book",
"type": "document",
"fields": [
{
"name": "title",
"type": "string"
},
{
"name": "author",
"type": "string"
}
]
},
"name": "book",
"title": "Book",
"type": "Document",
"fields": [
{
\\"name\\": \\"title\\",
\\"title\\": \\"Title\\",
\\"description\\": \\"\\",
\\"hidden\\": false,
\\"readOnly\\": false,
\\"codegen\\": {
\\"required\\": false
"name": "title",
"title": "Title",
"description": "",
"hidden": false,
"readOnly": false,
"codegen": {
"required": false
},
\\"hasValidation\\": false,
\\"definition\\": {
\\"codegen\\": {
\\"required\\": false
"hasValidation": false,
"definition": {
"codegen": {
"required": false
},
"description": null,
"hidden": false,
"name": "title",
"readOnly": false,
"title": "Title",
"hasValidation": false,
"originalNode": {
"name": "title",
"type": "string"
},
\\"description\\": null,
\\"hidden\\": false,
\\"name\\": \\"title\\",
\\"readOnly\\": false,
\\"title\\": \\"Title\\",
\\"hasValidation\\": false,
\\"type\\": \\"String\\",
\\"list\\": null
"type": "String",
"list": null
}
},
{
\\"name\\": \\"author\\",
\\"title\\": \\"Author\\",
\\"description\\": \\"\\",
\\"hidden\\": false,
\\"readOnly\\": false,
\\"codegen\\": {
\\"required\\": false
"name": "author",
"title": "Author",
"description": "",
"hidden": false,
"readOnly": false,
"codegen": {
"required": false
},
\\"hasValidation\\": false,
\\"definition\\": {
\\"codegen\\": {
\\"required\\": false
"hasValidation": false,
"definition": {
"codegen": {
"required": false
},
"description": null,
"hidden": false,
"name": "author",
"readOnly": false,
"title": "Author",
"hasValidation": false,
"originalNode": {
"name": "author",
"type": "string"
},
\\"description\\": null,
\\"hidden\\": false,
\\"name\\": \\"author\\",
\\"readOnly\\": false,
\\"title\\": \\"Author\\",
\\"hasValidation\\": false,
\\"type\\": \\"String\\",
\\"list\\": null
"type": "String",
"list": null
}
}
]
}
],
\\"registeredTypes\\": []
"registeredTypes": []
}",
]
`);
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/schema-codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
generateSchemaTypes,
} from '@sanity-codegen/schema-codegen';
import { getConfig } from '../get-config';
import { getSchemaPath } from '../get-schema-path';
import { getSanityConfigPath } from '../get-sanity-config-path';
import { simpleLogger } from '../simple-logger';
import { createAnimatedLogger } from '../create-animated-logger';

Expand Down Expand Up @@ -80,7 +80,7 @@ export default class SchemaCodegen extends Command {

static args: Parser.args.IArg[] = [
{
name: 'schemaPath',
name: 'sanityConfigPath',
description: stripIndents`
Optionally provide the path to your sanity schema entry point. If not
provided, the CLI will try to get this value from your sanity.json file.
Expand All @@ -99,7 +99,7 @@ export default class SchemaCodegen extends Command {
const normalizedSchema = config?.normalizedSchema
? config.normalizedSchema
: await schemaExtractor({
schemaPath: await getSchemaPath({
sanityConfigPath: await getSanityConfigPath({
config,
args,
root,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/get-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('getConfig', () => {
.map((call) => call[0])
.map((message: string) => message.replace(/:\s[\w/\\.-]+/g, ' <PATH>')),
).toMatchInlineSnapshot(`
Array [
[
"Using sanity-codegen config found at <PATH>",
"Using babelrc config found at <PATH>",
]
Expand Down
Loading

1 comment on commit 9d3f3bb

@vercel
Copy link

@vercel vercel bot commented on 9d3f3bb Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.