From dff8b1ba6270007e128d517666d8a32941f89f03 Mon Sep 17 00:00:00 2001 From: Sindre Gulseth Date: Tue, 12 Mar 2024 13:09:21 +0100 Subject: [PATCH] feat(codegen): add codegen skeleton package contains just the infrastructure for a new package for codegen application --- packages/@sanity/codegen/.depcheckrc.json | 3 + packages/@sanity/codegen/.eslintrc.cjs | 11 ++++ packages/@sanity/codegen/.gitignore | 12 ++++ packages/@sanity/codegen/README.md | 3 + packages/@sanity/codegen/babel.config.json | 12 ++++ packages/@sanity/codegen/jest.config.cjs | 8 +++ packages/@sanity/codegen/package.config.ts | 5 ++ packages/@sanity/codegen/package.json | 64 +++++++++++++++++++ .../@sanity/codegen/src/_exports/index.ts | 1 + packages/@sanity/codegen/tsconfig.json | 15 +++++ packages/@sanity/codegen/tsconfig.lib.json | 15 +++++ packages/@sanity/codegen/tsdoc.json | 33 ++++++++++ pnpm-lock.yaml | 6 ++ tsconfig.json | 1 + 14 files changed, 189 insertions(+) create mode 100644 packages/@sanity/codegen/.depcheckrc.json create mode 100644 packages/@sanity/codegen/.eslintrc.cjs create mode 100644 packages/@sanity/codegen/.gitignore create mode 100644 packages/@sanity/codegen/README.md create mode 100644 packages/@sanity/codegen/babel.config.json create mode 100644 packages/@sanity/codegen/jest.config.cjs create mode 100644 packages/@sanity/codegen/package.config.ts create mode 100644 packages/@sanity/codegen/package.json create mode 100644 packages/@sanity/codegen/src/_exports/index.ts create mode 100644 packages/@sanity/codegen/tsconfig.json create mode 100644 packages/@sanity/codegen/tsconfig.lib.json create mode 100644 packages/@sanity/codegen/tsdoc.json diff --git a/packages/@sanity/codegen/.depcheckrc.json b/packages/@sanity/codegen/.depcheckrc.json new file mode 100644 index 000000000000..d2b37f0015c0 --- /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 000000000000..99fd6c692245 --- /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 000000000000..52b428d6f80c --- /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 000000000000..4cb7e1a8288a --- /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/babel.config.json b/packages/@sanity/codegen/babel.config.json new file mode 100644 index 000000000000..4dd92d93f5c3 --- /dev/null +++ b/packages/@sanity/codegen/babel.config.json @@ -0,0 +1,12 @@ +{ + "presets": [ + ["@babel/preset-env", {"targets": "maintained node versions"}], + [ + "@babel/preset-react", + { + "runtime": "automatic" + } + ], + "@babel/preset-typescript" + ] +} diff --git a/packages/@sanity/codegen/jest.config.cjs b/packages/@sanity/codegen/jest.config.cjs new file mode 100644 index 000000000000..51ecfb62217a --- /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 000000000000..fc4cec4fc5ce --- /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 000000000000..5f30f9f4e59b --- /dev/null +++ b/packages/@sanity/codegen/package.json @@ -0,0 +1,64 @@ +{ + "name": "@sanity/codegen", + "version": "3.30.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" + }, + "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 000000000000..32194a4a2f09 --- /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 000000000000..e54085759342 --- /dev/null +++ b/packages/@sanity/codegen/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../tsconfig.settings", + "include": ["./src/**/*"], + "compilerOptions": { + "composite": true, + "lib": ["ES2022.Error"], + "rootDir": ".", + "outDir": "./lib/dts", + "declarationDir": "./lib/dts" + }, + "references": [ + {"path": "../../@sanity/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 000000000000..e54085759342 --- /dev/null +++ b/packages/@sanity/codegen/tsconfig.lib.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../tsconfig.settings", + "include": ["./src/**/*"], + "compilerOptions": { + "composite": true, + "lib": ["ES2022.Error"], + "rootDir": ".", + "outDir": "./lib/dts", + "declarationDir": "./lib/dts" + }, + "references": [ + {"path": "../../@sanity/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 000000000000..0700c7d44a6f --- /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 e6aaac597f69..953f98a98725 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 c242407e6dac..dbdd3859010d 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"},