@openwop/cli 0.1.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/install.sh ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # OpenWOP CLI one-line installer.
4
+ #
5
+ # curl -fsSL https://openwop.dev/install.sh | bash
6
+ #
7
+ # Detects the OS, ensures Node 22+ is present (installs via the platform
8
+ # package manager when missing), installs the @openwop/cli npm package
9
+ # globally, then launches the onboarding wizard. Non-interactive/CI callers
10
+ # can skip onboarding with OPENWOP_INSTALL_NO_ONBOARD=1.
11
+ #
12
+ # Honest about its limits: it never silently "succeeds" — if Node can't be
13
+ # provisioned it prints the manual step and exits non-zero.
14
+ set -euo pipefail
15
+
16
+ REQUIRED_NODE_MAJOR=22
17
+ PKG="${OPENWOP_INSTALL_PKG:-@openwop/cli}"
18
+
19
+ log() { printf '\033[36m▸\033[0m %s\n' "$*"; }
20
+ warn() { printf '\033[33m!\033[0m %s\n' "$*" >&2; }
21
+ die() { printf '\033[31m✗\033[0m %s\n' "$*" >&2; exit 1; }
22
+
23
+ detect_os() {
24
+ case "$(uname -s)" in
25
+ Darwin) echo macos ;;
26
+ Linux) echo linux ;;
27
+ *) echo "$(uname -s)" ;;
28
+ esac
29
+ }
30
+
31
+ node_major() {
32
+ command -v node >/dev/null 2>&1 || { echo 0; return; }
33
+ node -e 'process.stdout.write(String(process.versions.node.split(".")[0]))' 2>/dev/null || echo 0
34
+ }
35
+
36
+ ensure_node() {
37
+ local have; have="$(node_major)"
38
+ if [ "$have" -ge "$REQUIRED_NODE_MAJOR" ]; then
39
+ log "Node $(node --version) detected."
40
+ return
41
+ fi
42
+ warn "Node ${REQUIRED_NODE_MAJOR}+ is required (found: ${have:-none}). Attempting install…"
43
+ local os; os="$(detect_os)"
44
+ if [ "$os" = "macos" ] && command -v brew >/dev/null 2>&1; then
45
+ brew install node
46
+ elif [ "$os" = "linux" ] && command -v apt-get >/dev/null 2>&1; then
47
+ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
48
+ sudo apt-get install -y nodejs
49
+ else
50
+ die "Could not auto-install Node on this system. Install Node ${REQUIRED_NODE_MAJOR}+ from https://nodejs.org and re-run."
51
+ fi
52
+ [ "$(node_major)" -ge "$REQUIRED_NODE_MAJOR" ] || die "Node install did not yield ${REQUIRED_NODE_MAJOR}+. Install manually from https://nodejs.org."
53
+ }
54
+
55
+ main() {
56
+ log "OpenWOP CLI installer ($(detect_os))"
57
+ ensure_node
58
+ command -v npm >/dev/null 2>&1 || die "npm not found on PATH (it ships with Node). Install Node ${REQUIRED_NODE_MAJOR}+ and re-run."
59
+
60
+ log "Installing ${PKG} globally…"
61
+ npm install -g "$PKG"
62
+
63
+ command -v openwop >/dev/null 2>&1 || die "openwop not on PATH after install. Add your npm global bin dir to PATH (npm bin -g)."
64
+ log "Installed: $(openwop --version 2>/dev/null || echo '@openwop/cli')"
65
+
66
+ if [ "${OPENWOP_INSTALL_NO_ONBOARD:-0}" = "1" ]; then
67
+ log "Skipping onboarding (OPENWOP_INSTALL_NO_ONBOARD=1). Run \`openwop onboard\` when ready."
68
+ return
69
+ fi
70
+ log "Launching onboarding…"
71
+ openwop onboard || warn "Onboarding exited early — re-run anytime with \`openwop onboard\`."
72
+ }
73
+
74
+ main "$@"
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@openwop/cli",
3
+ "version": "0.1.0",
4
+ "description": "OpenWOP CLI for operating the workflow-engine demo app and OpenWOP-compatible hosts.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "bin": {
8
+ "openwop": "./dist/openwop.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "install.sh",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "build": "rm -rf dist && esbuild src/openwop.ts src/cli.ts --bundle --platform=node --target=node20 --format=esm --outdir=dist --packages=external --banner:js=\"import { createRequire as _cr } from 'module'; const require = _cr(import.meta.url);\"",
17
+ "typecheck": "tsc --noEmit",
18
+ "test": "npm run build && node --test test/*.test.mjs"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^20.14.0",
22
+ "esbuild": "^0.24.0",
23
+ "typescript": "^5.6.0"
24
+ },
25
+ "peerDependencies": {
26
+ "@whiskeysockets/baileys": ">=6",
27
+ "discord.js": ">=14"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "@whiskeysockets/baileys": { "optional": true },
31
+ "discord.js": { "optional": true }
32
+ },
33
+ "engines": {
34
+ "node": ">=20"
35
+ }
36
+ }