Skip to content

Commit

Permalink
fix: migrating docs.yml to 0.15.0-rc0 should fail if custom-domain is…
Browse files Browse the repository at this point in the history
… an array (#3467)
  • Loading branch information
abvthecity authored Apr 25, 2024
1 parent f3d1b1a commit 3a222a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
loadRawGeneratorsConfiguration
} from "./generators-configuration";
import { PathModificationStrategy } from "./generators-configuration/convertLegacyGeneratorsConfiguration";
import { migrateDocsInstances } from "./migrateDocsInstances";

const APIS_DIRECTORY = "apis";

Expand Down Expand Up @@ -93,7 +94,7 @@ async function migrateAndWriteDocsYml({
}
const convertedDocsConfig = convertLegacyDocsConfig({
docsConfiguration,
docsURLs,
docsURLs: migrateDocsInstances(docsURLs),
apiName
});
const absolutePathToDocsConfig = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getAbsolutePathToDocsFolder, getAbsolutePathToDocsYaml, loadRawDocsConf
import { convertLegacyDocsConfig } from "./docs-config/convertLegacyDocsConfig";
import { getAbsolutePathToGeneratorsConfiguration, loadRawGeneratorsConfiguration } from "./generators-configuration";
import { convertLegacyGeneratorsConfiguration } from "./generators-configuration/convertLegacyGeneratorsConfiguration";
import { migrateDocsInstances } from "./migrateDocsInstances";

/**
* fern/ <------ path to fern directory
Expand Down Expand Up @@ -48,7 +49,7 @@ async function migrateAndWriteDocsYml({
}
const convertedDocsConfig = convertLegacyDocsConfig({
docsConfiguration,
docsURLs,
docsURLs: migrateDocsInstances(docsURLs),
apiName: undefined
});
const absolutePathToDocsConfig = getAbsolutePathToDocsYaml({ absolutePathToWorkspace });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { docsYml } from "@fern-api/configuration";
import { DocsURL } from "./docs-config";

export function migrateDocsInstances(docsURLs: docsYml.RawSchemas.DocsInstances[]): DocsURL[] {
return docsURLs.map((docsURL) => {
if (Array.isArray(docsURL.customDomain)) {
throw new Error("Expected custom-domain to be a string, but it was an array.");
}
return {
...docsURL,
customDomain: docsURL.customDomain
};
});
}

0 comments on commit 3a222a5

Please sign in to comment.