Skip to content

Commit

Permalink
feat: add auto-delete of retired docs versions
Browse files Browse the repository at this point in the history
  • Loading branch information
btlghrants committed Jan 5, 2024
1 parent 78b560d commit 77fd68e
Show file tree
Hide file tree
Showing 25 changed files with 81 additions and 5,070 deletions.
26 changes: 23 additions & 3 deletions build/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as util from 'node:util'
import * as child_process from 'node:child_process';
import * as semver from 'semver';
import * as yaml from 'yaml';
import { glob } from 'glob';
import { heredoc } from './heredoc.mjs';

const exec = util.promisify(child_process.exec);
Expand Down Expand Up @@ -103,8 +104,8 @@ await activity(`Search core repo versions`, async (log) => {
return list
}, [])

const ongoing = majmins.slice(0, RUN.cutoff)
const retired = majmins.slice(RUN.cutoff)
let ongoing = majmins.slice(0, RUN.cutoff)
RUN.retired = majmins.slice(RUN.cutoff)

RUN.versions = sort.reduce((list, ver) => {
const mm = majmin(ver)
Expand All @@ -114,10 +115,29 @@ await activity(`Search core repo versions`, async (log) => {
RUN.versions.push("main")

log.push(['ongoing', ongoing])
log.push(['retired', retired])
log.push(['retired', RUN.retired])
log.push(['versions', RUN.versions])
})

await activity(`Nuke retired version content`, async (log) => {
for (const majmin of RUN.retired) {
const contentGlob = `${RUN.work}/content/en/v${majmin}.*`
const staticGlob = `${RUN.work}/static/v${majmin}.*`

const contentDirs = await glob(contentGlob)
const staticDirs = await glob(staticGlob)

contentDirs.forEach(async (path) => {
await fs.rm(path, {recursive: true, force: true})
log.push([majmin, path])
})

staticDirs.forEach(async (path) => {
await fs.rm(path, {recursive: true, force: true})
log.push([majmin, path])
})
}
})

for (const version of RUN.versions) {
RUN.version = version
Expand Down
1 change: 1 addition & 0 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"@jest/globals": "29.7.0",
"commander": "^11.1.0",
"glob": "^10.3.10",
"jest": "29.7.0",
"semver": "^7.5.4",
"yaml": "^2.3.4"
Expand Down
Loading

0 comments on commit 77fd68e

Please sign in to comment.