mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 06:58:07 -05:00
chore(biome): removed prettier, added biome (#407)
* chore: replace prettier with biome and add linting * chore: update devcontainer settings to use biome for linting and remove eslint, prettier * chore: update docker-compose to use Postgres 17-alpine and standardize quotes * chore: fixed more BUT disabled most rules due to limit * added additional rules, fixed linting & ts errors * added additional rules * rebased & linted * fixed oauth * updated biome & minor modifications --------- Co-authored-by: Aditya Tripathi <aditya@climactic.co>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env ts-node
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { glob } from 'glob'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
console.log('Starting documentation generator...')
|
||||
|
||||
@@ -21,17 +21,11 @@ if (!fs.existsSync(DOCS_OUTPUT_PATH)) {
|
||||
fs.mkdirSync(DOCS_OUTPUT_PATH, { recursive: true })
|
||||
}
|
||||
|
||||
// Type for block input config
|
||||
interface InputConfig {
|
||||
type: string
|
||||
required: boolean
|
||||
}
|
||||
|
||||
// Type for block output config
|
||||
interface OutputConfig {
|
||||
type: string | Record<string, any>
|
||||
}
|
||||
|
||||
// Basic interface for BlockConfig to avoid import issues
|
||||
interface BlockConfig {
|
||||
type: string
|
||||
@@ -122,7 +116,7 @@ function extractIcons(): Record<string, string> {
|
||||
function extractBlockConfig(fileContent: string): BlockConfig | null {
|
||||
try {
|
||||
// Match the block name and type from imports and export statement
|
||||
const typeMatch = fileContent.match(/type\s+(\w+)Response\s*=/)
|
||||
const _typeMatch = fileContent.match(/type\s+(\w+)Response\s*=/)
|
||||
const exportMatch = fileContent.match(/export\s+const\s+(\w+)Block\s*:/)
|
||||
|
||||
if (!exportMatch) {
|
||||
@@ -289,7 +283,7 @@ function extractInputs(content: string): Record<string, any> {
|
||||
const propName = propMatch[1]
|
||||
const typeMatch = propText.match(/type\s*:\s*['"]?([^'"}, ]+)['"]?/s)
|
||||
const requiredMatch = propText.match(/required\s*:\s*(true|false)/s)
|
||||
const descriptionMatch = propText.match(/description\s*:\s*['"]([^'"]+)['"]/s)
|
||||
const _descriptionMatch = propText.match(/description\s*:\s*['"]([^'"]+)['"]/s)
|
||||
|
||||
inputs[propName] = {
|
||||
type: typeMatch ? typeMatch[1] : 'any',
|
||||
@@ -444,7 +438,7 @@ function extractToolsAccess(content: string): string[] {
|
||||
function extractToolInfo(
|
||||
toolName: string,
|
||||
fileContent: string,
|
||||
filePath: string = ''
|
||||
filePath = ''
|
||||
): {
|
||||
description: string
|
||||
params: Array<{ name: string; type: string; required: boolean; description: string }>
|
||||
@@ -452,10 +446,7 @@ function extractToolInfo(
|
||||
} | null {
|
||||
try {
|
||||
// Extract tool config section - Simplified regex to match any *Tool export pattern
|
||||
const toolConfigRegex = new RegExp(
|
||||
`export const \\w+Tool\\s*[=<][^{]*{[\\s\\S]*?params\\s*:\\s*{([\\s\\S]*?)}`,
|
||||
'im'
|
||||
)
|
||||
const toolConfigRegex = /export const \w+Tool\s*[=<][^{]*{[\s\S]*?params\s*:\s*{([\s\S]*?)}/im
|
||||
const toolConfigMatch = fileContent.match(toolConfigRegex)
|
||||
|
||||
// Extract description
|
||||
@@ -640,7 +631,7 @@ function parseOutputStructure(
|
||||
|
||||
while ((fieldMatch = fieldRegex.exec(outputContent)) !== null) {
|
||||
const fieldName = fieldMatch[1].trim()
|
||||
const fieldType = fieldMatch[2].trim().replace(/["'\[\]]/g, '')
|
||||
const _fieldType = fieldMatch[2].trim().replace(/["'[\]]/g, '')
|
||||
|
||||
// Determine a good description based on field name
|
||||
let description = 'Dynamic output field'
|
||||
@@ -872,10 +863,7 @@ function mergeWithManualContent(
|
||||
// Insert after the matched content
|
||||
const insertPosition = match.index + match[0].length
|
||||
console.log(`Inserting ${sectionName} content after position ${insertPosition}`)
|
||||
mergedContent =
|
||||
mergedContent.slice(0, insertPosition) +
|
||||
`\n\n{/* MANUAL-CONTENT-START:${sectionName} */}\n${content}\n{/* MANUAL-CONTENT-END */}\n` +
|
||||
mergedContent.slice(insertPosition)
|
||||
mergedContent = `${mergedContent.slice(0, insertPosition)}\n\n{/* MANUAL-CONTENT-START:${sectionName} */}\n${content}\n{/* MANUAL-CONTENT-END */}\n${mergedContent.slice(insertPosition)}`
|
||||
} else {
|
||||
console.log(
|
||||
`Could not find insertion point for ${sectionName}, regex pattern: ${insertionPoint.regex}`
|
||||
@@ -1032,7 +1020,7 @@ async function generateMarkdownForBlock(
|
||||
const id = subBlock.id || ''
|
||||
const title = subBlock.title || ''
|
||||
const type = subBlock.type || 'string'
|
||||
const required = !!subBlock.condition ? 'No' : 'Yes'
|
||||
const required = subBlock.condition ? 'No' : 'Yes'
|
||||
|
||||
let description = title
|
||||
if (subBlock.placeholder) {
|
||||
@@ -1087,7 +1075,7 @@ async function generateMarkdownForBlock(
|
||||
|
||||
let optionsSection = ''
|
||||
if (dropdownBlocks.length > 0) {
|
||||
optionsSection = `## Available Options\n\n`
|
||||
optionsSection = '## Available Options\n\n'
|
||||
|
||||
dropdownBlocks.forEach((sb) => {
|
||||
optionsSection += `### ${sb.title || sb.id} (${sb.id ? `\`${sb.id}\`` : ''})\n\n`
|
||||
@@ -1122,11 +1110,11 @@ async function generateMarkdownForBlock(
|
||||
let outputsSection = ''
|
||||
|
||||
if (outputs && Object.keys(outputs).length > 0) {
|
||||
outputsSection = `## Outputs\n\n`
|
||||
outputsSection = '## Outputs\n\n'
|
||||
|
||||
// Create the base outputs table
|
||||
outputsSection += `| Output | Type | Description |\n`
|
||||
outputsSection += `| ------ | ---- | ----------- |\n`
|
||||
outputsSection += '| Output | Type | Description |\n'
|
||||
outputsSection += '| ------ | ---- | ----------- |\n'
|
||||
|
||||
// Process each output field
|
||||
for (const outputKey in outputs) {
|
||||
@@ -1196,7 +1184,7 @@ async function generateMarkdownForBlock(
|
||||
// Create tools section with more details
|
||||
let toolsSection = ''
|
||||
if (tools.access?.length) {
|
||||
toolsSection = `## Tools\n\n`
|
||||
toolsSection = '## Tools\n\n'
|
||||
|
||||
// For each tool, try to find its definition and extract parameter information
|
||||
for (const tool of tools.access) {
|
||||
@@ -1211,9 +1199,9 @@ async function generateMarkdownForBlock(
|
||||
}
|
||||
|
||||
// Add Input Parameters section for the tool
|
||||
toolsSection += `#### Input\n\n`
|
||||
toolsSection += `| Parameter | Type | Required | Description |\n`
|
||||
toolsSection += `| --------- | ---- | -------- | ----------- |\n`
|
||||
toolsSection += '#### Input\n\n'
|
||||
toolsSection += '| Parameter | Type | Required | Description |\n'
|
||||
toolsSection += '| --------- | ---- | -------- | ----------- |\n'
|
||||
|
||||
if (toolInfo.params.length > 0) {
|
||||
// Use dynamically extracted parameters
|
||||
@@ -1237,7 +1225,7 @@ async function generateMarkdownForBlock(
|
||||
}
|
||||
|
||||
// Add Output Parameters section for the tool
|
||||
toolsSection += `\n#### Output\n\n`
|
||||
toolsSection += '\n#### Output\n\n'
|
||||
|
||||
if (Object.keys(toolInfo.outputs).length > 0) {
|
||||
// Use dynamically extracted outputs in table format
|
||||
@@ -1247,7 +1235,7 @@ async function generateMarkdownForBlock(
|
||||
}
|
||||
}
|
||||
|
||||
toolsSection += `\n`
|
||||
toolsSection += '\n'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1280,10 +1268,7 @@ ${toolsSection}
|
||||
|
||||
${
|
||||
subBlocks.length > 0
|
||||
? '### Input\n\n' +
|
||||
'| Parameter | Type | Required | Description | \n' +
|
||||
'| --------- | ---- | -------- | ----------- | \n' +
|
||||
inputsTable
|
||||
? `### Input\n\n| Parameter | Type | Required | Description | \n| --------- | ---- | -------- | ----------- | \n${inputsTable}`
|
||||
: 'No configuration parameters required.'
|
||||
}
|
||||
|
||||
@@ -1367,8 +1352,8 @@ generateAllBlockDocs()
|
||||
|
||||
function generateMarkdownTable(outputs: Record<string, string>): string {
|
||||
let table = ''
|
||||
table += `| Parameter | Type |\n`
|
||||
table += `| --------- | ---- |\n`
|
||||
table += '| Parameter | Type |\n'
|
||||
table += '| --------- | ---- |\n'
|
||||
|
||||
for (const [key, value] of Object.entries(outputs)) {
|
||||
// Try to determine a reasonable type from the value description
|
||||
|
||||
@@ -57,10 +57,3 @@ if ! npx tsx ./generate-block-docs.ts; then
|
||||
fi
|
||||
|
||||
echo "Documentation generation complete!"
|
||||
echo "Generated documentation can be found in apps/docs/content/docs/tools/"
|
||||
|
||||
# Run prettier on the generated documentation files
|
||||
echo "Formatting generated documentation files with Prettier..."
|
||||
cd "$ROOT_DIR"
|
||||
npx prettier --write "apps/docs/content/docs/tools/**/*.mdx"
|
||||
echo "Formatting complete!"
|
||||
Reference in New Issue
Block a user