@capawesome/cloud-sdk

中文文档
0.1.7发布于 2026/10/04MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 6336

Node.js SDK for the Capawesome Cloud API.

原始使用文档
文档目录18 节
  1. SDKs
  2. Installation
  3. Getting started
  4. Configuration
  5. Usage
  6. Organizations
  7. Apps
  8. Live updates
  9. Deployments
  10. Git repositories
  11. Native builds
  12. Available resources
  13. Error handling
  14. Development
  15. Setup
  16. Testing
  17. Publishing
  18. License

@capawesome/cloud-sdk

npm version npm downloads license

Node.js SDK for the Capawesome Cloud API.

It provides a fully typed, promise-based interface for managing organizations, apps, live update channels and deployments, native builds, app store destinations, and more.

Note: The Capawesome Cloud API is still in development and may change without notice. Response types intentionally expose only the most relevant properties to minimize breaking changes.

SDKs

Official SDKs for the Capawesome Cloud API:

LanguagePackageRepository
Node.js@capawesome/cloud-sdkcloud-node
Pythoncapawesome-cloudcloud-python

Installation

npm install @capawesome/cloud-sdk

Requirements: Node.js 20.19 or later. The package is published as ESM only, but can also be loaded from CommonJS via require().

Getting started

Create an API token in the Capawesome Cloud Console and pass it to the client:

import { CapawesomeCloud } from '@capawesome/cloud-sdk';

const client = new CapawesomeCloud({
  token: process.env.CAPAWESOME_TOKEN!,
});

const apps = await client.apps.list({ organizationId: process.env.CAPAWESOME_ORGANIZATION_ID! });
console.log(apps);

Configuration

OptionTypeDefaultDescription
tokenstring—API token used to authenticate.
baseUrlstringhttps://api.cloud.capawesome.ioBase URL of the API (for self-hosting/testing).
timeoutnumber60000Request timeout in milliseconds. Does not apply to streamed downloads.
maxRetriesnumber3Retries for transient failures (network, 429, 5xx) on idempotent requests.
fetchtypeof fetchglobalThis.fetchThe fetch implementation used for all requests.

Usage

All methods take a single options object and return a typed promise. Most operations are scoped to an app via appId.

Organizations

const organizations = await client.organizations.list();
const organization = await client.organizations.get({ organizationId });
const members = await client.organizations.members.list({ organizationId });

// Invite a new member
await client.organizations.invitations.create({
  organizationId,
  email: '[email protected]',
  role: 'member',
});

// Group apps and members in a team
const team = await client.organizations.teams.create({ organizationId, name: 'Mobile' });
await client.organizations.teams.apps.create({ organizationId, teamId: team.id, appId });

Apps

const apps = await client.apps.list({ organizationId });
const app = await client.apps.get({ appId });
const created = await client.apps.create({ name: 'My App', type: 'capacitor' });
await client.apps.update({ appId, name: 'Renamed App' });
await client.apps.delete({ appId });

Live updates

// Create a channel
const channel = await client.apps.channels.create({ appId, name: 'production' });

// Pause / resume a channel
await client.apps.channels.pause({ appId, channelId: channel.id });
await client.apps.channels.resume({ appId, channelId: channel.id });

Deployments

Promote a build to a channel (live updates) or a destination (app store publishing):

// Roll out a live update to half of the devices on a channel
await client.apps.deployments.create({
  appId,
  appBuildId,
  appChannelName: 'production',
  rolloutPercentage: 0.5,
});

// Publish a native build to an app store with localized release notes
await client.apps.deployments.create({
  appId,
  appBuildId,
  appDestinationName: 'Google Play',
  releaseNotes: {
    default: 'Bug fixes and performance improvements.',
    'de-DE': 'Fehlerbehebungen und Leistungsverbesserungen.',
  },
});

Git repositories

Native builds are created from the repository an app is linked to:

const [connection] = await client.organizations.gitConnections.list({ organizationId });
const repositories = await client.organizations.gitConnections.listRepositories({
  organizationId,
  gitConnectionId: connection.id,
});

await client.apps.repository.set({
  appId,
  gitConnectionId: connection.id,
  path: repositories[0].path,
});

Native builds

const build = await client.apps.builds.create({
  appId,
  platform: 'ios',
  gitRef: 'main',
});

// Poll the job that processes the build
let job = await client.jobs.get({ jobId: build.jobId! });
while (job.status === 'queued' || job.status === 'pending' || job.status === 'in_progress') {
  await new Promise((resolve) => setTimeout(resolve, 5000));
  job = await client.jobs.get({ jobId: job.id });
}

const logs = await client.jobs.getLogs({ jobId: job.id });

// Explain a failure
if (job.status === 'failed') {
  const { summary } = await client.jobs.getFailureSummary({ jobId: job.id });
  console.error(summary);
}

Build artifacts

Binary downloads return a ReadableStream so large files can be streamed to disk without buffering everything in memory:

