Skip to content

Commit

Permalink
Update file upload logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitrov-d committed Nov 29, 2023
1 parent 566a8fd commit c315a14
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 3 additions & 0 deletions packages/cli/src/modules/hosting/hosting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ export async function deployWebsite(
const hosting = new Hosting(optsWithGlobals);
try {
const website = hosting.website(optsWithGlobals.uuid);

console.log(`Uploading files from folder: ${path}`);
await website.uploadFromFolder(path);
const deployment = await website.deploy(
optsWithGlobals.preview
? DeployToEnvironment.TO_STAGING
: DeployToEnvironment.DIRECTLY_TO_PRODUCTION,
);

console.log(`Deployment started!`);
const deploymentData = await website
.deployment(deployment.deploymentUuid)
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/modules/storage/storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function uploadFromFolder(
) {
const storage = new Storage(optsWithGlobals);
try {
console.log(`Uploading files from folder: ${path}`);
await storage.bucket(optsWithGlobals.bucketUuid).uploadFromFolder(path);
} catch (err) {
exceptionHandler(err);
Expand Down
14 changes: 4 additions & 10 deletions packages/sdk/src/util/file-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,9 @@ export async function uploadFiles(
files?: FileMetadata[],
): Promise<void> {
if (folderPath) {
ApillonLogger.log(
`Preparing to upload files from ${folderPath}...`,
LogLevel.VERBOSE,
);
ApillonLogger.log(`Preparing to upload files from ${folderPath}...`);
} else if (files?.length) {
ApillonLogger.log(
`Preparing to upload ${files.length} files...`,
LogLevel.VERBOSE,
);
ApillonLogger.log(`Preparing to upload ${files.length} files...`);
} else {
throw new Error('Invalid upload parameters received');
}
Expand All @@ -95,12 +89,12 @@ export async function uploadFiles(
try {
files = listFilesRecursive(folderPath);
} catch (err) {
console.error(err);
ApillonLogger.log(err.message, LogLevel.ERROR);
throw new Error(`Error reading files in ${folderPath}`);
}
}

console.log(`Total files to upload: ${files.length}`);
ApillonLogger.log(`Total files to upload: ${files.length}`);

// Split files into chunks for parallel uploading
const fileChunkSize = 50;
Expand Down

0 comments on commit c315a14

Please sign in to comment.