Giter Site home page Giter Site logo

southclaws / sampctl Goto Github PK

View Code? Open in Web Editor NEW
237.0 14.0 33.0 139.94 MB

The Swiss Army Knife of SA:MP - vital tools for any server owner or library maintainer.

License: GNU General Public License v3.0

Go 98.85% Pawn 0.15% Shell 0.40% Dockerfile 0.07% C++ 0.05% Earthly 0.18% Ruby 0.30%
sa-mp sa-mp-server sa-mp-development server-tools command-line ctl package-manager package-management dependency-manager build-tool

sampctl's Introduction

sampctl

Build Status Go Report Card Ko-Fi FOSSA Status

sampctl-logo

The Swiss Army Knife of SA:MP - vital tools for any server owner or library maintainer.

sampctl is a command-line development tool for developing SA:MP Pawn scripts. It includes a package manager, a build tool and a configuration manager.

If that sentence meant nothing to you, don't worry! You'll probably find use in sampctl if you do anything related to the Pawn language. Below are some explanations of what the terms in bold above mean.

  • command-line development tool: Whether you're a seasoned developer or just a beginner, mastering the command-line on Windows and Unix systems is absolutely necessary to speed up your workflow, take advantage of tools (like this one) and just generally improve your knowledge of computing. If you've never opened Cmd, PowerShell (Windows) or Terminal (Mac) then read this guide.
  • Pawn scripts: This includes gamemodes, filterscripts and libraries (includes). sampctl introduces the concept of packages to the SA:MP and Pawn world to make everyone's life easier.
  • package manager: This allows you to easily use and share packages, no more downloading outdated .inc files from solidfiles...
  • build tool: Easily experiment with new versions of the compiler with a simpler setup and automatic download feature.
  • configuration manager: server.cfg files can get messy and unmanageable, sampctl can generate this file automatically from a much cleaner looking JSON or YAML equivalent.

For a quick-start guide, click this link!

Features

As mentioned above, sampctl is a command-line development tool so it has no graphical user interface. The videos below show sampctl being used with Visual Studio Code which is a light-weight text editor that works very well with sampctl to provide the perfect SA:MP/Pawn development environment.

Package Manager

Always have the libraries you need. Inspired by npm.

images/sampctl-package-ensure.gif

Build/Run Tool

Use on the command-line or integrate with any editor.

images/sampctl-package-build-vscode.gif

Easily write and run tests for libraries or quickly run arbitrary code. Utilise the power of Docker to run on any platform!

images/sampctl-package-run-container.gif

Developer Tools

Quickly bootstrap new packages.

images/sampctl-package-init.gif

SA:MP Server Configuration - no more server.cfg

Manage your server settings in JSON or YAML format

images/sampctl-server-init.gif

Automatic Server Restart - no more dodgy bash scripts

Run the server from sampctl and let it worry about restarting in case of crashes.

images/sampctl-server-run.gif

Automatic Server and Plugin Installer

Automatically download Windows/Linux server binaries and plugins when and where you need them.

images/sampctl-server-ensure.gif

Installation

Installation is simple and fast on all platforms so why not give sampctl a try?

Usage

For a list of commands, click here.

Or visit the Wiki site for documentation on each feature..


Overview

sampctl is designed for both development of gamemodes/libraries and management of live servers.

Below is a quick overview of the best features that will help you develop faster.

Package Management and Build Tool

If you've used platforms like NodeJS, Python, Go, Ruby, etc you know how useful tools like npm, pip, gem are.

It's about time Pawn had the same tool.

sampctl provides a simple and intuitive way to declare what includes your project needs. After that you simply let sampctl take care of the downloading and building.

If you release scripts, you know it's awkward to test even simple code. You need to set up a server, compile the include into a gamemode, configure the server and run it.

Forget all that. Just make a pawn.json/pawn.yaml in your project directory with sampctl package init and use sampctl package install to get the includes you need:

{
  "entry": "test.pwn",
  "output": "test.amx",
  "dependencies": ["pawn-lang/samp-stdlib", "Southclaws/formatex"]
}

Write your quick test code:

#include <a_samp>
#include <formatex>

main() {
    new str[128];
    formatex(str, sizeof str, "My favourite vehicle is: '%v'!", 400); // should print "Landstalker"
    print(str);
}

