# @pcit/pcit-js

> PCIT JS SDK

Latest version **18.12.0-rc.3** (published 2020-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pcit/pcit-js
pnpm add @pcit/pcit-js
yarn add @pcit/pcit-js
bun add @pcit/pcit-js
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 18.12.0-rc.3 |
| Published | 2020-04-15 |
| First published | 2018-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8.0 |
| Dependencies | 2 |
| Unpacked size | 66.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | khs1994 |
| Maintainers | khs1994 |
| Keywords | pcit, pcit-ce |

## Links

- npm: https://www.npmjs.com/package/@pcit/pcit-js
- Repository: https://github.com/pcit-ce/pcit-js
- Issues: https://github.com/pcit-ce/pcit-js/issues
- npm.io page: https://npm.io/package/@pcit/pcit-js

## Dependencies (2)

- [wx-fetch](https://npm.io/package/wx-fetch.md) github:khs1994/wx-fetch
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0

## Recent versions

- 18.12.0-rc.3 (latest) — 2020-04-15
- 18.12.0-dev.20190119.0 (next) — 2019-01-19
- 18.12.0-rc.2 — 2019-05-21
- 18.12.0-dev.20190118.0 — 2019-01-18
- 18.12.0-dev.20190117.0 — 2019-01-17
- 18.12.0-beta.9 — 2019-01-17
- 18.12.0-beta.8 — 2019-01-17
- 18.12.0-beta.7 — 2018-12-20
- 18.12.0-beta.6 — 2018-11-28
- 18.12.0-beta.3 — 2018-11-28
- 18.12.0-beta.2 — 2018-11-28
- 18.12.0-beta.1 — 2018-11-26
- 18.12.0-beta.0 — 2018-11-24

## README

# PCIT JS SDK

[![npm](https://img.shields.io/npm/v/@pcit/pcit-js.svg)](https://www.npmjs.com/package/@pcit/pcit-js)
[![install size](https://packagephobia.now.sh/badge?p=@pcit/pcit-js)](https://packagephobia.now.sh/result?p=@pcit/pcit-js)

- https://github.com/pcit-ce/pcit-js

## Usage

PCIT-JS SDK 支持在浏览器、Node.js、微信小程序端运行。

### Browers

```html
// https://ci.domain.com/demo.html

<script src="https://lib.baomitu.com/js-cookie/2.2.0/js.cookie.min.js"></script>
<script src="https://unpkg.com/@pcit/pcit-js@18.12.0-rc.2/dist/pcit.min.js"></script>

<script>
  // get token from cookie
  // TODO please get git_type from url
  const git_type = 'github';

  const TOKEN = Cookies.get(git_type + '_api_token');

  const pcit = new PCIT(TOKEN, '');

  const pcit_user = pcit.user;

  (async () => {
    const result = await pcit_user.current();
    // TODO
    console.log(result);
  })();
</script>
```

### Node.js

```bash
$ npm i --save @pcit/pcit-js
```

```js
// you can save token to system env NODE_PCIT_TOKEN
const TOKEN = process.env.NODE_PCIT_TOKEN || 'xxx';

// get module
const pcit = require('@pcit/pcit-js');

// get repo instance
const pcit_repo = new pcit.Repo(TOKEN, 'https://ci.domain.com/api');

// call repo find method
(async () => {
  let result = await pcit_repo.find('pcit-ce', 'pcit');

  console.log(result);
})();
```

or

```js
// you can save token to system env NODE_PCIT_TOKEN
const TOKEN = process.env.NODE_PCIT_TOKEN || 'xxx';

// get pcit class
const PCIT = require('@pcit/pcit-js');

// get pcit instance
const pcit = new PCIT(TOKEN, 'https://ci.domain.com/api');

// get repo instance
const pcit_repo = pcit.repo;

// call repo find method
(async () => {
  let result = await pcit_repo.find('pcit-ce', 'pcit');

  console.log(result);
})();
```

### TypeScript

```bash
$ npm i --save @pcit/pcit-js
```

```ts
// you can save token to system env NODE_PCIT_TOKEN
const TOKEN: string = process.env.NODE_PCIT_TOKEN || 'xxx';

import PCIT from '@pcit/pcit-js';

const pcit = new PCIT(TOKEN, 'https://ci.khs1994.com/api');

const pcit_builds = pcit.builds;

(async () => {
  let result = await pcit_builds.find(100);
  console.log(result);
})();
```

## Dev

### PCIT 开发环境

```bash
$ npm run dev:build
```

### PCIT 小程序开发环境

```bash
$ npm run dev:miniprogram
```

---
_Source: https://npm.io/package/@pcit/pcit-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