import { Writable } from 'node:stream';
import { createWriteStream } from 'node:fs';

const stream = await client.apps.builds.artifacts.download({ appId, buildId, artifactId });
await stream.pipeTo(Writable.toWeb(createWriteStream('artifact.ipa')));

You can also obtain a signed, time-limited download URL:

const { url, expiresAt } = await client.apps.builds.artifacts.getSignedDownloadUrl({
  appId,
  buildId,
  artifactId,
});

Certificates

import { readFile } from 'node:fs/promises';

const certificate = await client.apps.certificates.create({
  appId,
  name: 'Distribution Certificate',
  platform: 'ios',
  type: 'production',
  file: await readFile('distribution.p12'),
  fileName: 'distribution.p12',
  password: process.env.CERT_PASSWORD,
});

Environments, secrets & variables

const environment = await client.apps.environments.create({ appId, name: 'production' });

await client.apps.environments.secrets.create({
  appId,
  environmentId: environment.id,
  key: 'API_KEY',
  value: process.env.API_KEY!,
});

await client.apps.environments.variables.create({
  appId,
  environmentId: environment.id,
  key: 'API_URL',
  value: 'https://api.example.com',
});

Available resources

Resources mirror the API's path hierarchy. App-scoped resources are nested under client.apps.*, organization-scoped resources under client.organizations.*; top-level resources are exposed directly on the client.

ResourceDescription
client.appsCreate, read, update, delete and transfer apps.
client.apps.channelsManage live update channels (incl. pause/resume).
client.apps.deploymentsPromote builds to channels or destinations.
client.apps.buildsTrigger and manage native builds.
client.apps.builds.artifactsList and download build artifacts.
client.apps.buildSourcesRegister and download native build sources.
client.apps.certificatesManage signing certificates.
client.apps.destinationsManage app store publishing destinations.
client.apps.environmentsManage environments, secrets and variables.
client.apps.automationsManage build automations.
client.apps.devicesManage registered devices.
client.apps.webhooksManage app webhooks.
client.apps.configurationsManage native app configurations.
client.apps.repositoryLink an app to a Git repository.
client.organizationsCreate, read and update organizations.
client.organizations.membersManage organization members.
client.organizations.invitationsInvite users to an organization.
client.organizations.teamsManage teams and their apps and members.
client.organizations.licenseKeysManage license keys for Insiders packages.
client.organizations.gitConnectionsManage Git connections and browse repositories.
client.jobsInspect background jobs and their logs.
client.usersAccess the authenticated user.

Error handling

Any non-2xx response is thrown as a CapawesomeCloudError:

import { CapawesomeCloudError } from '@capawesome/cloud-sdk';

try {
  await client.apps.get({ appId: 'unknown' });
} catch (error) {
  if (error instanceof CapawesomeCloudError) {
    console.error(error.status); // 404
    console.error(error.message); // "App not found."
    console.error(error.body); // { message: "App not found." }
  }
}

Development

Setup

Clone the repository and install the dependencies:

npm install

This also sets up the Git hooks (via Husky), which run Prettier on staged files before every commit. Common scripts during development:

ScriptDescription
npm run buildBuild the package into dist/ with tsdown.
npm run devRebuild on change (watch mode).
npm run typecheckType-check without emitting output.
npm run lintCheck formatting and lint rules.
npm run fmtAuto-fix formatting and lint issues.

Testing

Tests are written with Vitest and live in the test/ directory:

npm test          # run the suite once
npm run test:watch # re-run on change

Publishing

Releases are automated with Release Please, which derives the next version and changelog entries from Conventional Commits.

On every push to main, the Release workflow creates or updates a release pull request that bumps the version and updates CHANGELOG.md. Merging that pull request creates the git tag and GitHub release, and publishes the package to npm.

License

See LICENSE.

版本与发布记录

@capawesome/cloud-sdk 共发布 7 个版本,首次发布于 2026/06/02;过去 12 个月发布了 7 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.7latest2026/10/041 个月前
0.1.62026/10/021 个月前
0.1.52026/09/301 个月前
0.1.42026/09/271 个月前
0.1.32026/08/182 个月前
0.1.22026/08/132 个月前

关于 @capawesome/cloud-sdk 的常见问题

@capawesome/cloud-sdk 是什么?

Node.js SDK for the Capawesome Cloud API.

如何安装 @capawesome/cloud-sdk?

在项目目录运行 npm install @capawesome/cloud-sdk,或使用 pnpm add / yarn add / bun add。

@capawesome/cloud-sdk 支持 TypeScript 吗?

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

@capawesome/cloud-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@capawesome/cloud-sdk 需要什么版本的 Node.js?

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

@capawesome/cloud-sdk 可以商用吗?

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

@capawesome/cloud-sdk 的下载量有多少?

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

@capawesome/cloud-sdk 还在维护吗?

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