File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Generate Docs
2+
3+ on :
4+ workflow_dispatch
5+
6+ jobs :
7+ generate-docs :
8+ runs-on : " ubuntu-latest"
9+ timeout-minutes : 30
10+ steps :
11+ - uses : actions/checkout@v4
12+ with :
13+ fetch-depth : 0
14+
15+ - name : Install Node.js
16+ uses : actions/setup-node@v4
17+ with :
18+ node-version : lts/*
19+
20+ - name : Install dependencies
21+ shell : bash
22+ run : npm i
23+
24+ - name : Run Generate Docs Command
25+ shell : bash
26+ run : npm run generate-plugin-docs
27+
28+ - name : test
29+ shell : bash
30+ run : git diff --name-only
Original file line number Diff line number Diff line change @@ -315,12 +315,29 @@ sidebar_label: ${sidebarLabel}${plugin.isExperimental ? ' 🧪' : ''}
315315${ readme } `. trim ( ) ;
316316}
317317
318+ async function invalidateJSDELIVRCache ( url ) {
319+ const rsp = await fetch ( url . replace ( 'cdn' , 'purge' ) , { method : 'GET' } ) ;
320+ let err = null ;
321+ let rspData = null ;
322+ try {
323+ rspData = await rsp . json ( ) ;
324+ } catch ( e ) {
325+ err = e ;
326+ }
327+ // @ts -ignore
328+ if ( err !== null || rspData . status !== 'finished' ) {
329+ console . error ( err ) ;
330+ throw new Error ( "Failed to invalidate JSDELIVR cache for " + url ) ;
331+ }
332+ }
333+
318334/**
319335 * @param {PluginApi } plugin
320336 * @returns {Promise<string> }
321337 */
322338async function getReadme ( plugin ) {
323339 const url = `https://cdn.jsdelivr.net/npm/${ plugin . npmScope } /${ ! plugin . isCore ? plugin . id : 'core' } @${ plugin . tag ?? tag } /${ plugin . isCore ? `${ plugin . id } .md` : 'README.md' } ` ;
340+ await invalidateJSDELIVRCache ( url ) ;
324341 const rsp = await fetch ( url ) ;
325342 return rsp . text ( ) ;
326343}
@@ -331,11 +348,13 @@ async function getReadme(plugin) {
331348 */
332349async function getPkgJsonData ( plugin ) {
333350 const url = `https://cdn.jsdelivr.net/npm/${ plugin . npmScope } /${ ! plugin . isCore ? plugin . id : 'core' } @${ plugin . tag ?? tag } /package.json` ;
351+ await invalidateJSDELIVRCache ( url ) ;
334352 const rsp = await fetch ( url ) ;
335353 return rsp . json ( ) ;
336354}
337355
338356async function main ( ) {
357+ console . log ( "Updating Plugin API Files..." ) ;
339358 await Promise . all ( pluginApis . map ( buildPluginApiDocs ) ) ;
340359 console . log ( `Plugin API Files Updated 🎸` ) ;
341360}
You can’t perform that action at this time.
0 commit comments