Skip to content

Commit

Permalink
refactor: migrate to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
jschuur committed Apr 16, 2023
1 parent b74cfcd commit 03b1b18
Show file tree
Hide file tree
Showing 27 changed files with 1,558 additions and 748 deletions.
18 changes: 0 additions & 18 deletions .eslintrc.cjs

This file was deleted.

20 changes: 20 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"linebreak-style": ["error", "unix"],
"semi": ["error", "always"],
"quotes": ["error", "single"]
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.env
!.env.sample
!.env.sample
dist
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Instead of entering a prompt, you can also use a number of commands to modify se

- `.model`, `.temperature`, `.maxtokens`, `.historylength` or `.system` followed by a value will change a setting, or show it without a value
- `.settings` shows all the current settings
- `.reset` resets settings to when you launched the current session
- `.reset` resets one or all settings to when you launched the current session
- `.retry` reruns the last prompt with the latest settings
- `.last` shows the last response again without running it through ChatGPT again (applies new word wrap/clipboard settings)
- `.clear` clears the [conversation history](#controlling-conversation-context)
Expand Down Expand Up @@ -92,6 +92,6 @@ When asked 'What are the benefits of a ChatGPT command line interface?', it whol
## Stack

Some of the libraries used: [clack](https://github.com/natemoo-re/clack/) for some of the prompt UI, [OpenAI Node.js library](https://github.com/openai/openai-node) to interact with the ChatGPT API, [node-clipboardy](https://www.npmjs.com/package/node-clipboardy) to copy responses to the system clipboard.
Some of the libraries used: [clack](https://github.com/natemoo-re/clack/) for some of the prompt UI, [OpenAI Node.js library](https://github.com/openai/openai-node) to interact with the ChatGPT API, [node-clipboardy](https://www.npmjs.com/package/node-clipboardy) to copy responses to the system clipboard, [zod](https://zod.dev/) for type safe validation [tsx](https://www.npmjs.com/package/tsx) for local TypeScript development.

\- [Joost Schuur](https://joostschuur.com) ([@joostschuur](https://twitter.com/joostschuur))
39 changes: 34 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
{
"name": "chatgpt-repl",
"version": "0.4.4",
"version": "0.4.6",
"description": "CLI REPL interface to ChatGPT",
"main": "src/cli.js",
"type": "module",
"bin": {
"chatgpt-repl": "src/cli.js"
"chatgpt-repl": "dist/cli.js"
},
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"clean": "rm -rf dist; rm -rf node_modules; pnpm install",
"lint": "tsc --noEmit",
"chatgpt-repl": "tsx src/cli.ts",
"prepublishOnly": "pnpm run lint && pnpm run clean && pnpm run build"
},
"scripts": {},
"author": "Joost Schuur <[email protected]>",
"license": "ISC",
"dependencies": {
"@clack/prompts": "^0.6.3",
"axios": "^1.3.5",
"boolean": "^3.2.0",
"commander": "^10.0.0",
"conf": "^11.0.1",
Expand All @@ -27,11 +35,17 @@
"term-size": "^3.0.2",
"update-notifier": "^6.0.2",
"wordcount": "^1.1.1",
"wrap-text": "^1.0.9"
"wrap-text": "^1.0.9",
"zod": "^3.21.4"
},
"publishConfig": {
"access": "public"
},
"files": [
"dist",
"package.json",
"screenshot.png"
],
"keywords": [
"chatgpt",
"cli",
Expand All @@ -48,6 +62,21 @@
"url": "https://github.com/jschuur/chatgpt-repl.git"
},
"devDependencies": {
"eslint": "^8.35.0"
"@types/jsonfile": "^6.1.1",
"@types/md5": "^2.3.2",
"@types/node": "^18.15.3",
"@types/pluralize": "^0.0.29",
"@types/update-notifier": "^6.0.2",
"@types/wrap-text": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"eslint": "^8.35.0",
"tsx": "^3.12.5",
"typescript": "^5.0.2"
},
"cspell": {
"ignorePaths": [
"pnpm-lock.yaml"
]
}
}
Loading

0 comments on commit 03b1b18

Please sign in to comment.