Build with sampctl package build and run it with sampctl package run!

sampctl package run

Server Plugins
--------------
 Loaded 0 plugins.

Started server on port: 7777, with maxplayers: 50 lanmode is OFF.

Filterscripts
---------------
  Loaded 0 filterscripts.

My favourite vehicle is: 'Landstalker'!

You get the compiler output and the server output without ever needing to:

  • visit sa-mp.com/download.php
  • unzip a server package
  • worry about Windows or Linux differences
  • set up the Pawn compiler with your favourite editor
  • make sure the Pawn compiler is reading the correct includes
  • download the formatex include

See documentation for more info.

Server Configuration and Automatic Plugin Download

Use JSON or YAML to write your server config:

{
  "gamemodes": ["rivershell"],
  "plugins": ["maddinat0r/sscanf"],
  "rcon_password": "test",
  "port": 8080
}

It compiles to this:

gamemode0 rivershell
plugins sscanf.so
rcon_password test
port 8080
(... and the rest of the settings which have default values)

What also happens here is maddinat0r/sscanf tells sampctl to automatically get the latest sscanf plugin and place the .so or .dll file into the plugins/ directory.

See documentation for more info.


sampctl

1.10.0 - Southclaws [email protected]

The Swiss Army Knife of SA:MP - vital tools for any server owner or library maintainer.

Commands (6)

sampctl

Usage: sampctl <subcommand>

For managing servers and runtime configurations.

Subcommands (4)

sampctl init

Usage: sampctl init

Bootstrap a new SA:MP server and generates a samp.json/samp.yaml configuration based on user input. If gamemodes, filterscripts or plugins directories are present, you will be prompted to select relevant files.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --version value: the SA:MP server version to use (default: "0.3.7")
  • --dir value: working directory for the server - by default, uses the current directory (default: ".")

sampctl download

Usage: sampctl download

Downloads the files necessary to run a SA:MP server to the current directory (unless --dir specified). Will download the latest stable (non RC) server version unless --version is specified.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --version value: the SA:MP server version to use (default: "0.3.7")
  • --dir value: working directory for the server - by default, uses the current directory (default: ".")

sampctl ensure

Usage: sampctl ensure

Ensures the server environment is representative of the configuration specified in samp.json/samp.yaml - downloads server binaries and plugin files if necessary and generates a server.cfg file.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the server - by default, uses the current directory (default: ".")
  • --noCache --forceEnsure: forces download of plugins if --forceEnsure is set

sampctl run

Usage: sampctl run

Generates a server.cfg file based on the configuration inside samp.json/samp.yaml then executes the server process and automatically restarts it on crashes.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the server - by default, uses the current directory (default: ".")
  • --container: starts the server as a Linux container instead of running it in the current directory
  • --mountCache --container: if --container is set, mounts the local cache directory inside the container
  • --noCache: forces download of plugins

sampctl package

Usage: sampctl package <subcommand>

For managing Pawn packages such as gamemodes and libraries.

Subcommands (9)

sampctl package init

Usage: sampctl package init

Helper tool to bootstrap a new package or turn an existing project into a package.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the project - by default, uses the current directory (default: ".")

sampctl package ensure

Usage: sampctl package ensure

Ensures dependencies are up to date based on the dependencies field in pawn.json/pawn.yaml.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the project - by default, uses the current directory (default: ".")
  • --update: update cached dependencies to latest version

sampctl package install

Usage: sampctl package install [package definition]

Installs a new package by adding it to the dependencies field in pawn.json/pawn.yaml and downloads the contents.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the project - by default, uses the current directory (default: ".")
  • --dev: for specifying dependencies only necessary for development or testing of the package

sampctl package uninstall

Usage: sampctl package uninstall [package definition]

Uninstalls package by removing it from the dependencies field in pawn.json/pawn.yaml and deletes the contents.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the project - by default, uses the current directory (default: ".")
  • --dev: for specifying development dependencies

sampctl package release

Usage: sampctl package release

Creates a release version and tags the repository with the next version number, creates a GitHub release with archived package files.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the project - by default, uses the current directory (default: ".")

sampctl package get

Usage: sampctl package get [package definition] (target path)

Clones a GitHub package to either a directory named after the repo or, if the cwd is empty, the cwd and then ensures the package.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration

