lerna
Version:
Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository
1,518 lines (1,496 loc) • 450 kB
JavaScript
"use strict";
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 __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// libs/core/src/lib/add-dependencies.ts
function addDependencies(projects, projectGraph) {
const projectsLookup = new Set(projects.map((p) => p.name));
const dependencies = projectGraph.localPackageDependencies;
const collected = /* @__PURE__ */ new Set();
projects.forEach((currentNode) => {
if (dependencies[currentNode.name] && dependencies[currentNode.name].length === 0) {
return;
}
const queue2 = [currentNode];
const seen = /* @__PURE__ */ new Set();
while (queue2.length) {
const node = queue2.shift();
dependencies[node.name]?.forEach(({ target }) => {
if (seen.has(target)) {
return;
}
seen.add(target);
if (target === currentNode.name || projectsLookup.has(target)) {
return;
}
const dependencyNode = projectGraph.nodes[target];
collected.add(dependencyNode);
queue2.push(dependencyNode);
});
}
});
return Array.from(/* @__PURE__ */ new Set([...projects, ...collected]));
}
var init_add_dependencies = __esm({
"libs/core/src/lib/add-dependencies.ts"() {
"use strict";
}
});
// libs/core/src/lib/add-dependents.ts
function addDependents(projects, projectGraph) {
const projectsLookup = new Set(projects.map((p) => p.name));
const dependents = (0, import_lodash.flatten)(
Object.values(projectGraph.localPackageDependencies)
).reduce(
(prev, next) => ({
...prev,
[next.target]: [...prev[next.target] || [], next.source]
}),
{}
);
const collected = /* @__PURE__ */ new Set();
projects.forEach((currentNode) => {
if (dependents[currentNode.name] && dependents[currentNode.name].length === 0) {
return;
}
const queue2 = [currentNode];
const seen = /* @__PURE__ */ new Set();
while (queue2.length) {
const node = queue2.shift();
dependents[node.name]?.forEach((dep) => {
if (seen.has(dep)) {
return;
}
seen.add(dep);
if (dep === currentNode.name || projectsLookup.has(dep)) {
return;
}
const dependentNode = projectGraph.nodes[dep];
collected.add(dependentNode);
queue2.push(dependentNode);
});
}
});
return Array.from(/* @__PURE__ */ new Set([...projects, ...collected]));
}
var import_lodash;
var init_add_dependents = __esm({
"libs/core/src/lib/add-dependents.ts"() {
"use strict";
import_lodash = require("lodash");
}
});
// libs/core/src/lib/npmlog/are-we-there-yet/tracker-base.ts
var import_node_events, trackerId, TrackerBase;
var init_tracker_base = __esm({
"libs/core/src/lib/npmlog/are-we-there-yet/tracker-base.ts"() {
"use strict";
import_node_events = __toESM(require("node:events"));
trackerId = 0;
TrackerBase = class extends import_node_events.default {
constructor(name = "") {
super();
this.id = ++trackerId;
this.name = name;
}
};
}
});
// libs/core/src/lib/npmlog/are-we-there-yet/tracker.ts
var Tracker;
var init_tracker = __esm({
"libs/core/src/lib/npmlog/are-we-there-yet/tracker.ts"() {
"use strict";
init_tracker_base();
Tracker = class extends TrackerBase {
constructor(name, todo) {
super(name);
this.workDone = 0;
this.workTodo = todo || 0;
}
completed() {
return this.workTodo === 0 ? 0 : this.workDone / this.workTodo;
}
addWork(work) {
this.workTodo += work;
this.emit("change", this.name, this.completed(), this);
}
completeWork(work) {
this.workDone += work;
if (this.workDone > this.workTodo) {
this.workDone = this.workTodo;
}
this.emit("change", this.name, this.completed(), this);
}
finish() {
this.workTodo = this.workDone = 1;
this.emit("change", this.name, 1, this);
}
};
}
});
// libs/core/src/lib/npmlog/are-we-there-yet/tracker-stream.ts
var import_node_stream, TrackerStream;
var init_tracker_stream = __esm({
"libs/core/src/lib/npmlog/are-we-there-yet/tracker-stream.ts"() {
"use strict";
import_node_stream = __toESM(require("node:stream"));
init_tracker();
TrackerStream = class extends import_node_stream.default.Transform {
constructor(name, size = 0, options) {
super(options);
this.tracker = new Tracker(name, size);
this.name = name;
this.id = this.tracker.id;
this.tracker.on("change", this.trackerChange.bind(this));
}
trackerChange(name, completion) {
this.emit("change", name, completion, this);
}
_transform(data, encoding, cb) {
this.tracker.completeWork(data.length ? data.length : 1);
this.push(data);
cb();
}
_flush(cb) {
this.tracker.finish();
cb();
}
completed() {
return this.tracker.completed();
}
addWork(work) {
return this.tracker.addWork(work);
}
finish() {
return this.tracker.finish();
}
};
}
});
// libs/core/src/lib/npmlog/are-we-there-yet/tracker-group.ts
function bubbleChange(trackerGroup) {
return function(name, completed, tracker) {
trackerGroup.completion[tracker.id] = completed;
if (trackerGroup.finished) {
return;
}
trackerGroup.emit("change", name || trackerGroup.name, trackerGroup.completed(), trackerGroup);
};
}
var TrackerGroup;
var init_tracker_group = __esm({
"libs/core/src/lib/npmlog/are-we-there-yet/tracker-group.ts"() {
"use strict";
init_tracker();
init_tracker_base();
init_tracker_stream();
TrackerGroup = class _TrackerGroup extends TrackerBase {
constructor() {
super(...arguments);
this.parentGroup = null;
this.trackers = [];
this.completion = {};
this.weight = {};
this.totalWeight = 0;
this.finished = false;
this.bubbleChange = bubbleChange(this);
}
nameInTree() {
const names = [];
let from = this;
while (from) {
names.unshift(from.name);
from = from.parentGroup;
}
return names.join("/");
}
addUnit(unit, weight = 0) {
if (unit.addUnit) {
let toTest = this;
while (toTest) {
if (unit === toTest) {
throw new Error(
"Attempted to add tracker group " + unit.name + " to tree that already includes it " + this.nameInTree()
);
}
toTest = toTest.parentGroup;
}
unit.parentGroup = this;
}
this.weight[unit.id] = weight || 1;
this.totalWeight += this.weight[unit.id];
this.trackers.push(unit);
this.completion[unit.id] = unit.completed();
unit.on("change", this.bubbleChange);
if (!this.finished) {
this.emit("change", unit.name, this.completion[unit.id], unit);
}
return unit;
}
completed() {
if (this.trackers.length === 0) {
return 0;
}
const valPerWeight = 1 / this.totalWeight;
let completed = 0;
for (let ii = 0; ii < this.trackers.length; ii++) {
const trackerId2 = this.trackers[ii].id;
completed += valPerWeight * this.weight[trackerId2] * this.completion[trackerId2];
}
return completed;
}
newGroup(name, weight = 0) {
return this.addUnit(new _TrackerGroup(name), weight);
}
newItem(name, todo, weight = 0) {
return this.addUnit(new Tracker(name, todo), weight);
}
newStream(name, todo, weight = 0) {
return this.addUnit(new TrackerStream(name, todo), weight);
}
finish() {
this.finished = true;
if (!this.trackers.length) {
this.addUnit(new Tracker(), 1);
}
for (let ii = 0; ii < this.trackers.length; ii++) {
const tracker = this.trackers[ii];
tracker.finish();
tracker.removeListener("change", this.bubbleChange);
}
this.emit("change", this.name, 1, this);
}
debug(depth = 0) {
const indent = " ".repeat(depth);
let output2 = `${indent}${this.name || "top"}: ${this.completed()}
`;
this.trackers.forEach(function(tracker) {
output2 += tracker instanceof _TrackerGroup ? tracker.debug(depth + 1) : `${indent} ${tracker.name}: ${tracker.completed()}
`;
});
return output2;
}
};
}
});
// libs/core/src/lib/npmlog/gauge/wide-truncate.ts
var require_wide_truncate = __commonJS({
"libs/core/src/lib/npmlog/gauge/wide-truncate.ts"(exports2, module2) {
"use strict";
var stringWidth = require("string-width");
var util4 = require("node:util");
module2.exports = wideTruncate;
function wideTruncate(str, target) {
if (stringWidth(str) === 0) {
return str;
}
if (target <= 0) {
return "";
}
if (stringWidth(str) <= target) {
return str;
}
var noAnsi = util4.stripVTControlCharacters(str);
var ansiSize = str.length + noAnsi.length;
var truncated = str.slice(0, target + ansiSize);
while (stringWidth(truncated) > target) {
truncated = truncated.slice(0, -1);
}
return truncated;
}
}
});
// libs/core/src/lib/npmlog/gauge/error.ts
var require_error = __commonJS({
"libs/core/src/lib/npmlog/gauge/error.ts"(exports2) {
"use strict";
var util4 = require("util");
var User = exports2.User = function User2(msg) {
var err = new Error(msg);
Error.captureStackTrace(err, User2);
err.code = "EGAUGE";
return err;
};
exports2.MissingTemplateValue = function MissingTemplateValue(item, values) {
var err = new User(util4.format('Missing template value "%s"', item.type));
Error.captureStackTrace(err, MissingTemplateValue);
err.template = item;
err.values = values;
return err;
};
exports2.Internal = function Internal(msg) {
var err = new Error(msg);
Error.captureStackTrace(err, Internal);
err.code = "EGAUGEINTERNAL";
return err;
};
}
});
// libs/core/src/lib/npmlog/gauge/template-item.ts
var require_template_item = __commonJS({
"libs/core/src/lib/npmlog/gauge/template-item.ts"(exports2, module2) {
"use strict";
var stringWidth = require("string-width");
module2.exports = TemplateItem;
function isPercent(num) {
if (typeof num !== "string") {
return false;
}
return num.slice(-1) === "%";
}
function percent(num) {
return Number(num.slice(0, -1)) / 100;
}
function TemplateItem(values, outputLength) {
this.overallOutputLength = outputLength;
this.finished = false;
this.type = null;
this.value = null;
this.length = null;
this.maxLength = null;
this.minLength = null;
this.kerning = null;
this.align = "left";
this.padLeft = 0;
this.padRight = 0;
this.index = null;
this.first = null;
this.last = null;
if (typeof values === "string") {
this.value = values;
} else {
for (var prop in values) {
this[prop] = values[prop];
}
}
if (isPercent(this.length)) {
this.length = Math.round(this.overallOutputLength * percent(this.length));
}
if (isPercent(this.minLength)) {
this.minLength = Math.round(this.overallOutputLength * percent(this.minLength));
}
if (isPercent(this.maxLength)) {
this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength));
}
return this;
}
TemplateItem.prototype = {};
TemplateItem.prototype.getBaseLength = function() {
var length = this.length;
if (length == null && typeof this.value === "string" && this.maxLength == null && this.minLength == null) {
length = stringWidth(this.value);
}
return length;
};
TemplateItem.prototype.getLength = function() {
var length = this.getBaseLength();
if (length == null) {
return null;
}
return length + this.padLeft + this.padRight;
};
TemplateItem.prototype.getMaxLength = function() {
if (this.maxLength == null) {
return null;
}
return this.maxLength + this.padLeft + this.padRight;
};
TemplateItem.prototype.getMinLength = function() {
if (this.minLength == null) {
return null;
}
return this.minLength + this.padLeft + this.padRight;
};
}
});
// libs/core/src/lib/npmlog/gauge/render-template.ts
var require_render_template = __commonJS({
"libs/core/src/lib/npmlog/gauge/render-template.ts"(exports2, module2) {
"use strict";
var align = require("wide-align");
var validate = require("aproba");
var wideTruncate = require_wide_truncate();
var error = require_error();
var TemplateItem = require_template_item();
function renderValueWithValues(values) {
return function(item) {
return renderValue(item, values);
};
}
var renderTemplate = module2.exports = function(width, template, values) {
var items = prepareItems(width, template, values);
var rendered = items.map(renderValueWithValues(values)).join("");
return align.left(wideTruncate(rendered, width), width);
};
function preType(item) {
var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1);
return "pre" + cappedTypeName;
}
function postType(item) {
var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1);
return "post" + cappedTypeName;
}
function hasPreOrPost(item, values) {
if (!item.type) {
return;
}
return values[preType(item)] || values[postType(item)];
}
function generatePreAndPost(baseItem, parentValues) {
var item = Object.assign({}, baseItem);
var values = Object.create(parentValues);
var template = [];
var pre = preType(item);
var post = postType(item);
if (values[pre]) {
template.push({ value: values[pre] });
values[pre] = null;
}
item.minLength = null;
item.length = null;
item.maxLength = null;
template.push(item);
values[item.type] = values[item.type];
if (values[post]) {
template.push({ value: values[post] });
values[post] = null;
}
return function($1, $2, length) {
return renderTemplate(length, template, values);
};
}
function prepareItems(width, template, values) {
function cloneAndObjectify(item, index, arr) {
var cloned = new TemplateItem(item, width);
var type = cloned.type;
if (cloned.value == null) {
if (!(type in values)) {
if (cloned.default == null) {
throw new error.MissingTemplateValue(cloned, values);
} else {
cloned.value = cloned.default;
}
} else {
cloned.value = values[type];
}
}
if (cloned.value == null || cloned.value === "") {
return null;
}
cloned.index = index;
cloned.first = index === 0;
cloned.last = index === arr.length - 1;
if (hasPreOrPost(cloned, values)) {
cloned.value = generatePreAndPost(cloned, values);
}
return cloned;
}
var output2 = template.map(cloneAndObjectify).filter(function(item) {
return item != null;
});
var remainingSpace = width;
var variableCount = output2.length;
function consumeSpace(length) {
if (length > remainingSpace) {
length = remainingSpace;
}
remainingSpace -= length;
}
function finishSizing(item, length) {
if (item.finished) {
throw new error.Internal("Tried to finish template item that was already finished");
}
if (length === Infinity) {
throw new error.Internal("Length of template item cannot be infinity");
}
if (length != null) {
item.length = length;
}
item.minLength = null;
item.maxLength = null;
--variableCount;
item.finished = true;
if (item.length == null) {
item.length = item.getBaseLength();
}
if (item.length == null) {
throw new error.Internal("Finished template items must have a length");
}
consumeSpace(item.getLength());
}
output2.forEach(function(item) {
if (!item.kerning) {
return;
}
var prevPadRight = item.first ? 0 : output2[item.index - 1].padRight;
if (!item.first && prevPadRight < item.kerning) {
item.padLeft = item.kerning - prevPadRight;
}
if (!item.last) {
item.padRight = item.kerning;
}
});
output2.forEach(function(item) {
if (item.getBaseLength() == null) {
return;
}
finishSizing(item);
});
var resized = 0;
var resizing;
var hunkSize;
do {
resizing = false;
hunkSize = Math.round(remainingSpace / variableCount);
output2.forEach(function(item) {
if (item.finished) {
return;
}
if (!item.maxLength) {
return;
}
if (item.getMaxLength() < hunkSize) {
finishSizing(item, item.maxLength);
resizing = true;
}
});
} while (resizing && resized++ < output2.length);
if (resizing) {
throw new error.Internal("Resize loop iterated too many times while determining maxLength");
}
resized = 0;
do {
resizing = false;
hunkSize = Math.round(remainingSpace / variableCount);
output2.forEach(function(item) {
if (item.finished) {
return;
}
if (!item.minLength) {
return;
}
if (item.getMinLength() >= hunkSize) {
finishSizing(item, item.minLength);
resizing = true;
}
});
} while (resizing && resized++ < output2.length);
if (resizing) {
throw new error.Internal("Resize loop iterated too many times while determining minLength");
}
hunkSize = Math.round(remainingSpace / variableCount);
output2.forEach(function(item) {
if (item.finished) {
return;
}
finishSizing(item, hunkSize);
});
return output2;
}
function renderFunction(item, values, length) {
validate("OON", arguments);
if (item.type) {
return item.value(values, values[item.type + "Theme"] || {}, length);
} else {
return item.value(values, {}, length);
}
}
function renderValue(item, values) {
var length = item.getBaseLength();
var value = typeof item.value === "function" ? renderFunction(item, values, length) : item.value;
if (value == null || value === "") {
return "";
}
var alignWith = align[item.align] || align.left;
var leftPadding = item.padLeft ? align.left("", item.padLeft) : "";
var rightPadding = item.padRight ? align.right("", item.padRight) : "";
var truncated = wideTruncate(String(value), length);
var aligned = alignWith(truncated, length);
return leftPadding + aligned + rightPadding;
}
}
});
// libs/core/src/lib/npmlog/gauge/plumbing.ts
var require_plumbing = __commonJS({
"libs/core/src/lib/npmlog/gauge/plumbing.ts"(exports2, module2) {
"use strict";
var consoleControl2 = require("console-control-strings");
var renderTemplate = require_render_template();
var validate = require("aproba");
var Plumbing2 = module2.exports = function(theme, template, width) {
if (!width) {
width = 80;
}
validate("OAN", [theme, template, width]);
this.showing = false;
this.theme = theme;
this.width = width;
this.template = template;
};
Plumbing2.prototype = {};
Plumbing2.prototype.setTheme = function(theme) {
validate("O", [theme]);
this.theme = theme;
};
Plumbing2.prototype.setTemplate = function(template) {
validate("A", [template]);
this.template = template;
};
Plumbing2.prototype.setWidth = function(width) {
validate("N", [width]);
this.width = width;
};
Plumbing2.prototype.hide = function() {
return consoleControl2.gotoSOL() + consoleControl2.eraseLine();
};
Plumbing2.prototype.hideCursor = consoleControl2.hideCursor;
Plumbing2.prototype.showCursor = consoleControl2.showCursor;
Plumbing2.prototype.show = function(status) {
var values = Object.create(this.theme);
for (var key in status) {
values[key] = status[key];
}
return renderTemplate(this.width, this.template, values).trim() + consoleControl2.color("reset") + consoleControl2.eraseLine() + consoleControl2.gotoSOL();
};
}
});
// libs/core/src/lib/npmlog/gauge/has-color.ts
var require_has_color = __commonJS({
"libs/core/src/lib/npmlog/gauge/has-color.ts"(exports2, module2) {
"use strict";
var colorSupport = require("color-support");
module2.exports = colorSupport().hasBasic;
}
});
// libs/core/src/lib/npmlog/gauge/spin.ts
var require_spin = __commonJS({
"libs/core/src/lib/npmlog/gauge/spin.ts"(exports2, module2) {
"use strict";
module2.exports = function spin(spinstr, spun) {
return spinstr[spun % spinstr.length];
};
}
});
// libs/core/src/lib/npmlog/gauge/progress-bar.ts
var require_progress_bar = __commonJS({
"libs/core/src/lib/npmlog/gauge/progress-bar.ts"(exports2, module2) {
"use strict";
var validate = require("aproba");
var renderTemplate = require_render_template();
var wideTruncate = require_wide_truncate();
var stringWidth = require("string-width");
module2.exports = function(theme, width, completed) {
validate("ONN", [theme, width, completed]);
if (completed < 0) {
completed = 0;
}
if (completed > 1) {
completed = 1;
}
if (width <= 0) {
return "";
}
var sofar = Math.round(width * completed);
var rest = width - sofar;
var template = [
{ type: "complete", value: repeat(theme.complete, sofar), length: sofar },
{ type: "remaining", value: repeat(theme.remaining, rest), length: rest }
];
return renderTemplate(width, template, theme);
};
function repeat(string, width) {
var result = "";
var n = width;
do {
if (n % 2) {
result += string;
}
n = Math.floor(n / 2);
string += string;
} while (n && stringWidth(result) < width);
return wideTruncate(result, width);
}
}
});
// libs/core/src/lib/npmlog/gauge/base-theme.ts
var require_base_theme = __commonJS({
"libs/core/src/lib/npmlog/gauge/base-theme.ts"(exports2, module2) {
"use strict";
var spin = require_spin();
var progressBar = require_progress_bar();
module2.exports = {
activityIndicator: function(values, theme) {
if (values.spun == null) {
return;
}
return spin(theme, values.spun);
},
progressbar: function(values, theme, width) {
if (values.completed == null) {
return;
}
return progressBar(theme, width, values.completed);
}
};
}
});
// libs/core/src/lib/npmlog/gauge/theme-set.ts
var require_theme_set = __commonJS({
"libs/core/src/lib/npmlog/gauge/theme-set.ts"(exports2, module2) {
"use strict";
module2.exports = function() {
return ThemeSetProto.newThemeSet();
};
var ThemeSetProto = {};
ThemeSetProto.baseTheme = require_base_theme();
ThemeSetProto.newTheme = function(parent, theme) {
if (!theme) {
theme = parent;
parent = this.baseTheme;
}
return Object.assign({}, parent, theme);
};
ThemeSetProto.getThemeNames = function() {
return Object.keys(this.themes);
};
ThemeSetProto.addTheme = function(name, parent, theme) {
this.themes[name] = this.newTheme(parent, theme);
};
ThemeSetProto.addToAllThemes = function(theme) {
var themes = this.themes;
Object.keys(themes).forEach(function(name) {
Object.assign(themes[name], theme);
});
Object.assign(this.baseTheme, theme);
};
ThemeSetProto.getTheme = function(name) {
if (!this.themes[name]) {
throw this.newMissingThemeError(name);
}
return this.themes[name];
};
ThemeSetProto.setDefault = function(opts, name) {
if (name == null) {
name = opts;
opts = {};
}
var platform = opts.platform == null ? "fallback" : opts.platform;
var hasUnicode3 = !!opts.hasUnicode;
var hasColor2 = !!opts.hasColor;
if (!this.defaults[platform]) {
this.defaults[platform] = { true: {}, false: {} };
}
this.defaults[platform][hasUnicode3][hasColor2] = name;
};
ThemeSetProto.getDefault = function(opts) {
if (!opts) {
opts = {};
}
var platformName = opts.platform || process.platform;
var platform = this.defaults[platformName] || this.defaults.fallback;
var hasUnicode3 = !!opts.hasUnicode;
var hasColor2 = !!opts.hasColor;
if (!platform) {
throw this.newMissingDefaultThemeError(platformName, hasUnicode3, hasColor2);
}
if (!platform[hasUnicode3][hasColor2]) {
if (hasUnicode3 && hasColor2 && platform[!hasUnicode3][hasColor2]) {
hasUnicode3 = false;
} else if (hasUnicode3 && hasColor2 && platform[hasUnicode3][!hasColor2]) {
hasColor2 = false;
} else if (hasUnicode3 && hasColor2 && platform[!hasUnicode3][!hasColor2]) {
hasUnicode3 = false;
hasColor2 = false;
} else if (hasUnicode3 && !hasColor2 && platform[!hasUnicode3][hasColor2]) {
hasUnicode3 = false;
} else if (!hasUnicode3 && hasColor2 && platform[hasUnicode3][!hasColor2]) {
hasColor2 = false;
} else if (platform === this.defaults.fallback) {
throw this.newMissingDefaultThemeError(platformName, hasUnicode3, hasColor2);
}
}
if (platform[hasUnicode3][hasColor2]) {
return this.getTheme(platform[hasUnicode3][hasColor2]);
} else {
return this.getDefault(Object.assign({}, opts, { platform: "fallback" }));
}
};
ThemeSetProto.newMissingThemeError = function newMissingThemeError(name) {
var err = new Error('Could not find a gauge theme named "' + name + '"');
Error.captureStackTrace.call(err, newMissingThemeError);
err.theme = name;
err.code = "EMISSINGTHEME";
return err;
};
ThemeSetProto.newMissingDefaultThemeError = function newMissingDefaultThemeError(platformName, hasUnicode3, hasColor2) {
var err = new Error(
"Could not find a gauge theme for your platform/unicode/color use combo:\n platform = " + platformName + "\n hasUnicode = " + hasUnicode3 + "\n hasColor = " + hasColor2
);
Error.captureStackTrace.call(err, newMissingDefaultThemeError);
err.platform = platformName;
err.hasUnicode = hasUnicode3;
err.hasColor = hasColor2;
err.code = "EMISSINGTHEME";
return err;
};
ThemeSetProto.newThemeSet = function() {
var themeset = function(opts) {
return themeset.getDefault(opts);
};
return Object.assign(themeset, ThemeSetProto, {
themes: Object.assign({}, this.themes),
baseTheme: Object.assign({}, this.baseTheme),
defaults: JSON.parse(JSON.stringify(this.defaults || {}))
});
};
}
});
// libs/core/src/lib/npmlog/gauge/themes.ts
var require_themes = __commonJS({
"libs/core/src/lib/npmlog/gauge/themes.ts"(exports2, module2) {
"use strict";
var color = require("console-control-strings").color;
var ThemeSet = require_theme_set();
var themes = module2.exports = new ThemeSet();
themes.addTheme("ASCII", {
preProgressbar: "[",
postProgressbar: "]",
progressbarTheme: {
complete: "#",
remaining: "."
},
activityIndicatorTheme: "-\\|/",
preSubsection: ">"
});
themes.addTheme("colorASCII", themes.getTheme("ASCII"), {
progressbarTheme: {
preComplete: color("bgBrightWhite", "brightWhite"),
complete: "#",
postComplete: color("reset"),
preRemaining: color("bgBrightBlack", "brightBlack"),
remaining: ".",
postRemaining: color("reset")
}
});
themes.addTheme("brailleSpinner", {
preProgressbar: "(",
postProgressbar: ")",
progressbarTheme: {
complete: "#",
remaining: "\u2802"
},
activityIndicatorTheme: "\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F",
preSubsection: ">"
});
themes.addTheme("colorBrailleSpinner", themes.getTheme("brailleSpinner"), {
progressbarTheme: {
preComplete: color("bgBrightWhite", "brightWhite"),
complete: "#",
postComplete: color("reset"),
preRemaining: color("bgBrightBlack", "brightBlack"),
remaining: "\u2802",
postRemaining: color("reset")
}
});
themes.setDefault({}, "ASCII");
themes.setDefault({ hasColor: true }, "colorASCII");
themes.setDefault({ platform: "darwin", hasUnicode: true }, "brailleSpinner");
themes.setDefault({ platform: "darwin", hasUnicode: true, hasColor: true }, "colorBrailleSpinner");
themes.setDefault({ platform: "linux", hasUnicode: true }, "brailleSpinner");
themes.setDefault({ platform: "linux", hasUnicode: true, hasColor: true }, "colorBrailleSpinner");
}
});
// libs/core/src/lib/npmlog/gauge/set-interval.ts
var require_set_interval = __commonJS({
"libs/core/src/lib/npmlog/gauge/set-interval.ts"(exports2, module2) {
"use strict";
module2.exports = setInterval;
}
});
// libs/core/src/lib/npmlog/gauge/process.ts
var require_process = __commonJS({
"libs/core/src/lib/npmlog/gauge/process.ts"(exports2, module2) {
"use strict";
module2.exports = process;
}
});
// libs/core/src/lib/npmlog/gauge/set-immediate.ts
var require_set_immediate = __commonJS({
"libs/core/src/lib/npmlog/gauge/set-immediate.ts"(exports2, module2) {
"use strict";
var process3 = require_process();
try {
module2.exports = setImmediate;
} catch (ex) {
module2.exports = process3.nextTick;
}
}
});
// libs/core/src/lib/npmlog/gauge/index.ts
function callWith(obj, method) {
return function() {
return method.call(obj);
};
}
var import_signal_exit, hasUnicode, Plumbing, hasColor, defaultThemes, setInterval2, process2, setImmediate2, Gauge;
var init_gauge = __esm({
"libs/core/src/lib/npmlog/gauge/index.ts"() {
"use strict";
import_signal_exit = __toESM(require("signal-exit"));
hasUnicode = require("has-unicode");
Plumbing = require_plumbing();
hasColor = require_has_color();
defaultThemes = require_themes();
setInterval2 = require_set_interval();
process2 = require_process();
setImmediate2 = require_set_immediate();
Gauge = class {
constructor(arg1, arg2) {
let options, writeTo;
if (arg1 && arg1.write) {
writeTo = arg1;
options = arg2 || {};
} else if (arg2 && arg2.write) {
writeTo = arg2;
options = arg1 || {};
} else {
writeTo = process2.stderr;
options = arg1 || arg2 || {};
}
this._status = {
spun: 0,
section: "",
subsection: ""
};
this._paused = false;
this._disabled = true;
this._showing = false;
this._onScreen = false;
this._needsRedraw = false;
this._hideCursor = options.hideCursor == null ? true : options.hideCursor;
this._fixedFramerate = options.fixedFramerate == null ? !/^v0\.8\./.test(process2.version) : options.fixedFramerate;
this._lastUpdateAt = null;
this._updateInterval = options.updateInterval == null ? 50 : options.updateInterval;
this._themes = options.themes || defaultThemes;
this._theme = options.theme;
const theme = this._computeTheme(options.theme);
const template = options.template || [
{ type: "progressbar", length: 20 },
{ type: "activityIndicator", kerning: 1, length: 1 },
{ type: "section", kerning: 1, default: "" },
{ type: "subsection", kerning: 1, default: "" }
];
this.setWriteTo(writeTo, options.tty);
const PlumbingClass = options.Plumbing || Plumbing;
this._gauge = new PlumbingClass(theme, template, this.getWidth());
this._$$doRedraw = callWith(this, this._doRedraw);
this._$$handleSizeChange = callWith(this, this._handleSizeChange);
this._cleanupOnExit = options.cleanupOnExit == null || options.cleanupOnExit;
this._removeOnExit = null;
if (options.enabled || options.enabled == null && this._tty && this._tty.isTTY) {
this.enable();
} else {
this.disable();
}
}
isEnabled() {
return !this._disabled;
}
setTemplate(template) {
this._gauge.setTemplate(template);
if (this._showing) {
this._requestRedraw();
}
}
_computeTheme(theme) {
if (!theme) {
theme = {};
}
if (typeof theme === "string") {
theme = this._themes.getTheme(theme);
} else if (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null) {
const useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode;
const useColor = theme.hasColor == null ? hasColor : theme.hasColor;
theme = this._themes.getDefault({
hasUnicode: useUnicode,
hasColor: useColor,
platform: theme.platform
});
}
return theme;
}
setThemeset(themes) {
this._themes = themes;
this.setTheme(this._theme);
}
setTheme(theme) {
this._gauge.setTheme(this._computeTheme(theme));
if (this._showing) {
this._requestRedraw();
}
this._theme = theme;
}
_requestRedraw() {
this._needsRedraw = true;
if (!this._fixedFramerate) {
this._doRedraw();
}
}
getWidth() {
return (this._tty && this._tty.columns || 80) - 1;
}
setWriteTo(writeTo, tty) {
const enabled = !this._disabled;
if (enabled) {
this.disable();
}
this._writeTo = writeTo;
this._tty = tty || writeTo === process2.stderr && process2.stdout.isTTY && process2.stdout || writeTo.isTTY && writeTo || this._tty;
if (this._gauge) {
this._gauge.setWidth(this.getWidth());
}
if (enabled) {
this.enable();
}
}
enable() {
if (!this._disabled) {
return;
}
this._disabled = false;
if (this._tty) {
this._enableEvents();
}
if (this._showing) {
this.show();
}
}
disable() {
if (this._disabled) {
return;
}
if (this._showing) {
this._lastUpdateAt = null;
this._showing = false;
this._doRedraw();
this._showing = true;
}
this._disabled = true;
if (this._tty) {
this._disableEvents();
}
}
_enableEvents() {
if (this._cleanupOnExit) {
this._removeOnExit = (0, import_signal_exit.default)(callWith(this, this.disable));
}
this._tty.on("resize", this._$$handleSizeChange);
if (this._fixedFramerate) {
this.redrawTracker = setInterval2(this._$$doRedraw, this._updateInterval);
if (this.redrawTracker.unref) {
this.redrawTracker.unref();
}
}
}
_disableEvents() {
this._tty.removeListener("resize", this._$$handleSizeChange);
if (this._fixedFramerate) {
clearInterval(this.redrawTracker);
}
if (this._removeOnExit) {
this._removeOnExit();
}
}
hide(cb) {
if (this._disabled) {
return cb && process2.nextTick(cb);
}
if (!this._showing) {
return cb && process2.nextTick(cb);
}
this._showing = false;
this._doRedraw();
cb && setImmediate2(cb);
}
show(section, completed) {
this._showing = true;
if (typeof section === "string") {
this._status.section = section;
} else if (typeof section === "object") {
const sectionKeys = Object.keys(section);
for (let ii = 0; ii < sectionKeys.length; ++ii) {
const key = sectionKeys[ii];
this._status[key] = section[key];
}
}
if (completed != null) {
this._status.completed = completed;
}
if (this._disabled) {
return;
}
this._requestRedraw();
}
pulse(subsection) {
this._status.subsection = subsection || "";
this._status.spun++;
if (this._disabled) {
return;
}
if (!this._showing) {
return;
}
this._requestRedraw();
}
_handleSizeChange() {
this._gauge.setWidth(this._tty.columns - 1);
this._requestRedraw();
}
_doRedraw() {
if (this._disabled || this._paused) {
return;
}
if (!this._fixedFramerate) {
const now = Date.now();
if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) {
return;
}
this._lastUpdateAt = now;
}
if (!this._showing && this._onScreen) {
this._onScreen = false;
let result = this._gauge.hide();
if (this._hideCursor) {
result += this._gauge.showCursor();
}
return this._writeTo.write(result);
}
if (!this._showing && !this._onScreen) {
return;
}
if (this._showing && !this._onScreen) {
this._onScreen = true;
this._needsRedraw = true;
if (this._hideCursor) {
this._writeTo.write(this._gauge.hideCursor());
}
}
if (!this._needsRedraw) {
return;
}
if (!this._writeTo.write(this._gauge.show(this._status))) {
this._paused = true;
this._writeTo.on(
"drain",
callWith(this, function() {
this._paused = false;
this._doRedraw();
})
);
}
}
};
}
});
// libs/core/src/lib/npmlog/index.ts
var import_node_events2, import_node_util, setBlocking, consoleControl, Logger, log, trackerConstructors, mixinLog, npmlog_default;
var init_npmlog = __esm({
"libs/core/src/lib/npmlog/index.ts"() {
"use strict";
import_node_events2 = require("node:events");
import_node_util = __toESM(require("node:util"));
init_tracker_group();
init_gauge();
setBlocking = require("set-blocking");
consoleControl = require("console-control-strings");
setBlocking(true);
Logger = class extends import_node_events2.EventEmitter {
constructor() {
super();
this._stream = process.stderr;
this._paused = false;
this._buffer = [];
this.unicodeEnabled = false;
this.colorEnabled = void 0;
this.id = 0;
this.record = [];
this.maxRecordSize = 1e4;
this.level = "info";
this.prefixStyle = { fg: "magenta" };
this.headingStyle = { fg: "white", bg: "black" };
this.style = {};
this.levels = {};
this.disp = {};
this.gauge = new Gauge(this._stream, {
enabled: false,
theme: { hasColor: this.useColor() },
template: [
{ type: "progressbar", length: 20 },
{ type: "activityIndicator", kerning: 1, length: 1 },
{ type: "section", default: "" },
":",
{ type: "logline", kerning: 1, default: "" }
]
});
this.tracker = new TrackerGroup();
this.progressEnabled = this.gauge.isEnabled();
this.addLevel("silly", -Infinity, { inverse: true }, "sill");
this.addLevel("verbose", 1e3, { fg: "cyan", bg: "black" }, "verb");
this.addLevel("info", 2e3, { fg: "green" });
this.addLevel("timing", 2500, { fg: "green", bg: "black" });
this.addLevel("http", 3e3, { fg: "green", bg: "black" });
this.addLevel("notice", 3500, { fg: "cyan", bg: "black" });
this.addLevel("warn", 4e3, { fg: "black", bg: "yellow" }, "WARN");
this.addLevel("error", 5e3, { fg: "red", bg: "black" }, "ERR!");
this.addLevel("silent", Infinity);
this.on("error", () => {
});
}
get stream() {
return this._stream;
}
set stream(newStream) {
this._stream = newStream;
if (this.gauge) {
this.gauge.setWriteTo(this._stream, this._stream);
}
}
useColor() {
return this.colorEnabled != null ? this.colorEnabled : this._stream?.isTTY ?? false;
}
enableColor() {
this.colorEnabled = true;
this.gauge.setTheme({ hasColor: this.colorEnabled, hasUnicode: this.unicodeEnabled });
}
disableColor() {
this.colorEnabled = false;
this.gauge.setTheme({ hasColor: this.colorEnabled, hasUnicode: this.unicodeEnabled });
}
enableUnicode() {
this.unicodeEnabled = true;
this.gauge.setTheme({ hasColor: this.useColor(), hasUnicode: this.unicodeEnabled });
}
disableUnicode() {
this.unicodeEnabled = false;
this.gauge.setTheme({ hasColor: this.useColor(), hasUnicode: this.unicodeEnabled });
}
setGaugeThemeset(themes) {
this.gauge.setThemeset(themes);
}
setGaugeTemplate(template) {
this.gauge.setTemplate(template);
}
enableProgress() {
if (this.progressEnabled || this._paused) {
return;
}
this.progressEnabled = true;
this.tracker.on("change", this.showProgress.bind(this));
this.gauge.enable();
}
disableProgress() {
if (!this.progressEnabled) {
return;
}
this.progressEnabled = false;
this.tracker.removeListener("change", this.showProgress.bind(this));
this.gauge.disable();
}
clearProgress(cb) {
if (!this.progressEnabled) {
return cb && process.nextTick(cb);
}
this.gauge.hide(cb);
}
showProgress(name, completed) {
if (!this.progressEnabled) {
return;
}
const values = {};
if (name) {
values.section = name;
}
const last = this.record[this.record.length - 1];
if (last) {
values.subsection = last.prefix;
const disp = this.disp[last.level];
let logline = this._format(disp, this.style[last.level]);
if (last.prefix) {
logline += " " + this._format(last.prefix, this.prefixStyle);
}
logline += " " + last.message.split(/\r?\n/)[0];
values.logline = logline;
}
values.completed = completed || this.tracker.completed();
this.gauge.show(values);
}
pause() {
this._paused = true;
if (this.progressEnabled) {
this.gauge.disable();
}
}
resume() {
if (!this._paused) {
return;
}
this._paused = false;
const buffer = this._buffer;
this._buffer = [];
buffer.forEach((m) => this.emitLog(m));
if (this.progressEnabled) {
this.gauge.enable();
}
}
log(lvl, prefix, ...messageArgs) {
const l = this.levels[lvl];
if (l === void 0) {
this.emit("error", new Error(import_node_util.default.format("Undefined log level: %j", lvl)));
return;
}
let stack = null;
const a = messageArgs.map((arg) => {
if (arg instanceof Error && arg.stack) {
Object.defineProperty(arg, "stack", {
value: stack = arg.stack + "",
enumerable: true,
writable: true
});
}
return arg;
});
if (stack) {
a.unshift(stack + "\n");
}
const message = import_node_util.default.format(...a);
const m = {
id: this.id++,
level: lvl,
prefix: String(prefix || ""),
message,
messageRaw: a
};
this.emit("log", m);
this.emit(`log.${lvl}`, m);
if (m.prefix) {
this.emit(m.prefix, m);
}
this.record.push(m);
const mrs = this.maxRecordSize;
if (this.record.length > mrs) {
this.record = this.record.slice(-Math.floor(mrs * 0.9));
}
this.emitLog(m);
}
emitLog(m) {
if (this._paused) {
this._buffer.push(m);
return;
}
if (this.progressEnabled) {
this.gauge.pulse(m.prefix);
}
const l = this.levels[m.level];
if (l === void 0 || l < this.levels[this.level] || l > 0 && !isFinite(l)) {
return;
}
const disp = this.disp[m.level];
this.clearProgress();
m.message?.split(/\r?\n/).forEach((line) => {
const heading = this.heading;
if (heading) {
this.write(heading, this.headingStyle);
this.write(" ");
}
this.write(disp, this.style[m.level]);
const p = m.prefix || "";
if (p) {
this.write(" ");
}
this.write(p, this.prefixStyle);
this.write(" " + line + "\n");
});
this.showProgress();
}
_format(msg, style) {
if (!this._stream) {
return;
}
let output2 = "";
if (this.useColor()) {
style = style || {};
const settings = [];
if (style.fg) settings.push(style.fg);
if (style.bg) settings.push("bg" + style.bg[0].toUpperCase() + style.bg.slice(1));
if (style.bold) settings.push("bold");
if (style.underline) settings.push("underline");
if (style.inverse) settings.push("inverse");
if (settings.length) output2 += consoleControl.color(settings);
if (style.beep) output2 += consoleControl.beep();
}
output2 += msg;
if (this.useColor()) output2 += consoleControl.color("reset");
return output2;
}
write(msg, style) {
if (!this._stream) {
return;
}
this._stream.write(this._format(msg, style));
}
addLevel(lvl, n, style, disp = null) {
if (disp == null) {
disp = lvl;
}
this.levels[lvl] = n;
this.style[lvl] = style;
if (!this[lvl]) {
this[lvl] = (...args) => {
const a = [lvl, ...args];
return this.log.apply(this, a);
};
}
this.disp[lvl] = disp;
}
};
log = new Logger();
trackerConstructors = ["newGroup", "newItem", "newStream"];
mixinLog = function(tracker) {
Array.from(
/* @__PURE__ */ new Set([...Object.keys(log), ...Object.getOwnPropertyNames(Object.getPrototypeOf(log))])
).forEach(function(P) {
if (P[0] === "_") {
return;
}
if (trackerConstructors.filter(