@ts-morph/common
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -26,8 +26,8 @@ import * as ts from "typescript"; | ||
private readonly tsConfigDirPath; | ||
constructor(fileSystem: TransactionalFileSystem, tsConfigFilePath: string, encoding: string); | ||
constructor(fileSystem: TransactionalFileSystem, tsConfigFilePath: StandardizedFilePath, encoding: string); | ||
getCompilerOptions(): ts.CompilerOptions; | ||
getErrors(): ts.Diagnostic[]; | ||
getPaths(compilerOptions?: CompilerOptions): { | ||
filePaths: string[]; | ||
directoryPaths: string[]; | ||
filePaths: StandardizedFilePath[]; | ||
directoryPaths: StandardizedFilePath[]; | ||
}; | ||
@@ -145,7 +145,2 @@ private parseJsonConfigFileContent; | ||
/** | ||
* Removes the source file from the document registry | ||
* @param fileName - File name to remove. | ||
*/ | ||
removeSourceFile(fileName: string): void; | ||
/** | ||
* Creates or updates a source file in the document registry. | ||
@@ -157,3 +152,8 @@ * @param fileName - File name to create or update. | ||
*/ | ||
createOrUpdateSourceFile(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: ts.IScriptSnapshot, scriptKind: ScriptKind | undefined): ts.SourceFile; | ||
createOrUpdateSourceFile(fileName: StandardizedFilePath, compilationSettings: CompilerOptions, scriptSnapshot: ts.IScriptSnapshot, scriptKind: ScriptKind | undefined): ts.SourceFile; | ||
/** | ||
* Removes the source file from the document registry. | ||
* @param fileName - File name to remove. | ||
*/ | ||
removeSourceFile(fileName: StandardizedFilePath): void; | ||
/** @inheritdoc */ | ||
@@ -179,3 +179,2 @@ acquireDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: ts.IScriptSnapshot, version: string, scriptKind: ScriptKind | undefined): ts.SourceFile; | ||
private updateSourceFile; | ||
private createCompilerSourceFile; | ||
} | ||
@@ -204,7 +203,7 @@ | ||
*/ | ||
containsSourceFileAtPath(filePath: string): boolean; | ||
containsSourceFileAtPath(filePath: StandardizedFilePath): boolean; | ||
/** | ||
* Gets the source file paths of all the source files in the container. | ||
*/ | ||
getSourceFilePaths(): string[]; | ||
getSourceFilePaths(): Iterable<StandardizedFilePath>; | ||
/** | ||
@@ -214,3 +213,3 @@ * Gets a source file from a file path, but only if it exists in the container's cache. | ||
*/ | ||
getSourceFileFromCacheFromFilePath(filePath: string): ts.SourceFile | undefined; | ||
getSourceFileFromCacheFromFilePath(filePath: StandardizedFilePath): ts.SourceFile | undefined; | ||
/** | ||
@@ -221,3 +220,3 @@ * Adds or gets a source file from a file path. | ||
*/ | ||
addOrGetSourceFileFromFilePath(filePath: string, opts: { | ||
addOrGetSourceFileFromFilePath(filePath: StandardizedFilePath, opts: { | ||
markInProject: boolean; | ||
@@ -235,3 +234,3 @@ scriptKind: ScriptKind | undefined; | ||
*/ | ||
containsDirectoryAtPath(dirPath: string): boolean; | ||
containsDirectoryAtPath(dirPath: StandardizedFilePath): boolean; | ||
/** | ||
@@ -241,3 +240,3 @@ * Gets the child directories of the specified directory. | ||
*/ | ||
getChildDirectoriesOfDirectory(dirPath: string): string[]; | ||
getChildDirectoriesOfDirectory(dirPath: StandardizedFilePath): StandardizedFilePath[]; | ||
} | ||
@@ -338,3 +337,3 @@ | ||
class ArgumentError extends BaseError { | ||
constructor(argName: string, message: string, prototype?: any); | ||
constructor(argName: string, message: string); | ||
} | ||
@@ -355,4 +354,4 @@ /** Thrown when an argument is null or whitespace. */ | ||
class PathNotFoundError extends BaseError { | ||
readonly path: string; | ||
constructor(path: string, prefix?: string, prototype?: any); | ||
readonly path: StandardizedFilePath; | ||
constructor(path: StandardizedFilePath, prefix?: string); | ||
readonly code: "ENOENT"; | ||
@@ -362,7 +361,7 @@ } | ||
class DirectoryNotFoundError extends PathNotFoundError { | ||
constructor(dirPath: string); | ||
constructor(dirPath: StandardizedFilePath); | ||
} | ||
/** Thrown when a file was not found. */ | ||
class FileNotFoundError extends PathNotFoundError { | ||
constructor(filePath: string); | ||
constructor(filePath: StandardizedFilePath); | ||
} | ||
@@ -456,3 +455,3 @@ /** Thrown when an action was taken that is not allowed. */ | ||
private fs; | ||
private globby; | ||
private fastGlob; | ||
/** @inheritdoc */ | ||
@@ -497,4 +496,6 @@ delete(path: string): Promise<void>; | ||
/** @inheritdoc */ | ||
glob(patterns: ReadonlyArray<string>): string[]; | ||
glob(patterns: ReadonlyArray<string>): Promise<string[]>; | ||
/** @inheritdoc */ | ||
globSync(patterns: ReadonlyArray<string>): string[]; | ||
/** @inheritdoc */ | ||
isCaseSensitive(): boolean; | ||
@@ -553,3 +554,5 @@ private getDirectoryNotFoundErrorIfNecessary; | ||
/** Uses pattern matching to find files or directories. */ | ||
glob(patterns: ReadonlyArray<string>): string[]; | ||
glob(patterns: ReadonlyArray<string>): Promise<string[]>; | ||
/** Synchronously uses pattern matching to find files or directories. */ | ||
globSync(patterns: ReadonlyArray<string>): string[]; | ||
} | ||
@@ -569,12 +572,12 @@ | ||
constructor(fileSystem: FileSystemHost); | ||
queueFileDelete(filePath: string): void; | ||
removeFileDelete(filePath: string): void; | ||
queueMkdir(dirPath: string): void; | ||
queueDirectoryDelete(dirPath: string): void; | ||
queueMoveDirectory(srcPath: string, destPath: string): void; | ||
queueCopyDirectory(srcPath: string, destPath: string): void; | ||
queueFileDelete(filePath: StandardizedFilePath): void; | ||
removeFileDelete(filePath: StandardizedFilePath): void; | ||
queueMkdir(dirPath: StandardizedFilePath): void; | ||
queueDirectoryDelete(dirPath: StandardizedFilePath): void; | ||
queueMoveDirectory(srcPath: StandardizedFilePath, destPath: StandardizedFilePath): void; | ||
queueCopyDirectory(srcPath: StandardizedFilePath, destPath: StandardizedFilePath): void; | ||
flush(): Promise<void>; | ||
flushSync(): void; | ||
saveForDirectory(dirPath: string): Promise<void>; | ||
saveForDirectorySync(dirPath: string): void; | ||
saveForDirectory(dirPath: StandardizedFilePath): Promise<void>; | ||
saveForDirectorySync(dirPath: StandardizedFilePath): void; | ||
private getAndClearOperationsForDir; | ||
@@ -584,28 +587,33 @@ private executeOperation; | ||
private getAndClearOperations; | ||
moveFileImmediately(oldFilePath: string, newFilePath: string, fileText: string): Promise<void>; | ||
moveFileImmediatelySync(oldFilePath: string, newFilePath: string, fileText: string): void; | ||
deleteFileImmediately(filePath: string): Promise<void>; | ||
deleteFileImmediatelySync(filePath: string): void; | ||
copyDirectoryImmediately(srcDirPath: string, destDirPath: string): Promise<void>; | ||
copyDirectoryImmediatelySync(srcDirPath: string, destDirPath: string): void; | ||
moveDirectoryImmediately(srcDirPath: string, destDirPath: string): Promise<void>; | ||
moveDirectoryImmediatelySync(srcDirPath: string, destDirPath: string): void; | ||
deleteDirectoryImmediately(dirPath: string): Promise<void>; | ||
deleteDirectoryImmediatelySync(dirPath: string): void; | ||
moveFileImmediately(oldFilePath: StandardizedFilePath, newFilePath: StandardizedFilePath, fileText: string): Promise<void>; | ||
moveFileImmediatelySync(oldFilePath: StandardizedFilePath, newFilePath: StandardizedFilePath, fileText: string): void; | ||
deleteFileImmediately(filePath: StandardizedFilePath): Promise<void>; | ||
deleteFileImmediatelySync(filePath: StandardizedFilePath): void; | ||
copyDirectoryImmediately(srcDirPath: StandardizedFilePath, destDirPath: StandardizedFilePath): Promise<void>; | ||
copyDirectoryImmediatelySync(srcDirPath: StandardizedFilePath, destDirPath: StandardizedFilePath): void; | ||
moveDirectoryImmediately(srcDirPath: StandardizedFilePath, destDirPath: StandardizedFilePath): Promise<void>; | ||
moveDirectoryImmediatelySync(srcDirPath: StandardizedFilePath, destDirPath: StandardizedFilePath): void; | ||
deleteDirectoryImmediately(dirPath: StandardizedFilePath): Promise<void>; | ||
/** Recreates a directory on the underlying file system asynchronously. */ | ||
clearDirectoryImmediately(dirPath: StandardizedFilePath): Promise<void>; | ||
/** Recreates a directory on the underlying file system synchronously. */ | ||
clearDirectoryImmediatelySync(dirPath: StandardizedFilePath): void; | ||
deleteDirectoryImmediatelySync(dirPath: StandardizedFilePath): void; | ||
private deleteSuppressNotFound; | ||
private deleteSuppressNotFoundSync; | ||
fileExistsSync(filePath: string): boolean; | ||
directoryExistsSync(dirPath: string): boolean; | ||
readFileSync(filePath: string, encoding: string | undefined): string; | ||
readDirSync(dirPath: string): string[]; | ||
glob(patterns: ReadonlyArray<string>): string[]; | ||
fileExistsSync(filePath: StandardizedFilePath): boolean; | ||
directoryExistsSync(dirPath: StandardizedFilePath): boolean; | ||
readFileSync(filePath: StandardizedFilePath, encoding: string | undefined): string; | ||
readDirSync(dirPath: StandardizedFilePath): StandardizedFilePath[]; | ||
glob(patterns: ReadonlyArray<string>): AsyncGenerator<StandardizedFilePath, void, unknown>; | ||
globSync(patterns: ReadonlyArray<string>): Generator<StandardizedFilePath, void, unknown>; | ||
getFileSystem(): FileSystemHost; | ||
getCurrentDirectory(): string; | ||
getDirectories(dirPath: string): string[]; | ||
realpathSync(path: string): string; | ||
getStandardizedAbsolutePath(fileOrDirPath: string, relativeBase?: string): string; | ||
readFileOrNotExists(filePath: string, encoding: string): false | Promise<string | false>; | ||
readFileOrNotExistsSync(filePath: string, encoding: string): string | false; | ||
writeFile(filePath: string, fileText: string): Promise<void>; | ||
writeFileSync(filePath: string, fileText: string): void; | ||
getCurrentDirectory(): StandardizedFilePath; | ||
getDirectories(dirPath: StandardizedFilePath): StandardizedFilePath[]; | ||
realpathSync(path: StandardizedFilePath): StandardizedFilePath; | ||
getStandardizedAbsolutePath(fileOrDirPath: string, relativeBase?: string): StandardizedFilePath; | ||
readFileOrNotExists(filePath: StandardizedFilePath, encoding: string): false | Promise<string | false>; | ||
readFileOrNotExistsSync(filePath: StandardizedFilePath, encoding: string): string | false; | ||
writeFile(filePath: StandardizedFilePath, fileText: string): Promise<void>; | ||
writeFileSync(filePath: StandardizedFilePath, fileText: string): void; | ||
private isPathDirectoryInQueueThatExists; | ||
@@ -640,3 +648,3 @@ private isPathQueuedForDeletion; | ||
*/ | ||
static pathJoin(...paths: string[]): string; | ||
static pathJoin<T extends string>(basePath: T, ...paths: string[]): T; | ||
/** | ||
@@ -653,3 +661,3 @@ * Gets if the path is absolute. | ||
*/ | ||
static getStandardizedAbsolutePath(fileSystem: FileSystemHost, fileOrDirPath: string, relativeBase?: string): string; | ||
static getStandardizedAbsolutePath(fileSystem: FileSystemHost, fileOrDirPath: string, relativeBase?: string): StandardizedFilePath; | ||
/** | ||
@@ -659,8 +667,8 @@ * Gets the directory path. | ||
*/ | ||
static getDirPath(fileOrDirPath: string): string; | ||
static getDirPath<T extends string>(fileOrDirPath: T): T; | ||
/** | ||
* Gets the base name. | ||
* Gets the last portion of the path. | ||
* @param fileOrDirPath - Path to get the base name from. | ||
*/ | ||
static getBaseName(fileOrDirPath: string): string; | ||
static getBaseName(fileOrDirPath: StandardizedFilePath): string; | ||
/** | ||
@@ -670,3 +678,3 @@ * Gets the extension of the file name. | ||
*/ | ||
static getExtension(fileOrDirPath: string): string; | ||
static getExtension(fileOrDirPath: StandardizedFilePath): string; | ||
/** | ||
@@ -676,3 +684,3 @@ * Changes all back slashes to forward slashes. | ||
*/ | ||
static standardizeSlashes(fileOrDirPath: string): string; | ||
static standardizeSlashes<T extends string>(fileOrDirPath: T): T; | ||
/** | ||
@@ -695,3 +703,3 @@ * Checks if a path ends with a specified search path. | ||
*/ | ||
static getParentMostPaths(paths: string[]): string[]; | ||
static getParentMostPaths(paths: StandardizedFilePath[]): StandardizedFilePath[]; | ||
/** | ||
@@ -703,3 +711,3 @@ * Reads a file or returns false if the file doesn't exist. | ||
*/ | ||
static readFileOrNotExists(fileSystem: FileSystemHost, filePath: string, encoding: string): Promise<string | false>; | ||
static readFileOrNotExists(fileSystem: FileSystemHost, filePath: StandardizedFilePath, encoding: string): Promise<string | false>; | ||
/** | ||
@@ -711,3 +719,3 @@ * Reads a file synchronously or returns false if the file doesn't exist. | ||
*/ | ||
static readFileOrNotExistsSync(fileSystem: FileSystemHost, filePath: string, encoding: string): string | false; | ||
static readFileOrNotExistsSync(fileSystem: FileSystemHost, filePath: StandardizedFilePath, encoding: string): string | false; | ||
/** | ||
@@ -723,3 +731,3 @@ * Gets the text with a byte order mark. | ||
*/ | ||
static getRelativePathTo(absoluteDirPathFrom: string, absolutePathTo: string): string; | ||
static getRelativePathTo(absoluteDirPathFrom: StandardizedFilePath, absolutePathTo: StandardizedFilePath): StandardizedFilePath; | ||
/** | ||
@@ -729,3 +737,3 @@ * Gets if the path is for the root directory. | ||
*/ | ||
static isRootDirPath(dirOrFilePath: string): boolean; | ||
static isRootDirPath(dirOrFilePath: StandardizedFilePath): boolean; | ||
/** | ||
@@ -735,3 +743,3 @@ * Gets the descendant directories of the specified directory. | ||
*/ | ||
static getDescendantDirectories(fileSystemWrapper: TransactionalFileSystem, dirPath: string): string[]; | ||
static getDescendantDirectories(fileSystemWrapper: TransactionalFileSystem, dirPath: StandardizedFilePath): IterableIterator<StandardizedFilePath>; | ||
/** | ||
@@ -748,7 +756,2 @@ * Gets the glob as absolute. | ||
static isNegatedGlob(glob: string): boolean; | ||
/** | ||
* Gets the glob's directory. | ||
* @param glob - Glob. | ||
*/ | ||
static getGlobDir(glob: string): string; | ||
} | ||
@@ -759,6 +762,17 @@ | ||
export interface InMemoryFileSystemHostOptions { | ||
/** | ||
* Set this to true to not load the /node_modules/typescript/lib files on construction. | ||
* @default false | ||
*/ | ||
skipLoadingLibFiles?: boolean; | ||
} | ||
/** An implementation of a file system that exists in memory only. */ | ||
export declare class InMemoryFileSystemHost implements FileSystemHost { | ||
private readonly directories; | ||
constructor(); | ||
/** | ||
* Constructor. | ||
* @param options - Options for creating the file system. | ||
*/ | ||
constructor(options?: InMemoryFileSystemHostOptions); | ||
/** @inheritdoc */ | ||
@@ -792,3 +806,2 @@ isCaseSensitive(): boolean; | ||
copySync(srcPath: string, destPath: string): void; | ||
private _copyDirInternal; | ||
/** @inheritdoc */ | ||
@@ -807,6 +820,12 @@ fileExists(filePath: string): Promise<boolean>; | ||
/** @inheritdoc */ | ||
glob(patterns: ReadonlyArray<string>): string[]; | ||
private getOrCreateDir; | ||
glob(patterns: ReadonlyArray<string>): Promise<string[]>; | ||
/** @inheritdoc */ | ||
globSync(patterns: ReadonlyArray<string>): string[]; | ||
} | ||
/** Nominal type to denote a file path that has been standardized. */ | ||
export declare type StandardizedFilePath = string & { | ||
_standardizedFilePathBrand: undefined; | ||
}; | ||
/** | ||
@@ -902,2 +921,8 @@ * Gets the enum name for the specified syntax kind. | ||
/** | ||
* Deep clones an object not maintaining references. | ||
* @remarks If this has a circular reference it will go forever so be careful. | ||
*/ | ||
export declare function deepClone<T extends object>(objToClone: T): T; | ||
/** | ||
* Event container subscription type | ||
@@ -943,3 +968,3 @@ */ | ||
private constructor(); | ||
static isWhitespaceChar(char: string | undefined): boolean; | ||
static isWhitespaceCharCode(charCode: number | undefined): boolean; | ||
static isSpaces(text: string): boolean; | ||
@@ -974,3 +999,9 @@ static hasBom(text: string): boolean; | ||
/** Loads the lib files that are stored in a separate module. */ | ||
export declare function getLibFiles(): { | ||
fileName: string; | ||
text: string; | ||
}[]; | ||
import { SyntaxKind, ScriptTarget, ScriptKind, LanguageVariant, EmitHint, ModuleKind, ModuleResolutionKind, NewLineKind, TypeFlags, ObjectFlags, SymbolFlags, TypeFormatFlags, DiagnosticCategory, CompilerOptions, EditorSettings } from "typescript"; | ||
export { ts, SyntaxKind, ScriptTarget, ScriptKind, LanguageVariant, EmitHint, ModuleKind, ModuleResolutionKind, NewLineKind, TypeFlags, ObjectFlags, SymbolFlags, TypeFormatFlags, DiagnosticCategory, CompilerOptions, EditorSettings }; |
{ | ||
"name": "@ts-morph/common", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Common functionality for ts-morph packages.", | ||
@@ -11,4 +11,5 @@ "main": "dist/ts-morph-common.js", | ||
"scripts": { | ||
"build": "rimraf dist && yarn rollup && yarn build:declarations", | ||
"build": "rimraf dist && yarn createLibFile && yarn rollup && yarn build:declarations", | ||
"build:declarations": "ts-node --compiler ttypescript --project scripts/tsconfig.json --transpile-only scripts/buildDeclarations.ts", | ||
"createLibFile": "ts-node scripts/createLibFile.ts", | ||
"test": "cross-env TS_NODE_COMPILER=\"ttypescript\" TS_NODE_TRANSPILE_ONLY=\"true\" mocha --opts mocha.opts", | ||
@@ -21,5 +22,4 @@ "test:ci": "yarn test", | ||
"@dsherret/to-absolute-glob": "^2.0.2", | ||
"fast-glob": "^3.1.0", | ||
"fs-extra": "^8.1.0", | ||
"glob-parent": "^5.1.0", | ||
"globby": "^10.0.1", | ||
"is-negated-glob": "^1.0.0", | ||
@@ -30,6 +30,5 @@ "multimatch": "^4.0.0", | ||
"devDependencies": { | ||
"@ts-morph/scripts": "~0.2.0", | ||
"@types/chai": "^4.2.4", | ||
"@types/fs-extra": "^8.0.1", | ||
"@types/glob-parent": "^5.1.0", | ||
"@types/globby": "^9.1.0", | ||
"@types/is-negated-glob": "^1.0.0", | ||
@@ -40,5 +39,5 @@ "@types/mocha": "^5.2.7", | ||
"@types/ts-nameof": "^4.0.0", | ||
"@ts-morph/scripts": "~0.1.0", | ||
"chai": "^4.2.0", | ||
"cross-env": "^6.0.3", | ||
"dts-minify": "^0.2.0", | ||
"mocha": "^6.2.2", | ||
@@ -65,3 +64,2 @@ "rimraf": "^3.0.0", | ||
"source-map-support": false, | ||
"globby": false, | ||
"glob-parent": false, | ||
@@ -68,0 +66,0 @@ "glob": false |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
973705
6
19
6
6710
+ Addedfast-glob@^3.1.0
- Removedglob-parent@^5.1.0
- Removedglobby@^10.0.1
- Removed@types/glob@7.2.0(transitive)
- Removed@types/minimatch@5.1.2(transitive)
- Removed@types/node@22.7.4(transitive)
- Removeddir-glob@3.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedglobby@10.0.2(transitive)
- Removedignore@5.3.2(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedslash@3.0.0(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedwrappy@1.0.2(transitive)