build: unify build flags (#2891)

This commit is contained in:
Alex Yang
2023-06-28 16:45:05 +08:00
parent e7f4d82881
commit fc36aac0fb
7 changed files with 93 additions and 63 deletions

View File

@@ -85,14 +85,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: development environment: development
env: env:
API_SERVER_PROFILE: local RELEASE_VERSION: canary
ENABLE_DEBUG_PAGE: 1
ENABLE_PLUGIN: true
ENABLE_ALL_PAGE_FILTER: true
ENABLE_LEGACY_PROVIDER: true
ENABLE_PRELOADING: false
ENABLE_NEW_SETTING_MODAL: false
ENABLE_SQLITE_PROVIDER: false
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@@ -112,13 +105,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: development environment: development
env: env:
API_SERVER_PROFILE: affine ENABLE_BOOKMARK_OPERATION: true
ENABLE_DEBUG_PAGE: 1 RELEASE_VERSION: canary
ENABLE_PLUGIN: true
ENABLE_ALL_PAGE_FILTER: true
ENABLE_LEGACY_PROVIDER: false
ENABLE_PRELOADING: false
ENABLE_NEW_SETTING_MODAL: false
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

View File

@@ -54,10 +54,6 @@ jobs:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
API_SERVER_PROFILE: prod
ENABLE_TEST_PROPERTIES: false
ENABLE_BOOKMARK_OPERATION: true
ENABLE_SQLITE_PROVIDER: false
RELEASE_VERSION: ${{ github.event.inputs.version }} RELEASE_VERSION: ${{ github.event.inputs.version }}
- name: Upload Artifact (web-static) - name: Upload Artifact (web-static)

View File

@@ -1,23 +1,5 @@
NEXT_PUBLIC_FIREBASE_API_KEY=
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
NEXT_PUBLIC_FIREBASE_PROJECT_ID=
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
NEXT_PUBLIC_FIREBASE_APP_ID=
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=
# absolute path to the block suite directory # absolute path to the block suite directory
LOCAL_BLOCK_SUITE= LOCAL_BLOCK_SUITE=
# see next.config.js
API_SERVER_PROFILE=
# save workspace to idb
ENABLE_IDB_PROVIDER=1
PREFETCH_WORKSPACE=1
ENABLE_BC_PROVIDER=1
EXPOSE_INTERNAL=1
ENABLE_DEBUG_PAGE=
ENABLE_SUBPAGE=
ENABLE_CHANGELOG=1
ENABLE_LEGACY_PROVIDER=true
# Sentry # Sentry
SENTRY_AUTH_TOKEN= SENTRY_AUTH_TOKEN=

View File

@@ -11,31 +11,87 @@ export const blockSuiteFeatureFlags = {
enable_drag_handle: true, enable_drag_handle: true,
enable_surface: true, enable_surface: true,
enable_linked_page: true, enable_linked_page: true,
enable_bookmark_operation: process.env.ENABLE_BOOKMARK_OPERATION === 'true', enable_bookmark_operation: false,
};
/**
* @type {Record<string, import('@affine/env').BuildFlags>}
*/
const buildPreset = {
stable: {
enableAllPageFilter: true,
enablePlugin: false,
enableTestProperties: false,
enableBroadcastChannelProvider: true,
enableDebugPage: true,
enableLegacyCloud: false,
changelogUrl: 'https://affine.pro/blog/what-is-new-affine-0620',
enablePreloading: true,
enableNewSettingModal: false,
enableSQLiteProvider: false,
},
beta: {},
internal: {},
// canary will be aggressive and enable all features
canary: {
enableAllPageFilter: true,
enablePlugin: true,
enableTestProperties: true,
enableBroadcastChannelProvider: true,
enableDebugPage: true,
enableLegacyCloud: false,
changelogUrl: 'https://github.com/toeverything/AFFiNE/releases',
enablePreloading: true,
enableNewSettingModal: true,
enableSQLiteProvider: true,
},
};
// beta and internal versions are the same as stable
buildPreset.beta = buildPreset.stable;
buildPreset.internal = buildPreset.stable;
const currentBuild = process.env.BUILD_ENV || 'stable';
const currentBuildPreset = buildPreset[currentBuild];
const environmentPreset = {
enablePlugin: process.env.ENABLE_PLUGIN
? process.env.ENABLE_PLUGIN === 'true'
: buildPreset.canary.enablePlugin,
enableAllPageFilter: process.env.ENABLE_ALL_PAGE_FILTER
? process.env.ENABLE_ALL_PAGE_FILTER === 'true'
: buildPreset.canary.enableAllPageFilter,
enableTestProperties: process.env.ENABLE_TEST_PROPERTIES
? process.env.ENABLE_TEST_PROPERTIES === 'true'
: buildPreset.canary.enableTestProperties,
enableLegacyCloud: process.env.ENABLE_LEGACY_PROVIDER
? process.env.ENABLE_LEGACY_PROVIDER === 'true'
: buildPreset.canary.enableLegacyCloud,
enableBroadcastChannelProvider: process.env.ENABLE_BC_PROVIDER
? process.env.ENABLE_BC_PROVIDER !== 'false'
: buildPreset.canary.enableBroadcastChannelProvider,
changelogUrl: process.env.CHANGELOG_URL ?? buildPreset.canary.changelogUrl,
enablePreloading: process.env.ENABLE_PRELOADING
? process.env.ENABLE_PRELOADING === 'true'
: buildPreset.canary.enablePreloading,
enableNewSettingModal: process.env.ENABLE_NEW_SETTING_MODAL
? process.env.ENABLE_NEW_SETTING_MODAL === 'true'
: buildPreset.canary.enableNewSettingModal,
enableSQLiteProvider: process.env.ENABLE_SQLITE_PROVIDER
? process.env.ENABLE_SQLITE_PROVIDER === 'true'
: buildPreset.canary.enableSQLiteProvider,
}; };
/** /**
* @type {import('@affine/env').BuildFlags} * @type {import('@affine/env').BuildFlags}
*/ */
export const buildFlags = { const buildFlags = {
enablePlugin: process.env.ENABLE_PLUGIN === 'true', ...currentBuildPreset,
enableAllPageFilter: // environment preset will overwrite current build preset
!!process.env.VERCEL || // this environment variable is for debug proposes only
(process.env.ENABLE_ALL_PAGE_FILTER // do not put them into CI
? process.env.ENABLE_ALL_PAGE_FILTER === 'true' ...environmentPreset,
: false),
enableTestProperties: process.env.ENABLE_TEST_PROPERTIES
? process.env.ENABLE_TEST_PROPERTIES === 'true'
: true,
enableLegacyCloud: process.env.ENABLE_LEGACY_PROVIDER
? process.env.ENABLE_LEGACY_PROVIDER === 'true'
: true,
enableBroadcastChannelProvider: process.env.ENABLE_BC_PROVIDER !== 'false',
enableDebugPage: true,
changelogUrl:
process.env.CHANGELOG_URL ??
'https://affine.pro/blog/what-is-new-affine-0620',
enablePreloading: process.env.ENABLE_PRELOADING === 'true',
enableNewSettingModal: process.env.ENABLE_NEW_SETTING_MODAL === 'true',
enableSQLiteProvider: process.env.ENABLE_SQLITE_PROVIDER === 'true',
}; };
export { buildFlags };

