KPM Integration: Knight Package Manager CLI

KPM Integration: Knight Package Manager CLI
KPM (Knight Package Manager) is a command-line tool developed in TypeScript and distributed as an npm package (kpm.client). Its purpose is to streamline the process of managing Knight packages, such as Cmdr, in a structure similar to npm. With KPM, you can install, update, and uninstall Knight packages from your desktop CLI, allowing for easy management of game development dependencies.
This article will guide you through setting up KPM and provide example usage for managing packages within your Knight framework projects.
Installing KPM
To get started with KPM, you’ll need to install it globally via npm. Ensure you have Node.js and npm installed on your system.
Once installed, you can access KPM through your command line using the kpm command.
Example Usage of KPM
Let’s look at a basic example of using KPM in your desktop CLI.
Basic Commands
Here are some of the most commonly used commands in KPM, along with example usage.
1. Installing a Package
To install a Knight package (such as Cmdr), use the install command. You can specify the package and an optional version:
This will install the latest version of the Cmdr package. You can also specify a version:
This installs version 1.2.3 of the Cmdr package.
2. Uninstalling a Package
To uninstall a package, use the uninstall command:
This removes the Cmdr package from your Knight project.
3. Updating Packages
To update all installed packages to their latest versions, use the update command:
You can also update a specific package by specifying its name:
This updates only the Cmdr package to the latest version.
4. Checking for Updates
To check if a specific package has a new version available without installing the update, use the check-update command:
This will display information about whether a new version of the Cmdr package is available.
5. Outputting the Manifest of a Package
To view the manifest (for example a NPM package.json) of a specific package, use the output-manifest command:
This will print the package’s manifest to the console, showing details such as the version, dependencies, and other metadata.
6. Publishing Packages
KPM also allows you to publish packages. To open the KPM publish form in your default browser, use the publish command:
This will redirect you to the form where you can submit your package to the KPM repository.
7. Package Count
To get a count of all installed packages, use the count command:
This will display the total number of packages installed in your project.
Advanced Commands
KPM offers several advanced commands to help you further customize and manage your environment.
1. Setting the Installation Path
By default, KPM installs packages in the current running directory, but you can change this location using the set-path command:
This sets the new path where packages will be installed.
To verify the current path, use:
2. Unsafe Mode
KPM has a feature called "unsafe mode," which allows you to enable or disable certain operations that may pose risks to your game’s stability. You can toggle unsafe mode using the unsafemode command:
To disable it:
3. Reinstalling KPM Client
If you need to reinstall or update the KPM client to the latest version, you can use the npm command:
This command will uninstall and reinstall KPM to ensure you have the latest version of the CLI.
4. Logging In
To access certain features, such as downloading private packages, you need to be logged in. Use the login command to log in and save your authentication key:
Follow the prompts to log in securely.
Example Workflow
Here’s an example of a typical workflow using KPM in a project:
Install Cmdr:
Set a Custom Installation Path:
Check for Updates for Cmdr:
Update All Packages:
Output Manifest for Cmdr:
Log in to KPM:
This workflow allows you to efficiently manage the packages used in your Knight framework project without leaving your desktop CLI.
Last updated
Was this helpful?