@jpp-toolkit/plugin-build-fivem 0.0.8 → 0.0.9
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 +0 -1
- package/dist/index.mjs.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/src/fivem-build-command.ts +0 -1
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -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({}, this._compilerCallback.bind(this));\n } else {\n this.logger.info(`Building FiveM resource...\\n`);\n compiler.run(this._compilerCallback.bind(this));\n
|
|
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({}, this._compilerCallback.bind(this));\n } else {\n this.logger.info(`Building FiveM resource...\\n`);\n compiler.run(this._compilerCallback.bind(this));\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 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,0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2
2
|
"name": "@jpp-toolkit/plugin-build-fivem",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Plugin that add the fivem build command to the jpp cli.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jpp",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@oclif/core": "4.8.0",
|
|
38
38
|
"@rspack/core": "1.6.7",
|
|
39
|
-
"@jpp-toolkit/core": "0.0.15",
|
|
40
39
|
"@jpp-toolkit/rcon": "0.0.3",
|
|
40
|
+
"@jpp-toolkit/core": "0.0.15",
|
|
41
41
|
"@jpp-toolkit/rspack-config": "0.0.3",
|
|
42
42
|
"@jpp-toolkit/utils": "0.0.14"
|
|
43
43
|
},
|