Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nx-tools/ci-context

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nx-tools/ci-context - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

8

package.json

@@ -7,9 +7,11 @@ {

"license": "MIT",
"version": "1.0.0",
"version": "1.0.1",
"dependencies": {
"ci-info": "3.2.0",
"@actions/github": "5.0.0"
"@actions/github": "5.0.0",
"@nx-tools/core": "1.0.0"
},
"main": "./src/index.js",
"typings": "./src/index.d.ts"
"typings": "./src/index.d.ts",
"peerDependencies": {}
}

@@ -0,3 +1,4 @@

import { RunnerContext } from './interfaces';
export declare class ContextProxyFactory {
static create(): import("./interfaces").RunnerContext;
static create(): Promise<RunnerContext>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextProxyFactory = void 0;
const tslib_1 = require("tslib");
const circle = require("./utils/circle");

@@ -12,15 +13,17 @@ const github = require("./utils/github");

static create() {
if (!ci.isCI) {
return local.context();
}
if (ci.CIRCLE) {
return circle.context();
}
if (ci.GITHUB_ACTIONS) {
return github.context();
}
if (ci.GITLAB) {
return gitlab.context();
}
throw new Error('Unsupported runner provider');
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!ci.isCI) {
return local.context();
}
if (ci.CIRCLE) {
return circle.context();
}
if (ci.GITHUB_ACTIONS) {
return github.context();
}
if (ci.GITLAB) {
return gitlab.context();
}
throw new Error('Unsupported runner provider');
});
}

@@ -27,0 +30,0 @@ }

@@ -0,3 +1,4 @@

import { RepoMetadata } from './interfaces';
export declare class RepoProxyFactory {
static create(token: string): Promise<import("./interfaces").RepoMetadata>;
static create(token: string): Promise<RepoMetadata>;
}
import { RepoMetadata, RunnerContext } from '../interfaces';
export declare function context(): RunnerContext;
export declare function context(): Promise<RunnerContext>;
export declare function repo(token: string): Promise<RepoMetadata>;

@@ -6,12 +6,14 @@ "use strict";

function context() {
return {
actor: process.env.CIRCLE_USERNAME,
eventName: process.env.CI_PULL_REQUEST ? 'pull_request' : 'unknown',
job: process.env.CIRCLE_JOB,
payload: {},
ref: process.env.CIRCLE_TAG ? `refs/tags/${process.env.CIRCLE_TAG}` : `refs/heads/${process.env.CIRCLE_BRANCH}`,
runId: parseInt(process.env.CIRCLE_BUILD_NUM, 10),
runNumber: parseInt(process.env.CIRCLE_BUILD_NUM, 10),
sha: process.env.CIRCLE_SHA1,
};
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return {
actor: process.env.CIRCLE_USERNAME,
eventName: process.env.CI_PULL_REQUEST ? 'pull_request' : 'unknown',
job: process.env.CIRCLE_JOB,
payload: {},
ref: process.env.CIRCLE_TAG ? `refs/tags/${process.env.CIRCLE_TAG}` : `refs/heads/${process.env.CIRCLE_BRANCH}`,
runId: parseInt(process.env.CIRCLE_BUILD_NUM, 10),
runNumber: parseInt(process.env.CIRCLE_BUILD_NUM, 10),
sha: process.env.CIRCLE_SHA1,
};
});
}

@@ -18,0 +20,0 @@ exports.context = context;

import { RepoMetadata, RunnerContext } from '../interfaces';
export declare function context(): RunnerContext;
export declare function context(): Promise<RunnerContext>;
export declare function repo(token: string): Promise<RepoMetadata>;

@@ -7,13 +7,15 @@ "use strict";

function context() {
const { actor, eventName, job, ref, runId, runNumber, sha, payload } = github.context;
return {
actor,
eventName,
job,
payload,
ref,
runId,
runNumber,
sha,
};
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { actor, eventName, job, ref, runId, runNumber, sha, payload } = github.context;
return {
actor,
eventName,
job,
payload,
ref,
runId,
runNumber,
sha,
};
});
}

@@ -20,0 +22,0 @@ exports.context = context;

import { RepoMetadata, RunnerContext } from '../interfaces';
export declare function context(): RunnerContext;
export declare function context(): Promise<RunnerContext>;
export declare function repo(token: string): Promise<RepoMetadata>;

@@ -6,14 +6,16 @@ "use strict";

function context() {
return {
actor: process.env.GITLAB_USER_LOGIN,
eventName: process.env.CI_PIPELINE_SOURCE,
job: process.env.CI_JOB_NAME,
payload: {},
ref: process.env.CI_COMMIT_TAG
? `refs/tags/${process.env.CI_COMMIT_TAG}`
: `refs/heads/${process.env.CI_COMMIT_REF_SLUG}`,
runId: parseInt(process.env.CI_PIPELINE_IID, 10),
runNumber: parseInt(process.env.CI_PIPELINE_ID, 10),
sha: process.env.CI_COMMIT_SHA,
};
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return {
actor: process.env.GITLAB_USER_LOGIN,
eventName: process.env.CI_PIPELINE_SOURCE,
job: process.env.CI_JOB_NAME,
payload: {},
ref: process.env.CI_COMMIT_TAG
? `refs/tags/${process.env.CI_COMMIT_TAG}`
: `refs/heads/${process.env.CI_COMMIT_REF_SLUG}`,
runId: parseInt(process.env.CI_PIPELINE_IID, 10),
runNumber: parseInt(process.env.CI_PIPELINE_ID, 10),
sha: process.env.CI_COMMIT_SHA,
};
});
}

@@ -20,0 +22,0 @@ exports.context = context;

import { RepoMetadata, RunnerContext } from '../interfaces';
export declare function context(): RunnerContext;
export declare const getRef: () => Promise<string>;
export declare const getCommitUserEmail: () => Promise<string>;
export declare const getSha: () => Promise<string>;
export declare function context(): Promise<RunnerContext>;
export declare function repo(token: string): Promise<RepoMetadata>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.repo = exports.context = void 0;
exports.repo = exports.context = exports.getSha = exports.getCommitUserEmail = exports.getRef = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@nx-tools/core");
const getRef = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const output = yield core_1.getExecOutput('git symbolic-ref HEAD');
return output.stdout.trim();
});
exports.getRef = getRef;
const getCommitUserEmail = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const output = yield core_1.getExecOutput('git log -1 --pretty=format:%ae');
return output.stdout.trim();
});
exports.getCommitUserEmail = getCommitUserEmail;
const getSha = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const output = yield core_1.getExecOutput('git rev-parse HEAD');
return output.stdout.trim();
});
exports.getSha = getSha;
function context() {
return {
actor: process.env.NXDOCKER_ACTOR,
eventName: process.env.NXDOCKER_EVENT_NAME,
job: process.env.NXDOCKER_JOB,
payload: {},
ref: process.env.NXDOCKER_REF,
runId: parseInt(process.env.NXDOCKER_RUN_ID, 10),
runNumber: parseInt(process.env.NXDOCKER_RUN_NUMBER, 10),
sha: process.env.NXDOCKER_SHA,
};
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return {
actor: yield exports.getCommitUserEmail(),
eventName: 'push',
job: 'build',
payload: {},
ref: yield exports.getRef(),
runId: 0,
runNumber: 0,
sha: yield exports.getSha(),
};
});
}

@@ -17,0 +35,0 @@ exports.context = context;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc