Skip to content

Commit

Permalink
fix: get rid of git-repo-info
Browse files Browse the repository at this point in the history
  • Loading branch information
ouuan committed Feb 8, 2023
1 parent f0f77bd commit cbc710d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

declare module '~build/meta' {
export const totalSize: number;
export const sha: string;
export const committerDate: string;
}
3 changes: 1 addition & 2 deletions src/components/BaseFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
<script setup lang="ts">
import { filesize } from 'filesize';
import { format } from 'date-fns';
import { sha, committerDate } from '~build/info';
import { totalSize } from '~build/meta';
import { sha, committerDate, totalSize } from '~build/meta';
import useCopyrightYear from '~/composables/useCopyrightYear';
const { site } = usePage();
Expand Down
11 changes: 11 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import buildInfo from 'vite-plugin-info';

import { stat } from 'fs/promises';
import glob from 'glob-promise';
import { simpleGit } from 'simple-git';
import { builtinModules } from 'module';

export default defineConfig({
Expand All @@ -18,11 +19,21 @@ export default defineConfig({
}),
analyze({ limit: 10 }),
(async () => {
const gitLog = await simpleGit().log({
maxCount: 1,
format: {
sha: '%H',
committerDate: '%cI',
},
});
const { sha, committerDate } = gitLog.latest || { sha: '', committerDate: '' };
const files = await glob('posts/**/*.md{,x}');
const sizes = await Promise.all(files.map(async (file) => (await stat(file)).size));
const totalSize = sizes.reduce((a, b) => a + b, 0);
return buildInfo({
meta: {
sha,
committerDate,
totalSize,
},
});
Expand Down

0 comments on commit cbc710d

Please sign in to comment.