2023-07-18 19:53:10 +03:00
|
|
|
import type { BlockSuiteFeatureFlags, RuntimeConfig } from '@affine/env/global';
|
|
|
|
import type { BuildFlags } from '@affine/cli/config';
|
|
|
|
import { createRequire } from 'node:module';
|
|
|
|
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
const packageJson = require('../package.json');
|
|
|
|
|
|
|
|
const editorFlags: BlockSuiteFeatureFlags = {
|
2023-12-04 15:02:35 +03:00
|
|
|
enable_expand_database_block: false,
|
|
|
|
enable_bultin_ledits: false,
|
2023-07-18 19:53:10 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export function getRuntimeConfig(buildFlags: BuildFlags): RuntimeConfig {
|
2023-08-29 13:07:05 +03:00
|
|
|
const buildPreset: Record<BuildFlags['channel'], RuntimeConfig> = {
|
2023-07-18 19:53:10 +03:00
|
|
|
stable: {
|
|
|
|
enableTestProperties: false,
|
|
|
|
enableBroadcastChannelProvider: true,
|
|
|
|
enableDebugPage: true,
|
2023-11-08 15:08:24 +03:00
|
|
|
changelogUrl: 'https://affine.pro/what-is-new',
|
2023-12-06 13:43:13 +03:00
|
|
|
downloadUrl: 'https://affine.pro/download',
|
2024-01-05 17:01:25 +03:00
|
|
|
imageProxyUrl: '/api/worker/image-proxy',
|
2024-01-23 11:53:56 +03:00
|
|
|
linkPreviewUrl: '/api/worker/link-preview',
|
2023-07-18 19:53:10 +03:00
|
|
|
enablePreloading: true,
|
|
|
|
enableNewSettingModal: true,
|
|
|
|
enableNewSettingUnstableApi: false,
|
|
|
|
enableSQLiteProvider: true,
|
|
|
|
enableMoveDatabase: false,
|
2023-08-29 13:07:05 +03:00
|
|
|
enableNotificationCenter: true,
|
|
|
|
enableCloud: true,
|
2023-10-18 11:06:07 +03:00
|
|
|
enableCaptcha: true,
|
2023-08-29 13:07:05 +03:00
|
|
|
enableEnhanceShareMode: false,
|
2023-10-25 19:50:39 +03:00
|
|
|
enablePayment: true,
|
2023-12-27 09:30:29 +03:00
|
|
|
enablePageHistory: true,
|
2023-12-21 15:52:38 +03:00
|
|
|
serverUrlPrefix: 'https://app.affine.pro',
|
2023-07-18 19:53:10 +03:00
|
|
|
editorFlags,
|
|
|
|
appVersion: packageJson.version,
|
2023-12-06 13:15:03 +03:00
|
|
|
editorVersion: packageJson.dependencies['@blocksuite/presets'],
|
feat(core): add manual check for updates (#4957)
work for #4523
add `appBuildType` to `runtimeConfig`
add `useAppUpdater` to manage client updates
<!--
copilot:summary
-->
### <samp>🤖[[deprecated]](https://githubnext.com/copilot-for-prs-sunset) Generated by Copilot at cdd012c</samp>
This pull request refactors and enhances the update functionality for the frontend. It introduces a new custom hook `useAppUpdater` that simplifies the update logic and state management, and uses it in various components and commands. It also adds more options and feedback for the user to control and monitor the update process, such as manual download, auto-check, and auto-download toggles, and update status and progress indicators. It also updates the `AboutAffine` component to show the app icon, version, and build type. It also adds new translations, dependencies, types, and schemas related to the update functionality.
<img width="1073" alt="image" src="https://github.com/toeverything/AFFiNE/assets/102217452/16ae7a6a-0035-4e57-902b-6b8f63169501">
2023-11-29 16:31:25 +03:00
|
|
|
appBuildType: 'stable',
|
2023-07-18 19:53:10 +03:00
|
|
|
},
|
2023-08-29 13:07:05 +03:00
|
|
|
get beta() {
|
|
|
|
return {
|
|
|
|
...this.stable,
|
2023-12-27 09:30:29 +03:00
|
|
|
enablePageHistory: true,
|
2023-09-01 12:27:12 +03:00
|
|
|
serverUrlPrefix: 'https://insider.affine.pro',
|
feat(core): add manual check for updates (#4957)
work for #4523
add `appBuildType` to `runtimeConfig`
add `useAppUpdater` to manage client updates
<!--
copilot:summary
-->
### <samp>🤖[[deprecated]](https://githubnext.com/copilot-for-prs-sunset) Generated by Copilot at cdd012c</samp>
This pull request refactors and enhances the update functionality for the frontend. It introduces a new custom hook `useAppUpdater` that simplifies the update logic and state management, and uses it in various components and commands. It also adds more options and feedback for the user to control and monitor the update process, such as manual download, auto-check, and auto-download toggles, and update status and progress indicators. It also updates the `AboutAffine` component to show the app icon, version, and build type. It also adds new translations, dependencies, types, and schemas related to the update functionality.
<img width="1073" alt="image" src="https://github.com/toeverything/AFFiNE/assets/102217452/16ae7a6a-0035-4e57-902b-6b8f63169501">
2023-11-29 16:31:25 +03:00
|
|
|
appBuildType: 'beta' as const,
|
2023-08-29 13:07:05 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
get internal() {
|
|
|
|
return {
|
|
|
|
...this.stable,
|
2023-09-08 05:44:06 +03:00
|
|
|
serverUrlPrefix: 'https://insider.affine.pro',
|
feat(core): add manual check for updates (#4957)
work for #4523
add `appBuildType` to `runtimeConfig`
add `useAppUpdater` to manage client updates
<!--
copilot:summary
-->
### <samp>🤖[[deprecated]](https://githubnext.com/copilot-for-prs-sunset) Generated by Copilot at cdd012c</samp>
This pull request refactors and enhances the update functionality for the frontend. It introduces a new custom hook `useAppUpdater` that simplifies the update logic and state management, and uses it in various components and commands. It also adds more options and feedback for the user to control and monitor the update process, such as manual download, auto-check, and auto-download toggles, and update status and progress indicators. It also updates the `AboutAffine` component to show the app icon, version, and build type. It also adds new translations, dependencies, types, and schemas related to the update functionality.
<img width="1073" alt="image" src="https://github.com/toeverything/AFFiNE/assets/102217452/16ae7a6a-0035-4e57-902b-6b8f63169501">
2023-11-29 16:31:25 +03:00
|
|
|
appBuildType: 'internal' as const,
|
2023-08-29 13:07:05 +03:00
|
|
|
};
|
|
|
|
},
|
2023-07-18 19:53:10 +03:00
|
|
|
// canary will be aggressive and enable all features
|
|
|
|
canary: {
|
|
|
|
enableTestProperties: true,
|
|
|
|
enableBroadcastChannelProvider: true,
|
|
|
|
enableDebugPage: true,
|
2023-07-28 18:00:03 +03:00
|
|
|
changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
|
2023-12-06 13:43:13 +03:00
|
|
|
downloadUrl: 'https://affine.pro/download',
|
2024-01-05 17:01:25 +03:00
|
|
|
imageProxyUrl: '/api/worker/image-proxy',
|
2024-01-23 11:53:56 +03:00
|
|
|
linkPreviewUrl: '/api/worker/link-preview',
|
2023-07-18 19:53:10 +03:00
|
|
|
enablePreloading: true,
|
|
|
|
enableNewSettingModal: true,
|
|
|
|
enableNewSettingUnstableApi: false,
|
|
|
|
enableSQLiteProvider: true,
|
|
|
|
enableMoveDatabase: false,
|
|
|
|
enableNotificationCenter: true,
|
2023-08-29 13:07:05 +03:00
|
|
|
enableCloud: true,
|
2023-10-18 11:06:07 +03:00
|
|
|
enableCaptcha: true,
|
2023-08-29 13:07:05 +03:00
|
|
|
enableEnhanceShareMode: false,
|
2023-10-27 11:59:13 +03:00
|
|
|
enablePayment: true,
|
2023-11-27 05:41:19 +03:00
|
|
|
enablePageHistory: true,
|
2023-08-29 13:07:05 +03:00
|
|
|
serverUrlPrefix: 'https://affine.fail',
|
2023-07-18 19:53:10 +03:00
|
|
|
editorFlags,
|
|
|
|
appVersion: packageJson.version,
|
2023-12-06 13:15:03 +03:00
|
|
|
editorVersion: packageJson.dependencies['@blocksuite/presets'],
|
feat(core): add manual check for updates (#4957)
work for #4523
add `appBuildType` to `runtimeConfig`
add `useAppUpdater` to manage client updates
<!--
copilot:summary
-->
### <samp>🤖[[deprecated]](https://githubnext.com/copilot-for-prs-sunset) Generated by Copilot at cdd012c</samp>
This pull request refactors and enhances the update functionality for the frontend. It introduces a new custom hook `useAppUpdater` that simplifies the update logic and state management, and uses it in various components and commands. It also adds more options and feedback for the user to control and monitor the update process, such as manual download, auto-check, and auto-download toggles, and update status and progress indicators. It also updates the `AboutAffine` component to show the app icon, version, and build type. It also adds new translations, dependencies, types, and schemas related to the update functionality.
<img width="1073" alt="image" src="https://github.com/toeverything/AFFiNE/assets/102217452/16ae7a6a-0035-4e57-902b-6b8f63169501">
2023-11-29 16:31:25 +03:00
|
|
|
appBuildType: 'canary',
|
2023-07-18 19:53:10 +03:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const currentBuild = buildFlags.channel;
|
|
|
|
|
|
|
|
if (!(currentBuild in buildPreset)) {
|
|
|
|
throw new Error(`BUILD_TYPE ${currentBuild} is not supported`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const currentBuildPreset = buildPreset[currentBuild];
|
|
|
|
|
|
|
|
const environmentPreset = {
|
|
|
|
enableTestProperties: process.env.ENABLE_TEST_PROPERTIES
|
|
|
|
? process.env.ENABLE_TEST_PROPERTIES === 'true'
|
|
|
|
: currentBuildPreset.enableTestProperties,
|
|
|
|
enableBroadcastChannelProvider: process.env.ENABLE_BC_PROVIDER
|
|
|
|
? process.env.ENABLE_BC_PROVIDER !== 'false'
|
|
|
|
: currentBuildPreset.enableBroadcastChannelProvider,
|
|
|
|
changelogUrl: process.env.CHANGELOG_URL ?? currentBuildPreset.changelogUrl,
|
|
|
|
enablePreloading: process.env.ENABLE_PRELOADING
|
|
|
|
? process.env.ENABLE_PRELOADING === 'true'
|
|
|
|
: currentBuildPreset.enablePreloading,
|
|
|
|
enableNewSettingModal: process.env.ENABLE_NEW_SETTING_MODAL
|
|
|
|
? process.env.ENABLE_NEW_SETTING_MODAL === 'true'
|
|
|
|
: currentBuildPreset.enableNewSettingModal,
|
|
|
|
enableSQLiteProvider: process.env.ENABLE_SQLITE_PROVIDER
|
|
|
|
? process.env.ENABLE_SQLITE_PROVIDER === 'true'
|
|
|
|
: currentBuildPreset.enableSQLiteProvider,
|
|
|
|
enableNewSettingUnstableApi: process.env.ENABLE_NEW_SETTING_UNSTABLE_API
|
|
|
|
? process.env.ENABLE_NEW_SETTING_UNSTABLE_API === 'true'
|
|
|
|
: currentBuildPreset.enableNewSettingUnstableApi,
|
|
|
|
enableNotificationCenter: process.env.ENABLE_NOTIFICATION_CENTER
|
|
|
|
? process.env.ENABLE_NOTIFICATION_CENTER === 'true'
|
|
|
|
: currentBuildPreset.enableNotificationCenter,
|
|
|
|
enableCloud: process.env.ENABLE_CLOUD
|
|
|
|
? process.env.ENABLE_CLOUD === 'true'
|
|
|
|
: currentBuildPreset.enableCloud,
|
2023-10-18 11:06:07 +03:00
|
|
|
enableCaptcha: process.env.ENABLE_CAPTCHA
|
|
|
|
? process.env.ENABLE_CAPTCHA === 'true'
|
|
|
|
: buildFlags.mode === 'development'
|
2023-11-23 08:18:05 +03:00
|
|
|
? false
|
|
|
|
: currentBuildPreset.enableCaptcha,
|
2023-08-29 13:07:05 +03:00
|
|
|
enableEnhanceShareMode: process.env.ENABLE_ENHANCE_SHARE_MODE
|
|
|
|
? process.env.ENABLE_ENHANCE_SHARE_MODE === 'true'
|
|
|
|
: currentBuildPreset.enableEnhanceShareMode,
|
2023-07-18 19:53:10 +03:00
|
|
|
enableMoveDatabase: process.env.ENABLE_MOVE_DATABASE
|
|
|
|
? process.env.ENABLE_MOVE_DATABASE === 'true'
|
|
|
|
: currentBuildPreset.enableMoveDatabase,
|
2023-10-25 19:50:39 +03:00
|
|
|
enablePayment: process.env.ENABLE_PAYMENT
|
|
|
|
? process.env.ENABLE_PAYMENT !== 'false'
|
|
|
|
: buildFlags.mode === 'development'
|
2023-11-23 08:18:05 +03:00
|
|
|
? true
|
|
|
|
: currentBuildPreset.enablePayment,
|
2023-11-27 05:41:19 +03:00
|
|
|
enablePageHistory: process.env.ENABLE_PAGE_HISTORY
|
|
|
|
? process.env.ENABLE_PAGE_HISTORY === 'true'
|
|
|
|
: buildFlags.mode === 'development'
|
|
|
|
? true
|
|
|
|
: currentBuildPreset.enablePageHistory,
|
2023-07-18 19:53:10 +03:00
|
|
|
};
|
|
|
|
|
2023-08-29 13:07:05 +03:00
|
|
|
if (buildFlags.mode === 'development') {
|
|
|
|
currentBuildPreset.serverUrlPrefix = 'http://localhost:8080';
|
|
|
|
}
|
|
|
|
|
2023-07-18 19:53:10 +03:00
|
|
|
return {
|
|
|
|
...currentBuildPreset,
|
|
|
|
// environment preset will overwrite current build preset
|
|
|
|
// this environment variable is for debug proposes only
|
|
|
|
// do not put them into CI
|
|
|
|
...(process.env.CI ? {} : environmentPreset),
|
|
|
|
};
|
|
|
|
}
|