openplanet-lsp 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # openplanet-lsp
2
+
3
+ Language Server Protocol implementation for OpenPlanet AngelScript.
4
+
5
+ This npm package installs a small Node launcher plus an optional
6
+ platform-specific native binary (`openplanet-lsp-*`).
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install -g openplanet-lsp
12
+ # or project-local:
13
+ npm install --save-dev openplanet-lsp
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```bash
19
+ openplanet-lsp # stdio LSP server
20
+ openplanet-lsp --version
21
+ openplanet-lsp check <path>
22
+ ```
23
+
24
+ ## Supported platforms
25
+
26
+ | Platform package | OS | Arch |
27
+ |----------------------------------|---------|-------|
28
+ | `openplanet-lsp-linux-x64` | Linux | x64 |
29
+ | `openplanet-lsp-linux-arm64` | Linux | arm64 |
30
+ | `openplanet-lsp-darwin-x64` | macOS | x64 |
31
+ | `openplanet-lsp-darwin-arm64` | macOS | arm64 |
32
+ | `openplanet-lsp-win32-x64` | Windows | x64 |
33
+ | `openplanet-lsp-win32-arm64` | Windows | arm64 |
34
+
35
+ GitHub release archives (same binaries) are also published at:
36
+ https://github.com/clankercode/lsp-openplanet/releases
37
+
38
+ ## Programmatic
39
+
40
+ ```js
41
+ const { resolveBinaryPath } = require("openplanet-lsp");
42
+ console.log(resolveBinaryPath());
43
+ ```
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("child_process");
5
+ const { resolveBinaryPath } = require("../lib/platform");
6
+
7
+ let bin;
8
+ try {
9
+ bin = resolveBinaryPath();
10
+ } catch (err) {
11
+ console.error(err.message || err);
12
+ process.exit(1);
13
+ }
14
+
15
+ const result = spawnSync(bin, process.argv.slice(2), {
16
+ stdio: "inherit",
17
+ windowsHide: false,
18
+ });
19
+
20
+ if (result.error) {
21
+ console.error(result.error.message || result.error);
22
+ process.exit(1);
23
+ }
24
+
25
+ process.exit(result.status === null ? 1 : result.status);
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ // Soft postinstall check — optionalDependencies may legitimately be missing
4
+ // when npm installs on an unsupported host (e.g. building a container image
5
+ // for another arch). Only warn; the bin wrapper hard-fails at runtime.
6
+ const { platformInfo } = require("./platform");
7
+
8
+ const info = platformInfo();
9
+ if (!info.package) {
10
+ console.warn(
11
+ `[openplanet-lsp] warning: no prebuilt binary for ${info.key}. ` +
12
+ `The 'openplanet-lsp' command will fail until you install a matching ` +
13
+ `platform package or use a GitHub release binary.`
14
+ );
15
+ process.exit(0);
16
+ }
17
+
18
+ try {
19
+ require.resolve(`${info.package}/package.json`);
20
+ } catch {
21
+ console.warn(
22
+ `[openplanet-lsp] warning: optional platform package '${info.package}' ` +
23
+ `did not install. The CLI may be unavailable on this machine.`
24
+ );
25
+ }
package/lib/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ const { resolveBinaryPath, platformInfo, PLATFORMS } = require("./platform");
4
+
5
+ module.exports = {
6
+ resolveBinaryPath,
7
+ platformInfo,
8
+ PLATFORMS,
9
+ };
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Map Node's process.platform + process.arch to an optional platform package.
5
+ * Keep in sync with .github/workflows/release.yml matrix `npm_pkg` values.
6
+ */
7
+ const PLATFORMS = {
8
+ "darwin-arm64": {
9
+ package: "openplanet-lsp-darwin-arm64",
10
+ binary: "openplanet-lsp",
11
+ },
12
+ "darwin-x64": {
13
+ package: "openplanet-lsp-darwin-x64",
14
+ binary: "openplanet-lsp",
15
+ },
16
+ "linux-arm64": {
17
+ package: "openplanet-lsp-linux-arm64",
18
+ binary: "openplanet-lsp",
19
+ },
20
+ "linux-x64": {
21
+ package: "openplanet-lsp-linux-x64",
22
+ binary: "openplanet-lsp",
23
+ },
24
+ "win32-arm64": {
25
+ package: "openplanet-lsp-win32-arm64",
26
+ binary: "openplanet-lsp.exe",
27
+ },
28
+ "win32-x64": {
29
+ package: "openplanet-lsp-win32-x64",
30
+ binary: "openplanet-lsp.exe",
31
+ },
32
+ };
33
+
34
+ function platformKey(platform = process.platform, arch = process.arch) {
35
+ return `${platform}-${arch}`;
36
+ }
37
+
38
+ function platformInfo(platform = process.platform, arch = process.arch) {
39
+ const key = platformKey(platform, arch);
40
+ return { key, ...(PLATFORMS[key] || {}) };
41
+ }
42
+
43
+ /**
44
+ * Resolve the absolute path to the platform binary, or throw a helpful error.
45
+ */
46
+ function resolveBinaryPath(opts = {}) {
47
+ const { key, package: pkgName, binary } = platformInfo(opts.platform, opts.arch);
48
+ if (!pkgName) {
49
+ const supported = Object.keys(PLATFORMS).join(", ");
50
+ throw new Error(
51
+ `openplanet-lsp: unsupported platform '${key}'. Supported: ${supported}`
52
+ );
53
+ }
54
+
55
+ let pkgRoot;
56
+ try {
57
+ pkgRoot = require.resolve(`${pkgName}/package.json`);
58
+ } catch (err) {
59
+ throw new Error(
60
+ `openplanet-lsp: platform package '${pkgName}' is not installed.\n` +
61
+ `This usually means optionalDependencies failed (offline install, ` +
62
+ `registry mirror, or unsupported libc). Try:\n` +
63
+ ` npm install ${pkgName}@${require("../package.json").version}\n` +
64
+ `Or download a release binary from:\n` +
65
+ ` https://github.com/clankercode/lsp-openplanet/releases`
66
+ );
67
+ }
68
+
69
+ const path = require("path");
70
+ const fs = require("fs");
71
+ const binPath = path.join(path.dirname(pkgRoot), "bin", binary);
72
+ if (!fs.existsSync(binPath)) {
73
+ throw new Error(
74
+ `openplanet-lsp: binary missing in ${pkgName}: expected ${binPath}`
75
+ );
76
+ }
77
+ return binPath;
78
+ }
79
+
80
+ module.exports = {
81
+ PLATFORMS,
82
+ platformKey,
83
+ platformInfo,
84
+ resolveBinaryPath,
85
+ };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "openplanet-lsp",
3
+ "version": "0.2.0",
4
+ "description": "Language Server Protocol implementation for OpenPlanet AngelScript",
5
+ "keywords": [
6
+ "openplanet",
7
+ "angelscript",
8
+ "lsp",
9
+ "language-server",
10
+ "trackmania"
11
+ ],
12
+ "homepage": "https://github.com/clankercode/lsp-openplanet",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/clankercode/lsp-openplanet.git",
16
+ "directory": "npm/openplanet-lsp"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/clankercode/lsp-openplanet/issues"
20
+ },
21
+ "license": "MIT",
22
+ "author": "clankercode",
23
+ "type": "commonjs",
24
+ "bin": {
25
+ "openplanet-lsp": "bin/openplanet-lsp.js"
26
+ },
27
+ "main": "lib/index.js",
28
+ "files": [
29
+ "bin",
30
+ "lib",
31
+ "README.md"
32
+ ],
33
+ "engines": {
34
+ "node": ">=18"
35
+ },
36
+ "scripts": {
37
+ "postinstall": "node ./lib/check-platform.js"
38
+ },
39
+ "optionalDependencies": {
40
+ "openplanet-lsp-darwin-arm64": "0.2.0",
41
+ "openplanet-lsp-darwin-x64": "0.2.0",
42
+ "openplanet-lsp-linux-arm64": "0.2.0",
43
+ "openplanet-lsp-linux-x64": "0.2.0",
44
+ "openplanet-lsp-win32-arm64": "0.2.0",
45
+ "openplanet-lsp-win32-x64": "0.2.0"
46
+ }
47
+ }