sampctl package build

Usage: sampctl package build [build name]

Builds a package defined by a pawn.json/pawn.yaml file.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the project - by default, uses the current directory (default: ".")
  • --forceEnsure: forces dependency ensure before build
  • --dryRun: does not run the build but outputs the command necessary to do so
  • --watch: keeps sampctl running and triggers builds whenever source files change
  • --buildFile value: declares a file to store the incrementing build number for easy versioning
  • --relativePaths: force compiler output to use relative paths instead of absolute

sampctl package run

Usage: sampctl package run

Compiles and runs a package defined by a pawn.json/pawn.yaml file.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the server - by default, uses the current directory (default: ".")
  • --container: starts the server as a Linux container instead of running it in the current directory
  • --build --forceBuild: build configuration to use if --forceBuild is set
  • --forceBuild: forces a build to run before executing the server
  • --forceEnsure --forceBuild: forces dependency ensure before build if --forceBuild is set
  • --noCache --forceEnsure: forces download of plugins if --forceEnsure is set
  • --watch: keeps sampctl running and triggers builds whenever source files change
  • --buildFile value: declares a file to store the incrementing build number for easy versioning
  • --relativePaths: force compiler output to use relative paths instead of absolute

sampctl package template

Usage: sampctl package template <subcommand>

Provides commands for package templates

Subcommands (3)

sampctl package template make

Usage: sampctl package template make [name]

Creates a template package from the current directory if it is a package.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --dir value: working directory for the package - by default, uses the current directory (default: ".")
  • --update: update cached dependencies to latest version

sampctl package template build

Usage: sampctl package template build [template] [filename]

Builds the specified file in the context of the given template.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration

sampctl package template run

Usage: sampctl package template run [template] [filename]

Builds and runs the specified file in the context of the given template.

Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --version value: the SA:MP server version to use (default: "0.3.7")
  • --mode value: runtime mode, one of: server, main, y_testing (default: "main")

sampctl version

Show version number - this is also the version of the container image that will be used for --container runtimes.


sampctl completion

output bash autocomplete code


sampctl docs

Usage: sampctl docs > documentation.md

Generate documentation in markdown format and print to standard out.


sampctl help

Usage: Shows a list of commands or help for one command


Global Flags

  • --verbose: output all detailed information - useful for debugging
  • --platform windows: manually specify the target platform for downloaded binaries to either windows, linux or darwin.
  • --bare: skip all pre-run configuration
  • --help, -h: show help
  • --appVersion, -V: sampctl version

sampctl's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sampctl's Issues

Organise a proper deployment solution

Currently using gox to build cross-platform binaries but I have to upload manually.

https://goreleaser.com/ looks good and I can run it on TravisCI for auto deployments on each commit, it also supports build-time versioning so no more manual setting of app.Version!

Linux installation is quite straightforward but Windows can be weird for users who don't do CLI stuff often and don't have a ~/bin directory or something, http://scoop.sh/ looks like a nice solution for that and it's a one-liner in Powershell!

Automatic samp-servers.net server announcement

I may as well integrate two of my projects!

This should load info from a key such as listing inside the samp.json file and post it to http://api.samp.southcla.ws so users can take advantage of the better features of that list such as banner images and search tags.

Example:

{
    "gamemodes": [
        "mygame"
    ],
    "plugins": [
        "mysql",
        "streamer",
        "sscanf",
        "whirlpool",
        "filemanager"
    ],
    "hostname": "My Server",
    "maxplayers": 75,
    "port": 7777,
    "listing": {
        "description": "My awesome server is really cool!",
        "banner": "http://i.imgur.com/nf8923hg.jpg"
    }
}

Pattern recognition on y_testing output

A special flag should be added to a package runtime to specify whether the package is a test suite - this would give two things:

  • Parsing of the output to give a nice output for editors/CI
  • The ability to know when to kill the process when the tests are finished

"sleep" in "samp.json" expected as a string, instead of an integer

Command:

sampctl.exe run --dir "X:\cs\SAMPLauncherNET\SAMPLauncherNET\bin\Debug\development"

Message:

Exited with error: failed to generate config from environment: failed to unmarshal samp.json: json: cannot unmarshal number into Go struct field Config.sleep of type string

