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:
parent
36e927a8c6
commit
7e62aa0c6e
|
@ -9,7 +9,7 @@ import {AbsoluteFsPath, FileSystem, join, resolve} from '../../../src/ngtsc/file
|
||||||
import {DependencyResolver, SortedEntryPointsInfo} from '../dependencies/dependency_resolver';
|
import {DependencyResolver, SortedEntryPointsInfo} from '../dependencies/dependency_resolver';
|
||||||
import {Logger} from '../logging/logger';
|
import {Logger} from '../logging/logger';
|
||||||
import {NgccConfiguration} from '../packages/configuration';
|
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 {EntryPointManifest} from '../packages/entry_point_manifest';
|
||||||
import {PathMappings} from '../utils';
|
import {PathMappings} from '../utils';
|
||||||
import {NGCC_DIRECTORY} from '../writing/new_entry_point_file_writer';
|
import {NGCC_DIRECTORY} from '../writing/new_entry_point_file_writer';
|
||||||
|
@ -111,7 +111,7 @@ export class DirectoryWalkerEntryPointFinder implements EntryPointFinder {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topLevelEntryPoint === INVALID_ENTRY_POINT) {
|
if (topLevelEntryPoint === INCOMPATIBLE_ENTRY_POINT) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ export class DirectoryWalkerEntryPointFinder implements EntryPointFinder {
|
||||||
const possibleEntryPointPath = isDirectory ? path : stripJsExtension(path);
|
const possibleEntryPointPath = isDirectory ? path : stripJsExtension(path);
|
||||||
const subEntryPoint =
|
const subEntryPoint =
|
||||||
getEntryPointInfo(this.fs, this.config, this.logger, packagePath, possibleEntryPointPath);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
entryPoints.push(subEntryPoint);
|
entryPoints.push(subEntryPoint);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {DependencyResolver, SortedEntryPointsInfo} from '../dependencies/depende
|
||||||
import {Logger} from '../logging/logger';
|
import {Logger} from '../logging/logger';
|
||||||
import {hasBeenProcessed} from '../packages/build_marker';
|
import {hasBeenProcessed} from '../packages/build_marker';
|
||||||
import {NgccConfiguration} from '../packages/configuration';
|
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 {PathMappings} from '../utils';
|
||||||
import {EntryPointFinder} from './interface';
|
import {EntryPointFinder} from './interface';
|
||||||
import {getBasePaths} from './utils';
|
import {getBasePaths} from './utils';
|
||||||
|
@ -94,7 +94,7 @@ export class TargetedEntryPointFinder implements EntryPointFinder {
|
||||||
const packagePath = this.computePackagePath(entryPointPath);
|
const packagePath = this.computePackagePath(entryPointPath);
|
||||||
const entryPoint =
|
const entryPoint =
|
||||||
getEntryPointInfo(this.fs, this.config, this.logger, packagePath, entryPointPath);
|
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 null;
|
||||||
}
|
}
|
||||||
return entryPoint;
|
return entryPoint;
|
||||||
|
|
|
@ -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.
|
* 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()`.
|
* 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;
|
* This will be an `EntryPoint` object if an Angular entry-point was identified;
|
||||||
* Otherwise it will be a flag indicating one of:
|
* 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
|
* * 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
|
* 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.
|
* @param entryPointPath the absolute path to the potential entry-point.
|
||||||
* @returns
|
* @returns
|
||||||
* - An entry-point if it is valid.
|
* - 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`.
|
* 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(
|
export function getEntryPointInfo(
|
||||||
fs: FileSystem, config: NgccConfiguration, logger: Logger, packagePath: AbsoluteFsPath,
|
fs: FileSystem, config: NgccConfiguration, logger: Logger, packagePath: AbsoluteFsPath,
|
||||||
|
@ -138,14 +140,14 @@ export function getEntryPointInfo(
|
||||||
|
|
||||||
if (entryPointPackageJson === null) {
|
if (entryPointPackageJson === null) {
|
||||||
// package.json exists but could not be parsed and there was no redeeming config
|
// 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 ||
|
const typings = entryPointPackageJson.typings || entryPointPackageJson.types ||
|
||||||
guessTypingsFromPackageJson(fs, entryPointPath, entryPointPackageJson);
|
guessTypingsFromPackageJson(fs, entryPointPath, entryPointPackageJson);
|
||||||
if (typeof typings !== 'string') {
|
if (typeof typings !== 'string') {
|
||||||
// Missing the required `typings` property
|
// 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:
|
// An entry-point is assumed to be compiled by Angular if there is either:
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {Logger} from '../logging/logger';
|
||||||
|
|
||||||
import {NGCC_VERSION} from './build_marker';
|
import {NGCC_VERSION} from './build_marker';
|
||||||
import {NgccConfiguration} from './configuration';
|
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
|
* 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) {
|
for (const [packagePath, entryPointPath] of entryPointPaths) {
|
||||||
const result =
|
const result =
|
||||||
getEntryPointInfo(this.fs, this.config, this.logger, packagePath, entryPointPath);
|
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(
|
throw new Error(
|
||||||
`The entry-point manifest at ${manifestPath} contained an invalid pair of package paths: [${packagePath}, ${entryPointPath}]`);
|
`The entry-point manifest at ${manifestPath} contained an invalid pair of package paths: [${packagePath}, ${entryPointPath}]`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {AbsoluteFsPath, FileSystem, absoluteFrom, getFileSystem} from '../../../
|
||||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||||
import {loadTestFiles} from '../../../test/helpers';
|
import {loadTestFiles} from '../../../test/helpers';
|
||||||
import {NgccConfiguration} from '../../src/packages/configuration';
|
import {NgccConfiguration} from '../../src/packages/configuration';
|
||||||
import {EntryPoint, INVALID_ENTRY_POINT, NO_ENTRY_POINT, SUPPORTED_FORMAT_PROPERTIES, getEntryPointFormat, getEntryPointInfo} from '../../src/packages/entry_point';
|
import {EntryPoint, INCOMPATIBLE_ENTRY_POINT, NO_ENTRY_POINT, SUPPORTED_FORMAT_PROPERTIES, getEntryPointFormat, getEntryPointInfo} from '../../src/packages/entry_point';
|
||||||
import {MockLogger} from '../helpers/mock_logger';
|
import {MockLogger} from '../helpers/mock_logger';
|
||||||
|
|
||||||
runInEachFileSystem(() => {
|
runInEachFileSystem(() => {
|
||||||
|
@ -165,7 +165,7 @@ runInEachFileSystem(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return `INVALID_ENTRY_POINT` if there is no typings or types field in the package.json',
|
it('should return `INCOMPATIBLE_ENTRY_POINT` if there is no typings or types field in the package.json',
|
||||||
() => {
|
() => {
|
||||||
loadTestFiles([
|
loadTestFiles([
|
||||||
{
|
{
|
||||||
|
@ -182,10 +182,10 @@ runInEachFileSystem(() => {
|
||||||
const entryPoint = getEntryPointInfo(
|
const entryPoint = getEntryPointInfo(
|
||||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||||
_('/project/node_modules/some_package/missing_typings'));
|
_('/project/node_modules/some_package/missing_typings'));
|
||||||
expect(entryPoint).toBe(INVALID_ENTRY_POINT);
|
expect(entryPoint).toBe(INCOMPATIBLE_ENTRY_POINT);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return `INVALID_ENTRY_POINT` if the typings or types field is not a string in the package.json',
|
it('should return `INCOMPATIBLE_ENTRY_POINT` if the typings or types field is not a string in the package.json',
|
||||||
() => {
|
() => {
|
||||||
loadTestFiles([
|
loadTestFiles([
|
||||||
{
|
{
|
||||||
|
@ -202,7 +202,7 @@ runInEachFileSystem(() => {
|
||||||
const entryPoint = getEntryPointInfo(
|
const entryPoint = getEntryPointInfo(
|
||||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||||
_('/project/node_modules/some_package/typings_array'));
|
_('/project/node_modules/some_package/typings_array'));
|
||||||
expect(entryPoint).toBe(INVALID_ENTRY_POINT);
|
expect(entryPoint).toBe(INCOMPATIBLE_ENTRY_POINT);
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let prop of SUPPORTED_FORMAT_PROPERTIES) {
|
for (let prop of SUPPORTED_FORMAT_PROPERTIES) {
|
||||||
|
@ -359,7 +359,7 @@ runInEachFileSystem(() => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return `INVALID_ENTRY_POINT` if the package.json is not valid JSON', () => {
|
it('should return `INCOMPATIBLE_ENTRY_POINT` if the package.json is not valid JSON', () => {
|
||||||
loadTestFiles([
|
loadTestFiles([
|
||||||
// package.json might not be a valid JSON
|
// package.json might not be a valid JSON
|
||||||
// for example, @schematics/angular contains a package.json blueprint
|
// for example, @schematics/angular contains a package.json blueprint
|
||||||
|
@ -373,7 +373,7 @@ runInEachFileSystem(() => {
|
||||||
const entryPoint = getEntryPointInfo(
|
const entryPoint = getEntryPointInfo(
|
||||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||||
_('/project/node_modules/some_package/unexpected_symbols'));
|
_('/project/node_modules/some_package/unexpected_symbols'));
|
||||||
expect(entryPoint).toBe(INVALID_ENTRY_POINT);
|
expect(entryPoint).toBe(INCOMPATIBLE_ENTRY_POINT);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ runInEachFileSystem(() => {
|
||||||
const result = getEntryPointInfo(
|
const result = getEntryPointInfo(
|
||||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||||
_('/project/node_modules/some_package/valid_entry_point'));
|
_('/project/node_modules/some_package/valid_entry_point'));
|
||||||
if (result === NO_ENTRY_POINT || result === INVALID_ENTRY_POINT) {
|
if (result === NO_ENTRY_POINT || result === INCOMPATIBLE_ENTRY_POINT) {
|
||||||
return fail(`Expected an entry point but got ${result}`);
|
return fail(`Expected an entry point but got ${result}`);
|
||||||
}
|
}
|
||||||
entryPoint = result;
|
entryPoint = result;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {FileSystem, absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_s
|
||||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||||
import {loadTestFiles} from '../../../test/helpers';
|
import {loadTestFiles} from '../../../test/helpers';
|
||||||
import {NgccConfiguration} from '../../src/packages/configuration';
|
import {NgccConfiguration} from '../../src/packages/configuration';
|
||||||
import {EntryPoint, EntryPointFormat, EntryPointJsonProperty, INVALID_ENTRY_POINT, NO_ENTRY_POINT, getEntryPointInfo} from '../../src/packages/entry_point';
|
import {EntryPoint, EntryPointFormat, EntryPointJsonProperty, INCOMPATIBLE_ENTRY_POINT, NO_ENTRY_POINT, getEntryPointInfo} from '../../src/packages/entry_point';
|
||||||
import {EntryPointBundle, makeEntryPointBundle} from '../../src/packages/entry_point_bundle';
|
import {EntryPointBundle, makeEntryPointBundle} from '../../src/packages/entry_point_bundle';
|
||||||
import {FileWriter} from '../../src/writing/file_writer';
|
import {FileWriter} from '../../src/writing/file_writer';
|
||||||
import {NewEntryPointFileWriter} from '../../src/writing/new_entry_point_file_writer';
|
import {NewEntryPointFileWriter} from '../../src/writing/new_entry_point_file_writer';
|
||||||
|
@ -108,7 +108,7 @@ runInEachFileSystem(() => {
|
||||||
const config = new NgccConfiguration(fs, _('/'));
|
const config = new NgccConfiguration(fs, _('/'));
|
||||||
const result = getEntryPointInfo(
|
const result = getEntryPointInfo(
|
||||||
fs, config, logger, _('/node_modules/test'), _('/node_modules/test')) !;
|
fs, config, logger, _('/node_modules/test'), _('/node_modules/test')) !;
|
||||||
if (result === NO_ENTRY_POINT || result === INVALID_ENTRY_POINT) {
|
if (result === NO_ENTRY_POINT || result === INCOMPATIBLE_ENTRY_POINT) {
|
||||||
return fail(`Expected an entry point but got ${result}`);
|
return fail(`Expected an entry point but got ${result}`);
|
||||||
}
|
}
|
||||||
entryPoint = result;
|
entryPoint = result;
|
||||||
|
@ -248,7 +248,7 @@ runInEachFileSystem(() => {
|
||||||
const config = new NgccConfiguration(fs, _('/'));
|
const config = new NgccConfiguration(fs, _('/'));
|
||||||
const result = getEntryPointInfo(
|
const result = getEntryPointInfo(
|
||||||
fs, config, logger, _('/node_modules/test'), _('/node_modules/test/a')) !;
|
fs, config, logger, _('/node_modules/test'), _('/node_modules/test/a')) !;
|
||||||
if (result === NO_ENTRY_POINT || result === INVALID_ENTRY_POINT) {
|
if (result === NO_ENTRY_POINT || result === INCOMPATIBLE_ENTRY_POINT) {
|
||||||
return fail(`Expected an entry point but got ${result}`);
|
return fail(`Expected an entry point but got ${result}`);
|
||||||
}
|
}
|
||||||
entryPoint = result;
|
entryPoint = result;
|
||||||
|
@ -377,7 +377,7 @@ runInEachFileSystem(() => {
|
||||||
const config = new NgccConfiguration(fs, _('/'));
|
const config = new NgccConfiguration(fs, _('/'));
|
||||||
const result = getEntryPointInfo(
|
const result = getEntryPointInfo(
|
||||||
fs, config, new MockLogger(), _('/node_modules/test'), _('/node_modules/test/b')) !;
|
fs, config, new MockLogger(), _('/node_modules/test'), _('/node_modules/test/b')) !;
|
||||||
if (result === NO_ENTRY_POINT || result === INVALID_ENTRY_POINT) {
|
if (result === NO_ENTRY_POINT || result === INCOMPATIBLE_ENTRY_POINT) {
|
||||||
return fail(`Expected an entry point but got ${result}`);
|
return fail(`Expected an entry point but got ${result}`);
|
||||||
}
|
}
|
||||||
entryPoint = result;
|
entryPoint = result;
|
||||||
|
|
Loading…
Reference in New Issue