omnish 2.1.4 → 2.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnish",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "omnish — allowlisted inbox → your real shell (WhatsApp, Telegram, Discord, Slack, and 20+ channels). No AI.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "files": [
27
27
  "dist",
28
28
  "scripts/check-native-modules.mjs",
29
- "scripts/check-node-version.mjs",
30
- "scripts/node-version.mjs",
29
+ "scripts/check-node-version.cjs",
30
+ "scripts/node-version.cjs",
31
31
  "scripts/fix-node-pty-perms.mjs",
32
32
  "README.md",
33
33
  "CHANGELOG.md",
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "scripts": {
82
82
  "reinstall": "rm -rf node_modules && pnpm install",
83
- "preinstall": "node scripts/check-node-version.mjs",
83
+ "preinstall": "node scripts/check-node-version.cjs",
84
84
  "postinstall": "node scripts/check-native-modules.mjs && node scripts/fix-node-pty-perms.mjs",
85
85
  "build": "node scripts/build-bundle.mjs",
86
86
  "build:doc-index": "node scripts/build-doc-index.mjs",
@@ -2,9 +2,9 @@
2
2
  * Verify native addons load under the current Node ABI (postinstall guard).
3
3
  */
4
4
  import { createRequire } from "node:module";
5
- import { formatNativeModuleNodeHint } from "./node-version.mjs";
6
5
 
7
6
  const require = createRequire(import.meta.url);
7
+ const { formatNativeModuleNodeHint } = require("./node-version.cjs");
8
8
 
9
9
  const modules = ["better-sqlite3", "node-pty", "@parcel/watcher"];
10
10
 
@@ -1,19 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * preinstall guard — block unsupported Node with actionable upgrade steps.
4
+ * CommonJS so this runs on Node 10+ (including ancient distro Node 12).
4
5
  * Skip with OMNISH_SKIP_NODE_CHECK=1 (not recommended).
5
6
  */
6
- import { checkNodeVersion, formatNodeUpgradeHelp } from "./node-version.mjs";
7
+ "use strict";
8
+
9
+ var nodeVersion = require("./node-version.cjs");
7
10
 
8
11
  if (process.env.OMNISH_SKIP_NODE_CHECK === "1") {
9
12
  console.warn("omnish: skipping Node version check (OMNISH_SKIP_NODE_CHECK=1)");
10
13
  process.exit(0);
11
14
  }
12
15
 
13
- const result = checkNodeVersion();
16
+ var result = nodeVersion.checkNodeVersion();
14
17
  if (result.ok) {
15
18
  process.exit(0);
16
19
  }
17
20
 
18
- console.error(formatNodeUpgradeHelp(result));
21
+ console.error(nodeVersion.formatNodeUpgradeHelp(result));
19
22
  process.exit(1);
@@ -1,55 +1,56 @@
1
1
  /**
2
- * Node.js version policy for omnish installs and runtime checks.
3
- * matrix-js-sdk and other deps require Node 22+; package.json engines is the source of truth.
2
+ * Node.js version policy for omnish installs (CommonJS, parseable on Node 10+).
3
+ * Used by preinstall on hosts that may still run distro Node 12/14/16/18.
4
4
  */
5
- import fs from "node:fs";
6
- import os from "node:os";
7
- import path from "node:path";
8
- import { fileURLToPath } from "node:url";
5
+ "use strict";
9
6
 
10
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
- const DEFAULT_ENGINES_NODE = ">=22.13";
12
- const RECOMMENDED_NODE = "22";
7
+ var fs = require("fs");
8
+ var os = require("os");
9
+ var path = require("path");
10
+
11
+ var DEFAULT_ENGINES_NODE = ">=22.13";
12
+ var RECOMMENDED_NODE = "22";
13
13
 
14
14
  function readEnginesNode() {
15
15
  try {
16
- const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
17
- return typeof pkg.engines?.node === "string" ? pkg.engines.node : DEFAULT_ENGINES_NODE;
18
- } catch {
16
+ var pkg = JSON.parse(
17
+ fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8"),
18
+ );
19
+ if (pkg.engines && typeof pkg.engines.node === "string") {
20
+ return pkg.engines.node;
21
+ }
22
+ return DEFAULT_ENGINES_NODE;
23
+ } catch (err) {
19
24
  return DEFAULT_ENGINES_NODE;
20
25
  }
21
26
  }
22
27
 
23
- /** @returns {{ major: number, minor: number, patch: number } | null} */
24
- export function parseSemver(version) {
25
- const raw = String(version).trim().replace(/^v/, "");
26
- const m = /^(\d+)\.(\d+)\.(\d+)/.exec(raw);
28
+ function parseSemver(version) {
29
+ var raw = String(version).trim().replace(/^v/, "");
30
+ var m = /^(\d+)\.(\d+)\.(\d+)/.exec(raw);
27
31
  if (!m) {
28
32
  return null;
29
33
  }
30
34
  return { major: Number(m[1]), minor: Number(m[2]), patch: Number(m[3]) };
31
35
  }
32
36
 
33
- /** @returns {{ op: ">=" | ">" | "<=" | "<" | "=", major: number, minor: number, patch: number } | null} */
34
- export function parseEnginesConstraint(constraint) {
35
- const m = /^(>=|>|<=|<|=)?\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(String(constraint).trim());
37
+ function parseEnginesConstraint(constraint) {
38
+ var m = /^(>=|>|<=|<|=)?\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(
39
+ String(constraint).trim(),
40
+ );
36
41
  if (!m) {
37
42
  return null;
38
43
  }
39
44
  return {
40
- op: /** @type {">=" | ">" | "<=" | "<" | "="} */ (m[1] || ">="),
45
+ op: m[1] || ">=",
41
46
  major: Number(m[2]),
42
47
  minor: m[3] !== undefined ? Number(m[3]) : 0,
43
48
  patch: m[4] !== undefined ? Number(m[4]) : 0,
44
49
  };
45
50
  }
46
51
 
47
- /**
48
- * @param {{ major: number, minor: number, patch: number }} current
49
- * @param {{ op: string, major: number, minor: number, patch: number }} required
50
- */
51
- export function satisfiesEngines(current, required) {
52
- const cmp = (a, b) => {
52
+ function satisfiesEngines(current, required) {
53
+ function cmp(a, b) {
53
54
  if (a.major !== b.major) {
54
55
  return a.major - b.major;
55
56
  }
@@ -57,8 +58,8 @@ export function satisfiesEngines(current, required) {
57
58
  return a.minor - b.minor;
58
59
  }
59
60
  return a.patch - b.patch;
60
- };
61
- const delta = cmp(current, required);
61
+ }
62
+ var delta = cmp(current, required);
62
63
  switch (required.op) {
63
64
  case ">=":
64
65
  return delta >= 0;
@@ -75,13 +76,15 @@ export function satisfiesEngines(current, required) {
75
76
  }
76
77
  }
77
78
 
78
- /**
79
- * @param {string} [nodeVersion] process.version
80
- * @param {string} [enginesNode] package.json engines.node
81
- */
82
- export function checkNodeVersion(nodeVersion = process.version, enginesNode = readEnginesNode()) {
83
- const current = parseSemver(nodeVersion);
84
- const required = parseEnginesConstraint(enginesNode);
79
+ function checkNodeVersion(nodeVersion, enginesNode) {
80
+ if (nodeVersion === undefined) {
81
+ nodeVersion = process.version;
82
+ }
83
+ if (enginesNode === undefined) {
84
+ enginesNode = readEnginesNode();
85
+ }
86
+ var current = parseSemver(nodeVersion);
87
+ var required = parseEnginesConstraint(enginesNode);
85
88
  if (!current || !required) {
86
89
  return {
87
90
  ok: false,
@@ -91,13 +94,22 @@ export function checkNodeVersion(nodeVersion = process.version, enginesNode = re
91
94
  reason: "could not parse Node or engines constraint",
92
95
  };
93
96
  }
94
- const ok = satisfiesEngines(current, required);
97
+ var ok = satisfiesEngines(current, required);
95
98
  return {
96
- ok,
97
- current: `v${current.major}.${current.minor}.${current.patch}`,
99
+ ok: ok,
100
+ current: "v" + current.major + "." + current.minor + "." + current.patch,
98
101
  required: enginesNode,
99
102
  recommended: RECOMMENDED_NODE,
100
- reason: ok ? null : `need Node ${enginesNode}, found v${current.major}.${current.minor}.${current.patch}`,
103
+ reason: ok
104
+ ? null
105
+ : "need Node " +
106
+ enginesNode +
107
+ ", found v" +
108
+ current.major +
109
+ "." +
110
+ current.minor +
111
+ "." +
112
+ current.patch,
101
113
  };
102
114
  }
103
115
 
@@ -108,23 +120,23 @@ function shellComment(platform) {
108
120
  return "#";
109
121
  }
110
122
 
111
- /**
112
- * @param {string} [platform] os.platform()
113
- */
114
- export function formatNodeUpgradeHelp(result, platform = os.platform()) {
115
- const lines = [];
116
- const c = shellComment(platform);
123
+ function formatNodeUpgradeHelp(result, platform) {
124
+ if (platform === undefined) {
125
+ platform = os.platform();
126
+ }
127
+ var lines = [];
128
+ var c = shellComment(platform);
117
129
  lines.push("");
118
130
  lines.push("omnish needs a newer Node.js to install and run.");
119
- lines.push(` Required : Node ${result.required} (see package.json engines)`);
120
- lines.push(` You have : ${result.current}`);
121
- lines.push(` Recommend: Node ${result.recommended} LTS (matches .nvmrc in the repo)`);
131
+ lines.push(" Required : Node " + result.required + " (see package.json engines)");
132
+ lines.push(" You have : " + result.current);
133
+ lines.push(" Recommend: Node " + result.recommended + " (matches .nvmrc in the repo)");
122
134
  lines.push("");
123
135
  lines.push("Why: omnish ships native addons (better-sqlite3, node-pty) and depends on");
124
- lines.push("packages that require Node 22+. Older Node often fails at install or first run.");
136
+ lines.push("packages that require Node 22+. Older Node cannot install or run omnish.");
125
137
  lines.push("");
126
138
  lines.push("Pick one upgrade path, then re-run:");
127
- lines.push(` npm install -g omnish`);
139
+ lines.push(" npm install -g omnish");
128
140
  lines.push("");
129
141
 
130
142
  if (platform === "win32") {
@@ -145,9 +157,11 @@ export function formatNodeUpgradeHelp(result, platform = os.platform()) {
145
157
 
146
158
  if (platform === "darwin") {
147
159
  lines.push("macOS — nvm (install + set default + install omnish):");
148
- lines.push(`${c} install nvm: https://github.com/nvm-sh/nvm#installing-and-updating`);
149
- lines.push(" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash");
150
- lines.push(`${c} restart your shell, then:`);
160
+ lines.push(c + " install nvm: https://github.com/nvm-sh/nvm#installing-and-updating");
161
+ lines.push(
162
+ " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash",
163
+ );
164
+ lines.push(c + " restart your shell, then:");
151
165
  lines.push(" nvm install 22");
152
166
  lines.push(" nvm alias default 22");
153
167
  lines.push(" node -v");
@@ -166,10 +180,18 @@ export function formatNodeUpgradeHelp(result, platform = os.platform()) {
166
180
  return lines.join("\n");
167
181
  }
168
182
 
183
+ lines.push("Linux VPS / server — Debian or Ubuntu (replaces old apt node, e.g. v12):");
184
+ lines.push(" curl -fsSL https://deb.nodesource.com/setup_22.x | bash -");
185
+ lines.push(" apt-get install -y nodejs");
186
+ lines.push(" node -v");
187
+ lines.push(" npm install -g omnish");
188
+ lines.push("");
169
189
  lines.push("Linux — nvm (install + set default + install omnish):");
170
- lines.push(`${c} install nvm: https://github.com/nvm-sh/nvm#installing-and-updating`);
171
- lines.push(" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash");
172
- lines.push(`${c} restart your shell, then:`);
190
+ lines.push(c + " install nvm: https://github.com/nvm-sh/nvm#installing-and-updating");
191
+ lines.push(
192
+ " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash",
193
+ );
194
+ lines.push(c + " restart your shell, then:");
173
195
  lines.push(" nvm install 22");
174
196
  lines.push(" nvm alias default 22");
175
197
  lines.push(" node -v");
@@ -180,8 +202,8 @@ export function formatNodeUpgradeHelp(result, platform = os.platform()) {
180
202
  lines.push(" fnm default 22");
181
203
  lines.push(" npm install -g omnish");
182
204
  lines.push("");
183
- lines.push("Linux — NodeSource / distro packages:");
184
- lines.push(" https://nodejs.org/en/download (pick 22.x Current/LTS)");
205
+ lines.push("Linux — official builds:");
206
+ lines.push(" https://nodejs.org/en/download (pick 22.x)");
185
207
  lines.push("");
186
208
  lines.push("One-liner bootstrap (tries nvm/fnm, then installs omnish):");
187
209
  lines.push(
@@ -190,17 +212,17 @@ export function formatNodeUpgradeHelp(result, platform = os.platform()) {
190
212
  return lines.join("\n");
191
213
  }
192
214
 
193
- /**
194
- * @param {{ current?: string, required?: string, recommended?: string }} [overrides]
195
- */
196
- export function formatNativeModuleNodeHint(overrides = {}) {
197
- const result = checkNodeVersion(overrides.current ?? process.version, overrides.required);
198
- const lines = [
215
+ function formatNativeModuleNodeHint(overrides) {
216
+ overrides = overrides || {};
217
+ var current =
218
+ overrides.current !== undefined ? overrides.current : process.version;
219
+ var result = checkNodeVersion(current, overrides.required);
220
+ var lines = [
199
221
  "",
200
222
  "This often means Node was upgraded/downgraded after omnish was installed, or npm used",
201
223
  "a different Node than your shell default.",
202
224
  "",
203
- `Node now: ${result.current} (required: ${result.required})`,
225
+ "Node now: " + result.current + " (required: " + result.required + ")",
204
226
  "",
205
227
  "Fix:",
206
228
  " 1. Switch to Node 22+ and set it as default (see commands below)",
@@ -210,3 +232,12 @@ export function formatNativeModuleNodeHint(overrides = {}) {
210
232
  ];
211
233
  return lines.join("\n");
212
234
  }
235
+
236
+ module.exports = {
237
+ parseSemver: parseSemver,
238
+ parseEnginesConstraint: parseEnginesConstraint,
239
+ satisfiesEngines: satisfiesEngines,
240
+ checkNodeVersion: checkNodeVersion,
241
+ formatNodeUpgradeHelp: formatNodeUpgradeHelp,
242
+ formatNativeModuleNodeHint: formatNativeModuleNodeHint,
243
+ };