@@ -2,8 +2,8 @@ import fsp from 'fs/promises';
22import path , { resolve } from 'path' ;
33
44import {
5+ CLIENTS ,
56 configureGitHubAuthor ,
6- ensureGitHubToken ,
77 exists ,
88 getOctokit ,
99 gitBranchExists ,
@@ -22,16 +22,45 @@ import { getClientsConfigField } from '../../config.ts';
2222import { commitStartRelease } from './text.ts' ;
2323
2424async function handleSpecFiles ( spec : SpecsToPush , tempGitDir : string ) : Promise < void > {
25- const pathToSpecs = toAbsolutePath ( `${ tempGitDir } /${ spec . output } ` ) ;
26-
27- await run ( `cp ${ toAbsolutePath ( 'specs/bundled/README.md' ) } ${ pathToSpecs } ` ) ;
28- await run ( `cp ${ toAbsolutePath ( 'specs/major-breaking-changes-rename.json' ) } ${ pathToSpecs } ` ) ;
29- await run ( `cp ${ toAbsolutePath ( 'config/clients.config.json' ) } ${ pathToSpecs } ` ) ;
30- await run ( `cp ${ toAbsolutePath ( 'docs/bundled/*.json' ) } ${ pathToSpecs } ` ) ;
31- await run ( `cp ${ toAbsolutePath ( 'docs/bundled/*.yml' ) } ${ pathToSpecs } ` ) ;
32- await run ( `cp ${ toAbsolutePath ( 'docs/versions-history-with-sla-and-support-policy.json' ) } ${ pathToSpecs } ` ) ;
25+ const output = toAbsolutePath ( `${ tempGitDir } /${ spec . output } ` ) ;
26+
27+ if ( spec . includeSnippets ) {
28+ await run ( `cp ${ toAbsolutePath ( 'docs/bundled/*-snippets.json' ) } ${ output } ` ) ;
29+ }
30+
31+ if ( spec . includeSLA ) {
32+ await run ( `cp ${ toAbsolutePath ( 'specs/bundled/README.md' ) } ${ output } ` ) ;
33+ await run ( `cp ${ toAbsolutePath ( 'specs/major-breaking-changes-rename.json' ) } ${ output } ` ) ;
34+ await run ( `cp ${ toAbsolutePath ( 'config/clients.config.json' ) } ${ output } ` ) ;
35+ await run ( `cp ${ toAbsolutePath ( 'docs/versions-history-with-sla-and-support-policy.json' ) } ${ output } ` ) ;
36+ }
37+
3338 // adblock extensions ban words like `analytics` so we use a different file name just so the doc dans render it
34- await run ( `mv ${ pathToSpecs } /analytics.yml ${ pathToSpecs } /searchstats.yml` ) ;
39+ if ( spec . ext === 'yml' ) {
40+ await run ( `mv ${ output } /analytics.yml ${ output } /searchstats.yml` ) ;
41+ }
42+
43+ for ( const client of CLIENTS ) {
44+ const pathToBundledSpec = toAbsolutePath ( `docs/bundled/${ client } .${ spec . ext } ` ) ;
45+
46+ if ( ! ( await exists ( pathToBundledSpec ) ) ) {
47+ continue ;
48+ }
49+
50+ const outputFile = `${ output } /${ client } .${ spec . ext } ` ;
51+
52+ await run ( `cp ${ pathToBundledSpec } ${ outputFile } ` ) ;
53+
54+ if ( spec . placeholderVariables ) {
55+ let file = await fsp . readFile ( outputFile , 'utf8' ) ;
56+
57+ for ( const [ k , v ] of Object . entries ( spec . placeholderVariables ) ) {
58+ file = file . replace ( k , v ) ;
59+ }
60+
61+ await fsp . writeFile ( outputFile , file ) ;
62+ }
63+ }
3564}
3665
3766async function handleGuideFiles ( guide : GuidesToPush , tempGitDir : string ) : Promise < void > {
@@ -80,8 +109,6 @@ async function handleGuideFiles(guide: GuidesToPush, tempGitDir: string): Promis
80109}
81110
82111async function pushToRepository ( repository : string , config : RepositoryConfiguration ) : Promise < void > {
83- const githubToken = ensureGitHubToken ( ) ;
84-
85112 const lastCommitMessage = await run ( 'git log -1 --format="%s"' ) ;
86113 const author = ( await run ( 'git log -1 --format="Co-authored-by: %an <%ae>"' ) ) . trim ( ) ;
87114 const coAuthors = ( await run ( 'git log -1 --format="%(trailers:key=Co-authored-by)"' ) )
@@ -100,8 +127,7 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
100127 const tempGitDir = resolve ( process . env . RUNNER_TEMP ! || toAbsolutePath ( 'foo/local/test' ) , repository ) ;
101128 await fsp . rm ( tempGitDir , { force : true , recursive : true } ) ;
102129
103- const githubURL = `https://${ githubToken } :${ githubToken } @github.com/${ OWNER } /${ repository } ` ;
104- await run ( `git clone --depth 1 ${ githubURL } ${ tempGitDir } ` ) ;
130+ await run ( `gh repo clone ${ OWNER } /${ repository } ${ tempGitDir } ` ) ;
105131
106132 for ( const task of config . tasks ) {
107133 await run ( `git checkout ${ config . baseBranch } ` , { cwd : tempGitDir } ) ;
0 commit comments