@redpanda-data/docs-extensions-and-macros 3.1.3 → 3.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.adoc CHANGED
@@ -79,9 +79,11 @@ antora:
79
79
 
80
80
  === Version fetcher
81
81
 
82
- This extension fetches the latest release tag and latest release commit hash from http://github.com/redpanda-data/redpanda. These values are then assigned to the `full-version` and `latest-release-commit` attributes of the latest version of the Redpanda documentation, respectively.
82
+ This extension fetches the latest release versions from GitHub.
83
83
 
84
- It also fetches the latest version of Redpanda Console and assigns it to the `latest-console-version` attribute in the playbook so that all components have access to it.
84
+ The latest Console version is made available to all versions of the Redpanda docs (`ROOT` component.)
85
+
86
+ The latest Redpanda version and the latest Redpanda Operator version is made available to the latest version of the `ROOT` component.
85
87
 
86
88
  ==== Environment variables
87
89
 
@@ -28,6 +28,8 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
28
28
 
29
29
  console.log(chalk.cyan('Indexing...'))
30
30
 
31
+ const unixTimestamp = Math.floor(Date.now() / 1000)
32
+
31
33
  // Select indexable pages
32
34
  const pages = contentCatalog.getPages((page) => {
33
35
  if (!page.out || page.asciidoc?.attributes?.noindex != null) return
@@ -45,7 +47,6 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
45
47
  }
46
48
  const urlPath = extractUrlPath(siteUrl)
47
49
 
48
- const documents = {}
49
50
  var algoliaCount = 0
50
51
 
51
52
  for (var i = 0; i < pages.length; i++) {
@@ -181,13 +182,13 @@ function generateIndex (playbook, contentCatalog, { indexLatestOnly = false, exc
181
182
  title: documentTitle,
182
183
  product: component.title,
183
184
  version: version,
184
- //image: image? image: '',
185
185
  text: text,
186
186
  breadcrumbs: breadcrumbs,
187
187
  intro: intro,
188
188
  objectID: urlPath + page.pub.url,
189
189
  titles: titles,
190
190
  keywords: keywords,
191
+ unixTimestamp: unixTimestamp,
191
192
  type: 'Doc',
192
193
  _tags: [tag, 'docs']
193
194
  }
@@ -19,15 +19,12 @@ const github = new OctokitWithRetries(githubOptions);
19
19
  var latestConsoleReleaseVersion;
20
20
 
21
21
  module.exports = async () => {
22
- await github.rest.repos.getLatestRelease({
23
- owner,
24
- repo,
25
- }).then((release => {
26
- const tag = release.data.tag_name;
27
- latestConsoleReleaseVersion = tag.replace('v','');
28
- })).catch((error => {
29
- console.error(error)
30
- return null
31
- }))
32
- return latestConsoleReleaseVersion;
22
+ try {
23
+ const release = await github.rest.repos.getLatestRelease({ owner, repo });
24
+ latestConsoleReleaseVersion = release.data.tag_name.replace('v','');
25
+ return latestConsoleReleaseVersion;
26
+ } catch (error) {
27
+ console.error(error);
28
+ return null;
29
+ }
33
30
  };
@@ -0,0 +1,28 @@
1
+ // Fetch the latest release version from GitHub
2
+ const { Octokit } = require("@octokit/rest");
3
+ const { retry } = require("@octokit/plugin-retry");
4
+ const OctokitWithRetries = Octokit.plugin(retry);
5
+ const owner = 'redpanda-data';
6
+ const repo = 'redpanda-operator';
7
+
8
+ let githubOptions = {
9
+ userAgent: 'Redpanda Docs',
10
+ baseUrl: 'https://api.github.com',
11
+ };
12
+
13
+ if (process.env.REDPANDA_GITHUB_TOKEN) {
14
+ githubOptions.auth = process.env.REDPANDA_GITHUB_TOKEN;
15
+ }
16
+
17
+ const github = new OctokitWithRetries(githubOptions);
18
+
19
+ module.exports = async () => {
20
+ try {
21
+ const release = await github.rest.repos.getLatestRelease({ owner, repo });
22
+ latestOperatorReleaseVersion = release.data.tag_name;
23
+ return latestOperatorReleaseVersion;
24
+ } catch (error) {
25
+ console.error(error);
26
+ return null;
27
+ }
28
+ };
@@ -0,0 +1,39 @@
1
+ // Fetch the latest release version from GitHub
2
+ const { Octokit } = require("@octokit/rest");
3
+ const { retry } = require("@octokit/plugin-retry");
4
+ const OctokitWithRetries = Octokit.plugin(retry);
5
+ const owner = 'redpanda-data';
6
+ const repo = 'redpanda';
7
+
8
+ let githubOptions = {
9
+ userAgent: 'Redpanda Docs',
10
+ baseUrl: 'https://api.github.com',
11
+ };
12
+
13
+ if (process.env.REDPANDA_GITHUB_TOKEN) {
14
+ githubOptions.auth = process.env.REDPANDA_GITHUB_TOKEN;
15
+ }
16
+
17
+ const github = new OctokitWithRetries(githubOptions);
18
+
19
+ module.exports = async () => {
20
+ try {
21
+ // Fetch the latest release
22
+ const release = await github.rest.repos.getLatestRelease({ owner, repo });
23
+ const tag = release.data.tag_name;
24
+ latestRedpandaReleaseVersion = tag.replace('v', '');
25
+
26
+ // Get reference of the tag
27
+ const tagRef = await github.rest.git.getRef({ owner, repo, ref: `tags/${tag}` });
28
+ const releaseSha = tagRef.data.object.sha;
29
+
30
+ // Get the tag object to extract the commit hash
31
+ const tagData = await github.rest.git.getTag({ owner, repo, tag_sha: releaseSha });
32
+ latestRedpandaReleaseCommitHash = tagData.data.object.sha.substring(0, 7);
33
+
34
+ return [latestRedpandaReleaseVersion, latestRedpandaReleaseCommitHash];
35
+ } catch (error) {
36
+ console.error(error);
37
+ return [null, null];
38
+ }
39
+ };
@@ -4,8 +4,9 @@ antora:
4
4
  - require: ./extensions/setLatestVersion.js
5
5
  */
6
6
 
7
- const GetLatestRedpandaVersion = require('./getLatestRedpandaVersion');
8
- const GetLatestConsoleVersion = require('./getLatestConsoleVersion');
7
+ const GetLatestRedpandaVersion = require('./get-latest-redpanda-version');
8
+ const GetLatestConsoleVersion = require('./get-latest-console-version');
9
+ const GetLatestOperatorVersion = require('./get-latest-operator-version');
9
10
  const chalk = require('chalk')
10
11
 
11
12
 
@@ -19,12 +20,16 @@ module.exports.register = function ({ config }) {
19
20
  try {
20
21
  const LatestRedpandaVersion = await GetLatestRedpandaVersion();
21
22
  const LatestConsoleVersion = await GetLatestConsoleVersion();
23
+ const LatestOperatorVersion = await GetLatestOperatorVersion();
22
24
  if (LatestRedpandaVersion.length !== 2 || !LatestRedpandaVersion[0]) {
23
25
  logger.warn('Failed to get the latest Redpanda version - using defaults');
24
26
  }
25
27
  if (!LatestConsoleVersion) {
26
28
  logger.warn(`Failed to get latest Console version from GitHub - using default`)
27
29
  }
30
+ if (!LatestOperatorVersion) {
31
+ logger.warn(`Failed to get latest Operator version from GitHub - using default`)
32
+ }
28
33
  const components = await contentCatalog.getComponents();
29
34
  for (let i = 0; i < components.length; i++) {
30
35
  let component = components[i];
@@ -50,6 +55,11 @@ module.exports.register = function ({ config }) {
50
55
  component.latest.asciidoc.attributes['full-version'] = `${LatestRedpandaVersion[0]}`;
51
56
  component.latest.asciidoc.attributes['latest-release-commit'] = `${LatestRedpandaVersion[1]}`;
52
57
  console.log(`${chalk.green('Set the latest Redpanda version to')} ${chalk.bold(LatestRedpandaVersion[0])} ${chalk.bold(LatestRedpandaVersion[1])}`)
58
+
59
+ if (!LatestOperatorVersion) continue;
60
+
61
+ component.latest.asciidoc.attributes['latest-operator-version'] = `${LatestOperatorVersion}`;
62
+ console.log(`${chalk.green('Set the latest Redpanda Operator version to')} ${chalk.bold(LatestOperatorVersion)}`)
53
63
  }
54
64
  } catch(error) {
55
65
  logger.warn(error)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",
@@ -1,46 +0,0 @@
1
- // Fetch the latest release version from GitHub
2
- const { Octokit } = require("@octokit/rest");
3
- const { retry } = require("@octokit/plugin-retry");
4
- const OctokitWithRetries = Octokit.plugin(retry);
5
- const owner = 'redpanda-data';
6
- const repo = 'redpanda';
7
-
8
- let githubOptions = {
9
- userAgent: 'Redpanda Docs',
10
- baseUrl: 'https://api.github.com',
11
- };
12
-
13
- if (process.env.REDPANDA_GITHUB_TOKEN) {
14
- githubOptions.auth = process.env.REDPANDA_GITHUB_TOKEN;
15
- }
16
-
17
- const github = new OctokitWithRetries(githubOptions);
18
-
19
- var latestRedpandaReleaseVersion;
20
- var latestRedpandaReleaseCommitHash;
21
-
22
- module.exports = async () => {
23
- await github.rest.repos.getLatestRelease({
24
- owner,
25
- repo,
26
- }).then(async function(release) {
27
- const tag = release.data.tag_name;
28
- latestRedpandaReleaseVersion = tag.replace('v','');
29
- await github.rest.git.getRef({
30
- owner,
31
- repo,
32
- ref: `/tags/${tag}`,
33
- }).then(async function(tagRef) {
34
- const releaseSha = tagRef.data.object.sha;
35
- await github.rest.git.getTag({
36
- owner,
37
- repo,
38
- tag_sha: releaseSha,
39
- }).then((tag => latestRedpandaReleaseCommitHash = tag.data.object.sha.substring(0, 7)))
40
- })
41
- }).catch((error => {
42
- console.error(error)
43
- return null
44
- }))
45
- return [latestRedpandaReleaseVersion, latestRedpandaReleaseCommitHash];
46
- };