@chrisivey01/builder 1.0.1 → 1.0.2

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 +76 -0
  2. package/index.js +26 -1
  3. package/package.json +13 -3
package/index.d.ts ADDED
@@ -0,0 +1,76 @@
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
+ /**
20
+ * Build a FiveM/RedM resource with optional watch mode
21
+ * @param {BuilderOptions} [options] - Build configuration options
22
+ * @returns {Promise<void>}
23
+ */
24
+ export function build(options?: BuilderOptions): Promise<void>;
25
+ export type BuildConfig = {
26
+ /**
27
+ * - The platform target
28
+ */
29
+ platform?: "browser" | "node" | "neutral";
30
+ /**
31
+ * - The target ES version
32
+ */
33
+ target?: string | string[];
34
+ /**
35
+ * - The output format
36
+ */
37
+ format?: "iife" | "cjs" | "esm";
38
+ };
39
+ export type BuilderOptions = {
40
+ /**
41
+ * - Current working directory. Defaults to process.cwd()
42
+ */
43
+ cwd?: string;
44
+ /**
45
+ * - Name of the resource. Defaults to the basename of the cwd
46
+ */
47
+ resourceName?: string;
48
+ /**
49
+ * - Command line arguments. Defaults to process.argv.slice(2)
50
+ */
51
+ args?: string[];
52
+ /**
53
+ * - Endpoint for restarting the resource. Defaults to 'http://127.0.0.1:4689/rr'
54
+ */
55
+ restartEndpoint?: string;
56
+ /**
57
+ * - Timeout for restart requests in milliseconds. Defaults to 2000
58
+ */
59
+ restartTimeout?: number;
60
+ /**
61
+ * - Debounce delay for rebuilds in milliseconds. Defaults to 500
62
+ */
63
+ debounceDelay?: number;
64
+ /**
65
+ * - Port for web dev server. Defaults to 5173
66
+ */
67
+ webDevPort?: number;
68
+ /**
69
+ * - Build configurations for different targets
70
+ */
71
+ builds?: Record<string, BuildConfig>;
72
+ /**
73
+ * - Additional esbuild define values
74
+ */
75
+ define?: Record<string, string>;
76
+ };
package/index.js CHANGED
@@ -3,6 +3,31 @@ import { execSync, spawn } from 'node:child_process';
3
3
  import fs from 'node:fs';
4
4
  import { basename, resolve } from 'path';
5
5
 
6
+ /**
7
+ * @typedef {Object} BuildConfig
8
+ * @property {'browser' | 'node' | 'neutral'} [platform] - The platform target
9
+ * @property {string | string[]} [target] - The target ES version
10
+ * @property {'iife' | 'cjs' | 'esm'} [format] - The output format
11
+ */
12
+
13
+ /**
14
+ * @typedef {Object} BuilderOptions
15
+ * @property {string} [cwd] - Current working directory. Defaults to process.cwd()
16
+ * @property {string} [resourceName] - Name of the resource. Defaults to the basename of the cwd
17
+ * @property {string[]} [args] - Command line arguments. Defaults to process.argv.slice(2)
18
+ * @property {string} [restartEndpoint] - Endpoint for restarting the resource. Defaults to 'http://127.0.0.1:4689/rr'
19
+ * @property {number} [restartTimeout] - Timeout for restart requests in milliseconds. Defaults to 2000
20
+ * @property {number} [debounceDelay] - Debounce delay for rebuilds in milliseconds. Defaults to 500
21
+ * @property {number} [webDevPort] - Port for web dev server. Defaults to 5173
22
+ * @property {Record<string, BuildConfig>} [builds] - Build configurations for different targets
23
+ * @property {Record<string, string>} [define] - Additional esbuild define values
24
+ */
25
+
26
+ /**
27
+ * Build a FiveM/RedM resource with optional watch mode
28
+ * @param {BuilderOptions} [options] - Build configuration options
29
+ * @returns {Promise<void>}
30
+ */
6
31
  export async function build(options = {}) {
7
32
  const cwd = options.cwd || process.cwd();
8
33
  const resource_name = options.resourceName || basename(resolve(cwd));
@@ -10,7 +35,7 @@ export async function build(options = {}) {
10
35
  const IS_WATCH = args.includes('--watch');
11
36
  const IS_REDM = args.includes('--redm');
12
37
  const HAS_WEB_DIR = fs.existsSync(resolve(cwd, './web'));
13
-
38
+
14
39
  // Configuration defaults
15
40
  const config = {
16
41
  restartEndpoint: options.restartEndpoint || 'http://127.0.0.1:4689/rr',
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@chrisivey01/builder",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Build tool for FiveM/RedM resources with watch mode and auto-restart",
5
5
  "type": "module",
6
6
  "main": "index.js",
7
+ "types": "index.d.ts",
7
8
  "bin": {
8
9
  "build": "./cli.js"
9
10
  },
11
+ "files": [
12
+ "index.js",
13
+ "index.d.ts",
14
+ "cli.js"
15
+ ],
10
16
  "keywords": [
11
17
  "fivem",
12
18
  "redm",
@@ -17,9 +23,13 @@
17
23
  "author": "Chris Ivey",
18
24
  "license": "MIT",
19
25
  "dependencies": {
20
- "esbuild": "^0.24.2"
26
+ "esbuild": "^0.27.2"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.9.3"
21
30
  },
22
31
  "peerDependencies": {
23
32
  "esbuild": "^0.20.0"
24
- }
33
+ },
34
+ "scripts": {}
25
35
  }