Skip to content

Commit

Permalink
(chore, internal): move docs-config to use local typescript sdk gen (
Browse files Browse the repository at this point in the history
…#3047)

* docs-config -> local

* lint fix

* prettier

* monorepo lint

* prettier ignore

* fix

* fix compile

---------

Co-authored-by: dsinghvi <[email protected]>
  • Loading branch information
abvthecity and dsinghvi authored Feb 28, 2024
1 parent 04be316 commit 2cf4c5a
Show file tree
Hide file tree
Showing 196 changed files with 3,674 additions and 88 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ generated
bundle.c?js
.pnp*
packages/ir-sdk/**
packages/docs-config/**
packages/cli/openapi-ir-sdk/**
packages/docs-config-sdk/**
packages/seed/**
generators/typescript/utils/core-utilities/**
seed/**
Expand Down
45 changes: 29 additions & 16 deletions .pnp.cjs

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

Binary file not shown.
10 changes: 0 additions & 10 deletions fern/apis/docs-config/generators.yml

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"seed:local": "yarn workspace @fern-api/seed-cli dist:cli && node $(yarn workspace @fern-api/seed-cli bin seed)",
"ir:generate": "yarn workspace @fern-api/ir-sdk generate",
"openapi-ir:generate": "yarn workspace @fern-api/openapi-ir-sdk generate",
"seed-config:generate": "yarn workspace @fern-api/seed-cli generate"
"seed-config:generate": "yarn workspace @fern-api/seed-cli generate",
"docs-config:generate": "yarn workspace @fern-api/docs-config-sdk generate"
},
"devDependencies": {
"@babel/core": "^7.23.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"dependencies": {
"@fern-api/config-management-commons": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-config-sdk": "workspace:*",
"@fern-api/fdr-sdk": "0.50.8-1-gace1ff5",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-fern/docs-config": "0.0.76",
"js-yaml": "^4.1.0",
"tinycolor2": "^1.6.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Audiences } from "@fern-api/config-management-commons";
import { DocsV1Write } from "@fern-api/fdr-sdk";
import { AbsoluteFilePath, RelativeFilePath } from "@fern-api/fs-utils";
import { DocsInstances, TabConfig, VersionAvailability } from "@fern-fern/docs-config/api";
import { DocsInstances, TabConfig, VersionAvailability } from "@fern-api/docs-config-sdk";

export declare type WithoutQuestionMarks<T> = {
[K in keyof Required<T>]: undefined extends T[K] ? T[K] | undefined : T[K];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertNever } from "@fern-api/core-utils";
import { FernDocsConfig as RawDocs } from "@fern-api/docs-config-sdk";
import { DocsV1Write } from "@fern-api/fdr-sdk";
import { TaskContext } from "@fern-api/task-context";
import { FernDocsConfig as RawDocs } from "@fern-fern/docs-config";
import tinycolor from "tinycolor2";

export function convertColorsConfiguration(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { assertNever } from "@fern-api/core-utils";
import { FernDocsConfig as RawDocs, NavigationConfig, Serializer, VersionConfig } from "@fern-api/docs-config-sdk";
import { DocsV1Write } from "@fern-api/fdr-sdk";
import { AbsoluteFilePath, dirname, resolve } from "@fern-api/fs-utils";
import { TaskContext } from "@fern-api/task-context";
import { FernDocsConfig as RawDocs } from "@fern-fern/docs-config";
import { NavigationConfig, VersionConfig } from "@fern-fern/docs-config/api";
import { VersionFileConfig as RawVersionFileConfigSerializer } from "@fern-fern/docs-config/serialization";
import { readFile } from "fs/promises";
import yaml from "js-yaml";
import { convertColorsConfiguration } from "./convertColorsConfiguration";
Expand Down Expand Up @@ -130,8 +128,18 @@ export async function parseDocsConfiguration({
logo,
favicon,
backgroundImage,
colors: convertColorsConfiguration(colors ?? {}, context),
navbarLinks,
colors: convertColorsConfiguration(
colors ?? {
accentPrimary: undefined,
background: undefined
},
context
),
navbarLinks: navbarLinks?.map((navbarLink) => ({
type: navbarLink.type,
text: navbarLink.text,
url: navbarLink.href ?? navbarLink.url ?? "/"
})),
typography,
layout: convertLayoutConfig(layout),
css,
Expand Down Expand Up @@ -164,7 +172,7 @@ async function convertCssConfig(

function isRemoteJsConfig(
config: RawDocs.JsRemoteConfig | RawDocs.JsFileConfigSettings
): config is DocsV1Write.JsRemoteConfig {
): config is RawDocs.JsRemoteConfig {
return Object.hasOwn(config, "url");
}

Expand Down Expand Up @@ -284,7 +292,7 @@ async function getNavigationConfiguration({
for (const version of versions) {
const absoluteFilepathToVersionFile = resolve(absolutePathToFernFolder, version.path);
const content = yaml.load((await readFile(absoluteFilepathToVersionFile)).toString());
const result = await RawVersionFileConfigSerializer.parseOrThrow(content);
const result = await Serializer.VersionFileConfig.parseOrThrow(content);
const navigation = await convertNavigationConfiguration({
rawNavigationConfig: result.navigation,
absolutePathToFernFolder,
Expand Down Expand Up @@ -506,8 +514,8 @@ async function convertNavigationItem({
if (isRawLinkConfig(rawConfig)) {
return {
type: "link",
text: rawConfig.text,
url: rawConfig.url
text: rawConfig.link,
url: rawConfig.href
};
}
assertNever(rawConfig);
Expand Down Expand Up @@ -543,7 +551,7 @@ function isRawApiSectionConfig(item: RawDocs.NavigationItem): item is RawDocs.Ap

function isRawLinkConfig(item: RawDocs.NavigationItem): item is RawDocs.LinkConfiguration {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
return (item as RawDocs.LinkConfiguration).url != null;
return (item as RawDocs.LinkConfiguration).link != null;
}

async function convertImageReference({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"references": [
{ "path": "../../../commons/core-utils" },
{ "path": "../../../commons/fs-utils" },
{ "path": "../../../docs-config-sdk" },
{ "path": "../../task-context" },
{ "path": "../commons" }
]
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
},
"dependencies": {
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-config-sdk": "workspace:*",
"@fern-api/docs-configuration": "workspace:*",
"@fern-api/fdr-sdk": "0.50.8-1-gace1ff5",
"@fern-api/fs-utils": "workspace:*",
"@fern-api/ir-generator": "workspace:*",
"@fern-api/register": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-api/workspace-loader": "workspace:*",
"@fern-fern/docs-config": "0.0.76",
"cors": "^2.8.5",
"express": "^4.18.2",
"uuid": "^9.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docs-preview/src/previewDocs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assertNever, entries } from "@fern-api/core-utils";
import { TabConfig, VersionAvailability } from "@fern-api/docs-config-sdk";
import {
DocsNavigationConfiguration,
DocsNavigationItem,
Expand All @@ -22,7 +23,6 @@ import { generateIntermediateRepresentation } from "@fern-api/ir-generator";
import { convertIrToFdrApi } from "@fern-api/register";
import { TaskContext } from "@fern-api/task-context";
import { APIWorkspace, convertOpenApiWorkspaceToFernWorkspace, DocsWorkspace } from "@fern-api/workspace-loader";
import { TabConfig, VersionAvailability } from "@fern-fern/docs-config/api";
import { v4 as uuidv4 } from "uuid";

export async function getPreviewDocsDefinition({
Expand Down
1 change: 1 addition & 0 deletions packages/cli/docs-preview/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"references": [
{ "path": "../../commons/core-utils" },
{ "path": "../../commons/fs-utils" },
{ "path": "../../docs-config-sdk" },
{ "path": "../config-management/docs-configuration" },
{ "path": "../generation/ir-generator" },
{ "path": "../register" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@fern-api/config-management-commons": "workspace:*",
"@fern-api/core": "workspace:*",
"@fern-api/core-utils": "workspace:*",
"@fern-api/docs-config-sdk": "workspace:*",
"@fern-api/docs-configuration": "workspace:*",
"@fern-api/fdr-sdk": "0.50.8-1-gace1ff5",
"@fern-api/fs-utils": "workspace:*",
Expand All @@ -42,7 +43,6 @@
"@fern-api/register": "workspace:*",
"@fern-api/task-context": "workspace:*",
"@fern-api/workspace-loader": "workspace:*",
"@fern-fern/docs-config": "0.0.76",
"@fern-fern/fiddle-sdk": "^0.0.411",
"axios": "^0.28.0",
"chalk": "^5.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FernToken } from "@fern-api/auth";
import { createFdrService } from "@fern-api/core";
import { assertNever, entries, isNonNullish } from "@fern-api/core-utils";
import { FernDocsConfig, SnippetsConfiguration, TabConfig, VersionAvailability } from "@fern-api/docs-config-sdk";
import {
DocsNavigationConfiguration,
DocsNavigationItem,
Expand All @@ -18,8 +19,6 @@ import { AbsoluteFilePath, dirname, relative } from "@fern-api/fs-utils";
import { registerApi } from "@fern-api/register";
import { TaskContext } from "@fern-api/task-context";
import { DocsWorkspace, FernWorkspace } from "@fern-api/workspace-loader";
import { FernDocsConfig } from "@fern-fern/docs-config";
import { SnippetsConfiguration, TabConfig, VersionAvailability } from "@fern-fern/docs-config/api";
import axios from "axios";
import chalk from "chalk";
import { readFile } from "fs/promises";
Expand Down Expand Up @@ -693,7 +692,12 @@ async function convertNavigationItem({
token,
audiences: item.audiences,
snippetsConfig: convertDocsSnippetsConfigurationToFdr({
snippetsConfiguration: item.snippetsConfiguration ?? {}
snippetsConfiguration: item.snippetsConfiguration ?? {
python: undefined,
typescript: undefined,
go: undefined,
java: undefined
}
})
});
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{ "path": "../../../../commons/core-utils" },
{ "path": "../../../../commons/fs-utils" },
{ "path": "../../../../core" },
{ "path": "../../../../docs-config-sdk" },
{ "path": "../../../../ir-sdk" },
{ "path": "../../../auth" },
{ "path": "../../../config-management/commons" },
Expand Down
Loading

0 comments on commit 2cf4c5a

Please sign in to comment.