Spork Utility Collection for Janet

repository·master·Indexed 41 days ago

https://github.com/janet-lang/spork

A collection of utility modules for the Janet programming language, providing functionality not included in the Janet core library. It includes the janet-pm project manager for dependency and build management, janet-format for source code formatting, and janet-netrepl for networked REPL sessions.

Tokens
3.8K
Snippets
11
Records
21
Agent score
51%

What's inside Spork

  1. Key features of miniz

    master

    Miniz provides several specialized capabilities for data compression and archive management:

    • zlib Replacement: Acts as a drop-in replacement for the most commonly used zlib APIs.
    • Stream-based Processing: Supports coroutine-style stream processing (not block-based), allowing API functions to be called one byte at a time.
    • Low-level Codecs: Provides tdefl (compressor) and tinfl (decompressor) with simple state structs that can be saved/restored via memcpy. These APIs do not use the heap.
    • Archive Manipulation: Includes a set of APIs for reading, writing, and appending .ZIP format archives.
    • Image Support: Includes functions for writing .PNG format image files.
    • Portability: Written in plain C, tested with GCC, clang, and Visual Studio.
  2. View Spork documentation locally

    master

    Spork documentation is written in Mendoza. To view it as a local static site, follow these steps:

    1. Ensure Janet and jpm are installed.
    2. Install Mendoza globally: [sudo] jpm install mendoza.
    3. Clone the Spork repository and enter the root directory.
    4. Build and serve the documentation using Mendoza.
    5. Access the site at http://localhost:8000 while the server is running.
    # Install Mendoza
    [sudo] jpm install mendoza
    
    # Build and serve docs from spork root
    mdz build && mdz serve
  3. Integrate miniz into a project

    master

    Miniz is a single-file C library that implements zlib (RFC 1950) and Deflate (RFC 1951) standards. You can integrate it into your project in two ways:

    1. Manual Integration: Download the miniz.c and miniz.h files from the releases page and add them directly to your source tree.
    2. Build System Integration: Use it as a CMake or Meson module, or via your preferred build system.
    // Add these files to your project
    miniz.c
    miniz.h
  4. Use Spork in your Janet programs

    master

    Spork is a collection of utility modules. You can use them in two ways:

    1. Import everything: Use (use spork) to import all available functionality into your current namespace.
    2. Selective import: If you only need specific functionality, use import for the specific modules required to keep your namespace clean.
    # To import all features
    (use spork)
    
    # To import only specific parts (example pattern)
    (import spork/module-name)
  5. Install Spork

    master

    Depending on your Janet version, use one of the following methods to install Spork.

    For Janet 1.38.0 and newer

    Use the built-in --install flag. This installs modules to $JANET_PATH and executable scripts to $JANET_PATH/bin.

    For Janet versions prior to 1.38.0

    If your version supports the bundle module, use the bundle/install function.

    Using JPM (Legacy)

    If you are using the legacy JPM package manager, use the install command.

    # Janet 1.38.0+
    [sudo] janet --install .
    
    # Prior to 1.38.0 (with bundle support)
    [sudo] janet -e '(bundle/install ".")'
    
    # Legacy JPM
    [sudo] jpm install spork
  6. Build and Test Spork from source

    master

    If you are developing or building Spork from the source repository, use the following commands. Note that Spork must be installed to test properly.

    Build

    Use the bundle module to run the build process.

    Test

    Install the current directory first, then run the check command via the bundle module.

    # Build
    janet -l ./bundle -e '(build)'
    
    # Test
    janet --install .
    janet -l ./bundle -e '(check)'
  7. Use janet-pm for project and global management

    master

    janet-pm is the Janet Project Manager, a build tool for Janet. It can be used in two modes:

    1. Project Mode: Run from a directory containing a project.janet file to perform operations on that specific project.
    2. Global Mode: Run from anywhere to perform operations on the global module cache (modpath).

    Note that commands requiring write permission to the modpath are considered privileged and may require superuser privileges in some environments.

  8. Create new Janet projects

    master

    Use these commands to scaffold new project structures in a directory named name.

    • new-project name: Standard Janet project.
    • new-simple-project name: A project that can be distributed without requiring spork.
    • new-c-project name: A project containing C+Janet code.
    • new-exe-project name: A project designed to produce an executable.
  9. Manage global packages and environments with janet-pm

    master

    Use these commands to manage the global module cache (modpath) or create new environments:

    • install [repo...]: Install remote bundles and their required dependencies.
    • clear-cache: Clear the cache of saved remote dependencies.
    • list-pkgs [search]: List packages from the remote package listing. If search is provided, it filters by that string. If omitted, prints the entire listing.
    • env name: Create an isolated environment for installing Janet dependencies and scripts.
    • new-project [name]: Create a new Janet project in the directory name.
    • new-simple-project [name]: Create a new Janet project in name that can be distributed without spork.
    • new-c-project [name]: Create a new C+Janet project in name.
    • new-exe-project [name]: Create a new project for an executable in name.
  10. Manage project-specific dependencies and builds

    master

    Run these commands from within a directory containing a project.janet file.

    • deps: Install dependencies for the current project.
    • install (repos...): Install project artifacts (shorthand for janet --install .).
    • uninstall (repos...): Uninstall project artifacts (shorthand for janet --uninstall {current-project-name or repos}).
    • reinstall (repos...): Reinstall project artifacts.
    • build: Build all artifacts in the build/ directory (shorthand for run build).
    • clean: Remove generated files/artifacts by calling the (clean) hook.
    • clean-build: Performs a clean followed by a build.
    • test: Run tests located in the test/ directory. It patches module paths to load built native code without installation (shorthand for run check).
    • prune: Remove bundles marked for auto-remove that have no dependents.
    • save-lockfile (dest): Save currently installed bundles to a lockfile (defaults to lockfile.jdn).
    • load-lockfile (src): Install all bundles from the specified lockfile (defaults to lockfile.jdn).