@gapi/cli

中文文档
1.8.263发布于 2026/11/16MITTypeScriptESM + CJS近 30 天下载 4783

Gapi command line interface

原始使用文档

WIKI

Gapi - Advanced graphql server with typescript decorators

Starter - Basic starter project

Starter-advanced - Advanced starter project

Gapi-angular-client - Gapi Apollo Angular client

To install gapi utility type following command:

npm i -g @gapi/cli

To create new basic project from scratch via CLI type:

gapi new my-project

To create new advanced project from scratch via CLI type:

gapi new my-project --advanced

To create new basic project with microservices from scratch via CLI type:

gapi new my-project --microservices

Available commands

Create new project
gapi new project-name
Start created project.
gapi start
(Uses internally on every restart to introspect api schema check "gapi schema introspect" command)
Can be disabled inside package.json > nodemonConfig > events > restart
With this configuration it will make request to localhost:9000 and will take current API schema then will generate graphql.d.ts based on introspection
  "nodemonConfig": {
    "events": {
      "restart": "sleep 1 && gapi schema introspect"
    }
  },
Start production (it will start pm2 and will use process.yml file inside working directory)
gapi start --prod --pm2
Start production inside Docker(it will start pm2-docker and will use process.yml file inside working directory)
gapi start --prod --docker

Start testing

Run single test iteration
Will take config > test > local configuration inside @gapi/cli.conf.yml
gapi test
Run tests in watch mode
gapi test --watch
Run tests with different environment
It will take configuration from @gapi/cli.conf.yml
You can extend configurations from APP when you write after environment "extends app/my-environment"

Custom testing environments

config:
  app:
    local:
      API_PORT: 9000
      API_CERT: ./cert.key
      NODE_ENV: development
      AMQP_HOST: 182.10.0.5
      AMQP_PORT: 5672
    prod:
      API_PORT: 9000
      API_CERT: ./cert.key
      NODE_ENV: production
      AMQP_HOST: 182.10.0.5
      AMQP_PORT: 5672
    my-environment:
      API_PORT: 9000
      API_CERT: ./cert.key
      NODE_ENV: development
      AMQP_HOST: 182.10.0.5
      AMQP_PORT: 5672
  test:
    my-environment: extends app/my-environment
    local: extends app/local
    prod: extends app/prod
    worker:
      API_PORT: 9000
      API_CERT: ./cert.key
      NODE_ENV: production
      AMQP_HOST: 182.10.0.5
      AMQP_PORT: 5672
Running with Testing worker environment
gapi test --worker

Running with Production environment

gapi test --prod
Running with custom enviroment
gapi test --my-enviroment

Schema

Schema introspection
It will generate graphql.d.ts file based on given address and output folder
Uses @gapi/cli.conf.yml file
config:
  schema:
    introspectionEndpoint: http://localhost:9000/graphql
    introspectionOutputFolder: ./src/app/core/api-introspection
gapi schema introspect
strictNullability - keep NonNull output fields required

By default every field of a generated OUTPUT interface is optional (field?: T). With strictNullability: true (or --strict-nullability) a NonNull output field stays required (field: T) and only nullable fields are optional (field?: T | null), so the generated types match the schema exactly. __typename stays optional.

config:
  schema:
    introspectionEndpoint: http://localhost:9000/graphql
    introspectionOutputFolder: ./src/app/core/api-introspection
    strictNullability: true
Available shared commands are:
--verbose - Show better logging

版本与发布记录

@gapi/cli 共发布 789 个版本,首次发布于 2018/03/23;过去 12 个月发布了 116 个版本。

版本发布日期距今
1.8.263latest2026/11/16今天
1.8.2622026/11/132 天前
1.8.2612026/11/096 天前
1.8.2602026/11/097 天前
1.8.2592026/11/097 天前
1.8.2582026/11/078 天前

其他发布通道:nightly → 1.8.168-nightly.3。

关于 @gapi/cli 的常见问题

@gapi/cli 是什么?

Gapi command line interface

如何安装 @gapi/cli?

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

@gapi/cli 支持 TypeScript 吗?

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

@gapi/cli 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gapi/cli 可以商用吗?

@gapi/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gapi/cli 的下载量有多少?

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

@gapi/cli 还在维护吗?

最新版本 1.8.263 发布于 2026/11/16(今天);至今共发布 789 个版本,其中过去 12 个月发布了 116 个;首次发布于 2018/03/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。