@@ -24,6 +24,7 @@ const LF_OSS_INDEX_PROJECT_GROUP_SLUG = 'lf-oss-index'
2424async function onboardProjectsFromCsv (
2525 csvFilePath : string ,
2626 bearerToken : string ,
27+ isDryRun = false ,
2728) : Promise < { successCount : number ; failureCount : number ; errors : string [ ] } > {
2829 log . info ( `Starting project onboarding from CSV: ${ csvFilePath } ` )
2930
@@ -68,7 +69,13 @@ async function onboardProjectsFromCsv(
6869 }
6970 }
7071
71- log . info ( `Loaded ${ projects . length } projects from CSV` )
72+ if ( isDryRun && projects . length > 0 ) {
73+ const firstProject = projects [ 0 ]
74+ projects . splice ( 1 )
75+ log . info ( `DRY RUN: Processing only first project: ${ firstProject . name } ` )
76+ } else {
77+ log . info ( `Loaded ${ projects . length } projects from CSV` )
78+ }
7279 } catch ( error ) {
7380 const errorMsg = `Failed to read or parse CSV file: ${ error . message } `
7481 log . error ( error , errorMsg )
@@ -276,12 +283,15 @@ async function writeFailedProjectsCsv(
276283async function main ( ) {
277284 const args = process . argv . slice ( 2 )
278285
279- if ( args . length !== 2 ) {
280- console . error ( 'Usage: tsx src/bin/onboard-projects.ts <bearer-token> <csv-file-path>' )
286+ if ( args . length < 2 || args . length > 3 ) {
287+ console . error (
288+ 'Usage: tsx src/bin/onboard-projects.ts <bearer-token> <csv-file-path> [--dry-run]' ,
289+ )
281290 console . error ( '' )
282291 console . error ( 'Arguments:' )
283292 console . error ( ' bearer-token: Bearer token for API authentication' )
284293 console . error ( ' csv-file-path: Path to CSV file containing projects to onboard' )
294+ console . error ( ' --dry-run: (optional) Test mode - only process the first project from CSV' )
285295 console . error ( '' )
286296 console . error ( 'CSV Format:' )
287297 console . error ( ' The CSV file should have the following columns:' )
@@ -296,7 +306,8 @@ async function main() {
296306 process . exit ( 1 )
297307 }
298308
299- const [ bearerToken , csvFilePath ] = args
309+ const [ bearerToken , csvFilePath , dryRunFlag ] = args
310+ const isDryRun = dryRunFlag === '--dry-run'
300311
301312 // Validate file exists
302313 const resolvedPath = path . resolve ( csvFilePath )
@@ -307,11 +318,15 @@ async function main() {
307318 process . exit ( 1 )
308319 }
309320
310- log . info ( `Starting project onboarding from CSV: ${ resolvedPath } ` )
321+ if ( isDryRun ) {
322+ log . info ( `Starting DRY RUN - will only process first project from CSV: ${ resolvedPath } ` )
323+ } else {
324+ log . info ( `Starting project onboarding from CSV: ${ resolvedPath } ` )
325+ }
311326
312327 try {
313328 // Run the onboarding function directly
314- const result = await onboardProjectsFromCsv ( resolvedPath , bearerToken )
329+ const result = await onboardProjectsFromCsv ( resolvedPath , bearerToken , isDryRun )
315330
316331 log . info ( 'Onboarding completed successfully' )
317332 console . log ( '\n=== Onboarding Results ===' )
@@ -332,6 +347,9 @@ async function main() {
332347 }
333348
334349 console . log ( '\n=== Summary ===' )
350+ if ( isDryRun ) {
351+ console . log ( '🧪 DRY RUN MODE: Only first project was processed for testing' )
352+ }
335353 console . log ( `Total processed: ${ result . successCount + result . failureCount } ` )
336354 console . log (
337355 `Success rate: ${ ( ( result . successCount / ( result . successCount + result . failureCount ) ) * 100 ) . toFixed ( 1 ) } %` ,
0 commit comments