@chrisivey01/builder 1.0.0 → 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 (4) hide show
  1. package/README.md +32 -32
  2. package/index.d.ts +76 -0
  3. package/index.js +26 -1
  4. package/package.json +14 -4
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @pma/build
1
+ # @chrisivey01/builder
2
2
 
3
3
  A build tool for FiveM/RedM resources with watch mode and auto-restart support.
4
4
 
@@ -14,11 +14,11 @@ A build tool for FiveM/RedM resources with watch mode and auto-restart support.
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- pnpm add -D @pma/build
17
+ pnpm add -D @chrisivey01/builder
18
18
  # or
19
- npm install --save-dev @pma/build
19
+ npm install --save-dev @chrisivey01/builder
20
20
  # or
21
- yarn add -D @pma/build
21
+ yarn add -D @chrisivey01/builder
22
22
  ```
23
23
 
24
24
  ## Usage
@@ -29,12 +29,12 @@ Add to your `package.json` scripts:
29
29
 
30
30
  ```json
31
31
  {
32
- "scripts": {
33
- "build": "pma-build",
34
- "watch": "pma-build --watch",
35
- "build:redm": "pma-build --redm",
36
- "watch:redm": "pma-build --watch --redm"
37
- }
32
+ "scripts": {
33
+ "build": "build",
34
+ "watch": "build --watch",
35
+ "build:redm": "build --redm",
36
+ "watch:redm": "build --watch --redm"
37
+ }
38
38
  }
39
39
  ```
40
40
 
@@ -50,18 +50,18 @@ pnpm watch:redm # Watch mode for RedM
50
50
  ### Programmatic API
51
51
 
52
52
  ```javascript
53
- import { build } from '@pma/build';
53
+ import { build } from "@chrisivey01/builder";
54
54
 
55
55
  await build({
56
- resourceName: 'my-resource',
57
- restartEndpoint: 'http://127.0.0.1:4689/rr',
58
- restartTimeout: 2000,
59
- debounceDelay: 500,
60
- webDevPort: 5173,
61
- builds: {
62
- client: { platform: 'browser', target: 'es2021', format: 'iife' },
63
- server: { platform: 'node', target: 'node16', format: 'cjs' }
64
- }
56
+ resourceName: "my-resource",
57
+ restartEndpoint: "http://127.0.0.1:4689/rr",
58
+ restartTimeout: 2000,
59
+ debounceDelay: 500,
60
+ webDevPort: 5173,
61
+ builds: {
62
+ client: { platform: "browser", target: "es2021", format: "iife" },
63
+ server: { platform: "node", target: "node16", format: "cjs" },
64
+ },
65
65
  });
66
66
  ```
67
67
 
@@ -71,14 +71,14 @@ Create a `build.config.js` in your project root:
71
71
 
72
72
  ```javascript
73
73
  export default {
74
- restartEndpoint: 'http://127.0.0.1:4689/rr',
75
- restartTimeout: 2000,
76
- debounceDelay: 500,
77
- webDevPort: 5173,
78
- builds: {
79
- client: { platform: 'browser', target: 'es2021', format: 'iife' },
80
- server: { platform: 'node', target: 'node16', format: 'cjs' }
81
- }
74
+ restartEndpoint: "http://127.0.0.1:4689/rr",
75
+ restartTimeout: 2000,
76
+ debounceDelay: 500,
77
+ webDevPort: 5173,
78
+ builds: {
79
+ client: { platform: "browser", target: "es2021", format: "iife" },
80
+ server: { platform: "node", target: "node16", format: "cjs" },
81
+ },
82
82
  };
83
83
  ```
84
84
 
@@ -88,10 +88,10 @@ The build tool automatically injects a `GAME` constant into your code:
88
88
 
89
89
  ```typescript
90
90
  // Available globally in your code
91
- if (GAME === 'REDM') {
92
- console.log('Running on RedM');
91
+ if (GAME === "REDM") {
92
+ console.log("Running on RedM");
93
93
  } else {
94
- console.log('Running on FiveM');
94
+ console.log("Running on FiveM");
95
95
  }
96
96
  ```
97
97
 
@@ -99,7 +99,7 @@ Add this to your `types/game.d.ts`:
99
99
 
100
100
  ```typescript
101
101
  declare global {
102
- const GAME: "REDM" | "FIVEM";
102
+ const GAME: "REDM" | "FIVEM";
103
103
  }
104
104
 
105
105
  export {};
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.0",
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
- "pma-build": "./cli.js"
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
  }