1. @truffle/box
Truffle project boilerplate utility
@truffle/box
Package: @truffle/box
Created by: trufflesuite
Last modified: Tue, 27 Feb 2024 01:25:25 GMT
Version: 2.1.81
License: MIT
Downloads: 314
Repository: https://github.com/trufflesuite/truffle

Install

npm install @truffle/box
yarn add @truffle/box

@truffle/box

Truffle Box management functionality.

Handles behavior for unboxing a new project from a predefined Truffle Box.

Usage

 const TruffleBox = require("@truffle/box");

// `@truffle/box` prompts when unboxing into non-empty directories & before potential overwrites
// a `force` option can be passed to force unboxing. default is false
const unboxOptions = { force: false };

// .unbox() validates & unboxes truffle box repos
// pass the current working directory as directory to unbox into
TruffleBox.unbox("https://github.com/trufflesuite/truffle-init-default", process.cwd(), unboxOptions);

// or specify relative path to unbox into (path must already exist)
TruffleBox.unbox("https://github.com/trufflesuite/truffle-init-default", "some/relativePath", unboxOptions);

Box Configuration

Truffle Boxes are configured via a required truffle-box.json file in the
box repo's root directory.

This box configuration file specifies an object containing the following
properties:

  • ignore

    A list of relative paths to files that should be removed upon box unpack.
    Useful to remove box READMEs or other artifacts that pertain to box but not
    the set-up Truffle project.

    Example:

     "ignore": [
      "README.md",
      ".gitignore"
    ]
    
  • commands

    An object mapping supported behaviors for project to invoked command strings.

    truffle unbox prints commands to screen upon unboxing for documentation
    purposes.

    Example:

     "commands": {
      "compile": "truffle compile",
      "migrate": "truffle migrate",
      "test": "truffle test"
    }
    
  • hooks

    An object to specify commands to run at particular steps in the unbox
    process. Maps strings identifying individual hooks to command strings.

    Example:

     "hooks": {
      "post-unpack": "npm install"
    }
    

Available Unbox Hooks

  • post-unpack

    If provided, runs command after box files are fetched and cleaned up for a
    new project.

    Commonly useful to install dependencies, e.g.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code