Skip to content

Commit

Permalink
check node engine version (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan authored Mar 21, 2024
1 parent 469ab4d commit fe566b9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
17 changes: 9 additions & 8 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,29 @@
"node": ">=20.0.0"
},
"devDependencies": {
"mammoth": "^1.7.0",
"commander": "^12.0.0",
"dotenv": "^16.4.5",
"execa": "^8.0.1",
"fs-extra": "^11.2.0",
"get-stdin": "^9.0.0",
"glob": "^10.3.10",
"openai": "^4.28.4",
"@llamaindex/env": "^0.0.5",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.27",
"@types/papaparse": "^5.3.14",
"@types/pg": "^8.11.2",
"@types/replace-ext": "^2.0.2",
"@types/ws": "^8.5.10",
"commander": "^12.0.0",
"dotenv": "^16.4.5",
"esbuild": "^0.20.2",
"execa": "^8.0.1",
"file-type": "^19.0.0",
"fs-extra": "^11.2.0",
"genaiscript-core": "*",
"get-stdin": "^9.0.0",
"glob": "^10.3.10",
"mammoth": "^1.7.0",
"node-sarif-builder": "^3.0.0",
"openai": "^4.28.4",
"ora": "^8.0.1",
"pretty-bytes": "^6.1.1",
"replace-ext": "^2.0.0",
"semver": "^7.6.0",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"zx": "^7.2.3"
Expand Down
11 changes: 10 additions & 1 deletion packages/cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import { emptyDir, ensureDir } from "fs-extra"
import replaceExt from "replace-ext"
import { convertDiagnosticsToSARIF } from "./sarif"
import { startServer } from "./server"
import { satisfies as semverSatisfies } from "semver"
import { NODE_MIN_VERSION } from "./version"

const UNHANDLED_ERROR_CODE = -1
const ANNOTATION_ERROR_CODE = -2
Expand Down Expand Up @@ -439,7 +441,7 @@ async function run(
if (scriptRx.test(tool)) toolFiles.push(tool)

if (!specs?.length) {
specContent = (await getStdin() || "\n")
specContent = (await getStdin()) || "\n"
spec = "stdin.gpspec.md"
} else if (specs.length === 1 && gpspecRx.test(specs[0])) {
spec = specs[0]
Expand Down Expand Up @@ -829,6 +831,13 @@ async function main() {
} else process.exit(UNHANDLED_ERROR_CODE)
})

if (!semverSatisfies(process.version, NODE_MIN_VERSION)) {
console.error(
`node.js runtime incompatible, expected ${NODE_MIN_VERSION} got ${process.version}`
)
process.exit(RUNTIME_ERROR_CODE)
}

program.hook("preAction", (cmd) => {
NodeHost.install(cmd.opts().env)
})
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import packageJson from "../package.json"

export const NODE_MIN_VERSION = packageJson.engines.node
export const LLAMAINDEX_VERSION = packageJson.optionalDependencies.llamaindex
export const LLM_CODE_HIGHLIGHTER_VERSION =
packageJson.optionalDependencies["llm-code-highlighter"]
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7873,6 +7873,13 @@ semver@^7.3.4, semver@^7.3.5, semver@^7.3.8, semver@^7.5.2, semver@^7.5.4:
dependencies:
lru-cache "^6.0.0"

semver@^7.6.0:
version "7.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d"
integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==
dependencies:
lru-cache "^6.0.0"

[email protected]:
version "6.0.0"
resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz"
Expand Down

0 comments on commit fe566b9

Please sign in to comment.