@pcit/pcit-js
TypeScript icon, indicating that this package has built-in type declarations

18.12.0-rc.3 • Public • Published

PCIT JS SDK

npm install size

Usage

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

Browers

// 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

$ npm i --save @pcit/pcit-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

// 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

$ npm i --save @pcit/pcit-js
// 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 开发环境

$ npm run dev:build

PCIT 小程序开发环境

$ npm run dev:miniprogram

Readme

Keywords

Package Sidebar

Install

npm i @pcit/pcit-js

Weekly Downloads

15

Version

18.12.0-rc.3

License

MIT

Unpacked Size

67.8 kB

Total Files

29

Last publish

Collaborators

  • khs1994