sicua
Version:
A tool for analyzing project structure and dependencies
66 lines (65 loc) • 2.13 kB
TypeScript
export declare class PathUtils {
/**
* Normalizes a file path to a consistent format
*/
static normalizePath(filePath: string): string;
/**
* Gets relative path between two absolute paths
*/
static getRelativePath(from: string, to: string): string;
/**
* Checks if a path is absolute
*/
static isAbsolutePath(filePath: string): boolean;
/**
* Gets directory name from path
*/
static getDirectory(filePath: string): string;
/**
* Gets file name from path
*/
static getFileName(filePath: string): string;
/**
* Gets file extension from path
*/
static getFileExtension(filePath: string): string;
/**
* Joins path segments
*/
static joinPaths(...paths: string[]): string;
/**
* Resolves a path to its absolute form
*/
static resolvePath(...paths: string[]): string;
/**
* Generate SHA-256 hash of a string
*/
static generateHash(input: string): string;
/**
* Checks if a path is within another path
*/
static isWithinDirectory(directory: string, filePath: string): boolean;
/**
* Checks if path is a TypeScript/JavaScript file
*/
static isSourceFile(filePath: string): boolean;
}
export declare function calculateFileHash(filePath: string): Promise<string>;
export declare function ensureDirectoryExists(dirPath: string): Promise<void>;
export declare function readJsonFile(filePath: string): Promise<any>;
export declare function writeJsonFile(filePath: string, data: any): Promise<void>;
/**
* Extracts the package name from an import path
* @example
* extractPackageName("@angular/core") // returns "@angular/core"
* extractPackageName("lodash") // returns "lodash"
* extractPackageName("./local/file") // returns null
*/
export declare function extractPackageName(importPath: string): string | null;
/**
* Checks if a path is using an alias pattern
* @example
* isPathAlias("@/components/Button") // returns true
* isPathAlias("lodash") // returns false
*/
export declare function isPathAlias(path: string): boolean;