@@ -25,25 +25,18 @@ const revisions = yaml.load(revisionsPrevYml) as Record<
2525 RevisionYmlEntry
2626> ;
2727
28- for ( const id in revisions ) {
29- delete revisions [ id ] . lang ;
30- delete revisions [ id ] . page ;
31- }
32-
3328for ( const lang of langEntries ) {
3429 for ( const page of lang . pages ) {
3530 const sections = await getMarkdownSections ( lang . id , page . slug ) ;
3631 for ( const section of sections ) {
37- if ( section . file === "-intro.md" ) continue ;
3832 if ( section . id in revisions ) {
39- revisions [ section . id ] . lang = lang . id ;
40- revisions [ section . id ] . page = page . slug ;
33+ revisions [ section . id ] . page = `${ lang . id } /${ page . slug } ` ;
4134 if ( ! revisions [ section . id ] . rev . some ( ( r ) => r . md5 === section . md5 ) ) {
4235 // ドキュメントが変更された場合
4336 console . log ( `${ section . id } has new md5: ${ section . md5 } ` ) ;
4437 revisions [ section . id ] . rev . push ( {
4538 md5 : section . md5 ,
46- commit,
39+ git : commit ,
4740 path : `public/docs/${ lang . id } /${ page . slug } /${ section . file } ` ,
4841 } ) ;
4942 }
@@ -54,22 +47,33 @@ for (const lang of langEntries) {
5447 rev : [
5548 {
5649 md5 : section . md5 ,
57- commit,
50+ git : commit ,
5851 path : `public/docs/${ lang . id } /${ page . slug } /${ section . file } ` ,
5952 } ,
6053 ] ,
61- lang : lang . id ,
62- page : page . slug ,
54+ page : `${ lang . id } /${ page . slug } ` ,
6355 } ;
6456 }
6557 }
6658 }
6759}
6860
69- const revisionsYml = yaml . dump ( revisions ) ;
61+ for ( const id in revisions ) {
62+ if ( ! existsSync ( join ( docsDir , revisions [ id ] . page ) ) ) {
63+ throw new Error (
64+ `The page slug ${ revisions [ id ] . page } previously used by section ${ id } does not exist. ` +
65+ `Please replace 'page: ${ revisions [ id ] . page } ' in public/docs/revisions.yml with new page path manually.`
66+ ) ;
67+ }
68+ }
69+
70+ const revisionsYml = yaml . dump ( revisions , {
71+ sortKeys : true ,
72+ noArrayIndent : true ,
73+ } ) ;
7074await writeFile (
7175 join ( docsDir , "revisions.yml" ) ,
72- "# This file will be updated by scripts/updateDocsRevisions.ts. Do not edit manually.\n" +
76+ "# This file will be updated by CI. Do not edit manually, unless CI failed .\n" +
7377 revisionsYml ,
7478 "utf-8"
7579) ;
0 commit comments