View File

@@ -32,6 +32,10 @@ function setEditorFlags(workspace: Workspace) {
value value
); );
}); });
workspace.awarenessStore.setFlag(
'enable_bookmark_operation',
environment.isDesktop
);
} }
const hashMap = new Map<string, Workspace>(); const hashMap = new Map<string, Workspace>();

View File

@@ -4,7 +4,9 @@ import { test } from '@playwright/test';
test('init page', async ({ page }) => { test('init page', async ({ page }) => {
await page.goto('http://localhost:8081/'); await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line'); await page.waitForSelector('v-line', {
timeout: 10000,
});
const currentWorkspaceId: string = await page.evaluate( const currentWorkspaceId: string = await page.evaluate(
() => (globalThis.currentWorkspace as any).id () => (globalThis.currentWorkspace as any).id

View File

@@ -15,9 +15,11 @@ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar t
await page.getByText('All Pages').click(); await page.getByText('All Pages').click();
} }
const title = 'AFFiNE - not just a note taking app';
// Drag-and-drop // Drag-and-drop
// Ref: https://playwright.dev/docs/input#dragging-manually // Ref: https://playwright.dev/docs/input#dragging-manually
await page.getByText('Untitled').hover(); await page.getByText(title).hover();
await page.mouse.down(); await page.mouse.down();
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
await page.getByText('Trash').hover(); await page.getByText('Trash').hover();
@@ -29,7 +31,7 @@ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar t
).toBeVisible(); ).toBeVisible();
await expect( await expect(
page.getByText('Untitled'), page.getByText(title),
'The deleted post is no longer on the All Page list' 'The deleted post is no longer on the All Page list'
).toHaveCount(0); ).toHaveCount(0);
@@ -37,7 +39,7 @@ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar t
// Visit trash page via url // Visit trash page via url
await page.getByText('Trash', { exact: true }).click(); await page.getByText('Trash', { exact: true }).click();
await expect( await expect(
page.getByText('Untitled'), page.getByText(title),
'The deleted post exists in the Trash list' 'The deleted post exists in the Trash list'
).toHaveCount(1); ).toHaveCount(1);
}); });