samp.json:

{
	"ackslimit": 3000,
	"announce": false,
	"bind": "",
	"chatlogging": true,
	"conncookies": true,
	"connseedtime": 300000,
	"cookielogging": false,
	"db_log_queries": false,
	"db_logging": false,
	"filterscripts": [
		"ferriswheel",
		"flymode"
	],
	"gamemodes": [
		"bare",
		"grandlarc"
	],
	"gamemodetext": "Unknown",
	"hostname": "SA-MP Server",
	"incar_rate": 30,
	"lagcompmode": 1,
	"language": "SA-MP Server",
	"lanmode": false,
	"logqueries": false,
	"logtimeformat": "[%H:%M:%S]",
	"mapname": "San Andreas",
	"max_players": 50,
	"maxnpc": 0,
	"messageholelimit": 3000,
	"messageslimit": 500,
	"minconnectiontime": 0,
	"nosign": "",
	"onfoot_rate": 30,
	"password": "",
	"playertimeout": 10000,
	"plugins": [],
	"port": 8192,
	"query": false,
	"rcon": false,
	"rcon_password": "nicememe",
	"sleep": 5,
	"stream_distance": 200,
	"stream_rate": 1000,
	"timestamp": true,
	"weapon_rate": 30,
	"weburl": "bigeti.de"
}

Capture SIGINT to kill container

Repeated uses of --container leak containers and closing sampctl does not close the container it started. Capturing SIGINT and performing a graceful shutdown is needed.

implement a flag to run as a docker container

sampctl run --container should instead start a docker container with the southclaws/sampctl:latest image and mount the current directory to /samp then execute sampctl run inside the container.

This would speed up development as the user would never need to worry about running their dev server on Windows and thus not need to use .dll plugins or any of the other oddities.

Build configurations in pawn.json

pawn.json should contain a section for defining one or more build configurations. A build configuration should allow specifying the compiler version, various flags and constant definitions.

Example of proposed format:

{
	"entry": "gamemodes/ScavengeSurvive.pwn",
	"builds": [
		{
			"name": "debug",
			"version": "3.10.4",
			"args": ["-d3", "-O0"],
			"vars": {
				"MAX_PLAYERS": "32",
				"MYSQL_PASSWORD": "1234"
			}
		}
		{
			"name": "production",
			"version": "3.10.3",
			"args": ["-O2"],
			"vars": {
				"MAX_PLAYERS": "300",
				"MYSQL_PASSWORD": "$MYSQL_PASSWORD"
			}
		}
	]
}

Another idea I had was defining constant values as environment variables with the $ prefix (with the ability to escape with \$ if you want the value to actually contain a literal $).

Split codebase into packages

The codebase is growing now and should be split into modules. These modules should be split based on subcommands as well as a common package for shared functionality.

Add support for local dependencies

The dependencies entries in pawn.json should allow local paths via file:// scheme for private dependencies or those not on GitHub. Just as a convenience tool too, in case the existing dependency tool fails for any reason.

Recursive Dependency Discovery

Once a dependency has been ensured, the app should look for a pawn.json inside its directory, parse the dependencies section and add any new dependencies to the ensure process.

This may get easier to implement once the ensure process is made concurrent and operates more like a thread-safe queue.

samp.json

Like the attribute gamemode , the attributes filterscripts and plugins should be defined as string arrays aswell.

Add --container configuration to samp.json

Required configuration should be:

  • Volume mounts
  • Network to join (for user-defined bridge networks or host network)
  • Restart policy

Proposed field container:

{
    "container": {
        ...
    }
}

server.cfg generator should be platform aware

If a user writes in their samp.json:

{
    "plugins": [
        "FileManager",
        "Whirlpool",
        "cTime"
    ]
}

On windows, the generated config should be fine on its own.

On linux, the generated config:

  • use .so extensions
  • check if file exists with a different case, if so, change value to match filename

Absolute paths in "--dir" are concatenated wrong

Specifying an absolute path in "--dir" doesn't work.

panic: GetFileAttributesEx X:\cs\SAMPLauncherNET\SAMPLauncherNET\bin\Debug\X:\cs\SAMPLauncherNET\SAMPLauncherNET\bin\Debug\development\samp-npc.exe: Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.

