refactor(ngcc): rename INVALID_ENTRY_POINT to INCOMPATIBLE_ENTRY_POINT (#36305)

This name better reflects its meaning.

PR Close #36305
This commit is contained in:
Pete Bacon Darwin
2020-03-30 11:12:54 +01:00
committed by Alex Rickabaugh
parent 3545a49a79
commit de594ca221
6 changed files with 28 additions and 26 deletions

View File

@ -9,7 +9,7 @@ import {AbsoluteFsPath, FileSystem, join, resolve} from '../../../src/ngtsc/file
import {DependencyResolver, SortedEntryPointsInfo} from '../dependencies/dependency_resolver';
import {Logger} from '../logging/logger';
import {NgccConfiguration} from '../packages/configuration';
import {EntryPoint, INVALID_ENTRY_POINT, NO_ENTRY_POINT, getEntryPointInfo} from '../packages/entry_point';
import {EntryPoint, INCOMPATIBLE_ENTRY_POINT, NO_ENTRY_POINT, getEntryPointInfo} from '../packages/entry_point';
import {EntryPointManifest} from '../packages/entry_point_manifest';
import {PathMappings} from '../utils';
import {NGCC_DIRECTORY} from '../writing/new_entry_point_file_writer';
@ -111,7 +111,7 @@ export class DirectoryWalkerEntryPointFinder implements EntryPointFinder {
return [];
}
if (topLevelEntryPoint === INVALID_ENTRY_POINT) {
if (topLevelEntryPoint === INCOMPATIBLE_ENTRY_POINT) {
return null;
}
@ -126,7 +126,7 @@ export class DirectoryWalkerEntryPointFinder implements EntryPointFinder {
const possibleEntryPointPath = isDirectory ? path : stripJsExtension(path);
const subEntryPoint =
getEntryPointInfo(this.fs, this.config, this.logger, packagePath, possibleEntryPointPath);
if (subEntryPoint === NO_ENTRY_POINT || subEntryPoint === INVALID_ENTRY_POINT) {
if (subEntryPoint === NO_ENTRY_POINT || subEntryPoint === INCOMPATIBLE_ENTRY_POINT) {
return false;
}
entryPoints.push(subEntryPoint);

View File

@ -10,7 +10,7 @@ import {DependencyResolver, SortedEntryPointsInfo} from '../dependencies/depende
import {Logger} from '../logging/logger';
import {hasBeenProcessed} from '../packages/build_marker';
import {NgccConfiguration} from '../packages/configuration';
import {EntryPoint, EntryPointJsonProperty, INVALID_ENTRY_POINT, NO_ENTRY_POINT, getEntryPointInfo} from '../packages/entry_point';
import {EntryPoint, EntryPointJsonProperty, INCOMPATIBLE_ENTRY_POINT, NO_ENTRY_POINT, getEntryPointInfo} from '../packages/entry_point';
import {PathMappings} from '../utils';
import {EntryPointFinder} from './interface';
import {getBasePaths} from './utils';
@ -94,7 +94,7 @@ export class TargetedEntryPointFinder implements EntryPointFinder {
const packagePath = this.computePackagePath(entryPointPath);
const entryPoint =
getEntryPointInfo(this.fs, this.config, this.logger, packagePath, entryPointPath);
if (entryPoint === NO_ENTRY_POINT || entryPoint === INVALID_ENTRY_POINT) {
if (entryPoint === NO_ENTRY_POINT || entryPoint === INCOMPATIBLE_ENTRY_POINT) {
return null;
}
return entryPoint;

View File

@ -86,7 +86,7 @@ export const NO_ENTRY_POINT = 'no-entry-point';
/**
* The path has a package.json, but it is not a valid entry-point for ngcc processing.
*/
export const INVALID_ENTRY_POINT = 'invalid-entry-point';
export const INCOMPATIBLE_ENTRY_POINT = 'incompatible-entry-point';
/**
* The result of calling `getEntryPointInfo()`.
@ -94,10 +94,11 @@ export const INVALID_ENTRY_POINT = 'invalid-entry-point';
* This will be an `EntryPoint` object if an Angular entry-point was identified;
* Otherwise it will be a flag indicating one of:
* * NO_ENTRY_POINT - the path is not an entry-point or ngcc is configured to ignore it
* * INVALID_ENTRY_POINT - the path was a non-processable entry-point that should be searched
* * INCOMPATIBLE_ENTRY_POINT - the path was a non-processable entry-point that should be searched
* for sub-entry-points
*/
export type GetEntryPointResult = EntryPoint | typeof INVALID_ENTRY_POINT | typeof NO_ENTRY_POINT;
export type GetEntryPointResult =
EntryPoint | typeof INCOMPATIBLE_ENTRY_POINT | typeof NO_ENTRY_POINT;
/**
@ -107,9 +108,10 @@ export type GetEntryPointResult = EntryPoint | typeof INVALID_ENTRY_POINT | type
* @param entryPointPath the absolute path to the potential entry-point.
* @returns
* - An entry-point if it is valid.
* - `undefined` when there is no package.json at the path and there is no config to force an
* - `NO_ENTRY_POINT` when there is no package.json at the path and there is no config to force an
* entry-point or the entrypoint is `ignored`.
* - `null` there is a package.json but it is not a valid Angular compiled entry-point.
* - `INCOMPATIBLE_ENTRY_POINT` there is a package.json but it is not a valid Angular compiled
* entry-point.
*/
export function getEntryPointInfo(
fs: FileSystem, config: NgccConfiguration, logger: Logger, packagePath: AbsoluteFsPath,
@ -138,14 +140,14 @@ export function getEntryPointInfo(
if (entryPointPackageJson === null) {
// package.json exists but could not be parsed and there was no redeeming config
return INVALID_ENTRY_POINT;
return INCOMPATIBLE_ENTRY_POINT;
}
const typings = entryPointPackageJson.typings || entryPointPackageJson.types ||
guessTypingsFromPackageJson(fs, entryPointPath, entryPointPackageJson);
if (typeof typings !== 'string') {
// Missing the required `typings` property
return INVALID_ENTRY_POINT;
return INCOMPATIBLE_ENTRY_POINT;
}
// An entry-point is assumed to be compiled by Angular if there is either:

View File

@ -12,7 +12,7 @@ import {Logger} from '../logging/logger';
import {NGCC_VERSION} from './build_marker';
import {NgccConfiguration} from './configuration';
import {EntryPoint, INVALID_ENTRY_POINT, NO_ENTRY_POINT, getEntryPointInfo} from './entry_point';
import {EntryPoint, INCOMPATIBLE_ENTRY_POINT, NO_ENTRY_POINT, getEntryPointInfo} from './entry_point';
/**
* Manages reading and writing a manifest file that contains a list of all the entry-points that
@ -71,7 +71,7 @@ export class EntryPointManifest {
for (const [packagePath, entryPointPath] of entryPointPaths) {
const result =
getEntryPointInfo(this.fs, this.config, this.logger, packagePath, entryPointPath);
if (result === NO_ENTRY_POINT || result === INVALID_ENTRY_POINT) {
if (result === NO_ENTRY_POINT || result === INCOMPATIBLE_ENTRY_POINT) {
throw new Error(
`The entry-point manifest at ${manifestPath} contained an invalid pair of package paths: [${packagePath}, ${entryPointPath}]`);
} else {