@goodfoot/wiki 0.5.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/bin/wiki ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("child_process");
5
+ const path = require("path");
6
+ const fs = require("fs");
7
+
8
+ const binaryName = process.platform === "win32" ? "wiki.exe" : "wiki";
9
+ const nativePath = path.join(__dirname, "..", "lib", binaryName);
10
+
11
+ if (!fs.existsSync(nativePath)) {
12
+ process.stderr.write(
13
+ "@goodfoot/wiki: Native binary not found.\n" +
14
+ "Try reinstalling: npm install @goodfoot/wiki\n"
15
+ );
16
+ process.exit(1);
17
+ }
18
+
19
+ const result = spawnSync(nativePath, process.argv.slice(2), { stdio: "inherit" });
20
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@goodfoot/wiki",
3
+ "version": "0.5.0",
4
+ "bin": {
5
+ "wiki": "bin/wiki"
6
+ },
7
+ "scripts": {
8
+ "postinstall": "node scripts/postinstall.js",
9
+ "build": "env CARGO_BUILD_JOBS=1 CARGO_TARGET_DIR=target/build cargo build --release",
10
+ "build:clean": "rm -rf target/build target/lint target/test target/typecheck && env CARGO_BUILD_JOBS=1 CARGO_TARGET_DIR=target/build cargo build --release",
11
+ "test": "env CARGO_BUILD_JOBS=1 CARGO_TARGET_DIR=target/test cargo test --quiet -- --test-threads=1",
12
+ "lint": "env CARGO_BUILD_JOBS=1 CARGO_TARGET_DIR=target/lint cargo clippy --quiet -- -D warnings",
13
+ "typecheck": "env CARGO_BUILD_JOBS=1 CARGO_TARGET_DIR=target/typecheck cargo check --quiet"
14
+ },
15
+ "files": [
16
+ "bin/",
17
+ "scripts/postinstall.js"
18
+ ],
19
+ "optionalDependencies": {
20
+ "@goodfoot/wiki-darwin-arm64": "workspace:*",
21
+ "@goodfoot/wiki-darwin-x64": "workspace:*",
22
+ "@goodfoot/wiki-linux-arm64": "workspace:*",
23
+ "@goodfoot/wiki-linux-x64": "workspace:*",
24
+ "@goodfoot/wiki-win32-x64": "workspace:*"
25
+ }
26
+ }
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const PLATFORM_MAP = {
7
+ linux: 'linux',
8
+ darwin: 'darwin',
9
+ win32: 'win32'
10
+ };
11
+
12
+ const ARCH_MAP = {
13
+ x64: 'x64',
14
+ arm64: 'arm64'
15
+ };
16
+
17
+ function main() {
18
+ const platform = PLATFORM_MAP[process.platform];
19
+ const arch = ARCH_MAP[process.arch];
20
+
21
+ if (!platform || !arch) {
22
+ console.log(
23
+ `@goodfoot/wiki: No prebuilt binary available for ${process.platform}-${process.arch}. Build from source with "cargo build --release".`
24
+ );
25
+ process.exit(0);
26
+ }
27
+
28
+ const packageName = `@goodfoot/wiki-${platform}-${arch}`;
29
+ const binaryName = process.platform === 'win32' ? 'wiki.exe' : 'wiki';
30
+
31
+ let packageDir;
32
+ try {
33
+ packageDir = path.dirname(require.resolve(`${packageName}/package.json`));
34
+ } catch {
35
+ // Platform package not installed -- user may have built from source
36
+ console.log(`@goodfoot/wiki: Optional package ${packageName} not found. Skipping binary setup.`);
37
+ process.exit(0);
38
+ }
39
+
40
+ const sourceBinary = path.join(packageDir, 'bin', binaryName);
41
+ if (!fs.existsSync(sourceBinary)) {
42
+ console.log(`@goodfoot/wiki: Binary not found in ${packageName}. The package may not have been published yet.`);
43
+ process.exit(0);
44
+ }
45
+
46
+ const targetDir = path.join(__dirname, '..', 'lib');
47
+ const targetBinary = path.join(targetDir, binaryName);
48
+
49
+ fs.mkdirSync(targetDir, { recursive: true });
50
+
51
+ // Remove existing binary if present
52
+ try {
53
+ fs.unlinkSync(targetBinary);
54
+ } catch {
55
+ // Ignore if it doesn't exist
56
+ }
57
+
58
+ // Try symlink first, fall back to copy
59
+ try {
60
+ fs.symlinkSync(sourceBinary, targetBinary);
61
+ } catch {
62
+ fs.copyFileSync(sourceBinary, targetBinary);
63
+ fs.chmodSync(targetBinary, 0o755);
64
+ }
65
+
66
+ console.log(`@goodfoot/wiki: Installed ${binaryName} from ${packageName}`);
67
+ }
68
+
69
+ main();