()
| 20 | } |
| 21 | |
| 22 | async function handler() { |
| 23 | // TODO: Implement a marker-based root discovery (e.g., .ng-secondary-base). |
| 24 | // This should traverse upward to find the secondary base before falling back to `git rev-parse --show-toplevel`. |
| 25 | // Necessary to support non-standard repository structures where workflows are triggered outside the traditional rootDir. |
| 26 | const rootDir = process.cwd(); |
| 27 | const packageJsonPath = join(rootDir, 'package.json'); |
| 28 | const moduleBazelPath = join(rootDir, 'MODULE.bazel'); |
| 29 | let nvmrcPath = join(rootDir, '.nvmrc'); |
| 30 | if (!existsSync(nvmrcPath)) { |
| 31 | nvmrcPath = join(determineRepoBaseDirFromCwd(), '.nvmrc'); |
| 32 | } |
| 33 | |
| 34 | // Read package.json |
| 35 | const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as PackageJson; |
| 36 | const pnpmVersion = packageJson.engines?.pnpm; |
| 37 | const tsVersion = packageJson.dependencies?.typescript || packageJson.devDependencies?.typescript; |
| 38 | |
| 39 | // Read .nvmrc |
| 40 | let nvmrcVersion: string | undefined; |
| 41 | try { |
| 42 | nvmrcVersion = readFileSync(nvmrcPath, 'utf8').trim().replace(/^v/, ''); |
| 43 | } catch { |
| 44 | // .nvmrc is optional. |
| 45 | } |
| 46 | |
| 47 | // Read MODULE.bazel |
| 48 | const originalBazelContent = readFileSync(moduleBazelPath, 'utf8'); |
| 49 | let moduleBazelContent = originalBazelContent; |
| 50 | |
| 51 | if (pnpmVersion) { |
| 52 | moduleBazelContent = await syncPnpm(moduleBazelContent, pnpmVersion); |
| 53 | } |
| 54 | |
| 55 | if (tsVersion) { |
| 56 | moduleBazelContent = await syncTypeScript(moduleBazelContent, tsVersion); |
| 57 | } |
| 58 | |
| 59 | if (nvmrcVersion) { |
| 60 | moduleBazelContent = await syncNodeJs(moduleBazelContent, nvmrcVersion); |
| 61 | } |
| 62 | |
| 63 | if (originalBazelContent !== moduleBazelContent) { |
| 64 | writeFileSync(moduleBazelPath, moduleBazelContent); |
| 65 | |
| 66 | await formatFiles([moduleBazelPath]); |
| 67 | |
| 68 | ChildProcess.spawnSync(getBazelBin(), ['mod', 'deps', '--lockfile_mode=update'], { |
| 69 | suppressErrorOnFailingExitCode: true, |
| 70 | }); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /** CLI command module. */ |
| 75 | export const SyncModuleBazelModule: CommandModule = { |
nothing calls this directly
no test coverage detected