feat(classes.smartarchive): Support URL streams, recursive archive unpacking and filesystem export; improve ZIP/GZIP/BZIP2 robustness; CI and package metadata updates
This commit is contained in:
@@ -18,7 +18,7 @@ export class TarTools {
|
||||
| plugins.smartfile.StreamFile;
|
||||
byteLength?: number;
|
||||
filePath?: string;
|
||||
}
|
||||
},
|
||||
): Promise<void> {
|
||||
return new Promise<void>(async (resolve, reject) => {
|
||||
let fileName: string | null = null;
|
||||
@@ -28,7 +28,8 @@ export class TarTools {
|
||||
} else if (optionsArg.content instanceof plugins.smartfile.SmartFile) {
|
||||
fileName = (optionsArg.content as plugins.smartfile.SmartFile).relative;
|
||||
} else if (optionsArg.content instanceof plugins.smartfile.StreamFile) {
|
||||
fileName = (optionsArg.content as plugins.smartfile.StreamFile).relativeFilePath;
|
||||
fileName = (optionsArg.content as plugins.smartfile.StreamFile)
|
||||
.relativeFilePath;
|
||||
} else if (optionsArg.filePath) {
|
||||
fileName = optionsArg.filePath;
|
||||
}
|
||||
@@ -47,9 +48,11 @@ export class TarTools {
|
||||
contentByteLength = await optionsArg.content.getSize(); // assuming SmartFile has getSize method
|
||||
} else if (optionsArg.content instanceof plugins.smartfile.StreamFile) {
|
||||
contentByteLength = await optionsArg.content.getSize(); // assuming StreamFile has getSize method
|
||||
} else if (optionsArg.content instanceof plugins.smartstream.stream.Readable) {
|
||||
} else if (
|
||||
optionsArg.content instanceof plugins.smartstream.stream.Readable
|
||||
) {
|
||||
console.warn(
|
||||
'@push.rocks/smartarchive: When streaming, it is recommended to provide byteLength, if known.'
|
||||
'@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);
|
||||
@@ -63,12 +66,18 @@ export class TarTools {
|
||||
if (Buffer.isBuffer(optionsArg.content)) {
|
||||
content = plugins.smartstream.stream.Readable.from(optionsArg.content);
|
||||
} else if (typeof optionsArg.content === 'string') {
|
||||
content = plugins.smartstream.stream.Readable.from(Buffer.from(optionsArg.content));
|
||||
content = plugins.smartstream.stream.Readable.from(
|
||||
Buffer.from(optionsArg.content),
|
||||
);
|
||||
} else if (optionsArg.content instanceof plugins.smartfile.SmartFile) {
|
||||
content = plugins.smartstream.stream.Readable.from(optionsArg.content.contents);
|
||||
content = plugins.smartstream.stream.Readable.from(
|
||||
optionsArg.content.contents,
|
||||
);
|
||||
} else if (optionsArg.content instanceof plugins.smartfile.StreamFile) {
|
||||
content = await optionsArg.content.createReadStream();
|
||||
} else if (optionsArg.content instanceof plugins.smartstream.stream.Readable) {
|
||||
} else if (
|
||||
optionsArg.content instanceof plugins.smartstream.stream.Readable
|
||||
) {
|
||||
content = optionsArg.content;
|
||||
}
|
||||
|
||||
@@ -87,7 +96,7 @@ export class TarTools {
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
content.pipe(entry);
|
||||
@@ -100,7 +109,10 @@ export class TarTools {
|
||||
* @param directoryPath
|
||||
*/
|
||||
public async packDirectory(directoryPath: string) {
|
||||
const fileTree = await plugins.smartfile.fs.listFileTree(directoryPath, '**/*');
|
||||
const fileTree = await plugins.smartfile.fs.listFileTree(
|
||||
directoryPath,
|
||||
'**/*',
|
||||
);
|
||||
const pack = await this.getPackStream();
|
||||
for (const filePath of fileTree) {
|
||||
const absolutePath = plugins.path.join(directoryPath, filePath);
|
||||
|
Reference in New Issue
Block a user