@airtable/blocks-cli

中文文档
3.0.3发布于 2026/04/30UNLICENSEDTypeScriptCommonJS近 30 天下载 2.1万

Official command line tool for Airtable blocks development

原始使用文档
文档目录13 节
  1. block add-remote BLOCKIDENTIFIER REMOTENAME
  2. block help [COMMAND]
  3. block init BLOCKIDENTIFIER BLOCKDIRPATH
  4. block list-remotes
  5. block release
  6. block remove-remote REMOTENAME
  7. block run
  8. block set-api-key [APIKEY]
  9. block submit
  10. CSS Support
  11. Using code from other directories
  12. Customizing the webpack config
  13. Using a custom bundler

@airtable/blocks-cli

Command line tool for Airtable Blocks development.

Installation

To install or update the block cli, run:

npm install --global @airtable/blocks-cli

Usage

$ npm install -g @airtable/blocks-cli
$ block COMMAND
running command...
$ block (-v|--version|version)
@airtable/blocks-cli/3.0.3 darwin-arm64 node-v22.14.0
$ block --help [COMMAND]
USAGE
  $ block COMMAND
...

Commands

block add-remote BLOCKIDENTIFIER REMOTENAME

[Beta] Add a new remote configuration

USAGE
  $ block add-remote BLOCKIDENTIFIER REMOTENAME

OPTIONS
  -h, --help  show CLI help

EXAMPLE
  $ block add-remote app12345678/blk12345678 new-remote

block help [COMMAND]

display help for block

USAGE
  $ block help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

block init BLOCKIDENTIFIER BLOCKDIRPATH

Initialize an Airtable extension project

USAGE
  $ block init BLOCKIDENTIFIER BLOCKDIRPATH

OPTIONS
  -h, --help           show CLI help
  --template=template  [default: https://github.com/Airtable/apps-hello-world]

EXAMPLE
  $ block init app12345678/blk12345678 hello-world-extension --template https://github.com/Airtable/apps-hello-world

block list-remotes

[Beta] List remote configurations

USAGE
  $ block list-remotes

OPTIONS
  -h, --help  show CLI help

EXAMPLE
  $ block list-remotes

block release

Release a build to an Airtable base

USAGE
  $ block release

OPTIONS
  -h, --help       show CLI help
  --remote=remote  [Beta] Configure which remote to use

EXAMPLE
  $ block release

block remove-remote REMOTENAME

[Beta] Remove a remote configuration

USAGE
  $ block remove-remote REMOTENAME

OPTIONS
  -h, --help  show CLI help

EXAMPLE
  $ block remove-remote old-remote

block run

Run the extension locally

USAGE
  $ block run

OPTIONS
  -h, --help       show CLI help
  --port=port      [default: 9000] HTTPS port the server listens on. The server will listen for HTTP on PORT + 1.
  --remote=remote  [Beta] Configure which remote to use

EXAMPLE
  $ block run

block set-api-key [APIKEY]

Set a personal access token (with block:manage scope) for an Airtable account to upload to

USAGE
  $ block set-api-key [APIKEY]

OPTIONS
  -h, --help             show CLI help
  --location=(user|app)  [default: user]

EXAMPLE
  $ block set-api-key
  $ block set-api-key TOKEN
  $ block set-api-key --location app TOKEN

block submit

Submit extension for review for listing in the the Airtable Marketplace

USAGE
  $ block submit

OPTIONS
  -h, --help       show CLI help
  --remote=remote  Configure which remote to use

EXAMPLE
  $ block submit

New features in v2

CSS Support

The new CLI supports css files within your extension by default. The default webpack bundler is configured with css-loader and style-loader. This means you can import a css file into your extension. Example:

// styles.css
.red {
  color: red;
}
import {initializeBlock} from '@airtable/blocks/ui';
import React from 'react';
import './styles.css'

function MyExtension() {
    return <div className="red">Hello world</div>;
}

initializeBlock(() => <MyExtension />);

Using code from other directories

The new CLI allows this method of code-sharing by allowing “sibling directories” outside the source directory to be bundled. Those other directories can include npm imports based on link or file.

More details and an example can be found here.

Customizing the webpack config

By default, the CLI uses webpack to bundle your code. Out of the box, it supports using plain JavaScript or TypeScript and styling via CSS files. If you want to customize the webpack config further, you can do so by installing the @airtable/blocks-webpack-bundler package. For more information about installing this package and customizing the webpack config, see the README for the @airtable/blocks-webpack-bundler package at packages/webpack-bundler/README.md.

Using a custom bundler

If customizing the webpack config as described above does not solve your use case, it is also possible to replace the bundler entirely with a custom implementation. This is will require a significant amount of work.

Custom bundlers allow users to replace the CLI's built-in bundling functionality that turns extension source code into publishable artifacts. Your custom bundler's output must conform to the Airtable platform's expected format, calling convention, and file structure.

Unlike other bundling systems, which allow configurability by composing multiple single-purpose plugins (or replacing just part of the bundling pipeline), this CLI exposes a simpler bundler extension API that expects a single, complete replacement of bundling functionality.

To use a custom bundler:

  1. Save your bundler as a JavaScript file (i.e. index.js). The bundler must be a CommonJS module. If your bundler in written in TypeScript, you must use the transpiled version as the entry file.

  2. Then, change the block.json ‘bundler.module’ option to point at your new bundler entry file; i.e.:

// block.json
{
    “bundler”: {
        “module”: “./bundler/index.js”
    }
}
  1. Once the change is made, restart your dev server (if running on a dev server).

A bundler needs to implement the following APIs:

class Bundler {
    async bundleAsync(options: ReleaseBundleOptions): Promise<void> {
        // implement release build
    }

    async findDependenciesAsync(options: SubmitFindDependenciesOptions): Promise<{files: Array<string>}> {
        // used in `block submit`
    }

    async startDevServerAsync(options: RunDevServerOptions & RunDevServerMethods): Promise<void> {
        // implement run development build
    }

    async teardownAsync(): Promise<void> {
        // implement any work needed to gracefully
        // close bundler process
    }
}

export default function() {
    return new Bundler();
}

For more details about the bundler API, see src/bundler/bundler.ts

Static assets are still not supported by default, but you can now swap in your own bundler that supports this.

版本与发布记录

@airtable/blocks-cli 共发布 103 个版本,首次发布于 2019/05/25;过去 12 个月发布了 4 个版本。

版本发布日期距今
3.0.3latest2026/04/306 个月前
2.0.12v2-latest2026/04/306 个月前
3.0.22026/04/296 个月前
2.0.112026/04/296 个月前
3.0.12025/09/181.1 年前
3.0.02025/09/181.1 年前

其他发布通道:beta → 2.0.0-beta.7,next → 2.0.8-rc.1,v2-latest → 2.0.12。

关于 @airtable/blocks-cli 的常见问题

@airtable/blocks-cli 是什么?

Official command line tool for Airtable blocks development

如何安装 @airtable/blocks-cli?

在项目目录运行 npm install @airtable/blocks-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 block,可以用 npx block 直接运行。

@airtable/blocks-cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@airtable/blocks-cli 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@airtable/blocks-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=10.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@airtable/blocks-cli 可以商用吗?

@airtable/blocks-cli 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@airtable/blocks-cli 的下载量有多少?

根据 npm 官方下载统计,@airtable/blocks-cli 在 2026/10/05 – 2026/11/03 这 30 天内被下载 20,734 次,日均约 691 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@airtable/blocks-cli 还在维护吗?

最新版本 3.0.3 发布于 2026/04/30(6 个月前);至今共发布 103 个版本,其中过去 12 个月发布了 4 个;首次发布于 2019/05/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。