Skip to content

Commit f093bda

Browse files
committed
feat: log size and only tar files
1 parent bfc57e1 commit f093bda

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

api/scripts/build.mjs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env zx
2-
import { cp, mkdir, writeFile } from 'fs/promises';
2+
import { cp, mkdir, writeFile, stat } from 'fs/promises';
3+
import { pathExists } from 'fs-extra';
34
import { exit } from 'process';
45

56
import { $, cd } from 'zx';
67

78
import { getDeploymentVersion } from './get-deployment-version.mjs';
89

910
try {
10-
1111
// Enable colours in output
1212
process.env.FORCE_COLOR = '1';
1313

@@ -80,8 +80,18 @@ try {
8080
console.log('Dependencies installed, packing...');
8181

8282
// Now we'll pack everything in the pre-pack directory to the release directory
83-
await $`tar -czf ./deploy/release/unraid-api-${deploymentVersion}.tgz ./deploy/pre-pack/`;
84-
console.log('Packing complete, build finished.');
83+
await cd('./deploy/pre-pack');
84+
const tarballPath = `../release/unraid-api-${deploymentVersion}.tgz`;
85+
await $`tar -czf ${tarballPath} .`;
86+
// Ensure the tarball exists
87+
if (!(await pathExists(tarballPath))) {
88+
console.error(`Failed to create tarball at ${tarballPath}`);
89+
process.exit(1);
90+
}
91+
const packageSize = Math.round((await stat(tarballPath)).size / 1024 / 1024);
92+
console.log(
93+
`Package created at: ${tarballPath} with size ${packageSize} MB`
94+
);
8595
} catch (error) {
8696
// Error with a command
8797
if (Object.keys(error).includes('stderr')) {

0 commit comments

Comments
 (0)