There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat: improve dev mode for local blocksuite (#1654)
Himself65156edb1d4b8c
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjsindex 640d24ec1f..1dfd744225 100644--- a/apps/web/next.config.mjs+++ b/apps/web/next.config.mjs@@ -14,6 +14,10 @@ console.info('Runtime Preset', preset);const enableDebugLocal = path.isAbsolute(process.env.LOCAL_BLOCK_SUITE ?? '');+if (enableDebugLocal) {+ console.info('Debugging local blocksuite');+}+const profileTarget = {ac: '100.85.73.88:12001',dev: '100.84.105.99:11001',diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex aa76e06f88..9885c9069e 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -11,5 +11,8 @@"devDependencies": {"@clack/core": "^0.3.2","@clack/prompts": "^0.6.3"+ },+ "dependencies": {+ "dotenv": "^16.0.3"}}diff --git a/packages/cli/src/dev.mjs b/packages/cli/src/dev.mjsindex 30875a60b6..5a228ecb32 100755--- a/packages/cli/src/dev.mjs+++ b/packages/cli/src/dev.mjs@@ -1,12 +1,17 @@#!/usr/bin/env nodeimport { spawn } from 'node:child_process';+import * as fs from 'node:fs';import * as path from 'node:path';import { fileURLToPath } from 'node:url';import * as p from '@clack/prompts';+const __filename = fileURLToPath(import.meta.url);const __dirname = path.dirname(__filename);+const root = path.resolve(__dirname, '..', '..', '..');+const cwd = path.resolve(root, 'apps', 'web');+const dev = await p.group({server: () =>@@ -30,6 +35,11 @@ const dev = await p.group(},],}),+ debugBlockSuite: () =>+ p.confirm({+ message: 'Debug blocksuite locally?',+ initialValue: false,+ }),},{onCancel: () => {@@ -39,17 +49,34 @@ const dev = await p.group(});-if (dev.server === 'local') {- console.log('You might need setup OctoBase dev server first.');-}-const env = {NODE_API_SERVER: dev.server,PATH: process.env.PATH,};-const root = path.resolve(__dirname, '..', '..', '..');-const cwd = path.resolve(root, 'apps', 'web');+if (dev.debugBlockSuite) {+ const { config } = await import('dotenv');+ const envLocal = config({+ path: path.resolve(cwd, '.env.local'),+ });++ const localBlockSuite = await p.text({+ message: 'local blocksuite PATH',+ initialValue: envLocal.error+ ? undefined+ : envLocal.parsed.LOCAL_BLOCK_SUITE,+ });+ if (!fs.existsSync(localBlockSuite)) {+ throw new Error(`local blocksuite not found: ${localBlockSuite}`);+ }+ env.LOCAL_BLOCK_SUITE = localBlockSuite;+} else {+ env.LOCAL_BLOCK_SUITE = '';+}++if (dev.server === 'local') {+ console.log('You might need setup OctoBase dev server first.');+}spawn('yarn', ['dev'], {env,diff --git a/yarn.lock b/yarn.lockindex ef75f970f8..910a805381 100644--- a/yarn.lock+++ b/yarn.lock@@ -73,6 +73,7 @@ __metadata:dependencies:"@clack/core": ^0.3.2"@clack/prompts": ^0.6.3+ dotenv: ^16.0.3bin:dev-web: ./src/dev.mjslanguageName: unknown