@flatfile/gecko

中文文档
0.1.17发布于 2025/06/04近 30 天下载 1.7万

Gecko mascot, a green gecko wearing glasses

原始使用文档
文档目录5 节
  1. Prerequisites
  2. Example: React + Vite front end
  3. Example: Express REST API
  4. Project structure
  5. Reference

Gecko

Gecko mascot, a green gecko wearing glasses

Gecko is a JSX code generation framework for TypeScript.

Prerequisites

Gecko is written in TypeScript, and requires tsx.

Bun support is planned.

Example: React + Vite front end

To test Gecko, run the following from this repository's root folder:

npm install
cd examples/calculator
npm --prefix project install
npm run gecko
npm --prefix project run dev

Gecko should run and generate files in the ./examples/calculator/project/src/gecko_generated folder.

If there were no errors during the Gecko or Vite build, the calculator example will be available at http://localhost:5173 that looks like this:

Calculator example

Example: Express REST API

To start the API, first run Gecko and then launch the resulting API:

npm install
cd examples/rest-api
npm install
npm --prefix project install
npm run gecko
npm --prefix project start

If there were no errors encountered, you should be able to visit http://localhost:3000/users and see a list of users:

[
  {
    "id": "1",
    "name": "Test user",
    "email": "[email protected]"
  }
]

Project structure

Projects using Gecko should have the following structure:

├── gecko.tsx
├── package.json
├── project
│   ├── (your project files)
│   ├── package.json
└── templates
    └── example.tsx

Your entire project source code, including its package.json, tsconfig.json, etc should be in the ./project sub-folder. This is important because the gecko.tsx template file must be isolated from your project's own TypeScript configuration. It will run under Gecko's internal tsconfig.json. You can use any structure you like, as long as the gecko.tsx file is not nested in your project's source tree, where you might have another tsconfig.json file, which could cause conflicts.

Reference

Gecko uses a file named gecko.tsx at the root of your project to generate files. The file contents might look something like:

import {
  File,
  Folder,
  geckoJSX,
  Root,
  Text,
} from '@flatfile/gecko'

import { Button } from './templates/Button'

export default function () {
  return (
    <Root path="project/src/gecko_generated" erase>
      <File name="readme.md">
        <Text>Hello world</Text>
      </File>
      <Folder name="components">
        {[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((digit) => (
          <File name={`Digit${digit}.tsx`}>
            <Button label={digit} />
          </File>
        ))}
      </Folder>
    </Root>
  )
}

Gecko supports many JSX tags to structure generated code. For the complete list, see the tag reference.

版本与发布记录

@flatfile/gecko 共发布 56 个版本,首次发布于 2024/05/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.17latest2025/06/041.5 年前
0.1.162025/06/041.5 年前
0.1.152024/10/042 年前
0.1.142024/09/192 年前
0.1.132024/09/192 年前
0.1.122024/09/192 年前

关于 @flatfile/gecko 的常见问题

如何安装 @flatfile/gecko?

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

@flatfile/gecko 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/flatfile__gecko 是否存在。

@flatfile/gecko 可以商用吗?

@flatfile/gecko 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@flatfile/gecko 的下载量有多少?

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

@flatfile/gecko 还在维护吗?

最新版本 0.1.17 发布于 2025/06/04(1.5 年前);至今共发布 56 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/05/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。