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

release-banner.js 2.1 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
50
51
52
53
54
55
56
57
58
59
60
  1. #!/usr/bin/env node
  2. const fs = require('fs')
  3. const path = require('path')
  4. const program = require('commander')
  5. const yaml = require('js-yaml')
  6. const allVersions = require('../../lib/all-versions')
  7. const releaseCandidateFile = 'data/variables/release_candidate.yml'
  8. const releaseCandidateYaml = path.join(process.cwd(), releaseCandidateFile)
  9. const allowedActions = ['create', 'remove']
  10. // [start-readme]
  11. //
  12. // This script creates or removes a release candidate banner for a specified version.
  13. //
  14. // [end-readme]
  15. program
  16. .description('Create or remove a release candidate banner for the provided docs version.')
  17. // The following two settings let us use `version` as a flag without clashing with reserved opts
  18. .storeOptionsAsProperties(false)
  19. .passCommandToAction(false)
  20. .option(`-a, --action <${allowedActions.join(' or ')}>`, 'Create or remove the banner.')
  21. .option('-v, --version <version>', 'The version the banner applies to. Must be in <plan@release> format.')
  22. .parse(process.argv)
  23. const options = program.opts()
  24. if (!allowedActions.includes(options.action)) {
  25. console.log(`Error! You must specify --action <${allowedActions.join(' or ')}>.`)
  26. process.exit(1)
  27. }
  28. if (!(Object.keys(allVersions).includes(options.version))) {
  29. console.log('Error! You must specify --version with the full name of a supported version, e.g., enterprise-server@2.22.')
  30. process.exit(1)
  31. }
  32. // Load the release candidate variable
  33. const releaseCandidateData = yaml.safeLoad(fs.readFileSync(releaseCandidateYaml, 'utf8'))
  34. // Create or remove the variable
  35. if (options.action === 'create') {
  36. releaseCandidateData.version = options.version
  37. }
  38. if (options.action === 'remove') {
  39. releaseCandidateData.version = ''
  40. }
  41. // Update the file
  42. fs.writeFileSync(releaseCandidateYaml, yaml.safeDump(releaseCandidateData))
  43. // Display next steps
  44. console.log(`\nDone! Commit the update to ${releaseCandidateFile}. This ${options.action}s the banner for ${options.version}.
  45. - To change the banner text, you can edit header.notices.release_candidate in data/ui.yml.
  46. - To change the banner styling, you can edit includes/header-notification.html.
  47. `)
Tip!

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

Comments

Loading...