The Package Manager is OwnLang's command-line utility for project management and dependency handling. It provides the own
command for initializing projects, managing dependencies, and running scripts. The system uses a global registry hosted on GitHub and manages local project configurations through own-package.json
files.
For information about other CLI tools like the beautifier and linter, see CLI Tools and Utilities. For details about the REPL interactive environment, see Interactive REPL.
The package manager is implemented as a collection of OwnLang classes that work together to provide comprehensive project management functionality.
Package Manager Class Hierarchy
Sources: ownlang-desktop/src/main/resources/scripts/own.own25-29 ownlang-desktop/src/main/resources/scripts/own/Own.own5-8
The package manager creates a shared context object that provides common services to all components:
Context Property | Purpose | Implementation |
---|---|---|
DEBUG | Debug logging flag | Environment variable OWN_DEBUG |
TMPDIR | Temporary directory path | Environment variables TEMP /TMP |
OSNAME | Operating system detection | Java system property os.name |
logger | Colored console output | Custom logging with ANSI colors |
registry | Global package registry | GitHub-hosted JSON registry |
config | Project configuration | own-package.json management |
packages | Package operations | Download, install, usage display |
projects | Project scaffolding | Default file generation |
Sources: ownlang-desktop/src/main/resources/scripts/own.own20-29 ownlang-desktop/src/main/resources/scripts/own.own10-18
The package manager supports multiple commands through argument pattern matching in the main script:
Command Routing in own.own
Sources: ownlang-desktop/src/main/resources/scripts/own.own31-40
Command | Syntax | Purpose |
---|---|---|
init | own init | Initialize new project with default structure |
add | own add <package> | Add package dependency to configuration |
install | own install | Download all dependencies from configuration |
run | own run [script] | Execute project scripts (default or named) |
usage | own usage <package> | Display package usage documentation |
Sources: ownlang-desktop/src/main/resources/scripts/own/Own.own61-74
Project configuration is managed through the own-package.json
file, which follows a structured format similar to Node.js package.json.
The Config
class handles all configuration operations and provides default values:
Property | Default Value | Purpose |
---|---|---|
name | Current directory name (sanitized) | Project identifier |
version | "1.0.0" | Project version |
author | Current user name | Project author |
program | "main.own" | Main program file |
scripts | {"default": ["$ownlang$", "-f", "$program$"]} | Executable scripts |
dependencies | {} | Package dependencies |
Sources: ownlang-desktop/src/main/resources/scripts/own/Config.own41-57
Configuration Lifecycle Management
Sources: ownlang-desktop/src/main/resources/scripts/own/Config.own12-38
The package manager uses a global registry hosted on GitHub to discover and download packages.
Registry Data Flow
Sources: ownlang-desktop/src/main/resources/scripts/own/Registry.own4 ownlang-desktop/src/main/resources/scripts/own/Registry.own10
The system supports different package types, with GitHub Gists being the primary supported format:
Package Type | Source | File Resolution |
---|---|---|
gist | GitHub Gist API | Raw URL extraction from JSON response |
Default | Not implemented | Empty array returned |
The download process involves:
own-modules/<package>/
directoryown-package.json
Sources: ownlang-desktop/src/main/resources/scripts/own/Packages.own81-93 ownlang-desktop/src/main/resources/scripts/own/Packages.own104-114
Packages can provide usage documentation through .usage.own
files. The usage
command displays this documentation:
Usage Documentation Display
Sources: ownlang-desktop/src/main/resources/scripts/own/Packages.own129-144
The Projects
class handles project initialization and default file creation.
When own init
is executed, the system:
own-package.json
with defaultsThe default program template creates a simple "Hello, world!" application:
Sources: ownlang-desktop/src/main/resources/scripts/own/Projects.own6-8 ownlang-desktop/src/main/resources/scripts/own/Own.own10-17
The package manager supports running predefined scripts through variable substitution:
Variable | Replacement | Purpose |
---|---|---|
$ownlang$ | ownlang or ownlang.cmd | OwnLang executable (OS-specific) |
$program$ | Configuration program value | Main program file |
$dir$ | Current working directory | Project directory path |
Scripts are executed using Java's ProcessBuilder
with inherited I/O for seamless integration with the terminal environment.
Sources: ownlang-desktop/src/main/resources/scripts/own/Own.own38-59 ownlang-desktop/src/main/resources/scripts/own/Own.own3
Refresh this wiki