Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
Command Reference

init


The blocklet init command is an interactive utility that scaffolds a new Blocklet project in the current working directory. It walks you through a series of prompts to generate a blocklet.yml metadata file and creates the essential files and directories needed to get started.

This command is ideal when you want to start a new project from scratch. If you prefer to start from a pre-built template, consider using the blocklet create command instead. For a deeper dive into the files generated, refer to the Project Structure documentation.

How It Works#

The init command follows a clear process to set up your project:

Yes, DID is valid

Yes, DID is invalid

No

No

Yes

Yes

No

Start: blocklet init

blocklet.yml exists?

Exit

Generate new DID

Update blocklet.yml and Exit

Read defaults from package.json?

--yes flag used?

Ask interactive questions

Use default answers

Gather answers

--did flag provided?

Use provided DID

Generate new DID via Wallet

Construct final metadata

Create project files (blocklet.yml, logo.png, etc.)

End


Usage#

To start the interactive initialization process, simply run the command in your project's root directory:

blocklet init

Interactive Prompts#

If you run the command without any flags, it will prompt you for the following information:

Prompt

Description

Default Source

blocklet title

The human-readable name of your blocklet.

The current directory's name.

Please write concise description:

A short summary of what your blocklet does.

The description from package.json if available.

What's the group of the blocklet?

The type of blocklet you are creating (e.g., dapp, static).

dapp

What's the entry point of the blocklet?

The main file that starts your blocklet (e.g., index.js).

Varies based on the selected group.

Command Options#

You can modify the behavior of init using the following command-line options:

Option

Description

--yes, -y

Skips all interactive prompts and uses the default values. This is useful for automated scripts.

--force

Similar to --yes, forces the initialization with default values.

--did <did>

Provides a pre-existing DID for the blocklet, skipping the wallet-based DID generation step.

--connect-url <url>

Specifies a custom Blocklet Store URL to use for generating a new DID. Defaults to the official store.

--monikers <name>

A special-purpose flag that only generates a DID with the given name and prints it, then exits. It does not initialize a project.

Generated Files and Directories#

Upon successful completion, blocklet init creates the following structure in your project directory:

File / Directory

Description

blocklet.yml

The core metadata file that defines your blocklet's properties.

blocklet.md

A Markdown file for your blocklet's detailed description and documentation.

screenshots/

A directory to store screenshots of your blocklet's user interface.

logo.png

A default placeholder logo for your blocklet.

.gitignore

A standard .gitignore file to exclude build artifacts and dependencies from version control.

index.js or index.html

A basic entrypoint file is created depending on the blocklet group (dapp or static).

Examples#

Interactive Initialization#

Run the command and answer the prompts to create your blocklet.yml.

$ blocklet init
This utility will walk you through create such files and folders(if not exists):
- blocklet.yml
- blocklet.md
- screenshots/

It only covers common items, if you want to check all items, please visit:
https://github.com/ArcBlock/blocklets#keyinfo-blockletjson

Press ^C to quit.
? blocklet title: My First Blocklet
? Please write concise description:: A simple blocklet to demonstrate the init command.
? What's the group of the blocklet? dapp
? What's the entry point of the blocklet? index.js
... (DID generation with Wallet) ...
✔ Meta file blocklet.yml was created
✔ Doc file blocklet.md was created
✔ Screenshots dir screenshots/ was created
✔ logo.png was created
✔ index.js was created

Non-Interactive Initialization#

Use the --yes flag to accept all default values and create the project files automatically.

blocklet init --yes

Using a Pre-existing DID#

If you already have a DID you wish to assign to the blocklet, you can provide it directly.

blocklet init --yes --did z8iZpky...uN7hG9k


After initializing your project, you have a basic structure ready for development. The next step is to add your application logic and run it locally. For guidance on this, proceed to the Develop a Blocklet guide.