MCPcopy Create free account
hub / github.com/angular/dev-infra / getExpectedVersionFromPnpmLockUpstream

Function getExpectedVersionFromPnpmLockUpstream

ng-dev/utils/version-check.ts:71–102  ·  view source on GitHub ↗

Retrieves the pnpm lock file from upstream on the primary branch and extracts the version.

()

Source from the content-addressed store, hash-verified

69 } catch {
70 return false;
71 }
72 }
73
74 if (localVersion !== expectedVersion) {
75 Log.warn(' ⚠ Your locally installed version of the `ng-dev` tool is outdated and not');
76 Log.warn(' matching with the version in the `pnpm-lock.yaml` file.');
77 Log.warn(' Re-install the dependencies to ensure you are using the correct version.');
78 return false;
79 }
80
81 return true;
82}
83
84/** Retrieves the expected ng-dev version from the pnpm lockfile using `pnpm list`. */
85async function getExpectedVersionFromPnpm(workspacePath: string): Promise<string | null> {
86 try {
87 const {stdout} = await ChildProcess.spawn(
88 'pnpm',
89 ['list', '@angular/ng-dev', '--json', '--lockfile-only'],
90 {
91 cwd: workspacePath,
92 mode: 'silent',
93 suppressErrorOnFailingExitCode: true,
94 },
95 );
96 return extractNgDevVersionFromPnpmList(stdout);
97 } catch (e) {
98 Log.debug('Could not find expected ng-dev version from `pnpm list`:', e);
99 return null;
100 }
101}
102
103interface PnpmListProject {
104 dependencies?: Record<string, {version: string}>;
105 devDependencies?: Record<string, {version: string}>;

Callers 1

Calls 2

getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected