Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 15x 15x 15x 15x 15x 10x 11x 11x 11x 11x 11x 11x 4x 4x 4x 4x 4x 4x 10x 14x 14x 14x 10x 10x 10x 10x 10x 7x 11x 11x 11x 1x 1x 5x 5x 5x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import * as mimeTypes from "mime-types";
import { ReadStream, statSync } from "node:fs";
export type UploadApplicationV1Response = {
prefix: string;
uploaded: number;
};
export type UploadApplicationV2Response = UploadApplicationV1Response & {
componentBaseUrl: string;
};
export type File = {
filename: string;
size: number;
url: string;
};
export type UploadApplicationResponse = {
applicationId: string;
files: File[];
};
export class FileDescriptor {
constructor(
public readonly filename: string,
public readonly content: Buffer | ReadStream,
public readonly contentType: string | undefined = undefined,
public readonly relativePath: string | undefined = undefined,
) {
this.filename = filename.replace(/^\/+/, "");
this.contentType = contentType ?? getContentType(filename);
this.relativePath = relativePath;
}
public getFileSize(): number {
if (this.content instanceof Buffer) {
return this.content.length;
}
return statSync(this.filename).size;
}
public getNormalizedFilename(): string {
// win32 => posix filepath. Bucketeer does not accept windows style filepaths
return this.getNormalizedPath(this.filename);
}
public getNormalizedRelativePath(): string | undefined {
// win32 => posix filepath. Bucketeer does not accept windows style filepaths
return this.relativePath
? this.getNormalizedPath(this.relativePath)
: undefined;
}
private getNormalizedPath(path: string): string {
return path.replace(/\\/g, "/").replace(/^\/+/, "");
}
public isBuildFile(): boolean {
return this.filename.startsWith("dist");
}
public static totalFileSizeMB(files: FileDescriptor[]): number {
return files.reduce(
(acc, file) => acc + file.getFileSize() / (1024 * 1024),
0,
);
}
}
function getContentType(filename: string): string {
let mimeType = mimeTypes.lookup(filename);
if (!mimeType) {
mimeType = "application/octet-stream";
}
return mimeType;
}
export interface MultiPageApplicationAndComponents {
application: Record<string, any>;
pages: Record<string, any>[];
apis: Record<string, any>[];
components: Record<string, any>[];
}
|