@gesslar/toolkit 3.35.0 → 3.35.1

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
@@ -5,7 +5,7 @@
5
5
  "name": "gesslar",
6
6
  "url": "https://gesslar.dev"
7
7
  },
8
- "version": "3.35.0",
8
+ "version": "3.35.1",
9
9
  "license": "Unlicense",
10
10
  "homepage": "https://github.com/gesslar/toolkit#readme",
11
11
  "repository": {
@@ -46,6 +46,7 @@
46
46
  "files": [
47
47
  "src/",
48
48
  "types/",
49
+ "scripts/",
49
50
  "UNLICENSE.txt"
50
51
  ],
51
52
  "engines": {
@@ -0,0 +1,60 @@
1
+ /* -- temporarily turning off
2
+
3
+ import {readFile} from "node:fs/promises"
4
+ import {dirname, join} from "node:path"
5
+ import {fileURLToPath} from "node:url"
6
+
7
+ await(async() => {
8
+ const __dirname = dirname(fileURLToPath(import.meta.url))
9
+ const pkgPath = join(__dirname, "../package.json")
10
+
11
+ try {
12
+ const pkg = JSON.parse(await readFile(pkgPath, "utf-8"))
13
+ const nodeEngine = pkg.engines?.node
14
+
15
+ const versionMatch = nodeEngine?.match(/(?<target>\d+\.\d+\.\d+)$/)
16
+ const {target} = versionMatch?.groups ?? {}
17
+
18
+ if(!target)
19
+ throw new Error(`Could not parse target version from engines.node: "${nodeEngine}"`)
20
+
21
+ const current = process.versions.node
22
+
23
+ const isCompatible = (() => {
24
+ const c = current.split(".").map(Number)
25
+ const t = target.split(".").map(Number)
26
+
27
+ // Major
28
+ if(c[0] > t[0])
29
+ return true
30
+
31
+ if(c[0] < t[0])
32
+ return false
33
+
34
+ // Minor
35
+ if(c[1] > t[1])
36
+ return true
37
+
38
+ if(c[1] < t[1])
39
+ return false
40
+
41
+ // Patch
42
+ if(c[2] < t[2])
43
+ return false
44
+
45
+ return true
46
+ })()
47
+
48
+ if(!isCompatible) {
49
+ console.error(`\x1b[31m%s\x1b[0m`, `✖ Error: @gesslar/toolkit requires Node.js ${nodeEngine}`)
50
+ console.error(`\x1b[90m%s\x1b[0m`, ` Current version: ${current}`)
51
+ process.exit(1)
52
+ }
53
+ } catch(err) {
54
+ console.warn(`\x1b[33m%s\x1b[0m`, `⚠ Compatibility check failed: ${err.message}`)
55
+ // We exit 0 here if we want to allow the install to proceed despite a script error,
56
+ // or exit 1 to be strictly safe.
57
+ process.exit(0)
58
+ }
59
+ })()
60
+ */