style(ngcc): reformat of ngcc after clang update (#36447)
PR Close #36447
This commit is contained in:

committed by
Kara Erickson

parent
c8bef1259c
commit
8be8466a00
@ -8,7 +8,7 @@
|
||||
import {absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {loadTestFiles} from '../../../test/helpers';
|
||||
import {NGCC_VERSION, cleanPackageJson, hasBeenProcessed, markAsProcessed, needsCleaning} from '../../src/packages/build_marker';
|
||||
import {cleanPackageJson, hasBeenProcessed, markAsProcessed, needsCleaning, NGCC_VERSION} from '../../src/packages/build_marker';
|
||||
import {EntryPointPackageJson} from '../../src/packages/entry_point';
|
||||
import {DirectPackageJsonUpdater} from '../../src/writing/package_json_updater';
|
||||
|
||||
@ -192,8 +192,9 @@ runInEachFileSystem(() => {
|
||||
.toBe(false);
|
||||
});
|
||||
|
||||
it('should return false if no markers exist',
|
||||
() => { expect(hasBeenProcessed({name: 'test'}, 'module')).toBe(false); });
|
||||
it('should return false if no markers exist', () => {
|
||||
expect(hasBeenProcessed({name: 'test'}, 'module')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('needsCleaning()', () => {
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
import {createHash} from 'crypto';
|
||||
|
||||
import {FileSystem, absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {absoluteFrom, FileSystem, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {loadTestFiles} from '../../../test/helpers';
|
||||
import {DEFAULT_NGCC_CONFIG, NgccConfiguration} from '../../src/packages/configuration';
|
||||
@ -27,8 +27,8 @@ runInEachFileSystem(() => {
|
||||
it('should error if a project level config file is badly formatted', () => {
|
||||
loadTestFiles([{name: _Abs('/project-1/ngcc.config.js'), contents: `bad js code`}]);
|
||||
expect(() => new NgccConfiguration(fs, _Abs('/project-1')))
|
||||
.toThrowError(
|
||||
`Invalid project configuration file at "${_Abs('/project-1/ngcc.config.js')}": Unexpected identifier`);
|
||||
.toThrowError(`Invalid project configuration file at "${
|
||||
_Abs('/project-1/ngcc.config.js')}": Unexpected identifier`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -50,8 +50,8 @@ runInEachFileSystem(() => {
|
||||
};`
|
||||
}]);
|
||||
const project1Conf = new NgccConfiguration(fs, project1);
|
||||
const expectedProject1Config =
|
||||
`{"packages":{"${project1Package1}":[{"entryPoints":{"${project1Package1EntryPoint1}":{}},"versionRange":"*"}]}}`;
|
||||
const expectedProject1Config = `{"packages":{"${project1Package1}":[{"entryPoints":{"${
|
||||
project1Package1EntryPoint1}":{}},"versionRange":"*"}]}}`;
|
||||
expect(project1Conf.hash)
|
||||
.toEqual(createHash('md5').update(expectedProject1Config).digest('hex'));
|
||||
|
||||
@ -71,8 +71,8 @@ runInEachFileSystem(() => {
|
||||
};`
|
||||
}]);
|
||||
const project2Conf = new NgccConfiguration(fs, project2);
|
||||
const expectedProject2Config =
|
||||
`{"packages":{"${project2Package1}":[{"entryPoints":{"${project2Package1EntryPoint1}":{"ignore":true}},"versionRange":"*"}]}}`;
|
||||
const expectedProject2Config = `{"packages":{"${project2Package1}":[{"entryPoints":{"${
|
||||
project2Package1EntryPoint1}":{"ignore":true}},"versionRange":"*"}]}}`;
|
||||
expect(project2Conf.hash)
|
||||
.toEqual(createHash('md5').update(expectedProject2Config).digest('hex'));
|
||||
});
|
||||
@ -136,8 +136,9 @@ runInEachFileSystem(() => {
|
||||
}]);
|
||||
const configuration = new NgccConfiguration(fs, _Abs('/project-1'));
|
||||
expect(() => configuration.getConfig(_Abs('/project-1/node_modules/package-1'), '1.0.0'))
|
||||
.toThrowError(
|
||||
`Invalid package configuration file at "${_Abs('/project-1/node_modules/package-1/ngcc.config.js')}": Unexpected identifier`);
|
||||
.toThrowError(`Invalid package configuration file at "${
|
||||
_Abs(
|
||||
'/project-1/node_modules/package-1/ngcc.config.js')}": Unexpected identifier`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -243,7 +244,7 @@ runInEachFileSystem(() => {
|
||||
]);
|
||||
|
||||
const configuration = new NgccConfiguration(fs, _Abs('/project-1'));
|
||||
const getConfig = (packageName: string, version: string | null) =>
|
||||
const getConfig = (packageName: string, version: string|null) =>
|
||||
configuration.getConfig(_Abs(`/project-1/node_modules/${packageName}`), version);
|
||||
|
||||
// Default version range: *
|
||||
@ -343,7 +344,6 @@ runInEachFileSystem(() => {
|
||||
versionRange: '*',
|
||||
entryPoints: {[_Abs('/project-1/node_modules/@angular/common')]: {}}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should override package level config with project level config per package', () => {
|
||||
@ -412,8 +412,7 @@ runInEachFileSystem(() => {
|
||||
configuration.getConfig(_Abs('/project-1/node_modules/package-1'), '1.0.0');
|
||||
expect(config).toEqual({
|
||||
versionRange: '*',
|
||||
entryPoints:
|
||||
{[_Abs('/project-1/node_modules/package-1/default-level-entry-point')]: {}}
|
||||
entryPoints: {[_Abs('/project-1/node_modules/package-1/default-level-entry-point')]: {}}
|
||||
});
|
||||
});
|
||||
|
||||
@ -427,8 +426,7 @@ runInEachFileSystem(() => {
|
||||
// merge entry-points.
|
||||
expect(config).toEqual({
|
||||
versionRange: '1.0.0',
|
||||
entryPoints:
|
||||
{[_Abs('/project-1/node_modules/package-1/package-level-entry-point')]: {}}
|
||||
entryPoints: {[_Abs('/project-1/node_modules/package-1/package-level-entry-point')]: {}}
|
||||
});
|
||||
});
|
||||
|
||||
@ -465,8 +463,7 @@ runInEachFileSystem(() => {
|
||||
// merge entry-points.
|
||||
expect(config).toEqual({
|
||||
versionRange: '*',
|
||||
entryPoints:
|
||||
{[_Abs('/project-1/node_modules/package-1/project-level-entry-point')]: {}}
|
||||
entryPoints: {[_Abs('/project-1/node_modules/package-1/project-level-entry-point')]: {}}
|
||||
});
|
||||
});
|
||||
|
||||
@ -490,7 +487,7 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
|
||||
const configuration = new NgccConfiguration(fs, _Abs('/project-1'));
|
||||
const getConfig = (packageName: string, version: string | null) =>
|
||||
const getConfig = (packageName: string, version: string|null) =>
|
||||
configuration.getConfig(_Abs(`/project-1/node_modules/${packageName}`), version);
|
||||
|
||||
// Default version range: *
|
||||
|
@ -13,7 +13,6 @@ import {makeEntryPointBundle} from '../../src/packages/entry_point_bundle';
|
||||
|
||||
runInEachFileSystem(() => {
|
||||
describe('entry point bundle', () => {
|
||||
|
||||
function setupMockFileSystem(): void {
|
||||
const _ = absoluteFrom;
|
||||
loadTestFiles([
|
||||
@ -196,7 +195,7 @@ runInEachFileSystem(() => {
|
||||
'/node_modules/other/index.d.ts',
|
||||
].map(p => absoluteFrom(p).toString())));
|
||||
|
||||
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
||||
expect(esm5bundle.dts!.program.getSourceFiles().map(sf => sf.fileName))
|
||||
.toEqual(jasmine.arrayWithExactContents([
|
||||
// All modules in the dts program should be declaration files
|
||||
'/node_modules/test/index.d.ts',
|
||||
@ -231,7 +230,7 @@ runInEachFileSystem(() => {
|
||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
||||
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
||||
expect(esm5bundle.dts!.program.getSourceFiles().map(sf => sf.fileName))
|
||||
.toContain(absoluteFrom('/node_modules/test/internal.d.ts'));
|
||||
});
|
||||
|
||||
@ -253,7 +252,7 @@ runInEachFileSystem(() => {
|
||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ true);
|
||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||
.toContain(absoluteFrom('/node_modules/internal/esm2015/src/internal.js'));
|
||||
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
||||
expect(esm5bundle.dts!.program.getSourceFiles().map(sf => sf.fileName))
|
||||
.toContain(absoluteFrom('/node_modules/internal/src/internal.d.ts'));
|
||||
});
|
||||
|
||||
@ -275,7 +274,7 @@ runInEachFileSystem(() => {
|
||||
/* pathMappings */ undefined, /* mirrorDtsFromSrc */ false);
|
||||
expect(esm5bundle.src.program.getSourceFiles().map(sf => sf.fileName))
|
||||
.toContain(absoluteFrom('/node_modules/test/internal.js'));
|
||||
expect(esm5bundle.dts !.program.getSourceFiles().map(sf => sf.fileName))
|
||||
expect(esm5bundle.dts!.program.getSourceFiles().map(sf => sf.fileName))
|
||||
.not.toContain(absoluteFrom('/node_modules/test/internal.d.ts'));
|
||||
});
|
||||
});
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
import {createHash} from 'crypto';
|
||||
|
||||
import {FileSystem, absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {absoluteFrom, FileSystem, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {loadTestFiles} from '../../../test/helpers';
|
||||
import {NGCC_VERSION} from '../../src/packages/build_marker';
|
||||
@ -135,13 +135,15 @@ runInEachFileSystem(() => {
|
||||
_Abs('/project/node_modules/__ngcc_entry_points__.json'), JSON.stringify(manifestFile));
|
||||
const entryPoints = manifest.readEntryPointsUsingManifest(_Abs('/project/node_modules'));
|
||||
expect(entryPoints).toEqual([{
|
||||
name: 'some_package/valid_entry_point', packageJson: jasmine.any(Object),
|
||||
package: _Abs('/project/node_modules/some_package'),
|
||||
path: _Abs('/project/node_modules/some_package/valid_entry_point'),
|
||||
typings: _Abs(
|
||||
'/project/node_modules/some_package/valid_entry_point/valid_entry_point.d.ts'),
|
||||
compiledByAngular: true, ignoreMissingDependencies: false,
|
||||
generateDeepReexports: false,
|
||||
name: 'some_package/valid_entry_point',
|
||||
packageJson: jasmine.any(Object),
|
||||
package: _Abs('/project/node_modules/some_package'),
|
||||
path: _Abs('/project/node_modules/some_package/valid_entry_point'),
|
||||
typings:
|
||||
_Abs('/project/node_modules/some_package/valid_entry_point/valid_entry_point.d.ts'),
|
||||
compiledByAngular: true,
|
||||
ignoreMissingDependencies: false,
|
||||
generateDeepReexports: false,
|
||||
} as any]);
|
||||
});
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AbsoluteFsPath, FileSystem, absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {absoluteFrom, AbsoluteFsPath, FileSystem, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {loadTestFiles} from '../../../test/helpers';
|
||||
import {NgccConfiguration} from '../../src/packages/configuration';
|
||||
import {EntryPoint, INCOMPATIBLE_ENTRY_POINT, NO_ENTRY_POINT, SUPPORTED_FORMAT_PROPERTIES, getEntryPointFormat, getEntryPointInfo} from '../../src/packages/entry_point';
|
||||
import {EntryPoint, getEntryPointFormat, getEntryPointInfo, INCOMPATIBLE_ENTRY_POINT, NO_ENTRY_POINT, SUPPORTED_FORMAT_PROPERTIES} from '../../src/packages/entry_point';
|
||||
import {MockLogger} from '../helpers/mock_logger';
|
||||
|
||||
runInEachFileSystem(() => {
|
||||
@ -69,8 +69,7 @@ runInEachFileSystem(() => {
|
||||
]);
|
||||
const config = new NgccConfiguration(fs, _('/project'));
|
||||
spyOn(config, 'getConfig').and.returnValue({
|
||||
entryPoints:
|
||||
{[_('/project/node_modules/some_package/valid_entry_point')]: {ignore: true}}
|
||||
entryPoints: {[_('/project/node_modules/some_package/valid_entry_point')]: {ignore: true}}
|
||||
});
|
||||
const entryPoint = getEntryPointInfo(
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
@ -102,8 +101,9 @@ runInEachFileSystem(() => {
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
_('/project/node_modules/some_package/valid_entry_point'));
|
||||
const overriddenPackageJson = {
|
||||
...loadPackageJson(fs, '/project/node_modules/some_package/valid_entry_point'),
|
||||
...override};
|
||||
...loadPackageJson(fs, '/project/node_modules/some_package/valid_entry_point'),
|
||||
...override
|
||||
};
|
||||
expect(entryPoint).toEqual({
|
||||
name: 'some_package/valid_entry_point',
|
||||
package: SOME_PACKAGE,
|
||||
@ -145,8 +145,7 @@ runInEachFileSystem(() => {
|
||||
const override =
|
||||
JSON.parse(createPackageJson('missing_package_json', {excludes: ['name']}));
|
||||
spyOn(config, 'getConfig').and.returnValue({
|
||||
entryPoints:
|
||||
{[_('/project/node_modules/some_package/missing_package_json')]: {override}}
|
||||
entryPoints: {[_('/project/node_modules/some_package/missing_package_json')]: {override}}
|
||||
});
|
||||
const entryPoint = getEntryPointInfo(
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
@ -211,37 +210,38 @@ runInEachFileSystem(() => {
|
||||
// Let's give 'module' a specific path, otherwise compute it based on the property.
|
||||
const typingsPath = prop === 'module' ? 'index' : `${prop}/missing_typings`;
|
||||
|
||||
it(`should return an object if it can guess the typings path from the "${prop}" field`, () => {
|
||||
loadTestFiles([
|
||||
{
|
||||
name: _('/project/node_modules/some_package/missing_typings/package.json'),
|
||||
contents: createPackageJson('missing_typings', {excludes: ['typings']}),
|
||||
},
|
||||
{
|
||||
name: _(
|
||||
`/project/node_modules/some_package/missing_typings/${typingsPath}.metadata.json`),
|
||||
contents: 'some meta data',
|
||||
},
|
||||
{
|
||||
name: _(`/project/node_modules/some_package/missing_typings/${typingsPath}.d.ts`),
|
||||
contents: '// some typings file',
|
||||
},
|
||||
]);
|
||||
const config = new NgccConfiguration(fs, _('/project'));
|
||||
const entryPoint = getEntryPointInfo(
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
_('/project/node_modules/some_package/missing_typings'));
|
||||
expect(entryPoint).toEqual({
|
||||
name: 'some_package/missing_typings',
|
||||
package: SOME_PACKAGE,
|
||||
path: _('/project/node_modules/some_package/missing_typings'),
|
||||
typings: _(`/project/node_modules/some_package/missing_typings/${typingsPath}.d.ts`),
|
||||
packageJson: loadPackageJson(fs, '/project/node_modules/some_package/missing_typings'),
|
||||
compiledByAngular: true,
|
||||
ignoreMissingDependencies: false,
|
||||
generateDeepReexports: false,
|
||||
});
|
||||
});
|
||||
it(`should return an object if it can guess the typings path from the "${prop}" field`,
|
||||
() => {
|
||||
loadTestFiles([
|
||||
{
|
||||
name: _('/project/node_modules/some_package/missing_typings/package.json'),
|
||||
contents: createPackageJson('missing_typings', {excludes: ['typings']}),
|
||||
},
|
||||
{
|
||||
name: _(`/project/node_modules/some_package/missing_typings/${
|
||||
typingsPath}.metadata.json`),
|
||||
contents: 'some meta data',
|
||||
},
|
||||
{
|
||||
name: _(`/project/node_modules/some_package/missing_typings/${typingsPath}.d.ts`),
|
||||
contents: '// some typings file',
|
||||
},
|
||||
]);
|
||||
const config = new NgccConfiguration(fs, _('/project'));
|
||||
const entryPoint = getEntryPointInfo(
|
||||
fs, config, new MockLogger(), SOME_PACKAGE,
|
||||
_('/project/node_modules/some_package/missing_typings'));
|
||||
expect(entryPoint).toEqual({
|
||||
name: 'some_package/missing_typings',
|
||||
package: SOME_PACKAGE,
|
||||
path: _('/project/node_modules/some_package/missing_typings'),
|
||||
typings: _(`/project/node_modules/some_package/missing_typings/${typingsPath}.d.ts`),
|
||||
packageJson: loadPackageJson(fs, '/project/node_modules/some_package/missing_typings'),
|
||||
compiledByAngular: true,
|
||||
ignoreMissingDependencies: false,
|
||||
generateDeepReexports: false,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('should return an object with `compiledByAngular` set to false if there is no metadata.json file next to the typing file',
|
||||
@ -401,23 +401,29 @@ runInEachFileSystem(() => {
|
||||
entryPoint = result;
|
||||
});
|
||||
|
||||
it('should return `esm2015` format for `fesm2015` property',
|
||||
() => { expect(getEntryPointFormat(fs, entryPoint, 'fesm2015')).toBe('esm2015'); });
|
||||
it('should return `esm2015` format for `fesm2015` property', () => {
|
||||
expect(getEntryPointFormat(fs, entryPoint, 'fesm2015')).toBe('esm2015');
|
||||
});
|
||||
|
||||
it('should return `esm5` format for `fesm5` property',
|
||||
() => { expect(getEntryPointFormat(fs, entryPoint, 'fesm5')).toBe('esm5'); });
|
||||
it('should return `esm5` format for `fesm5` property', () => {
|
||||
expect(getEntryPointFormat(fs, entryPoint, 'fesm5')).toBe('esm5');
|
||||
});
|
||||
|
||||
it('should return `esm2015` format for `es2015` property',
|
||||
() => { expect(getEntryPointFormat(fs, entryPoint, 'es2015')).toBe('esm2015'); });
|
||||
it('should return `esm2015` format for `es2015` property', () => {
|
||||
expect(getEntryPointFormat(fs, entryPoint, 'es2015')).toBe('esm2015');
|
||||
});
|
||||
|
||||
it('should return `esm2015` format for `esm2015` property',
|
||||
() => { expect(getEntryPointFormat(fs, entryPoint, 'esm2015')).toBe('esm2015'); });
|
||||
it('should return `esm2015` format for `esm2015` property', () => {
|
||||
expect(getEntryPointFormat(fs, entryPoint, 'esm2015')).toBe('esm2015');
|
||||
});
|
||||
|
||||
it('should return `esm5` format for `esm5` property',
|
||||
() => { expect(getEntryPointFormat(fs, entryPoint, 'esm5')).toBe('esm5'); });
|
||||
it('should return `esm5` format for `esm5` property', () => {
|
||||
expect(getEntryPointFormat(fs, entryPoint, 'esm5')).toBe('esm5');
|
||||
});
|
||||
|
||||
it('should return `esm5` format for `module` property',
|
||||
() => { expect(getEntryPointFormat(fs, entryPoint, 'module')).toBe('esm5'); });
|
||||
it('should return `esm5` format for `module` property', () => {
|
||||
expect(getEntryPointFormat(fs, entryPoint, 'module')).toBe('esm5');
|
||||
});
|
||||
|
||||
it('should return `umd` for `main` if the file contains a UMD wrapper function', () => {
|
||||
loadTestFiles([{
|
||||
|
Reference in New Issue
Block a user