goroutine 1 [running]:
main.exists(0x115acf80, 0x78, 0x2)
        C:/Users/south/go/src/github.com/Southclaws/sampctl/download.go:211 +0x74
main.ValidateServerDir(0x114f1500, 0x6b, 0x7670d6, 0x5, 0x30, 0x31, 0xffffffe1)
        C:/Users/south/go/src/github.com/Southclaws/sampctl/download.go:184 +0xa4
main.Run(0x76ea79, 0x16, 0x7670d6, 0x5, 0x114f1500, 0x6b, 0xdb4730, 0x0)
        C:/Users/south/go/src/github.com/Southclaws/sampctl/run.go:15 +0x53
main.main.func2(0x111aa420, 0x0, 0x111aa420)
        C:/Users/south/go/src/github.com/Southclaws/sampctl/main.go:84 +0x173
github.com/Southclaws/sampctl/vendor/gopkg.in/urfave/cli%2ev1.HandleAction(0x700a40, 0x114446b0, 0x111aa420, 0x112b6600, 0x0)
        C:/Users/south/go/src/github.com/Southclaws/sampctl/vendor/gopkg.in/urfave/cli.v1/app.go:490 +0xa2
github.com/Southclaws/sampctl/vendor/gopkg.in/urfave/cli%2ev1.Command.Run(0x766b8c, 0x3, 0x0, 0x0, 0x114446c0, 0x1, 0x1, 0x779ee2, 0x34, 0x0, ...)
        C:/Users/south/go/src/github.com/Southclaws/sampctl/vendor/gopkg.in/urfave/cli.v1/command.go:210 +0x999
github.com/Southclaws/sampctl/vendor/gopkg.in/urfave/cli%2ev1.(*App).Run(0x114c8460, 0x11179aa0, 0x4, 0x4, 0x0, 0x0)
        C:/Users/south/go/src/github.com/Southclaws/sampctl/vendor/gopkg.in/urfave/cli.v1/app.go:255 +0x606
main.main()
        C:/Users/south/go/src/github.com/Southclaws/sampctl/main.go:116 +0x892

Relative paths work fine, though.

Issue with "--dir"

This is what I get, when I attempt to start a server:

Starting server process './samp-server.exe'...
Exited with error: exec: "./samp-server.exe": file does not exist

samp-server.exe is in that working directory specified in --dir.

Implement object package manager based on samp-objects.com

Since 0.3.8 is coming and I'm already working on a directory site for sharing objects, it makes sense to add version control and auto-acquisition capabilities for objects too!

Since usernames and object names use the same pattern as GitHub, the patterns would be the same as code dependencies.

Proposed usage in samp.json:

{
    "gamemodes": [ "grandlarceny"],
    "plugins": "streamer",
    "objects": [
        "Southclaws/barrel",
        "samp-objects.com/J0shES/Kyle-Smith-Skin",
        "https://samp-objects.com/TommyB/SomeRoleplayNonsense"
    ]
}

Of course a server could use thousands of objects, so it would make sense to store this in a separate file, aptly named objects.json:

[
    "Southclaws/barrel",
    "samp-objects.com/J0shES/Kyle-Smith-Skin",
    "https://samp-objects.com/TommyB/SomeRoleplayNonsense"
]

Of course the actual syntax would need to specify the other parameters of AddCharModel and AddSimpleModel so they would likely be JSON objects instead of strings - however, it could be handy to define it all in a single string...

I'd love to have some feedback on this from people who have had a chance to play with the new system - ideally on some of the pitfalls or errors you have encountered that could get caught by sampctl and provide better error messages.

Implement a package init subcommand for `pawn.json` generation

Starting from an existing package should be simple for the user. This proposal is for a new package subcommand called init which will be similar to sampctl server init but for Pawn source packages.

Since SA:MP is a rather small code economy, there are rarely include name clashes (the only one I can think of is Slice's strlib and Westie's strlib) so gathering dependencies should be easy.

This can involve first asking the user for their gamemodes directory (./gamemodes/ by default) and then parsing all the .pwn source files in that directory searching for some regular expression for the #include <>/"" pattern. It will then present the user with a list of dependencies it has inferred prompting for confirmation.

Given the differences with versions on popular libraries such as MySQL and Streamer, any versioning issues must be fixed for this and the user should be prompted to provide a version from a list of tags/releases of each dependency.

