refactor(ivy): ngcc - remove the last remnants of path
and canonical-path
(#29643)
The ngcc code now uses `AbsoluteFsPath` and `PathSegment` to do all its path manipulation. PR Close #29643
This commit is contained in:
parent
20898f9f4f
commit
029a93963a
@ -6,9 +6,9 @@
|
|||||||
* Use of this source code is governed by an MIT-style license that can be
|
* Use of this source code is governed by an MIT-style license that can be
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
import * as path from 'canonical-path';
|
|
||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
|
|
||||||
|
import {AbsoluteFsPath} from '../src/ngtsc/path';
|
||||||
import {mainNgcc} from './src/main';
|
import {mainNgcc} from './src/main';
|
||||||
import {ConsoleLogger, LogLevel} from './src/logging/console_logger';
|
import {ConsoleLogger, LogLevel} from './src/logging/console_logger';
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ if (require.main === module) {
|
|||||||
'The formats option (-f/--formats) has been removed. Consider the properties option (-p/--properties) instead.');
|
'The formats option (-f/--formats) has been removed. Consider the properties option (-p/--properties) instead.');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const baseSourcePath = path.resolve(options['s'] || './node_modules');
|
const baseSourcePath = AbsoluteFsPath.resolve(options['s'] || './node_modules');
|
||||||
const propertiesToConsider: string[] = options['p'];
|
const propertiesToConsider: string[] = options['p'];
|
||||||
const targetEntryPointPath = options['t'] ? options['t'] : undefined;
|
const targetEntryPointPath = options['t'] ? options['t'] : undefined;
|
||||||
const compileAllFormats = !options['first-only'];
|
const compileAllFormats = !options['first-only'];
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
import {ConstantPool} from '@angular/compiler';
|
import {ConstantPool} from '@angular/compiler';
|
||||||
import * as path from 'path';
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {BaseDefDecoratorHandler, ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ReferencesRegistry, ResourceLoader} from '../../../src/ngtsc/annotations';
|
import {BaseDefDecoratorHandler, ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ReferencesRegistry, ResourceLoader} from '../../../src/ngtsc/annotations';
|
||||||
@ -57,7 +56,7 @@ class NgccResourceLoader implements ResourceLoader {
|
|||||||
preload(): undefined|Promise<void> { throw new Error('Not implemented.'); }
|
preload(): undefined|Promise<void> { throw new Error('Not implemented.'); }
|
||||||
load(url: string): string { return this.fs.readFile(AbsoluteFsPath.resolve(url)); }
|
load(url: string): string { return this.fs.readFile(AbsoluteFsPath.resolve(url)); }
|
||||||
resolve(url: string, containingFile: string): string {
|
resolve(url: string, containingFile: string): string {
|
||||||
return path.resolve(path.dirname(containingFile), url);
|
return AbsoluteFsPath.resolve(AbsoluteFsPath.dirname(AbsoluteFsPath.from(containingFile)), url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {DepGraph} from 'dependency-graph';
|
import {DepGraph} from 'dependency-graph';
|
||||||
import {resolve} from 'path';
|
|
||||||
|
|
||||||
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
|
import {AbsoluteFsPath} from '../../../src/ngtsc/path';
|
||||||
import {Logger} from '../logging/logger';
|
import {Logger} from '../logging/logger';
|
||||||
@ -171,7 +170,7 @@ function getEntryPointPath(entryPoint: EntryPoint): AbsoluteFsPath {
|
|||||||
|
|
||||||
if (format === 'esm2015' || format === 'esm5') {
|
if (format === 'esm2015' || format === 'esm5') {
|
||||||
const formatPath = entryPoint.packageJson[property] !;
|
const formatPath = entryPoint.packageJson[property] !;
|
||||||
return AbsoluteFsPath.from(resolve(entryPoint.path, formatPath));
|
return AbsoluteFsPath.resolve(entryPoint.path, formatPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Error(`There is no format with import statements in '${entryPoint.path}' entry-point.`);
|
throw new Error(`There is no format with import statements in '${entryPoint.path}' entry-point.`);
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
import {AbsoluteFsPath} from '@angular/compiler-cli/src/ngtsc/path';
|
import {AbsoluteFsPath} from '@angular/compiler-cli/src/ngtsc/path';
|
||||||
import {existsSync, readFileSync, readdirSync, statSync, writeFileSync} from 'fs';
|
import {existsSync, readFileSync, readdirSync, statSync, writeFileSync} from 'fs';
|
||||||
import * as mockFs from 'mock-fs';
|
import * as mockFs from 'mock-fs';
|
||||||
import {join} from 'path';
|
|
||||||
|
|
||||||
import {getAngularPackagesFromRunfiles, resolveNpmTreeArtifact} from '../../../test/runfile_helpers';
|
import {getAngularPackagesFromRunfiles, resolveNpmTreeArtifact} from '../../../test/runfile_helpers';
|
||||||
import {NodeJSFileSystem} from '../../src/file_system/node_js_file_system';
|
import {NodeJSFileSystem} from '../../src/file_system/node_js_file_system';
|
||||||
@ -142,8 +141,8 @@ describe('ngcc main()', () => {
|
|||||||
|
|
||||||
|
|
||||||
function markPropertiesAsProcessed(packagePath: string, properties: EntryPointJsonProperty[]) {
|
function markPropertiesAsProcessed(packagePath: string, properties: EntryPointJsonProperty[]) {
|
||||||
const basePath = '/node_modules';
|
const basePath = _('/node_modules');
|
||||||
const targetPackageJsonPath = _(join(basePath, packagePath, 'package.json'));
|
const targetPackageJsonPath = AbsoluteFsPath.join(basePath, packagePath, 'package.json');
|
||||||
const targetPackage = loadPackage(packagePath);
|
const targetPackage = loadPackage(packagePath);
|
||||||
const fs = new NodeJSFileSystem();
|
const fs = new NodeJSFileSystem();
|
||||||
markAsProcessed(fs, targetPackage, targetPackageJsonPath, 'typings');
|
markAsProcessed(fs, targetPackage, targetPackageJsonPath, 'typings');
|
||||||
@ -386,7 +385,7 @@ function loadDirectory(directoryPath: string): Directory {
|
|||||||
const directory: Directory = {};
|
const directory: Directory = {};
|
||||||
|
|
||||||
readdirSync(directoryPath).forEach(item => {
|
readdirSync(directoryPath).forEach(item => {
|
||||||
const itemPath = join(directoryPath, item);
|
const itemPath = AbsoluteFsPath.resolve(directoryPath, item);
|
||||||
if (statSync(itemPath).isDirectory()) {
|
if (statSync(itemPath).isDirectory()) {
|
||||||
directory[item] = loadDirectory(itemPath);
|
directory[item] = loadDirectory(itemPath);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user