2023-10-18 09:13:47 +03:00
|
|
|
import path from 'node:path';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
2023-08-22 18:16:26 +03:00
|
|
|
|
2023-10-18 09:13:47 +03:00
|
|
|
import { z } from 'zod';
|
2023-08-22 18:16:26 +03:00
|
|
|
|
|
|
|
const ReleaseTypeSchema = z.enum(['stable', 'beta', 'canary', 'internal']);
|
|
|
|
|
2023-10-18 09:13:47 +03:00
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
|
|
|
2024-09-18 07:14:56 +03:00
|
|
|
const REPO_ROOT = path.resolve(__dirname, '..', '..', '..', '..', '..');
|
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
|
|
|
|
2024-03-21 17:29:02 +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;
|
|
|
|
|
2024-04-25 06:30:04 +03:00
|
|
|
const appIdMap = {
|
|
|
|
internal: 'pro.affine.internal',
|
|
|
|
canary: 'pro.affine.canary',
|
|
|
|
beta: 'pro.affine.beta',
|
|
|
|
stable: 'pro.affine.app',
|
|
|
|
};
|
|
|
|
|
2023-10-18 09:13:47 +03:00
|
|
|
export {
|
2024-04-25 06:30:04 +03:00
|
|
|
appIdMap,
|
2023-10-18 09:13:47 +03:00
|
|
|
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,
|
2024-03-21 17:29:02 +03:00
|
|
|
iconX64PngPath,
|
2023-10-18 09:13:47 +03:00
|
|
|
icoPath,
|
2023-08-22 18:16:26 +03:00
|
|
|
platform,
|
2023-10-18 09:13:47 +03:00
|
|
|
productName,
|
2024-04-25 06:30:04 +03:00
|
|
|
REPO_ROOT,
|
2023-10-18 09:13:47 +03:00
|
|
|
ROOT,
|
2023-08-22 18:16:26 +03:00
|
|
|
stableBuild,
|
|
|
|
};
|