feat: add local blocksuite debug support (#3591)

Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
fourdim
2023-08-08 01:44:31 +08:00
committed by GitHub
parent 952283fe16
commit ec05bd3f53
4 changed files with 95 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ const flags: BuildFlags = {
mode: 'development',
channel: 'canary',
coverage: false,
localBlockSuite: undefined,
};
const buildFlags = await p.group(
@@ -79,6 +80,11 @@ const buildFlags = await p.group(
message: 'Enable coverage',
initialValue: process.env.COVERAGE === 'true',
}),
debugBlockSuite: () =>
p.confirm({
message: 'Debug blocksuite locally?',
initialValue: false,
}),
},
{
onCancel: () => {
@@ -88,6 +94,27 @@ const buildFlags = await p.group(
}
);
if (buildFlags.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 (typeof localBlockSuite !== 'string') {
throw new Error('local blocksuite PATH is required');
}
if (!existsSync(localBlockSuite)) {
throw new Error(`local blocksuite not found: ${localBlockSuite}`);
}
flags.localBlockSuite = localBlockSuite;
}
flags.distribution = buildFlags.distribution as any;
flags.mode = buildFlags.mode as any;
flags.channel = buildFlags.channel as any;

View File

@@ -5,6 +5,7 @@ export type BuildFlags = {
mode: 'development' | 'production';
channel: 'stable' | 'beta' | 'canary' | 'internal';
coverage?: boolean;
localBlockSuite?: string;
};
export const projectRoot = fileURLToPath(