Skip to content

Commit

Permalink
Start adding readme controller
Browse files Browse the repository at this point in the history
  • Loading branch information
amckinney committed May 26, 2024
1 parent a71408c commit 968ed6d
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 3 deletions.
9 changes: 7 additions & 2 deletions fern/apis/generator-cli/definition/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ service:
name: GenerateReadmeRequest
body:
properties:
readmeConfig: ReadmeConfig
# TODO: If we store the features.yml data in the DB, we can
# alternatively accept the generator name and version.
featuresConfig: features.FeaturesConfig
readmeConfig: ReadmeConfig
snippets:
# TODO: Can we reference the generator-exec snippets here?
# TODO: This is duplicative; FDR already stores snippets, so
# we shouldn't need to pass them here. However, FDR doesn't
# store the snippets based on their feature, so we'd need
# to remodel the FDR API to do so.
docs: |
The snippet.json produced by the generator.
type: unknown
Expand Down
2 changes: 1 addition & 1 deletion packages/generator-cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {};
export * from "./readme";
2 changes: 2 additions & 0 deletions packages/generator-cli/src/readme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { ReadmeGenerator } from "./ReadmeGenerator";
export { ReadmeParser } from "./ReadmeParser";
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions servers/fdr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@aws-sdk/client-s3": "^3.335.0",
"@aws-sdk/s3-request-presigner": "^3.574.0",
"@fern-api/generator-cli": "workspace:*",
"@fern-api/fdr-sdk": "workspace:*",
"@fern-api/template-resolver": "workspace:*",
"@fern-api/venus-api-sdk": "^0.6.2-1-gbbd1ac5",
Expand Down
4 changes: 4 additions & 0 deletions servers/fdr/src/__test__/local/setupMockFdr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getDocsReadService } from "../../controllers/docs/v1/getDocsReadService
import { getDocsWriteService } from "../../controllers/docs/v1/getDocsWriteService";
import { getDocsReadV2Service } from "../../controllers/docs/v2/getDocsReadV2Service";
import { getDocsWriteV2Service } from "../../controllers/docs/v2/getDocsWriteV2Service";
import { getReadmeService } from "../../controllers/readme/getReadmeService";
import { getSnippetsFactoryService } from "../../controllers/snippets/getSnippetsFactoryService";
import { getSnippetsService } from "../../controllers/snippets/getSnippetsService";
import { getTemplatesService } from "../../controllers/snippets/getTemplatesService";
Expand Down Expand Up @@ -102,6 +103,9 @@ async function runMockFdr(port: number): Promise<MockFdr.Instance> {
templates: getTemplatesService(fdrApplication),
diff: getApiDiffService(fdrApplication),
docsCache: getDocsCacheService(fdrApplication),
generatorCli: {
readme: getReadmeService(fdrApplication),
},
});
const server = app.listen(port);
console.log(`Mock FDR server running on http://localhost:${port}/`);
Expand Down
12 changes: 12 additions & 0 deletions servers/fdr/src/controllers/readme/getReadmeService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReadmeService } from "../../api/generated/api/resources/generatorCli/resources/readme/service/ReadmeService";
import { type FdrApplication } from "../../app";

export function getReadmeService(app: FdrApplication): ReadmeService {
return new ReadmeService({
generate: async (req, res) => {
// TODO: Implement me! This will take the same form as the CLI entrypoint.
// TODO: We will need to import generator-exec from here.
return;
},
});
}
4 changes: 4 additions & 0 deletions servers/fdr/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getDocsReadService } from "./controllers/docs/v1/getDocsReadService";
import { getDocsWriteService } from "./controllers/docs/v1/getDocsWriteService";
import { getDocsReadV2Service } from "./controllers/docs/v2/getDocsReadV2Service";
import { getDocsWriteV2Service } from "./controllers/docs/v2/getDocsWriteV2Service";
import { getReadmeService } from "./controllers/readme/getReadmeService";
import { getSnippetsFactoryService } from "./controllers/snippets/getSnippetsFactoryService";
import { getSnippetsService } from "./controllers/snippets/getSnippetsService";
import { getTemplatesService } from "./controllers/snippets/getTemplatesService";
Expand Down Expand Up @@ -111,6 +112,9 @@ async function startServer(): Promise<void> {
templates: getTemplatesService(app),
diff: getApiDiffService(app),
docsCache: getDocsCacheService(app),
generatorCli: {
readme: getReadmeService(app),
},
});
registerBackgroundTasks(app);
app.logger.info(`Listening for requests on port ${PORT}`);
Expand Down

0 comments on commit 968ed6d

Please sign in to comment.