@titanpl/core 2.0.5 → 2.0.6

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.
Files changed (2) hide show
  1. package/configure.js +45 -0
  2. package/package.json +5 -2
package/configure.js ADDED
@@ -0,0 +1,45 @@
1
+ import { readFileSync, existsSync, writeFileSync } from 'fs';
2
+ import { resolve } from 'path';
3
+ import { platform as _platform } from 'os';
4
+ const platform = _platform(); // 'win32', 'linux', 'darwin'
5
+ const titanConfigPath = resolve(__dirname, 'titan.json');
6
+
7
+ console.log(`Configuring titan.json for platform: ${platform}`);
8
+
9
+ try {
10
+ const content = readFileSync(titanConfigPath, 'utf8');
11
+ const titanConfig = JSON.parse(content);
12
+
13
+ let libPath = "";
14
+ if (platform === 'win32') {
15
+ libPath = "native/target/release/titan_core.dll";
16
+ } else if (platform === 'darwin') {
17
+ libPath = "native/target/release/libtitan_core.dylib";
18
+ } else {
19
+ // Assume linux/unix defaults for anything else
20
+ libPath = "native/target/release/libtitan_core.so";
21
+ }
22
+
23
+ const fullPath = resolve(__dirname, libPath);
24
+ if (!existsSync(fullPath)) {
25
+ console.warn(`Warning: Native binary not found at ${fullPath}. Valid binaries for this platform must be built or provided.`);
26
+ }
27
+
28
+ // Check if configuration actually needs changing to avoid unnecessary writes
29
+ if (titanConfig.native && titanConfig.native.path === libPath) {
30
+ console.log(`titan.json is already configured for ${platform}.`);
31
+ process.exit(0);
32
+ }
33
+
34
+ if (!titanConfig.native) {
35
+ titanConfig.native = {};
36
+ }
37
+
38
+ titanConfig.native.path = libPath;
39
+
40
+ writeFileSync(titanConfigPath, JSON.stringify(titanConfig, null, 2));
41
+ console.log(`Successfully updated titan.json native path to: ${libPath}`);
42
+ } catch (error) {
43
+ console.error("Error configuring titan.json:", error);
44
+ process.exit(1);
45
+ }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@titanpl/core",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "The official Core Standard Library for Titan Planet - provides fs, path, crypto, os, net, proc, time, and url modules",
5
5
  "main": "index.js",
6
+ "type": "module",
6
7
  "types": "index.d.ts",
7
8
  "scripts": {
8
9
  "configure": "node configure.js",
@@ -27,6 +28,7 @@
27
28
  "license": "ISC",
28
29
  "files": [
29
30
  "index.js",
31
+ "configure.js",
30
32
  "titan.json",
31
33
  "globals.d.ts",
32
34
  "index.d.ts",
@@ -36,7 +38,8 @@
36
38
  "README.md"
37
39
  ],
38
40
  "engines": {
39
- "node": ">=18.0.0"
41
+ "node": ">=18.0.0",
42
+ "@ezetgalaxy/titan": ">=26.10.2"
40
43
  },
41
44
  "devDependencies": {
42
45
  "esbuild": "^0.27.2"