code:
/**
 * trace-event - A library to create a trace of your node app per
 * Google's Trace Event format:
 * // JSSTYLED
 *      https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU
 */
/// <reference types="node" />
import { Readable as ReadableStream } from "stream";
export interface Event {
    ts: number;
    pid: number;
    tid: number;
    /** event phase */
    ph?: string;
    [otherData: string]: any;
}
export interface Fields {
    cat?: any;
    args?: any;
    [filedName: string]: any;
}
export interface TracerOptions {
    parent?: Tracer | null;
    fields?: Fields | null;
    objectMode?: boolean | null;
    noStream?: boolean;
}
export declare class Tracer extends ReadableStream {
    private _objectMode;
    /** Node Stream internal APIs */
    private _push;
    private firstPush?;
    private noStream;
    private events;
    private parent;
    private fields;
    constructor(opts?: TracerOptions);
    /**
     * If in no streamMode in order to flush out the trace
     * you need to call flush.
     */
    flush(): void;
    _read(_: number): void;
    private _pushString;
    private _flush;
    child(fields: Fields): Tracer;
    begin(fields: Fields): void;
    end(fields: Fields): void;
    completeEvent(fields: Fields): void;
    instantEvent(fields: Fields): void;
    mkEventFunc(ph: string): (fields: Fields) => void;
}


code:
"use strict";
/**
 * trace-event - A library to create a trace of your node app per
 * Google's Trace Event format:
 * // JSSTYLED
 *      https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tracer = void 0;
const stream_1 = require("stream");
function evCommon() {
    var hrtime = process.hrtime(); // [seconds, nanoseconds]
    var ts = hrtime[0] * 1000000 + Math.round(hrtime[1] / 1000); // microseconds
    return {
        ts,
        pid: process.pid,
        tid: process.pid // no meaningful tid for node.js
    };
}
class Tracer extends stream_1.Readable {
    constructor(opts = {}) {
        super();
        this.noStream = false;
        this.events = [];
        if (typeof opts !== "object") {
            throw new Error("Invalid options passed (must be an object)");
        }
        if (opts.parent != null && typeof opts.parent !== "object") {
            throw new Error("Invalid option (parent) passed (must be an object)");
        }
        if (opts.fields != null && typeof opts.fields !== "object") {
            throw new Error("Invalid option (fields) passed (must be an object)");
        }
        if (opts.objectMode != null &&
            (opts.objectMode !== true && opts.objectMode !== false)) {
            throw new Error("Invalid option (objectsMode) passed (must be a boolean)");
        }
        this.noStream = opts.noStream || false;
        this.parent = opts.parent;
        if (this.parent) {
            this.fields = Object.assign({}, opts.parent && opts.parent.fields);
        }
        else {
            this.fields = {};
        }
        if (opts.fields) {
            Object.assign(this.fields, opts.fields);
        }
        if (!this.fields.cat) {
            // trace-viewer *requires* `cat`, so let's have a fallback.
            this.fields.cat = "default";
        }
        else if (Array.isArray(this.fields.cat)) {
            this.fields.cat = this.fields.cat.join(",");
        }
        if (!this.fields.args) {
            // trace-viewer *requires* `args`, so let's have a fallback.
            this.fields.args = {};
        }
        if (this.parent) {
            // TODO: Not calling Readable ctor here. Does that cause probs?
            //      Probably if trying to pipe from the child.
            //      Might want a serpate TracerChild class for these guys.
            this._push = this.parent._push.bind(this.parent);
        }
        else {
            this._objectMode = Boolean(opts.objectMode);
            var streamOpts = { objectMode: this._objectMode };
            if (this._objectMode) {
                this._push = this.push;
            }
            else {
                this._push = this._pushString;
                streamOpts.encoding = "utf8";
            }
            stream_1.Readable.call(this, streamOpts);
        }
    }
    /**
     * If in no streamMode in order to flush out the trace
     * you need to call flush.
     */
    flush() {
        if (this.noStream === true) {
            for (const evt of this.events) {
                this._push(evt);
            }
            this._flush();
        }
    }
    _read(_) { }
    _pushString(ev) {
        var separator = "";
        if (!this.firstPush) {
            this.push("[");
            this.firstPush = true;
        }
        else {
            separator = ",\n";
        }
        this.push(separator + JSON.stringify(ev), "utf8");
    }
    _flush() {
        if (!this._objectMode) {
            this.push("]");
        }
    }
    child(fields) {
        return new Tracer({
            parent: this,
            fields: fields
        });
    }
    begin(fields) {
        return this.mkEventFunc("B")(fields);
    }
    end(fields) {
        return this.mkEventFunc("E")(fields);
    }
    completeEvent(fields) {
        return this.mkEventFunc("X")(fields);
    }
    instantEvent(fields) {
        return this.mkEventFunc("I")(fields);
    }
    mkEventFunc(ph) {
        return (fields) => {
            var ev = evCommon();
            // Assign the event phase.
            ev.ph = ph;
            if (fields) {
                if (typeof fields === "string") {
                    ev.name = fields;
                }
                else {
                    for (const k of Object.keys(fields)) {
                        if (k === "cat") {
                            ev.cat = fields.cat.join(",");
                        }
                        else {
                            ev[k] = fields[k];
                        }
                    }
                }
            }
            if (!this.noStream) {
                this._push(ev);
            }
            else {
                this.events.push(ev);
            }
        };
    }
}
exports.Tracer = Tracer;
/*
 * These correspond to the "Async events" in the Trace Events doc.
 *
 * Required fields:
 * - name
 * - id
 *
 * Optional fields:
 * - cat (array)
 * - args (object)
 * - TODO: stack fields, other optional fields?
 *
 * Dev Note: We don't explicitly assert that correct fields are
 * used for speed (premature optimization alert!).
 */

