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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 30 deletions

View File

@ -88,8 +88,6 @@
"nx-cloud": "latest",
"nyc": "^15.1.0",
"prettier": "^2.8.8",
"react": "18.3.0-canary-8ec962d82-20230623",
"react-dom": "18.3.0-canary-8ec962d82-20230623",
"serve": "^14.2.0",
"typescript": "^5.1.5",
"vite": "^4.3.9",
@ -99,15 +97,5 @@
"vitest-fetch-mock": "^0.2.2",
"vitest-mock-extended": "^1.1.3"
},
"resolutions": {
"lit": "^2.7.2",
"idb": "^7.1.1",
"@emotion/cache": "^11.10.7",
"@types/cacheable-request": "^6.0.2",
"@types/responselike": "^1.0.0"
},
"packageManager": "yarn@3.6.0",
"dependencies": {
"marked-mangle": "^1.0.1"
}
"packageManager": "yarn@3.6.0"
}

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}`);
}

View File

@ -7,7 +7,7 @@
"allowSyntheticDefaultImports": true,
"outDir": "lib"
},
"include": ["vitest.config.ts", "scripts"],
"include": ["vitest.config.ts", "scripts", "packages/cli/src"],
"references": [
{
"path": "./packages/env"

View File

@ -73,8 +73,11 @@ __metadata:
"@clack/core": ^0.3.2
"@clack/prompts": ^0.6.3
dotenv: ^16.3.1
ts-node: ^10.9.1
peerDependencies:
ts-node: "*"
bin:
dev-web: ./src/dev.mjs
dev-web: ./src/dev.mts
languageName: unknown
linkType: soft
@ -356,15 +359,12 @@ __metadata:
husky: ^8.0.3
lint-staged: ^13.2.2
madge: ^6.1.0
marked-mangle: ^1.0.1
msw: ^1.2.2
nanoid: ^4.0.2
nx: 16.3.2
nx-cloud: latest
nyc: ^15.1.0
prettier: ^2.8.8
react: 18.3.0-canary-8ec962d82-20230623
react-dom: 18.3.0-canary-8ec962d82-20230623
serve: ^14.2.0
typescript: ^5.1.5
vite: ^4.3.9
@ -4690,7 +4690,7 @@ __metadata:
languageName: node
linkType: hard
"@emotion/cache@npm:^11.10.7":
"@emotion/cache@npm:^11.11.0":
version: 11.11.0
resolution: "@emotion/cache@npm:11.11.0"
dependencies:
@ -11792,7 +11792,7 @@ __metadata:
languageName: node
linkType: hard
"@types/cacheable-request@npm:^6.0.2":
"@types/cacheable-request@npm:^6.0.1":
version: 6.0.3
resolution: "@types/cacheable-request@npm:6.0.3"
dependencies:
@ -20412,7 +20412,14 @@ __metadata:
languageName: node
linkType: hard
"idb@npm:^7.1.1":
"idb@npm:7.0.1":
version: 7.0.1
resolution: "idb@npm:7.0.1"
checksum: 61526789562cc3518a1a030c7a06cc98edfcd62795700ff28c701d6f84c178aee4e98bedfc79e6c394ba26084aa4667d6594b1728e5868f305f9b34148662679
languageName: node
linkType: hard
"idb@npm:7.1.1, idb@npm:^7.1.1":
version: 7.1.1
resolution: "idb@npm:7.1.1"
checksum: 1973c28d53c784b177bdef9f527ec89ec239ec7cf5fcbd987dae75a16c03f5b7dfcc8c6d3285716fd0309dd57739805390bd9f98ce23b1b7d8849a3b52de8d56
@ -22973,7 +22980,7 @@ __metadata:
languageName: node
linkType: hard
"lit@npm:^2.7.2":
"lit@npm:^2.7.3, lit@npm:^2.7.5":
version: 2.7.5
resolution: "lit@npm:2.7.5"
dependencies: