cbs-block
v1.0.11
Published
SDK for creating CodeBlock Studio blocks
Maintainers
Readme
🚀 CodeBlock Studio SDK (CLI)
The professional toolkit for building, testing, and sharing CodeBlock Studio extensions.
Built for performance. Designed for developers.
📦 Installation
Install globally to use the cbs-block command anywhere:
npm install cbs-block -g🛠️ Feature Highlights
- Code-First Workflow: Build complex blocks with full folder structures, supporting
index.js/ts,package.json, and localnode_modules. - Advanced Dependency Bundling: Automatically bundle popular npm packages (axios, lodash, moment) into blocks for seamless execution.
- Integrated Unit Testing: Run logic tests instantly with
cbs-block test(now supports async functions). - Micro-Benchmarking: Performance-test your logic with
cbs-block bench(100k iteration analysis). - Integrated Tutorials: Every new project includes a beautiful, CSS-rich
tutorial.html. View it viacbs-block tutorial. - VSIX-Style Packaging: Bundle your workspace into a professional
.cbsextextension with one command.
🔧 Advanced Dependency Bundling
The SDK now supports automatic bundling of popular npm packages:
Supported Packages
- axios: HTTP client for API calls
- lodash: Utility functions for data manipulation
- moment: Date/time formatting and parsing
Example: Weather API Block
// In your index.js
const axios = require('axios');
const _ = require('lodash');
const moment = require('moment');
async function run(inputs) {
const response = await axios.get(`https://api.weather.com/${inputs.city}`);
const data = _.pick(response.data, ['temp', 'description']);
return {
temperature: data.temp,
description: _.capitalize(data.description),
timestamp: moment().format('YYYY-MM-DD HH:mm:ss')
};
}Building with Dependencies
# Install dependencies
npm install axios lodash moment
# Build with automatic bundling
cbs-block build
# Output shows bundled packages
📦 Bundling axios...
📦 Bundling lodash utilities...
📦 Bundling moment.js...
✔ Built successfully!🚀 Quick Start
1. Initialize a Project
Create a new workspace for your block library:
cbs-block init MyAwesomePack
cd MyAwesomePack2. Create a Block
Generate a professional directory-based block:
cbs-block create MyBlock3. Develop & Test
Open index.js, write your logic, and test it:
cbs-block build
cbs-block test myblock.cbsblock4. Pack & Share
Bundle your workspace into a professional extension:
cbs-block pack🛠️ Command Reference
| Command | Description |
| --- | --- |
| init [name] | Initialize a new block project workspace. |
| create [name] | Scaffold a new block (supports Directory or Single-File mode). |
| build [dir] | Compile a directory block into a production .cbsblock with dependency bundling. |
| pack | Bundle your workspace into a professional .cbsext extension. |
| test <file> | Run logic unit tests with mock data (now supports async functions). |
| bench <file> | Benchmark block logic performance (iterations & μs). |
| tutorial | Open the integrated developer guide in your browser. |
| link | Link local blocks to your CodeBlock Studio installation. |
| publish | Deploys your package to the global CBS Marketplace. |
| site | Generate a themed documentation website for your project. |
| doc <file> | Generate a markdown README for a specific block. |
| lint | Validate block definitions for schema compliance. |
| wizard | Launch the guided template-based block creator that outputs polished .cbsblock files. |
| status | Check SDK version and environment health. |
🚀 Guided Block Wizard
cbs-block wizard walks through curated templates (Math Adder, HTTP Fetch, Web Alert) and writes a polished .cbsblock file with metadata, ports, logic, and color already substituted.
Included Templates
- File System Operator – read/write/append/delete files, list directories, glob, and mkdir from one block.
- Environment Manager – get/set/delete environment variables and load/save
.envfiles. - Database Operator – mock relational queries, inserts, updates, deletes, and table lifecycle actions.
- Network API – HTTP/WebSocket/ping/download/upload helper with consistent mock responses.
- Weather Lookup – OpenWeatherMap-based weather fetcher that falls back to mock data without an API key.
Template Library
The wizard reads templates/library.json, where each entry defines a block skeleton with {{placeholder}} tokens, default metadata (category, color, defaultName), and variables prompts that collect template-specific values (with optional sanitization for port names).
Edit templates/library.json to add or tune starters; the wizard refreshes automatically the next time it runs.
🧩 The .cbsext Format
Professional extensions are packaged as ZIP-based .cbsext files. This allows for:
- Rich Assets: Bundle icons, helper scripts, and HTML tutorials into one file.
- Enterprise Metadata: Verified publisher IDs and display names.
- Dependency Isolation: Fully bundled logic with optimized execution.
Build the future of visual coding with CodeBlock Studio.