license: mit


chrome-trace-event

description: A library to create a trace of your node app per Google's Trace Event format.

license: MIT

author: Trent Mick, Sam Saccone

keywords: trace-event trace event trace-viewer google

build: tsc

check_format: prettier -l lib/** test/** examples/**

test: tape test/*.test.js


code:
# Changelog

## v1.6.0

* feat: add Sail CI support
* feat: add Buddy support
* feat: add Bitrise support
* feat: detect Jenkins PRs
* feat: detect Drone PRs

## v1.5.1

* fix: use full path to vendors.json

## v1.5.0

* feat: add dsari detection ([#15](https://github.com/watson/ci-info/pull/15))
* feat: add ci.isPR ([#16](https://github.com/watson/ci-info/pull/16))

## v1.4.0

* feat: add Cirrus CI detection ([#13](https://github.com/watson/ci-info/pull/13))
* feat: add Shippable CI detection ([#14](https://github.com/watson/ci-info/pull/14))

## v1.3.1

* chore: reduce npm package size by not including `.github` folder content ([#11](https://github.com/watson/ci-info/pull/11))

## v1.3.0

* feat: add support for Strider CD
* chore: deprecate vendor constant `TDDIUM` in favor of `SOLANO`
* docs: add missing vendor constant to docs

## v1.2.0

* feat: detect solano-ci ([#9](https://github.com/watson/ci-info/pull/9))

## v1.1.3

* fix: fix spelling of Hunson in `ci.name`

## v1.1.2

* fix: no more false positive matches for Jenkins

## v1.1.1

* docs: sort lists of CI servers in README.md
* docs: add missing AWS CodeBuild to the docs

## v1.1.0

* feat: add AWS CodeBuild to CI detection ([#2](https://github.com/watson/ci-info/pull/2))

## v1.0.1

* chore: reduce npm package size by using an `.npmignore` file ([#3](https://github.com/watson/ci-info/pull/3))

## v1.0.0

* Initial release


code:
# ci-info

Get details about the current Continuous Integration environment.

Please [open an
issue](https://github.com/watson/ci-info/issues/new?template=ci-server-not-detected.md)
if your CI server isn't properly detected :)

[![npm](https://img.shields.io/npm/v/ci-info.svg)](https://www.npmjs.com/package/ci-info)
[![Build status](https://travis-ci.org/watson/ci-info.svg?branch=master)](https://travis-ci.org/watson/ci-info)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

## Installation

```bash
npm install ci-info --save
```

## Usage

```js
var ci = require('ci-info')

if (ci.isCI) {
  console.log('The name of the CI server is:', ci.name)
} else {
  console.log('This program is not running on a CI server')
}
```

## Supported CI tools

Officially supported CI servers:

| Name | Constant |
|------|----------|
| [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `ci.CODEBUILD` |
| [AppVeyor](http://www.appveyor.com) | `ci.APPVEYOR` |
| [Bamboo](https://www.atlassian.com/software/bamboo) by Atlassian | `ci.BAMBOO` |
| [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) | `ci.BITBUCKET` |
| [Bitrise](https://www.bitrise.io/) | `ci.BITRISE` |
| [Buddy](https://buddy.works/) | `ci.BUDDY` |
| [Buildkite](https://buildkite.com) | `ci.BUILDKITE` |
| [CircleCI](http://circleci.com) | `ci.CIRCLE` |
| [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` |
| [Codeship](https://codeship.com) | `ci.CODESHIP` |
| [Drone](https://drone.io) | `ci.DRONE` |
| [dsari](https://github.com/rfinnie/dsari) | `ci.DSARI` |
| [GitLab CI](https://about.gitlab.com/gitlab-ci/) | `ci.GITLAB` |
| [GoCD](https://www.go.cd/) | `ci.GOCD` |
| [Hudson](http://hudson-ci.org) | `ci.HUDSON` |
| [Jenkins CI](https://jenkins-ci.org) | `ci.JENKINS` |
| [Magnum CI](https://magnum-ci.com) | `ci.MAGNUM` |
| [Sail CI](https://sail.ci/) | `ci.SAIL` |
| [Semaphore](https://semaphoreci.com) | `ci.SEMAPHORE` |
| [Shippable](https://www.shippable.com/) | `ci.SHIPPABLE` |
| [Solano CI](https://www.solanolabs.com/) | `ci.SOLANO` |
| [Strider CD](https://strider-cd.github.io/) | `ci.STRIDER` |
| [TaskCluster](http://docs.taskcluster.net) | `ci.TASKCLUSTER` |
| [Team Foundation Server](https://www.visualstudio.com/en-us/products/tfs-overview-vs.aspx) by Microsoft | `ci.TFS` |
| [TeamCity](https://www.jetbrains.com/teamcity/) by JetBrains | `ci.TEAMCITY` |
| [Travis CI](http://travis-ci.org) | `ci.TRAVIS` |

## API

### `ci.name`

A string. Will contain the name of the CI server the code is running on.
If not CI server is detected, it will be `null`.

Don't depend on the value of this string not to change for a specific
vendor. If you find your self writing `ci.name === 'Travis CI'`, you
most likely want to use `ci.TRAVIS` instead.

### `ci.isCI`

A boolean. Will be `true` if the code is running on a CI server.
Otherwise `false`.

Some CI servers not listed here might still trigger the `ci.isCI`
boolean to be set to `true` if they use certain vendor neutral
environment variables. In those cases `ci.name` will be `null` and no
vendor specific boolean will be set to `true`.

### `ci.isPR`

A boolean if PR detection is supported for the current CI server. Will
be `true` if a PR is being tested. Otherwise `false`. If PR detection is
not supported for the current CI server, the value will be `null`.

### `ci.<VENDOR-CONSTANT>`

A vendor specific boolean constants is exposed for each support CI
vendor. A constant will be `true` if the code is determined to run on
the given CI server.  Otherwise `false`.

Examples of vendor constants are `ci.TRAVIS` or `ci.APPVEYOR`. For a
complete list, see the support table above.

Deprecated vendor constants that will be removed in the next major
release:

- `ci.TDDIUM` (Solano CI) This have been renamed `ci.SOLANO`

## License

[MIT](LICENSE)


code:
'use strict'

var vendors = require('./vendors.json')

var env = process.env

// Used for testinging only
Object.defineProperty(exports, '_vendors', {
  value: vendors.map(function (v) { return v.constant })
})

exports.name = null
exports.isPR = null

vendors.forEach(function (vendor) {
  var envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env]
  var isCI = envs.every(function (obj) {
    return checkEnv(obj)
  })

  exports[vendor.constant] = isCI

  if (isCI) {
    exports.name = vendor.name

    switch (typeof vendor.pr) {
      case 'string':
        // "pr": "CIRRUS_PR"
        exports.isPR = !!env[vendor.pr]
        break
      case 'object':
        if ('env' in vendor.pr) {
          // "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" }
          exports.isPR = vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne
        } else if ('any' in vendor.pr) {
          // "pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
          exports.isPR = vendor.pr.any.some(function (key) {
            return !!env[key]
          })
        } else {
          // "pr": { "DRONE_BUILD_EVENT": "pull_request" }
          exports.isPR = checkEnv(vendor.pr)
        }
        break
      default:
        // PR detection not supported for this vendor
        exports.isPR = null
    }
  }
})

exports.isCI = !!(
  env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
  env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
  env.BUILD_NUMBER || // Jenkins, TeamCity
  env.RUN_ID || // TaskCluster, dsari
  exports.name ||
  false
)

function checkEnv (obj) {
  if (typeof obj === 'string') return !!env[obj]
  return Object.keys(obj).every(function (k) {
    return env[k] === obj[k]
  })
}


ci-info

description: Get details about the current Continuous Integration environment

test: standard && node test.js

type: git

keywords: ci continuous integration test detect

author: Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)


AppVeyor

constant: APPVEYOR

env: APPVEYOR

Bamboo

constant: BAMBOO

Bitbucket Pipelines

constant: BITBUCKET

Bitrise

constant: BITRISE

Buddy

constant: BUDDY

Buildkite

constant: BUILDKITE

env: BUILDKITE

ne: false

CircleCI

constant: CIRCLE

env: CIRCLECI

Cirrus CI

constant: CIRRUS

AWS CodeBuild

constant: CODEBUILD

Codeship

constant: CODESHIP

CI_NAME: codeship

Drone

constant: DRONE

env: DRONE

dsari

constant: DSARI

env: DSARI

GitLab CI

constant: GITLAB

GoCD

constant: GOCD

Hudson

constant: HUDSON

Jenkins

constant: JENKINS

Magnum CI

constant: MAGNUM

env: MAGNUM

Sail CI

constant: SAIL

env: SAILCI

Semaphore

constant: SEMAPHORE

env: SEMAPHORE

Shippable

constant: SHIPPABLE

env: SHIPPABLE

IS_PULL_REQUEST: true

Solano CI

constant: SOLANO

env: TDDIUM

Strider CD

constant: STRIDER

env: STRIDER

TaskCluster

constant: TASKCLUSTER

Solano CI

constant: TDDIUM

TeamCity

constant: TEAMCITY

Team Foundation Server

constant: TFS

Travis CI

constant: TRAVIS

env: TRAVIS