This commit is contained in:
Paul Merlin 2020-06-13 16:37:06 +02:00
parent 36d51a403a
commit 720051268d
569 changed files with 2 additions and 61688 deletions

5
.gitignore vendored
View file

@ -1,6 +1,5 @@
__tests__/runner/* # Dependency directory
!lib/ node_modules
!node_modules
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore # Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs # Logs

View file

@ -1,51 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const exec = __importStar(require("@actions/exec"));
function execute(executable, root, argv) {
return __awaiter(this, void 0, void 0, function* () {
let publishing = false;
let buildScanUrl;
const status = yield exec.exec(executable, argv, {
cwd: root,
ignoreReturnCode: true,
listeners: {
stdline: (line) => {
if (line.startsWith("Publishing build scan...")) {
publishing = true;
}
if (publishing && line.length == 0) {
publishing = false;
}
if (publishing && line.startsWith("http")) {
buildScanUrl = line.trim();
publishing = false;
}
}
}
});
return new BuildResultImpl(status, buildScanUrl);
});
}
exports.execute = execute;
class BuildResultImpl {
constructor(status, buildScanUrl) {
this.status = status;
this.buildScanUrl = buildScanUrl;
}
}

View file

@ -1,11 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const IS_WINDOWS = process.platform === "win32";
function wrapperFilename() {
return IS_WINDOWS ? "gradlew.bat" : "gradlew";
}
exports.wrapperFilename = wrapperFilename;
function installScriptFilename() {
return IS_WINDOWS ? "gradle.bat" : "gradle";
}
exports.installScriptFilename = installScriptFilename;

View file

@ -1,77 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const path = __importStar(require("path"));
const string_argv_1 = require("string-argv");
const execution = __importStar(require("./execution"));
const gradlew = __importStar(require("./gradlew"));
const provision = __importStar(require("./provision"));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const baseDirectory = process.env[`GITHUB_WORKSPACE`] || "";
let result = yield execution.execute(yield resolveGradleExecutable(baseDirectory), resolveBuildRootDirectory(baseDirectory), parseCommandLineArguments());
if (result.buildScanUrl) {
core.setOutput("build-scan-url", result.buildScanUrl);
}
if (result.status != 0) {
core.setFailed(`Gradle process exited with status ${result.status}`);
}
}
catch (error) {
core.setFailed(error.message);
}
});
}
exports.run = run;
run();
function resolveGradleExecutable(baseDirectory) {
return __awaiter(this, void 0, void 0, function* () {
const gradleVersion = inputOrNull("gradle-version");
if (gradleVersion != null && gradleVersion != "wrapper") {
return path.resolve(yield provision.gradleVersion(gradleVersion));
}
const gradleExecutable = inputOrNull("gradle-executable");
if (gradleExecutable != null) {
return path.resolve(baseDirectory, gradleExecutable);
}
const wrapperDirectory = inputOrNull("wrapper-directory");
const executableDirectory = wrapperDirectory != null
? path.join(baseDirectory, wrapperDirectory)
: baseDirectory;
return path.resolve(executableDirectory, gradlew.wrapperFilename());
});
}
function resolveBuildRootDirectory(baseDirectory) {
let buildRootDirectory = inputOrNull("build-root-directory");
return buildRootDirectory == null
? path.resolve(baseDirectory)
: path.resolve(baseDirectory, buildRootDirectory);
}
function parseCommandLineArguments() {
const input = inputOrNull("arguments");
return input == null ? [] : string_argv_1.parseArgsStringToArgv(input);
}
function inputOrNull(name) {
const inputString = core.getInput(name);
if (inputString.length == 0) {
return null;
}
return inputString;
}

View file

@ -1,166 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const httpm = __importStar(require("typed-rest-client/HttpClient"));
const unzip = __importStar(require("unzipper"));
const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io"));
const toolCache = __importStar(require("@actions/tool-cache"));
const gradlew = __importStar(require("./gradlew"));
const httpc = new httpm.HttpClient("eskatos/gradle-command-action");
const gradleVersionsBaseUrl = "https://services.gradle.org/versions";
function gradleVersion(gradleVersion) {
return __awaiter(this, void 0, void 0, function* () {
switch (gradleVersion) {
case "current":
return gradleCurrent();
case "rc":
return gradleReleaseCandidate();
case "nightly":
return gradleNightly();
case "release-nightly":
return gradleReleaseNightly();
default:
return gradle(gradleVersion);
}
});
}
exports.gradleVersion = gradleVersion;
function gradleCurrent() {
return __awaiter(this, void 0, void 0, function* () {
const json = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/current`);
return provisionGradle(json.version, json.downloadUrl);
});
}
function gradleReleaseCandidate() {
return __awaiter(this, void 0, void 0, function* () {
const json = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-candidate`);
if (json) {
return provisionGradle(json.version, json.downloadUrl);
}
return gradleCurrent();
});
}
function gradleNightly() {
return __awaiter(this, void 0, void 0, function* () {
const json = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/nightly`);
return provisionGradle(json.version, json.downloadUrl);
});
}
function gradleReleaseNightly() {
return __awaiter(this, void 0, void 0, function* () {
const json = yield gradleVersionDeclaration(`${gradleVersionsBaseUrl}/release-nightly`);
return provisionGradle(json.version, json.downloadUrl);
});
}
function gradle(version) {
return __awaiter(this, void 0, void 0, function* () {
const declaration = yield findGradleVersionDeclaration(version);
if (!declaration) {
throw new Error(`Gradle version ${version} does not exists`);
}
return provisionGradle(declaration.version, declaration.downloadUrl);
});
}
function gradleVersionDeclaration(url) {
return __awaiter(this, void 0, void 0, function* () {
const json = yield httpGetJson(url);
return (json.version && json.version.length > 0) ? json : undefined;
});
}
function findGradleVersionDeclaration(version) {
return __awaiter(this, void 0, void 0, function* () {
const json = yield httpGetJson(`${gradleVersionsBaseUrl}/all`);
const found = json.find((entry) => {
return entry.version === version;
});
return found ? found : undefined;
});
}
function provisionGradle(version, url) {
return __awaiter(this, void 0, void 0, function* () {
const cachedInstall = toolCache.find("gradle", version);
if (cachedInstall.length > 0) {
const cachedExecutable = executableFrom(cachedInstall);
core.info(`Provisioned Gradle executable ${cachedExecutable}`);
return cachedExecutable;
}
const home = process.env["HOME"] || "";
const tmpdir = path.join(home, "gradle-provision-tmpdir");
const downloadsDir = path.join(tmpdir, "downloads");
const installsDir = path.join(tmpdir, "installs");
yield io.mkdirP(downloadsDir);
yield io.mkdirP(installsDir);
core.info(`Downloading ${url}`);
const downloadPath = path.join(downloadsDir, `gradle-${version}-bin.zip`);
yield httpDownload(url, downloadPath);
core.info(`Downloaded at ${downloadPath}, size ${fs.statSync(downloadPath).size}`);
yield extractZip(downloadPath, installsDir);
const installDir = path.join(installsDir, `gradle-${version}`);
core.info(`Extracted in ${installDir}`);
const executable = executableFrom(installDir);
fs.chmodSync(executable, "755");
core.info(`Provisioned Gradle executable ${executable}`);
toolCache.cacheDir(installDir, "gradle", version);
return executable;
});
}
function executableFrom(installDir) {
return path.join(installDir, "bin", `${gradlew.installScriptFilename()}`);
}
function httpGetJson(url) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield httpc.get(url);
const body = yield response.readBody();
return JSON.parse(body);
});
}
function httpDownload(url, path) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(function (resolve, reject) {
const writeStream = fs.createWriteStream(path);
httpc.get(url).then(response => {
response.message.pipe(writeStream)
.on("close", () => {
resolve();
})
.on("error", err => {
reject(err);
});
}).catch(reason => {
reject(reason);
});
});
});
}
function extractZip(zip, destination) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(function (resolve, reject) {
fs.createReadStream(zip)
.pipe(unzip.Extract({ "path": destination }))
.on("close", () => {
resolve();
})
.on("error", err => {
reject(err);
});
});
});
}

1
node_modules/.bin/mkdirp generated vendored
View file

@ -1 +0,0 @@
../mkdirp/bin/cmd.js

1
node_modules/.bin/rimraf generated vendored
View file

@ -1 +0,0 @@
../rimraf/bin.js

1
node_modules/.bin/uuid generated vendored
View file

@ -1 +0,0 @@
../uuid/bin/uuid

97
node_modules/@actions/core/README.md generated vendored
View file

@ -1,97 +0,0 @@
# `@actions/core`
> Core functions for setting results, logging, registering secrets and exporting variables across actions
## Usage
#### Inputs/Outputs
You can use this library to get inputs or set outputs:
```js
const core = require('@actions/core');
const myInput = core.getInput('inputName', { required: true });
// Do stuff
core.setOutput('outputKey', 'outputVal');
```
#### Exporting variables
You can also export variables for future steps. Variables get set in the environment.
```js
const core = require('@actions/core');
// Do stuff
core.exportVariable('envVar', 'Val');
```
#### PATH Manipulation
You can explicitly add items to the path for all remaining steps in a workflow:
```js
const core = require('@actions/core');
core.addPath('pathToTool');
```
#### Exit codes
You should use this library to set the failing exit code for your action:
```js
const core = require('@actions/core');
try {
// Do stuff
}
catch (err) {
// setFailed logs the message and sets a failing exit code
core.setFailed(`Action failed with error ${err}`);
}
```
#### Logging
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
```js
const core = require('@actions/core');
const myInput = core.getInput('input');
try {
core.debug('Inside try block');
if (!myInput) {
core.warning('myInput was not set');
}
// Do stuff
}
catch (err) {
core.error(`Error ${err}, action may still succeed though`);
}
```
This library can also wrap chunks of output in foldable groups.
```js
const core = require('@actions/core')
// Manually wrap output
core.startGroup('Do some function')
doSomeFunction()
core.endGroup()
// Wrap an asynchronous function call
const result = await core.group('Do something async', async () => {
const response = await doSomeHTTPRequest()
return response
})
```

View file

@ -1,16 +0,0 @@
interface CommandProperties {
[key: string]: string;
}
/**
* Commands
*
* Command Format:
* ##[name key=value;key=value]message
*
* Examples:
* ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definitelyNotAPassword!
*/
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
export declare function issue(name: string, message?: string): void;
export {};

View file

@ -1,66 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const os = require("os");
/**
* Commands
*
* Command Format:
* ##[name key=value;key=value]message
*
* Examples:
* ##[warning]This is the user warning message
* ##[set-secret name=mypassword]definitelyNotAPassword!
*/
function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message);
process.stdout.write(cmd.toString() + os.EOL);
}
exports.issueCommand = issueCommand;
function issue(name, message = '') {
issueCommand(name, {}, message);
}
exports.issue = issue;
const CMD_STRING = '::';
class Command {
constructor(command, properties, message) {
if (!command) {
command = 'missing.command';
}
this.command = command;
this.properties = properties;
this.message = message;
}
toString() {
let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' ';
for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key];
if (val) {
// safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)},`;
}
}
}
}
cmdStr += CMD_STRING;
// safely append the message - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason
const message = `${this.message || ''}`;
cmdStr += escapeData(message);
return cmdStr;
}
}
function escapeData(s) {
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
}
function escape(s) {
return s
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
.replace(/]/g, '%5D')
.replace(/;/g, '%3B');
}
//# sourceMappingURL=command.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,IAAI,CAAA;AAEvB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,UAAU,CAAA;QAEpB,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}

View file

@ -1,99 +0,0 @@
/**
* 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;
}
/**
* 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
}
/**
* sets env variable for this action and future actions in the job
* @param name the name of the variable to set
* @param val the value of the variable
*/
export declare function exportVariable(name: string, val: string): void;
/**
* exports the variable and registers a secret which will get masked from logs
* @param name the name of the variable to set
* @param val value of the secret
*/
export declare function exportSecret(name: string, val: string): void;
/**
* Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath
*/
export declare function addPath(inputPath: string): void;
/**
* Gets the value of an input. The value is also trimmed.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns string
*/
export declare function getInput(name: string, options?: InputOptions): string;
/**
* Sets the value of an output.
*
* @param name name of the output to set
* @param value value to store
*/
export declare function setOutput(name: string, value: string): void;
/**
* 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): void;
/**
* Writes debug message to user log
* @param message debug message
*/
export declare function debug(message: string): void;
/**
* Adds an error issue
* @param message error issue message
*/
export declare function error(message: string): void;
/**
* Adds an warning issue
* @param message warning issue message
*/
export declare function warning(message: string): void;
/**
* Writes info to log with console.log.
* @param message info message
*/
export declare function info(message: string): void;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
export declare function startGroup(name: string): void;
/**
* End an output group.
*/
export declare function 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 function group<T>(name: string, fn: () => Promise<T>): Promise<T>;

View file

@ -1,177 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("./command");
const os = require("os");
const path = require("path");
/**
* 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 = {}));
//-----------------------------------------------------------------------
// Variables
//-----------------------------------------------------------------------
/**
* sets env variable for this action and future actions in the job
* @param name the name of the variable to set
* @param val the value of the variable
*/
function exportVariable(name, val) {
process.env[name] = val;
command_1.issueCommand('set-env', { name }, val);
}
exports.exportVariable = exportVariable;
/**
* exports the variable and registers a secret which will get masked from logs
* @param name the name of the variable to set
* @param val value of the secret
*/
function exportSecret(name, val) {
exportVariable(name, val);
// the runner will error with not implemented
// leaving the function but raising the error earlier
command_1.issueCommand('set-secret', {}, val);
throw new Error('Not implemented.');
}
exports.exportSecret = exportSecret;
/**
* Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath
*/
function addPath(inputPath) {
command_1.issueCommand('add-path', {}, inputPath);
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
}
exports.addPath = addPath;
/**
* Gets the value of an input. The value is also trimmed.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns string
*/
function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
return val.trim();
}
exports.getInput = getInput;
/**
* Sets the value of an output.
*
* @param name name of the output to set
* @param value value to store
*/
function setOutput(name, value) {
command_1.issueCommand('set-output', { name }, value);
}
exports.setOutput = setOutput;
//-----------------------------------------------------------------------
// 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
*/
function setFailed(message) {
process.exitCode = ExitCode.Failure;
error(message);
}
exports.setFailed = setFailed;
//-----------------------------------------------------------------------
// Logging Commands
//-----------------------------------------------------------------------
/**
* Writes debug message to user log
* @param message debug message
*/
function debug(message) {
command_1.issueCommand('debug', {}, message);
}
exports.debug = debug;
/**
* Adds an error issue
* @param message error issue message
*/
function error(message) {
command_1.issue('error', message);
}
exports.error = error;
/**
* Adds an warning issue
* @param message warning issue message
*/
function warning(message) {
command_1.issue('warning', message);
}
exports.warning = warning;
/**
* Writes info to log with console.log.
* @param message info message
*/
function 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
*/
function startGroup(name) {
command_1.issue('group', name);
}
exports.startGroup = startGroup;
/**
* End an output group.
*/
function endGroup() {
command_1.issue('endgroup');
}
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
*/
function group(name, fn) {
return __awaiter(this, void 0, void 0, function* () {
startGroup(name);
let result;
try {
result = yield fn();
}
finally {
endGroup();
}
return result;
});
}
exports.group = group;
//# sourceMappingURL=core.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,yBAAwB;AACxB,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAEzB,6CAA6C;IAC7C,qDAAqD;IACrD,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC;AAPD,oCAOC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACrE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}

View file

@ -1,67 +0,0 @@
{
"_args": [
[
"@actions/core@1.1.1",
"/Users/paul/src/codeartisans/gradle-command-action"
]
],
"_from": "@actions/core@1.1.1",
"_id": "@actions/core@1.1.1",
"_inBundle": false,
"_integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg==",
"_location": "/@actions/core",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@actions/core@1.1.1",
"name": "@actions/core",
"escapedName": "@actions%2fcore",
"scope": "@actions",
"rawSpec": "1.1.1",
"saveSpec": null,
"fetchSpec": "1.1.1"
},
"_requiredBy": [
"/",
"/@actions/tool-cache"
],
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
"_spec": "1.1.1",
"_where": "/Users/paul/src/codeartisans/gradle-command-action",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
"description": "Actions core lib",
"devDependencies": {
"@types/node": "^12.0.2"
},
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
"keywords": [
"github",
"actions",
"core"
],
"license": "MIT",
"main": "lib/core.js",
"name": "@actions/core",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/toolkit.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc"
},
"version": "1.1.1"
}

View file

@ -1,7 +0,0 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

60
node_modules/@actions/exec/README.md generated vendored
View file

