@nx-tools/core
Advanced tools
Comparing version
@@ -7,6 +7,6 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-alpha.12", | ||
"version": "1.0.0-beta.1", | ||
"dependencies": { | ||
"@actions/exec": "^1.0.0", | ||
"@nx-tools/ci": "^1.0.0-alpha.12", | ||
"ci-info": "^3.1.1", | ||
"chalk": "^4.1.0" | ||
@@ -13,0 +13,0 @@ }, |
export * from '@actions/exec'; | ||
export { config as dotenv } from 'dotenv'; | ||
export * from './lib/core'; | ||
export * from './lib/process-utils'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.dotenv = void 0; | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("@actions/exec"), exports); | ||
var dotenv_1 = require("dotenv"); | ||
Object.defineProperty(exports, "dotenv", { enumerable: true, get: function () { return dotenv_1.config; } }); | ||
tslib_1.__exportStar(require("./lib/core"), exports); | ||
tslib_1.__exportStar(require("./lib/process-utils"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -70,3 +70,3 @@ /** | ||
*/ | ||
export declare const endGroup: (name: string) => void; | ||
export declare const endGroup: () => void; | ||
/** | ||
@@ -81,17 +81,3 @@ * Wrap an asynchronous function call in a group. | ||
export declare const group: <T>(name: string, fn: () => Promise<T>) => Promise<T>; | ||
/** | ||
* Saves state for current action, the state can only be retrieved by this action's post job execution. | ||
* | ||
* @param name name of the state to store | ||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify | ||
*/ | ||
export declare function saveState(name: string, value: any): void; | ||
/** | ||
* Gets the value of an state set by this action's main execution. | ||
* | ||
* @param name name of the state to get | ||
* @returns string | ||
*/ | ||
export declare function getState(name: string): string; | ||
export declare const asyncForEach: (array: any, callback: any) => Promise<void>; | ||
export declare const asyncForEach: <T>(array: T[], callback: (value: T, i: number, arr: T[]) => Promise<void>) => Promise<void>; | ||
export declare const parseBoolean: (value?: boolean) => 'true' | 'false' | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseBoolean = exports.asyncForEach = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.getInput = exports.ExitCode = void 0; | ||
exports.parseBoolean = exports.asyncForEach = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.getInput = exports.ExitCode = void 0; | ||
const tslib_1 = require("tslib"); | ||
const ci_1 = require("@nx-tools/ci"); | ||
const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
const os = tslib_1.__importStar(require("os")); | ||
const os = require("os"); | ||
const groups = []; | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const chalk = require('chalk'); | ||
/** | ||
@@ -66,3 +67,3 @@ * The code to exit an action | ||
exports.debug = (message) => { | ||
exports.info(chalk_1.default.green(`::debug::${message}`)); | ||
exports.info(chalk.green(`::debug::${message}`)); | ||
}; | ||
@@ -74,3 +75,3 @@ /** | ||
exports.error = (message) => { | ||
exports.info(chalk_1.default.red(`::error::${message instanceof Error ? message.toString() : message}`)); | ||
exports.info(chalk.red(`::error::${message instanceof Error ? message.toString() : message}`)); | ||
}; | ||
@@ -82,3 +83,3 @@ /** | ||
exports.warning = (message) => { | ||
exports.info(chalk_1.default.yellow(`::warning::${message instanceof Error ? message.toString() : message}`)); | ||
exports.info(chalk.yellow(`::warning::${message instanceof Error ? message.toString() : message}`)); | ||
}; | ||
@@ -100,12 +101,16 @@ /** | ||
exports.startGroup = (name) => { | ||
switch (ci_1.runnerProvider()) { | ||
case ci_1.RunnerProvider.GitLab: | ||
exports.info('section_start:`date +%s`:' + name + '\re[0K'); | ||
break; | ||
case ci_1.RunnerProvider.GitHub: | ||
case ci_1.RunnerProvider.Local: | ||
default: | ||
exports.info(`::group::${name}`); | ||
break; | ||
const { GITHUB_ACTIONS, GITLAB_CI } = process.env; | ||
if (GITLAB_CI) { | ||
const timestamp = Math.trunc(Date.now() / 1000); | ||
const groupName = name.toLocaleLowerCase().replace(/\s/g, '-'); | ||
groups.push(groupName); | ||
exports.info(`\\e[0Ksection_start:${timestamp}:${groupName}\\r\\e[0K${name}`); | ||
} | ||
else if (GITHUB_ACTIONS) { | ||
exports.info(`::group::${name}`); | ||
} | ||
else { | ||
groups.push(name); | ||
exports.info(`-->::${name}::`); | ||
} | ||
}; | ||
@@ -115,13 +120,16 @@ /** | ||
*/ | ||
exports.endGroup = (name) => { | ||
switch (ci_1.runnerProvider()) { | ||
case ci_1.RunnerProvider.GitLab: | ||
exports.info('section_end:`date +%s`:' + name + '\re[0K'); | ||
break; | ||
case ci_1.RunnerProvider.GitHub: | ||
case ci_1.RunnerProvider.Local: | ||
default: | ||
exports.info('::endgroup::'); | ||
break; | ||
exports.endGroup = () => { | ||
const { GITHUB_ACTIONS, GITLAB_CI } = process.env; | ||
if (GITLAB_CI) { | ||
const timestamp = Math.trunc(Date.now() / 1000); | ||
const groupName = groups.pop() || ''; | ||
exports.info(`\\e[0Ksection_end:${timestamp}:${groupName}\\r\\e[0K`); | ||
} | ||
else if (GITHUB_ACTIONS) { | ||
exports.info('::endgroup::'); | ||
} | ||
else { | ||
const groupName = groups.pop() || ''; | ||
exports.info(`<--::${groupName}::`); | ||
} | ||
}; | ||
@@ -143,3 +151,3 @@ /** | ||
finally { | ||
exports.endGroup(name); | ||
exports.endGroup(); | ||
} | ||
@@ -149,26 +157,2 @@ return result; | ||
//----------------------------------------------------------------------- | ||
// Wrapper action state | ||
//----------------------------------------------------------------------- | ||
/** | ||
* Saves state for current action, the state can only be retrieved by this action's post job execution. | ||
* | ||
* @param name name of the state to store | ||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function saveState(name, value) { | ||
// issueCommand('save-state', { name }, value); | ||
} | ||
exports.saveState = saveState; | ||
/** | ||
* Gets the value of an state set by this action's main execution. | ||
* | ||
* @param name name of the state to get | ||
* @returns string | ||
*/ | ||
function getState(name) { | ||
return process.env[`STATE_${name}`] || ''; | ||
} | ||
exports.getState = getState; | ||
//----------------------------------------------------------------------- | ||
// Utils Commands | ||
@@ -175,0 +159,0 @@ //----------------------------------------------------------------------- |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
0
-100%12271
-27.46%8
-27.27%246
-26.35%+ Added
+ Added
- Removed
- Removed