@redpanda-data/docs-extensions-and-macros 3.7.2 → 3.7.4

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.
@@ -6,7 +6,7 @@ module.exports.register = function ({ config }) {
6
6
  this.once('contentClassified', ({ siteCatalog, contentCatalog }) => {
7
7
  const redpandaConnect = contentCatalog.getComponents().find(component => component.name === 'redpanda-connect')
8
8
  if (!redpandaConnect || !redpandaConnect.latest) {
9
- logger.info('Could not find the redpanda-connect component')
9
+ logger.warn('Could not find the redpanda-connect component. Skipping category creation.')
10
10
  return
11
11
  }
12
12
 
@@ -116,7 +116,8 @@ module.exports.register = function ({ config }) {
116
116
  redpandaConnect.latest.asciidoc.attributes.driverSupportData = driverSupportData
117
117
  redpandaConnect.latest.asciidoc.attributes.cacheSupportData = cacheSupportData
118
118
 
119
- logger.info(`Added Redpanda Connect data to latest Asciidoc object: ${JSON.stringify({ connectCategoriesData, flatComponentsData }, null, 2)}`)
119
+ logger.info(`Added Redpanda Connect data to latest Asciidoc object.`)
120
+ logger.debug(`${JSON.stringify({ connectCategoriesData, flatComponentsData }, null, 2)}`)
120
121
  } catch (error) {
121
122
  logger.error(`Error processing Redpanda Connect files: ${error.message}`)
122
123
  }
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
+ const semver = require('semver');
2
3
 
3
4
  module.exports.register = function () {
4
- const sanitizeAttributeValue = (value) => String(value).replace("@", "");
5
5
  this.on('contentClassified', ({ contentCatalog }) => {
6
6
  const componentVersionTable = contentCatalog.getComponents().reduce((componentMap, component) => {
7
7
  componentMap[component.name] = component.versions.reduce((versionMap, componentVersion) => {
@@ -12,39 +12,66 @@ module.exports.register = function () {
12
12
  }, {});
13
13
 
14
14
  contentCatalog.findBy({ family: 'attachment' }).forEach((attachment) => {
15
- const componentVersion = componentVersionTable[attachment.src.component][attachment.src.version];
16
- let attributes = componentVersion.asciidoc?.attributes;
17
- if (!attributes) return;
18
- attributes = Object.entries(attributes).reduce((accum, [name, val]) => {
19
- const stringValue = String(val); // Ensure val is a string
20
- accum[name] = stringValue.endsWith('@') ? stringValue.slice(0, stringValue.length - 1) : stringValue;
15
+ const componentVersion = componentVersionTable[attachment.src.component]?.[attachment.src.version];
16
+ if (!componentVersion?.asciidoc?.attributes) return;
17
+
18
+ const attributes = Object.entries(componentVersion.asciidoc.attributes).reduce((accum, [name, val]) => {
19
+ const stringValue = String(val);
20
+ accum[name] = stringValue.endsWith('@') ? sanitizeAttributeValue(stringValue) : stringValue;
21
21
  return accum;
22
22
  }, {});
23
- let modified;
23
+
24
24
  let contentString = attachment.contents.toString();
25
- // Specific replacements for YAML files
25
+ let modified = false;
26
+
27
+ // Determine if we're using the tag or version attributes
28
+ // We introduced tag attributes in Self-Managed 24.3
29
+ const isPrerelease = attributes['page-component-version-is-prerelease'];
30
+ const componentVersionNumber = formatVersion(componentVersion.version || '');
31
+ const useTagAttributes = isPrerelease || (componentVersionNumber && semver.gte(componentVersionNumber, '24.3.0') && componentVersion.title === 'Self-Managed');
32
+
33
+ // Set replacements based on the condition
34
+ const redpandaVersion = isPrerelease
35
+ ? sanitizeAttributeValue(attributes['redpanda-beta-tag'] || '')
36
+ : (useTagAttributes
37
+ ? sanitizeAttributeValue(attributes['latest-redpanda-tag'] || '')
38
+ : sanitizeAttributeValue(attributes['full-version'] || ''));
39
+
40
+ const consoleVersion = useTagAttributes
41
+ ? sanitizeAttributeValue(attributes['latest-console-tag'] || '')
42
+ : sanitizeAttributeValue(attributes['latest-console-version'] || '');
43
+ const redpandaRepo = isPrerelease ? 'redpanda-unstable' : 'redpanda';
44
+ const consoleRepo = 'console';
45
+
46
+ // YAML-specific replacements
26
47
  if (attachment.out.path.endsWith('.yaml') || attachment.out.path.endsWith('.yml')) {
27
- const redpandaVersionRegex = /(\$\{REDPANDA_VERSION[^\}]*\})/g;
28
- const redpandaConsoleVersionRegex = /(\$\{REDPANDA_CONSOLE_VERSION[^\}]*\})/g;
29
- let fullVersion = attributes['full-version'] ? sanitizeAttributeValue(attributes['full-version']) : '';
30
- const latestConsoleVersion = attributes['latest-console-version'] ? sanitizeAttributeValue(attributes['latest-console-version']) : '';
31
- if (attributes['page-component-version-is-prerelease']) {
32
- fullVersion = attributes['redpanda-beta-version'] ? sanitizeAttributeValue(attributes['redpanda-beta-version']) : fullVersion;
33
- }
34
- contentString = contentString.replace(redpandaVersionRegex, fullVersion);
35
- contentString = contentString.replace(redpandaConsoleVersionRegex, latestConsoleVersion);
48
+ contentString = replacePlaceholder(contentString, /\$\{REDPANDA_DOCKER_REPO:[^\}]*\}/g, redpandaRepo);
49
+ contentString = replacePlaceholder(contentString, /\$\{CONSOLE_DOCKER_REPO:[^\}]*\}/g, consoleRepo);
50
+ contentString = replacePlaceholder(contentString, /\$\{REDPANDA_VERSION[^\}]*\}/g, redpandaVersion);
51
+ contentString = replacePlaceholder(contentString, /\$\{REDPANDA_CONSOLE_VERSION[^\}]*\}/g, consoleVersion);
36
52
  modified = true;
37
53
  }
38
54
 
39
- const result = contentString.replace(/\{([\p{Alpha}\d_][\p{Alpha}\d_-]*)\}/gu, (match, name) => {
55
+ // General attribute replacements (excluding uppercase with underscores)
56
+ const result = contentString.replace(/\{([a-z][\p{Alpha}\d_-]*)\}/gu, (match, name) => {
40
57
  if (!(name in attributes)) return match;
41
58
  modified = true;
42
- let value = attributes[name];
43
- if (value.endsWith('@')) value = value.slice(0, value.length - 1);
44
- return value;
59
+ return attributes[name];
45
60
  });
46
61
 
47
62
  if (modified) attachment.contents = Buffer.from(result);
48
63
  });
49
64
  });
65
+
66
+ // Helper function to replace placeholders with attribute values
67
+ function replacePlaceholder(content, regex, replacement) {
68
+ return content.replace(regex, replacement);
69
+ }
70
+
71
+ const sanitizeAttributeValue = (value) => String(value).replace('@', '');
72
+
73
+ const formatVersion = (version) => {
74
+ if (!version) return null;
75
+ return semver.valid(version) ? version : `${version}.0`;
76
+ };
50
77
  };
@@ -2,8 +2,7 @@ module.exports = async (github, owner, repo) => {
2
2
 
3
3
  try {
4
4
  const release = await github.rest.repos.getLatestRelease({ owner, repo });
5
- tag = release.data.tag_name.replace(/^v/, '');
6
- return tag;
5
+ return release.data.tag_name
7
6
  } catch (error) {
8
7
  console.error(error);
9
8
  return null;
@@ -1,5 +1,5 @@
1
1
  module.exports = async (github, owner, repo) => {
2
- const semver = require('semver')
2
+ const semver = require('semver');
3
3
  try {
4
4
  const releases = await github.rest.repos.listReleases({
5
5
  owner,
@@ -8,15 +8,14 @@ module.exports = async (github, owner, repo) => {
8
8
  per_page: 50
9
9
  });
10
10
 
11
- // Filter valid semver tags and sort them
11
+ // Filter tags with valid semver format
12
12
  const sortedReleases = releases.data
13
- .map(release => release.tag_name.replace(/^v/, ''))
14
- .filter(tag => semver.valid(tag))
15
- // Sort in descending order to get the highest version first
16
- .sort(semver.rcompare);
13
+ .map(release => release.tag_name)
14
+ .filter(tag => semver.valid(tag.replace(/^v/, '')))
15
+ .sort((a, b) => semver.rcompare(a.replace(/^v/, ''), b.replace(/^v/, '')));
17
16
 
18
17
  if (sortedReleases.length > 0) {
19
- // Return the highest version
18
+ // Return the highest version with "v" prefix
20
19
  return sortedReleases[0];
21
20
  } else {
22
21
  console.log("No valid semver releases found.");
@@ -9,23 +9,21 @@ module.exports = async (github, owner, repo) => {
9
9
  per_page: 50
10
10
  });
11
11
 
12
- // Filter valid semver tags, exclude drafts, and sort them to find the highest version
12
+ // Filter valid semver tags and sort them to find the highest version
13
13
  const sortedReleases = releases.data
14
- .filter(release => !release.draft)
15
- .map(release => release.tag_name.replace(/^v/, ''))
16
- .filter(tag => semver.valid(tag))
17
- // Sort in descending order to get the highest version first
18
- .sort(semver.rcompare);
14
+ .map(release => release.tag_name)
15
+ .filter(tag => semver.valid(tag.replace(/^v/, '')))
16
+ .sort((a, b) => semver.rcompare(a.replace(/^v/, ''), b.replace(/^v/, '')));
19
17
 
20
18
  if (sortedReleases.length > 0) {
21
- const latestRedpandaReleaseVersion = sortedReleases.find(tag => !tag.includes('rc'));
22
- const latestRcReleaseVersion = sortedReleases.find(tag => tag.includes('rc'));
19
+ const latestRedpandaReleaseVersion = sortedReleases.find(tag => !tag.includes('-rc'));
20
+ const latestRcReleaseVersion = sortedReleases.find(tag => tag.includes('-rc'));
23
21
 
24
22
  // Get the commit hash for the highest version tag
25
23
  const commitData = await github.rest.git.getRef({
26
24
  owner,
27
25
  repo,
28
- ref: `tags/v${latestRedpandaReleaseVersion}`
26
+ ref: `tags/${latestRedpandaReleaseVersion}`
29
27
  });
30
28
  const latestRedpandaReleaseCommitHash = commitData.data.object.sha;
31
29
 
@@ -34,7 +32,7 @@ module.exports = async (github, owner, repo) => {
34
32
  const rcCommitData = await github.rest.git.getRef({
35
33
  owner,
36
34
  repo,
37
- ref: `tags/v${latestRcReleaseVersion}`
35
+ ref: `tags/${latestRcReleaseVersion}`
38
36
  });
39
37
  latestRcReleaseCommitHash = rcCommitData.data.object.sha;
40
38
  }
@@ -1,13 +1,16 @@
1
+ 'use strict';
2
+
1
3
  module.exports.register = function ({ config }) {
2
- const GetLatestRedpandaVersion = require('./get-latest-redpanda-version')
3
- const GetLatestConsoleVersion = require('./get-latest-console-version')
4
- const GetLatestOperatorVersion = require('./get-latest-operator-version')
5
- const GetLatestHelmChartVersion = require('./get-latest-redpanda-helm-version')
6
- const GetLatestConnectVersion = require('./get-latest-connect')
7
- const chalk = require('chalk')
8
- const logger = this.getLogger('set-latest-version-extension')
4
+ const GetLatestRedpandaVersion = require('./get-latest-redpanda-version');
5
+ const GetLatestConsoleVersion = require('./get-latest-console-version');
6
+ const GetLatestOperatorVersion = require('./get-latest-operator-version');
7
+ const GetLatestHelmChartVersion = require('./get-latest-redpanda-helm-version');
8
+ const GetLatestConnectVersion = require('./get-latest-connect');
9
+ const chalk = require('chalk');
10
+ const logger = this.getLogger('set-latest-version-extension');
11
+
9
12
  if (!process.env.REDPANDA_GITHUB_TOKEN) {
10
- logger.warn('REDPANDA_GITHUB_TOKEN environment variable not set. Attempting unauthenticated request.')
13
+ logger.warn('REDPANDA_GITHUB_TOKEN environment variable not set. Attempting unauthenticated request.');
11
14
  }
12
15
 
13
16
  this.on('contentClassified', async ({ contentCatalog }) => {
@@ -17,83 +20,105 @@ module.exports.register = function ({ config }) {
17
20
  const OctokitWithRetries = Octokit.plugin(retry);
18
21
 
19
22
  const owner = 'redpanda-data';
20
-
21
- let githubOptions = {
23
+ const githubOptions = {
22
24
  userAgent: 'Redpanda Docs',
23
25
  baseUrl: 'https://api.github.com',
26
+ auth: process.env.REDPANDA_GITHUB_TOKEN || undefined,
24
27
  };
25
-
26
- if (process.env.REDPANDA_GITHUB_TOKEN) {
27
- githubOptions.auth = process.env.REDPANDA_GITHUB_TOKEN;
28
- }
29
-
30
28
  const github = new OctokitWithRetries(githubOptions);
29
+
31
30
  try {
32
- const results = await Promise.allSettled([
31
+ const [
32
+ latestRedpandaResult,
33
+ latestConsoleResult,
34
+ latestOperatorResult,
35
+ latestHelmChartResult,
36
+ latestConnectResult,
37
+ ] = await Promise.allSettled([
33
38
  GetLatestRedpandaVersion(github, owner, 'redpanda'),
34
39
  GetLatestConsoleVersion(github, owner, 'console'),
35
40
  GetLatestOperatorVersion(github, owner, 'redpanda-operator'),
36
41
  GetLatestHelmChartVersion(github, owner, 'helm-charts', 'charts/redpanda/Chart.yaml'),
37
- GetLatestConnectVersion(github, owner, 'connect')
38
- ])
42
+ GetLatestConnectVersion(github, owner, 'connect'),
43
+ ]);
39
44
 
40
- const LatestRedpandaVersion = results[0].status === 'fulfilled' ? results[0].value : null
41
- const LatestConsoleVersion = results[1].status === 'fulfilled' ? results[1].value : null
42
- const LatestOperatorVersion = results[2].status === 'fulfilled' ? results[2].value : null
43
- const LatestHelmChartVersion = results[3].status === 'fulfilled' ? results[3].value : null
44
- const LatestConnectVersion = results[4].status === 'fulfilled' ? results[4].value : null
45
+ const latestVersions = {
46
+ redpanda: latestRedpandaResult.status === 'fulfilled' ? latestRedpandaResult.value : {},
47
+ console: latestConsoleResult.status === 'fulfilled' ? latestConsoleResult.value : undefined,
48
+ operator: latestOperatorResult.status === 'fulfilled' ? latestOperatorResult.value : undefined,
49
+ helmChart: latestHelmChartResult.status === 'fulfilled' ? latestHelmChartResult.value : undefined,
50
+ connect: latestConnectResult.status === 'fulfilled' ? latestConnectResult.value : undefined,
51
+ };
45
52
 
46
- const components = await contentCatalog.getComponents()
53
+ const components = await contentCatalog.getComponents();
47
54
  components.forEach(component => {
48
- let prerelease = component.latestPrerelease;
55
+ const prerelease = component.latestPrerelease;
56
+
49
57
  component.versions.forEach(({ name, version, asciidoc }) => {
50
- // This attribute is used for conditionally rendering content for beta releases.
51
- // It is also used in the `unpublish-pages` extension to unpublish beta pages that aren't part of a beta version.
52
- if (prerelease && prerelease.version === version) {
53
- asciidoc.attributes['page-component-version-is-prerelease'] = 'true'
58
+ if (prerelease?.version === version) {
59
+ asciidoc.attributes['page-component-version-is-prerelease'] = 'true';
54
60
  }
55
- if (LatestConsoleVersion) {
56
- asciidoc.attributes['latest-console-version'] = `${LatestConsoleVersion}@`
57
- logger.info(`Set Redpanda Console version to ${LatestConsoleVersion} in ${name} ${version}`)
61
+
62
+ // Set operator and helm chart attributes
63
+ if (latestVersions.operator) {
64
+ asciidoc.attributes['latest-operator-version'] = latestVersions.operator;
58
65
  }
59
- if (LatestConnectVersion) {
60
- asciidoc.attributes['latest-connect-version'] = `${LatestConnectVersion}@`
61
- logger.info(`Set Redpanda Connect version to ${LatestConnectVersion} in ${name} ${version}`)
66
+ if (latestVersions.helmChart) {
67
+ asciidoc.attributes['latest-redpanda-helm-chart-version'] = latestVersions.helmChart;
62
68
  }
63
- if (LatestRedpandaVersion && LatestRedpandaVersion.latestRcRelease && LatestRedpandaVersion.latestRcRelease.version) {
64
- asciidoc.attributes['redpanda-beta-version'] = `${LatestRedpandaVersion.latestRcRelease.version}@`
65
- asciidoc.attributes['redpanda-beta-commit'] = `${LatestRedpandaVersion.latestRcRelease.commitHash}@`
66
- logger.info(`Updated to latest Redpanda RC version: ${LatestRedpandaVersion.latestRcRelease.version} with commit: ${LatestRedpandaVersion.latestRcRelease.commitHash}`)
67
- }
68
- })
69
-
70
- if (!component.latest.asciidoc) {
71
- component.latest.asciidoc = { attributes: {} }
72
- }
73
69
 
74
- if (LatestRedpandaVersion && LatestRedpandaVersion.latestRedpandaRelease && semver.valid(LatestRedpandaVersion.latestRedpandaRelease.version)) {
75
- let currentVersion = component.latest.asciidoc.attributes['full-version'] || '0.0.0'
76
- if (semver.gt(LatestRedpandaVersion.latestRedpandaRelease.version, currentVersion)) {
77
- component.latest.asciidoc.attributes['full-version'] = `${LatestRedpandaVersion.latestRedpandaRelease.version}@`
78
- component.latest.asciidoc.attributes['latest-release-commit'] = `${LatestRedpandaVersion.latestRedpandaRelease.commitHash}@`
79
- logger.info(`Updated to latest Redpanda version: ${LatestRedpandaVersion.latestRedpandaRelease.version} with commit: ${LatestRedpandaVersion.latestRedpandaRelease.commitHash}`)
70
+ // Set attributes for console and connect versions
71
+ if (latestVersions.console) {
72
+ setVersionAndTagAttributes(asciidoc, 'latest-console', latestVersions.console, name, version);
80
73
  }
81
- }
74
+ if (latestVersions.connect) {
75
+ setVersionAndTagAttributes(asciidoc, 'latest-connect', latestVersions.connect, name, version);
76
+ }
77
+ // Special handling for Redpanda RC versions if in beta
78
+ if (latestVersions.redpanda?.latestRcRelease?.version) {
79
+ setVersionAndTagAttributes(asciidoc, 'redpanda-beta', latestVersions.redpanda.latestRcRelease.version, name, version)
80
+ asciidoc.attributes['redpanda-beta-commit'] = latestVersions.redpanda.latestRcRelease.commitHash;
81
+ }
82
+ });
82
83
 
83
- if (LatestOperatorVersion) {
84
- component.latest.asciidoc.attributes['latest-operator-version'] = `${LatestOperatorVersion}@`
85
- logger.info(`Updated to latest Redpanda Operator version: ${LatestOperatorVersion}`)
86
- }
84
+ if (!component.latest.asciidoc) component.latest.asciidoc = { attributes: {} };
87
85
 
88
- if (LatestHelmChartVersion) {
89
- component.latest.asciidoc.attributes['latest-redpanda-helm-chart-version'] = `${LatestHelmChartVersion}@`
90
- logger.info(`Updated to latest Redpanda Helm chart version: ${LatestHelmChartVersion}`)
86
+ // For Redpanda GA version, set both latest-redpanda-version and latest-redpanda-tag if available
87
+ if (semver.valid(latestVersions.redpanda?.latestRedpandaRelease?.version)) {
88
+ const currentVersion = component.latest.asciidoc.attributes['full-version'] || '0.0.0';
89
+ if (semver.gt(latestVersions.redpanda.latestRedpandaRelease.version, currentVersion)) {
90
+ // Required for backwards compatibility. Some docs still use full-version
91
+ component.latest.asciidoc.attributes['full-version'] = sanitizeVersion(latestVersions.redpanda.latestRedpandaRelease.version);
92
+ setVersionAndTagAttributes(component.latest.asciidoc, 'latest-redpanda', latestVersions.redpanda.latestRedpandaRelease.version, component.latest.name, component.latest.version);
93
+ component.latest.asciidoc.attributes['latest-release-commit'] = latestVersions.redpanda.latestRedpandaRelease.commitHash;
94
+ logger.info(`Updated Redpanda release version to ${latestVersions.redpanda.latestRedpandaRelease.version}`);
95
+ }
91
96
  }
92
- })
97
+ });
93
98
 
94
- console.log(`${chalk.green('Updated Redpanda documentation versions successfully.')}`)
99
+ console.log(chalk.green('Updated Redpanda documentation versions successfully.'));
95
100
  } catch (error) {
96
- logger.error(`Error updating versions: ${error}`)
101
+ logger.error(`Error updating versions: ${error}`);
97
102
  }
98
- })
99
- }
103
+ });
104
+
105
+ // Helper function to set both latest-*version and latest-*tag attributes
106
+ function setVersionAndTagAttributes(asciidoc, baseName, versionData, name = '', version = '') {
107
+ if (versionData) {
108
+ const versionWithoutPrefix = sanitizeVersion(versionData);
109
+ asciidoc.attributes[`${baseName}-version`] = versionWithoutPrefix; // Without "v" prefix
110
+ asciidoc.attributes[`${baseName}-tag`] = `${versionData}`;
111
+
112
+ if (name && version) {
113
+ logger.info(`Set ${baseName}-version to ${versionWithoutPrefix} and ${baseName}-tag to ${versionData} in ${name} ${version}`);
114
+ } else {
115
+ logger.info(`Updated ${baseName}-version to ${versionWithoutPrefix} and ${baseName}-tag to ${versionData}`);
116
+ }
117
+ }
118
+ }
119
+
120
+ // Helper function to sanitize version by removing "v" prefix
121
+ function sanitizeVersion(version) {
122
+ return version.replace(/^v/, '');
123
+ }
124
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "3.7.2",
3
+ "version": "3.7.4",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",