Skip to content

Commit eb6df94

Browse files
committed
chore: cleanup logs
1 parent 3910fd0 commit eb6df94

1 file changed

Lines changed: 42 additions & 46 deletions

File tree

services/apps/script_executor_worker/src/bin/onboard-projects.ts

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ async function onboardProjectsFromCsv(
7575
// Read and parse CSV file
7676
try {
7777
const csvData = fs.readFileSync(csvFilePath, 'utf8')
78-
const records = await new Promise<any[]>((resolve, reject) => {
78+
const records = await new Promise<Record<string, string>[]>((resolve, reject) => {
7979
parse(
8080
csvData,
8181
{
8282
columns: true,
8383
skip_empty_lines: true,
8484
trim: true,
8585
},
86-
(err: any, output: any) => {
86+
(err: Error | null, output: Record<string, string>[]) => {
8787
if (err) reject(err)
8888
else resolve(output)
8989
},
@@ -378,25 +378,25 @@ async function main() {
378378
const args = process.argv.slice(2)
379379

380380
if (args.length < 2 || args.length > 3) {
381-
console.error(
382-
'Usage: tsx src/bin/onboard-projects.ts <bearer-token> <csv-file-path> [--dry-run]',
383-
)
384-
console.error('')
385-
console.error('Arguments:')
386-
console.error(' bearer-token: Bearer token for API authentication')
387-
console.error(' csv-file-path: Path to CSV file containing projects to onboard')
388-
console.error(' --dry-run: (optional) Test mode - only process the first project from CSV')
389-
console.error('')
390-
console.error('CSV Format:')
391-
console.error(' The CSV file should have the following columns:')
392-
console.error(' - project name: Project name')
393-
console.error(' - project slug: Project slug (will be namespaced for non-LF projects)')
394-
console.error(' - repo url: GitHub repository URL')
395-
console.error('')
396-
console.error('Example CSV content:')
397-
console.error('project name,project slug,repo url')
398-
console.error('My Project,my-project,https://github.com/owner/repo')
399-
console.error('Another Project,another-project,git@github.com:owner/another-repo.git')
381+
log.error(`
382+
Usage: tsx src/bin/onboard-projects.ts <bearer-token> <csv-file-path> [--dry-run]
383+
384+
Arguments:
385+
bearer-token: Bearer token for API authentication
386+
csv-file-path: Path to CSV file containing projects to onboard
387+
--dry-run: (optional) Test mode - only process the first project from CSV
388+
389+
CSV Format:
390+
The CSV file should have the following columns:
391+
- project name: Project name
392+
- project slug: Project slug (will be namespaced for non-LF projects)
393+
- repo url: GitHub repository URL
394+
395+
Example CSV content:
396+
project name,project slug,repo url
397+
My Project,my-project,https://github.com/owner/repo
398+
Another Project,another-project,git@github.com:owner/another-repo.git
399+
`)
400400
process.exit(1)
401401
}
402402

@@ -408,7 +408,7 @@ async function main() {
408408
try {
409409
fs.accessSync(resolvedPath, fs.constants.F_OK)
410410
} catch (error) {
411-
console.error(`Error: CSV file not found at path: ${resolvedPath}`)
411+
log.error(`Error: CSV file not found at path: ${resolvedPath}`)
412412
process.exit(1)
413413
}
414414

@@ -422,44 +422,40 @@ async function main() {
422422
// Run the onboarding function directly
423423
const result = await onboardProjectsFromCsv(resolvedPath, bearerToken, isDryRun)
424424

425-
log.info('Onboarding completed successfully')
426-
console.log('\n=== Onboarding Results ===')
427-
console.log(`✅ Successfully onboarded: ${result.successCount} projects`)
428-
console.log(`❌ Failed to onboard: ${result.failureCount} projects`)
429-
430-
if (result.errors.length > 0) {
431-
console.log('\n=== Errors ===')
432-
result.errors.forEach((error, index) => {
433-
console.log(`${index + 1}. ${error}`)
434-
})
435-
}
425+
log.info(`
426+
Onboarding completed successfully: ${result.successCount} successful, ${result.failureCount} failed
427+
428+
=== Onboarding Results ===
429+
✅ Successfully onboarded: ${result.successCount} projects
430+
❌ Failed to onboard: ${result.failureCount} projects
431+
`)
436432

437433
if (result.failedProjects.length > 0) {
438-
console.log('\n=== Failed Projects ===')
434+
log.info(`=== Failed Projects ===`)
439435
result.failedProjects.forEach((project, index) => {
440-
console.log(`${index + 1}. ${project.name} (${project.slug}) - ${project.reason}`)
441-
console.log(` Repo: ${project.repoUrl}`)
436+
log.info(`
437+
${index + 1}. ${project.name} (${project.slug}) - ${project.reason}
438+
Repo: ${project.repoUrl}
439+
`)
442440
})
443441
}
444442

445-
console.log('\n=== Summary ===')
446-
if (isDryRun) {
447-
console.log('🧪 DRY RUN MODE: Only first project was processed for testing')
448-
}
449-
console.log(`Total processed: ${result.successCount + result.failureCount}`)
450-
console.log(
451-
`Success rate: ${((result.successCount / (result.successCount + result.failureCount)) * 100).toFixed(1)}%`,
452-
)
443+
log.info(`
444+
=== Summary ===
445+
${isDryRun ? '🧪 DRY RUN MODE: Only first project was processed for testing' : ''}
446+
Total processed: ${result.successCount + result.failureCount}
447+
Success rate: ${((result.successCount / (result.successCount + result.failureCount)) * 100).toFixed(1)}%
448+
`)
453449

454450
process.exit(result.failureCount > 0 ? 1 : 0)
455451
} catch (error) {
456452
log.error(error, 'Failed to run onboarding')
457-
console.error(`\n❌ Error: ${error.message}`)
453+
log.error(`\n❌ Error: ${error.message}`)
458454
process.exit(1)
459455
}
460456
}
461457

462458
main().catch((error) => {
463-
console.error('Unexpected error:', error)
459+
log.error('Unexpected error:', error)
464460
process.exit(1)
465461
})

0 commit comments

Comments
 (0)