mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Remove remnants of Fern docs
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Emulator Test / docker (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Test / docker (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Emulator Test / docker (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Test / docker (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
This commit is contained in:
parent
d96dceb42b
commit
9b388d9168
@ -1,12 +1,10 @@
|
||||
import { parseOpenAPI, parseWebhookOpenAPI } from '@/lib/openapi';
|
||||
import { parseOpenAPI } from '@/lib/openapi';
|
||||
import { isSmartRouteHandler } from '@/route-handlers/smart-route-handler';
|
||||
import { webhookEvents } from '@stackframe/stack-shared/dist/interface/webhooks';
|
||||
import { writeFileSyncIfChanged } from '@stackframe/stack-shared/dist/utils/fs';
|
||||
import { HTTP_METHODS } from '@stackframe/stack-shared/dist/utils/http';
|
||||
import { typedKeys } from '@stackframe/stack-shared/dist/utils/objects';
|
||||
import { glob } from 'glob';
|
||||
import path from 'path';
|
||||
import yaml from 'yaml';
|
||||
|
||||
async function main() {
|
||||
console.log("Started docs schema generator");
|
||||
@ -34,14 +32,7 @@ async function main() {
|
||||
}))),
|
||||
audience,
|
||||
});
|
||||
const openAPISchema = yaml.stringify(openApiSchemaObject);
|
||||
writeFileSyncIfChanged(`../mcp-server/openapi/${audience}.json`, JSON.stringify(openApiSchemaObject, null, 2));
|
||||
writeFileSyncIfChanged(`../../docs/fern/openapi/${audience}.yaml`, openAPISchema);
|
||||
|
||||
const webhookOpenAPISchema = yaml.stringify(parseWebhookOpenAPI({
|
||||
webhooks: webhookEvents,
|
||||
}));
|
||||
writeFileSyncIfChanged(`../../docs/fern/openapi/webhooks.yaml`, webhookOpenAPISchema);
|
||||
}
|
||||
console.log("Successfully updated docs schemas");
|
||||
}
|
||||
|
||||
@ -1,101 +0,0 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import yaml from "yaml";
|
||||
import { PLATFORMS, copyFromSrcToDest, processMacros, withGeneratorLock, writeFileSyncIfChanged } from "./utils";
|
||||
|
||||
interface DocObject {
|
||||
platform?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
function processDocObject(obj: any, platforms: string[]): { result: any, validPaths: string[] } {
|
||||
// If not an object, return as is
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return { result: obj, validPaths: [] };
|
||||
}
|
||||
|
||||
// Handle arrays
|
||||
if (Array.isArray(obj)) {
|
||||
const processed = obj
|
||||
.map(item => processDocObject(item, platforms))
|
||||
.filter(item => item.result !== null);
|
||||
return {
|
||||
result: processed.map(p => p.result),
|
||||
validPaths: processed.flatMap(p => p.validPaths)
|
||||
};
|
||||
}
|
||||
|
||||
// Handle objects
|
||||
const docObj = obj as DocObject;
|
||||
|
||||
// If object has platform and it doesn't match current platform, exclude it
|
||||
if (docObj.platform) {
|
||||
if (!platforms.includes(docObj.platform)) {
|
||||
return { result: null, validPaths: [] };
|
||||
}
|
||||
// Remove the platform field from the output
|
||||
const { platform: _, ...rest } = docObj;
|
||||
obj = rest;
|
||||
}
|
||||
|
||||
const validPaths: string[] = [];
|
||||
|
||||
// Recursively process all properties
|
||||
const result: { [key: string]: any } = {};
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
const { result: processed, validPaths: processedValidPaths } = processDocObject(value, platforms);
|
||||
processedValidPaths.forEach(path => validPaths.push(path));
|
||||
|
||||
if (processed !== null) {
|
||||
if (typeof processed === 'string') {
|
||||
if (key === 'path') {
|
||||
validPaths.push(processed.split('/').slice(3).join('/'));
|
||||
}
|
||||
|
||||
result[key] = processed.replace(/{platform}/g, platforms[0]);
|
||||
} else {
|
||||
result[key] = processed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
result,
|
||||
validPaths
|
||||
}
|
||||
}
|
||||
|
||||
withGeneratorLock(async () => {
|
||||
const docsDir = path.resolve(__dirname, "..", "docs", "fern");
|
||||
const templateDir = path.join(docsDir, "docs", "pages-template");
|
||||
const ymlTemplatePath = path.join(docsDir, "docs-template.yml");
|
||||
|
||||
for (const platform of ["next", "js", "react", "python"]) {
|
||||
const destDir = path.join(docsDir, 'docs', `pages-${platform}`);
|
||||
|
||||
const mainYmlContent = fs.readFileSync(ymlTemplatePath, "utf-8");
|
||||
const macroProcessed = processMacros(mainYmlContent, PLATFORMS[platform]);
|
||||
const template = yaml.parse(macroProcessed);
|
||||
const { result: processed, validPaths: processedValidPaths } = processDocObject(template, PLATFORMS[platform]);
|
||||
const output = yaml.stringify(processed);
|
||||
writeFileSyncIfChanged(path.join(docsDir, `${platform}.yml`), output);
|
||||
|
||||
// Copy the entire template directory, processing macros for each file
|
||||
copyFromSrcToDest({
|
||||
srcDir: templateDir,
|
||||
destDir,
|
||||
editFn: (relativePath, content) => {
|
||||
return processMacros(content, PLATFORMS[platform]);
|
||||
},
|
||||
filterFn: (relativePath) => {
|
||||
if (relativePath.endsWith('.mdx') && !relativePath.startsWith('snippets')) {
|
||||
return processedValidPaths.includes(relativePath);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user