Skip to content

Commit 42bcea4

Browse files
committed
fix: use build git and build ci
1 parent 04f5750 commit 42bcea4

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14+
1415
permissions:
1516
pages: write # to deploy to Pages
1617
id-token: write # to verify the deployment originates from an appropriate source

examples/vite/main.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import now from '~build/time';
22
import {
3-
CI,
43
github,
54
branch,
65
sha,
@@ -13,9 +12,10 @@ import {
1312
author,
1413
authorDate,
1514
commitMessage
16-
} from '~build/info';
15+
} from '~build/git';
1716
import { message } from '~build/meta';
1817
import { name, version } from '~build/package';
18+
import { isCI, name as ciName } from '~build/ci';
1919

2020
import { format } from 'date-fns';
2121

@@ -39,7 +39,7 @@ h1.innerHTML = `<a href="${github}" target="_blank">unplugin-info<a>`;
3939
buildTime.appendChild(h1);
4040

4141
append('Build time: ', format(now, 'yyyy-MM-dd hh:mm'));
42-
append('CI: ', CI ? CI : 'Not a CI env');
42+
append('CI: ', isCI ? ciName : 'Not a CI env');
4343
append('Github: ', github ? github : 'Not a github');
4444
append('Branch: ', branch);
4545
append('SHA: ', sha);
@@ -60,3 +60,19 @@ append('Package version: ', version);
6060
append('', '');
6161

6262
append('You can also open console and play around with it.', '');
63+
64+
const printBuildInfo = () => {
65+
if (process.env.NODE_ENV === 'development') {
66+
return;
67+
}
68+
console.group('Build info');
69+
console.log('Project:', name);
70+
console.log('Build date:', now ? now.toLocaleString() : 'Unknown');
71+
console.log('Environment:', `${process.env.NODE_ENV}${isCI ? '(ci)' : ''}`);
72+
console.log('Version:', version);
73+
console.log(`${name} is an open source project, you can view its source code on Github!`);
74+
console.log(github);
75+
console.groupEnd();
76+
};
77+
78+
printBuildInfo();

examples/webpack/src/print-build-info.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { name, version } from '~build/package';
21
import time from '~build/time';
32
import { isCI } from '~build/ci';
43
import { github } from '~build/git';
4+
import { name, version } from '~build/package';
55

66
const printBuildInfo = () => {
77
if (process.env.NODE_ENV === 'development') {

0 commit comments

Comments
 (0)