(workspacePath: string)
| 44 | * @returns a boolean indicating success or failure. |
| 45 | */ |
| 46 | export async function verifyNgDevToolIsUpToDate(workspacePath: string): Promise<boolean> { |
| 47 | const packageJsonPath = path.join(workspacePath, workspaceRelativePackageJsonPath); |
| 48 | const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); |
| 49 | // If we are operating in the actual dev-infra repo, always return `true`. |
| 50 | if (packageJson.name === '@angular/build-tooling') { |
| 51 | Log.debug('Skipping ng-dev version check as this is a locally generated version.'); |
| 52 | return true; |
| 53 | } |
| 54 | const expectedVersion = await getExpectedVersionFromPnpmLockUpstream(); |
| 55 | |
| 56 | Log.debug('Checking ng-dev version in lockfile and in the running script:'); |
| 57 | Log.debug(` Local: ${localVersion}`); |
| 58 | Log.debug(` Expected: ${expectedVersion}`); |
| 59 | |
| 60 | if (localVersion !== expectedVersion) { |
| 61 | Log.warn(' ⚠ Your locally installed version of the `ng-dev` tool is outdated and not'); |
| 62 | Log.warn(' matching with the version in the `package.json` file.'); |
| 63 | Log.warn(' Re-install the dependencies to ensure you are using the correct version.'); |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | return true; |
| 68 | } |
| 69 | |
| 70 | /** Retrieves the pnpm lock file from upstream on the primary branch and extracts the version. */ |
| 71 | async function getExpectedVersionFromPnpmLockUpstream(): Promise<string> { |
no test coverage detected