@jpp-toolkit/plugin-build-fivem 0.0.130 → 0.0.132

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/dist/index.d.mts CHANGED
@@ -1,15 +1,14 @@
1
1
  import { Command } from "@jpp-toolkit/core";
2
- import * as _$_oclif_core_interfaces0 from "@oclif/core/interfaces";
3
2
 
4
3
  //#region src/fivem-build-command.d.ts
5
4
  declare class FivemBuildCommand extends Command {
6
5
  static summary: string;
7
6
  static flags: {
8
- watch: _$_oclif_core_interfaces0.BooleanFlag<boolean>;
9
- autoReload: _$_oclif_core_interfaces0.BooleanFlag<boolean>;
10
- server: _$_oclif_core_interfaces0.OptionFlag<string, _$_oclif_core_interfaces0.CustomOptions>;
11
- password: _$_oclif_core_interfaces0.OptionFlag<string | undefined, _$_oclif_core_interfaces0.CustomOptions>;
12
- resourceName: _$_oclif_core_interfaces0.OptionFlag<string | undefined, _$_oclif_core_interfaces0.CustomOptions>;
7
+ watch: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ autoReload: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ server: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ password: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ resourceName: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
12
  };
14
13
  static examples: {
15
14
  description: string;
package/dist/index.mjs CHANGED
@@ -136,7 +136,7 @@ const commands = { "build:fivem": class FivemBuildCommand extends Command {
136
136
  reloadFivemResource();
137
137
  };
138
138
  if (watch) {
139
- const devServerOptions = uiConfig.devServer ?? {};
139
+ const devServerOptions = typeof uiConfig.devServer === "object" ? uiConfig.devServer : {};
140
140
  devServerOptions.hot = true;
141
141
  await new RspackDevServer(devServerOptions, uiCompiler).start();
142
142
  scriptCompiler.watch({}, compilerCallback);
@@ -165,7 +165,7 @@ const commands = { "build:fivem": class FivemBuildCommand extends Command {
165
165
  if (!host || !port) throw new Error(`Invalid server address format: ${flags.server}. Expected format is "ip:port".`);
166
166
  rconOptions = {
167
167
  host,
168
- port: parseInt(port),
168
+ port: parseInt(port, 10),
169
169
  password: flags.password
170
170
  };
171
171
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/fivem-rcon.ts","../src/fivem-build-command.ts","../src/index.ts"],"sourcesContent":["import dgram from 'node:dgram';\n\nimport { getErrMsg } from '@jpp-toolkit/utils';\n\nexport type RconOptions = {\n readonly host: string;\n readonly port: number;\n readonly password: string;\n readonly timeout?: number | undefined;\n};\n\nfunction buildCommand(command: string, password: string): Buffer {\n const buffer = Buffer.alloc(11 + password.length + command.length);\n buffer.writeUInt32LE(0xffffffff, 0);\n buffer.write('rcon ', 4);\n buffer.write(password, 9, password.length);\n buffer.write(' ', 9 + password.length, 1);\n buffer.write(command, 10 + password.length, command.length);\n buffer.write('\\n', 10 + password.length + command.length, 1);\n return buffer;\n}\n\nexport async function sendFivemRcon(command: string, options: RconOptions): Promise<string> {\n const socket = dgram.createSocket('udp4');\n\n return new Promise<string>((resolve, reject) => {\n let timeoutId: NodeJS.Timeout;\n\n const handleError = (err?: Error | string | null) => {\n if (!err) return;\n clearTimeout(timeoutId);\n const msg = getErrMsg(err);\n reject(new Error(`Failed to send command to ${options.host}:${options.port}: ${msg}`));\n };\n\n const handleMessage = (msg: Buffer) => {\n clearTimeout(timeoutId);\n const res = msg.toString('ascii').slice(4).trim();\n if (res.includes('Invalid password')) return void handleError('Invalid password');\n resolve(res);\n };\n\n timeoutId = setTimeout(\n () => handleError(`Timeout after ${options.timeout}ms`),\n options.timeout ?? 5000,\n );\n\n socket.once('error', handleError);\n socket.once('message', handleMessage);\n\n const cmd = buildCommand(command, options.password);\n socket.send(cmd, 0, cmd.length, options.port, options.host, handleError);\n }).finally(() => {\n socket.close();\n });\n}\n\nexport async function refreshAndEnsureFivemResource(\n resourceName: string,\n options: RconOptions,\n): Promise<void> {\n const res = await sendFivemRcon(`refresh; ensure ${resourceName}`, options);\n if (res.includes(\"Couldn't find resource\"))\n throw new Error(`Resource \"${resourceName}\" not found`);\n if (!res.includes('Started resource'))\n throw new Error(`Failed to start resource \"${resourceName}\"`);\n}\n","import path from 'node:path';\n\nimport { Command } from '@jpp-toolkit/core';\nimport {\n createFivemScriptRspackConfig,\n createFivemUiRspackConfig,\n} from '@jpp-toolkit/rspack-config';\nimport { debounce } from '@jpp-toolkit/utils';\nimport { Flags } from '@oclif/core';\nimport type { MultiStats, Stats } from '@rspack/core';\nimport { rspack } from '@rspack/core';\nimport { RspackDevServer } from '@rspack/dev-server';\n\nimport type { RconOptions } from './fivem-rcon';\nimport { refreshAndEnsureFivemResource } from './fivem-rcon';\n\ntype FivemBuildCommandOptions = {\n readonly resourceName: string;\n readonly rconOptions?: RconOptions | undefined;\n readonly watch: boolean;\n};\n\nexport class FivemBuildCommand extends Command {\n static override summary = 'Build the FiveM resource using predefined config.';\n\n static override flags = {\n watch: Flags.boolean({\n char: 'w',\n description: 'Watch files for changes and rebuild automatically.',\n default: false,\n }),\n autoReload: Flags.boolean({\n char: 'r',\n description: 'Automatically reload FiveM resource after build.',\n default: false,\n }),\n server: Flags.string({\n char: 's',\n description: 'Server \"ip:port\" to connect for reloading FiveM resource after build.',\n default: '127.0.0.1:30120',\n required: false,\n }),\n password: Flags.string({\n char: 'p',\n description: 'RCON password for the FiveM server to reload resource after build.',\n required: false,\n }),\n resourceName: Flags.string({\n char: 'n',\n description:\n 'Name of the FiveM resource to reload. If not provided, the name of the folder containing the resource will be used.',\n required: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Build the FiveM resource.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n {\n description: 'Build the FiveM resource in watch mode.',\n command: '<%= config.bin %> <%= command.id %> --watch',\n },\n {\n description:\n 'Build the FiveM resource and automatically reload it on the server after build.',\n command:\n '<%= config.bin %> <%= command.id %> --auto-reload --password your_rcon_password',\n },\n {\n description:\n 'Build the FiveM resource in watch mode and automatically reload it on the server after each build.',\n command:\n '<%= config.bin %> <%= command.id %> --watch --auto-reload --password your_rcon_password',\n },\n {\n description:\n 'Build the FiveM resource and connect to a specific server for auto-reload.',\n command:\n '<%= config.bin %> <%= command.id %> --auto-reload --server=127.0.0.1:30120 --password your_rcon_password',\n },\n ];\n\n public async run(): Promise<void> {\n const { resourceName, rconOptions, watch } = await this._parseOptions();\n\n const scriptConfig = createFivemScriptRspackConfig(undefined, {\n isProduction: !watch,\n })({\n RSPACK_BUILD: !watch,\n RSPACK_WATCH: watch,\n });\n const scriptCompiler = rspack(scriptConfig);\n\n const uiConfig = createFivemUiRspackConfig(\n { resourceName },\n { isProduction: !watch },\n )({\n RSPACK_BUILD: !watch,\n RSPACK_SERVE: watch,\n });\n const uiCompiler = rspack(uiConfig);\n\n const reloadFivemResource = debounce(async () => {\n if (!rconOptions) return;\n this.logger.log('');\n this.logger.info(`Reloading FiveM resource \"${resourceName}\"...`);\n try {\n await refreshAndEnsureFivemResource(resourceName, rconOptions);\n this.logger.success(`FiveM resource reloaded successfully.\\n`);\n } catch (error) {\n this.logger.error(`Failed to reload FiveM resource: ${error}\\n`);\n }\n }, 500);\n\n const compilerCallback = (err: Error | null, stats: Stats | MultiStats | undefined) => {\n if (err) {\n this.logger.error(err.toString());\n return;\n }\n if (!stats) return;\n this.logger.log(stats.toString({ preset: 'normal', colors: true }), '\\n');\n void reloadFivemResource();\n };\n\n if (watch) {\n const devServerOptions = uiConfig.devServer ?? {};\n devServerOptions.hot = true;\n const devServer = new RspackDevServer(devServerOptions, uiCompiler);\n await devServer.start();\n scriptCompiler.watch({}, compilerCallback);\n } else {\n uiCompiler.run((error: Error | null, stats: Stats | MultiStats | undefined) => {\n uiCompiler.close((closeErr) => {\n if (closeErr) this.logger.error(closeErr.toString());\n compilerCallback(error, stats);\n });\n });\n scriptCompiler.run((error: Error | null, stats: Stats | MultiStats | undefined) => {\n scriptCompiler.close((closeErr) => {\n if (closeErr) this.logger.error(closeErr.toString());\n compilerCallback(error, stats);\n });\n });\n }\n }\n\n private async _parseOptions(): Promise<FivemBuildCommandOptions> {\n const { flags } = await this.parse(FivemBuildCommand);\n\n const resourceName = flags.resourceName ?? path.basename(process.cwd());\n\n let rconOptions: RconOptions | undefined;\n\n if (flags.autoReload) {\n if (!flags.password) {\n throw new Error(\n 'RCON password is required for auto-reload. Please provide it using the --password flag.',\n );\n }\n\n const match = /^(?<host>[^:]+):(?<port>\\d+)$/u.exec(flags.server);\n const { host, port } = match?.groups ?? {};\n\n if (!host || !port) {\n throw new Error(\n `Invalid server address format: ${flags.server}. Expected format is \"ip:port\".`,\n );\n }\n\n rconOptions = {\n host,\n port: parseInt(port),\n password: flags.password,\n };\n }\n\n return { resourceName, rconOptions, watch: flags.watch };\n }\n}\n","import { FivemBuildCommand } from './fivem-build-command';\n\nexport const commands = {\n 'build:fivem': FivemBuildCommand,\n};\n"],"mappings":";;;;;;;;;AAWA,SAAS,aAAa,SAAiB,UAA0B;CAC7D,MAAM,SAAS,OAAO,MAAM,KAAK,SAAS,SAAS,QAAQ,OAAO;CAClE,OAAO,cAAc,YAAY,EAAE;CACnC,OAAO,MAAM,SAAS,EAAE;CACxB,OAAO,MAAM,UAAU,GAAG,SAAS,OAAO;CAC1C,OAAO,MAAM,KAAK,IAAI,SAAS,QAAQ,EAAE;CACzC,OAAO,MAAM,SAAS,KAAK,SAAS,QAAQ,QAAQ,OAAO;CAC3D,OAAO,MAAM,MAAM,KAAK,SAAS,SAAS,QAAQ,QAAQ,EAAE;CAC5D,OAAO;;AAGX,eAAsB,cAAc,SAAiB,SAAuC;CACxF,MAAM,SAAS,MAAM,aAAa,OAAO;CAEzC,OAAO,IAAI,SAAiB,SAAS,WAAW;EAC5C,IAAI;EAEJ,MAAM,eAAe,QAAgC;GACjD,IAAI,CAAC,KAAK;GACV,aAAa,UAAU;GACvB,MAAM,MAAM,UAAU,IAA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AO;GACvB,eAAe,MAAM,EAAE,EAAE,iBAAiB;SACvC;GACH,WAAW,KAAK,OAAqB,UAA0C;IAC3E,WAAW,OAAO,aAAa;KAC3B,IAAI,UAAU,KAAK,OAAO,MAAM,SAAS,UAAU,CAAC;KACpD,iBAAiB,OAAO,MAAM;MAChC;KACJ;GACF,eAAe,KAAK,OAAqB,UAA0C;IAC/E,eAAe,OAAO,aAAa;KAC/B,IAAI,UAAU,KAAK,OAAO,MAAM,SAAS,UAAU,CAAC;KACpD,iBAAiB,OAAO,MAAM;MAChC;KACJ;;;CAIV,MAAc,gBAAmD;EAC7D,MAAM,EAAE,UAAU,MAAM,KAAK,MAAM,kBAAkB;EAErD,MAAM,eAAe,MAAM,gBAAgB,KAAK,SAAS,QAAQ,KAAK,CAAC;EAEvE,IAAI;EAEJ,IAAI,MAAM,YAAY;GAClB,IAAI,CAAC,MAAM,UACP,MAAM,IAAI,MACN,0FACH;GAIL,MAAM,EAAE,MAAM,SADA,iCAAiC,KAAK,MAAM,OAC9B,EAAE,UAAU,EAAE;GAE1C,IAAI,CAAC,QAAQ,CAAC,MACV,MAAM,IAAI,MACN,kCAAkC,MAAM,OAAO,iCAClD;GAGL,cAAc;IACV;IACA,MAAM,SAAS,KAAK;IACpB,UAAU,MAAM;IACnB;;EAGL,OAAO;GAAE;GAAc;GAAa,OAAO,MAAM;GAAO;;GC9K/D"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/fivem-rcon.ts","../src/fivem-build-command.ts","../src/index.ts"],"sourcesContent":["import dgram from 'node:dgram';\n\nimport { getErrMsg } from '@jpp-toolkit/utils';\n\nexport type RconOptions = {\n readonly host: string;\n readonly port: number;\n readonly password: string;\n readonly timeout?: number | undefined;\n};\n\nfunction buildCommand(command: string, password: string): Buffer {\n const buffer = Buffer.alloc(11 + password.length + command.length);\n buffer.writeUInt32LE(0xffffffff, 0);\n buffer.write('rcon ', 4);\n buffer.write(password, 9, password.length);\n buffer.write(' ', 9 + password.length, 1);\n buffer.write(command, 10 + password.length, command.length);\n buffer.write('\\n', 10 + password.length + command.length, 1);\n return buffer;\n}\n\nexport async function sendFivemRcon(command: string, options: RconOptions): Promise<string> {\n const socket = dgram.createSocket('udp4');\n\n return new Promise<string>((resolve, reject) => {\n let timeoutId: NodeJS.Timeout;\n\n const handleError = (err?: Error | string | null) => {\n if (!err) return;\n clearTimeout(timeoutId);\n const msg = getErrMsg(err);\n reject(new Error(`Failed to send command to ${options.host}:${options.port}: ${msg}`));\n };\n\n const handleMessage = (msg: Buffer) => {\n clearTimeout(timeoutId);\n const res = msg.toString('ascii').slice(4).trim();\n if (res.includes('Invalid password')) return void handleError('Invalid password');\n resolve(res);\n };\n\n timeoutId = setTimeout(\n () => handleError(`Timeout after ${options.timeout}ms`),\n options.timeout ?? 5000,\n );\n\n socket.once('error', handleError);\n socket.once('message', handleMessage);\n\n const cmd = buildCommand(command, options.password);\n socket.send(cmd, 0, cmd.length, options.port, options.host, handleError);\n }).finally(() => {\n socket.close();\n });\n}\n\nexport async function refreshAndEnsureFivemResource(\n resourceName: string,\n options: RconOptions,\n): Promise<void> {\n const res = await sendFivemRcon(`refresh; ensure ${resourceName}`, options);\n if (res.includes(\"Couldn't find resource\"))\n throw new Error(`Resource \"${resourceName}\" not found`);\n if (!res.includes('Started resource'))\n throw new Error(`Failed to start resource \"${resourceName}\"`);\n}\n","import path from 'node:path';\n\nimport { Command } from '@jpp-toolkit/core';\nimport {\n createFivemScriptRspackConfig,\n createFivemUiRspackConfig,\n} from '@jpp-toolkit/rspack-config';\nimport { debounce } from '@jpp-toolkit/utils';\nimport { Flags } from '@oclif/core';\nimport type { MultiStats, Stats } from '@rspack/core';\nimport { rspack } from '@rspack/core';\nimport { RspackDevServer } from '@rspack/dev-server';\n\nimport type { RconOptions } from './fivem-rcon';\nimport { refreshAndEnsureFivemResource } from './fivem-rcon';\n\ntype FivemBuildCommandOptions = {\n readonly resourceName: string;\n readonly rconOptions?: RconOptions | undefined;\n readonly watch: boolean;\n};\n\nexport class FivemBuildCommand extends Command {\n static override summary = 'Build the FiveM resource using predefined config.';\n\n static override flags = {\n watch: Flags.boolean({\n char: 'w',\n description: 'Watch files for changes and rebuild automatically.',\n default: false,\n }),\n autoReload: Flags.boolean({\n char: 'r',\n description: 'Automatically reload FiveM resource after build.',\n default: false,\n }),\n server: Flags.string({\n char: 's',\n description: 'Server \"ip:port\" to connect for reloading FiveM resource after build.',\n default: '127.0.0.1:30120',\n required: false,\n }),\n password: Flags.string({\n char: 'p',\n description: 'RCON password for the FiveM server to reload resource after build.',\n required: false,\n }),\n resourceName: Flags.string({\n char: 'n',\n description:\n 'Name of the FiveM resource to reload. If not provided, the name of the folder containing the resource will be used.',\n required: false,\n }),\n };\n\n static override examples = [\n {\n description: 'Build the FiveM resource.',\n command: '<%= config.bin %> <%= command.id %>',\n },\n {\n description: 'Build the FiveM resource in watch mode.',\n command: '<%= config.bin %> <%= command.id %> --watch',\n },\n {\n description:\n 'Build the FiveM resource and automatically reload it on the server after build.',\n command:\n '<%= config.bin %> <%= command.id %> --auto-reload --password your_rcon_password',\n },\n {\n description:\n 'Build the FiveM resource in watch mode and automatically reload it on the server after each build.',\n command:\n '<%= config.bin %> <%= command.id %> --watch --auto-reload --password your_rcon_password',\n },\n {\n description:\n 'Build the FiveM resource and connect to a specific server for auto-reload.',\n command:\n '<%= config.bin %> <%= command.id %> --auto-reload --server=127.0.0.1:30120 --password your_rcon_password',\n },\n ];\n\n public async run(): Promise<void> {\n const { resourceName, rconOptions, watch } = await this._parseOptions();\n\n const scriptConfig = createFivemScriptRspackConfig(undefined, {\n isProduction: !watch,\n })({\n RSPACK_BUILD: !watch,\n RSPACK_WATCH: watch,\n });\n const scriptCompiler = rspack(scriptConfig);\n\n const uiConfig = createFivemUiRspackConfig(\n { resourceName },\n { isProduction: !watch },\n )({\n RSPACK_BUILD: !watch,\n RSPACK_SERVE: watch,\n });\n const uiCompiler = rspack(uiConfig);\n\n const reloadFivemResource = debounce(async () => {\n if (!rconOptions) return;\n this.logger.log('');\n this.logger.info(`Reloading FiveM resource \"${resourceName}\"...`);\n try {\n await refreshAndEnsureFivemResource(resourceName, rconOptions);\n this.logger.success(`FiveM resource reloaded successfully.\\n`);\n } catch (error) {\n this.logger.error(`Failed to reload FiveM resource: ${error}\\n`);\n }\n }, 500);\n\n const compilerCallback = (err: Error | null, stats: Stats | MultiStats | undefined) => {\n if (err) {\n this.logger.error(err.toString());\n return;\n }\n if (!stats) return;\n this.logger.log(stats.toString({ preset: 'normal', colors: true }), '\\n');\n void reloadFivemResource();\n };\n\n if (watch) {\n const devServerOptions =\n typeof uiConfig.devServer === 'object' ? uiConfig.devServer : {};\n devServerOptions.hot = true;\n const devServer = new RspackDevServer(devServerOptions, uiCompiler);\n await devServer.start();\n scriptCompiler.watch({}, compilerCallback);\n } else {\n uiCompiler.run((error: Error | null, stats: Stats | MultiStats | undefined) => {\n uiCompiler.close((closeErr) => {\n if (closeErr) this.logger.error(closeErr.toString());\n compilerCallback(error, stats);\n });\n });\n scriptCompiler.run((error: Error | null, stats: Stats | MultiStats | undefined) => {\n scriptCompiler.close((closeErr) => {\n if (closeErr) this.logger.error(closeErr.toString());\n compilerCallback(error, stats);\n });\n });\n }\n }\n\n private async _parseOptions(): Promise<FivemBuildCommandOptions> {\n const { flags } = await this.parse(FivemBuildCommand);\n\n const resourceName = flags.resourceName ?? path.basename(process.cwd());\n\n let rconOptions: RconOptions | undefined;\n\n if (flags.autoReload) {\n if (!flags.password) {\n throw new Error(\n 'RCON password is required for auto-reload. Please provide it using the --password flag.',\n );\n }\n\n const match = /^(?<host>[^:]+):(?<port>\\d+)$/u.exec(flags.server);\n const { host, port } = match?.groups ?? {};\n\n if (!host || !port) {\n throw new Error(\n `Invalid server address format: ${flags.server}. Expected format is \"ip:port\".`,\n );\n }\n\n rconOptions = {\n host,\n port: parseInt(port, 10),\n password: flags.password,\n };\n }\n\n return { resourceName, rconOptions, watch: flags.watch };\n }\n}\n","import { FivemBuildCommand } from './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gB,KAAK,SAAS,QAAQ,IAAI,CAAC;EAEtE,IAAI;EAEJ,IAAI,MAAM,YAAY;GAClB,IAAI,CAAC,MAAM,UACP,MAAM,IAAI,MACN,yFACJ;GAIJ,MAAM,EAAE,MAAM,SADA,iCAAiC,KAAK,MAAM,MAC/B,GAAG,UAAU,CAAC;GAEzC,IAAI,CAAC,QAAQ,CAAC,MACV,MAAM,IAAI,MACN,kCAAkC,MAAM,OAAO,gCACnD;GAGJ,cAAc;IACV;IACA,MAAM,SAAS,MAAM,EAAE;IACvB,UAAU,MAAM;GACpB;EACJ;EAEA,OAAO;GAAE;GAAc;GAAa,OAAO,MAAM;EAAM;CAC3D;AACJ,ECjLA"}
@@ -79,5 +79,5 @@
79
79
  "summary": "Build the FiveM resource using predefined config."
80
80
  }
81
81
  },
82
- "version": "0.0.130"
82
+ "version": "0.0.132"
83
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpp-toolkit/plugin-build-fivem",
3
- "version": "0.0.130",
3
+ "version": "0.0.132",
4
4
  "description": "Plugin that add the fivem build command to the jpp cli.",
5
5
  "keywords": [
6
6
  "jpp",
@@ -35,18 +35,18 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@oclif/core": "4.11.3",
38
- "@rspack/core": "1.7.11",
39
- "@rspack/dev-server": "1.2.1",
40
- "@jpp-toolkit/core": "0.0.54",
41
- "@jpp-toolkit/rspack-config": "0.0.61",
42
- "@jpp-toolkit/utils": "0.0.37"
38
+ "@rspack/core": "2.0.3",
39
+ "@rspack/dev-server": "2.0.1",
40
+ "@jpp-toolkit/core": "0.0.55",
41
+ "@jpp-toolkit/rspack-config": "0.0.63",
42
+ "@jpp-toolkit/utils": "0.0.38"
43
43
  },
44
44
  "devDependencies": {
45
45
  "oclif": "4.23.7"
46
46
  },
47
47
  "engines": {
48
48
  "node": "24",
49
- "pnpm": "10"
49
+ "pnpm": "11"
50
50
  },
51
51
  "volta": {
52
52
  "extends": "../../package.json"
@@ -125,7 +125,8 @@ export class FivemBuildCommand extends Command {
125
125
  };
126
126
 
127
127
  if (watch) {
128
- const devServerOptions = uiConfig.devServer ?? {};
128
+ const devServerOptions =
129
+ typeof uiConfig.devServer === 'object' ? uiConfig.devServer : {};
129
130
  devServerOptions.hot = true;
130
131
  const devServer = new RspackDevServer(devServerOptions, uiCompiler);
131
132
  await devServer.start();
@@ -171,7 +172,7 @@ export class FivemBuildCommand extends Command {
171
172
 
172
173
  rconOptions = {
173
174
  host,
174
- port: parseInt(port),
175
+ port: parseInt(port, 10),
175
176
  password: flags.password,
176
177
  };
177
178
  }