fix(plugins): Migrate filesystem usage to Node fs/fsPromises and upgrade smartfile to v13; add listFileTree helper and update tests

This commit is contained in:
2025-11-25 11:59:11 +00:00
parent 7ccd210c45
commit 634c204a00
13 changed files with 7423 additions and 248 deletions

View File

@@ -55,7 +55,7 @@ export class TarTools {
'@push.rocks/smartarchive: When streaming, it is recommended to provide byteLength, if known.',
);
} else if (optionsArg.filePath) {
const fileStat = await plugins.smartfile.fs.stat(optionsArg.filePath);
const fileStat = await plugins.fsPromises.stat(optionsArg.filePath);
contentByteLength = fileStat.size;
}
@@ -109,19 +109,16 @@ export class TarTools {
* @param directoryPath
*/
public async packDirectory(directoryPath: string) {
const fileTree = await plugins.smartfile.fs.listFileTree(
directoryPath,
'**/*',
);
const fileTree = await plugins.listFileTree(directoryPath, '**/*');
const pack = await this.getPackStream();
for (const filePath of fileTree) {
const absolutePath = plugins.path.join(directoryPath, filePath);
const fileStat = await plugins.smartfile.fs.stat(absolutePath);
const fileStat = await plugins.fsPromises.stat(absolutePath);
await this.addFileToPack(pack, {
byteLength: fileStat.size,
filePath: absolutePath,
fileName: filePath,
content: plugins.smartfile.fsStream.createReadStream(absolutePath),
content: plugins.fs.createReadStream(absolutePath),
});
}
return pack;