Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node REPL #2355

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion 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 typescript and javascript 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 Expand Up @@ -166,7 +193,7 @@ Development on the Node wrapper may involve changes in either the TypeScript or
# Run from the node folder
npm run lint
# To automatically apply ESLint and/or prettier recommendations
npx run lint:fix
npm run lint:fix
```

2. Rust
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
Loading