create_build_info_ts
This script will create a TypeScript file at the given path containing build and source control information.
The given path can either be relative to the base directory (-d
) or an absolute path—intermediate directories will not be created.
The following parameters are optional:
d
-
the base directory (
$PWD
if not given) f
-
overwrite the existing file
The value of
|
The value of The following will give you the timestamp of the HEAD commit:
|
This script will add source control information if the base directory (
The value of |
Usage
$ scripts/web/create_build_info_ts.sh build-info.ts
$ scripts/web/create_build_info_ts.sh -f /tmp/build-info.ts
$ scripts/web/create_build_info_ts.sh -d ~/git_repo src/build-info.ts
$ scripts/web/create_build_info_ts.sh src/build-info.ts
⇓
export type BuildInfo = {
// ...
};
export const buildInfo: BuildInfo = {
build: {
id: '1710116078',
time: '2024-03-11T00:14:38Z',
},
git: {
branch: 'main',
commit: {
id: '95189bb08fa918576f10339eb15303d152ade2aa',
time: '2024-03-10T23:52:54Z',
},
},
};
$ SOURCE_DATE_EPOCH=0 scripts/web/create_build_info_ts.sh src/build-info.ts
⇓
...
build: {
...
time: '1970-01-01T00:00:00Z',
},
...