Skip to content

Commit 6506c5f

Browse files
committed
chore(ci): Cleanup JS
1 parent 1cb33bf commit 6506c5f

File tree

4 files changed

+68
-36
lines changed

4 files changed

+68
-36
lines changed

.github/workflows/audit-documentation.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ on:
1212
required: false
1313
type: boolean
1414
default: false
15-
16-
schedule:
17-
# Run weekly on Mondays at 9 AM UTC for all audits
18-
- cron: '0 9 * * 1'
1915

2016
jobs:
2117
cli-3-core:

eslint.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ export default [
9595
},
9696
},
9797

98+
// Configuration for Node.js helper scripts
99+
{
100+
files: ['helper-scripts/**/*.js'],
101+
languageOptions: {
102+
globals: {
103+
...globals.node,
104+
},
105+
},
106+
rules: {
107+
// Node.js specific rules
108+
},
109+
},
110+
98111
// Configuration for specific file patterns
99112
{
100113
files: ['**/*.js'],

helper-scripts/common/validate-tags.js

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
*/
77

88
import { spawn } from 'child_process';
9-
import { dirname, join } from 'path';
10-
import { fileURLToPath } from 'url';
11-
12-
const __filename = fileURLToPath(import.meta.url);
13-
const __dirname = dirname(__filename);
149

1510
/**
1611
* Execute a command and return the output
@@ -37,7 +32,9 @@ function execCommand(command, args = [], cwd = process.cwd()) {
3732
if (code === 0) {
3833
resolve(stdout.trim());
3934
} else {
40-
reject(new Error(`Command failed: ${command} ${args.join(' ')}\n${stderr}`));
35+
reject(
36+
new Error(`Command failed: ${command} ${args.join(' ')}\n${stderr}`)
37+
);
4138
}
4239
});
4340
});
@@ -50,8 +47,12 @@ function execCommand(command, args = [], cwd = process.cwd()) {
5047
*/
5148
async function getGitTags(repoPath = process.cwd()) {
5249
try {
53-
const output = await execCommand('git', ['tag', '--list', '--sort=-version:refname'], repoPath);
54-
return output ? output.split('\n').filter(tag => tag.trim()) : [];
50+
const output = await execCommand(
51+
'git',
52+
['tag', '--list', '--sort=-version:refname'],
53+
repoPath
54+
);
55+
return output ? output.split('\n').filter((tag) => tag.trim()) : [];
5556
} catch (error) {
5657
throw new Error(`Failed to get git tags: ${error.message}`);
5758
}
@@ -76,12 +77,16 @@ async function isValidTag(version, repoPath = process.cwd()) {
7677
* Validate multiple version tags
7778
* @param {string[]} versions - Array of version strings to validate
7879
* @param {string} repoPath - Path to the git repository
79-
* @returns {Promise<{valid: boolean, errors: string[], availableTags: string[]}>}
80+
* @returns {Promise<{
81+
* valid: boolean,
82+
* errors: string[],
83+
* availableTags: string[]
84+
* }>} Validation result
8085
*/
8186
async function validateTags(versions, repoPath = process.cwd()) {
8287
const errors = [];
8388
const availableTags = await getGitTags(repoPath);
84-
89+
8590
for (const version of versions) {
8691
if (version && version !== 'local' && !availableTags.includes(version)) {
8792
errors.push(`Version '${version}' is not a valid git tag`);
@@ -91,7 +96,7 @@ async function validateTags(versions, repoPath = process.cwd()) {
9196
return {
9297
valid: errors.length === 0,
9398
errors,
94-
availableTags: availableTags.slice(0, 10) // Return top 10 most recent tags
99+
availableTags: availableTags.slice(0, 10), // Return top 10 most recent tags
95100
};
96101
}
97102

@@ -101,26 +106,32 @@ async function validateTags(versions, repoPath = process.cwd()) {
101106
* @param {string} previousVersion - Previous version (optional)
102107
* @param {string} repoPath - Path to the git repository
103108
*/
104-
async function validateVersionInputs(version, previousVersion = null, repoPath = process.cwd()) {
109+
async function validateVersionInputs(
110+
version,
111+
previousVersion = null,
112+
repoPath = process.cwd()
113+
) {
105114
const versionsToCheck = [version];
106115
if (previousVersion) {
107116
versionsToCheck.push(previousVersion);
108117
}
109118

110119
const validation = await validateTags(versionsToCheck, repoPath);
111-
120+
112121
if (!validation.valid) {
113122
console.error('\n❌ Version validation failed:');
114-
validation.errors.forEach(error => console.error(` - ${error}`));
115-
123+
validation.errors.forEach((error) => console.error(` - ${error}`));
124+
116125
if (validation.availableTags.length > 0) {
117126
console.error('\n📋 Available tags (most recent first):');
118-
validation.availableTags.forEach(tag => console.error(` - ${tag}`));
127+
validation.availableTags.forEach((tag) => console.error(` - ${tag}`));
119128
} else {
120129
console.error('\n📋 No git tags found in repository');
121130
}
122-
123-
console.error('\n💡 Tip: Use "local" for development/testing with local containers');
131+
132+
console.error(
133+
'\n💡 Tip: Use "local" for development/testing with local containers'
134+
);
124135
process.exit(1);
125136
}
126137

@@ -134,10 +145,16 @@ async function validateVersionInputs(version, previousVersion = null, repoPath =
134145
*/
135146
async function getRepositoryRoot(startPath = process.cwd()) {
136147
try {
137-
const output = await execCommand('git', ['rev-parse', '--show-toplevel'], startPath);
148+
const output = await execCommand(
149+
'git',
150+
['rev-parse', '--show-toplevel'],
151+
startPath
152+
);
138153
return output;
139154
} catch (error) {
140-
throw new Error(`Not a git repository or git not available: ${error.message}`);
155+
throw new Error(
156+
`Not a git repository or git not available: ${error.message}`
157+
);
141158
}
142159
}
143160

@@ -146,24 +163,26 @@ export {
146163
isValidTag,
147164
validateTags,
148165
validateVersionInputs,
149-
getRepositoryRoot
166+
getRepositoryRoot,
150167
};
151168

152169
// CLI usage when run directly
153170
if (import.meta.url === `file://${process.argv[1]}`) {
154171
const args = process.argv.slice(2);
155-
172+
156173
if (args.length === 0) {
157174
console.log('Usage: node validate-tags.js <version> [previous-version]');
158175
console.log('Examples:');
159176
console.log(' node validate-tags.js v3.0.0');
160177
console.log(' node validate-tags.js v3.0.0 v2.9.0');
161-
console.log(' node validate-tags.js local # Special case for development');
178+
console.log(
179+
' node validate-tags.js local # Special case for development'
180+
);
162181
process.exit(1);
163182
}
164183

165184
const [version, previousVersion] = args;
166-
185+
167186
try {
168187
const repoRoot = await getRepositoryRoot();
169188
await validateVersionInputs(version, previousVersion, repoRoot);
@@ -172,4 +191,4 @@ if (import.meta.url === `file://${process.argv[1]}`) {
172191
console.error(`Error: ${error.message}`);
173192
process.exit(1);
174193
}
175-
}
194+
}

helper-scripts/influxdb3-monolith/audit-cli-documentation.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import { promises as fs } from 'fs';
1111
import { homedir } from 'os';
1212
import { join, dirname } from 'path';
1313
import { fileURLToPath } from 'url';
14-
import { validateVersionInputs, getRepositoryRoot } from '../common/validate-tags.js';
14+
import {
15+
validateVersionInputs,
16+
getRepositoryRoot,
17+
} from '../common/validate-tags.js';
1518

1619
const __filename = fileURLToPath(import.meta.url);
1720
const __dirname = dirname(__filename);
@@ -107,7 +110,7 @@ class CLIDocAuditor {
107110
coreToken = (await fs.readFile(this.coreTokenFile, 'utf8')).trim();
108111
}
109112
}
110-
} catch (e) {
113+
} catch {
111114
// Token file doesn't exist or can't be read
112115
}
113116

@@ -120,7 +123,7 @@ class CLIDocAuditor {
120123
).trim();
121124
}
122125
}
123-
} catch (e) {
126+
} catch {
124127
// Token file doesn't exist or can't be read
125128
}
126129

@@ -683,9 +686,10 @@ Replace the following:
683686
if (missingCount === 0) {
684687
output += 'No missing documentation files detected.\n';
685688
} else {
686-
output += `\n### Quick Actions\n\n`;
687-
output += `Copy and paste these commands to create missing documentation:\n\n`;
688-
output += `\`\`\`bash\n`;
689+
output += '\n### Quick Actions\n\n';
690+
output +=
691+
'Copy and paste these commands to create missing documentation:\n\n';
692+
output += '```bash\n';
689693
for (const doc of missingDocs) {
690694
const relativePatch = join(
691695
'helper-scripts/output/cli-audit/patches',
@@ -696,7 +700,7 @@ Replace the following:
696700
output += `mkdir -p $(dirname ${doc.file})\n`;
697701
output += `cp ${relativePatch} ${doc.file}\n\n`;
698702
}
699-
output += `\`\`\`\n`;
703+
output += '```\n';
700704
}
701705

702706
output += '\n';

0 commit comments

Comments
 (0)