@ -1,60 +0,0 @@
# `@actions/exec`
## Usage
#### Basic
You can use this package to execute your tools on the command line in a cross platform way:
```js
const exec = require('@actions/exec');
await exec.exec('node index.js');
```
#### Args
You can also pass in arg arrays:
```js
const exec = require('@actions/exec');
await exec.exec('node', ['index.js', 'foo=bar']);
```
#### Output/options
Capture output or specify [other options](https://github.com/actions/toolkit/blob/d9347d4ab99fd507c0b9104b2cf79fb44fcc827d/packages/exec/src/interfaces.ts#L5):
```js
const exec = require('@actions/exec');
let myOutput = '';
let myError = '';
const options = {};
options.listeners = {
stdout: (data: Buffer) => {
myOutput += data.toString();
},
stderr: (data: Buffer) => {
myError += data.toString();
}
};
options.cwd = './lib';
await exec.exec('node', ['index.js', 'foo=bar'], options);
```
#### Exec tools not in the PATH
You can use it in conjunction with the `which` function from `@actions/io` to execute tools that are not in the PATH:
```js
const exec = require('@actions/exec');
const io = require('@actions/io');
const pythonPath: string = await io.which('python', true)
await exec.exec(`"${pythonPath}"`, ['main.py']);
```

View file

@ -1,12 +0,0 @@
import * as im from './interfaces';
/**
* Exec a command.
* Output will be streamed to the live console.
* Returns promise with return code
*
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
* @param args optional arguments for tool. Escaping is handled by the lib.
* @param options optional exec options. See ExecOptions
* @returns Promise<number> exit code
*/
export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>;

View file

@ -1,37 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const tr = require("./toolrunner");
/**
* Exec a command.
* Output will be streamed to the live console.
* Returns promise with return code
*
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
* @param args optional arguments for tool. Escaping is handled by the lib.
* @param options optional exec options. See ExecOptions
* @returns Promise<number> exit code
*/
function exec(commandLine, args, options) {
return __awaiter(this, void 0, void 0, function* () {
const commandArgs = tr.argStringToArray(commandLine);
if (commandArgs.length === 0) {
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
}
// Path to tool to execute should be first arg
const toolPath = commandArgs[0];
args = commandArgs.slice(1).concat(args || []);
const runner = new tr.ToolRunner(toolPath, args, options);
return runner.exec();
});
}
exports.exec = exec;
//# sourceMappingURL=exec.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,mCAAkC;AAElC;;;;;;;;;GASG;AACH,SAAsB,IAAI,CACxB,WAAmB,EACnB,IAAe,EACf,OAAwB;;QAExB,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QACpD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAkB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACxE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;IACtB,CAAC;CAAA;AAdD,oBAcC"}

View file

@ -1,35 +0,0 @@
/// <reference types="node" />
import * as stream from 'stream';
/**
* Interface for exec options
*/
export interface ExecOptions {
/** optional working directory. defaults to current */
cwd?: string;
/** optional envvar dictionary. defaults to current process's env */
env?: {
[key: string]: string;
};
/** optional. defaults to false */
silent?: boolean;
/** optional out stream to use. Defaults to process.stdout */
outStream?: stream.Writable;
/** optional err stream to use. Defaults to process.stderr */
errStream?: stream.Writable;
/** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */
windowsVerbatimArguments?: boolean;
/** optional. whether to fail if output to stderr. defaults to false */
failOnStdErr?: boolean;
/** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */
ignoreReturnCode?: boolean;
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
delay?: number;
/** optional. Listeners for output. Callback functions that will be called on these events */
listeners?: {
stdout?: (data: Buffer) => void;
stderr?: (data: Buffer) => void;
stdline?: (data: string) => void;
errline?: (data: string) => void;
debug?: (data: string) => void;
};
}

View file

@ -1,3 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}

View file

@ -1,37 +0,0 @@
/// <reference types="node" />
import * as events from 'events';
import * as im from './interfaces';
export declare class ToolRunner extends events.EventEmitter {
constructor(toolPath: string, args?: string[], options?: im.ExecOptions);
private toolPath;
private args;
private options;
private _debug;
private _getCommandString;
private _processLineBuffer;
private _getSpawnFileName;
private _getSpawnArgs;
private _endsWith;
private _isCmdFile;
private _windowsQuoteCmdArg;
private _uvQuoteCmdArg;
private _cloneExecOptions;
private _getSpawnOptions;
/**
* Exec a tool.
* Output will be streamed to the live console.
* Returns promise with return code
*
* @param tool path to tool to exec
* @param options optional exec options. See ExecOptions
* @returns number
*/
exec(): Promise<number>;
}
/**
* Convert an arg string to an array of args. Handles escaping
*
* @param argString string of arguments
* @returns string[] array of arguments
*/
export declare function argStringToArray(argString: string): string[];

View file

