fix(npmextra): update to new format

This commit is contained in:
2025-12-13 11:42:39 +00:00
parent f8d0895aab
commit 3b1c84d7e8
18 changed files with 1951 additions and 1801 deletions

View File

@@ -31,16 +31,32 @@ export class LazyFileLoader {
for (const globPattern of globs) {
try {
const smartFiles = await plugins.smartfile.fs.fileTreeToObject(this.projectRoot, globPattern);
const fileArray = Array.isArray(smartFiles) ? smartFiles : [smartFiles];
const virtualDir = await plugins.smartfileFactory.virtualDirectoryFromPath(this.projectRoot);
// Filter files based on glob pattern using simple pattern matching
const smartFiles = virtualDir.filter(file => {
// Simple glob matching
const relativePath = file.relative;
if (globPattern.includes('**')) {
// Handle ** patterns - match any path
const pattern = globPattern.replace(/\*\*/g, '.*').replace(/\*/g, '[^/]*');
return new RegExp(`^${pattern}$`).test(relativePath);
} else if (globPattern.includes('*')) {
// Handle single * patterns
const pattern = globPattern.replace(/\*/g, '[^/]*');
return new RegExp(`^${pattern}$`).test(relativePath);
} else {
// Exact match
return relativePath === globPattern;
}
}).listFiles();
for (const smartFile of fileArray) {
for (const smartFile of smartFiles) {
try {
const meta = await this.getMetadata(smartFile.path);
const meta = await this.getMetadata(smartFile.absolutePath);
metadata.push(meta);
} catch (error) {
// Skip files that can't be read
console.warn(`Failed to get metadata for ${smartFile.path}:`, error.message);
console.warn(`Failed to get metadata for ${smartFile.absolutePath}:`, error.message);
}
}
} catch (error) {
@@ -104,7 +120,7 @@ export class LazyFileLoader {
// Load files in parallel
const loadPromises = metadata.map(async (meta) => {
try {
const contents = await plugins.smartfile.fs.toStringSync(meta.path);
const contents = await plugins.fsInstance.file(meta.path).encoding('utf8').read() as string;
const tokenCount = tokenizer(contents);
const fileInfo: IFileInfo = {
@@ -138,7 +154,7 @@ export class LazyFileLoader {
tokenizer: (content: string) => number
): Promise<IFileInfo> {
const meta = await this.getMetadata(filePath);
const contents = await plugins.smartfile.fs.toStringSync(filePath);
const contents = await plugins.fsInstance.file(filePath).encoding('utf8').read() as string;
const tokenCount = tokenizer(contents);
const relativePath = plugins.path.relative(this.projectRoot, filePath);