openmemo 0.2.1 → 0.2.3
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/openmemo +7 -31
- package/bin/postinstall.mjs +67 -34
- package/package.json +1 -7
package/bin/openmemo
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
set -e
|
|
3
3
|
|
|
4
|
-
# Get the directory where this script is located
|
|
5
4
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
6
|
-
PKG_DIR="$(dirname "$SCRIPT_DIR")"
|
|
7
5
|
|
|
8
|
-
# Detect platform
|
|
9
6
|
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
10
7
|
ARCH="$(uname -m)"
|
|
11
8
|
|
|
@@ -20,36 +17,15 @@ case "$ARCH" in
|
|
|
20
17
|
arm64|aarch64) ARCH="arm64" ;;
|
|
21
18
|
esac
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
BIN_NAME="openmemo-${OS}-${ARCH}"
|
|
21
|
+
[ "$OS" = "windows" ] && BIN_NAME="${BIN_NAME}.exe"
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
# Path 1: Global install - binary package is a sibling in node_modules
|
|
28
|
-
GLOBAL_BIN="$PKG_DIR/../$BIN_PKG/openmemo-${PLATFORM}"
|
|
23
|
+
BIN_PATH="$SCRIPT_DIR/$BIN_NAME"
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# Windows executable paths
|
|
34
|
-
GLOBAL_BIN_EXE="$PKG_DIR/../$BIN_PKG/openmemo-${PLATFORM}.exe"
|
|
35
|
-
LOCAL_BIN_EXE="$PKG_DIR/node_modules/$BIN_PKG/openmemo-${PLATFORM}.exe"
|
|
36
|
-
|
|
37
|
-
# Try each path
|
|
38
|
-
if [ -x "$GLOBAL_BIN" ]; then
|
|
39
|
-
exec "$GLOBAL_BIN" "$@"
|
|
40
|
-
elif [ -x "$LOCAL_BIN" ]; then
|
|
41
|
-
exec "$LOCAL_BIN" "$@"
|
|
42
|
-
elif [ -x "$GLOBAL_BIN_EXE" ]; then
|
|
43
|
-
exec "$GLOBAL_BIN_EXE" "$@"
|
|
44
|
-
elif [ -x "$LOCAL_BIN_EXE" ]; then
|
|
45
|
-
exec "$LOCAL_BIN_EXE" "$@"
|
|
25
|
+
if [ -x "$BIN_PATH" ]; then
|
|
26
|
+
exec "$BIN_PATH" "$@"
|
|
46
27
|
else
|
|
47
|
-
echo "Error:
|
|
48
|
-
echo ""
|
|
49
|
-
echo "Searched paths:"
|
|
50
|
-
echo " - $GLOBAL_BIN"
|
|
51
|
-
echo " - $LOCAL_BIN"
|
|
52
|
-
echo ""
|
|
53
|
-
echo "Please reinstall: npm install -g openmemo"
|
|
28
|
+
echo "Error: Binary not found at $BIN_PATH"
|
|
29
|
+
echo "Try reinstalling: npm install -g openmemo"
|
|
54
30
|
exit 1
|
|
55
31
|
fi
|
package/bin/postinstall.mjs
CHANGED
|
@@ -1,43 +1,76 @@
|
|
|
1
|
-
import { platform, arch } from "os"
|
|
2
|
-
import { existsSync } from "fs"
|
|
3
|
-
import { dirname, join } from "path"
|
|
4
|
-
import { fileURLToPath } from "url"
|
|
1
|
+
import { platform, arch } from "os"
|
|
2
|
+
import { existsSync, createWriteStream, chmodSync } from "fs"
|
|
3
|
+
import { dirname, join } from "path"
|
|
4
|
+
import { fileURLToPath } from "url"
|
|
5
|
+
import { createRequire } from "module"
|
|
6
|
+
import https from "https"
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
// Skip during CI builds
|
|
9
|
+
if (process.env.CI) {
|
|
10
|
+
console.log("[openmemo] Skipping binary download in CI environment")
|
|
11
|
+
process.exit(0)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const require = createRequire(import.meta.url)
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
16
|
+
const pkg = require("../package.json")
|
|
7
17
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
linux: "linux",
|
|
11
|
-
win32: "windows",
|
|
12
|
-
};
|
|
18
|
+
const REPO = "arkjun/openmemo"
|
|
19
|
+
const VERSION = pkg.version
|
|
13
20
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
arm64: "arm64",
|
|
17
|
-
};
|
|
21
|
+
const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" }
|
|
22
|
+
const archMap = { x64: "x64", arm64: "arm64" }
|
|
18
23
|
|
|
19
|
-
const os = platformMap[platform()]
|
|
20
|
-
const cpu = archMap[arch()]
|
|
24
|
+
const os = platformMap[platform()]
|
|
25
|
+
const cpu = archMap[arch()]
|
|
21
26
|
|
|
22
27
|
if (!os || !cpu) {
|
|
23
|
-
console.warn(`[openmemo] Unsupported platform: ${platform()}-${arch()}`)
|
|
24
|
-
process.exit(0)
|
|
28
|
+
console.warn(`[openmemo] Unsupported platform: ${platform()}-${arch()}`)
|
|
29
|
+
process.exit(0)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const binaryName = `openmemo-${os}-${cpu}${os === "windows" ? ".exe" : ""}`
|
|
33
|
+
const binaryPath = join(__dirname, binaryName)
|
|
34
|
+
|
|
35
|
+
// Skip if already exists
|
|
36
|
+
if (existsSync(binaryPath)) {
|
|
37
|
+
console.log(`[openmemo] Binary already exists`)
|
|
38
|
+
process.exit(0)
|
|
25
39
|
}
|
|
26
40
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${binaryName}`
|
|
42
|
+
|
|
43
|
+
console.log(`[openmemo] Downloading binary for ${os}-${cpu}...`)
|
|
44
|
+
|
|
45
|
+
function download(url, dest) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const request = (url) => {
|
|
48
|
+
https.get(url, (res) => {
|
|
49
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
50
|
+
request(res.headers.location)
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
if (res.statusCode !== 200) {
|
|
54
|
+
reject(new Error(`Download failed: ${res.statusCode}`))
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
const file = createWriteStream(dest)
|
|
58
|
+
res.pipe(file)
|
|
59
|
+
file.on("finish", () => {
|
|
60
|
+
file.close()
|
|
61
|
+
chmodSync(dest, 0o755)
|
|
62
|
+
resolve()
|
|
63
|
+
})
|
|
64
|
+
}).on("error", reject)
|
|
65
|
+
}
|
|
66
|
+
request(url)
|
|
67
|
+
})
|
|
43
68
|
}
|
|
69
|
+
|
|
70
|
+
download(url, binaryPath)
|
|
71
|
+
.then(() => console.log(`[openmemo] Binary installed successfully`))
|
|
72
|
+
.catch((err) => {
|
|
73
|
+
console.error(`[openmemo] Failed to download binary: ${err.message}`)
|
|
74
|
+
console.error(`[openmemo] URL: ${url}`)
|
|
75
|
+
process.exit(1)
|
|
76
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openmemo",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "OpenTUI-based memo app inspired by mattn/memo",
|
|
5
5
|
"bin": {
|
|
6
6
|
"openmemo": "bin/openmemo"
|
|
@@ -32,11 +32,5 @@
|
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"postinstall": "node bin/postinstall.mjs"
|
|
35
|
-
},
|
|
36
|
-
"optionalDependencies": {
|
|
37
|
-
"openmemo-darwin-arm64": "0.2.1",
|
|
38
|
-
"openmemo-linux-x64": "0.2.1",
|
|
39
|
-
"openmemo-linux-arm64": "0.2.1",
|
|
40
|
-
"openmemo-windows-x64": "0.2.1"
|
|
41
35
|
}
|
|
42
36
|
}
|