signal-desktop/ts/scripts/get-expire-time.ts

39 lines
1 KiB
TypeScript
Raw Normal View History

2021-12-14 08:43:46 -08:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { join } from 'path';
import { execSync } from 'child_process';
import { writeFileSync } from 'fs';
import { DAY } from '../util/durations';
2024-12-16 18:52:18 -05:00
import { version } from '../../package.json';
2025-01-16 11:44:23 -05:00
import { isNotUpdatable } from '../util/version';
2021-12-14 08:43:46 -08:00
const unixTimestamp = parseInt(
process.env.SOURCE_DATE_EPOCH ||
execSync('git show -s --format=%ct').toString('utf8'),
2021-12-14 08:43:46 -08:00
10
);
const buildCreation = unixTimestamp * 1000;
2025-01-16 11:44:23 -05:00
// NB: Build expirations are also determined via users' auto-update settings; see
// getExpirationTimestamp
const validDuration = isNotUpdatable(version) ? DAY * 30 : DAY * 90;
const buildExpiration = buildCreation + validDuration;
2021-12-14 08:43:46 -08:00
const localProductionPath = join(
__dirname,
'../../config/local-production.json'
);
2024-12-16 18:52:18 -05:00
const localProductionConfig = {
buildCreation,
buildExpiration,
2025-01-16 11:44:23 -05:00
...(isNotUpdatable(version) ? { updatesEnabled: false } : {}),
2024-12-16 18:52:18 -05:00
};
2021-12-14 08:43:46 -08:00
writeFileSync(
localProductionPath,
`${JSON.stringify(localProductionConfig)}\n`
);