@flyingboat/upup 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +84 -33
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -60,6 +60,31 @@ const yellow = (t) => wrap(t, codes.yellow);
|
|
|
60
60
|
const gray = (t) => wrap(t, codes.gray);
|
|
61
61
|
const bold = (t) => wrap(t, codes.bold);
|
|
62
62
|
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/cli-compact.ts
|
|
65
|
+
function renderCompact(rows) {
|
|
66
|
+
console.log(compact$1(rows).join("\n"));
|
|
67
|
+
}
|
|
68
|
+
function compact$1(rows) {
|
|
69
|
+
const content = [];
|
|
70
|
+
for (const row of rows) {
|
|
71
|
+
content.push(...block(row));
|
|
72
|
+
content.push("");
|
|
73
|
+
}
|
|
74
|
+
return content;
|
|
75
|
+
}
|
|
76
|
+
function block(row) {
|
|
77
|
+
const content = [];
|
|
78
|
+
let status = row.status;
|
|
79
|
+
if (status === "need update") status = yellow(status);
|
|
80
|
+
else if (status === "ok") status = green(status);
|
|
81
|
+
content.push(`[${bold(row.package)}]`);
|
|
82
|
+
content.push(` status: ${status}`);
|
|
83
|
+
content.push(` current: ${row.current} (${row.age} ago)`);
|
|
84
|
+
if (row.status === "need update") content.push(` latest: ${row.latest} (${row.latestAge} ago) change: ${row.change}`);
|
|
85
|
+
return content;
|
|
86
|
+
}
|
|
87
|
+
|
|
63
88
|
//#endregion
|
|
64
89
|
//#region src/cli-table.ts
|
|
65
90
|
const leftTopCorner = "┌";
|
|
@@ -1625,7 +1650,6 @@ function getBump(current, latest) {
|
|
|
1625
1650
|
|
|
1626
1651
|
//#endregion
|
|
1627
1652
|
//#region src/cli.ts
|
|
1628
|
-
const defaultRefreshInterval = 80;
|
|
1629
1653
|
const spinnerFrames = [
|
|
1630
1654
|
"⠋",
|
|
1631
1655
|
"⠙",
|
|
@@ -1638,6 +1662,7 @@ const spinnerFrames = [
|
|
|
1638
1662
|
"⠇",
|
|
1639
1663
|
"⠏"
|
|
1640
1664
|
];
|
|
1665
|
+
const defaultCtx = { refreshInterval: 80 };
|
|
1641
1666
|
var Renderer = class {
|
|
1642
1667
|
_renderFn;
|
|
1643
1668
|
constructor(renderFn) {
|
|
@@ -1647,38 +1672,58 @@ var Renderer = class {
|
|
|
1647
1672
|
this._renderFn(props);
|
|
1648
1673
|
}
|
|
1649
1674
|
};
|
|
1650
|
-
function spinner(
|
|
1651
|
-
return spinnerFrames[Math.floor(Date.now() / refreshInterval) % spinnerFrames.length];
|
|
1675
|
+
function spinner(ctx) {
|
|
1676
|
+
return spinnerFrames[Math.floor(Date.now() / ctx.refreshInterval) % spinnerFrames.length];
|
|
1652
1677
|
}
|
|
1653
|
-
function
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
latestAge,
|
|
1670
|
-
status,
|
|
1671
|
-
change
|
|
1672
|
-
};
|
|
1678
|
+
function parseRow(r, ctx) {
|
|
1679
|
+
if (r.status === "error") console.error(`Failed to fetch ${r.dep.name}`);
|
|
1680
|
+
let age = r.dep.versionValid ? "-" : "invalid version";
|
|
1681
|
+
if (!r.dep.localDep && r.dep.versionValid) age = r.dep.versionAge ? timeAgoFromAge(r.dep.versionAge) : spinner(ctx);
|
|
1682
|
+
let latestAge = r.dep.localDep ? "-" : spinner(ctx);
|
|
1683
|
+
if (!r.dep.localDep && r.dep.latestVersionAge) latestAge = timeAgoFromAge(r.dep.latestVersionAge);
|
|
1684
|
+
const status = r.status === "pending" ? spinner(ctx) : r.status === "done" && r.needUpdate ? "need update" : "ok";
|
|
1685
|
+
const change = r.needUpdate ? getBump(r.dep.version, r.dep.latestVersion ?? "") : "-";
|
|
1686
|
+
return {
|
|
1687
|
+
package: r.dep.name,
|
|
1688
|
+
current: r.dep.version,
|
|
1689
|
+
age,
|
|
1690
|
+
latest: r.dep.latestVersion ?? spinner(ctx),
|
|
1691
|
+
latestAge,
|
|
1692
|
+
status,
|
|
1693
|
+
change
|
|
1673
1694
|
};
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1695
|
+
}
|
|
1696
|
+
function unwrap(rows, ctx) {
|
|
1697
|
+
return {
|
|
1698
|
+
deps: rows.filter((x) => x.dep.type === "dep").map((r) => parseRow(r, ctx)),
|
|
1699
|
+
devDeps: rows.filter((x) => x.dep.type === "devDep").map((r) => parseRow(r, ctx))
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
function pluralDependency(n) {
|
|
1703
|
+
return `${n} Dependenc${n === 1 ? "y" : "ies"}`;
|
|
1704
|
+
}
|
|
1705
|
+
function renderDepsCompact(rows, ctx) {
|
|
1706
|
+
const { deps, devDeps } = unwrap(rows, ctx);
|
|
1707
|
+
if (deps.length > 0) {
|
|
1708
|
+
console.log(`${pluralDependency(deps.length)}\n`);
|
|
1709
|
+
renderCompact(deps);
|
|
1677
1710
|
}
|
|
1678
|
-
if (
|
|
1679
|
-
if (
|
|
1680
|
-
console.log(`${
|
|
1681
|
-
|
|
1711
|
+
if (devDeps.length > 0) {
|
|
1712
|
+
if (deps.length > 0) console.log("");
|
|
1713
|
+
console.log(`${pluralDependency(devDeps.length)}\n`);
|
|
1714
|
+
renderCompact(devDeps);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
function renderDepsTable(rows, ctx) {
|
|
1718
|
+
const { deps, devDeps } = unwrap(rows, ctx);
|
|
1719
|
+
if (deps.length > 0) {
|
|
1720
|
+
console.log(`${pluralDependency(deps.length)}\n`);
|
|
1721
|
+
renderTable(deps);
|
|
1722
|
+
}
|
|
1723
|
+
if (devDeps.length > 0) {
|
|
1724
|
+
if (deps.length > 0) console.log("");
|
|
1725
|
+
console.log(`${pluralDependency(devDeps.length)}\n`);
|
|
1726
|
+
renderTable(devDeps);
|
|
1682
1727
|
}
|
|
1683
1728
|
}
|
|
1684
1729
|
|
|
@@ -1744,17 +1789,23 @@ if (!process$1 || !process$1.argv) {
|
|
|
1744
1789
|
}
|
|
1745
1790
|
let args = process$1.argv;
|
|
1746
1791
|
args = args.slice(2);
|
|
1792
|
+
let compact = false;
|
|
1747
1793
|
let ci = false;
|
|
1748
1794
|
let cwd = process$1.cwd();
|
|
1749
1795
|
if (args.length > 0) for (const arg of args) if (arg.startsWith("--")) {
|
|
1750
1796
|
if (arg === "--ci") ci = true;
|
|
1797
|
+
else if (arg === "--compact") compact = true;
|
|
1751
1798
|
} else cwd = args[0];
|
|
1752
|
-
const
|
|
1799
|
+
const ctx = defaultCtx;
|
|
1753
1800
|
async function run() {
|
|
1754
1801
|
console.log("Checking for packages updates ...\n");
|
|
1755
1802
|
const renderer = new Renderer((props) => {
|
|
1756
1803
|
if (!ci) console.clear();
|
|
1757
|
-
|
|
1804
|
+
if (compact) {
|
|
1805
|
+
renderDepsCompact(props.deps, ctx);
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
renderDepsTable(props.deps, ctx);
|
|
1758
1809
|
});
|
|
1759
1810
|
const pkgFile = `${cwd}/package.json`;
|
|
1760
1811
|
if (!fs.existsSync(pkgFile)) {
|
|
@@ -1766,7 +1817,7 @@ async function run() {
|
|
|
1766
1817
|
needUpdate: false,
|
|
1767
1818
|
status: "pending"
|
|
1768
1819
|
})) };
|
|
1769
|
-
const ticker = ci ? null : setInterval(() => renderer.render(props), refreshInterval);
|
|
1820
|
+
const ticker = ci ? null : setInterval(() => renderer.render(props), ctx.refreshInterval);
|
|
1770
1821
|
const tasks = props.deps.map(async (row) => {
|
|
1771
1822
|
try {
|
|
1772
1823
|
if (row.dep.localDep) {
|