mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-09-21 00:18:02 +03:00
feat: improve dev mode for local blocksuite (#1654)
This commit is contained in:
parent
ba2295c426
commit
156edb1d4b
@ -14,6 +14,10 @@ console.info('Runtime Preset', preset);
|
|||||||
|
|
||||||
const enableDebugLocal = path.isAbsolute(process.env.LOCAL_BLOCK_SUITE ?? '');
|
const enableDebugLocal = path.isAbsolute(process.env.LOCAL_BLOCK_SUITE ?? '');
|
||||||
|
|
||||||
|
if (enableDebugLocal) {
|
||||||
|
console.info('Debugging local blocksuite');
|
||||||
|
}
|
||||||
|
|
||||||
const profileTarget = {
|
const profileTarget = {
|
||||||
ac: '100.85.73.88:12001',
|
ac: '100.85.73.88:12001',
|
||||||
dev: '100.84.105.99:11001',
|
dev: '100.84.105.99:11001',
|
||||||
|
@ -11,5 +11,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@clack/core": "^0.3.2",
|
"@clack/core": "^0.3.2",
|
||||||
"@clack/prompts": "^0.6.3"
|
"@clack/prompts": "^0.6.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"dotenv": "^16.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
import * as p from '@clack/prompts';
|
import * as p from '@clack/prompts';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
const root = path.resolve(__dirname, '..', '..', '..');
|
||||||
|
const cwd = path.resolve(root, 'apps', 'web');
|
||||||
|
|
||||||
const dev = await p.group(
|
const dev = await p.group(
|
||||||
{
|
{
|
||||||
server: () =>
|
server: () =>
|
||||||
@ -30,6 +35,11 @@ const dev = await p.group(
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
debugBlockSuite: () =>
|
||||||
|
p.confirm({
|
||||||
|
message: 'Debug blocksuite locally?',
|
||||||
|
initialValue: false,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
onCancel: () => {
|
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 = {
|
const env = {
|
||||||
NODE_API_SERVER: dev.server,
|
NODE_API_SERVER: dev.server,
|
||||||
PATH: process.env.PATH,
|
PATH: process.env.PATH,
|
||||||
};
|
};
|
||||||
|
|
||||||
const root = path.resolve(__dirname, '..', '..', '..');
|
if (dev.debugBlockSuite) {
|
||||||
const cwd = path.resolve(root, 'apps', 'web');
|
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'], {
|
spawn('yarn', ['dev'], {
|
||||||
env,
|
env,
|
||||||
|
Loading…
Reference in New Issue
Block a user