build: create script to update integration lock files (#49787)

* Adds a small script to conveniently re-generate lock files for
  integration tests.
* Updates the `.gitignore` for integration tests to ignore node
  modules. Some tests do not have a `.gitignore` (like the CLI
  boilerplate tests).

PR Close #49787
This commit is contained in:
Paul Gschwendtner
2023-04-11 16:11:25 +00:00
committed by Andrew Kushnir
parent 222f795bda
commit 4373003d20
2 changed files with 37 additions and 1 deletions
+5 -1
View File
@@ -6,4 +6,8 @@ tmp/
*/src/*.js
!karma.conf.js
**/.yarn_local_cache*
**/NPM_PACKAGE_MANIFEST.json
**/NPM_PACKAGE_MANIFEST.json
*/node_modules/
.tmp-yarn-cache/
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env node
/**
* Script that deletes all `yarn.lock` files for integration tests and
* re-builds them from scratch. This script is useful as lock fils in
* integration tests are not necessarily up-to-date, given dependencies
* being linked from the root `/package.json`, or locally-built 1st party
* packages being used from tarball archives.
*/
import childProcess from 'child_process';
import url from 'url';
import path from 'path';
import glob from 'glob';
import fs from 'fs';
const containingDir = path.dirname(url.fileURLToPath(import.meta.url));
const testDirs = glob.sync('*/BUILD.bazel', {cwd: containingDir})
.map((d) => path.join(containingDir, path.dirname(d)));
const yarnTestTmpDir = path.join(containingDir, '.tmp-yarn-cache');
for (const testDir of testDirs) {
fs.rmSync(path.join(testDir, 'yarn.lock'));
childProcess.spawnSync('yarn', ['install', '--cache-folder', yarnTestTmpDir], {
cwd: testDir,
shell: true,
stdio: 'inherit',
});
}
fs.rmSync(yarnTestTmpDir, {recursive: true});