From bae95446817c515a5deeb5188a985942e6ebc2c7 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Fri, 16 Feb 2024 02:29:48 +1100 Subject: [PATCH] Fix dependency issue --- adapter-iron-harvest/package-lock.json | 152 ++------------------ adapter-iron-harvest/package.json | 1 - adapter-iron-harvest/src/core/algorithms.ts | 21 --- adapter-iron-harvest/src/core/maps.ts | 3 +- adapter-iron-harvest/src/core/scenario.ts | 79 ---------- adapter-iron-harvest/src/helpers/exec.ts | 33 ----- adapter-iron-harvest/tests/exec.test.ts | 22 --- adapter-warthog-websocket/package-lock.json | 10 +- adapter-warthog-websocket/package.json | 2 +- 9 files changed, 17 insertions(+), 306 deletions(-) delete mode 100644 adapter-iron-harvest/src/core/algorithms.ts delete mode 100644 adapter-iron-harvest/src/core/scenario.ts delete mode 100644 adapter-iron-harvest/src/helpers/exec.ts delete mode 100644 adapter-iron-harvest/tests/exec.test.ts diff --git a/adapter-iron-harvest/package-lock.json b/adapter-iron-harvest/package-lock.json index a84b9e11..b37c583e 100644 --- a/adapter-iron-harvest/package-lock.json +++ b/adapter-iron-harvest/package-lock.json @@ -1,12 +1,12 @@ { - "name": "iron-harvest-map-server", - "version": "1.0.0", + "name": "adapter-iron-harvest", + "version": "1.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "iron-harvest-map-server", - "version": "1.0.0", + "name": "adapter-iron-harvest", + "version": "1.0.5", "license": "ISC", "dependencies": { "boxen": "^7.1.1", @@ -20,12 +20,10 @@ "lru-cache": "^6.0.0", "md5": "^2.3.0", "node-emoji": "^2.1.0", - "pathfinding-binaries": "github:path-visualiser/pathfinding#binaries", "protocol": "file:../protocol", "socket.io": "^4.1.3", "socket.io-client": "^4.1.3", "tempy": "^1.0.1", - "ts-node": "^10.4.0", "typescript": "^4.4.4", "yaml": "^2.3.1", "zod": "^3.21.4" @@ -45,7 +43,7 @@ } }, "../protocol": { - "version": "1.0.0", + "version": "1.0.5", "license": "ISC" }, "node_modules/@babel/generator": { @@ -106,26 +104,6 @@ "node": ">=6.9.0" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@esbuild/android-arm": { "version": "0.18.17", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.17.tgz", @@ -496,6 +474,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, "engines": { "node": ">=6.0.0" } @@ -512,7 +491,8 @@ "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.14", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.18", @@ -572,26 +552,6 @@ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" }, - "node_modules/@tsconfig/node10": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", - "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", - "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==" - }, "node_modules/@types/body-parser": { "version": "1.19.2", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", @@ -835,6 +795,7 @@ "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "dev": true, "bin": { "acorn": "bin/acorn" }, @@ -933,11 +894,6 @@ "node": ">= 8" } }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==" - }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -1505,11 +1461,6 @@ "node": ">= 0.10" } }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==" - }, "node_modules/crypt": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", @@ -1617,14 +1568,6 @@ "node": ">=8" } }, - "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -2502,11 +2445,6 @@ "node": ">=10" } }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" - }, "node_modules/md5": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", @@ -2968,15 +2906,6 @@ "integrity": "sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==", "dev": true }, - "node_modules/pathfinding-binaries": { - "version": "1.0.1", - "resolved": "git+ssh://git@github.com/path-visualiser/pathfinding.git#623b93a9748577ac14b23a08881fe2385e4f4725", - "hasInstallScript": true, - "license": "ISC", - "dependencies": { - "typescript": "^4.4.3" - } - }, "node_modules/pathval": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", @@ -4085,56 +4014,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, - "node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/ts-node/node_modules/acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/tsconfck": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/tsconfck/-/tsconfck-2.1.2.tgz", @@ -4273,11 +4152,6 @@ "node": ">= 0.4.0" } }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==" - }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -4732,14 +4606,6 @@ "node": ">=10" } }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "engines": { - "node": ">=6" - } - }, "node_modules/yocto-queue": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", diff --git a/adapter-iron-harvest/package.json b/adapter-iron-harvest/package.json index 6aeafd7c..99b3bc23 100644 --- a/adapter-iron-harvest/package.json +++ b/adapter-iron-harvest/package.json @@ -23,7 +23,6 @@ "lru-cache": "^6.0.0", "md5": "^2.3.0", "node-emoji": "^2.1.0", - "pathfinding-binaries": "github:path-visualiser/pathfinding#binaries", "protocol": "file:../protocol", "socket.io": "^4.1.3", "socket.io-client": "^4.1.3", diff --git a/adapter-iron-harvest/src/core/algorithms.ts b/adapter-iron-harvest/src/core/algorithms.ts deleted file mode 100644 index 9c001653..00000000 --- a/adapter-iron-harvest/src/core/algorithms.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { mapValues, startCase } from "lodash"; - -export const algorithms = mapValues( - { - dijkstra: { name: "Dijkstra" }, - cbs_ll: { name: "Conflict-based Search" }, - cbs_ll_w: { name: undefined }, - astar: { name: "A* Search" }, - astar_wgm: { name: undefined }, - astar4c: { name: undefined }, - sssp: { name: "Single Source Shortest Path" }, - sipp: { name: undefined }, - jps: { name: "Jump Point Search" }, - jps2: { name: "Jump Point Search 2" }, - "jps2+": { name: "Jump Point Search 2+" }, - jps4c: { name: undefined }, - gdfs: { name: undefined }, - dfs: { name: "Depth-first Search" }, - }, - ({ name }, k) => ({ name: name ?? startCase(k) }) -); diff --git a/adapter-iron-harvest/src/core/maps.ts b/adapter-iron-harvest/src/core/maps.ts index 5b59c6c8..08ad0fbc 100644 --- a/adapter-iron-harvest/src/core/maps.ts +++ b/adapter-iron-harvest/src/core/maps.ts @@ -1,8 +1,9 @@ import { keys, some, startCase } from "lodash"; import { parse, relative, resolve } from "path"; -import { handlers } from "./scenario"; import { getConfig } from "../config"; +const handlers = { grid: undefined }; + export type MapTypeKey = keyof typeof handlers; export function mapIsSupported(path: string) { diff --git a/adapter-iron-harvest/src/core/scenario.ts b/adapter-iron-harvest/src/core/scenario.ts deleted file mode 100644 index 3b12dc74..00000000 --- a/adapter-iron-harvest/src/core/scenario.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { - constant, - Dictionary, - first, - floor, - join, - last, - map, - split, -} from "lodash"; -import { roadhog, warthog } from "pathfinding-binaries"; -import { ParamsOf } from "protocol/Message"; -import { PathfindingTask } from "protocol/SolveTask"; -import { exec } from "../helpers/exec"; - -type Params = Omit< - ParamsOf, - "algorithm" | "format" | "mapURI" ->; - -export function grid(m: string, { instances }: Params) { - const [, h, w] = split(m, "\n"); - const [width, height] = map([w, h], (d) => +last(split(d, " "))!); - return (path: string) => - join( - [ - "version 1", - ...map(instances, ({ start, end }) => - join( - [ - 0, - path, - width, - height, - start! % width, - floor(start! / width), - end! % width, - floor(end! / width), - 0, - ], - " " - ) - ), - ], - "\n" - ); -} - -export const handlers = { - grid: { - create: grid, - invoke: (alg, scen) => - exec(warthog, { args: { alg, scen }, flags: ["verbose"] }, true), - }, - xy: { - create: (_, { instances }) => { - const instance = first(instances); - if (instance) { - const { start = 0, end = 0 } = instance; - return constant(`p aux sp p2p 1\nq ${start + 1} ${end + 1}\n`); - } - }, - invoke: (alg, scen, m) => - exec( - roadhog, - { args: { alg, problem: scen, input: m }, flags: ["verbose"] }, - true - ), - }, -} as Dictionary; - -type Handler = { - create: (m: string, params: Params) => (path: string) => string; - invoke: ( - alg: string, - scenarioPath: string, - mapPath: string - ) => Promise; -}; diff --git a/adapter-iron-harvest/src/helpers/exec.ts b/adapter-iron-harvest/src/helpers/exec.ts deleted file mode 100644 index 273831e5..00000000 --- a/adapter-iron-harvest/src/helpers/exec.ts +++ /dev/null @@ -1,33 +0,0 @@ -import execSh from "exec-sh"; -import { entries, join, trim } from "lodash"; - -const sh = execSh.promise; - -export class ExecError extends Error {} - -type Param = string | number | boolean; - -type Options = { - params?: Param[]; - args?: { [K: string]: Param }; - flags?: string[]; -}; - -export async function exec( - path: string, - { params = [], args = {}, flags = [] }: Options = {}, - errorsAsOutput?: boolean -) { - const command = [ - path, - ...entries(args).map(([k, v]) => `--${k} ${v}`), - ...flags.map((s) => `--${s}`), - ...params, - ]; - const { stdout, stderr } = await sh(command.join(" "), true); - if (!stderr) { - return trim(stdout); - } else if (errorsAsOutput) { - return trim(join([stderr, stdout], "\n")); - } else throw new ExecError(stderr); -} diff --git a/adapter-iron-harvest/tests/exec.test.ts b/adapter-iron-harvest/tests/exec.test.ts deleted file mode 100644 index 77564d91..00000000 --- a/adapter-iron-harvest/tests/exec.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { warthog } from "pathfinding-binaries"; -import { exec } from "../src/helpers/exec"; -import { describe, it, expect } from "vitest"; - -describe("exec", () => { - it("returns hello", async () => { - const output = await exec("echo", { params: ["hello"] }); - expect(output).toEqual("hello"); - }); - - it("runs node with flags", async () => { - const output = await exec("node", { - args: { eval: '"console.log(1+1)"' }, - }); - expect(output).toEqual("2"); - }); - - it("runs the warthog solver", async () => { - const output = await exec(warthog, { flags: ["help"] }, true); - expect(output.startsWith("==> manual <==")).toBeTruthy(); - }); -}); diff --git a/adapter-warthog-websocket/package-lock.json b/adapter-warthog-websocket/package-lock.json index 82025e3a..fb8747ee 100644 --- a/adapter-warthog-websocket/package-lock.json +++ b/adapter-warthog-websocket/package-lock.json @@ -1,12 +1,12 @@ { - "name": "warthog-websocket", - "version": "1.0.0", + "name": "adapter-warthog-websocket", + "version": "1.0.5", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "warthog-websocket", - "version": "1.0.0", + "name": "adapter-warthog-websocket", + "version": "1.0.5", "license": "ISC", "dependencies": { "boxen": "^7.1.1", @@ -66,7 +66,7 @@ } }, "../protocol": { - "version": "1.0.0", + "version": "1.0.5", "license": "ISC" }, "node_modules/@esbuild/android-arm": { diff --git a/adapter-warthog-websocket/package.json b/adapter-warthog-websocket/package.json index f2b750be..97bca980 100644 --- a/adapter-warthog-websocket/package.json +++ b/adapter-warthog-websocket/package.json @@ -21,7 +21,7 @@ "lru-cache": "^6.0.0", "md5": "^2.3.0", "node-emoji": "^2.1.0", - "pathfinding-binaries": "github:path-visualiser/pathfinding#binaries", + "pathfinding-binaries": "github:path-visualiser/warthog#binaries", "protocol": "file:../protocol", "socket.io": "^4.1.3", "socket.io-client": "^4.1.3",