@flyingboat/upup 0.3.0 → 0.4.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/README.md +4 -4
- package/dist/bundle.js +73 -37
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -23,8 +23,8 @@ Run in the current project:
|
|
|
23
23
|
upup
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
## Flags
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
- `--ci`: Run in CI mode, disabling animations
|
|
29
|
+
- `--compact`: Render the result in a compact format
|
|
30
|
+
- `--export-to-file`: Export the result to a file instead of printing it to stdout
|
package/dist/bundle.js
CHANGED
|
@@ -59,13 +59,16 @@ const green = (t) => wrap(t, codes.green);
|
|
|
59
59
|
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
|
+
function clearColor(t) {
|
|
63
|
+
return t.replace(/\x1b\[[0-9;]*m/g, "");
|
|
64
|
+
}
|
|
62
65
|
|
|
63
66
|
//#endregion
|
|
64
67
|
//#region src/cli-compact.ts
|
|
65
|
-
function renderCompact(rows) {
|
|
66
|
-
console.log(compact
|
|
68
|
+
function renderCompact(rows, ctx) {
|
|
69
|
+
ctx.console.log(compact(rows).join("\n"));
|
|
67
70
|
}
|
|
68
|
-
function compact
|
|
71
|
+
function compact(rows) {
|
|
69
72
|
const content = [];
|
|
70
73
|
for (const row of rows) {
|
|
71
74
|
content.push(...block(row));
|
|
@@ -95,8 +98,8 @@ const leftMiddleCorner = "├";
|
|
|
95
98
|
const rightMiddleCorner = "┤";
|
|
96
99
|
const horizontal = "─";
|
|
97
100
|
const vertical = "│";
|
|
98
|
-
function renderTable(rows) {
|
|
99
|
-
console.log(table(rows).join("\n"));
|
|
101
|
+
function renderTable(rows, ctx) {
|
|
102
|
+
ctx.console.log(table(rows).join("\n"));
|
|
100
103
|
}
|
|
101
104
|
function table(rows) {
|
|
102
105
|
const content = [];
|
|
@@ -1662,7 +1665,6 @@ const spinnerFrames = [
|
|
|
1662
1665
|
"⠇",
|
|
1663
1666
|
"⠏"
|
|
1664
1667
|
];
|
|
1665
|
-
const defaultCtx = { refreshInterval: 80 };
|
|
1666
1668
|
var Renderer = class {
|
|
1667
1669
|
_renderFn;
|
|
1668
1670
|
constructor(renderFn) {
|
|
@@ -1676,7 +1678,7 @@ function spinner(ctx) {
|
|
|
1676
1678
|
return spinnerFrames[Math.floor(Date.now() / ctx.refreshInterval) % spinnerFrames.length];
|
|
1677
1679
|
}
|
|
1678
1680
|
function parseRow(r, ctx) {
|
|
1679
|
-
if (r.status === "error") console.error(`Failed to fetch ${r.dep.name}`);
|
|
1681
|
+
if (r.status === "error") ctx.console.error(`Failed to fetch ${r.dep.name}`);
|
|
1680
1682
|
let age = r.dep.versionValid ? "-" : "invalid version";
|
|
1681
1683
|
if (!r.dep.localDep && r.dep.versionValid) age = r.dep.versionAge ? timeAgoFromAge(r.dep.versionAge) : spinner(ctx);
|
|
1682
1684
|
let latestAge = r.dep.localDep ? "-" : spinner(ctx);
|
|
@@ -1705,28 +1707,53 @@ function pluralDependency(n) {
|
|
|
1705
1707
|
function renderDepsCompact(rows, ctx) {
|
|
1706
1708
|
const { deps, devDeps } = unwrap(rows, ctx);
|
|
1707
1709
|
if (deps.length > 0) {
|
|
1708
|
-
console.log(`${pluralDependency(deps.length)}\n`);
|
|
1709
|
-
renderCompact(deps);
|
|
1710
|
+
ctx.console.log(`${pluralDependency(deps.length)}\n`);
|
|
1711
|
+
renderCompact(deps, ctx);
|
|
1710
1712
|
}
|
|
1711
1713
|
if (devDeps.length > 0) {
|
|
1712
|
-
if (deps.length > 0) console.log("");
|
|
1713
|
-
console.log(`${pluralDependency(devDeps.length)}\n`);
|
|
1714
|
-
renderCompact(devDeps);
|
|
1714
|
+
if (deps.length > 0) ctx.console.log("");
|
|
1715
|
+
ctx.console.log(`${pluralDependency(devDeps.length)}\n`);
|
|
1716
|
+
renderCompact(devDeps, ctx);
|
|
1715
1717
|
}
|
|
1716
1718
|
}
|
|
1717
1719
|
function renderDepsTable(rows, ctx) {
|
|
1718
1720
|
const { deps, devDeps } = unwrap(rows, ctx);
|
|
1719
1721
|
if (deps.length > 0) {
|
|
1720
|
-
console.log(`${pluralDependency(deps.length)}\n`);
|
|
1721
|
-
renderTable(deps);
|
|
1722
|
+
ctx.console.log(`${pluralDependency(deps.length)}\n`);
|
|
1723
|
+
renderTable(deps, ctx);
|
|
1722
1724
|
}
|
|
1723
1725
|
if (devDeps.length > 0) {
|
|
1724
|
-
if (deps.length > 0) console.log("");
|
|
1725
|
-
console.log(`${pluralDependency(devDeps.length)}\n`);
|
|
1726
|
-
renderTable(devDeps);
|
|
1726
|
+
if (deps.length > 0) ctx.console.log("");
|
|
1727
|
+
ctx.console.log(`${pluralDependency(devDeps.length)}\n`);
|
|
1728
|
+
renderTable(devDeps, ctx);
|
|
1727
1729
|
}
|
|
1728
1730
|
}
|
|
1729
1731
|
|
|
1732
|
+
//#endregion
|
|
1733
|
+
//#region src/console.ts
|
|
1734
|
+
var CliOutput = class {
|
|
1735
|
+
error(...message) {
|
|
1736
|
+
console.error(...message);
|
|
1737
|
+
}
|
|
1738
|
+
log(...message) {
|
|
1739
|
+
console.log(...message);
|
|
1740
|
+
}
|
|
1741
|
+
};
|
|
1742
|
+
var FileOutput = class {
|
|
1743
|
+
content = [];
|
|
1744
|
+
error(...message) {
|
|
1745
|
+
this.content.push(...message);
|
|
1746
|
+
}
|
|
1747
|
+
log(...message) {
|
|
1748
|
+
this.content.push(...message);
|
|
1749
|
+
}
|
|
1750
|
+
saveTo(filePath) {
|
|
1751
|
+
this.content = this.content.map((l) => clearColor(l));
|
|
1752
|
+
const header = `Upup report generated on ${(/* @__PURE__ */ new Date()).toISOString()}\n\n`;
|
|
1753
|
+
fs.writeFileSync(filePath, `${header}${this.content.join("\n")}`);
|
|
1754
|
+
}
|
|
1755
|
+
};
|
|
1756
|
+
|
|
1730
1757
|
//#endregion
|
|
1731
1758
|
//#region src/npm.ts
|
|
1732
1759
|
function getPackageJson(packageJsonPath) {
|
|
@@ -1787,26 +1814,23 @@ if (!process$1 || !process$1.argv) {
|
|
|
1787
1814
|
console.log("no process");
|
|
1788
1815
|
process$1.exit(1);
|
|
1789
1816
|
}
|
|
1790
|
-
let args = process$1.argv;
|
|
1791
|
-
args = args.slice(2);
|
|
1792
|
-
let compact = false;
|
|
1793
|
-
let ci = false;
|
|
1794
|
-
let cwd = process$1.cwd();
|
|
1795
|
-
if (args.length > 0) for (const arg of args) if (arg.startsWith("--")) {
|
|
1796
|
-
if (arg === "--ci") ci = true;
|
|
1797
|
-
else if (arg === "--compact") compact = true;
|
|
1798
|
-
} else cwd = args[0];
|
|
1799
|
-
const ctx = defaultCtx;
|
|
1800
1817
|
async function run() {
|
|
1818
|
+
let args = process$1.argv;
|
|
1819
|
+
args = args.slice(2);
|
|
1820
|
+
let compact = false;
|
|
1821
|
+
let ci = false;
|
|
1822
|
+
let cwd = process$1.cwd();
|
|
1823
|
+
let outputType = "cli";
|
|
1824
|
+
if (args.length > 0) for (const arg of args) if (arg.startsWith("--")) {
|
|
1825
|
+
if (arg === "--ci") ci = true;
|
|
1826
|
+
else if (arg === "--compact") compact = true;
|
|
1827
|
+
else if (arg === "--export-to-file") outputType = "file";
|
|
1828
|
+
} else cwd = args[0];
|
|
1829
|
+
const ctx = {
|
|
1830
|
+
console: outputType === "cli" ? new CliOutput() : new FileOutput(),
|
|
1831
|
+
refreshInterval: 80
|
|
1832
|
+
};
|
|
1801
1833
|
console.log("Checking for packages updates ...\n");
|
|
1802
|
-
const renderer = new Renderer((props) => {
|
|
1803
|
-
if (!ci) console.clear();
|
|
1804
|
-
if (compact) {
|
|
1805
|
-
renderDepsCompact(props.deps, ctx);
|
|
1806
|
-
return;
|
|
1807
|
-
}
|
|
1808
|
-
renderDepsTable(props.deps, ctx);
|
|
1809
|
-
});
|
|
1810
1834
|
const pkgFile = `${cwd}/package.json`;
|
|
1811
1835
|
if (!fs.existsSync(pkgFile)) {
|
|
1812
1836
|
console.error(`package.json file not found at ${cwd}`);
|
|
@@ -1817,6 +1841,14 @@ async function run() {
|
|
|
1817
1841
|
needUpdate: false,
|
|
1818
1842
|
status: "pending"
|
|
1819
1843
|
})) };
|
|
1844
|
+
const renderer = new Renderer((props) => {
|
|
1845
|
+
if (!ci) console.clear();
|
|
1846
|
+
if (compact) {
|
|
1847
|
+
renderDepsCompact(props.deps, ctx);
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
renderDepsTable(props.deps, ctx);
|
|
1851
|
+
});
|
|
1820
1852
|
const ticker = ci ? null : setInterval(() => renderer.render(props), ctx.refreshInterval);
|
|
1821
1853
|
const tasks = props.deps.map(async (row) => {
|
|
1822
1854
|
try {
|
|
@@ -1842,8 +1874,12 @@ async function run() {
|
|
|
1842
1874
|
if (ticker) clearInterval(ticker);
|
|
1843
1875
|
renderer.render(props);
|
|
1844
1876
|
const nOutdated = props.deps.filter((x) => x.needUpdate).length;
|
|
1845
|
-
const nUpToDate = props.deps.
|
|
1846
|
-
console.log(`\n${yellow(`${nOutdated}`)} outdated, ${green(`${nUpToDate}`)} up to date`);
|
|
1877
|
+
const nUpToDate = props.deps.length - nOutdated;
|
|
1878
|
+
ctx.console.log(`\n${yellow(`${nOutdated}`)} outdated, ${green(`${nUpToDate}`)} up to date`);
|
|
1879
|
+
if ("saveTo" in ctx.console) {
|
|
1880
|
+
ctx.console.saveTo(".upup_report");
|
|
1881
|
+
console.log("Result saved to .upup_report");
|
|
1882
|
+
}
|
|
1847
1883
|
}
|
|
1848
1884
|
run().catch((err) => {
|
|
1849
1885
|
console.error(err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flyingboat/upup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "CLI tool for listing outdated dependencies",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Francois Lajoie",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@biomejs/biome": "^2.3.14",
|
|
32
|
-
"@types/node": "^25.2.
|
|
32
|
+
"@types/node": "^25.2.3",
|
|
33
33
|
"@types/semver": "^7.7.1",
|
|
34
|
-
"rolldown": "^1.0.0-rc.
|
|
34
|
+
"rolldown": "^1.0.0-rc.4",
|
|
35
35
|
"typescript": "~5.9.3",
|
|
36
36
|
"vitest": "^4.0.18"
|
|
37
37
|
}
|