mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
feat: init package cli (#1646)
This commit is contained in:
58
packages/cli/src/dev.mjs
Normal file
58
packages/cli/src/dev.mjs
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env node
|
||||
import { spawn } from 'node:child_process';
|
||||
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 dev = await p.group(
|
||||
{
|
||||
server: () =>
|
||||
p.select({
|
||||
message: `Select dev server`,
|
||||
initialValue: 'local',
|
||||
options: [
|
||||
{
|
||||
value: 'local',
|
||||
label: 'local - 127.0.0.1:3000',
|
||||
hint: 'recommend',
|
||||
},
|
||||
{ value: 'dev', label: 'dev - 100.84.105.99:11001' },
|
||||
{
|
||||
value: 'ac',
|
||||
label: 'ac - 100.85.73.88:12001',
|
||||
},
|
||||
{
|
||||
value: 'test',
|
||||
label: 'test - 100.84.105.99:11001',
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
onCancel: () => {
|
||||
p.cancel('Operation cancelled.');
|
||||
process.exit(0);
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (dev.server === 'local') {
|
||||
console.log('You might need setup OctoBase dev server first.');
|
||||
}
|
||||
|
||||
const env = {
|
||||
NODE_API_SERVER: dev.server,
|
||||
};
|
||||
|
||||
const cwd = path.resolve(__dirname, '..', '..', '..', 'apps', 'web');
|
||||
|
||||
const process = spawn('yarn', ['dev'], {
|
||||
env,
|
||||
cwd,
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
});
|
||||
Reference in New Issue
Block a user