Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions dist/lib.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { parseArgs } from "node:util";
//#region src/tools/lib.ts
async function getAgent(buildAgent) {
if (!buildAgent || !/^[a-z0-9-]+$/i.test(buildAgent)) throw new Error(`Invalid build agent: ${buildAgent}`);
return new (await (import(`./tools/${buildAgent}/agent.mjs`))).BuildAgent();
}
async function getToolRunner(buildAgent, tool) {
if (!tool || !/^[a-z0-9-]+$/i.test(tool)) throw new Error(`Invalid tool: ${tool}`);
const agent = await getAgent(buildAgent);
return new (await (import(`./tools/libs/${tool}.mjs`))).Runner(agent);
}
function parseCliArgs() {
return parseArgs({ options: {
agent: {
type: "string",
short: "a"
},
tool: {
type: "string",
short: "t"
},
command: {
type: "string",
short: "c"
}
} }).values;
}
async function run(agent, tool, command) {
return await (await getToolRunner(agent, tool)).run(command);
}
/**
* Returns all indexes of a specified single character within a given string.
*
* Iterates through the `searchString` and collects the zero-based indexes
* where the character `indexOf` appears. Throws an error if `indexOf` is not a single character.
*
* @param searchString - The string to search within.
* @param indexOf - The single character to find in the string.
* @returns An array of indexes where the character appears in the string.
* @throws {Error} If `indexOf` is not a single character.
*/
function allIndexesOf(searchString, indexOf) {
if (indexOf.length !== 1) throw new Error("indexOf must be a single character");
const resultArray = [];
for (let i = 0; i < searchString.length; i++) if (searchString[i] === indexOf) resultArray.push(i);
return resultArray;
}
//#endregion
export { run as a, parseCliArgs as i, getAgent as n, getToolRunner as r, allIndexesOf as t };

//# sourceMappingURL=lib.mjs.map
1 change: 1 addition & 0 deletions dist/lib.mjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions dist/rolldown-runtime.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
export { __toESM as n, __commonJSMin as t };
219 changes: 105 additions & 114 deletions dist/tools/azure/agent.mjs
Original file line number Diff line number Diff line change
@@ -1,123 +1,114 @@
import * as os from 'node:os';
import * as process from 'node:process';
import { B as BuildAgentBase } from '../libs/agents.mjs';

