@redpanda-data/docs-extensions-and-macros 4.13.5 → 4.13.6
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.
|
@@ -9,14 +9,18 @@
|
|
|
9
9
|
* Get GitHub token from environment variables
|
|
10
10
|
* Checks multiple common variable names in priority order:
|
|
11
11
|
* 1. REDPANDA_GITHUB_TOKEN - Custom Redpanda token
|
|
12
|
-
* 2.
|
|
13
|
-
* 3.
|
|
12
|
+
* 2. ACTIONS_BOT_TOKEN - GitHub Actions bot token
|
|
13
|
+
* 3. GITHUB_TOKEN - GitHub Actions default
|
|
14
|
+
* 4. VBOT_GITHUB_API_TOKEN - Legacy bot token
|
|
15
|
+
* 5. GH_TOKEN - GitHub CLI default
|
|
14
16
|
*
|
|
15
17
|
* @returns {string|null} GitHub token or null if not found
|
|
16
18
|
*/
|
|
17
19
|
function getGitHubToken() {
|
|
18
20
|
return process.env.REDPANDA_GITHUB_TOKEN ||
|
|
21
|
+
process.env.ACTIONS_BOT_TOKEN ||
|
|
19
22
|
process.env.GITHUB_TOKEN ||
|
|
23
|
+
process.env.VBOT_GITHUB_API_TOKEN ||
|
|
20
24
|
process.env.GH_TOKEN ||
|
|
21
25
|
null;
|
|
22
26
|
}
|
package/package.json
CHANGED
|
@@ -1172,12 +1172,40 @@ async function handleRpcnConnectorDocs (options) {
|
|
|
1172
1172
|
const missingFromCloudDocs = []
|
|
1173
1173
|
const cloudDocsErrors = []
|
|
1174
1174
|
if (cloudSupportedSet.size > 0 && options.checkCloudDocs !== false) {
|
|
1175
|
-
console.log('\n
|
|
1175
|
+
console.log('\n INFO: Checking cloud-docs repository for missing connector pages...')
|
|
1176
1176
|
|
|
1177
1177
|
// Use shared Octokit instance
|
|
1178
1178
|
const octokit = require('../../cli-utils/octokit-client')
|
|
1179
1179
|
|
|
1180
1180
|
try {
|
|
1181
|
+
// Optimization: Fetch entire directory tree in 1 API call instead of 471 individual calls
|
|
1182
|
+
console.log(' Fetching cloud-docs directory tree (1 API call)...')
|
|
1183
|
+
|
|
1184
|
+
let existingFiles = new Set()
|
|
1185
|
+
|
|
1186
|
+
try {
|
|
1187
|
+
// Get the tree for the components directory
|
|
1188
|
+
const { data: tree } = await octokit.git.getTree({
|
|
1189
|
+
owner: 'redpanda-data',
|
|
1190
|
+
repo: 'cloud-docs',
|
|
1191
|
+
tree_sha: 'main:modules/develop/pages/connect/components',
|
|
1192
|
+
recursive: true
|
|
1193
|
+
})
|
|
1194
|
+
|
|
1195
|
+
// Build a set of existing file paths for O(1) lookup
|
|
1196
|
+
tree.tree.forEach(item => {
|
|
1197
|
+
if (item.type === 'blob' && item.path.endsWith('.adoc')) {
|
|
1198
|
+
existingFiles.add(item.path)
|
|
1199
|
+
}
|
|
1200
|
+
})
|
|
1201
|
+
|
|
1202
|
+
console.log(` Loaded ${existingFiles.size} existing connector pages from cloud-docs`)
|
|
1203
|
+
} catch (treeError) {
|
|
1204
|
+
console.log(` WARNING: Could not fetch tree (${treeError.status}), falling back to individual checks`)
|
|
1205
|
+
// If tree API fails, fall back to individual checks (old behavior)
|
|
1206
|
+
existingFiles = null
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1181
1209
|
// Check each cloud-supported connector
|
|
1182
1210
|
// Filter to only check actual connector/component types that need individual pages
|
|
1183
1211
|
const connectorTypes = ['inputs', 'outputs', 'processors', 'caches', 'buffers', 'scanners', 'metrics', 'tracers']
|
|
@@ -1198,95 +1226,67 @@ async function handleRpcnConnectorDocs (options) {
|
|
|
1198
1226
|
}
|
|
1199
1227
|
}
|
|
1200
1228
|
|
|
1201
|
-
const
|
|
1229
|
+
const relativePath = `${type}/${name}.adoc`
|
|
1230
|
+
const fullPath = `modules/develop/pages/connect/components/${relativePath}`
|
|
1231
|
+
|
|
1232
|
+
// Fast path: Check against tree if we have it
|
|
1233
|
+
if (existingFiles !== null) {
|
|
1234
|
+
if (!existingFiles.has(relativePath)) {
|
|
1235
|
+
missingFromCloudDocs.push({ type, name, path: fullPath })
|
|
1236
|
+
}
|
|
1237
|
+
continue
|
|
1238
|
+
}
|
|
1202
1239
|
|
|
1240
|
+
// Fallback path: Individual API calls (only if tree fetch failed)
|
|
1203
1241
|
try {
|
|
1204
1242
|
await octokit.repos.getContent({
|
|
1205
1243
|
owner: 'redpanda-data',
|
|
1206
1244
|
repo: 'cloud-docs',
|
|
1207
|
-
path:
|
|
1245
|
+
path: fullPath,
|
|
1208
1246
|
ref: 'main'
|
|
1209
1247
|
})
|
|
1210
1248
|
// File exists, no action needed
|
|
1211
1249
|
} catch (error) {
|
|
1212
1250
|
if (error.status === 404) {
|
|
1213
1251
|
// File doesn't exist in cloud-docs
|
|
1214
|
-
missingFromCloudDocs.push({ type, name, path:
|
|
1252
|
+
missingFromCloudDocs.push({ type, name, path: fullPath })
|
|
1215
1253
|
} else {
|
|
1216
|
-
// Non-404 error
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
await new Promise((resolve, reject) => {
|
|
1225
|
-
const req = https.request({
|
|
1226
|
-
hostname: parsedUrl.hostname,
|
|
1227
|
-
path: parsedUrl.pathname,
|
|
1228
|
-
method: 'HEAD',
|
|
1229
|
-
timeout: 5000
|
|
1230
|
-
}, (res) => {
|
|
1231
|
-
if (res.statusCode === 200) {
|
|
1232
|
-
resolve() // File exists
|
|
1233
|
-
} else if (res.statusCode === 404) {
|
|
1234
|
-
reject(new Error('404'))
|
|
1235
|
-
} else {
|
|
1236
|
-
reject(new Error(`Status ${res.statusCode}`))
|
|
1237
|
-
}
|
|
1238
|
-
})
|
|
1239
|
-
req.on('error', reject)
|
|
1240
|
-
req.on('timeout', () => {
|
|
1241
|
-
req.destroy()
|
|
1242
|
-
reject(new Error('Timeout'))
|
|
1243
|
-
})
|
|
1244
|
-
req.end()
|
|
1245
|
-
})
|
|
1246
|
-
// Fallback succeeded - file exists, no action needed
|
|
1247
|
-
} catch (fallbackError) {
|
|
1248
|
-
if (fallbackError.message === '404') {
|
|
1249
|
-
// Confirmed missing via fallback
|
|
1250
|
-
missingFromCloudDocs.push({ type, name, path: cloudDocsPath })
|
|
1251
|
-
} else {
|
|
1252
|
-
// Both API and fallback failed
|
|
1253
|
-
cloudDocsErrors.push({
|
|
1254
|
-
type,
|
|
1255
|
-
name,
|
|
1256
|
-
path: cloudDocsPath,
|
|
1257
|
-
status: error.status || 'unknown',
|
|
1258
|
-
message: `API: ${error.message}; Fallback: ${fallbackError.message}`
|
|
1259
|
-
})
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1254
|
+
// Non-404 error - record as error
|
|
1255
|
+
cloudDocsErrors.push({
|
|
1256
|
+
type,
|
|
1257
|
+
name,
|
|
1258
|
+
path: fullPath,
|
|
1259
|
+
status: error.status || 'unknown',
|
|
1260
|
+
message: error.message
|
|
1261
|
+
})
|
|
1262
1262
|
}
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
1266
|
// Report results
|
|
1267
1267
|
if (cloudDocsErrors.length > 0) {
|
|
1268
|
-
console.log(`
|
|
1268
|
+
console.log(` WARNING: Encountered ${cloudDocsErrors.length} error(s) while checking cloud-docs (check inconclusive):`)
|
|
1269
1269
|
cloudDocsErrors.forEach(({ type, name, status, message }) => {
|
|
1270
|
-
console.log(`
|
|
1270
|
+
console.log(` - ${type}/${name} - Status ${status}: ${message}`)
|
|
1271
1271
|
})
|
|
1272
|
-
console.log(`
|
|
1272
|
+
console.log(` INFO: Please resolve these errors (e.g., check GITHUB_TOKEN or VBOT_GITHUB_API_TOKEN, API rate limits, network connectivity)`)
|
|
1273
1273
|
if (missingFromCloudDocs.length > 0) {
|
|
1274
|
-
console.log(`
|
|
1274
|
+
console.log(` INFO: Additionally, ${missingFromCloudDocs.length} connector(s) confirmed missing from cloud-docs:`)
|
|
1275
1275
|
missingFromCloudDocs.forEach(({ type, name }) => {
|
|
1276
|
-
console.log(`
|
|
1276
|
+
console.log(` - ${type}/${name}`)
|
|
1277
1277
|
})
|
|
1278
1278
|
}
|
|
1279
1279
|
} else if (missingFromCloudDocs.length > 0) {
|
|
1280
|
-
console.log(`
|
|
1280
|
+
console.log(` WARNING: Found ${missingFromCloudDocs.length} cloud-supported connector(s) missing from cloud-docs:`)
|
|
1281
1281
|
missingFromCloudDocs.forEach(({ type, name }) => {
|
|
1282
|
-
console.log(`
|
|
1282
|
+
console.log(` - ${type}/${name}`)
|
|
1283
1283
|
})
|
|
1284
|
-
console.log(`
|
|
1284
|
+
console.log(` INFO: These connectors need pages added to https://github.com/redpanda-data/cloud-docs`)
|
|
1285
1285
|
} else {
|
|
1286
|
-
console.log(`
|
|
1286
|
+
console.log(` All cloud-supported connectors have pages in cloud-docs`)
|
|
1287
1287
|
}
|
|
1288
1288
|
} catch (error) {
|
|
1289
|
-
console.log(`
|
|
1289
|
+
console.log(` WARNING: Could not check cloud-docs: ${error.message}`)
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
1292
|
|