Skip to content

Commit eedcc26

Browse files
committed
feat(nx-heroku): add function to show repo size
1 parent a9c4251 commit eedcc26

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/nx-heroku/src/executors/common/git.ts

+11
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,14 @@ export async function getGitRemoteBranch(options: {
6969
);
7070
return stdout?.trim();
7171
}
72+
73+
/**
74+
* @returns {Promise<string>} size (eg: 1.06 GiB)
75+
*/
76+
export async function getGitRepoSizePack(): Promise<string> {
77+
const { stdout } = await exec(
78+
`git count-objects -H -v | grep 'size-pack' | cut -d':' -f2`,
79+
{ encoding: 'utf-8' }
80+
);
81+
return stdout?.trim();
82+
}

packages/nx-heroku/src/executors/deploy/services/heroku-deploy.service.ts

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Inject, Service } from 'typedi';
44
import { Environment, EXECUTOR_CONTEXT } from '../../common/constants';
55
import {
66
getGitEmail,
7+
getGitRepoSizePack,
78
getGitUserName,
89
setGitEmail,
910
setGitUserName,
@@ -73,9 +74,16 @@ export class HerokuDeployService extends HerokuBaseService<DeployExecutorSchema>
7374
);
7475
// If the Repo clone is shallow, make it unshallow
7576
if (isShallow === 'true\n') {
77+
this.logger.warn(
78+
'The git repository is shallow, fetching all commits to get the correct size of the repository'
79+
);
7680
await exec('git fetch --prune --unshallow');
7781
}
7882

83+
// show git repo size
84+
const size = await getGitRepoSizePack();
85+
this.logger.info(`Git repo size: ${size}`);
86+
7987
await this.setupHerokuAuth();
8088
}
8189

0 commit comments

Comments
 (0)