const CMD_PREFIX = "##vso[";
var TaskResult = /* @__PURE__ */ ((TaskResult2) => {
TaskResult2[TaskResult2["Succeeded"] = 0] = "Succeeded";
TaskResult2[TaskResult2["SucceededWithIssues"] = 1] = "SucceededWithIssues";
TaskResult2[TaskResult2["Failed"] = 2] = "Failed";
TaskResult2[TaskResult2["Cancelled"] = 3] = "Cancelled";
TaskResult2[TaskResult2["Skipped"] = 4] = "Skipped";
return TaskResult2;
})(TaskResult || {});
import { t as BuildAgentBase } from "../libs/agents.mjs";
import * as os from "node:os";
import * as process from "node:process";
//#region src/agents/azure/command.ts
var CMD_PREFIX = "##vso[";
var TaskResult = /* @__PURE__ */ function(TaskResult) {
TaskResult[TaskResult["Succeeded"] = 0] = "Succeeded";
TaskResult[TaskResult["SucceededWithIssues"] = 1] = "SucceededWithIssues";
TaskResult[TaskResult["Failed"] = 2] = "Failed";
TaskResult[TaskResult["Cancelled"] = 3] = "Cancelled";
TaskResult[TaskResult["Skipped"] = 4] = "Skipped";
return TaskResult;
}({});
/**
* Command Format:
* ##vso[artifact.command key=value;key=value]user message
*
* Examples:
* ##vso[task.progress value=58]
* ##vso[task.issue type=warning;]This is the user warning message
**/
function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message);
process.stdout.write(`${cmd.toString()}${os.EOL}`);
}
class Command {
command;
message;
properties;
constructor(command, properties, message) {
if (!command) {
command = "missing.command";
}
this.command = command;
this.properties = properties;
this.message = message;
}
toString() {
let cmdStr = CMD_PREFIX + this.command;
if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += " ";
for (const key in this.properties) {
if (Object.prototype.hasOwnProperty.call(this.properties, key)) {
const val = this.properties[key];
if (val) {
cmdStr += `${key}=${escapeProperty(`${val || ""}`)};`;
}
}
}
}
cmdStr += "]";
const message = `${this.message || ""}`;
cmdStr += escapeData(message);
return cmdStr;
}
const cmd = new Command(command, properties, message);
process.stdout.write(`${cmd.toString()}${os.EOL}`);
}
var Command = class {
command;
message;
properties;
constructor(command, properties, message) {
if (!command) command = "missing.command";
this.command = command;
this.properties = properties;
this.message = message;
}
toString() {
let cmdStr = CMD_PREFIX + this.command;
if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += " ";
for (const key in this.properties) if (Object.prototype.hasOwnProperty.call(this.properties, key)) {
const val = this.properties[key];
if (val) cmdStr += `${key}=${escapeProperty(`${val || ""}`)};`;
}
}
cmdStr += "]";
const message = `${this.message || ""}`;
cmdStr += escapeData(message);
return cmdStr;
}
};
function escapeData(s) {
return toCommandValue(s).replace(/%/g, "%AZP25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
return toCommandValue(s).replace(/%/g, "%AZP25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
}
function escapeProperty(s) {
return toCommandValue(s).replace(/%/g, "%AZP25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/]/g, "%5D").replace(/;/g, "%3B");
return toCommandValue(s).replace(/%/g, "%AZP25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/]/g, "%5D").replace(/;/g, "%3B");
}
function toCommandValue(input) {
if (input === null || input === void 0) {
return "";
} else if (typeof input === "string" || input instanceof String) {
return input;
}
return JSON.stringify(input);
}

class BuildAgent extends BuildAgentBase {
agentName = "Azure Pipelines";
sourceDirVariable = "BUILD_SOURCESDIRECTORY";
tempDirVariable = "AGENT_TEMPDIRECTORY";
cacheDirVariable = "AGENT_TOOLSDIRECTORY";
addPath(inputPath) {
super.addPath(inputPath);
issueCommand("task.prependpath", {}, inputPath);
}
info = (message) => {
process.stdout.write(`${message}${os.EOL}`);
};
debug = (message) => issueCommand("task.debug", {}, message);
warn = (message) => issueCommand("task.issue", { type: "warning" }, message);
error = (message) => issueCommand("task.issue", { type: "error" }, message);
setSucceeded = (message, done) => this._setResult(TaskResult.Succeeded, message, done);
setFailed = (message, done) => this._setResult(TaskResult.Failed, message, done);
setOutput = (name, value) => this._setVariable(name, value, true);
setVariable = (name, value) => this._setVariable(name, value);
updateBuildNumber = (version) => this._updateBuildNumber(version);
_updateBuildNumber(version) {
this.debug(`build number: ${version}`);
issueCommand("build.updatebuildnumber", {}, version);
}
_setResult(result, message, done) {
this.debug(`task result: ${TaskResult[result]}`);
if (result === TaskResult.Failed && message) {
this.error(message);
} else if (result === TaskResult.SucceededWithIssues && message) {
this.warn(message);
} else {
this.info(message);
}
const properties = { result: TaskResult[result] };
if (done) {
properties["done"] = "true";
}
issueCommand("task.complete", properties, message);
}
_setVariable(name, val, isOutput = false) {
const key = this._getVariableKey(name);
const varValue = val || "";
process.env[key] = varValue;
issueCommand(
"task.setvariable",
{
variable: name || "",
isOutput: (isOutput || false).toString(),
issecret: "false"
},
varValue
);
}
_getVariableKey(name) {
return name.replace(/\./g, "_").replace(/ /g, "_").toUpperCase();
}
if (input === null || input === void 0) return "";
else if (typeof input === "string" || input instanceof String) return input;
return JSON.stringify(input);
}

//#endregion
//#region src/agents/azure/build-agent.ts
var BuildAgent = class extends BuildAgentBase {
agentName = "Azure Pipelines";
sourceDirVariable = "BUILD_SOURCESDIRECTORY";
tempDirVariable = "AGENT_TEMPDIRECTORY";
cacheDirVariable = "AGENT_TOOLSDIRECTORY";
addPath(inputPath) {
super.addPath(inputPath);
issueCommand("task.prependpath", {}, inputPath);
}
info = (message) => {
process.stdout.write(`${message}${os.EOL}`);
};
debug = (message) => issueCommand("task.debug", {}, message);
warn = (message) => issueCommand("task.issue", { type: "warning" }, message);
error = (message) => issueCommand("task.issue", { type: "error" }, message);
setSucceeded = (message, done) => this._setResult(TaskResult.Succeeded, message, done);
setFailed = (message, done) => this._setResult(TaskResult.Failed, message, done);
setOutput = (name, value) => this._setVariable(name, value, true);
setVariable = (name, value) => this._setVariable(name, value);
updateBuildNumber = (version) => this._updateBuildNumber(version);
_updateBuildNumber(version) {
this.debug(`build number: ${version}`);
issueCommand("build.updatebuildnumber", {}, version);
}
_setResult(result, message, done) {
this.debug(`task result: ${TaskResult[result]}`);
if (result === TaskResult.Failed && message) this.error(message);
else if (result === TaskResult.SucceededWithIssues && message) this.warn(message);
else this.info(message);
const properties = { result: TaskResult[result] };
if (done) properties["done"] = "true";
issueCommand("task.complete", properties, message);
}
_setVariable(name, val, isOutput = false) {
const key = this._getVariableKey(name);
const varValue = val || "";
process.env[key] = varValue;
issueCommand("task.setvariable", {
variable: name || "",
isOutput: (isOutput || false).toString(),
issecret: "false"
}, varValue);
}
_getVariableKey(name) {
return name.replace(/\./g, "_").replace(/ /g, "_").toUpperCase();
}
};
//#endregion
export { BuildAgent };
//# sourceMappingURL=agent.mjs.map

//# sourceMappingURL=agent.mjs.map
Loading