( config: T & Partial<DevInfraReleaseConfig>, )
| 138 | |
| 139 | /** Asserts that the given configuration is a valid `DevInfraReleaseConfig`. */ |
| 140 | export function assertValidReleaseConfig<T extends NgDevConfig>( |
| 141 | config: T & Partial<DevInfraReleaseConfig>, |
| 142 | ): asserts config is T & DevInfraReleaseConfig { |
| 143 | // List of errors encountered validating the config. |
| 144 | const errors: string[] = []; |
| 145 | |
| 146 | if (config.release === undefined) { |
| 147 | throw new ConfigValidationError('No configuration provided for `release`'); |
| 148 | } |
| 149 | if (config.release.representativeNpmPackage === undefined) { |
| 150 | errors.push(`No "representativeNpmPackage" configured for releasing.`); |
| 151 | } |
| 152 | if (config.release.npmPackages === undefined) { |
| 153 | errors.push(`No "npmPackages" configured for releasing.`); |
| 154 | } |
| 155 | if (config.release.buildPackages === undefined) { |
| 156 | errors.push(`No "buildPackages" function configured for releasing.`); |
| 157 | } |
| 158 | |
| 159 | if (config.release.representativeNpmPackage && config.release.npmPackages) { |
| 160 | const representativePkgEntry = config.release.npmPackages.find( |
| 161 | (pkg) => pkg.name === config.release?.representativeNpmPackage, |
| 162 | ); |
| 163 | |
| 164 | if (representativePkgEntry === undefined) { |
| 165 | errors.push( |
| 166 | `Configured "representativeNpmPackage" (${representativePkgEntry}) does not match ` + |
| 167 | `a package in "npmPackages".`, |
| 168 | ); |
| 169 | } else if (representativePkgEntry.experimental) { |
| 170 | errors.push( |
| 171 | `Configured "representativeNpmPackage" (${representativePkgEntry}) corresponds to an ` + |
| 172 | `experimental package. The representative NPM package is expected to be a ` + |
| 173 | `long-standing and non-experimental package of the project.`, |
| 174 | ); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | if (errors.length) { |
| 179 | throw new ConfigValidationError('Invalid `release` configuration', errors); |
| 180 | } |
| 181 | } |
no test coverage detected