AFFiNE/packages/frontend/electron/scripts/make-env.ts

61 lines
1.4 KiB
TypeScript
Raw Normal View History

import path from 'node:path';
import { fileURLToPath } from 'node:url';
2023-08-22 18:16:26 +03:00
import { z } from 'zod';
2023-08-22 18:16:26 +03:00
const ReleaseTypeSchema = z.enum(['stable', 'beta', 'canary', 'internal']);
const __dirname = fileURLToPath(new URL('.', import.meta.url));
2023-08-22 18:16:26 +03:00
const ROOT = path.resolve(__dirname, '..');
const envBuildType = (process.env.BUILD_TYPE || 'canary').trim().toLowerCase();
const buildType = ReleaseTypeSchema.parse(envBuildType);
const stableBuild = buildType === 'stable';
const productName = !stableBuild ? `AFFiNE-${buildType}` : 'AFFiNE';
const icoPath = path.join(
ROOT,
!stableBuild
? `./resources/icons/icon_${buildType}.ico`
: './resources/icons/icon.ico'
);
2023-10-16 18:54:28 +03:00
const iconX64PngPath = path.join(
ROOT,
`./resources/icons/icon_${buildType}_64x64.png`
);
2023-08-22 18:16:26 +03:00
const icnsPath = path.join(
ROOT,
!stableBuild
? `./resources/icons/icon_${buildType}.icns`
: './resources/icons/icon.icns'
);
2023-10-16 18:54:28 +03:00
const iconPngPath = path.join(ROOT, './resources/icons/icon.png');
2023-08-22 18:16:26 +03:00
const iconUrl = `https://cdn.affine.pro/app-icons/icon_${buildType}.ico`;
const arch =
process.argv.indexOf('--arch') > 0
? process.argv[process.argv.indexOf('--arch') + 1]
: process.arch;
const platform =
process.argv.indexOf('--platform') > 0
? process.argv[process.argv.indexOf('--platform') + 1]
: process.platform;
export {
arch,
2023-08-22 18:16:26 +03:00
buildType,
icnsPath,
2023-10-16 18:54:28 +03:00
iconPngPath,
2023-08-22 18:16:26 +03:00
iconUrl,
iconX64PngPath,
icoPath,
2023-08-22 18:16:26 +03:00
platform,
productName,
ROOT,
2023-08-22 18:16:26 +03:00
stableBuild,
};