@@ -3,8 +3,9 @@ import yaml from 'js-yaml'
33import path from 'path'
44
55import { allVersions } from '../../../../lib/all-versions.js'
6- const OPEN_API_RELEASES_DIR = path . join ( '..' , 'github' , '/app/api/description/config/releases' )
76
7+ const OPEN_API_RELEASES_DIR = '../github/app/api/description/config/releases'
8+ const metaData = JSON . parse ( await readFile ( 'src/rest/data/meta.json' , 'utf8' ) )
89// Gets the full list of unpublished + active, deprecated + active,
910// or active schemas from the github/github repo
1011// `openApiReleaseDir` is the path to the `app/api/description/config/releases`
@@ -24,8 +25,21 @@ export async function getSchemas(directory = OPEN_API_RELEASES_DIR) {
2425 const content = await readFile ( path . join ( directory , file ) , 'utf8' )
2526 const yamlContent = yaml . load ( content )
2627
28+ const releaseMatch = Object . keys ( metaData . versionMapping ) . find ( ( name ) =>
29+ fileBaseName . startsWith ( name )
30+ )
31+ if ( ! releaseMatch ) {
32+ throw new Error (
33+ `🛑 The file ${ fileBaseName } does not match any known docs version name. (not one of ${ Object . keys (
34+ metaData . versionMapping
35+ ) } )`
36+ )
37+ }
38+ const docsName =
39+ metaData . versionMapping [ fileBaseName ] ||
40+ fileBaseName . replace ( releaseMatch , metaData . versionMapping [ releaseMatch ] )
2741 const isDeprecatedInDocs = ! Object . keys ( allVersions ) . find (
28- ( version ) => allVersions [ version ] . openApiVersionName === fileBaseName
42+ ( version ) => allVersions [ version ] . openApiVersionName === docsName
2943 )
3044 if ( ! yamlContent . published ) {
3145 unpublished . push ( newFileName )
0 commit comments