@ -1,574 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const os = require("os");
const events = require("events");
const child = require("child_process");
/* eslint-disable @typescript-eslint/unbound-method */
const IS_WINDOWS = process.platform === 'win32';
/*
* Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way.
*/
class ToolRunner extends events.EventEmitter {
constructor(toolPath, args, options) {
super();
if (!toolPath) {
throw new Error("Parameter 'toolPath' cannot be null or empty.");
}
this.toolPath = toolPath;
this.args = args || [];
this.options = options || {};
}
_debug(message) {
if (this.options.listeners && this.options.listeners.debug) {
this.options.listeners.debug(message);
}
}
_getCommandString(options, noPrefix) {
const toolPath = this._getSpawnFileName();
const args = this._getSpawnArgs(options);
let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool
if (IS_WINDOWS) {
// Windows + cmd file
if (this._isCmdFile()) {
cmd += toolPath;
for (const a of args) {
cmd += ` ${a}`;
}
}
// Windows + verbatim
else if (options.windowsVerbatimArguments) {
cmd += `"${toolPath}"`;
for (const a of args) {
cmd += ` ${a}`;
}
}
// Windows (regular)
else {
cmd += this._windowsQuoteCmdArg(toolPath);
for (const a of args) {
cmd += ` ${this._windowsQuoteCmdArg(a)}`;
}
}
}
else {
// OSX/Linux - this can likely be improved with some form of quoting.
// creating processes on Unix is fundamentally different than Windows.
// on Unix, execvp() takes an arg array.
cmd += toolPath;
for (const a of args) {
cmd += ` ${a}`;
}
}
return cmd;
}
_processLineBuffer(data, strBuffer, onLine) {
try {
let s = strBuffer + data.toString();
let n = s.indexOf(os.EOL);
while (n > -1) {
const line = s.substring(0, n);
onLine(line);
// the rest of the string ...
s = s.substring(n + os.EOL.length);
n = s.indexOf(os.EOL);
}
strBuffer = s;
}
catch (err) {
// streaming lines to console is best effort. Don't fail a build.
this._debug(`error processing line. Failed with error ${err}`);
}
}
_getSpawnFileName() {
if (IS_WINDOWS) {
if (this._isCmdFile()) {
return process.env['COMSPEC'] || 'cmd.exe';
}
}
return this.toolPath;
}
_getSpawnArgs(options) {
if (IS_WINDOWS) {
if (this._isCmdFile()) {
let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
for (const a of this.args) {
argline += ' ';
argline += options.windowsVerbatimArguments
? a
: this._windowsQuoteCmdArg(a);
}
argline += '"';
return [argline];
}
}
return this.args;
}
_endsWith(str, end) {
return str.endsWith(end);
}
_isCmdFile() {
const upperToolPath = this.toolPath.toUpperCase();
return (this._endsWith(upperToolPath, '.CMD') ||
this._endsWith(upperToolPath, '.BAT'));
}
_windowsQuoteCmdArg(arg) {
// for .exe, apply the normal quoting rules that libuv applies
if (!this._isCmdFile()) {
return this._uvQuoteCmdArg(arg);
}
// otherwise apply quoting rules specific to the cmd.exe command line parser.
// the libuv rules are generic and are not designed specifically for cmd.exe
// command line parser.
//
// for a detailed description of the cmd.exe command line parser, refer to
// http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
// need quotes for empty arg
if (!arg) {
return '""';
}
// determine whether the arg needs to be quoted
const cmdSpecialChars = [
' ',
'\t',
'&',
'(',
')',
'[',
']',
'{',
'}',
'^',
'=',
';',
'!',
"'",
'+',
',',
'`',
'~',
'|',
'<',
'>',
'"'
];
let needsQuotes = false;
for (const char of arg) {
if (cmdSpecialChars.some(x => x === char)) {
needsQuotes = true;
break;
}
}
// short-circuit if quotes not needed
if (!needsQuotes) {
return arg;
}
// the following quoting rules are very similar to the rules that by libuv applies.
//
// 1) wrap the string in quotes
//
// 2) double-up quotes - i.e. " => ""
//
// this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
// doesn't work well with a cmd.exe command line.
//
// note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
// for example, the command line:
// foo.exe "myarg:""my val"""
// is parsed by a .NET console app into an arg array:
// [ "myarg:\"my val\"" ]
// which is the same end result when applying libuv quoting rules. although the actual
// command line from libuv quoting rules would look like:
// foo.exe "myarg:\"my val\""
//
// 3) double-up slashes that precede a quote,
// e.g. hello \world => "hello \world"
// hello\"world => "hello\\""world"
// hello\\"world => "hello\\\\""world"
// hello world\ => "hello world\\"
//
// technically this is not required for a cmd.exe command line, or the batch argument parser.
// the reasons for including this as a .cmd quoting rule are:
//
// a) this is optimized for the scenario where the argument is passed from the .cmd file to an
// external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
//
// b) it's what we've been doing previously (by deferring to node default behavior) and we
// haven't heard any complaints about that aspect.
//
// note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
// escaped when used on the command line directly - even though within a .cmd file % can be escaped
// by using %%.
//
// the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
// the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
//
// one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
// often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
// variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
// to an external program.
//
// an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
// % can be escaped within a .cmd file.
let reverse = '"';
let quoteHit = true;
for (let i = arg.length; i > 0; i--) {
// walk the string in reverse
reverse += arg[i - 1];
if (quoteHit && arg[i - 1] === '\\') {
reverse += '\\'; // double the slash
}
else if (arg[i - 1] === '"') {
quoteHit = true;
reverse += '"'; // double the quote
}
else {
quoteHit = false;
}
}
reverse += '"';
return reverse
.split('')
.reverse()
.join('');
}
_uvQuoteCmdArg(arg) {
// Tool runner wraps child_process.spawn() and needs to apply the same quoting as
// Node in certain cases where the undocumented spawn option windowsVerbatimArguments
// is used.
//
// Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
// see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
// pasting copyright notice from Node within this function:
//
// Copyright Joyent, Inc. and other Node contributors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
if (!arg) {
// Need double quotation for empty argument
return '""';
}
if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) {
// No quotation needed
return arg;
}
if (!arg.includes('"') && !arg.includes('\\')) {
// No embedded double quotes or backslashes, so I can just wrap
// quote marks around the whole thing.
return `"${arg}"`;
}
// Expected input/output:
// input : hello"world
// output: "hello\"world"
// input : hello""world
// output: "hello\"\"world"
// input : hello\world
// output: hello\world
// input : hello\\world
// output: hello\\world
// input : hello\"world
// output: "hello\\\"world"
// input : hello\\"world
// output: "hello\\\\\"world"
// input : hello world\
// output: "hello world\\" - note the comment in libuv actually reads "hello world\"
// but it appears the comment is wrong, it should be "hello world\\"
let reverse = '"';
let quoteHit = true;
for (let i = arg.length; i > 0; i--) {
// walk the string in reverse
reverse += arg[i - 1];
if (quoteHit && arg[i - 1] === '\\') {
reverse += '\\';
}
else if (arg[i - 1] === '"') {
quoteHit = true;
reverse += '\\';
}
else {
quoteHit = false;
}
}
reverse += '"';
return reverse
.split('')
.reverse()
.join('');
}
_cloneExecOptions(options) {
options = options || {};
const result = {
cwd: options.cwd || process.cwd(),
env: options.env || process.env,
silent: options.silent || false,
windowsVerbatimArguments: options.windowsVerbatimArguments || false,
failOnStdErr: options.failOnStdErr || false,
ignoreReturnCode: options.ignoreReturnCode || false,
delay: options.delay || 10000
};
result.outStream = options.outStream || process.stdout;
result.errStream = options.errStream || process.stderr;
return result;
}
_getSpawnOptions(options, toolPath) {
options = options || {};
const result = {};
result.cwd = options.cwd;
result.env = options.env;
result['windowsVerbatimArguments'] =
options.windowsVerbatimArguments || this._isCmdFile();
if (options.windowsVerbatimArguments) {
result.argv0 = `"${toolPath}"`;
}
return result;
}
/**
* Exec a tool.
* Output will be streamed to the live console.
* Returns promise with return code
*
* @param tool path to tool to exec
* @param options optional exec options. See ExecOptions
* @returns number
*/
exec() {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
this._debug(`exec tool: ${this.toolPath}`);
this._debug('arguments:');
for (const arg of this.args) {
this._debug(` ${arg}`);
}
const optionsNonNull = this._cloneExecOptions(this.options);
if (!optionsNonNull.silent && optionsNonNull.outStream) {
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
}
const state = new ExecState(optionsNonNull, this.toolPath);
state.on('debug', (message) => {
this._debug(message);
});
const fileName = this._getSpawnFileName();
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
const stdbuffer = '';
if (cp.stdout) {
cp.stdout.on('data', (data) => {
if (this.options.listeners && this.options.listeners.stdout) {
this.options.listeners.stdout(data);
}
if (!optionsNonNull.silent && optionsNonNull.outStream) {
optionsNonNull.outStream.write(data);
}
this._processLineBuffer(data, stdbuffer, (line) => {
if (this.options.listeners && this.options.listeners.stdline) {
this.options.listeners.stdline(line);
}
});
});
}
const errbuffer = '';
if (cp.stderr) {
cp.stderr.on('data', (data) => {
state.processStderr = true;
if (this.options.listeners && this.options.listeners.stderr) {
this.options.listeners.stderr(data);
}
if (!optionsNonNull.silent &&
optionsNonNull.errStream &&
optionsNonNull.outStream) {
const s = optionsNonNull.failOnStdErr
? optionsNonNull.errStream
: optionsNonNull.outStream;
s.write(data);
}
this._processLineBuffer(data, errbuffer, (line) => {
if (this.options.listeners && this.options.listeners.errline) {
this.options.listeners.errline(line);
}
});
});
}
cp.on('error', (err) => {
state.processError = err.message;
state.processExited = true;
state.processClosed = true;
state.CheckComplete();
});
cp.on('exit', (code) => {
state.processExitCode = code;
state.processExited = true;
this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
state.CheckComplete();
});
cp.on('close', (code) => {
state.processExitCode = code;
state.processExited = true;
state.processClosed = true;
this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
state.CheckComplete();
});
state.on('done', (error, exitCode) => {
if (stdbuffer.length > 0) {
this.emit('stdline', stdbuffer);
}
if (errbuffer.length > 0) {
this.emit('errline', errbuffer);
}
cp.removeAllListeners();
if (error) {
reject(error);
}
else {
resolve(exitCode);
}
});
});
});
}
}
exports.ToolRunner = ToolRunner;
/**
* Convert an arg string to an array of args. Handles escaping
*
* @param argString string of arguments
* @returns string[] array of arguments
*/
function argStringToArray(argString) {
const args = [];
let inQuotes = false;
let escaped = false;
let arg = '';
function append(c) {
// we only escape double quotes.
if (escaped && c !== '"') {
arg += '\\';
}
arg += c;
escaped = false;
}
for (let i = 0; i < argString.length; i++) {
const c = argString.charAt(i);
if (c === '"') {
if (!escaped) {
inQuotes = !inQuotes;
}
else {
append(c);
}
continue;
}
if (c === '\\' && escaped) {
append(c);
continue;
}
if (c === '\\' && inQuotes) {
escaped = true;
continue;
}
if (c === ' ' && !inQuotes) {
if (arg.length > 0) {
args.push(arg);
arg = '';
}
continue;
}
append(c);
}
if (arg.length > 0) {
args.push(arg.trim());
}
return args;
}
exports.argStringToArray = argStringToArray;
class ExecState extends events.EventEmitter {
constructor(options, toolPath) {
super();
this.processClosed = false; // tracks whether the process has exited and stdio is closed
this.processError = '';
this.processExitCode = 0;
this.processExited = false; // tracks whether the process has exited
this.processStderr = false; // tracks whether stderr was written to
this.delay = 10000; // 10 seconds
this.done = false;
this.timeout = null;
if (!toolPath) {
throw new Error('toolPath must not be empty');
}
this.options = options;
this.toolPath = toolPath;
if (options.delay) {
this.delay = options.delay;
}
}
CheckComplete() {
if (this.done) {
return;
}
if (this.processClosed) {
this._setResult();
}
else if (this.processExited) {
this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
}
}
_debug(message) {
this.emit('debug', message);
}
_setResult() {
// determine whether there is an error
let error;
if (this.processExited) {
if (this.processError) {
error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
}
else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
}
else if (this.processStderr && this.options.failOnStdErr) {
error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
}
}
// clear the timeout
if (this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
this.done = true;
this.emit('done', error, this.processExitCode);
}
static HandleTimeout(state) {
if (state.done) {
return;
}
if (!state.processClosed && state.processExited) {
const message = `The STDIO streams did not close within ${state.delay /
1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
state._debug(message);
}
state._setResult();
}
}
//# sourceMappingURL=toolrunner.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,68 +0,0 @@
{
"_args": [
[
"@actions/exec@1.0.1",
"/Users/paul/src/codeartisans/gradle-command-action"
]
],
"_from": "@actions/exec@1.0.1",
"_id": "@actions/exec@1.0.1",
"_inBundle": false,
"_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ==",
"_location": "/@actions/exec",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@actions/exec@1.0.1",
"name": "@actions/exec",
"escapedName": "@actions%2fexec",
"scope": "@actions",
"rawSpec": "1.0.1",
"saveSpec": null,
"fetchSpec": "1.0.1"
},
"_requiredBy": [
"/",
"/@actions/tool-cache"
],
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz",
"_spec": "1.0.1",
"_where": "/Users/paul/src/codeartisans/gradle-command-action",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
"description": "Actions exec lib",
"devDependencies": {
"@actions/io": "^1.0.1"
},
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
"keywords": [
"github",
"actions",
"exec"
],
"license": "MIT",
"main": "lib/exec.js",
"name": "@actions/exec",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/toolkit.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc"
},
"version": "1.0.1"
}

View file

@ -1,7 +0,0 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

53
node_modules/@actions/io/README.md generated vendored
View file

@ -1,53 +0,0 @@
# `@actions/io`
> Core functions for cli filesystem scenarios
## Usage
#### mkdir -p
Recursively make a directory. Follows rules specified in [man mkdir](https://linux.die.net/man/1/mkdir) with the `-p` option specified:
```js
const io = require('@actions/io');
await io.mkdirP('path/to/make');
```
#### cp/mv
Copy or move files or folders. Follows rules specified in [man cp](https://linux.die.net/man/1/cp) and [man mv](https://linux.die.net/man/1/mv):
```js
const io = require('@actions/io');
// Recursive must be true for directories
const options = { recursive: true, force: false }
await io.cp('path/to/directory', 'path/to/dest', options);
await io.mv('path/to/file', 'path/to/dest');
```
#### rm -rf
Remove a file or folder recursively. Follows rules specified in [man rm](https://linux.die.net/man/1/rm) with the `-r` and `-f` rules specified.
```js
const io = require('@actions/io');
await io.rmRF('path/to/directory');
await io.rmRF('path/to/file');
```
#### which
Get the path to a tool and resolves via paths. Follows the rules specified in [man which](https://linux.die.net/man/1/which).
```js
const exec = require('@actions/exec');
const io = require('@actions/io');
const pythonPath: string = await io.which('python', true)
await exec.exec(`"${pythonPath}"`, ['main.py']);
```

View file

@ -1,29 +0,0 @@
/// <reference types="node" />
import * as fs from 'fs';
export declare const chmod: typeof fs.promises.chmod, copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, readlink: typeof fs.promises.readlink, rename: typeof fs.promises.rename, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, symlink: typeof fs.promises.symlink, unlink: typeof fs.promises.unlink;
export declare const IS_WINDOWS: boolean;
export declare function exists(fsPath: string): Promise<boolean>;
export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>;
/**
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
*/
export declare function isRooted(p: string): boolean;
/**
* Recursively create a directory at `fsPath`.
*
* This implementation is optimistic, meaning it attempts to create the full
* path first, and backs up the path stack from there.
*
* @param fsPath The path to create
* @param maxDepth The maximum recursion depth
* @param depth The current recursion depth
*/
export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>;
/**
* Best effort attempt to determine whether a file exists and is executable.
* @param filePath file path to check
* @param extensions additional file extensions to try
* @return if file exists and is executable, returns the file path. otherwise empty string.
*/
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;

View file

@ -1,195 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = require("assert");
const fs = require("fs");
const path = require("path");
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
exports.IS_WINDOWS = process.platform === 'win32';
function exists(fsPath) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield exports.stat(fsPath);
}
catch (err) {
if (err.code === 'ENOENT') {
return false;
}
throw err;
}
return true;
});
}
exports.exists = exists;
function isDirectory(fsPath, useStat = false) {
return __awaiter(this, void 0, void 0, function* () {
const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
return stats.isDirectory();
});
}
exports.isDirectory = isDirectory;
/**
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
*/
function isRooted(p) {
p = normalizeSeparators(p);
if (!p) {
throw new Error('isRooted() parameter "p" cannot be empty');
}
if (exports.IS_WINDOWS) {
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
); // e.g. C: or C:\hello
}
return p.startsWith('/');
}
exports.isRooted = isRooted;
/**
* Recursively create a directory at `fsPath`.
*
* This implementation is optimistic, meaning it attempts to create the full
* path first, and backs up the path stack from there.
*
* @param fsPath The path to create
* @param maxDepth The maximum recursion depth
* @param depth The current recursion depth
*/
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
return __awaiter(this, void 0, void 0, function* () {
assert_1.ok(fsPath, 'a path argument must be provided');
fsPath = path.resolve(fsPath);
if (depth >= maxDepth)
return exports.mkdir(fsPath);
try {
yield exports.mkdir(fsPath);
return;
}
catch (err) {
switch (err.code) {
case 'ENOENT': {
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
yield exports.mkdir(fsPath);
return;
}
default: {
let stats;
try {
stats = yield exports.stat(fsPath);
}
catch (err2) {
throw err;
}
if (!stats.isDirectory())
throw err;
}
}
}
});
}
exports.mkdirP = mkdirP;
/**
* Best effort attempt to determine whether a file exists and is executable.
* @param filePath file path to check
* @param extensions additional file extensions to try
* @return if file exists and is executable, returns the file path. otherwise empty string.
*/
function tryGetExecutablePath(filePath, extensions) {
return __awaiter(this, void 0, void 0, function* () {
let stats = undefined;
try {
// test file exists
stats = yield exports.stat(filePath);
}
catch (err) {
if (err.code !== 'ENOENT') {
// eslint-disable-next-line no-console
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
}
}
if (stats && stats.isFile()) {
if (exports.IS_WINDOWS) {
// on Windows, test for valid extension
const upperExt = path.extname(filePath).toUpperCase();
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
return filePath;
}
}
else {
if (isUnixExecutable(stats)) {
return filePath;
}
}
}
// try each extension
const originalFilePath = filePath;
for (const extension of extensions) {
filePath = originalFilePath + extension;
stats = undefined;
try {
stats = yield exports.stat(filePath);
}
catch (err) {
if (err.code !== 'ENOENT') {
// eslint-disable-next-line no-console
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
}
}
if (stats && stats.isFile()) {
if (exports.IS_WINDOWS) {
// preserve the case of the actual file (since an extension was appended)
try {
const directory = path.dirname(filePath);
const upperName = path.basename(filePath).toUpperCase();
for (const actualName of yield exports.readdir(directory)) {
if (upperName === actualName.toUpperCase()) {
filePath = path.join(directory, actualName);
break;
}
}
}
catch (err) {
// eslint-disable-next-line no-console
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
}
return filePath;
}
else {
if (isUnixExecutable(stats)) {
return filePath;
}
}
}
}
return '';
});
}
exports.tryGetExecutablePath = tryGetExecutablePath;
function normalizeSeparators(p) {
p = p || '';
if (exports.IS_WINDOWS) {
// convert slashes on Windows
p = p.replace(/\//g, '\\');
// remove redundant slashes
return p.replace(/\\\\+/g, '\\');
}
// remove redundant slashes
return p.replace(/\/\/+/g, '/');
}
// on Mac/Linux, test the execute bit
// R W X R W X R W X
// 256 128 64 32 16 8 4 2 1
function isUnixExecutable(stats) {
return ((stats.mode & 1) > 0 ||
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
}
//# sourceMappingURL=io-util.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAyB;AACzB,yBAAwB;AACxB,6BAA4B;AAEf,gBAYE,qTAAA;AAEF,QAAA,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AAEtD,SAAsB,MAAM,CAAC,MAAc;;QACzC,IAAI;YACF,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;SACnB;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,OAAO,KAAK,CAAA;aACb;YAED,MAAM,GAAG,CAAA;SACV;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAZD,wBAYC;AAED,SAAsB,WAAW,CAC/B,MAAc,EACd,UAAmB,KAAK;;QAExB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,YAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC;CAAA;AAND,kCAMC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,CAAS;IAChC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;KAC5D;IAED,IAAI,kBAAU,EAAE;QACd,OAAO,CACL,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,8BAA8B;SACxE,CAAA,CAAC,sBAAsB;KACzB;IAED,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAbD,4BAaC;AAED;;;;;;;;;GASG;AACH,SAAsB,MAAM,CAC1B,MAAc,EACd,WAAmB,IAAI,EACvB,QAAgB,CAAC;;QAEjB,WAAE,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAA;QAE9C,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE7B,IAAI,KAAK,IAAI,QAAQ;YAAE,OAAO,aAAK,CAAC,MAAM,CAAC,CAAA;QAE3C,IAAI;YACF,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;YACnB,OAAM;SACP;QAAC,OAAO,GAAG,EAAE;YACZ,QAAQ,GAAG,CAAC,IAAI,EAAE;gBAChB,KAAK,QAAQ,CAAC,CAAC;oBACb,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;oBACvD,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;oBACnB,OAAM;iBACP;gBACD,OAAO,CAAC,CAAC;oBACP,IAAI,KAAe,CAAA;oBAEnB,IAAI;wBACF,KAAK,GAAG,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;qBAC3B;oBAAC,OAAO,IAAI,EAAE;wBACb,MAAM,GAAG,CAAA;qBACV;oBAED,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;wBAAE,MAAM,GAAG,CAAA;iBACpC;aACF;SACF;IACH,CAAC;CAAA;AAlCD,wBAkCC;AAED;;;;;GAKG;AACH,SAAsB,oBAAoB,CACxC,QAAgB,EAChB,UAAoB;;QAEpB,IAAI,KAAK,GAAyB,SAAS,CAAA;QAC3C,IAAI;YACF,mBAAmB;YACnB,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;SAC7B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;aACF;SACF;QACD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAC3B,IAAI,kBAAU,EAAE;gBACd,uCAAuC;gBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;gBACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,EAAE;oBACpE,OAAO,QAAQ,CAAA;iBAChB;aACF;iBAAM;gBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;oBAC3B,OAAO,QAAQ,CAAA;iBAChB;aACF;SACF;QAED,qBAAqB;QACrB,MAAM,gBAAgB,GAAG,QAAQ,CAAA;QACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAAA;YAEvC,KAAK,GAAG,SAAS,CAAA;YACjB,IAAI;gBACF,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;aAC7B;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACzB,sCAAsC;oBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;iBACF;aACF;YAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;gBAC3B,IAAI,kBAAU,EAAE;oBACd,yEAAyE;oBACzE,IAAI;wBACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;wBACxC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;wBACvD,KAAK,MAAM,UAAU,IAAI,MAAM,eAAO,CAAC,SAAS,CAAC,EAAE;4BACjD,IAAI,SAAS,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE;gCAC1C,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;gCAC3C,MAAK;6BACN;yBACF;qBACF;oBAAC,OAAO,GAAG,EAAE;wBACZ,sCAAsC;wBACtC,OAAO,CAAC,GAAG,CACT,yEAAyE,QAAQ,MAAM,GAAG,EAAE,CAC7F,CAAA;qBACF;oBAED,OAAO,QAAQ,CAAA;iBAChB;qBAAM;oBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;wBAC3B,OAAO,QAAQ,CAAA;qBAChB;iBACF;aACF;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA5ED,oDA4EC;AAED,SAAS,mBAAmB,CAAC,CAAS;IACpC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACX,IAAI,kBAAU,EAAE;QACd,6BAA6B;QAC7B,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAE1B,2BAA2B;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;KACjC;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,qCAAqC;AACrC,6BAA6B;AAC7B,6BAA6B;AAC7B,SAAS,gBAAgB,CAAC,KAAe;IACvC,OAAO,CACL,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACxD,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC"}

56
node_modules/@actions/io/lib/io.d.ts generated vendored
View file

@ -1,56 +0,0 @@
/**
* Interface for cp/mv options
*/
export interface CopyOptions {
/** Optional. Whether to recursively copy all subdirectories. Defaults to false */
recursive?: boolean;
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
force?: boolean;
}
/**
* Interface for cp/mv options
*/
export interface MoveOptions {
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
force?: boolean;
}
/**
* Copies a file or folder.
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
*
* @param source source path
* @param dest destination path
* @param options optional. See CopyOptions.
*/
export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>;
/**
* Moves a path.
*
* @param source source path
* @param dest destination path
* @param options optional. See MoveOptions.
*/
export declare function mv(source: string, dest: string, options?: MoveOptions): Promise<void>;
/**
* Remove a path recursively with force
*
* @param inputPath path to remove
*/
export declare function rmRF(inputPath: string): Promise<void>;
/**
* Make a directory. Creates the full path with folders in between
* Will throw if it fails
*
* @param fsPath path to create
* @returns Promise<void>
*/
export declare function mkdirP(fsPath: string): Promise<void>;
/**
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
* If you check and the tool does not exist, it will throw.
*
* @param tool name of the tool
* @param check whether to check if tool exists
* @returns Promise<string> path to tool
*/
export declare function which(tool: string, check?: boolean): Promise<string>;

290
node_modules/@actions/io/lib/io.js generated vendored
View file

@ -1,290 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const childProcess = require("child_process");
const path = require("path");
const util_1 = require("util");
const ioUtil = require("./io-util");
const exec = util_1.promisify(childProcess.exec);
/**
* Copies a file or folder.
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
*
* @param source source path
* @param dest destination path
* @param options optional. See CopyOptions.
*/
function cp(source, dest, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const { force, recursive } = readCopyOptions(options);
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
// Dest is an existing file, but not forcing
if (destStat && destStat.isFile() && !force) {
return;
}
// If dest is an existing directory, should copy inside.
const newDest = destStat && destStat.isDirectory()
? path.join(dest, path.basename(source))
: dest;
if (!(yield ioUtil.exists(source))) {
throw new Error(`no such file or directory: ${source}`);
}
const sourceStat = yield ioUtil.stat(source);
if (sourceStat.isDirectory()) {
if (!recursive) {
throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
}
else {
yield cpDirRecursive(source, newDest, 0, force);
}
}
else {
if (path.relative(source, newDest) === '') {
// a file cannot be copied to itself
throw new Error(`'${newDest}' and '${source}' are the same file`);
}
yield copyFile(source, newDest, force);
}
});
}
exports.cp = cp;
/**
* Moves a path.
*
* @param source source path
* @param dest destination path
* @param options optional. See MoveOptions.
*/
function mv(source, dest, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
if (yield ioUtil.exists(dest)) {
let destExists = true;
if (yield ioUtil.isDirectory(dest)) {
// If dest is directory copy src into dest
dest = path.join(dest, path.basename(source));
destExists = yield ioUtil.exists(dest);
}
if (destExists) {
if (options.force == null || options.force) {
yield rmRF(dest);
}
else {
throw new Error('Destination already exists');
}
}
}
yield mkdirP(path.dirname(dest));
yield ioUtil.rename(source, dest);
});
}
exports.mv = mv;
/**
* Remove a path recursively with force
*
* @param inputPath path to remove
*/
function rmRF(inputPath) {
return __awaiter(this, void 0, void 0, function* () {
if (ioUtil.IS_WINDOWS) {
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
try {
if (yield ioUtil.isDirectory(inputPath, true)) {
yield exec(`rd /s /q "${inputPath}"`);
}
else {
yield exec(`del /f /a "${inputPath}"`);
}
}
catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT')
throw err;
}
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
try {
yield ioUtil.unlink(inputPath);
}
catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT')
throw err;
}
}
else {
let isDir = false;
try {
isDir = yield ioUtil.isDirectory(inputPath);
}
catch (err) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if (err.code !== 'ENOENT')
throw err;
return;
}
if (isDir) {
yield exec(`rm -rf "${inputPath}"`);
}
else {
yield ioUtil.unlink(inputPath);
}
}
});
}
exports.rmRF = rmRF;
/**
* Make a directory. Creates the full path with folders in between
* Will throw if it fails
*
* @param fsPath path to create
* @returns Promise<void>
*/
function mkdirP(fsPath) {
return __awaiter(this, void 0, void 0, function* () {
yield ioUtil.mkdirP(fsPath);
});
}
exports.mkdirP = mkdirP;
/**
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
* If you check and the tool does not exist, it will throw.
*
* @param tool name of the tool
* @param check whether to check if tool exists
* @returns Promise<string> path to tool
*/
function which(tool, check) {
return __awaiter(this, void 0, void 0, function* () {
if (!tool) {
throw new Error("parameter 'tool' is required");
}
// recursive when check=true
if (check) {
const result = yield which(tool, false);
if (!result) {
if (ioUtil.IS_WINDOWS) {
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
}
else {
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
}
}
}
try {
// build the list of extensions to try
const extensions = [];
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
if (extension) {
extensions.push(extension);
}
}
}
// if it's rooted, return it if exists. otherwise return empty.
if (ioUtil.isRooted(tool)) {
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
if (filePath) {
return filePath;
}
return '';
}
// if any path separators, return empty
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
return '';
}
// build the list of directories
//
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
// it feels like we should not do this. Checking the current directory seems like more of a use
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
// across platforms.
const directories = [];
if (process.env.PATH) {
for (const p of process.env.PATH.split(path.delimiter)) {
if (p) {
directories.push(p);
}
}
}
// return the first match
for (const directory of directories) {
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
if (filePath) {
return filePath;
}
}
return '';
}
catch (err) {
throw new Error(`which failed with message ${err.message}`);
}
});
}
exports.which = which;
function readCopyOptions(options) {
const force = options.force == null ? true : options.force;
const recursive = Boolean(options.recursive);
return { force, recursive };
}
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
return __awaiter(this, void 0, void 0, function* () {
// Ensure there is not a run away recursive copy
if (currentDepth >= 255)
return;
currentDepth++;
yield mkdirP(destDir);
const files = yield ioUtil.readdir(sourceDir);
for (const fileName of files) {
const srcFile = `${sourceDir}/${fileName}`;
const destFile = `${destDir}/${fileName}`;
const srcFileStat = yield ioUtil.lstat(srcFile);
if (srcFileStat.isDirectory()) {
// Recurse
yield cpDirRecursive(srcFile, destFile, currentDepth, force);
}
else {
yield copyFile(srcFile, destFile, force);
}
}
// Change the mode for the newly created directory
yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
});
}
// Buffered file copy
function copyFile(srcFile, destFile, force) {
return __awaiter(this, void 0, void 0, function* () {
if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
// unlink/re-link it
try {
yield ioUtil.lstat(destFile);
yield ioUtil.unlink(destFile);
}
catch (e) {
// Try to override file permission
if (e.code === 'EPERM') {
yield ioUtil.chmod(destFile, '0666');
yield ioUtil.unlink(destFile);
}
// other errors = it doesn't exist, no work to do
}
// Copy over symlink
const symlinkFull = yield ioUtil.readlink(srcFile);
yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null);
}
else if (!(yield ioUtil.exists(destFile)) || force) {
yield ioUtil.copyFile(srcFile, destFile);
}
});
}
//# sourceMappingURL=io.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,65 +0,0 @@
{
"_args": [
[
"@actions/io@1.0.1",
"/Users/paul/src/codeartisans/gradle-command-action"
]
],
"_from": "@actions/io@1.0.1",
"_id": "@actions/io@1.0.1",
"_inBundle": false,
"_integrity": "sha512-rhq+tfZukbtaus7xyUtwKfuiCRXd1hWSfmJNEpFgBQJ4woqPEpsBw04awicjwz9tyG2/MVhAEMfVn664Cri5zA==",
"_location": "/@actions/io",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@actions/io@1.0.1",
"name": "@actions/io",
"escapedName": "@actions%2fio",
"scope": "@actions",
"rawSpec": "1.0.1",
"saveSpec": null,
"fetchSpec": "1.0.1"
},
"_requiredBy": [
"/",
"/@actions/tool-cache"
],
"_resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.1.tgz",
"_spec": "1.0.1",
"_where": "/Users/paul/src/codeartisans/gradle-command-action",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
"description": "Actions io lib",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
"keywords": [
"github",
"actions",
"io"
],
"license": "MIT",
"main": "lib/io.js",
"name": "@actions/io",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/toolkit.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc"
},
"version": "1.0.1"
}

View file

@ -1,7 +0,0 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,82 +0,0 @@
# `@actions/tool-cache`
> Functions necessary for downloading and caching tools.
## Usage
#### Download
You can use this to download tools (or other files) from a download URL:
```js
const tc = require('@actions/tool-cache');
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
```
#### Extract
These can then be extracted in platform specific ways:
```js
const tc = require('@actions/tool-cache');
if (process.platform === 'win32') {
const node12Path = tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to');
// Or alternately
const node12Path = tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
}
else {
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
}
```
#### Cache
Finally, you can cache these directories in our tool-cache. This is useful if you want to switch back and forth between versions of a tool, or save a tool between runs for private runners (private runners are still in development but are on the roadmap).
You'll often want to add it to the path as part of this step:
```js
const tc = require('@actions/tool-cache');
const core = require('@actions/core');
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0');
core.addPath(cachedPath);
```
You can also cache files for reuse.
```js
const tc = require('@actions/tool-cache');
tc.cacheFile('path/to/exe', 'destFileName.exe', 'myExeName', '1.1.0');
```
#### Find
Finally, you can find directories and files you've previously cached:
```js
const tc = require('@actions/tool-cache');
const core = require('@actions/core');
const nodeDirectory = tc.find('node', '12.x', 'x64');
core.addPath(nodeDirectory);
```
You can even find all cached versions of a tool:
```js
const tc = require('@actions/tool-cache');
const allNodeVersions = tc.findAllVersions('node');
console.log(`Versions of node available: ${allNodeVersions}`);
```

View file

@ -1,79 +0,0 @@
export declare class HTTPError extends Error {
readonly httpStatusCode: number | undefined;
constructor(httpStatusCode: number | undefined);
}
/**
* Download a tool from an url and stream it into a file
*
* @param url url of tool to download
* @returns path to downloaded tool
*/
export declare function downloadTool(url: string): Promise<string>;
/**
* Extract a .7z file
*
* @param file path to the .7z file
* @param dest destination directory. Optional.
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
* interface, it is smaller than the full command line interface, and it does support long paths. At the
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
* to 7zr.exe can be pass to this function.
* @returns path to the destination directory
*/
export declare function extract7z(file: string, dest?: string, _7zPath?: string): Promise<string>;
/**
* Extract a tar
*
* @param file path to the tar
* @param dest destination directory. Optional.
* @param flags flags for the tar. Optional.
* @returns path to the destination directory
*/
export declare function extractTar(file: string, dest?: string, flags?: string): Promise<string>;
/**
* Extract a zip
*
* @param file path to the zip
* @param dest destination directory. Optional.
* @returns path to the destination directory
*/
export declare function extractZip(file: string, dest?: string): Promise<string>;
/**
* Caches a directory and installs it into the tool cacheDir
*
* @param sourceDir the directory to cache into tools
* @param tool tool name
* @param version version of the tool. semver format
* @param arch architecture of the tool. Optional. Defaults to machine architecture
*/
export declare function cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string>;
/**
* Caches a downloaded file (GUID) and installs it
* into the tool cache with a given targetName
*
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
* @param targetFile the name of the file name in the tools directory
* @param tool tool name
* @param version version of the tool. semver format
* @param arch architecture of the tool. Optional. Defaults to machine architecture
*/
export declare function cacheFile(sourceFile: string, targetFile: string, tool: string, version: string, arch?: string): Promise<string>;
/**
* Finds the path to a tool version in the local installed tool cache
*
* @param toolName name of the tool
* @param versionSpec version of the tool
* @param arch optional arch. defaults to arch of computer
*/
export declare function find(toolName: string, versionSpec: string, arch?: string): string;
/**
* Finds the paths to all versions of a tool that are installed in the local tool cache
*
* @param toolName name of the tool
* @param arch optional arch. defaults to arch of computer
*/
export declare function findAllVersions(toolName: string, arch?: string): string[];

View file

@ -1,449 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = require("@actions/core");
const io = require("@actions/io");
const fs = require("fs");
const os = require("os");
const path = require("path");
const httpm = require("typed-rest-client/HttpClient");
const semver = require("semver");
const uuidV4 = require("uuid/v4");
const exec_1 = require("@actions/exec/lib/exec");
const assert_1 = require("assert");
class HTTPError extends Error {
constructor(httpStatusCode) {
super(`Unexpected HTTP response: ${httpStatusCode}`);
this.httpStatusCode = httpStatusCode;
Object.setPrototypeOf(this, new.target.prototype);
}
}
exports.HTTPError = HTTPError;
const IS_WINDOWS = process.platform === 'win32';
const userAgent = 'actions/tool-cache';
// On load grab temp directory and cache directory and remove them from env (currently don't want to expose this)
let tempDirectory = process.env['RUNNER_TEMP'] || '';
let cacheRoot = process.env['RUNNER_TOOL_CACHE'] || '';
// If directories not found, place them in common temp locations
if (!tempDirectory || !cacheRoot) {
let baseLocation;
if (IS_WINDOWS) {
// On windows use the USERPROFILE env variable
baseLocation = process.env['USERPROFILE'] || 'C:\\';
}
else {
if (process.platform === 'darwin') {
baseLocation = '/Users';
}
else {
baseLocation = '/home';
}
}
if (!tempDirectory) {
tempDirectory = path.join(baseLocation, 'actions', 'temp');
}
if (!cacheRoot) {
cacheRoot = path.join(baseLocation, 'actions', 'cache');
}
}
/**
* Download a tool from an url and stream it into a file
*
* @param url url of tool to download
* @returns path to downloaded tool
*/
function downloadTool(url) {
return __awaiter(this, void 0, void 0, function* () {
// Wrap in a promise so that we can resolve from within stream callbacks
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
try {
const http = new httpm.HttpClient(userAgent, [], {
allowRetries: true,
maxRetries: 3
});
const destPath = path.join(tempDirectory, uuidV4());
yield io.mkdirP(tempDirectory);
core.debug(`Downloading ${url}`);
core.debug(`Downloading ${destPath}`);
if (fs.existsSync(destPath)) {
throw new Error(`Destination file path ${destPath} already exists`);
}
const response = yield http.get(url);
if (response.message.statusCode !== 200) {
const err = new HTTPError(response.message.statusCode);
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
throw err;
}
const file = fs.createWriteStream(destPath);
file.on('open', () => __awaiter(this, void 0, void 0, function* () {
try {
const stream = response.message.pipe(file);
stream.on('close', () => {
core.debug('download complete');
resolve(destPath);
});
}
catch (err) {
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
reject(err);
}
}));
file.on('error', err => {
file.end();
reject(err);
});
}
catch (err) {
reject(err);
}
}));
});
}
exports.downloadTool = downloadTool;
/**
* Extract a .7z file
*
* @param file path to the .7z file
* @param dest destination directory. Optional.
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
* interface, it is smaller than the full command line interface, and it does support long paths. At the
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
* to 7zr.exe can be pass to this function.
* @returns path to the destination directory
*/
function extract7z(file, dest, _7zPath) {
return __awaiter(this, void 0, void 0, function* () {
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
assert_1.ok(file, 'parameter "file" is required');
dest = dest || (yield _createExtractFolder(dest));
const originalCwd = process.cwd();
process.chdir(dest);
if (_7zPath) {
try {
const args = [
'x',
'-bb1',
'-bd',
'-sccUTF-8',
file
];
const options = {
silent: true
};
yield exec_1.exec(`"${_7zPath}"`, args, options);
}
finally {
process.chdir(originalCwd);
}
}
else {
const escapedScript = path
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
.replace(/'/g, "''")
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
];
const options = {
silent: true
};
try {
const powershellPath = yield io.which('powershell', true);
yield exec_1.exec(`"${powershellPath}"`, args, options);
}
finally {
process.chdir(originalCwd);
}
}
return dest;
});
}
exports.extract7z = extract7z;
/**
* Extract a tar
*
* @param file path to the tar
* @param dest destination directory. Optional.
* @param flags flags for the tar. Optional.
* @returns path to the destination directory
*/
function extractTar(file, dest, flags = 'xz') {
return __awaiter(this, void 0, void 0, function* () {
if (!file) {
throw new Error("parameter 'file' is required");
}
dest = dest || (yield _createExtractFolder(dest));
const tarPath = yield io.which('tar', true);
yield exec_1.exec(`"${tarPath}"`, [flags, '-C', dest, '-f', file]);
return dest;
});
}
exports.extractTar = extractTar;
/**
* Extract a zip
*
* @param file path to the zip
* @param dest destination directory. Optional.
* @returns path to the destination directory
*/
function extractZip(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
if (!file) {
throw new Error("parameter 'file' is required");
}
dest = dest || (yield _createExtractFolder(dest));
if (IS_WINDOWS) {
yield extractZipWin(file, dest);
}
else {
if (process.platform === 'darwin') {
yield extractZipDarwin(file, dest);
}
else {
yield extractZipNix(file, dest);
}
}
return dest;
});
}
exports.extractZip = extractZip;
function extractZipWin(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
// build the powershell command
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
// run powershell
const powershellPath = yield io.which('powershell');
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
];
yield exec_1.exec(`"${powershellPath}"`, args);
});
}
function extractZipNix(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
});
}
function extractZipDarwin(file, dest) {
return __awaiter(this, void 0, void 0, function* () {
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip-darwin');
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
});
}
/**
* Caches a directory and installs it into the tool cacheDir
*
* @param sourceDir the directory to cache into tools
* @param tool tool name
* @param version version of the tool. semver format
* @param arch architecture of the tool. Optional. Defaults to machine architecture
*/
function cacheDir(sourceDir, tool, version, arch) {
return __awaiter(this, void 0, void 0, function* () {
version = semver.clean(version) || version;
arch = arch || os.arch();
core.debug(`Caching tool ${tool} ${version} ${arch}`);
core.debug(`source dir: ${sourceDir}`);
if (!fs.statSync(sourceDir).isDirectory()) {
throw new Error('sourceDir is not a directory');
}
// Create the tool dir
const destPath = yield _createToolPath(tool, version, arch);
// copy each child item. do not move. move can fail on Windows
// due to anti-virus software having an open handle on a file.
for (const itemName of fs.readdirSync(sourceDir)) {
const s = path.join(sourceDir, itemName);
yield io.cp(s, destPath, { recursive: true });
}
// write .complete
_completeToolPath(tool, version, arch);
return destPath;
});
}
exports.cacheDir = cacheDir;
/**
* Caches a downloaded file (GUID) and installs it
* into the tool cache with a given targetName
*
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
* @param targetFile the name of the file name in the tools directory
* @param tool tool name
* @param version version of the tool. semver format
* @param arch architecture of the tool. Optional. Defaults to machine architecture
*/
function cacheFile(sourceFile, targetFile, tool, version, arch) {
return __awaiter(this, void 0, void 0, function* () {
version = semver.clean(version) || version;
arch = arch || os.arch();
core.debug(`Caching tool ${tool} ${version} ${arch}`);
core.debug(`source file: ${sourceFile}`);
if (!fs.statSync(sourceFile).isFile()) {
throw new Error('sourceFile is not a file');
}
// create the tool dir
const destFolder = yield _createToolPath(tool, version, arch);
// copy instead of move. move can fail on Windows due to
// anti-virus software having an open handle on a file.
const destPath = path.join(destFolder, targetFile);
core.debug(`destination file ${destPath}`);
yield io.cp(sourceFile, destPath);
// write .complete
_completeToolPath(tool, version, arch);
return destFolder;
});
}
exports.cacheFile = cacheFile;
/**
* Finds the path to a tool version in the local installed tool cache
*
* @param toolName name of the tool
* @param versionSpec version of the tool
* @param arch optional arch. defaults to arch of computer
*/
function find(toolName, versionSpec, arch) {
if (!toolName) {
throw new Error('toolName parameter is required');
}
if (!versionSpec) {
throw new Error('versionSpec parameter is required');
}
arch = arch || os.arch();
// attempt to resolve an explicit version
if (!_isExplicitVersion(versionSpec)) {
const localVersions = findAllVersions(toolName, arch);
const match = _evaluateVersions(localVersions, versionSpec);
versionSpec = match;
}
// check for the explicit version in the cache
let toolPath = '';
if (versionSpec) {
versionSpec = semver.clean(versionSpec) || '';
const cachePath = path.join(cacheRoot, toolName, versionSpec, arch);
core.debug(`checking cache: ${cachePath}`);
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
toolPath = cachePath;
}
else {
core.debug('not found');
}
}
return toolPath;
}
exports.find = find;
/**
* Finds the paths to all versions of a tool that are installed in the local tool cache
*
* @param toolName name of the tool
* @param arch optional arch. defaults to arch of computer
*/
function findAllVersions(toolName, arch) {
const versions = [];
arch = arch || os.arch();
const toolPath = path.join(cacheRoot, toolName);
if (fs.existsSync(toolPath)) {
const children = fs.readdirSync(toolPath);
for (const child of children) {
if (_isExplicitVersion(child)) {
const fullPath = path.join(toolPath, child, arch || '');
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
versions.push(child);
}
}
}
}
return versions;
}
exports.findAllVersions = findAllVersions;
function _createExtractFolder(dest) {
return __awaiter(this, void 0, void 0, function* () {
if (!dest) {
// create a temp dir
dest = path.join(tempDirectory, uuidV4());
}
yield io.mkdirP(dest);
return dest;
});
}
function _createToolPath(tool, version, arch) {
return __awaiter(this, void 0, void 0, function* () {
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
core.debug(`destination ${folderPath}`);
const markerPath = `${folderPath}.complete`;
yield io.rmRF(folderPath);
yield io.rmRF(markerPath);
yield io.mkdirP(folderPath);
return folderPath;
});
}
function _completeToolPath(tool, version, arch) {
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
const markerPath = `${folderPath}.complete`;
fs.writeFileSync(markerPath, '');
core.debug('finished caching tool');
}
function _isExplicitVersion(versionSpec) {
const c = semver.clean(versionSpec) || '';
core.debug(`isExplicit: ${c}`);
const valid = semver.valid(c) != null;
core.debug(`explicit? ${valid}`);
return valid;
}
function _evaluateVersions(versions, versionSpec) {
let version = '';
core.debug(`evaluating ${versions.length} versions`);
versions = versions.sort((a, b) => {
if (semver.gt(a, b)) {
return 1;
}
return -1;
});
for (let i = versions.length - 1; i >= 0; i--) {
const potential = versions[i];
const satisfied = semver.satisfies(potential, versionSpec);
if (satisfied) {
version = potential;
break;
}
}
if (version) {
core.debug(`matched: ${version}`);
}
else {
core.debug('match not found');
}
return version;
}
//# sourceMappingURL=tool-cache.js.map

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
../semver/bin/semver.js

View file

@ -1,70 +0,0 @@
# changes log
## 6.2.0
* Coerce numbers to strings when passed to semver.coerce()
* Add `rtl` option to coerce from right to left
## 6.1.3
* Handle X-ranges properly in includePrerelease mode
## 6.1.2
* Do not throw when testing invalid version strings
## 6.1.1
* Add options support for semver.coerce()
* Handle undefined version passed to Range.test
## 6.1.0
* Add semver.compareBuild function
* Support `*` in semver.intersects
## 6.0
* Fix `intersects` logic.
This is technically a bug fix, but since it is also a change to behavior
that may require users updating their code, it is marked as a major
version increment.
## 5.7
* Add `minVersion` method
## 5.6
* Move boolean `loose` param to an options object, with
backwards-compatibility protection.
* Add ability to opt out of special prerelease version handling with
the `includePrerelease` option flag.
## 5.5
* Add version coercion capabilities
## 5.4
* Add intersection checking
## 5.3
* Add `minSatisfying` method
## 5.2
* Add `prerelease(v)` that returns prerelease components
## 5.1
* Add Backus-Naur for ranges
* Remove excessively cute inspection methods
## 5.0
* Remove AMD/Browserified build artifacts
* Fix ltr and gtr when using the `*` range
* Fix for range `*` with a prerelease identifier

View file

@ -1,15 +0,0 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View file

@ -1,443 +0,0 @@
semver(1) -- The semantic versioner for npm
===========================================
## Install
```bash
npm install semver
````
## Usage
As a node module:
```js
const semver = require('semver')
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
semver.clean(' =v1.2.3 ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.gt('1.2.3', '9.8.7') // false
semver.lt('1.2.3', '9.8.7') // true
semver.minVersion('>=1.0.0') // '1.0.0'
semver.valid(semver.coerce('v2')) // '2.0.0'
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
```
As a command-line utility:
```
$ semver -h
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] <version> [<version> [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range <range>
Print versions that match the specified range.
-i --increment [<level>]
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, or prerelease. Default level is 'patch'.
Only one version may be specified.
--preid <identifier>
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
```
## Versions
A "version" is described by the `v2.0.0` specification found at
<https://semver.org/>.
A leading `"="` or `"v"` character is stripped off and ignored.
## Ranges
A `version range` is a set of `comparators` which specify versions
that satisfy the range.
A `comparator` is composed of an `operator` and a `version`. The set
of primitive `operators` is:
* `<` Less than
* `<=` Less than or equal to
* `>` Greater than
* `>=` Greater than or equal to
* `=` Equal. If no operator is specified, then equality is assumed,
so this operator is optional, but MAY be included.
For example, the comparator `>=1.2.7` would match the versions
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
or `1.1.0`.
Comparators can be joined by whitespace to form a `comparator set`,
which is satisfied by the **intersection** of all of the comparators
it includes.
A range is composed of one or more comparator sets, joined by `||`. A
version matches a range if and only if every comparator in at least
one of the `||`-separated comparator sets is satisfied by the version.
For example, the range `>=1.2.7 <1.3.0` would match the versions
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
or `1.1.0`.
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
### Prerelease Tags
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
it will only be allowed to satisfy comparator sets if at least one
comparator with the same `[major, minor, patch]` tuple also has a
prerelease tag.
For example, the range `>1.2.3-alpha.3` would be allowed to match the
version `1.2.3-alpha.7`, but it would *not* be satisfied by
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
range only accepts prerelease tags on the `1.2.3` version. The
version `3.4.5` *would* satisfy the range, because it does not have a
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
The purpose for this behavior is twofold. First, prerelease versions
frequently are updated very quickly, and contain many breaking changes
that are (by the author's design) not yet fit for public consumption.
Therefore, by default, they are excluded from range matching
semantics.
Second, a user who has opted into using a prerelease version has
clearly indicated the intent to use *that specific* set of
alpha/beta/rc versions. By including a prerelease tag in the range,
the user is indicating that they are aware of the risk. However, it
is still not appropriate to assume that they have opted into taking a
similar risk on the *next* set of prerelease versions.
Note that this behavior can be suppressed (treating all prerelease
versions as if they were normal versions, for the purpose of range
matching) by setting the `includePrerelease` flag on the options
object to any
[functions](https://github.com/npm/node-semver#functions) that do
range matching.
#### Prerelease Identifiers
The method `.inc` takes an additional `identifier` string argument that
will append the value of the string as a prerelease identifier:
```javascript
semver.inc('1.2.3', 'prerelease', 'beta')
// '1.2.4-beta.0'
```
command-line example:
```bash
$ semver 1.2.3 -i prerelease --preid beta
1.2.4-beta.0
```
Which then can be used to increment further:
```bash
$ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1
```
### Advanced Range Syntax
Advanced range syntax desugars to primitive comparators in
deterministic ways.
Advanced ranges may be combined in the same way as primitive
comparators using white space or `||`.
#### Hyphen Ranges `X.Y.Z - A.B.C`
Specifies an inclusive set.
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
If a partial version is provided as the first version in the inclusive
range, then the missing pieces are replaced with zeroes.
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
If a partial version is provided as the second version in the
inclusive range, then all versions that start with the supplied parts
of the tuple are accepted, but nothing that would be greater than the
provided tuple parts.
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
numeric values in the `[major, minor, patch]` tuple.
* `*` := `>=0.0.0` (Any version satisfies)
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
A partial version range is treated as an X-Range, so the special
character is in fact optional.
* `""` (empty string) := `*` := `>=0.0.0`
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
Allows patch-level changes if a minor version is specified on the
comparator. Allows minor-level changes if not.
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
Allows changes that do not modify the left-most non-zero element in the
`[major, minor, patch]` tuple. In other words, this allows patch and
minor updates for versions `1.0.0` and above, patch updates for
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
Many authors treat a `0.x` version as if the `x` were the major
"breaking-change" indicator.
Caret ranges are ideal when an author may make breaking changes
between `0.2.4` and `0.3.0` releases, which is a common practice.
However, it presumes that there will *not* be breaking changes between
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
additive (but non-breaking), according to commonly observed practices.
* `^1.2.3` := `>=1.2.3 <2.0.0`
* `^0.2.3` := `>=0.2.3 <0.3.0`
* `^0.0.3` := `>=0.0.3 <0.0.4`
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
`0.0.3` version *only* will be allowed, if they are greater than or
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
When parsing caret ranges, a missing `patch` value desugars to the
number `0`, but will allow flexibility within that value, even if the
major and minor versions are both `0`.
* `^1.2.x` := `>=1.2.0 <2.0.0`
* `^0.0.x` := `>=0.0.0 <0.1.0`
* `^0.0` := `>=0.0.0 <0.1.0`
A missing `minor` and `patch` values will desugar to zero, but also
allow flexibility within those values, even if the major version is
zero.
* `^1.x` := `>=1.0.0 <2.0.0`
* `^0.x` := `>=0.0.0 <1.0.0`
### Range Grammar
Putting all this together, here is a Backus-Naur grammar for ranges,
for the benefit of parser authors:
```bnf
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+
```
## Functions
All methods and classes take a final `options` object argument. All
options in this object are `false` by default. The options supported
are:
- `loose` Be more forgiving about not-quite-valid semver strings.
(Any resulting output will always be 100% strict compliant, of
course.) For backwards compatibility reasons, if the `options`
argument is a boolean value instead of an object, it is interpreted
to be the `loose` param.
- `includePrerelease` Set to suppress the [default
behavior](https://github.com/npm/node-semver#prerelease-tags) of
excluding prerelease tagged versions from ranges unless they are
explicitly opted into.
Strict-mode Comparators and Ranges will be strict about the SemVer
strings that they parse.
* `valid(v)`: Return the parsed version, or null if it's not valid.
* `inc(v, release)`: Return the version incremented by the release
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
`prepatch`, or `prerelease`), or null if it's not valid
* `premajor` in one call will bump the version up to the next major
version and down to a prerelease of that major version.
`preminor`, and `prepatch` work the same way.
* If called from a non-prerelease version, the `prerelease` will work the
same as `prepatch`. It increments the patch version, then makes a
prerelease. If the input version is already a prerelease it simply
increments it.
* `prerelease(v)`: Returns an array of prerelease components, or null
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
* `major(v)`: Return the major version number.
* `minor(v)`: Return the minor version number.
* `patch(v)`: Return the patch version number.
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
or comparators intersect.
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
a `SemVer` object or `null`.
### Comparison
* `gt(v1, v2)`: `v1 > v2`
* `gte(v1, v2)`: `v1 >= v2`
* `lt(v1, v2)`: `v1 < v2`
* `lte(v1, v2)`: `v1 <= v2`
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
even if they're not the exact same string. You already know how to
compare strings.
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
the corresponding function above. `"==="` and `"!=="` do simple
string comparison, but are included for completeness. Throws if an
invalid comparison string is provided.
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
in descending order when passed to `Array.sort()`.
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
are equal. Sorts in ascending order if passed to `Array.sort()`.
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `diff(v1, v2)`: Returns difference between two versions by the release type
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
or null if the versions are the same.
### Comparators
* `intersects(comparator)`: Return true if the comparators intersect
### Ranges
* `validRange(range)`: Return the valid range or null if it's not valid
* `satisfies(version, range)`: Return true if the version satisfies the
range.
* `maxSatisfying(versions, range)`: Return the highest version in the list
that satisfies the range, or `null` if none of them do.
* `minSatisfying(versions, range)`: Return the lowest version in the list
that satisfies the range, or `null` if none of them do.
* `minVersion(range)`: Return the lowest version that can possibly match
the given range.
* `gtr(version, range)`: Return `true` if version is greater than all the
versions possible in the range.
* `ltr(version, range)`: Return `true` if version is less than all the
versions possible in the range.
* `outside(version, range, hilo)`: Return true if the version is outside
the bounds of the range in either the high or low direction. The
`hilo` argument must be either the string `'>'` or `'<'`. (This is
the function called by `gtr` and `ltr`.)
* `intersects(range)`: Return true if any of the ranges comparators intersect
Note that, since ranges may be non-contiguous, a version might not be
greater than a range, less than a range, *or* satisfy a range! For
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
until `2.0.0`, so the version `1.2.10` would not be greater than the
range (because `2.0.1` satisfies, which is higher), nor less than the
range (since `1.2.8` satisfies, which is lower), and it also does not
satisfy the range.
If you want to know if a version satisfies or does not satisfy a
range, use the `satisfies(version, range)` function.
### Coercion
* `coerce(version, options)`: Coerces a string to semver if possible
This aims to provide a very forgiving translation of a non-semver string to
semver. It looks for the first digit in a string, and consumes all
remaining characters which satisfy at least a partial semver (e.g., `1`,
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
is not valid). The maximum length for any semver component considered for
coercion is 16 characters; longer components will be ignored
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
components are invalid (`9999999999999999.4.7.4` is likely invalid).
If the `options.rtl` flag is set, then `coerce` will return the right-most
coercible tuple that does not share an ending index with a longer coercible
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
any other overlapping SemVer tuple.
### Clean
* `clean(version)`: Clean a string to be a valid semver if possible
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
ex.
* `s.clean(' = v 2.1.5foo')`: `null`
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean(' = v 2.1.5-foo')`: `null`
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean('=v2.1.5')`: `'2.1.5'`
* `s.clean(' =v2.1.5')`: `2.1.5`
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
* `s.clean('~1.0.0')`: `null`

View file

@ -1,174 +0,0 @@
#!/usr/bin/env node
// Standalone semver comparison program.
// Exits successfully and prints matching version(s) if
// any supplied version is valid and passes all tests.
var argv = process.argv.slice(2)
var versions = []
var range = []
var inc = null
var version = require('../package.json').version
var loose = false
var includePrerelease = false
var coerce = false
var rtl = false
var identifier
var semver = require('../semver')
var reverse = false
var options = {}
main()
function main () {
if (!argv.length) return help()
while (argv.length) {
var a = argv.shift()
var indexOfEqualSign = a.indexOf('=')
if (indexOfEqualSign !== -1) {
a = a.slice(0, indexOfEqualSign)
argv.unshift(a.slice(indexOfEqualSign + 1))
}
switch (a) {
case '-rv': case '-rev': case '--rev': case '--reverse':
reverse = true
break
case '-l': case '--loose':
loose = true
break
case '-p': case '--include-prerelease':
includePrerelease = true
break
case '-v': case '--version':
versions.push(argv.shift())
break
case '-i': case '--inc': case '--increment':
switch (argv[0]) {
case 'major': case 'minor': case 'patch': case 'prerelease':
case 'premajor': case 'preminor': case 'prepatch':
inc = argv.shift()
break
default:
inc = 'patch'
break
}
break
case '--preid':
identifier = argv.shift()
break
case '-r': case '--range':
range.push(argv.shift())
break
case '-c': case '--coerce':
coerce = true
break
case '--rtl':
rtl = true
break
case '--ltr':
rtl = false
break
case '-h': case '--help': case '-?':
return help()
default:
versions.push(a)
break
}
}
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
versions = versions.map(function (v) {
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
}).filter(function (v) {
return semver.valid(v)
})
if (!versions.length) return fail()
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
for (var i = 0, l = range.length; i < l; i++) {
versions = versions.filter(function (v) {
return semver.satisfies(v, range[i], options)
})
if (!versions.length) return fail()
}
return success(versions)
}
function failInc () {
console.error('--inc can only be used on a single version with no range')
fail()
}
function fail () { process.exit(1) }
function success () {
var compare = reverse ? 'rcompare' : 'compare'
versions.sort(function (a, b) {
return semver[compare](a, b, options)
}).map(function (v) {
return semver.clean(v, options)
}).map(function (v) {
return inc ? semver.inc(v, inc, options, identifier) : v
}).forEach(function (v, i, _) { console.log(v) })
}
function help () {
console.log(['SemVer ' + version,
'',
'A JavaScript implementation of the https://semver.org/ specification',
'Copyright Isaac Z. Schlueter',
'',
'Usage: semver [options] <version> [<version> [...]]',
'Prints valid versions sorted by SemVer precedence',
'',
'Options:',
'-r --range <range>',
' Print versions that match the specified range.',
'',
'-i --increment [<level>]',
' Increment a version by the specified level. Level can',
' be one of: major, minor, patch, premajor, preminor,',
" prepatch, or prerelease. Default level is 'patch'.",
' Only one version may be specified.',
'',
'--preid <identifier>',
' Identifier to be used to prefix premajor, preminor,',
' prepatch or prerelease version increments.',
'',
'-l --loose',
' Interpret versions and ranges loosely',
'',
'-p --include-prerelease',
' Always include prerelease versions in range matching',
'',
'-c --coerce',
' Coerce a string into SemVer if possible',
' (does not imply --loose)',
'',
'--rtl',
' Coerce version strings right to left',
'',
'--ltr',
' Coerce version strings left to right (default)',
'',
'Program exits successfully if any valid version satisfies',
'all supplied ranges, and prints all satisfying versions.',
'',
'If no satisfying versions are found, then exits failure.',
'',
'Versions are printed in ascending order, so supplying',
'multiple versions to the utility will just sort them.'
].join('\n'))
}

View file

@ -1,63 +0,0 @@
{
"_args": [
[
"semver@6.3.0",
"/Users/paul/src/codeartisans/gradle-command-action"
]
],
"_from": "semver@6.3.0",
"_id": "semver@6.3.0",
"_inBundle": false,
"_integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"_location": "/@actions/tool-cache/semver",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "semver@6.3.0",
"name": "semver",
"escapedName": "semver",
"rawSpec": "6.3.0",
"saveSpec": null,
"fetchSpec": "6.3.0"
},
"_requiredBy": [
"/@actions/tool-cache"
],
"_resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"_spec": "6.3.0",
"_where": "/Users/paul/src/codeartisans/gradle-command-action",
"bin": {
"semver": "./bin/semver.js"
},
"bugs": {
"url": "https://github.com/npm/node-semver/issues"
},
"description": "The semantic version parser used by npm.",
"devDependencies": {
"tap": "^14.3.1"
},
"files": [
"bin",
"range.bnf",
"semver.js"
],
"homepage": "https://github.com/npm/node-semver#readme",
"license": "ISC",
"main": "semver.js",
"name": "semver",
"repository": {
"type": "git",
"url": "git+https://github.com/npm/node-semver.git"
},
"scripts": {
"postpublish": "git push origin --follow-tags",
"postversion": "npm publish",
"preversion": "npm test",
"test": "tap"
},
"tap": {
"check-coverage": true
},
"version": "6.3.0"
}

View file

@ -1,16 +0,0 @@
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | [1-9] ( [0-9] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+

File diff suppressed because it is too large Load diff

View file

@ -1,79 +0,0 @@
{
"_args": [
[
"@actions/tool-cache@1.1.1",
"/Users/paul/src/codeartisans/gradle-command-action"
]
],
"_from": "@actions/tool-cache@1.1.1",
"_id": "@actions/tool-cache@1.1.1",
"_inBundle": false,
"_integrity": "sha512-AILekrrj/L4N/5z5TGtUKVie4nKjxDioCgOEymyYxzPhGfjIxfE71tN2VTTpiICEWJ883rPRj2+WinTr1b6yVA==",
"_location": "/@actions/tool-cache",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@actions/tool-cache@1.1.1",
"name": "@actions/tool-cache",
"escapedName": "@actions%2ftool-cache",
"scope": "@actions",
"rawSpec": "1.1.1",
"saveSpec": null,
"fetchSpec": "1.1.1"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.1.1.tgz",
"_spec": "1.1.1",
"_where": "/Users/paul/src/codeartisans/gradle-command-action",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
"dependencies": {
"@actions/core": "^1.1.0",
"@actions/exec": "^1.0.1",
"@actions/io": "^1.0.1",
"semver": "^6.1.0",
"typed-rest-client": "^1.4.0",
"uuid": "^3.3.2"
},
"description": "Actions tool-cache lib",
"devDependencies": {
"@types/nock": "^10.0.3",
"@types/semver": "^6.0.0",
"@types/uuid": "^3.4.4",
"nock": "^10.0.6"
},
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib",
"scripts"
],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
"keywords": [
"github",
"actions",
"exec"
],
"license": "MIT",
"main": "lib/tool-cache.js",
"name": "@actions/tool-cache",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/toolkit.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc"
},
"version": "1.1.1"
}

View file

@ -1,60 +0,0 @@
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Source,
[Parameter(Mandatory = $true)]
[string]$Target)
# This script translates the output from 7zdec into UTF8. Node has limited
# built-in support for encodings.
#
# 7zdec uses the system default code page. The system default code page varies
# depending on the locale configuration. On an en-US box, the system default code
# page is Windows-1252.
#
# Note, on a typical en-US box, testing with the 'ç' character is a good way to
# determine whether data is passed correctly between processes. This is because
# the 'ç' character has a different code point across each of the common encodings
# on a typical en-US box, i.e.
# 1) the default console-output code page (IBM437)
# 2) the system default code page (i.e. CP_ACP) (Windows-1252)
# 3) UTF8
$ErrorActionPreference = 'Stop'
# Redefine the wrapper over STDOUT to use UTF8. Node expects UTF8 by default.
$stdout = [System.Console]::OpenStandardOutput()
$utf8 = New-Object System.Text.UTF8Encoding($false) # do not emit BOM
$writer = New-Object System.IO.StreamWriter($stdout, $utf8)
[System.Console]::SetOut($writer)
# All subsequent output must be written using [System.Console]::WriteLine(). In
# PowerShell 4, Write-Host and Out-Default do not consider the updated stream writer.
Set-Location -LiteralPath $Target
# Print the ##command.
$_7zdec = Join-Path -Path "$PSScriptRoot" -ChildPath "externals/7zdec.exe"
[System.Console]::WriteLine("##[command]$_7zdec x `"$Source`"")
# The $OutputEncoding variable instructs PowerShell how to interpret the output
# from the external command.
$OutputEncoding = [System.Text.Encoding]::Default
# Note, the output from 7zdec.exe needs to be iterated over. Otherwise PowerShell.exe
# will launch the external command in such a way that it inherits the streams.
& $_7zdec x $Source 2>&1 |
ForEach-Object {
if ($_ -is [System.Management.Automation.ErrorRecord]) {
[System.Console]::WriteLine($_.Exception.Message)
}
else {
[System.Console]::WriteLine($_)
}
}
[System.Console]::WriteLine("##[debug]7zdec.exe exit code '$LASTEXITCODE'")
[System.Console]::Out.Flush()
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,5 +0,0 @@
test
.gitignore
.travis.yml
Makefile
example.js

View file

@ -1,21 +0,0 @@
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,91 +0,0 @@
# balanced-match
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
## Example
Get the first matching pair of braces:
```js
var balanced = require('balanced-match');
console.log(balanced('{', '}', 'pre{in{nested}}post'));
console.log(balanced('{', '}', 'pre{first}between{second}post'));
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
```
The matches are:
```bash
$ node example.js
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
{ start: 3,
end: 9,
pre: 'pre',
body: 'first',
post: 'between{second}post' }
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
```
## API
### var m = balanced(a, b, str)
For the first non-nested matching pair of `a` and `b` in `str`, return an
object with those keys:
* **start** the index of the first match of `a`
* **end** the index of the matching `b`
* **pre** the preamble, `a` and `b` not included
* **body** the match, `a` and `b` not included
* **post** the postscript, `a` and `b` not included
If there's no match, `undefined` will be returned.
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
### var r = balanced.range(a, b, str)
For the first non-nested matching pair of `a` and `b` in `str`, return an
array with indexes: `[ <a index>, <b index> ]`.
If there's no match, `undefined` will be returned.
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
## Installation
With [npm](https://npmjs.org) do:
```bash
npm install balanced-match
```
## License
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

59
node_modules/balanced-match/index.js generated vendored
View file

@ -1,59 +0,0 @@
'use strict';
module.exports = balanced;
function balanced(a, b, str) {
if (a instanceof RegExp) a = maybeMatch(a, str);
if (b instanceof RegExp) b = maybeMatch(b, str);
var r = range(a, b, str);
return r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + a.length, r[1]),
post: str.slice(r[1] + b.length)
};
}
function maybeMatch(reg, str) {
var m = str.match(reg);
return m ? m[0] : null;
}
balanced.range = range;
function range(a, b, str) {
var begs, beg, left, right, result;
var ai = str.indexOf(a);
var bi = str.indexOf(b, ai + 1);
var i = ai;
if (ai >= 0 && bi > 0) {
begs = [];
left = str.length;
while (i >= 0 && !result) {
if (i == ai) {
begs.push(i);
ai = str.indexOf(a, i + 1);
} else if (begs.length == 1) {
result = [ begs.pop(), bi ];
} else {
beg = begs.pop();
if (beg < left) {
left = beg;
right = bi;
}
bi = str.indexOf(b, i + 1);
}
i = ai < bi && ai >= 0 ? ai : bi;
}
if (begs.length) {
result = [ left, right ];
}
}
return result;
}

View file

@ -1,80 +0,0 @@
{
"_args": [
[
"balanced-match@1.0.0",
"/Users/paul/src/codeartisans/gradle-command-action"
]
],
"_from": "balanced-match@1.0.0",
"_id": "balanced-match@1.0.0",
"_inBundle": false,
"_integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"_location": "/balanced-match",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "balanced-match@1.0.0",
"name": "balanced-match",
"escapedName": "balanced-match",
"rawSpec": "1.0.0",
"saveSpec": null,
"fetchSpec": "1.0.0"
},
"_requiredBy": [
"/brace-expansion"
],
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"_spec": "1.0.0",
"_where": "/Users/paul/src/codeartisans/gradle-command-action",
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
"url": "http://juliangruber.com"
},
"bugs": {
"url": "https://github.com/juliangruber/balanced-match/issues"
},
"dependencies": {},
"description": "Match balanced character pairs, like \"{\" and \"}\"",
"devDependencies": {
"matcha": "^0.7.0",
"tape": "^4.6.0"
},
"homepage": "https://github.com/juliangruber/balanced-match",
"keywords": [
"match",
"regexp",
"test",
"balanced",
"parse"
],
"license": "MIT",
"main": "index.js",
"name": "balanced-match",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/balanced-match.git"
},
"scripts": {
"bench": "make bench",
"test": "make test"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/8..latest",
"firefox/20..latest",
"firefox/nightly",
"chrome/25..latest",
"chrome/canary",
"opera/12..latest",
"opera/next",
"safari/5.1..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
},
"version": "1.0.0"
}

File diff suppressed because it is too large Load diff

1452
node_modules/big-integer/BigInteger.js generated vendored

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

24
node_modules/big-integer/LICENSE generated vendored
View file

@ -1,24 +0,0 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>

580
node_modules/big-integer/README.md generated vendored
View file

@ -1,580 +0,0 @@
# BigInteger.js [![Build Status][travis-img]][travis-url] [![Coverage Status][coveralls-img]][coveralls-url] [![Monthly Downloads][downloads-img]][downloads-url]
[travis-url]: https://travis-ci.org/peterolson/BigInteger.js
[travis-img]: https://travis-ci.org/peterolson/BigInteger.js.svg?branch=master
[coveralls-url]: https://coveralls.io/github/peterolson/BigInteger.js?branch=master
[coveralls-img]: https://coveralls.io/repos/peterolson/BigInteger.js/badge.svg?branch=master&service=github
[downloads-url]: https://www.npmjs.com/package/big-integer
[downloads-img]: https://img.shields.io/npm/dm/big-integer.svg
**BigInteger.js** is an arbitrary-length integer library for Javascript, allowing arithmetic operations on integers of unlimited size, notwithstanding memory and time limitations.
**Update (December 2, 2018):** [`BigInt` is being added as a native feature of JavaScript](https://tc39.github.io/proposal-bigint/). This library now works as a polyfill: if the environment supports the native `BigInt`, this library acts as a thin wrapper over the native implementation.
## Installation
If you are using a browser, you can download [BigInteger.js from GitHub](http://peterolson.github.com/BigInteger.js/BigInteger.min.js) or just hotlink to it:
<script src="https://peterolson.github.io/BigInteger.js/BigInteger.min.js"></script>
If you are using node, you can install BigInteger with [npm](https://npmjs.org/).
npm install big-integer
Then you can include it in your code:
var bigInt = require("big-integer");
## Usage
### `bigInt(number, [base], [alphabet], [caseSensitive])`
You can create a bigInt by calling the `bigInt` function. You can pass in
- a string, which it will parse as an bigInt and throw an `"Invalid integer"` error if the parsing fails.
- a Javascript number, which it will parse as an bigInt and throw an `"Invalid integer"` error if the parsing fails.
- another bigInt.
- nothing, and it will return `bigInt.zero`.
If you provide a second parameter, then it will parse `number` as a number in base `base`. Note that `base` can be any bigInt (even negative or zero). The letters "a-z" and "A-Z" will be interpreted as the numbers 10 to 35. Higher digits can be specified in angle brackets (`<` and `>`). The default `base` is `10`.
You can specify a custom alphabet for base conversion with the third parameter. The default `alphabet` is `"0123456789abcdefghijklmnopqrstuvwxyz"`.
The fourth parameter specifies whether or not the number string should be case-sensitive, i.e. whether `a` and `A` should be treated as different digits. By default `caseSensitive` is `false`.
Examples:
var zero = bigInt();
var ninetyThree = bigInt(93);
var largeNumber = bigInt("75643564363473453456342378564387956906736546456235345");
var googol = bigInt("1e100");
var bigNumber = bigInt(largeNumber);
var maximumByte = bigInt("FF", 16);
var fiftyFiveGoogol = bigInt("<55>0", googol);
Note that Javascript numbers larger than `9007199254740992` and smaller than `-9007199254740992` are not precisely represented numbers and will not produce exact results. If you are dealing with numbers outside that range, it is better to pass in strings.
### Method Chaining
Note that bigInt operations return bigInts, which allows you to chain methods, for example:
var salary = bigInt(dollarsPerHour).times(hoursWorked).plus(randomBonuses)
### Constants
There are three named constants already stored that you do not have to construct with the `bigInt` function yourself:
- `bigInt.one`, equivalent to `bigInt(1)`
- `bigInt.zero`, equivalent to `bigInt(0)`
- `bigInt.minusOne`, equivalent to `bigInt(-1)`
The numbers from -999 to 999 are also already prestored and can be accessed using `bigInt[index]`, for example:
- `bigInt[-999]`, equivalent to `bigInt(-999)`
- `bigInt[256]`, equivalent to `bigInt(256)`
### Methods
#### `abs()`
Returns the absolute value of a bigInt.
- `bigInt(-45).abs()` => `45`
- `bigInt(45).abs()` => `45`
#### `add(number)`
Performs addition.
- `bigInt(5).add(7)` => `12`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Addition)
#### `and(number)`
Performs the bitwise AND operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
- `bigInt(6).and(3)` => `2`
- `bigInt(6).and(-3)` => `4`
#### `bitLength()`
Returns the number of digits required to represent a bigInt in binary.
- `bigInt(5)` => `3` (since 5 is `101` in binary, which is three digits long)
#### `compare(number)`
Performs a comparison between two numbers. If the numbers are equal, it returns `0`. If the first number is greater, it returns `1`. If the first number is lesser, it returns `-1`.
- `bigInt(5).compare(5)` => `0`
- `bigInt(5).compare(4)` => `1`
- `bigInt(4).compare(5)` => `-1`
#### `compareAbs(number)`
Performs a comparison between the absolute value of two numbers.
- `bigInt(5).compareAbs(-5)` => `0`
- `bigInt(5).compareAbs(4)` => `1`
- `bigInt(4).compareAbs(-5)` => `-1`
#### `compareTo(number)`
Alias for the `compare` method.
#### `divide(number)`
Performs integer division, disregarding the remainder.
- `bigInt(59).divide(5)` => `11`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
#### `divmod(number)`
Performs division and returns an object with two properties: `quotient` and `remainder`. The sign of the remainder will match the sign of the dividend.
- `bigInt(59).divmod(5)` => `{quotient: bigInt(11), remainder: bigInt(4) }`
- `bigInt(-5).divmod(2)` => `{quotient: bigInt(-2), remainder: bigInt(-1) }`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
#### `eq(number)`
Alias for the `equals` method.
#### `equals(number)`
Checks if two numbers are equal.
- `bigInt(5).equals(5)` => `true`
- `bigInt(4).equals(7)` => `false`
#### `geq(number)`
Alias for the `greaterOrEquals` method.
#### `greater(number)`
Checks if the first number is greater than the second.
- `bigInt(5).greater(6)` => `false`
- `bigInt(5).greater(5)` => `false`
- `bigInt(5).greater(4)` => `true`
#### `greaterOrEquals(number)`
Checks if the first number is greater than or equal to the second.
- `bigInt(5).greaterOrEquals(6)` => `false`
- `bigInt(5).greaterOrEquals(5)` => `true`
- `bigInt(5).greaterOrEquals(4)` => `true`
#### `gt(number)`
Alias for the `greater` method.
#### `isDivisibleBy(number)`
Returns `true` if the first number is divisible by the second number, `false` otherwise.
- `bigInt(999).isDivisibleBy(333)` => `true`
- `bigInt(99).isDivisibleBy(5)` => `false`
#### `isEven()`
Returns `true` if the number is even, `false` otherwise.
- `bigInt(6).isEven()` => `true`
- `bigInt(3).isEven()` => `false`
#### `isNegative()`
Returns `true` if the number is negative, `false` otherwise.
Returns `false` for `0` and `-0`.
- `bigInt(-23).isNegative()` => `true`
- `bigInt(50).isNegative()` => `false`
#### `isOdd()`
Returns `true` if the number is odd, `false` otherwise.
- `bigInt(13).isOdd()` => `true`
- `bigInt(40).isOdd()` => `false`
#### `isPositive()`
Return `true` if the number is positive, `false` otherwise.
Returns `false` for `0` and `-0`.
- `bigInt(54).isPositive()` => `true`
- `bigInt(-1).isPositive()` => `false`
#### `isPrime()`
Returns `true` if the number is prime, `false` otherwise.
- `bigInt(5).isPrime()` => `true`
- `bigInt(6).isPrime()` => `false`
#### `isProbablePrime([iterations])`
Returns `true` if the number is very likely to be prime, `false` otherwise.
Argument is optional and determines the amount of iterations of the test (default: `5`). The more iterations, the lower chance of getting a false positive.
This uses the [Miller Rabin test](https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test).
- `bigInt(5).isProbablePrime()` => `true`
- `bigInt(49).isProbablePrime()` => `false`
- `bigInt(1729).isProbablePrime()` => `false`
Note that this function is not deterministic, since it relies on random sampling of factors, so the result for some numbers is not always the same.
If the number is composite then the MillerRabin primality test declares the number probably prime with a probability at most `4` to the power `iterations`.
If the number is prime, this function always returns `true`.
#### `isUnit()`
Returns `true` if the number is `1` or `-1`, `false` otherwise.
- `bigInt.one.isUnit()` => `true`
- `bigInt.minusOne.isUnit()` => `true`
- `bigInt(5).isUnit()` => `false`
#### `isZero()`
Return `true` if the number is `0` or `-0`, `false` otherwise.
- `bigInt.zero.isZero()` => `true`
- `bigInt("-0").isZero()` => `true`
- `bigInt(50).isZero()` => `false`
#### `leq(number)`
Alias for the `lesserOrEquals` method.
#### `lesser(number)`
Checks if the first number is lesser than the second.
- `bigInt(5).lesser(6)` => `true`
- `bigInt(5).lesser(5)` => `false`
- `bigInt(5).lesser(4)` => `false`
#### `lesserOrEquals(number)`
Checks if the first number is less than or equal to the second.
- `bigInt(5).lesserOrEquals(6)` => `true`
- `bigInt(5).lesserOrEquals(5)` => `true`
- `bigInt(5).lesserOrEquals(4)` => `false`
#### `lt(number)`
Alias for the `lesser` method.
#### `minus(number)`
Alias for the `subtract` method.
- `bigInt(3).minus(5)` => `-2`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Subtraction)
#### `mod(number)`
Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend.
- `bigInt(59).mod(5)` => `4`
- `bigInt(-5).mod(2)` => `-1`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
#### `modInv(mod)`
Finds the [multiplicative inverse](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of the number modulo `mod`.
- `bigInt(3).modInv(11)` => `4`
- `bigInt(42).modInv(2017)` => `1969`
#### `modPow(exp, mod)`
Takes the number to the power `exp` modulo `mod`.
- `bigInt(10).modPow(3, 30)` => `10`
#### `multiply(number)`
Performs multiplication.
- `bigInt(111).multiply(111)` => `12321`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication)
#### `neq(number)`
Alias for the `notEquals` method.
#### `next()`
Adds one to the number.
- `bigInt(6).next()` => `7`
#### `not()`
Performs the bitwise NOT operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
- `bigInt(10).not()` => `-11`
- `bigInt(0).not()` => `-1`
#### `notEquals(number)`
Checks if two numbers are not equal.
- `bigInt(5).notEquals(5)` => `false`
- `bigInt(4).notEquals(7)` => `true`
#### `or(number)`
Performs the bitwise OR operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
- `bigInt(13).or(10)` => `15`
- `bigInt(13).or(-8)` => `-3`
#### `over(number)`
Alias for the `divide` method.
- `bigInt(59).over(5)` => `11`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
#### `plus(number)`
Alias for the `add` method.
- `bigInt(5).plus(7)` => `12`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Addition)
#### `pow(number)`
Performs exponentiation. If the exponent is less than `0`, `pow` returns `0`. `bigInt.zero.pow(0)` returns `1`.
- `bigInt(16).pow(16)` => `18446744073709551616`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Exponentiation)
#### `prev(number)`
Subtracts one from the number.
- `bigInt(6).prev()` => `5`
#### `remainder(number)`
Alias for the `mod` method.
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
#### `shiftLeft(n)`
Shifts the number left by `n` places in its binary representation. If a negative number is provided, it will shift right. Throws an error if `n` is outside of the range `[-9007199254740992, 9007199254740992]`.
- `bigInt(8).shiftLeft(2)` => `32`
- `bigInt(8).shiftLeft(-2)` => `2`
#### `shiftRight(n)`
Shifts the number right by `n` places in its binary representation. If a negative number is provided, it will shift left. Throws an error if `n` is outside of the range `[-9007199254740992, 9007199254740992]`.
- `bigInt(8).shiftRight(2)` => `2`
- `bigInt(8).shiftRight(-2)` => `32`
#### `square()`
Squares the number
- `bigInt(3).square()` => `9`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Squaring)
#### `subtract(number)`
Performs subtraction.
- `bigInt(3).subtract(5)` => `-2`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Subtraction)
#### `times(number)`
Alias for the `multiply` method.
- `bigInt(111).times(111)` => `12321`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication)
#### `toArray(radix)`
Converts a bigInt into an object with the properties "value" and "isNegative." "Value" is an array of integers modulo the given radix. "isNegative" is a boolean that represents the sign of the result.
- `bigInt("1e9").toArray(10)` => {
value: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
isNegative: false
}
- `bigInt("1e9").toArray(16)` => {
value: [3, 11, 9, 10, 12, 10, 0, 0],
isNegative: false
}
- `bigInt(567890).toArray(100)` => {
value: [56, 78, 90],
isNegative: false
}
Negative bases are supported.
- `bigInt(12345).toArray(-10)` => {
value: [2, 8, 4, 6, 5],
isNegative: false
}
Base 1 and base -1 are also supported.
- `bigInt(-15).toArray(1)` => {
value: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
isNegative: true
}
- `bigInt(-15).toArray(-1)` => {
value: [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
isNegative: false
}
Base 0 is only allowed for the number zero.
- `bigInt(0).toArray(0)` => {
value: [0],
isNegative: false
}
- `bigInt(1).toArray(0)` => `Error: Cannot convert nonzero numbers to base 0.`
#### `toJSNumber()`
Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range `[-9007199254740992, 9007199254740992]`.
- `bigInt("18446744073709551616").toJSNumber()` => `18446744073709552000`
#### `xor(number)`
Performs the bitwise XOR operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
- `bigInt(12).xor(5)` => `9`
- `bigInt(12).xor(-5)` => `-9`
### Static Methods
#### `fromArray(digits, base = 10, isNegative?)`
Constructs a bigInt from an array of digits in base `base`. The optional `isNegative` flag will make the number negative.
- `bigInt.fromArray([1, 2, 3, 4, 5], 10)` => `12345`
- `bigInt.fromArray([1, 0, 0], 2, true)` => `-4`
#### `gcd(a, b)`
Finds the greatest common denominator of `a` and `b`.
- `bigInt.gcd(42,56)` => `14`
#### `isInstance(x)`
Returns `true` if `x` is a BigInteger, `false` otherwise.
- `bigInt.isInstance(bigInt(14))` => `true`
- `bigInt.isInstance(14)` => `false`
#### `lcm(a,b)`
Finds the least common multiple of `a` and `b`.
- `bigInt.lcm(21, 6)` => `42`
#### `max(a,b)`
Returns the largest of `a` and `b`.
- `bigInt.max(77, 432)` => `432`
#### `min(a,b)`
Returns the smallest of `a` and `b`.
- `bigInt.min(77, 432)` => `77`
#### `randBetween(min, max)`
Returns a random number between `min` and `max`.
- `bigInt.randBetween("-1e100", "1e100")` => (for example) `8494907165436643479673097939554427056789510374838494147955756275846226209006506706784609314471378745`
### Override Methods
#### `toString(radix = 10, [alphabet])`
Converts a bigInt to a string. There is an optional radix parameter (which defaults to 10) that converts the number to the given radix. Digits in the range `10-35` will use the letters `a-z`.
- `bigInt("1e9").toString()` => `"1000000000"`
- `bigInt("1e9").toString(16)` => `"3b9aca00"`
You can use a custom base alphabet with the second parameter. The default `alphabet` is `"0123456789abcdefghijklmnopqrstuvwxyz"`.
- `bigInt("5").toString(2, "aA")` => `"AaA"`
**Note that arithmetical operators will trigger the `valueOf` function rather than the `toString` function.** When converting a bigInteger to a string, you should use the `toString` method or the `String` function instead of adding the empty string.
- `bigInt("999999999999999999").toString()` => `"999999999999999999"`
- `String(bigInt("999999999999999999"))` => `"999999999999999999"`
- `bigInt("999999999999999999") + ""` => `1000000000000000000`
Bases larger than 36 are supported. If a digit is greater than or equal to 36, it will be enclosed in angle brackets.
- `bigInt(567890).toString(100)` => `"<56><78><90>"`
Negative bases are also supported.
- `bigInt(12345).toString(-10)` => `"28465"`
Base 1 and base -1 are also supported.
- `bigInt(-15).toString(1)` => `"-111111111111111"`
- `bigInt(-15).toString(-1)` => `"101010101010101010101010101010"`
Base 0 is only allowed for the number zero.
- `bigInt(0).toString(0)` => `0`
- `bigInt(1).toString(0)` => `Error: Cannot convert nonzero numbers to base 0.`
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#toString)
#### `valueOf()`
Converts a bigInt to a native Javascript number. This override allows you to use native arithmetic operators without explicit conversion:
- `bigInt("100") + bigInt("200") === 300; //true`
## Contributors
To contribute, just fork the project, make some changes, and submit a pull request. Please verify that the unit tests pass before submitting.
The unit tests are contained in the `spec/spec.js` file. You can run them locally by opening the `spec/SpecRunner.html` or file or running `npm test`. You can also [run the tests online from GitHub](http://peterolson.github.io/BigInteger.js/spec/SpecRunner.html).
There are performance benchmarks that can be viewed from the `benchmarks/index.html` page. You can [run them online from GitHub](http://peterolson.github.io/BigInteger.js/benchmark/).
## License
This project is public domain. For more details, read about the [Unlicense](http://unlicense.org/).

29
node_modules/big-integer/bower.json generated vendored
View file

@ -1,29 +0,0 @@
{
"name": "big-integer",
"description": "An arbitrary length integer library for Javascript",
"main": "./BigInteger.js",
"authors": [
"Peter Olson"
],
"license": "Unlicense",
"keywords": [
"math",
"big",
"bignum",
"bigint",
"biginteger",
"integer",
"arbitrary",
"precision",
"arithmetic"
],
"homepage": "https://github.com/peterolson/BigInteger.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"coverage",
"tests"
]
}

View file

@ -1,83 +0,0 @@
{
"_args": [
[
"big-integer@1.6.45",
"/Users/paul/src/codeartisans/gradle-command-action"
]
],
"_from": "big-integer@1.6.45",
"_id": "big-integer@1.6.45",
"_inBundle": false,
"_integrity": "sha512-nmb9E7oEtVJ7SmSCH/DeJobXyuRmaofkpoQSimMFu3HKJ5MADtM825SPLhDuWhZ6TElLAQtgJbQmBZuHIRlZoA==",
"_location": "/big-integer",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "big-integer@1.6.45",
"name": "big-integer",
"escapedName": "big-integer",
"rawSpec": "1.6.45",
"saveSpec": null,
"fetchSpec": "1.6.45"
},
"_requiredBy": [
"/unzipper"
],
"_resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.45.tgz",
"_spec": "1.6.45",
"_where": "/Users/paul/src/codeartisans/gradle-command-action",
"author": {
"name": "Peter Olson",
"email": "peter.e.c.olson+npm@gmail.com"
},
"bin": {},
"bugs": {
"url": "https://github.com/peterolson/BigInteger.js/issues"
},
"contributors": [],
"description": "An arbitrary length integer library for Javascript",
"devDependencies": {
"@types/lodash": "^4.14.118",
"@types/node": "^7.10.2",
"coveralls": "^2.11.4",
"jasmine": "2.1.x",
"jasmine-core": "^2.3.4",
"karma": "^0.13.22",
"karma-cli": "^1.0.1",
"karma-coverage": "^0.4.2",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "^1.0.4",
"lodash": "^4.17.11",
"typescript": "^3.6.3",
"uglifyjs": "^2.4.10"
},
"engines": {
"node": ">=0.6"
},
"homepage": "https://github.com/peterolson/BigInteger.js#readme",
"keywords": [
"math",
"big",
"bignum",
"bigint",
"biginteger",
"integer",
"arbitrary",
"precision",
"arithmetic"
],
"license": "Unlicense",
"main": "./BigInteger",
"name": "big-integer",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/peterolson/BigInteger.js.git"
},
"scripts": {
"minify": "uglifyjs BigInteger.js -o BigInteger.min.js",
"test": "tsc && karma start my.conf.js && node spec/tsDefinitions.js"
},
"typings": "./BigInteger.d.ts",
"version": "1.6.45"
}

View file

@ -1,26 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "./",
"moduleResolution": "node",
"allowJs": true,
"typeRoots": [
"./"
],
"types": [
"node"
],
"forceConsistentCasingInFileNames": true
},
"files": [
"BigInteger.d.ts",
"spec/tsDefinitions.ts"
]
}

1
node_modules/binary/.npmignore generated vendored
View file

@ -1 +0,0 @@
node_modules

4
node_modules/binary/.travis.yml generated vendored
View file

@ -1,4 +0,0 @@
language: node_js
node_js:
- 0.4
- 0.6

177
node_modules/binary/README.markdown generated vendored
View file

@ -1,177 +0,0 @@
binary
======
Unpack multibyte binary values from buffers and streams.
You can specify the endianness and signedness of the fields to be unpacked too.
This module is a cleaner and more complete version of
[bufferlist](https://github.com/substack/node-bufferlist)'s binary module that
runs on pre-allocated buffers instead of a linked list.
[![build status](https://secure.travis-ci.org/substack/node-binary.png)](http://travis-ci.org/substack/node-binary)
examples
========
stream.js
---------
``` js
var binary = require('binary');
var ws = binary()
.word32lu('x')
.word16bs('y')
.word16bu('z')
.tap(function (vars) {
console.dir(vars);
})
;
process.stdin.pipe(ws);
process.stdin.resume();
```
output:
```
$ node examples/stream.js
abcdefgh
{ x: 1684234849, y: 25958, z: 26472 }
^D
```
parse.js
--------
``` js
var buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);
var binary = require('binary');
var vars = binary.parse(buf)
.word16ls('ab')
.word32bu('cf')
.word8('x')
.vars
;
console.dir(vars);
```
output:
```
{ ab: 25185, cf: 1667523942, x: 0 }
```
methods
=======
`var binary = require('binary')`
var b = binary()
----------------
Return a new writable stream `b` that has the chainable methods documented below
for buffering binary input.
binary.parse(buf)
-----------------
Parse a static buffer in one pass. Returns a chainable interface with the
methods below plus a `vars` field to get at the variable stash as the last item
in a chain.
In parse mode, methods will set their keys to `null` if the buffer isn't big
enough except `buffer()` and `scan()` which read up up to the end of the buffer
and stop.
b.word{8,16,32,64}{l,b}{e,u,s}(key)
-----------------------------------
Parse bytes in the buffer or stream given:
* number of bits
* endianness ( l : little, b : big ),
* signedness ( u and e : unsigned, s : signed )
These functions won't start parsing until all previous parser functions have run
and the data is available.
The result of the parse goes into the variable stash at `key`.
If `key` has dots (`.`s), it refers to a nested address. If parent container
values don't exist they will be created automatically, so for instance you can
assign into `dst.addr` and `dst.port` and the `dst` key in the variable stash
will be `{ addr : x, port : y }` afterwards.
b.buffer(key, size)
-------------------
Take `size` bytes directly off the buffer stream, putting the resulting buffer
slice in the variable stash at `key`. If `size` is a string, use the value at
`vars[size]`. The key follows the same dotted address rules as the word
functions.
b.scan(key, buffer)
-------------------
Search for `buffer` in the stream and store all the intervening data in the
stash at at `key`, excluding the search buffer. If `buffer` passed as a string,
it will be converted into a Buffer internally.
For example, to read in a line you can just do:
``` js
var b = binary()
.scan('line', new Buffer('\r\n'))
.tap(function (vars) {
console.log(vars.line)
})
;
stream.pipe(b);
```
b.tap(cb)
---------
The callback `cb` is provided with the variable stash from all the previous
actions once they've all finished.
You can nest additional actions onto `this` inside the callback.
b.into(key, cb)
---------------
Like `.tap()`, except all nested actions will assign into a `key` in the `vars`
stash.
b.loop(cb)
----------
Loop, each time calling `cb(end, vars)` for function `end` and the variable
stash with `this` set to a new chain for nested parsing. The loop terminates
once `end` is called.
b.flush()
---------
Clear the variable stash entirely.
installation
============
To install with [npm](http://github.com/isaacs/npm):
```
npm install binary
```
notes
=====
The word64 functions will only return approximations since javascript uses ieee
floating point for all number types. Mind the loss of precision.
license
=======
MIT

11
node_modules/binary/example/buf.js generated vendored
View file

@ -1,11 +0,0 @@
var buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);
var binary = require('binary');
binary(buf)
.word16ls('ab')
.word32bu('cf')
.word8('x')
.tap(function (vars) {
console.dir(vars);
})
;

10
node_modules/binary/example/parse.js generated vendored
View file

@ -1,10 +0,0 @@
var buf = new Buffer([ 97, 98, 99, 100, 101, 102, 0 ]);
var binary = require('binary');
var vars = binary.parse(buf)
.word16ls('ab')
.word32bu('cf')
.word8('x')
.vars
;
console.dir(vars);

View file

@ -1,12 +0,0 @@
var binary = require('binary');
var ws = binary()
.word32lu('x')
.word16bs('y')
.word16bu('z')
.tap(function (vars) {
console.dir(vars);
})
;
process.stdin.pipe(ws);
process.stdin.resume();

397
node_modules/binary/index.js generated vendored
View file

@ -1,397 +0,0 @@
var Chainsaw = require('chainsaw');
var EventEmitter = require('events').EventEmitter;
var Buffers = require('buffers');
var Vars = require('./lib/vars.js');
var Stream = require('stream').Stream;
exports = module.exports = function (bufOrEm, eventName) {
if (Buffer.isBuffer(bufOrEm)) {
return exports.parse(bufOrEm);
}
var s = exports.stream();
if (bufOrEm && bufOrEm.pipe) {
bufOrEm.pipe(s);
}
else if (bufOrEm) {
bufOrEm.on(eventName || 'data', function (buf) {
s.write(buf);
});
bufOrEm.on('end', function () {
s.end();
});
}
return s;
};
exports.stream = function (input) {
if (input) return exports.apply(null, arguments);
var pending = null;
function getBytes (bytes, cb, skip) {
pending = {
bytes : bytes,
skip : skip,
cb : function (buf) {
pending = null;
cb(buf);
},
};
dispatch();
}
var offset = null;
function dispatch () {
if (!pending) {
if (caughtEnd) done = true;
return;
}
if (typeof pending === 'function') {
pending();
}
else {
var bytes = offset + pending.bytes;
if (buffers.length >= bytes) {
var buf;
if (offset == null) {
buf = buffers.splice(0, bytes);
if (!pending.skip) {
buf = buf.slice();
}
}
else {
if (!pending.skip) {
buf = buffers.slice(offset, bytes);
}
offset = bytes;
}
if (pending.skip) {
pending.cb();
}
else {
pending.cb(buf);
}
}
}
}
function builder (saw) {
function next () { if (!done) saw.next() }
var self = words(function (bytes, cb) {
return function (name) {
getBytes(bytes, function (buf) {
vars.set(name, cb(buf));
next();
});
};
});
self.tap = function (cb) {
saw.nest(cb, vars.store);
};
self.into = function (key, cb) {
if (!vars.get(key)) vars.set(key, {});
var parent = vars;
vars = Vars(parent.get(key));
saw.nest(function () {
cb.apply(this, arguments);
this.tap(function () {
vars = parent;
});
}, vars.store);
};
self.flush = function () {
vars.store = {};
next();
};
self.loop = function (cb) {
var end = false;
saw.nest(false, function loop () {
this.vars = vars.store;
cb.call(this, function () {
end = true;
next();
}, vars.store);
this.tap(function () {
if (end) saw.next()
else loop.call(this)
}.bind(this));
}, vars.store);
};
self.buffer = function (name, bytes) {
if (typeof bytes === 'string') {
bytes = vars.get(bytes);
}
getBytes(bytes, function (buf) {
vars.set(name, buf);
next();
});
};
self.skip = function (bytes) {
if (typeof bytes === 'string') {
bytes = vars.get(bytes);
}
getBytes(bytes, function () {
next();
});
};
self.scan = function find (name, search) {
if (typeof search === 'string') {
search = new Buffer(search);
}
else if (!Buffer.isBuffer(search)) {
throw new Error('search must be a Buffer or a string');
}
var taken = 0;
pending = function () {
var pos = buffers.indexOf(search, offset + taken);
var i = pos-offset-taken;
if (pos !== -1) {
pending = null;
if (offset != null) {
vars.set(
name,
buffers.slice(offset, offset + taken + i)
);
offset += taken + i + search.length;
}
else {
vars.set(
name,
buffers.slice(0, taken + i)
);
buffers.splice(0, taken + i + search.length);
}
next();
dispatch();
} else {
i = Math.max(buffers.length - search.length - offset - taken, 0);
}
taken += i;
};
dispatch();
};
self.peek = function (cb) {
offset = 0;
saw.nest(function () {
cb.call(this, vars.store);
this.tap(function () {
offset = null;
});
});
};
return self;
};
var stream = Chainsaw.light(builder);
stream.writable = true;
var buffers = Buffers();
stream.write = function (buf) {
buffers.push(buf);
dispatch();
};
var vars = Vars();
var done = false, caughtEnd = false;
stream.end = function () {
caughtEnd = true;
};
stream.pipe = Stream.prototype.pipe;
Object.getOwnPropertyNames(EventEmitter.prototype).forEach(function (name) {
stream[name] = EventEmitter.prototype[name];
});
return stream;
};
exports.parse = function parse (buffer) {
var self = words(function (bytes, cb) {
return function (name) {
if (offset + bytes <= buffer.length) {
var buf = buffer.slice(offset, offset + bytes);
offset += bytes;
vars.set(name, cb(buf));
}
else {
vars.set(name, null);
}
return self;
};
});
var offset = 0;
var vars = Vars();
self.vars = vars.store;
self.tap = function (cb) {
cb.call(self, vars.store);
return self;
};
self.into = function (key, cb) {
if (!vars.get(key)) {
vars.set(key, {});
}
var parent = vars;
vars = Vars(parent.get(key));
cb.call(self, vars.store);
vars = parent;
return self;
};
self.loop = function (cb) {
var end = false;
var ender = function () { end = true };
while (end === false) {
cb.call(self, ender, vars.store);
}
return self;
};
self.buffer = function (name, size) {
if (typeof size === 'string') {
size = vars.get(size);
}
var buf = buffer.slice(offset, Math.min(buffer.length, offset + size));
offset += size;
vars.set(name, buf);
return self;
};
self.skip = function (bytes) {
if (typeof bytes === 'string') {
bytes = vars.get(bytes);
}
offset += bytes;
return self;
};
self.scan = function (name, search) {
if (typeof search === 'string') {
search = new Buffer(search);
}
else if (!Buffer.isBuffer(search)) {
throw new Error('search must be a Buffer or a string');
}
vars.set(name, null);
// simple but slow string search
for (var i = 0; i + offset <= buffer.length - search.length + 1; i++) {
for (
var j = 0;
j < search.length && buffer[offset+i+j] === search[j];
j++
);
if (j === search.length) break;
}
vars.set(name, buffer.slice(offset, offset + i));
offset += i + search.length;
return self;
};
self.peek = function (cb) {
var was = offset;
cb.call(self, vars.store);
offset = was;
return self;
};
self.flush = function () {
vars.store = {};
return self;
};
self.eof = function () {
return offset >= buffer.length;
};
return self;
};
// convert byte strings to unsigned little endian numbers
function decodeLEu (bytes) {
var acc = 0;
for (var i = 0; i < bytes.length; i++) {
acc += Math.pow(256,i) * bytes[i];
}
return acc;
}
// convert byte strings to unsigned big endian numbers
function decodeBEu (bytes) {
var acc = 0;
for (var i = 0; i < bytes.length; i++) {
acc += Math.pow(256, bytes.length - i - 1) * bytes[i];
}
return acc;
}
// convert byte strings to signed big endian numbers
function decodeBEs (bytes) {
var val = decodeBEu(bytes);
if ((bytes[0] & 0x80) == 0x80) {
val -= Math.pow(256, bytes.length);
}
return val;
}
// convert byte strings to signed little endian numbers
function decodeLEs (bytes) {
var val = decodeLEu(bytes);
if ((bytes[bytes.length - 1] & 0x80) == 0x80) {
val -= Math.pow(256, bytes.length);
}
return val;
}
function words (decode) {
var self = {};
[ 1, 2, 4, 8 ].forEach(function (bytes) {
var bits = bytes * 8;
self['word' + bits + 'le']
= self['word' + bits + 'lu']
= decode(bytes, decodeLEu);
self['word' + bits + 'ls']
= decode(bytes, decodeLEs);
self['word' + bits + 'be']
= self['word' + bits + 'bu']
= decode(bytes, decodeBEu);
self['word' + bits + 'bs']
= decode(bytes, decodeBEs);
});
// word8be(n) == word8le(n) for all n
self.word8 = self.word8u = self.word8be;
self.word8s = self.word8bs;
return self;
}

28
node_modules/binary/lib/vars.js generated vendored
View file

@ -1,28 +0,0 @@
module.exports = function (store) {
function getset (name, value) {
var node = vars.store;
var keys = name.split('.');
keys.slice(0,-1).forEach(function (k) {
if (node[k] === undefined) node[k] = {};
node = node[k]
});
var key = keys[keys.length - 1];
if (arguments.length == 1) {
return node[key];
}
else {
return node[key] = value;
}
}
var vars = {
get : function (name) {
return getset(name);
},
set : function (name, value) {
return getset(name, value);
},
store : store || {},
};
return vars;
};

70
node_modules/binary/package.json generated vendored
View file

@ -1,70 +0,0 @@
{
"_args": [
[
"binary@0.3.0",
"/Users/paul/src/codeartisans/gradle-command-action"
]
],
"_from": "binary@0.3.0",
"_id": "binary@0.3.0",
"_inBundle": false,
"_integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=",
"_location": "/binary",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "binary@0.3.0",
"name": "binary",
"escapedName": "binary",
"rawSpec": "0.3.0",
"saveSpec": null,
"fetchSpec": "0.3.0"
},
"_requiredBy": [
"/unzipper"
],
"_resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz",
"_spec": "0.3.0",
"_where": "/Users/paul/src/codeartisans/gradle-command-action",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"bugs": {
"url": "https://github.com/substack/node-binary/issues"
},
"dependencies": {
"buffers": "~0.1.1",
"chainsaw": "~0.1.0"
},
"description": "Unpack multibyte binary values from buffers",
"devDependencies": {
"seq": "~0.2.5",
"tap": "~0.2.4"
},
"engine": {
"node": ">=0.4.0"
},
"homepage": "https://github.com/substack/node-binary#readme",
"keywords": [
"binary",
"decode",
"endian",
"unpack",
"signed",
"unsigned"
],
"license": "MIT",
"main": "./index.js",
"name": "binary",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/substack/node-binary.git"
},
"scripts": {
"test": "tap test/*.js"
},
"version": "0.3.0"
}

92
node_modules/binary/perf/loop.js generated vendored
View file

@ -1,92 +0,0 @@
var Seq = require('seq');
var Hash = require('hashish');
var EventEmitter = require('events').EventEmitter;
var Bin = require('binary');
var Buf = require('bufferlist/binary');
var BufferList = require('bufferlist');
console.log('loop');
function emitter () {
var em = new EventEmitter;
var i = 0;
var iv = setInterval(function () {
var buf = new Buffer(10000);
buf[0] = 0xff;
if (++ i >= 2000) {
buf[0] = 0;
clearInterval(iv);
}
em.emit('data', buf);
}, 1);
return em;
}
Seq()
.seq(function () {
var next = this.bind({}, null);
bufferlist(next);
})
.seq(function () {
var next = this.bind({}, null);
binary(next);
})
;
function binary (next) {
var em = emitter();
var t0 = Date.now();
Bin(em)
.loop(function (end) {
this
.word8('x')
.word8('y')
.word32be('z')
.word32le('w')
.buffer('buf', 10000 - 10)
.tap(function (vars) {
if (vars.x === 0) {
var tf = Date.now();
console.log(' binary: ' + (tf - t0) + ' ms');
end();
setTimeout(next, 20);
}
})
})
;
}
function bufferlist (next) {
var em = emitter();
var t0 = Date.now();
var blist = new BufferList;
em.on('data', function (buf) {
blist.push(buf);
});
Buf(blist)
.forever(function () {
var top = this;
this
.getWord8('x')
.getWord8('y')
.getWord32be('z')
.getWord32le('w')
.getBuffer('buf', 10000 - 10)
.tap(function (vars) {
if (vars.x === 0) {
var tf = Date.now();
console.log(' bufferlist: ' + (tf - t0) + ' ms');
top.exit();
setTimeout(next, 20);
}
})
})
.end()
;
}

80
node_modules/binary/perf/small.js generated vendored
View file

@ -1,80 +0,0 @@
var Seq = require('seq');
var Hash = require('hashish');
var Bin = require('binary');
var Buf = require('bufferlist/binary');
var BufferList = require('bufferlist');
var EventEmitter = require('events').EventEmitter;
function binary (buf, cb) {
Bin(buf)
.word32le('x')
.word16be('y')
.word16be('z')
.word32le('w')
.tap(cb)
;
};
function stream (buf, cb) {
var em = new EventEmitter;
Bin(em)
.word32le('x')
.word16be('y')
.word16be('z')
.word32le('w')
.tap(cb)
;
em.emit('data', buf);
};
function parse (buf, cb) {
cb(Bin.parse(buf)
.word32le('x')
.word16be('y')
.word16be('z')
.word32le('w')
.vars
);
};
function bufferlist (buf, cb) {
var blist = new BufferList;
blist.push(buf);
Buf(blist)
.getWord32le('x')
.getWord16be('y')
.getWord16be('z')
.getWord32le('w')
.tap(cb)
.end()
;
};
var buffers = [];
for (var i = 0; i < 200; i++) {
buffers.push(new Buffer(12));
}
console.log('small');
Seq(binary, stream, parse, bufferlist)
.seqEach(function (f) {
var t = this;
var t0 = Date.now();
Seq()
.extend(buffers)
.seqEach(function (buf) {
f(buf, this.bind(this, null));
})
.seq(function () {
var tf = Date.now();
console.log(' ' + f.name + ': ' + (tf - t0));
t(null);
})
;
})
.seq(function () {
this(null);
})
;

46
node_modules/binary/test/bu.js generated vendored
View file

@ -1,46 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('bu', function (t) {
t.plan(8);
// note: can't store -12667700813876161 exactly in an ieee float
var buf = new Buffer([
44, // a == 44
2, 43, // b == 555
164, 213, 37, 37, // c == 2765432101
29, 81, 180, 20, 155, 115, 203, 193, // d == 2112667700813876161
]);
binary.parse(buf)
.word8bu('a')
.word16bu('b')
.word32bu('c')
.word64bu('d')
.tap(function (vars) {
t.same(vars.a, 44);
t.same(vars.b, 555);
t.same(vars.c, 2765432101);
t.ok(
Math.abs(vars.d - 2112667700813876161) < 1500
);
})
;
// also check aliases here:
binary.parse(buf)
.word8be('a')
.word16be('b')
.word32be('c')
.word64be('d')
.tap(function (vars) {
t.same(vars.a, 44);
t.same(vars.b, 555);
t.same(vars.c, 2765432101);
t.ok(
Math.abs(vars.d - 2112667700813876161) < 1500
);
})
;
});

20
node_modules/binary/test/deferred.js generated vendored
View file

@ -1,20 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('deferred', function (t) {
t.plan(1);
var em = new EventEmitter;
binary.stream(em)
.word8('a')
.word16be('bc')
.tap(function (vars) {
t.same(vars, { a : 97, bc : 25187 });
})
;
setTimeout(function () {
em.emit('data', new Buffer([ 97, 98, 99 ]));
}, 10);
});

23
node_modules/binary/test/dots.js generated vendored
View file

@ -1,23 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('dots', function (t) {
t.plan(1);
binary.parse(new Buffer([ 97, 98, 99, 100, 101, 102 ]))
.word8('a')
.word16be('b.x')
.word16be('b.y')
.word8('b.z')
.tap(function (vars) {
t.same(vars, {
a : 97,
b : {
x : 256 * 98 + 99,
y : 256 * 100 + 101,
z : 102
},
});
})
;
});

41
node_modules/binary/test/eof.js generated vendored
View file

@ -1,41 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('eof', function (t) {
t.plan(4);
var stream = new EventEmitter;
binary.stream(stream)
.buffer('sixone', 5)
.peek(function () {
this.word32le('len');
})
.buffer('buf', 'len')
.word8('x')
.tap(function (vars) {
t.same(
[].slice.call(vars.sixone),
[].slice.call(new Buffer([ 6, 1, 6, 1, 6 ]))
);
t.same(vars.buf.length, vars.len);
t.same(
[].slice.call(vars.buf),
[ 9, 0, 0, 0, 97, 98, 99, 100, 101 ]
);
t.same(vars.x, 102);
})
;
var bufs = [
new Buffer([ 6, 1, 6, 1, 6, 9, 0, 0, 0, 97 ]),
new Buffer([ 98, 99 ]),
new Buffer([ 100, 101, 102 ]),
];
bufs.forEach(function (buf) {
stream.emit('data', buf);
});
stream.emit('end');
});

17
node_modules/binary/test/flush.js generated vendored
View file

@ -1,17 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('flush', function (t) {
t.plan(1);
binary.parse(new Buffer([ 97, 98, 99, 100, 101, 102 ]))
.word8('a')
.word16be('b')
.word16be('c')
.flush()
.word8('d')
.tap(function (vars) {
t.same(vars, { d : 102 });
})
;
});

View file

@ -1,14 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('from buffer', function (t) {
t.plan(1);
binary(new Buffer([ 97, 98, 99 ]))
.word8('a')
.word16be('bc')
.tap(function (vars) {
t.same(vars, { a : 97, bc : 25187 });
})
;
});

View file

@ -1,28 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('get buffer', function (t) {
t.plan(4);
var buf = new Buffer([ 4, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]);
binary.parse(buf)
.word8('a')
.buffer('b', 7)
.word16lu('c')
.tap(function (vars) {
t.equal(vars.a, 4);
t.equal(
vars.b.toString(),
new Buffer([ 2, 3, 4, 5, 6, 7, 8 ]).toString()
);
t.equal(vars.c, 2569);
})
.buffer('d', 'a')
.tap(function (vars) {
t.equal(
vars.d.toString(),
new Buffer([ 11, 12, 13, 14 ]).toString()
);
})
;
});

View file

@ -1,18 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('immediate', function (t) {
t.plan(1);
var em = new EventEmitter;
binary.stream(em, 'moo')
.word8('a')
.word16be('bc')
.tap(function (vars) {
t.same(vars, { a : 97, bc : 25187 });
})
;
em.emit('moo', new Buffer([ 97, 98, 99 ]));
});

38
node_modules/binary/test/interval.js generated vendored
View file

@ -1,38 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('interval', function (t) {
t.plan(1);
var em = new EventEmitter;
var i = 0;
var iv = setInterval(function () {
var buf = new Buffer(1000);
buf[0] = 0xff;
if (++i >= 1000) {
clearInterval(iv);
buf[0] = 0;
}
em.emit('data', buf);
}, 1);
var loops = 0;
binary(em)
.loop(function (end) {
this
.word8('x')
.word8('y')
.word32be('z')
.word32le('w')
.buffer('buf', 1000 - 10)
.tap(function (vars) {
loops ++;
if (vars.x == 0) end();
})
})
.tap(function () {
t.same(loops, 1000);
})
;
});

View file

@ -1,35 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('intoBuffer', function (t) {
t.plan(3);
var buf = new Buffer([ 1, 2, 3, 4, 5, 6 ])
binary.parse(buf)
.into('moo', function () {
this
.word8('x')
.word8('y')
.word8('z')
;
})
.tap(function (vars) {
t.same(vars, { moo : { x : 1, y : 2, z : 3 } });
})
.word8('w')
.tap(function (vars) {
t.same(vars, {
moo : { x : 1, y : 2, z : 3 },
w : 4,
});
})
.word8('x')
.tap(function (vars) {
t.same(vars, {
moo : { x : 1, y : 2, z : 3 },
w : 4,
x : 5,
});
})
;
});

View file

@ -1,43 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('into stream', function (t) {
t.plan(3);
var digits = [ 1, 2, 3, 4, 5, 6 ];
var stream = new EventEmitter;
var iv = setInterval(function () {
var d = digits.shift();
if (d) stream.emit('data', new Buffer([ d ]))
else clearInterval(iv)
}, 20);
binary.stream(stream)
.into('moo', function () {
this
.word8('x')
.word8('y')
.word8('z')
;
})
.tap(function (vars) {
t.same(vars, { moo : { x : 1, y : 2, z : 3 } });
})
.word8('w')
.tap(function (vars) {
t.same(vars, {
moo : { x : 1, y : 2, z : 3 },
w : 4,
});
})
.word8('x')
.tap(function (vars) {
t.same(vars, {
moo : { x : 1, y : 2, z : 3 },
w : 4,
x : 5,
});
})
;
});

44
node_modules/binary/test/loop.js generated vendored
View file

@ -1,44 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('loop', function (t) {
t.plan(3 * 2 + 1);
var em = new EventEmitter;
binary.stream(em)
.loop(function (end, vars) {
t.strictEqual(vars, this.vars);
this
.word16lu('a')
.word8u('b')
.word8s('c')
.tap(function (vars_) {
t.strictEqual(vars, vars_);
if (vars.c < 0) end();
})
;
})
.tap(function (vars) {
t.same(vars, { a : 1337, b : 55, c : -5 });
})
;
setTimeout(function () {
em.emit('data', new Buffer([ 2, 10, 88 ]));
}, 10);
setTimeout(function () {
em.emit('data', new Buffer([ 100, 3, 6, 242, 30 ]));
}, 20);
setTimeout(function () {
em.emit('data', new Buffer([ 60, 60, 199, 44 ]));
}, 30);
setTimeout(function () {
em.emit('data', new Buffer([ 57, 5 ]));
}, 80);
setTimeout(function () {
em.emit('data', new Buffer([ 55, 251 ]));
}, 90);
});

View file

@ -1,54 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('loop scan', function (t) {
t.plan(8 + 6 + 2);
var em = new EventEmitter;
binary.stream(em)
.loop(function (end) {
var vars_ = this.vars;
this
.scan('filler', 'BEGINMSG')
.buffer('cmd', 3)
.word8('num')
.tap(function (vars) {
t.strictEqual(vars, vars_);
if (vars.num != 0x02 && vars.num != 0x06) {
t.same(vars.filler.length, 0);
}
if (vars.cmd.toString() == 'end') end();
})
;
})
.tap(function (vars) {
t.same(vars.cmd.toString(), 'end');
t.same(vars.num, 0x08);
})
;
setTimeout(function () {
em.emit('data', new Buffer(
'BEGINMSGcmd\x01'
+ 'GARBAGEDATAXXXX'
+ 'BEGINMSGcmd\x02'
+ 'BEGINMSGcmd\x03'
));
}, 10);
setTimeout(function () {
em.emit('data', new Buffer(
'BEGINMSGcmd\x04'
+ 'BEGINMSGcmd\x05'
+ 'GARBAGEDATAXXXX'
+ 'BEGINMSGcmd\x06'
));
em.emit('data', new Buffer('BEGINMSGcmd\x07'));
}, 20);
setTimeout(function () {
em.emit('data', new Buffer('BEGINMSGend\x08'));
}, 30);
});

46
node_modules/binary/test/lu.js generated vendored
View file

@ -1,46 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('lu', function (t) {
t.plan(8);
// note: can't store -12667700813876161 exactly in an ieee float
var buf = new Buffer([
44, // a == 44
43, 2, // b == 555
37, 37, 213, 164, // c == 2765432101
193, 203, 115, 155, 20, 180, 81, 29, // d == 2112667700813876161
]);
binary.parse(buf)
.word8lu('a')
.word16lu('b')
.word32lu('c')
.word64lu('d')
.tap(function (vars) {
t.same(vars.a, 44);
t.same(vars.b, 555);
t.same(vars.c, 2765432101);
t.ok(
Math.abs(vars.d - 2112667700813876161) < 1500
);
})
;
// also check aliases here:
binary.parse(buf)
.word8le('a')
.word16le('b')
.word32le('c')
.word64le('d')
.tap(function (vars) {
t.same(vars.a, 44);
t.same(vars.b, 555);
t.same(vars.c, 2765432101);
t.ok(
Math.abs(vars.d - 2112667700813876161) < 1500
);
})
;
});

29
node_modules/binary/test/negbs.js generated vendored
View file

@ -1,29 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('negbs', function (t) {
t.plan(4);
// note: can't store -12667700813876161 exactly in an ieee float
var buf = new Buffer([
226, // a == -30
246, 219, // b == -2341
255, 243, 245, 236, // c == -789012
255, 210, 254, 203, 16, 222, 52, 63, // d == -12667700813876161
]);
binary.parse(buf)
.word8bs('a')
.word16bs('b')
.word32bs('c')
.word64bs('d')
.tap(function (vars) {
t.same(vars.a, -30);
t.same(vars.b, -2341);
t.same(vars.c, -789012);
t.ok(
Math.abs(vars.d - -12667700813876161) < 1500
);
})
;
});

29
node_modules/binary/test/negls.js generated vendored
View file

@ -1,29 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('negls', function (t) {
t.plan(4);
// note: can't store -12667700813876161 exactly in an ieee float
var buf = new Buffer([
226, // a == -30
219, 246, // b == -2341
236, 245, 243, 255, // c == -789012
63, 52, 222, 16, 203, 254, 210, 255, // d == -12667700813876161
]);
binary.parse(buf)
.word8ls('a')
.word16ls('b')
.word32ls('c')
.word64ls('d')
.tap(function (vars) {
t.same(vars.a, -30);
t.same(vars.b, -2341);
t.same(vars.c, -789012);
t.ok(
Math.abs(vars.d - -12667700813876161) < 1000
);
})
;
});

35
node_modules/binary/test/nested.js generated vendored
View file

@ -1,35 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('nested', function (t) {
t.plan(3);
var insideDone = false;
var em = new EventEmitter;
binary.stream(em)
.word16be('ab')
.tap(function () {
this
.word8('c')
.word8('d')
.tap(function () {
insideDone = true;
})
;
})
.tap(function (vars) {
t.ok(insideDone);
t.same(vars.c, 'c'.charCodeAt(0));
t.same(vars.d, 'd'.charCodeAt(0));
})
;
var strs = [ 'abc', 'def', 'hi', 'jkl' ];
var iv = setInterval(function () {
var s = strs.shift();
if (s) em.emit('data', new Buffer(s));
else clearInterval(iv);
}, 50);
});

View file

@ -1,17 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('not enough buf', function (t) {
t.plan(3);
var vars = binary(new Buffer([1,2,3,4]))
.word8('a')
.buffer('b', 10)
.word8('c')
.vars
;
t.same(vars.a, 1);
t.equal(vars.b.toString(), new Buffer([2,3,4]).toString());
t.strictEqual(vars.c, null);
});

View file

@ -1,19 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('not enough parse', function (t) {
t.plan(4);
var vars = binary(new Buffer([1,2]))
.word8('a')
.word8('b')
.word8('c')
.word8('d')
.vars
;
t.same(vars.a, 1);
t.same(vars.b, 2);
t.strictEqual(vars.c, null);
t.strictEqual(vars.d, null);
});

54
node_modules/binary/test/parse.js generated vendored
View file

@ -1,54 +0,0 @@
var binary = require('../');
var test = require('tap').test;
test('parse', function (t) {
t.plan(6);
var res = binary.parse(new Buffer([ 97, 98, 99, 99, 99, 99, 1, 2, 3 ]))
.word8('a')
.word16be('bc')
.skip(3)
.buffer('def', 3)
.tap(function (vars) {
t.equal(vars.a, 97);
t.equal(vars.bc, 25187);
t.same(
[].slice.call(vars.def),
[].slice.call(new Buffer([ 1, 2, 3]))
);
})
.vars
;
t.equal(res.a, 97);
t.equal(res.bc, 25187);
t.same(
[].slice.call(res.def),
[].slice.call(new Buffer([ 1, 2, 3 ]))
);
});
test('loop', function (t) {
t.plan(2);
var res = binary.parse(new Buffer([ 97, 98, 99, 4, 5, 2, -3, 9 ]))
.word8('a')
.word16be('bc')
.loop(function (end) {
var x = this.word8s('x').vars.x;
if (x < 0) end();
})
.tap(function (vars) {
t.same(vars, {
a : 97,
bc : 25187,
x : -3,
});
})
.word8('y')
.vars
;
t.same(res, {
a : 97,
bc : 25187,
x : -3,
y : 9,
});
});

40
node_modules/binary/test/peek.js generated vendored
View file

@ -1,40 +0,0 @@
var binary = require('../');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
test('peek', function (t) {
t.plan(4);
var bufs = [
new Buffer([ 6, 1, 6, 1, 6, 9, 0, 0, 0, 97 ]),
new Buffer([ 98, 99 ]),
new Buffer([ 100, 101, 102 ]),
];
var stream = new EventEmitter;
var iv = setInterval(function () {
var buf = bufs.shift();
if (buf) stream.emit('data', buf)
else clearInterval(iv)
}, 20);
binary.stream(stream)
.buffer('sixone', 5)
.peek(function () {
this.word32le('len');
})
.buffer('buf', 'len')
.word8('x')
.tap(function (vars) {
t.same(
[].slice.call(vars.sixone),
[].slice.call(new Buffer([ 6, 1, 6, 1, 6 ]))
);
t.same(vars.buf.length, vars.len);
t.same(
[].slice.call(vars.buf),
[ 9, 0, 0, 0, 97, 98, 99, 100, 101 ]
);
t.same(vars.x, 102);
})
;
});

Some files were not shown because too many files have changed in this diff Show more