Retrieves the pnpm lock file from upstream on the primary branch and extracts the version.
()
| 69 | if (localVersion !== expectedVersion) { |
| 70 | Log.warn(' ⚠ Your locally installed version of the `ng-dev` tool is outdated and not'); |
| 71 | Log.warn(' matching with the version in the `package.json` file.'); |
| 72 | Log.warn(' Re-install the dependencies to ensure you are using the correct version.'); |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | /** Retrieves the pnpm lock file from upstream on the primary branch and extracts the version. */ |
| 80 | async function getExpectedVersionFromPnpmLockUpstream(): Promise<string | null> { |
| 81 | const git = await GitClient.get(); |
| 82 | try { |
| 83 | const {data} = await git.github.repos.getContent({ |
| 84 | repo: git.remoteConfig.name, |
| 85 | owner: git.remoteConfig.owner, |
| 86 | ref: git.remoteConfig.mainBranchName, |
| 87 | // This media type ensures requested files come back as the raw content. |
| 88 | mediaType: {format: 'application/vnd.github.raw+json'}, |
| 89 | path: 'pnpm-lock.yaml', |
| 90 | }); |
| 91 | if (Array.isArray(data) || data.type !== 'file') { |
| 92 | throw Error( |
| 93 | `A non-single file of content was retrieved from Github when the pnpm-lock.yaml file was requested`, |
| 94 | ); |
| 95 | } |
| 96 | const content = Buffer.from(data.content, data.encoding as BufferEncoding).toString('utf-8'); |
| 97 | const expectedVersion = extractNgDevVersionFromPnpmLock(content); |
| 98 | if (expectedVersion === null) { |
| 99 | throw Error('Could not find @angular/ng-dev entry in pnpm-lock.yaml'); |
| 100 | } |
| 101 | |
| 102 | return expectedVersion; |
| 103 | } catch (e) { |
| 104 | Log.debug('Could not find expected ng-dev version from `pnpm-lock.yaml` file:', e); |
| 105 | return null; |
no test coverage detected