2025-08-15 16:20:30 +00:00
|
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Fix for misleading operator precedence in @octokit/request regex
|
2025-08-15 17:03:48 +00:00
|
|
|
|
* Changes /^text\/|charset=utf-8$/ to /^(text\/|charset=utf-8)$/
|
2025-08-15 16:20:30 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
2025-08-15 16:36:36 +00:00
|
|
|
|
const fs = require('fs')
|
2025-08-15 16:20:30 +00:00
|
|
|
|
|
|
|
|
|
|
const filesToFix = [
|
2025-08-15 16:48:23 +00:00
|
|
|
|
'node_modules/@actions/github/node_modules/@octokit/request/dist-src/fetch-wrapper.js',
|
|
|
|
|
|
'node_modules/@actions/github/node_modules/@octokit/request/dist-node/index.js',
|
|
|
|
|
|
'node_modules/@actions/github/node_modules/@octokit/request/dist-web/index.js',
|
2025-08-15 16:36:36 +00:00
|
|
|
|
]
|
2025-08-15 16:20:30 +00:00
|
|
|
|
|
2025-08-15 16:36:36 +00:00
|
|
|
|
process.stdout.write('🔧 Applying regex fix for @octokit/request...\n')
|
2025-08-15 16:20:30 +00:00
|
|
|
|
|
2025-08-15 16:36:36 +00:00
|
|
|
|
let filesFixed = 0
|
2025-08-15 16:20:30 +00:00
|
|
|
|
|
2025-08-15 16:36:36 +00:00
|
|
|
|
for (const filePath of filesToFix) {
|
2025-08-15 17:03:48 +00:00
|
|
|
|
try {
|
|
|
|
|
|
let content = fs.readFileSync(filePath, 'utf8')
|
|
|
|
|
|
const originalContent = content
|
2025-08-15 16:36:36 +00:00
|
|
|
|
|
2025-08-15 17:03:48 +00:00
|
|
|
|
// Fix the problematic regex pattern - add proper grouping to fix operator precedence
|
|
|
|
|
|
content = content.replace(/\/\^text\\?\/\|charset=utf-8\$?\//g, '/^(text\\/|charset=utf-8)$/')
|
2025-08-15 13:08:00 -04:00
|
|
|
|
content = content.replace(/\/\^text\/\|charset=utf-8\$?\//g, '/^(text\\/|charset=utf-8)$/')
|
2025-08-15 16:36:36 +00:00
|
|
|
|
|
2025-08-15 17:03:48 +00:00
|
|
|
|
if (content !== originalContent) {
|
|
|
|
|
|
fs.writeFileSync(filePath, content, 'utf8')
|
|
|
|
|
|
process.stdout.write(`✅ Fixed: ${filePath}\n`)
|
|
|
|
|
|
filesFixed++
|
|
|
|
|
|
} else {
|
|
|
|
|
|
process.stdout.write(`ℹ️ No changes needed: ${filePath}\n`)
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
if (error.code === 'ENOENT') {
|
|
|
|
|
|
process.stdout.write(`⚠️ File not found: ${filePath}\n`)
|
|
|
|
|
|
} else {
|
2025-08-15 16:48:23 +00:00
|
|
|
|
process.stderr.write(`❌ Error fixing ${filePath}: ${error.message}\n`)
|
|
|
|
|
|
}
|
2025-08-15 16:20:30 +00:00
|
|
|
|
}
|
2025-08-15 16:36:36 +00:00
|
|
|
|
}
|
2025-08-15 16:20:30 +00:00
|
|
|
|
|
2025-08-15 16:36:36 +00:00
|
|
|
|
process.stdout.write(`\n🎉 Fix complete! ${filesFixed} files updated.\n`)
|
2025-08-15 16:20:30 +00:00
|
|
|
|
if (filesFixed > 0) {
|
2025-08-15 16:48:23 +00:00
|
|
|
|
process.stdout.write('Run "npm run build:package" to rebuild with the fix.\n')
|
2025-08-15 16:20:30 +00:00
|
|
|
|
}
|