@jpp-toolkit/plugin-build-fivem 0.0.11 → 0.0.13

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.mjs CHANGED
@@ -78,11 +78,11 @@ var FivemBuildCommand = class FivemBuildCommand extends Command {
78
78
  const compiler = rspack(createFivemRspackConfig({ mode }));
79
79
  if (autoReload) {
80
80
  if (!password) this.fatalError("RCON password is required for auto-reload. Please provide it using the --password flag.");
81
- await this._enableAutoReload(compiler, resourceName, host, port, password);
81
+ this._enableAutoReload(compiler, resourceName, host, port, password);
82
82
  }
83
83
  if (flags.watch) {
84
84
  this.logger.info(`Building FiveM resource in watch mode...\n`);
85
- compiler.watch({}, (err, stats) => this._compilerCallback(err, stats, true));
85
+ compiler.watch({}, (err, stats) => this._compilerCallback(err, stats));
86
86
  } else {
87
87
  this.logger.info(`Building FiveM resource...\n`);
88
88
  compiler.run((err, stats) => this._compilerCallback(err, stats));
@@ -96,24 +96,16 @@ var FivemBuildCommand = class FivemBuildCommand extends Command {
96
96
  port: parseInt(port)
97
97
  };
98
98
  }
99
- _compilerCallback(err, stats, isWatchMode = false) {
99
+ _compilerCallback(err, stats) {
100
100
  if (err) {
101
101
  this.logger.error(getErrMsg(err));
102
102
  if ("details" in err) this.logger.error(err.details);
103
103
  if ("stack" in err) this.logger.error(err.stack);
104
- if (!isWatchMode) this.exit(1);
105
104
  return;
106
105
  }
107
106
  if (stats) this.logger.log(stats.toString(), "\n");
108
- if (!isWatchMode) this.exit(0);
109
107
  }
110
- async _enableAutoReload(compiler, resourceName, host, port, password) {
111
- const rcon = new FivemRcon({
112
- host,
113
- port,
114
- password
115
- });
116
- await rcon.connect();
108
+ _enableAutoReload(compiler, resourceName, host, port, password) {
117
109
  compiler.hooks.done.tapPromise("FivemAutoReloadPlugin", async (stats) => {
118
110
  if (stats.hasErrors()) {
119
111
  this.logger.warning("Build failed. Skipping FiveM resource reload.\n");
@@ -121,7 +113,11 @@ var FivemBuildCommand = class FivemBuildCommand extends Command {
121
113
  }
122
114
  this.logger.info(`Reloading FiveM resource "${resourceName}"...`);
123
115
  try {
124
- await rcon.refreshAndEnsureResource(resourceName);
116
+ await new FivemRcon({
117
+ host,
118
+ port,
119
+ password
120
+ }).refreshAndEnsureResource(resourceName);
125
121
  this.logger.success(`FiveM resource reloaded successfully.\n`);
126
122
  } catch (error) {
127
123
  this.logger.error(`Failed to reload FiveM resource: ${getErrMsg(error)}\n`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/fivem-build-command.ts","../src/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport { Command } from '@jpp-toolkit/core';\nimport { FivemRcon } from '@jpp-toolkit/rcon';\nimport { createFivemRspackConfig } from '@jpp-toolkit/rspack-config';\nimport { getErrMsg } from '@jpp-toolkit/utils';\nimport { Flags } from '@oclif/core';\nimport type { Compiler, Stats } from '@rspack/core';\nimport { rspack } from '@rspack/core';\n\ntype Mode = 'development' | 'production';\ntype ServerAddress = { readonly host: string; readonly port: number };\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 mode: Flags.string({\n char: 'm',\n description: 'Set the build mode (development or production).',\n options: ['development', 'production'],\n required: 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: 'Build the FiveM resource in production mode.',\n command: '<%= config.bin %> <%= command.id %> --mode=production',\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 { flags } = await this.parse(FivemBuildCommand);\n\n const { watch, autoReload, password } = flags;\n const mode = (flags.mode ?? (watch ? 'development' : 'production')) as Mode;\n const { host, port } = this._parseServerAddress(flags.server);\n const resourceName = flags.resourceName ?? path.basename(process.cwd());\n\n const config = createFivemRspackConfig({ mode });\n const compiler = rspack(config);\n\n if (autoReload) {\n if (!password) {\n this.fatalError(\n 'RCON password is required for auto-reload. Please provide it using the --password flag.',\n );\n }\n\n await this._enableAutoReload(compiler, resourceName, host, port, password);\n }\n\n if (flags.watch) {\n this.logger.info(`Building FiveM resource in watch mode...\\n`);\n compiler.watch({}, (err, stats) => this._compilerCallback(err, stats, true));\n } else {\n this.logger.info(`Building FiveM resource...\\n`);\n compiler.run((err, stats) => this._compilerCallback(err, stats));\n }\n }\n\n private _parseServerAddress(address: string): ServerAddress {\n const match = /^(?<host>[^:]+):(?<port>\\d+)$/u.exec(address);\n const { host, port } = match?.groups ?? {};\n\n if (!host || !port) {\n throw new Error(\n `Invalid server address format: ${address}. Expected format is \"ip:port\".`,\n );\n }\n\n return { host, port: parseInt(port) };\n }\n\n private _compilerCallback(\n err: Error | null,\n stats: Stats | undefined,\n isWatchMode = false,\n ): void {\n if (err) {\n this.logger.error(getErrMsg(err));\n if ('details' in err) this.logger.error(err.details as string);\n if ('stack' in err) this.logger.error(err.stack);\n if (!isWatchMode) this.exit(1);\n return;\n }\n\n if (stats) this.logger.log(stats.toString(), '\\n');\n\n if (!isWatchMode) this.exit(0);\n }\n\n private async _enableAutoReload(\n compiler: Compiler,\n resourceName: string,\n host: string,\n port: number,\n password: string,\n ): Promise<void> {\n const rcon = new FivemRcon({ host, port, password });\n await rcon.connect();\n\n compiler.hooks.done.tapPromise('FivemAutoReloadPlugin', async (stats) => {\n if (stats.hasErrors()) {\n this.logger.warning('Build failed. Skipping FiveM resource reload.\\n');\n return;\n }\n\n this.logger.info(`Reloading FiveM resource \"${resourceName}\"...`);\n try {\n await rcon.refreshAndEnsureResource(resourceName);\n this.logger.success(`FiveM resource reloaded successfully.\\n`);\n } catch (error) {\n this.logger.error(`Failed to reload FiveM resource: ${getErrMsg(error)}\\n`);\n }\n });\n }\n}\n","import { FivemBuildCommand } from './fivem-build-command';\n\nexport const commands = {\n 'build:fivem': FivemBuildCommand,\n};\n"],"mappings":";;;;;;;;;AAaA,IAAa,oBAAb,MAAa,0BAA0B,QAAQ;CAC3C,OAAgB,UAAU;CAE1B,OAAgB,QAAQ;EACpB,OAAO,MAAM,QAAQ;GACjB,MAAM;GACN,aAAa;GACb,SAAS;GACZ,CAAC;EACF,MAAM,MAAM,OAAO;GACf,MAAM;GACN,aAAa;GACb,SAAS,CAAC,eAAe,aAAa;GACtC,UAAU;GACb,CAAC;EACF,YAAY,MAAM,QAAQ;GACtB,MAAM;GACN,aAAa;GACb,SAAS;GACZ,CAAC;EACF,QAAQ,MAAM,OAAO;GACjB,MAAM;GACN,aAAa;GACb,SAAS;GACT,UAAU;GACb,CAAC;EACF,UAAU,MAAM,OAAO;GACnB,MAAM;GACN,aAAa;GACb,UAAU;GACb,CAAC;EACF,cAAc,MAAM,OAAO;GACvB,MAAM;GACN,aACI;GACJ,UAAU;GACb,CAAC;EACL;CAED,OAAgB,WAAW;EAC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,MAAK,OAAO,MAAM,IAAI,QAAkB;AAC9D,OAAI,WAAW,IAAK,MAAK,OAAO,MAAM,IAAI,MAAM;AAChD,OAAI,CAAC,YAAa,MAAK,KAAK,EAAE;AAC9B;;AAGJ,MAAI,MAAO,MAAK,OAAO,IAAI,MAAM,UAAU,EAAE,KAAK;AAElD,MAAI,CAAC,YAAa,MAAK,KAAK,EAAE;;CAGlC,MAAc,kBACV,UACA,cACA,MACA,MACA,UACa;EACb,MAAM,OAAO,IAAI,UAAU;GAAE;GAAM;GAAM;GAAU,CAAC;AACpD,QAAM,KAAK,SAAS;AAEpB,WAAS,MAAM,KAAK,WAAW,yBAAyB,OAAO,UAAU;AACrE,OAAI,MAAM,WAAW,EAAE;AACnB,SAAK,OAAO,QAAQ,kDAAkD;AACtE;;AAGJ,QAAK,OAAO,KAAK,6BAA6B,aAAa,MAAM;AACjE,OAAI;AACA,UAAM,KAAK,yBAAyB,aAAa;AACjD,SAAK,OAAO,QAAQ,0CAA0C;YACzD,OAAO;AACZ,SAAK,OAAO,MAAM,oCAAoC,UAAU,MAAM,CAAC,IAAI;;IAEjF;;;;;;ACvKV,MAAa,WAAW,EACpB,eAAe,mBAClB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/fivem-build-command.ts","../src/index.ts"],"sourcesContent":["import path from 'node:path';\n\nimport { Command } from '@jpp-toolkit/core';\nimport { FivemRcon } from '@jpp-toolkit/rcon';\nimport { createFivemRspackConfig } from '@jpp-toolkit/rspack-config';\nimport { getErrMsg } from '@jpp-toolkit/utils';\nimport { Flags } from '@oclif/core';\nimport type { Compiler, Stats } from '@rspack/core';\nimport { rspack } from '@rspack/core';\n\ntype Mode = 'development' | 'production';\ntype ServerAddress = { readonly host: string; readonly port: number };\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 mode: Flags.string({\n char: 'm',\n description: 'Set the build mode (development or production).',\n options: ['development', 'production'],\n required: 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: 'Build the FiveM resource in production mode.',\n command: '<%= config.bin %> <%= command.id %> --mode=production',\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 { flags } = await this.parse(FivemBuildCommand);\n\n const { watch, autoReload, password } = flags;\n const mode = (flags.mode ?? (watch ? 'development' : 'production')) as Mode;\n const { host, port } = this._parseServerAddress(flags.server);\n const resourceName = flags.resourceName ?? path.basename(process.cwd());\n\n const config = createFivemRspackConfig({ mode });\n const compiler = rspack(config);\n\n if (autoReload) {\n if (!password) {\n this.fatalError(\n 'RCON password is required for auto-reload. Please provide it using the --password flag.',\n );\n }\n\n this._enableAutoReload(compiler, resourceName, host, port, password);\n }\n\n if (flags.watch) {\n this.logger.info(`Building FiveM resource in watch mode...\\n`);\n compiler.watch({}, (err, stats) => this._compilerCallback(err, stats));\n } else {\n this.logger.info(`Building FiveM resource...\\n`);\n compiler.run((err, stats) => this._compilerCallback(err, stats));\n }\n }\n\n private _parseServerAddress(address: string): ServerAddress {\n const match = /^(?<host>[^:]+):(?<port>\\d+)$/u.exec(address);\n const { host, port } = match?.groups ?? {};\n\n if (!host || !port) {\n throw new Error(\n `Invalid server address format: ${address}. Expected format is \"ip:port\".`,\n );\n }\n\n return { host, port: parseInt(port) };\n }\n\n private _compilerCallback(err: Error | null, stats: Stats | undefined): void {\n if (err) {\n this.logger.error(getErrMsg(err));\n if ('details' in err) this.logger.error(err.details as string);\n if ('stack' in err) this.logger.error(err.stack);\n return;\n }\n\n if (stats) this.logger.log(stats.toString(), '\\n');\n }\n\n private _enableAutoReload(\n compiler: Compiler,\n resourceName: string,\n host: string,\n port: number,\n password: string,\n ): void {\n compiler.hooks.done.tapPromise('FivemAutoReloadPlugin', async (stats) => {\n if (stats.hasErrors()) {\n this.logger.warning('Build failed. Skipping FiveM resource reload.\\n');\n return;\n }\n\n this.logger.info(`Reloading FiveM resource \"${resourceName}\"...`);\n try {\n const rcon = new FivemRcon({ host, port, password });\n await rcon.refreshAndEnsureResource(resourceName);\n this.logger.success(`FiveM resource reloaded successfully.\\n`);\n } catch (error) {\n this.logger.error(`Failed to reload FiveM resource: ${getErrMsg(error)}\\n`);\n }\n });\n }\n}\n","import { FivemBuildCommand } from './fivem-build-command';\n\nexport const commands = {\n 'build:fivem': FivemBuildCommand,\n};\n"],"mappings":";;;;;;;;;AAaA,IAAa,oBAAb,MAAa,0BAA0B,QAAQ;CAC3C,OAAgB,UAAU;CAE1B,OAAgB,QAAQ;EACpB,OAAO,MAAM,QAAQ;GACjB,MAAM;GACN,aAAa;GACb,SAAS;GACZ,CAAC;EACF,MAAM,MAAM,OAAO;GACf,MAAM;GACN,aAAa;GACb,SAAS,CAAC,eAAe,aAAa;GAC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D,MAAM,EAAE,MAAM,SADA,iCAAiC,KAAK,QAAQ,EAC9B,UAAU,EAAE;AAE1C,MAAI,CAAC,QAAQ,CAAC,KACV,OAAM,IAAI,MACN,kCAAkC,QAAQ,iCAC7C;AAGL,SAAO;GAAE;GAAM,MAAM,SAAS,KAAK;GAAE;;CAGzC,AAAQ,kBAAkB,KAAmB,OAAgC;AACzE,MAAI,KAAK;AACL,QAAK,OAAO,MAAM,UAAU,IAAI,CAAC;AACjC,OAAI,aAAa,IAAK,MAAK,OAAO,MAAM,IAAI,QAAkB;AAC9D,OAAI,WAAW,IAAK,MAAK,OAAO,MAAM,IAAI,MAAM;AAChD;;AAGJ,MAAI,MAAO,MAAK,OAAO,IAAI,MAAM,UAAU,EAAE,KAAK;;CAGtD,AAAQ,kBACJ,UACA,cACA,MACA,MACA,UACI;AACJ,WAAS,MAAM,KAAK,WAAW,yBAAyB,OAAO,UAAU;AACrE,OAAI,MAAM,WAAW,EAAE;AACnB,SAAK,OAAO,QAAQ,kDAAkD;AACtE;;AAGJ,QAAK,OAAO,KAAK,6BAA6B,aAAa,MAAM;AACjE,OAAI;AAEA,UADa,IAAI,UAAU;KAAE;KAAM;KAAM;KAAU,CAAC,CACzC,yBAAyB,aAAa;AACjD,SAAK,OAAO,QAAQ,0CAA0C;YACzD,OAAO;AACZ,SAAK,OAAO,MAAM,oCAAoC,UAAU,MAAM,CAAC,IAAI;;IAEjF;;;;;;AC9JV,MAAa,WAAW,EACpB,eAAe,mBAClB"}
@@ -96,5 +96,5 @@
96
96
  "summary": "Build the FiveM resource using predefined config."
97
97
  }
98
98
  },
99
- "version": "0.0.11"
99
+ "version": "0.0.13"
100
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpp-toolkit/plugin-build-fivem",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Plugin that add the fivem build command to the jpp cli.",
5
5
  "keywords": [
6
6
  "jpp",
@@ -37,12 +37,12 @@
37
37
  "@oclif/core": "4.8.0",
38
38
  "@rspack/core": "1.6.7",
39
39
  "@jpp-toolkit/core": "0.0.15",
40
- "@jpp-toolkit/rcon": "0.0.3",
41
- "@jpp-toolkit/utils": "0.0.14",
42
- "@jpp-toolkit/rspack-config": "0.0.3"
40
+ "@jpp-toolkit/rcon": "0.0.4",
41
+ "@jpp-toolkit/rspack-config": "0.0.3",
42
+ "@jpp-toolkit/utils": "0.0.14"
43
43
  },
44
44
  "devDependencies": {
45
- "oclif": "4.22.55"
45
+ "oclif": "4.22.56"
46
46
  },
47
47
  "engines": {
48
48
  "node": "24",
@@ -101,12 +101,12 @@ export class FivemBuildCommand extends Command {
101
101
  );
102
102
  }
103
103
 
104
- await this._enableAutoReload(compiler, resourceName, host, port, password);
104
+ this._enableAutoReload(compiler, resourceName, host, port, password);
105
105
  }
106
106
 
107
107
  if (flags.watch) {
108
108
  this.logger.info(`Building FiveM resource in watch mode...\n`);
109
- compiler.watch({}, (err, stats) => this._compilerCallback(err, stats, true));
109
+ compiler.watch({}, (err, stats) => this._compilerCallback(err, stats));
110
110
  } else {
111
111
  this.logger.info(`Building FiveM resource...\n`);
112
112
  compiler.run((err, stats) => this._compilerCallback(err, stats));
@@ -126,34 +126,24 @@ export class FivemBuildCommand extends Command {
126
126
  return { host, port: parseInt(port) };
127
127
  }
128
128
 
129
- private _compilerCallback(
130
- err: Error | null,
131
- stats: Stats | undefined,
132
- isWatchMode = false,
133
- ): void {
129
+ private _compilerCallback(err: Error | null, stats: Stats | undefined): void {
134
130
  if (err) {
135
131
  this.logger.error(getErrMsg(err));
136
132
  if ('details' in err) this.logger.error(err.details as string);
137
133
  if ('stack' in err) this.logger.error(err.stack);
138
- if (!isWatchMode) this.exit(1);
139
134
  return;
140
135
  }
141
136
 
142
137
  if (stats) this.logger.log(stats.toString(), '\n');
143
-
144
- if (!isWatchMode) this.exit(0);
145
138
  }
146
139
 
147
- private async _enableAutoReload(
140
+ private _enableAutoReload(
148
141
  compiler: Compiler,
149
142
  resourceName: string,
150
143
  host: string,
151
144
  port: number,
152
145
  password: string,
153
- ): Promise<void> {
154
- const rcon = new FivemRcon({ host, port, password });
155
- await rcon.connect();
156
-
146
+ ): void {
157
147
  compiler.hooks.done.tapPromise('FivemAutoReloadPlugin', async (stats) => {
158
148
  if (stats.hasErrors()) {
159
149
  this.logger.warning('Build failed. Skipping FiveM resource reload.\n');
@@ -162,6 +152,7 @@ export class FivemBuildCommand extends Command {
162
152
 
163
153
  this.logger.info(`Reloading FiveM resource "${resourceName}"...`);
164
154
  try {
155
+ const rcon = new FivemRcon({ host, port, password });
165
156
  await rcon.refreshAndEnsureResource(resourceName);
166
157
  this.logger.success(`FiveM resource reloaded successfully.\n`);
167
158
  } catch (error) {