@chrisivey01/builder 1.0.3 → 1.0.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.
Files changed (3) hide show
  1. package/index.d.ts +0 -18
  2. package/index.js +21 -1
  3. package/package.json +1 -4
package/index.d.ts CHANGED
@@ -1,21 +1,3 @@
1
- /**
2
- * @typedef {Object} BuildConfig
3
- * @property {'browser' | 'node' | 'neutral'} [platform] - The platform target
4
- * @property {string | string[]} [target] - The target ES version
5
- * @property {'iife' | 'cjs' | 'esm'} [format] - The output format
6
- */
7
- /**
8
- * @typedef {Object} BuilderOptions
9
- * @property {string} [cwd] - Current working directory. Defaults to process.cwd()
10
- * @property {string} [resourceName] - Name of the resource. Defaults to the basename of the cwd
11
- * @property {string[]} [args] - Command line arguments. Defaults to process.argv.slice(2)
12
- * @property {string} [restartEndpoint] - Endpoint for restarting the resource. Defaults to 'http://127.0.0.1:4689/rr'
13
- * @property {number} [restartTimeout] - Timeout for restart requests in milliseconds. Defaults to 2000
14
- * @property {number} [debounceDelay] - Debounce delay for rebuilds in milliseconds. Defaults to 500
15
- * @property {number} [webDevPort] - Port for web dev server. Defaults to 5173
16
- * @property {Record<string, BuildConfig>} [builds] - Build configurations for different targets
17
- * @property {Record<string, string>} [define] - Additional esbuild define values
18
- */
19
1
  /**
20
2
  * Build a FiveM/RedM resource with optional watch mode
21
3
  * @param {BuilderOptions} [options] - Build configuration options
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import esbuild from 'esbuild';
2
2
  import { execSync, spawn } from 'node:child_process';
3
3
  import fs from 'node:fs';
4
+ import { networkInterfaces } from 'node:os';
4
5
  import { basename, resolve } from 'path';
5
6
 
6
7
  /**
@@ -23,6 +24,23 @@ import { basename, resolve } from 'path';
23
24
  * @property {Record<string, string>} [define] - Additional esbuild define values
24
25
  */
25
26
 
27
+ /**
28
+ * Get the local network IP address
29
+ * @returns {string} The local IP address or fallback to 127.0.0.1
30
+ */
31
+ function getLocalIP() {
32
+ const nets = networkInterfaces();
33
+ for (const name of Object.keys(nets)) {
34
+ for (const net of nets[name]) {
35
+ // Skip internal (loopback) and non-IPv4 addresses
36
+ if (net.family === 'IPv4' && !net.internal) {
37
+ return net.address;
38
+ }
39
+ }
40
+ }
41
+ return '127.0.0.1'; // Fallback to localhost
42
+ }
43
+
26
44
  /**
27
45
  * Build a FiveM/RedM resource with optional watch mode
28
46
  * @param {BuilderOptions} [options] - Build configuration options
@@ -36,6 +54,8 @@ export async function build(options = {}) {
36
54
  const IS_REDM = args.includes('--redm');
37
55
  const HAS_WEB_DIR = fs.existsSync(resolve(cwd, './web'));
38
56
  const PORT = IS_REDM ? 4700 : 4689;
57
+ const SERVER_IP = getLocalIP();
58
+
39
59
  // Configuration defaults
40
60
  const config = {
41
61
  restartEndpoint: options.restartEndpoint || `http://127.0.0.1:${PORT}/rr`,
@@ -77,7 +97,7 @@ export async function build(options = {}) {
77
97
  if (!HAS_WEB_DIR) {
78
98
  updated = updated.replace(/\n?\s*ui_page\s+['"][^'"]*['"]\s*\n?/g, '\n');
79
99
  } else {
80
- const desiredUiPage = IS_WATCH ? `ui_page 'http://127.0.0.1:${config.webDevPort}'` : "ui_page 'html/index.html'";
100
+ const desiredUiPage = IS_WATCH ? `ui_page 'http://${SERVER_IP}:${config.webDevPort}'` : "ui_page 'html/index.html'";
81
101
  updated = updated.match(/ui_page\s+['"][^'"]*['"]/)
82
102
  ? updated.replace(/ui_page\s+['"][^'"]*['"]/, desiredUiPage)
83
103
  : `${updated.trimEnd()}\n\n${desiredUiPage}\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrisivey01/builder",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Build tool for FiveM/RedM resources with watch mode and auto-restart",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -28,8 +28,5 @@
28
28
  "devDependencies": {
29
29
  "typescript": "^5.9.3"
30
30
  },
31
- "peerDependencies": {
32
- "esbuild": "^0.20.0"
33
- },
34
31
  "scripts": {}
35
32
  }