-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed issue with page parsing phetsims/special-ops#181
- Loading branch information
mattpen
committed
Apr 8, 2021
1 parent
aa0af7d
commit 91574b2
Showing
6 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"axios": "^0.21.1", | ||
"fs": "^0.0.1-security" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2021, University of Colorado Boulder | ||
|
||
// update-repos-list.js | ||
// | ||
// This script creates a file in this directly called `.repos` that is | ||
// a newline separated list of all repos in the phetsims organization. | ||
|
||
const axios = require( 'axios' ); | ||
const buildLocal = require( '../../perennial/js/common/buildLocal' ); | ||
const fs = require( 'fs' ); | ||
|
||
let a; | ||
|
||
( async () => { | ||
// temporarily store the old repos for troubleshooting if problems arise | ||
try { | ||
await fs.promises.rename( '.repos', '.repos.old' ); | ||
} | ||
catch( err ) { | ||
if ( err.code !== 'ENOENT' ) { | ||
console.error( err ); | ||
throw err; | ||
} | ||
} | ||
|
||
// Iterate over all repos in the organization | ||
let currentRepos; | ||
let repoNames = ''; | ||
let currentPage = 1; | ||
const pageSize = 100; | ||
do { | ||
currentRepos = ( await axios.get( `https://api.github.com/orgs/phetsims/repos?per_page=${pageSize}&page=${currentPage}&sort=full_name`, { | ||
auth: { | ||
username: buildLocal.developerGithubUsername, | ||
password: buildLocal.developerGithubAccessToken | ||
} | ||
} ) ).data; | ||
if ( currentRepos ) { | ||
repoNames += currentRepos.map( repo => repo.name ).join( '\n' ) + '\n'; | ||
} | ||
currentPage++; | ||
} while ( currentRepos && currentRepos.length === pageSize ); | ||
|
||
// Save to disk | ||
await fs.promises.writeFile( '.repos', repoNames ); | ||
|
||
// Clean up | ||
await fs.promises.unlink( '.repos.old' ); | ||
} )(); | ||
|