diff --git a/packages/@sanity/codegen/.depcheckrc.json b/packages/@sanity/codegen/.depcheckrc.json new file mode 100644 index 00000000000..d2b37f0015c --- /dev/null +++ b/packages/@sanity/codegen/.depcheckrc.json @@ -0,0 +1,3 @@ +{ + "ignores": ["@sanity/pkg-utils"] +} diff --git a/packages/@sanity/codegen/.eslintrc.cjs b/packages/@sanity/codegen/.eslintrc.cjs new file mode 100644 index 00000000000..99fd6c69224 --- /dev/null +++ b/packages/@sanity/codegen/.eslintrc.cjs @@ -0,0 +1,11 @@ +'use strict' + +const path = require('path') + +const ROOT_PATH = path.resolve(__dirname, '../../..') + +module.exports = { + rules: { + 'import/no-extraneous-dependencies': ['error', {packageDir: [ROOT_PATH, __dirname]}], + }, +} diff --git a/packages/@sanity/codegen/.gitignore b/packages/@sanity/codegen/.gitignore new file mode 100644 index 00000000000..52b428d6f80 --- /dev/null +++ b/packages/@sanity/codegen/.gitignore @@ -0,0 +1,12 @@ +# Logs +/logs +*.log + +# Coverage directory used by tools like istanbul +/coverage + +# Dependency directories +/node_modules + +# Compiled code +/lib diff --git a/packages/@sanity/codegen/README.md b/packages/@sanity/codegen/README.md new file mode 100644 index 00000000000..4cb7e1a8288 --- /dev/null +++ b/packages/@sanity/codegen/README.md @@ -0,0 +1,3 @@ +# @sanity/codegen + +Codegen toolkit for Sanity.io. This package is currently in an experimental state, and subject to change. diff --git a/packages/@sanity/codegen/jest.config.cjs b/packages/@sanity/codegen/jest.config.cjs new file mode 100644 index 00000000000..51ecfb62217 --- /dev/null +++ b/packages/@sanity/codegen/jest.config.cjs @@ -0,0 +1,8 @@ +'use strict' + +const {createJestConfig} = require('../../../test/config.cjs') + +module.exports = createJestConfig({ + displayName: require('./package.json').name, + testEnvironment: 'node', +}) diff --git a/packages/@sanity/codegen/package.config.ts b/packages/@sanity/codegen/package.config.ts new file mode 100644 index 00000000000..fc4cec4fc5c --- /dev/null +++ b/packages/@sanity/codegen/package.config.ts @@ -0,0 +1,5 @@ +import {defineConfig} from '@sanity/pkg-utils' + +import baseConfig from '../../../package.config' + +export default defineConfig(baseConfig) diff --git a/packages/@sanity/codegen/package.json b/packages/@sanity/codegen/package.json new file mode 100644 index 00000000000..17870b94217 --- /dev/null +++ b/packages/@sanity/codegen/package.json @@ -0,0 +1,67 @@ +{ + "name": "@sanity/codegen", + "version": "3.33.0", + "description": "Codegen toolkit for Sanity.io", + "keywords": [ + "sanity", + "cms", + "headless", + "realtime", + "content", + "codegen" + ], + "homepage": "https://www.sanity.io/", + "bugs": { + "url": "https://github.com/sanity-io/sanity/issues" + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/sanity-io/sanity.git", + "directory": "packages/@sanity/codegen" + }, + "license": "MIT", + "author": "Sanity.io ", + "exports": { + ".": { + "types": "./lib/dts/src/_exports/index.d.ts", + "source": "./src/_exports/index.ts", + "require": "./lib/_exports/index.js", + "node": { + "module": "./lib/_exports/index.esm.js", + "import": "./lib/_exports/index.cjs.mjs" + }, + "import": "./lib/_exports/index.esm.js", + "default": "./lib/_exports/index.esm.js" + }, + "./package.json": "./package.json" + }, + "main": "./lib/_exports/index.js", + "module": "./lib/_exports/index.esm.js", + "source": "./src/_exports/index.ts", + "types": "./lib/dts/src/_exports/index.d.ts", + "files": [ + "lib", + "src", + "!**/__tests__/**" + ], + "scripts": { + "prebuild": "run-s clean", + "build": "pkg-utils build --tsconfig tsconfig.lib.json", + "postbuild": "run-s check:package", + "check:package": "pkg-utils --strict --tsconfig tsconfig.lib.json", + "clean": "rimraf lib coverage", + "lint": "eslint .", + "watch": "pkg-utils watch --tsconfig tsconfig.lib.json", + "test": "jest" + }, + "dependencies": {}, + "devDependencies": { + "rimraf": "^3.0.2" + }, + "engines": { + "node": ">=18" + } +} diff --git a/packages/@sanity/codegen/src/_exports/index.ts b/packages/@sanity/codegen/src/_exports/index.ts new file mode 100644 index 00000000000..32194a4a2f0 --- /dev/null +++ b/packages/@sanity/codegen/src/_exports/index.ts @@ -0,0 +1 @@ +export const TODO = 1 diff --git a/packages/@sanity/codegen/tsconfig.json b/packages/@sanity/codegen/tsconfig.json new file mode 100644 index 00000000000..dfc2b88930a --- /dev/null +++ b/packages/@sanity/codegen/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../../tsconfig.settings", + "include": ["./src/**/*"], + "compilerOptions": { + "composite": true, + "lib": ["ES2022.Error"], + "rootDir": ".", + "outDir": "./lib/dts", + "declarationDir": "./lib/dts" + }, + "references": [{"path": "../types/tsconfig.lib.json"}, {"path": "../../groq/tsconfig.lib.json"}] +} diff --git a/packages/@sanity/codegen/tsconfig.lib.json b/packages/@sanity/codegen/tsconfig.lib.json new file mode 100644 index 00000000000..dfc2b88930a --- /dev/null +++ b/packages/@sanity/codegen/tsconfig.lib.json @@ -0,0 +1,12 @@ +{ + "extends": "../../../tsconfig.settings", + "include": ["./src/**/*"], + "compilerOptions": { + "composite": true, + "lib": ["ES2022.Error"], + "rootDir": ".", + "outDir": "./lib/dts", + "declarationDir": "./lib/dts" + }, + "references": [{"path": "../types/tsconfig.lib.json"}, {"path": "../../groq/tsconfig.lib.json"}] +} diff --git a/packages/@sanity/codegen/tsdoc.json b/packages/@sanity/codegen/tsdoc.json new file mode 100644 index 00000000000..0700c7d44a6 --- /dev/null +++ b/packages/@sanity/codegen/tsdoc.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "tagDefinitions": [ + { + "tagName": "@hidden", + "syntaxKind": "block", + "allowMultiple": true + }, + { + "tagName": "@todo", + "syntaxKind": "block", + "allowMultiple": true + } + ], + "supportForTags": { + "@hidden": true, + "@beta": true, + "@internal": true, + "@public": true, + "@experimental": true, + "@see": true, + "@link": true, + "@example": true, + "@deprecated": true, + "@alpha": true, + "@param": true, + "@returns": true, + "@remarks": true, + "@throws": true, + "@defaultValue": true, + "@todo": true + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index db9e4c59169..b6a9e6dac84 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -837,6 +837,12 @@ importers: specifier: ^4.0.0 version: 4.0.0 + packages/@sanity/codegen: + devDependencies: + rimraf: + specifier: ^3.0.2 + version: 3.0.2 + packages/@sanity/diff: dependencies: '@sanity/diff-match-patch': diff --git a/tsconfig.json b/tsconfig.json index c242407e6da..dbdd3859010 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,7 @@ {"path": "./packages/@sanity/mutator"}, {"path": "./packages/@sanity/portable-text-editor"}, {"path": "./packages/@sanity/schema"}, + {"path": "./packages/@sanity/codegen"}, {"path": "./packages/@sanity/types"}, {"path": "./packages/@sanity/util"}, {"path": "./packages/@sanity/vision"},