🚧 Use TS project references

This commit is contained in:
Baptiste Arnaud
2024-08-28 18:09:35 +02:00
parent 0c7d2afd51
commit fdd6cc6fee
627 changed files with 3043 additions and 1696 deletions

View File

@@ -161,7 +161,7 @@ export const ${camelCaseName}Block = createBlock({
const createPackageJson = async (path: string, { id }: { id: unknown }) => {
writeFileSync(
join(path, 'package.json'),
await prettier.format(
prettier.format(
JSON.stringify({
name: `@typebot.io/${id}-block`,
version: '1.0.0',
@@ -173,7 +173,6 @@ const createPackageJson = async (path: string, { id }: { id: unknown }) => {
'@typebot.io/forge': 'workspace:*',
'@typebot.io/tsconfig': 'workspace:*',
'@types/react': builderPackageJson.devDependencies['@types/react'],
typescript: builderPackageJson.devDependencies['typescript'],
'@typebot.io/lib': 'workspace:*',
},
}),
@@ -185,14 +184,13 @@ const createPackageJson = async (path: string, { id }: { id: unknown }) => {
const createTsConfig = async (path: string) => {
writeFileSync(
join(path, 'tsconfig.json'),
await prettier.format(
prettier.format(
JSON.stringify({
extends: '@typebot.io/tsconfig/base.json',
include: ['**/*.ts', '**/*.tsx'],
exclude: ['node_modules'],
compilerOptions: {
lib: ['ESNext', 'DOM'],
noEmit: true,
jsx: 'preserve',
jsxImportSource: 'react',
},
@@ -208,7 +206,7 @@ const createLogoFile = async (
) => {
writeFileSync(
join(path, 'logo.tsx'),
await prettier.format(
prettier.format(
`/** @jsxImportSource react */
export const ${capitalize(
@@ -226,7 +224,7 @@ const createAuthFile = async (
) =>
writeFileSync(
join(path, 'auth.ts'),
await prettier.format(
prettier.format(
`import { option, AuthDefinition } from '@typebot.io/forge'
export const auth = {
@@ -279,7 +277,7 @@ const createSchemasFile = async (
const camelCaseName = camelize(id as string)
writeFileSync(
join(path, 'schemas.ts'),
await prettier.format(
prettier.format(
`// Do not edit this file manually
import { ${
auth !== 'none' ? 'parseBlockCredentials,' : ''
@@ -327,7 +325,7 @@ ${existingDefinitionsData.slice(newObjectEntryIndex)}`
writeFileSync(
join(schemasPath, 'definitions.ts'),
await prettier.format(newDefinitionsData, {
prettier.format(newDefinitionsData, {
parser: 'typescript',
...prettierRc,
})
@@ -363,7 +361,7 @@ ${existingDefinitionsData.slice(newObjectEntryIndex)}`
writeFileSync(
join(schemasPath, 'schemas.ts'),
await prettier.format(newDefinitionsData, {
prettier.format(newDefinitionsData, {
parser: 'typescript',
...prettierRc,
})
@@ -399,7 +397,7 @@ ${existingSchemasData.slice(newObjectEntryIndex)}`
writeFileSync(
join(schemasPath, 'credentials.ts'),
await prettier.format(newDefinitionsData, {
prettier.format(newDefinitionsData, {
parser: 'typescript',
...prettierRc,
})
@@ -413,7 +411,7 @@ async function addBlockToRepoConstants(schemasPath: string, id: string) {
writeFileSync(
join(schemasPath, 'constants.ts'),
await prettier.format(
prettier.format(
existingDefinitionsData.replace(
`] as const satisfies ForgedBlock['type'][]`,
`'${id}'] as const satisfies ForgedBlock['type'][]`
@@ -432,7 +430,7 @@ async function addBlockToRepoPackageJson(id: string) {
packageJson.devDependencies[`@typebot.io/${id}-block`] = 'workspace:*'
writeFileSync(
join(schemasPath, 'package.json'),
await prettier.format(JSON.stringify(packageJson, null, 2), {
prettier.format(JSON.stringify(packageJson, null, 2), {
parser: 'json',
...prettierRc,
})

View File

@@ -2,7 +2,6 @@
"name": "forge-cli",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsx ./index.ts"
},
@@ -11,9 +10,9 @@
"license": "AGPL-3.0-or-later",
"devDependencies": {
"@clack/prompts": "^0.7.0",
"@typebot.io/tsconfig": "workspace:*",
"@types/node": "20.4.2",
"tsx": "4.6.2",
"prettier": "2.8.8"
"prettier": "2.8.8",
"@types/prettier": "2.7.3"
}
}
}

View File

@@ -1,9 +1,8 @@
{
"extends": "@typebot.io/tsconfig/base.json",
"extends": "../../tsconfig/base.json",
"include": ["./**/*.ts"],
"exclude": ["node_modules"],
"compilerOptions": {
"lib": ["ESNext"],
"resolveJsonModule": true
"resolveJsonModule": true,
"outDir": "dist"
}
}