@nx-tools/core
Advanced tools
Comparing version 1.0.0-beta.4 to 1.0.0
@@ -7,7 +7,6 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"@actions/exec": "1.0.4", | ||
"ci-info": "3.1.1", | ||
"chalk": "4.1.1" | ||
"@actions/core": "1.4.0", | ||
"@actions/exec": "1.1.0" | ||
}, | ||
@@ -14,0 +13,0 @@ "main": "./src/index.js", |
@@ -0,2 +1,3 @@ | ||
export { debug, endGroup, error, ExitCode, group, info, isDebug, setFailed, startGroup, warning } from '@actions/core'; | ||
export * from '@actions/exec'; | ||
export * from './lib/core'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.warning = exports.startGroup = exports.setFailed = exports.isDebug = exports.info = exports.group = exports.ExitCode = exports.error = exports.endGroup = exports.debug = void 0; | ||
const tslib_1 = require("tslib"); | ||
var core_1 = require("@actions/core"); | ||
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return core_1.debug; } }); | ||
Object.defineProperty(exports, "endGroup", { enumerable: true, get: function () { return core_1.endGroup; } }); | ||
Object.defineProperty(exports, "error", { enumerable: true, get: function () { return core_1.error; } }); | ||
Object.defineProperty(exports, "ExitCode", { enumerable: true, get: function () { return core_1.ExitCode; } }); | ||
Object.defineProperty(exports, "group", { enumerable: true, get: function () { return core_1.group; } }); | ||
Object.defineProperty(exports, "info", { enumerable: true, get: function () { return core_1.info; } }); | ||
Object.defineProperty(exports, "isDebug", { enumerable: true, get: function () { return core_1.isDebug; } }); | ||
Object.defineProperty(exports, "setFailed", { enumerable: true, get: function () { return core_1.setFailed; } }); | ||
Object.defineProperty(exports, "startGroup", { enumerable: true, get: function () { return core_1.startGroup; } }); | ||
Object.defineProperty(exports, "warning", { enumerable: true, get: function () { return core_1.warning; } }); | ||
tslib_1.__exportStar(require("@actions/exec"), exports); | ||
tslib_1.__exportStar(require("./lib/core"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -0,23 +1,12 @@ | ||
import { InputOptions as acInputOptions } from '@actions/core'; | ||
/** | ||
* Interface for getInput options | ||
*/ | ||
export interface InputOptions { | ||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */ | ||
required?: boolean; | ||
export interface InputOptions extends acInputOptions { | ||
fallback?: string; | ||
} | ||
/** | ||
* The code to exit an action | ||
*/ | ||
export declare enum ExitCode { | ||
/** | ||
* A code indicating that the action was successful | ||
*/ | ||
Success = 0, | ||
/** | ||
* A code indicating that the action was a failure | ||
*/ | ||
Failure = 1 | ||
} | ||
/** | ||
* Gets the value of an input. The value is also trimmed. | ||
* Gets the value of an input. | ||
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. | ||
* Returns an empty string if the value is not defined. | ||
* | ||
@@ -28,55 +17,15 @@ * @param name name of the input to get | ||
*/ | ||
export declare const getInput: (name: string, fallback?: string, options?: InputOptions) => string; | ||
export declare function getInput(name: string, options?: InputOptions): string; | ||
/** | ||
* Sets the action status to failed. | ||
* When the action exits it will be with an exit code of 1 | ||
* @param message add error issue message | ||
*/ | ||
export declare function setFailed(message: string | Error): void; | ||
/** | ||
* Gets whether Actions Step Debug is on or not | ||
*/ | ||
export declare const isDebug: () => boolean; | ||
/** | ||
* Writes debug message to user log | ||
* @param message debug message | ||
*/ | ||
export declare const debug: (message: string) => void; | ||
/** | ||
* Adds an error issue | ||
* @param message error issue message. Errors will be converted to string via toString() | ||
*/ | ||
export declare const error: (message: string | Error) => void; | ||
/** | ||
* Adds an warning issue | ||
* @param message warning issue message. Errors will be converted to string via toString() | ||
*/ | ||
export declare const warning: (message: string | Error) => void; | ||
/** | ||
* Writes info to log with console.log. | ||
* @param message info message | ||
*/ | ||
export declare const info: (message: string) => void; | ||
/** | ||
* Begin an output group. | ||
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification. | ||
* Support boolean input list: `true | True | TRUE | false | False | FALSE` . | ||
* The return value is also in boolean type. | ||
* ref: https://yaml.org/spec/1.2/spec.html#id2804923 | ||
* | ||
* Output until the next `groupEnd` will be foldable in this group | ||
* | ||
* @param name The name of the output group | ||
* @param name name of the input to get | ||
* @param options optional. See InputOptions. | ||
* @returns boolean | ||
*/ | ||
export declare const startGroup: (name: string) => void; | ||
/** | ||
* End an output group. | ||
*/ | ||
export declare const endGroup: () => void; | ||
/** | ||
* Wrap an asynchronous function call in a group. | ||
* | ||
* Returns the same type as the function itself. | ||
* | ||
* @param name The name of the group | ||
* @param fn The function to wrap in the group | ||
*/ | ||
export declare const group: <T>(name: string, fn: () => Promise<T>) => Promise<T>; | ||
export declare function getBooleanInput(name: string, options?: InputOptions): boolean; | ||
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; | ||
export declare const interpolate: (str: string) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
exports.interpolate = exports.asyncForEach = exports.getBooleanInput = exports.getInput = void 0; | ||
const tslib_1 = require("tslib"); | ||
const os = require("os"); | ||
const groups = []; | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const chalk = require('chalk'); | ||
/** | ||
* The code to exit an action | ||
*/ | ||
var ExitCode; | ||
(function (ExitCode) { | ||
/** | ||
* A code indicating that the action was successful | ||
*/ | ||
ExitCode[ExitCode["Success"] = 0] = "Success"; | ||
/** | ||
* A code indicating that the action was a failure | ||
*/ | ||
ExitCode[ExitCode["Failure"] = 1] = "Failure"; | ||
})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); | ||
const core_1 = require("@actions/core"); | ||
//----------------------------------------------------------------------- | ||
@@ -27,3 +10,5 @@ // Variables | ||
/** | ||
* Gets the value of an input. The value is also trimmed. | ||
* Gets the value of an input. | ||
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed. | ||
* Returns an empty string if the value is not defined. | ||
* | ||
@@ -34,129 +19,45 @@ * @param name name of the input to get | ||
*/ | ||
const getInput = (name, fallback, options) => { | ||
const val = process.env[`INPUT_${name.replace(/[ -]/g, '_').toUpperCase()}`] || fallback || ''; | ||
function getInput(name, options) { | ||
let val; | ||
try { | ||
val = core_1.getInput(name, options); | ||
if (!val && (options === null || options === void 0 ? void 0 : options.fallback)) { | ||
val = options.fallback; | ||
} | ||
} | ||
catch (error) { | ||
val = (options === null || options === void 0 ? void 0 : options.fallback) || ''; | ||
} | ||
if (options && options.required && !val) { | ||
throw new Error(`Input required and not supplied: ${name}`); | ||
} | ||
if (options && options.trimWhitespace === false) { | ||
return val; | ||
} | ||
return val.trim(); | ||
}; | ||
} | ||
exports.getInput = getInput; | ||
//----------------------------------------------------------------------- | ||
// Results | ||
//----------------------------------------------------------------------- | ||
/** | ||
* Sets the action status to failed. | ||
* When the action exits it will be with an exit code of 1 | ||
* @param message add error issue message | ||
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification. | ||
* Support boolean input list: `true | True | TRUE | false | False | FALSE` . | ||
* The return value is also in boolean type. | ||
* ref: https://yaml.org/spec/1.2/spec.html#id2804923 | ||
* | ||
* @param name name of the input to get | ||
* @param options optional. See InputOptions. | ||
* @returns boolean | ||
*/ | ||
function setFailed(message) { | ||
process.exitCode = ExitCode.Failure; | ||
exports.error(message); | ||
function getBooleanInput(name, options) { | ||
const trueValue = ['true', 'True', 'TRUE']; | ||
const falseValue = ['false', 'False', 'FALSE']; | ||
const val = getInput(name, options); | ||
if (trueValue.includes(val)) | ||
return true; | ||
if (falseValue.includes(val)) | ||
return false; | ||
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` + | ||
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); | ||
} | ||
exports.setFailed = setFailed; | ||
exports.getBooleanInput = getBooleanInput; | ||
//----------------------------------------------------------------------- | ||
// Logging Commands | ||
//----------------------------------------------------------------------- | ||
/** | ||
* Gets whether Actions Step Debug is on or not | ||
*/ | ||
const isDebug = () => { | ||
return process.env['RUNNER_DEBUG'] === '1'; | ||
}; | ||
exports.isDebug = isDebug; | ||
/** | ||
* Writes debug message to user log | ||
* @param message debug message | ||
*/ | ||
const debug = (message) => { | ||
exports.info(chalk.green(`::debug::${message}`)); | ||
}; | ||
exports.debug = debug; | ||
/** | ||
* Adds an error issue | ||
* @param message error issue message. Errors will be converted to string via toString() | ||
*/ | ||
const error = (message) => { | ||
exports.info(chalk.red(`::error::${message instanceof Error ? message.toString() : message}`)); | ||
}; | ||
exports.error = error; | ||
/** | ||
* Adds an warning issue | ||
* @param message warning issue message. Errors will be converted to string via toString() | ||
*/ | ||
const warning = (message) => { | ||
exports.info(chalk.yellow(`::warning::${message instanceof Error ? message.toString() : message}`)); | ||
}; | ||
exports.warning = warning; | ||
/** | ||
* Writes info to log with console.log. | ||
* @param message info message | ||
*/ | ||
const info = (message) => { | ||
process.stdout.write(message + os.EOL); | ||
}; | ||
exports.info = info; | ||
/** | ||
* Begin an output group. | ||
* | ||
* Output until the next `groupEnd` will be foldable in this group | ||
* | ||
* @param name The name of the output group | ||
*/ | ||
const startGroup = (name) => { | ||
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}::`); | ||
} | ||
}; | ||
exports.startGroup = startGroup; | ||
/** | ||
* End an output group. | ||
*/ | ||
const 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}::`); | ||
} | ||
}; | ||
exports.endGroup = endGroup; | ||
/** | ||
* Wrap an asynchronous function call in a group. | ||
* | ||
* Returns the same type as the function itself. | ||
* | ||
* @param name The name of the group | ||
* @param fn The function to wrap in the group | ||
*/ | ||
const group = (name, fn) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
exports.startGroup(name); | ||
let result; | ||
try { | ||
result = yield fn(); | ||
} | ||
finally { | ||
exports.endGroup(); | ||
} | ||
return result; | ||
}); | ||
exports.group = group; | ||
//----------------------------------------------------------------------- | ||
// Utils Commands | ||
@@ -170,4 +71,9 @@ //----------------------------------------------------------------------- | ||
exports.asyncForEach = asyncForEach; | ||
const parseBoolean = (value) => value === undefined ? undefined : value ? 'true' : 'false'; | ||
exports.parseBoolean = parseBoolean; | ||
const interpolate = (str) => { | ||
const replaced = str.replace(/\${?([a-zA-Z0-9_]+)?}?/g, (m1, g1) => { | ||
return process.env[g1] || m1; | ||
}); | ||
return replaced; | ||
}; | ||
exports.interpolate = interpolate; | ||
//# sourceMappingURL=core.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2
1
2
8586
125
1
+ Added@actions/core@1.4.0
+ Added@actions/core@1.4.0(transitive)
+ Added@actions/exec@1.1.0(transitive)
- Removedchalk@4.1.1
- Removedci-info@3.1.1
- Removed@actions/exec@1.0.4(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedchalk@4.1.1(transitive)
- Removedci-info@3.1.1(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedsupports-color@7.2.0(transitive)
Updated@actions/exec@1.1.0