refactor(cli): use typescript (#2938)

This commit is contained in:
Alex Yang
2023-06-30 14:58:57 +08:00
committed by GitHub
parent 62b465a889
commit b6c314e180
5 changed files with 32 additions and 30 deletions

View File

@@ -3,17 +3,21 @@
"type": "module",
"private": true,
"bin": {
"dev-web": "./src/dev.mjs"
"dev-web": "./src/dev.mts"
},
"scripts": {
"start": "node ./src/dev.mjs"
"start": "ts-node-esm ./src/dev.mjs"
},
"devDependencies": {
"@clack/core": "^0.3.2",
"@clack/prompts": "^0.6.3"
"@clack/prompts": "^0.6.3",
"ts-node": "^10.9.1"
},
"dependencies": {
"dotenv": "^16.3.1"
},
"peerDependencies": {
"ts-node": "*"
},
"version": "0.7.0-canary.24"
}

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env ts-node-esm
import { spawn } from 'node:child_process';
import * as fs from 'node:fs';
import * as path from 'node:path';
@@ -28,10 +28,10 @@ const dev = await p.group(
}
);
const env = {
PATH: process.env.PATH,
const env: Record<string, string> = {
PATH: process.env.PATH ?? '',
NODE_ENV: 'development',
PORT: 8080,
PORT: '8080',
};
if (dev.debugBlockSuite) {
@@ -44,8 +44,11 @@ if (dev.debugBlockSuite) {
message: 'local blocksuite PATH',
initialValue: envLocal.error
? undefined
: envLocal.parsed.LOCAL_BLOCK_SUITE,
: envLocal.parsed?.LOCAL_BLOCK_SUITE,
});
if (typeof localBlockSuite !== 'string') {
throw new Error('local blocksuite PATH is required');
}
if (!fs.existsSync(localBlockSuite)) {
throw new Error(`local blocksuite not found: ${localBlockSuite}`);
}