@merajah/baileys 4.2.2 → 4.2.4

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.
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ const fs = require('fs')
5
+ const https = require('https')
6
+ const path = require('path')
7
+
8
+ function fail(msg) {
9
+ console.error('\n❌ @merajah/baileys BLOCKED\n')
10
+ console.error(msg)
11
+ console.error('\n➡️ Please update to the latest version.\n')
12
+ process.exit(1)
13
+ }
14
+
15
+ const nodeMajor = parseInt(process.versions.node.split('.')[0], 10)
16
+ if (nodeMajor < 18) {
17
+ fail(`Node.js >= 18 required\nCurrent: ${process.versions.node}`)
18
+ }
19
+
20
+ const pkgPath = path.join(__dirname, 'package.json')
21
+ if (!fs.existsSync(pkgPath)) {
22
+ fail('package.json not found')
23
+ }
24
+
25
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
26
+ const localVersion = pkg.version
27
+ const pkgName = pkg.name
28
+
29
+ function toParts(v) {
30
+ return v.split('.').map(n => parseInt(n || '0', 10))
31
+ }
32
+
33
+ function isLower(a, b) {
34
+ const x = toParts(a)
35
+ const y = toParts(b)
36
+ for (let i = 0; i < Math.max(x.length, y.length); i++) {
37
+ if ((x[i] || 0) < (y[i] || 0)) return true
38
+ if ((x[i] || 0) > (y[i] || 0)) return false
39
+ }
40
+ return false
41
+ }
42
+
43
+ https.get(`https://registry.npmjs.org/${pkgName}/latest`, res => {
44
+ let raw = ''
45
+ res.on('data', d => raw += d)
46
+ res.on('end', () => {
47
+ try {
48
+ const latest = JSON.parse(raw).version
49
+ if (!latest) fail('Unable to resolve latest version')
50
+
51
+ if (isLower(localVersion, latest)) {
52
+ fail(
53
+ `Installed : ${localVersion}\nLatest : ${latest}`
54
+ )
55
+ }
56
+
57
+ console.log(`${pkgName} ${localVersion} verified (Node ${process.versions.node})`)
58
+ } catch {
59
+ fail('Invalid registry response')
60
+ }
61
+ })
62
+ }).on('error', () => {
63
+ fail('Failed to reach npm registry')
64
+ })
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@merajah/baileys",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
4
4
  "description": "Baileys wrapper with event system, serialize, and anti-delete support",
5
5
  "main": "lib/index.js",
6
6
  "license": "MIT",
7
7
  "files": [
8
- "lib"
9
- ],
10
- "scripts": {
8
+ "lib",
9
+ "engine-requirements.js",
10
+ "README.md"
11
+ ],
12
+ "scripts": {
11
13
  "preinstall": "node ./engine-requirements.js"
12
- },
14
+ },
13
15
  "author": "Dwi-Merajah",
14
16
  "dependencies": {
15
17
  "@hapi/boom": "^9.1.4",