Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

remove-static-files.js 1.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  1. #!/usr/bin/env node
  2. const fs = require('fs')
  3. const path = require('path')
  4. const rimraf = require('rimraf').sync
  5. const allVersions = require('../../lib/all-versions')
  6. const graphqlDataDir = path.join(process.cwd(), 'data/graphql')
  7. const webhooksStaticDir = path.join(process.cwd(), 'lib/webhooks/static')
  8. const graphqlStaticDir = path.join(process.cwd(), 'lib/graphql/static')
  9. const restDecoratedDir = path.join(process.cwd(), 'lib/rest/static/decorated')
  10. const restDereferencedDir = path.join(process.cwd(), 'lib/rest/static/dereferenced')
  11. // [start-readme]
  12. //
  13. // This script removes the static GraphQL, REST, and webhook files for any deprecated GHES versions.
  14. //
  15. // [end-readme]
  16. const supportedEnterpriseVersions = Object.values(allVersions).filter(v => v.plan === 'enterprise-server')
  17. // webhooks and GraphQL
  18. const supportedMiscVersions = supportedEnterpriseVersions.map(v => v.miscVersionName)
  19. // The miscBaseName is the same for all GHES versions (currently `ghes-`), so we can just grab the first one
  20. const miscBaseName = supportedEnterpriseVersions.map(v => v.miscBaseName)[0]
  21. ;[graphqlDataDir, graphqlStaticDir, webhooksStaticDir].forEach(dir => {
  22. removeFiles(dir, miscBaseName, supportedMiscVersions)
  23. })
  24. // REST
  25. const supportedOpenApiVersions = supportedEnterpriseVersions.map(v => v.openApiVersionName)
  26. // The openApiBaseName is the same for all GHES versions (currently `ghes-`), so we can just grab the first one
  27. const openApiBaseName = supportedEnterpriseVersions.map(v => v.openApiBaseName)[0]
  28. ;[restDecoratedDir, restDereferencedDir].forEach(dir => {
  29. removeFiles(dir, openApiBaseName, supportedOpenApiVersions)
  30. })
  31. function removeFiles (dir, baseName, supportedVersions) {
  32. fs.readdirSync(dir)
  33. .filter(file => file.includes(baseName))
  34. .filter(file => supportedVersions.every(version => !file.includes(version)))
  35. .forEach(file => {
  36. const fullPath = path.join(dir, file)
  37. console.log(`removing ${fullPath}`)
  38. rimraf(fullPath)
  39. })
  40. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...