diff --git a/js/CTSnapshot.js b/js/CTSnapshot.js index 96761d2..cfd3d8e 100644 --- a/js/CTSnapshot.js +++ b/js/CTSnapshot.js @@ -14,13 +14,9 @@ const deleteDirectory = require( '../../perennial/js/common/deleteDirectory' ); const execute = require( '../../perennial/js/common/execute' ); const getRepoList = require( '../../perennial/js/common/getRepoList' ); const gitRevParse = require( '../../perennial/js/common/gitRevParse' ); -const npmCommand = require( '../../perennial/js/common/npmCommand' ); const fs = require( 'fs' ); const _ = require( 'lodash' ); // eslint-disable-line -// constants -const copyOptions = { filter: path => path.indexOf( 'node_modules' ) < 0 }; - class CTSnapshot { /** * Creates this snapshot. @@ -76,8 +72,8 @@ class CTSnapshot { } for ( const repo of this.repos ) { - await copyDirectory( `${rootDir}/${repo}`, `${this.phetDir}/${repo}`, copyOptions ); - await copyDirectory( `${rootDir}/${repo}`, `${this.phetioDir}/${repo}`, copyOptions ); + await copyDirectory( `${rootDir}/${repo}`, `${this.phetDir}/${repo}`, {} ); + await copyDirectory( `${rootDir}/${repo}`, `${this.phetioDir}/${repo}`, {} ); } // @public {Array.} @@ -100,16 +96,6 @@ class CTSnapshot { } ); } - async npmInstall() { - const npmRepos = this.repos.filter( repo => fs.existsSync( `../${repo}/package.json` ) ); - for ( const repo of npmRepos ) { - this.setSnapshotStatus( `Running npm update for ${repo}` ); - - await execute( npmCommand, [ 'update', `--cache=../npm-caches/${repo}`, '--tmp=../npm-tmp' ], `${this.phetDir}/${repo}` ); - await execute( npmCommand, [ 'update', `--cache=../npm-caches/${repo}`, '--tmp=../npm-tmp' ], `${this.phetioDir}/${repo}` ); - } - } - /** * Removes the snapshot's files. * @public diff --git a/js/local-server.js b/js/local-server.js index e819213..b79d32e 100644 --- a/js/local-server.js +++ b/js/local-server.js @@ -11,7 +11,9 @@ const cloneMissingRepos = require( '../../perennial/js/common/cloneMissingRepos' const getRepoList = require( '../../perennial/js/common/getRepoList' ); const gitPull = require( '../../perennial/js/common/gitPull' ); const isStale = require( '../../perennial/js/common/isStale' ); +const npmUpdate = require( '../../perennial/js/common/npmUpdate' ); const CTSnapshot = require( './CTSnapshot' ); +const fs = require( 'fs' ); const http = require( 'http' ); const _ = require( 'lodash' ); // eslint-disable-line const path = require( 'path' ); @@ -297,7 +299,14 @@ const cycleSnapshots = async () => { for ( const repo of staleRepos ) { await gitPull( repo ); } - await cloneMissingRepos(); + const clonedRepos = await cloneMissingRepos(); + + // npm prune/update on any changed repos, so we can keep our npm status good in our checked out version + for ( const repo of [ ...staleRepos, ...clonedRepos ] ) { + if ( fs.existsSync( `../${repo}/package.json` ) ) { + await npmUpdate( repo ); + } + } } else { winston.info( 'No stale repos' ); @@ -312,8 +321,6 @@ const cycleSnapshots = async () => { snapshots.unshift( snapshot ); - await snapshot.npmInstall(); - const cutoffTimestamp = Date.now() - 1000 * 60 * 60 * 24 * NUMBER_OF_DAYS_TO_KEEP_SNAPSHOTS; while ( snapshots.length > 70 || snapshots[ snapshots.length - 1 ].timestamp < cutoffTimestamp && !snapshots[ snapshots.length - 1 ].exists ) { removeResultsForSnapshot( testResults, snapshots.pop() );