universo-platform-2d

Форк
0
84 строки · 2.9 Кб
1
import type { BUILD_CONFIG_TYPE } from '@affine/env/global';
2

3
import packageJson from '../../package.json' assert { type: 'json' };
4
import type { BuildFlags } from '../config';
5

6
export function getBuildConfig(buildFlags: BuildFlags): BUILD_CONFIG_TYPE {
7
  const buildPreset: Record<BuildFlags['channel'], BUILD_CONFIG_TYPE> = {
8
    get stable() {
9
      return {
10
        debug: buildFlags.mode === 'development',
11
        distribution: buildFlags.distribution,
12
        isDesktopEdition: (
13
          ['web', 'desktop', 'admin'] as BuildFlags['distribution'][]
14
        ).includes(buildFlags.distribution),
15
        isMobileEdition: (['mobile'] as BuildFlags['distribution'][]).includes(
16
          buildFlags.distribution
17
        ),
18
        isElectron: buildFlags.distribution === 'desktop',
19
        isWeb: buildFlags.distribution === 'web',
20
        isMobileWeb: buildFlags.distribution === 'mobile',
21

22
        isSelfHosted: process.env.SELF_HOSTED === 'true',
23
        appBuildType: 'stable' as const,
24
        serverUrlPrefix: 'https://app.affine.pro',
25
        appVersion: packageJson.version,
26
        editorVersion: packageJson.devDependencies['@blocksuite/affine'],
27
        githubUrl: 'https://github.com/toeverything/AFFiNE',
28
        changelogUrl: 'https://affine.pro/what-is-new',
29
        downloadUrl: 'https://affine.pro/download',
30
        imageProxyUrl: '/api/worker/image-proxy',
31
        linkPreviewUrl: '/api/worker/link-preview',
32
      };
33
    },
34
    get beta() {
35
      return {
36
        ...this.stable,
37
        appBuildType: 'beta' as const,
38
        serverUrlPrefix: 'https://insider.affine.pro',
39
        changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
40
      };
41
    },
42
    get internal() {
43
      return {
44
        ...this.stable,
45
        appBuildType: 'internal' as const,
46
        serverUrlPrefix: 'https://insider.affine.pro',
47
        changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
48
      };
49
    },
50
    // canary will be aggressive and enable all features
51
    get canary() {
52
      return {
53
        ...this.stable,
54
        appBuildType: 'canary' as const,
55
        serverUrlPrefix: 'https://affine.fail',
56
        changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
57
      };
58
    },
59
  };
60

61
  const currentBuild = buildFlags.channel;
62

63
  if (!(currentBuild in buildPreset)) {
64
    throw new Error(`BUILD_TYPE ${currentBuild} is not supported`);
65
  }
66

67
  const currentBuildPreset = buildPreset[currentBuild];
68

69
  const environmentPreset = {
70
    changelogUrl: process.env.CHANGELOG_URL ?? currentBuildPreset.changelogUrl,
71
  };
72

73
  if (buildFlags.mode === 'development') {
74
    currentBuildPreset.serverUrlPrefix = 'http://localhost:8080';
75
  }
76

77
  return {
78
    ...currentBuildPreset,
79
    // environment preset will overwrite current build preset
80
    // this environment variable is for debug proposes only
81
    // do not put them into CI
82
    ...(process.env.CI ? {} : environmentPreset),
83
  };
84
}
85

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.