httptoolkit / httptoolkit-server

The backend of HTTP Toolkit
https://httptoolkit.com
GNU Affero General Public License v3.0
460 stars 101 forks source link

Building on Windows #141

Open Starmania opened 3 days ago

Starmania commented 3 days ago

Hey Tim, I've been thinking about this for a long time, and Oclif is now able to build (and pack) on windows, so here we are...

Would it be interesting to make the build compatible between windows/linux?

I've done a few tests and according to the Oclif example, here's which version Httptoolkit-server should have: I only include what should be updated for the sake of brievity

  "dependencies": {
    "@oclif/core": "^4", // from "@oclif/command ^1.5.2
    "@oclif/plugin-help": "^6", //from ^2.2.3
    "@oclif/plugin-plugins": "^5"
    "@oclif/plugin-update": "^4" // from ^1.3.8
  },
  "devDependencies": {
    "@oclif/prettier-config": "^0.2.1",
    "@oclif/test": "^4",
    "eslint": "^8",
    "eslint-config-oclif": "^5",
    "eslint-config-oclif-typescript": "^3",
    "eslint-config-prettier": "^9",
    "oclif": "^4",
    "shx": "^0.3.3",
    "typescript": "^5" // from ~4.7, still compatible
  },
full package.json ```json { "name": "example-cli", "description": "A new CLI generated with oclif", "version": "0.0.0", "author": "Starmania", "bin": { "text-cli": "./bin/run.js" }, "dependencies": { "@oclif/core": "^4", "@oclif/plugin-help": "^6", "@oclif/plugin-plugins": "^5" }, "devDependencies": { "@oclif/prettier-config": "^0.2.1", "@oclif/test": "^4", "@types/chai": "^4", "@types/mocha": "^10", "@types/node": "^18", "chai": "^4", "eslint": "^8", "eslint-config-oclif": "^5", "eslint-config-oclif-typescript": "^3", "eslint-config-prettier": "^9", "mocha": "^10", "oclif": "^4", "shx": "^0.3.3", "ts-node": "^10", "typescript": "^5" }, "engines": { "node": ">=18.0.0" }, "files": [ "/bin", "/dist", "/oclif.manifest.json" ], "license": "MIT", "main": "dist/index.js", "oclif": { "bin": "text-cli", "dirname": "text-cli", "commands": "./dist/commands", "plugins": [ "@oclif/plugin-help", "@oclif/plugin-plugins" ], "topicSeparator": " ", "topics": { "hello": { "description": "Say hello to the world and others" } } }, "scripts": { "build": "shx rm -rf dist && tsc -b", "lint": "eslint . --ext .ts", "postpack": "shx rm -f oclif.manifest.json", "posttest": "npm run lint", "prepack": "oclif manifest && oclif readme", "test": "mocha --forbid-only \"test/**/*.test.ts\"", "version": "oclif readme && git add README.md" }, "types": "dist/index.d.ts" } ```

I'm ok to write a PR for that because I know it's boring stuff

pimterry commented 3 days ago

Unfortunately there are quite a few other breaking changes in that Oclif update that would need handling first to make this possible, but I'm definitely interested in going in that direction though if we can so you're welcome to investigate if you're interested. I've had https://github.com/oclif/oclif/issues/828 for example in my todo list for a long while but I've never found time to look into it properly.

What's the state of this if you build on Windows currently, does it just fail unavoidably?

Starmania commented 2 days ago

The current version of Oclif will refuse to run on windows. And just upgrading these libs is not possible. There are changes to do before that. 3 majors versions is a little bit too much :)

But upgrading to the latest version of oclif/command is possible without any problem. oclif/core is what replace oclif/command, but I didn't try to go further that oclif/command for now

Starmania commented 2 days ago

Ok, it seemes that I was a little bit too exited to see that, indeed, you could build for windows, and get the installer, but you can't "pack"... I will check if this is possible with an environment like MYSYS2 (Cygwin on steroïds). So my PR won't update Oclif version but just provide instructions on how to build on Windows... Arggh