Skip to content

Commit

Permalink
Add node REPL
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Sep 26, 2024
1 parent e599742 commit a5e0053
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
27 changes: 27 additions & 0 deletions node/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,33 @@ To run the integration tests with existing servers, run the following command:
npm run test -- --cluster-endpoints=localhost:7000 --standalone-endpoints=localhost:6379
```
### REPL (interactive shell)
It is possible to run an interactive shell synced with the currect client code to test and debug it:
```bash
npx ts-node --project tsconfig.json
```
This shell allows executing node code line by line:
```typescript
import { GlideClient, GlideClusterClient } from ".";
let client = await GlideClient.createClient({
addresses: [{ host: "localhost", port: 6379 }],
});
let clusterClient = await GlideClusterClient.createClient({
addresses: [{ host: "localhost", port: 7000 }],
});
await client.ping();
```
After applying changes in client code you need to restart the shell.
It has command history and bash-like search (`Ctrl+R`).
Shell hangs on exit (`Ctrl+D`) if you don't close the clients. Use `Ctrl+C` to kill it and/or close clients before exit.

### Submodules

After pulling new changes, ensure that you update the submodules by running the following command:
Expand Down
3 changes: 2 additions & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"semver": "^7.6.3",
"ts-jest": "^29.2.5",
"typescript": "^5.5.4",
"uuid": "^10.0.0"
"uuid": "^10.0.0",
"ts-node": "^10.9.2"
},
"author": "Valkey GLIDE Maintainers",
"license": "Apache-2.0",
Expand Down
9 changes: 9 additions & 0 deletions node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
"outDir": "./build-ts" /* Specify an output folder for all emitted files.*/
},
"ts-node": {
"transpileOnly": true,
"compilerOptions": {
"module": "CommonJS",
"target": "ES2018",
"esModuleInterop": true
},
"esm": true
},
"compileOnSave": false,
"include": ["./*.ts", "src/*.ts", "src/*.js"],
"exclude": ["node_modules", "build-ts"]
Expand Down

0 comments on commit a5e0053

Please sign in to comment.