|
1 | 1 | import {error} from '@angular/dev-infra-private/ng-dev';
|
2 |
| -import {dirname, join} from 'path'; |
3 | 2 | import chalk from 'chalk';
|
4 |
| -import {releasePackages} from '../../.ng-dev/release'; |
5 |
| -import {readFileSync} from 'fs'; |
| 3 | +import {existsSync, readFileSync} from 'fs'; |
| 4 | +import {dirname, join} from 'path'; |
6 | 5 | import semver from 'semver';
|
7 | 6 |
|
| 7 | +import {releasePackages} from '../../.ng-dev/release'; |
| 8 | + |
8 | 9 | /** Path to the directory containing all package sources. */
|
9 | 10 | const packagesDir = join(__dirname, '../../src');
|
10 | 11 |
|
11 | 12 | /** Asserts that valid migration collections for `ng-update` are configured. */
|
12 | 13 | export async function assertValidUpdateMigrationCollections(newVersion: semver.SemVer) {
|
13 | 14 | const failures: string[] = [];
|
14 | 15 | releasePackages.forEach(packageName => {
|
| 16 | + const packageDir = join(packagesDir, packageName); |
| 17 | + let packageJsonPath = join(packageDir, 'package.json'); |
| 18 | + |
| 19 | + // Some `package.json` files are auto-generated. In such cases we will have |
| 20 | + // a `package-base.json` file (as seen in the `material-experimental` package). |
| 21 | + // This will be the handwritten base config we use for validation. |
| 22 | + if (!existsSync(packageJsonPath)) { |
| 23 | + packageJsonPath = join(packageDir, 'package-base.json'); |
| 24 | + } |
| 25 | + |
15 | 26 | failures.push(
|
16 |
| - ...checkPackageJsonMigrations(join(packagesDir, packageName, 'package.json'), newVersion).map( |
17 |
| - f => chalk.yellow(` ⮑ ${chalk.bold(packageName)}: ${f}`), |
| 27 | + ...checkPackageJsonMigrations(packageJsonPath, newVersion).map(f => |
| 28 | + chalk.yellow(` ⮑ ${chalk.bold(packageName)}: ${f}`), |
18 | 29 | ),
|
19 | 30 | );
|
20 | 31 | });
|
|
0 commit comments