Human friendly build config

Arguments like -;+, -(+, -\ are odd because the +/- syntax isn't really standard in unix argument handling.

It would be better if there were word-based config params set in the build config:

{
    "semicolons": false,
    "brackets": true
}

I'll also take this opportunity to swap the required-ness around as a lot of these flags are treated as default in the SA:MP community due to the defaults in Pawno. Some of these config fields would be used to remove the arguments from the command invocation.

sampctl init to initialise a new server

like npm init, it should ask the user a few basic questions about their server.
the command only works in a valid server dir (binaries, gamemodes/filterscripts dirs)

ask:

  • gamemode name - maybe show a list of gamemodes/*.amx?
  • filterscripts - again, show list of filterscripts/*.amx
  • plugins - handle platform specific differences
  • port number
  • rcon pass - specify one or generate randomly, score complexity?

Implement plugin binaries version control

The last piece of the puzzle for full version control, package management and package runtime.

You can create a package, grab the dependencies with sampctl project ensure and run the code to execute tests, check outputs, or quickly spin up a server to test in-game. Unfortunately it's impossible to load plugins into the runtime as there's no way to declare a plugin binary as a dependency for a project runtime only the Pawn includes for the build stage.

This should be implemented as a method of declaring plugins in samp.json so a user could use a DependencyString style path instead of just a filename:

{
	"plugins": [
		"BigETI/pawn-memory:2.0"
	]
}

And then, a runtime section should be added to pawn.json spec to allow passing a server configuration to the package runtime, which would allow the specification of plugin versions.

{
	"entry": "sometest.pwn",
	"runtime": {
		"plugins": [
			"BigETI/pawn-memory:2.0"
		]
	}
}

Implement build plugins for pre-processing/pre-compiling

Inspired by Webpack, this addition will enable commands to be run on the input file of a project build.

Example:

{
    "entry": "gamemodes/my_gamemode.pwn",
    "output": "gamemodes/my_gamemode.amx",
    "builds": [
        {
            "name": "compile",
            "plugins": [
                ["sed", "-i", "'s/replace_me/__I_GOT_REPLACED__/g'", "-"]
            ]
        }
    ]
}

This simple example would pipe the contents of the entry file to the sed command which would simply do a replacement.

This could lead to some powerful compilation toolchains and enable easy pre-compiling for things like this: Southclaws/ScavengeSurvive#441

At first it would just be a basic command to execute but it could become more complex in future.

I would also like to write a simple tool that would automatically run a command across all #include'd files for a given Pawn entry file, to make modular gamemodes easier to process. This likely hinges on the development of pawn-parser!

Add exit detection for running unit tests or quick scripts

Similar to #41 however this is more of an automated solution. Sometimes you may not know how long a set of unit tests will take to run. It would be best to just let sampctl decide by monitoring the server process output for moments of silence and kill it after no message has come out of stdout for x seconds.

Similar to --timeout this would be for sampctl server run and sampctl package run. I haven't decided on the actual flag name but it would be something like --autokill followed by a time value such as 100ms, 3s or 1m - the default value for this would be something logical based on tests, probably 1 second.

Oh and it should also be a build config value (maybe only a build config and forget the flag completely?)

It would simply work by setting a timer before scanning the stdout/stderr of the server child process and each time a line is scanned the timer is reset. When the timer ends, the server child process is killed.

Implement an automatic Pawn compiler download and installation with guide

Many users have their Pawno folder in the server directory, which can lead to confusion on multiple projects but it's just the way people stick to since the server package is like that.

Most other languages put their compiler/interpreter on the system PATH variable so it can be executed from anywhere.

The tool should automatically download the Pawn compiler (not Pawno) by Zeex (maybe the default one later if there is demand) and install it at either ~/pawn or C:\pawn then issue a link to the user to guide them through the process of adding the directory to their system PATH variable, which will be hosted on this repository's wiki.

This will also help with #9 to facilitate with instant compilation and running of scripts.

Remote compile

Remote compile will combine #12 and #20 where two instances of sampctl running on separate hosts can work together to facilitate remote compilation.

This is mainly because Scavenge and Survive only works on Linux and the containerised version doesn't work because of some weird IO issue with the File Manager plugin.

So, this is how it'll work:

  • sampctl A running on dev machine (windows or mac)
  • sampctl B running on linux server machine
  • A is connected to B via a HTTP or socket connection

When A detects a .pwn file change in the package directory, it grabs the file contents and path and sends it to B. B then writes the file to disk on the given path while in a separate thread, B is running the normal hot-reload code which detects the file change and triggers a compile which (if it's running in hot-reload runtime mode) will restart the running server automatically.

The compilation output would be streamed back to A in order to provide feedback for IDE usage etc.

Roadmap:

  • Basic auto compile when .pwn changes detected
  • Auto compile + run a server and restart when .amx changes
  • HTTP server mode
  • HTTP client mode for sending commands to a server running in HTTP mode
  • Remote compile

Implement build config constants via environment variables

Something that was left out of the build configs in 1.3.0 release, constant values using environment variables:

"constants": { "MYSQL_PASSWORD": "$MYSQL_PASSWORD" }

A build constant uses an env var value if it's prefixed with a $, if the value doesn't need to be from an env var, the $ should be escapable via \$.

doesn't seem to support directories name with spaces?

I maybe wrong as I just began using samp ctl and realised, how useful it was!

Title says so^

Input
C:\Users\Patrick>sampctl server init --dir E:\PAWN\San Andreas Multiplayer\

Output as
C:\Users\Patrick>sampctl server init --dir E:\PAWN\San\

therefore showing the error
Exited with error: failed to initialise server: open E:\Developer\San\samp\samp.json: The system cannot find the path specified.

EDIT: Just wondering so instead of pressing compile F5 to compile on your Text Editor, I just run sampctl package build? is there any work around to compile it using sampctl when F5 is pressed for example?

Add --timeout for `run` subcommands

When running unit tests, the user does not intend to actually host a server. However, the SA:MP server process is a blocking, continual process which means it only exits when it errors internally or is closed externally via a signal.

--timeout for sampctl server run and sampctl package run will solve this with minimal effort.

It would simply set a timer when the process starts and kill the process when the time runs out.

Write a installation one-liner

In order to streamline the installation process and get the app into the hands of users as fast as possible, there should be a nice one-liner to run on a Linux terminal to install it.

Now that GoReleaser is using FPM to build .deb and .rpm packages, it should be trivial to add a script to the repository that can be executed via a nice one liner, similar to how Pachyderm and many other CLI tool developers do it. (http://pachyderm.readthedocs.io/en/latest/getting_started/local_installation.html#pachctl, https://gist.github.com/btm/6700524, etc)

Pachyderm's looks like this:

$ curl -o /tmp/pachctl.deb -L https://github.com/pachyderm/pachyderm/releases/download/v1.6.0/pachctl_1.6.0_amd64.deb && sudo dpkg -i /tmp/pachctl.deb

So I could probably generate a similar looking one on the TravisCI build and maybe add it to the readme.md automatically somehow...(?)

Make `sampctl pakage ensure` concurrent

Now that it works, it should be optimised because there's a lot of waiting while ensuring the dependencies of a large project such as Scavenge and Survive.

Add a `constraints` to Package definition

Constraints should contain various non-package dependencies such as compiler version, compiler arguments, and anything else I can think of.

This could facilitate more helpful error messages of weird edge cases with certain libraries.

Proposal/example:

{
    "user": "Misiur",
    "repo": "YSI-Includes",
...
    "constraints": {
        "compiler_version": "3.10.x",
        "compiler_args": [
            { "arg": "-(+", "constraint": "required" },
            { "arg": "-;+", "constraint": "required" },
            { "arg": "-\\+", "constraint": "required" },
            { "arg": "-Z+", "constraint": "required" },
        ]
    }
}

@Y-Less am I correct in thinking YSI requires those arguments to compile? I seem to remember having trouble if I omitted some of them (can't remember which).

Typo on README.md

An Easier Way To Configure via samp.json

Everybody loves JSON! An

😄

Windows stuff that needs to be done

Trust Windows to complicate things... but at the end of the day, it's all in the name of security and protecting the user so I can't complain.

Apparently I need an app manifest embedded in the binary in order to declare to Windows what permissions the app requires (writing to ~/.samp etc...)

Help from Windows experts would be appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.