chessdrive 0.0.0-stage → 0.1.0-staging.1

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 CHANGED
@@ -1,3 +1,16 @@
1
- # Temporary Holding Version
1
+ # chessdrive
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The ChessDrive API on the command line: Generate, Embed, Search and Engine, one command each, readable output by
4
+ default and the API's own JSON with `--json`.
5
+
6
+ ```bash
7
+ npm i -g chessdrive
8
+ chessdrive login
9
+ chessdrive engine --fen "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1" --depth 18
10
+ ```
11
+
12
+ `npx chessdrive` runs it without installing. The package holds no code of its own beyond a launcher: npm installs
13
+ the one `@chessdrive/<platform>` package that matches your machine (macOS and Linux on x64 and arm64, Windows on
14
+ x64), which holds the binary, so nothing is downloaded at install. Installing with `--omit=optional` leaves it out.
15
+
16
+ Every command, flag and exit code is in the [CLI docs](https://platform.chessdrive.io/docs/cli).
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ // The `chessdrive` command of the npm package (W2-19), esbuild's pattern: the package lists one package per
3
+ // platform as an optional dependency, each holding that platform's binary from `make cli-release`, and npm
4
+ // installs only the one whose `os` and `cpu` match. This runs it. Nothing is downloaded at install or here.
5
+ 'use strict';
6
+
7
+ const { spawnSync } = require('node:child_process');
8
+ const fs = require('node:fs');
9
+
10
+ const platform = `${process.platform}-${process.arch}`;
11
+ const pkg = `@chessdrive/${platform}`;
12
+ const exe = process.platform === 'win32' ? 'chessdrive.exe' : 'chessdrive';
13
+
14
+ let bin;
15
+ try {
16
+ bin = require.resolve(`${pkg}/bin/${exe}`);
17
+ } catch {
18
+ const builds = Object.keys(require('../package.json').optionalDependencies || {});
19
+ if (builds.includes(pkg)) {
20
+ console.error(`chessdrive: ${pkg}, the build for this machine, isn't installed. npm skips it when optional`);
21
+ console.error('dependencies are left out (--omit=optional, --no-optional): install chessdrive again without that.');
22
+ } else {
23
+ console.error(`chessdrive: there is no build for ${platform}; there are ${builds.map((b) => b.slice(b.indexOf('/') + 1)).join(', ')}.`);
24
+ }
25
+ process.exit(1);
26
+ }
27
+
28
+ // npm keeps the binary's executable bit, but a copy made some other way may not have it.
29
+ if (process.platform !== 'win32') {
30
+ try {
31
+ fs.accessSync(bin, fs.constants.X_OK);
32
+ } catch {
33
+ try {
34
+ fs.chmodSync(bin, 0o755);
35
+ } catch {
36
+ // spawnSync reports it below
37
+ }
38
+ }
39
+ }
40
+
41
+ const run = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
42
+ if (run.error) {
43
+ console.error(`chessdrive: couldn't run ${bin}: ${run.error.message}`);
44
+ process.exit(1);
45
+ }
46
+ // A binary stopped by a signal stops this the same way, so a shell sees what it would without npm.
47
+ if (run.signal) process.kill(process.pid, run.signal);
48
+ process.exit(run.status ?? 1);
package/package.json CHANGED
@@ -1,6 +1,23 @@
1
1
  {
2
2
  "name": "chessdrive",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-staging.1",
4
+ "description": "The ChessDrive API on the command line: Generate, Embed, Search and Engine.",
5
+ "homepage": "https://platform-staging.chessdrive.io/docs/cli",
6
+ "license": "UNLICENSED",
7
+ "bin": {
8
+ "chessdrive": "bin/chessdrive.js"
9
+ },
10
+ "files": [
11
+ "bin"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "optionalDependencies": {
17
+ "@chessdrive/darwin-arm64": "0.1.0-staging.1",
18
+ "@chessdrive/darwin-x64": "0.1.0-staging.1",
19
+ "@chessdrive/linux-arm64": "0.1.0-staging.1",
20
+ "@chessdrive/linux-x64": "0.1.0-staging.1",
21
+ "@chessdrive/win32-x64": "0.1.0-staging.1"
22
+ }
23
+ }