mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Align local version markers and GitHub Actions with Node 24, switch the default test entrypoint to the maintained Vitest runner, and replace pnpm-incompatible npm helpers in repo scripts. This also removes the obsolete AVA plus esm path and excludes disabled test fixtures from generic Vitest discovery so CI reflects the supported test surface.
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
import fs from 'fs-extra'
|
|
import 'dotenv/config.js'
|
|
import axios from 'axios'
|
|
|
|
import {
|
|
sitemapLocation,
|
|
sitemapIndexFileName,
|
|
} from '~/helpers/constants.js'
|
|
|
|
import { parseSitemapXml } from '~/helpers/api/sitemap/parse.js'
|
|
|
|
|
|
;(async () => {
|
|
|
|
// Build Sitemap Index URL
|
|
const sitemapIndexUrl = new URL( `${ sitemapLocation.split('static')[1] }${ sitemapIndexFileName }`, process.env.PUBLIC_API_DOMAIN )
|
|
|
|
// Fetch Sitemap Index
|
|
const sitemapIndexXML = await axios.get( sitemapIndexUrl.href ).then( response => response.data )
|
|
|
|
// Save Sitemap Index
|
|
const sitemapIndexFilePath = `${ sitemapLocation }${ sitemapIndexFileName }`
|
|
await fs.writeFile( sitemapIndexFilePath, sitemapIndexXML )
|
|
|
|
const urlEntries = parseSitemapXml( sitemapIndexXML )
|
|
|
|
|
|
// Fetch each sitemap
|
|
for ( const entry of urlEntries ) {
|
|
|
|
// Build Sitemap Index URL
|
|
const sitemapUrl = new URL( entry.loc )
|
|
const apiSitemapUrl = new URL( sitemapUrl.pathname, process.env.PUBLIC_API_DOMAIN )
|
|
|
|
// sitemapUrl.origin = process.env.PUBLIC_API_DOMAIN
|
|
|
|
// Fetch Sitemap Index
|
|
const sitemapXML = await axios.get( apiSitemapUrl.href ).then( response => response.data )
|
|
|
|
// const sitemap = parse( sitemapXML )
|
|
|
|
// console.log( 'sitemap', sitemap )
|
|
|
|
// console.log( 'apiSitemapUrl', apiSitemapUrl )
|
|
|
|
const sitemapFileName = apiSitemapUrl.pathname.split('/')[1]
|
|
const sitemapIndexFilePath = `${ sitemapLocation }${ sitemapFileName }`
|
|
|
|
// Save file
|
|
await fs.writeFile( sitemapIndexFilePath, sitemapXML )
|
|
}
|
|
|
|
|
|
process.exit()
|
|
})()
|