@attest-it/cli 0.2.0 → 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/README.md +8 -4
- package/dist/bin/attest-it.js +39 -4
- package/dist/bin/attest-it.js.map +1 -1
- package/dist/index.cjs +38 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
3
4
|
import * as path from 'path';
|
|
4
5
|
import { join, dirname } from 'path';
|
|
5
6
|
import { detectTheme } from 'chromaterm';
|
|
@@ -12,6 +13,7 @@ import * as React7 from 'react';
|
|
|
12
13
|
import { render, useApp, Box, Text, useInput } from 'ink';
|
|
13
14
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
15
|
import { readFile, unlink, mkdir, writeFile } from 'fs/promises';
|
|
16
|
+
import { fileURLToPath } from 'url';
|
|
15
17
|
|
|
16
18
|
// src/index.ts
|
|
17
19
|
var globalOptions = {};
|
|
@@ -1604,10 +1606,39 @@ function hasWarnings(result, maxAgeDays) {
|
|
|
1604
1606
|
(s) => s.status === "VALID" && (s.age ?? 0) > maxAgeDays - warningThreshold
|
|
1605
1607
|
);
|
|
1606
1608
|
}
|
|
1607
|
-
|
|
1608
|
-
//
|
|
1609
|
+
function hasVersion(data) {
|
|
1610
|
+
return typeof data === "object" && data !== null && "version" in data && // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1611
|
+
typeof data.version === "string";
|
|
1612
|
+
}
|
|
1613
|
+
var cachedVersion;
|
|
1614
|
+
function getPackageVersion() {
|
|
1615
|
+
if (cachedVersion !== void 0) {
|
|
1616
|
+
return cachedVersion;
|
|
1617
|
+
}
|
|
1618
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
1619
|
+
const __dirname = dirname(__filename);
|
|
1620
|
+
const possiblePaths = [join(__dirname, "../package.json"), join(__dirname, "../../package.json")];
|
|
1621
|
+
for (const packageJsonPath of possiblePaths) {
|
|
1622
|
+
try {
|
|
1623
|
+
const content = readFileSync(packageJsonPath, "utf-8");
|
|
1624
|
+
const packageJsonData = JSON.parse(content);
|
|
1625
|
+
if (!hasVersion(packageJsonData)) {
|
|
1626
|
+
throw new Error(`Invalid package.json at ${packageJsonPath}: missing version field`);
|
|
1627
|
+
}
|
|
1628
|
+
cachedVersion = packageJsonData.version;
|
|
1629
|
+
return cachedVersion;
|
|
1630
|
+
} catch (error2) {
|
|
1631
|
+
if (error2 instanceof Error && "code" in error2 && error2.code === "ENOENT") {
|
|
1632
|
+
continue;
|
|
1633
|
+
}
|
|
1634
|
+
throw error2;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
throw new Error("Could not find package.json");
|
|
1638
|
+
}
|
|
1609
1639
|
var program = new Command();
|
|
1610
|
-
program.name("attest-it").description("Human-gated test attestation system").
|
|
1640
|
+
program.name("attest-it").description("Human-gated test attestation system").option("-c, --config <path>", "Path to config file").option("-v, --verbose", "Verbose output").option("-q, --quiet", "Minimal output");
|
|
1641
|
+
program.option("-V, --version", "output the version number");
|
|
1611
1642
|
program.addCommand(initCommand);
|
|
1612
1643
|
program.addCommand(statusCommand);
|
|
1613
1644
|
program.addCommand(runCommand);
|
|
@@ -1615,6 +1646,10 @@ program.addCommand(keygenCommand);
|
|
|
1615
1646
|
program.addCommand(pruneCommand);
|
|
1616
1647
|
program.addCommand(verifyCommand);
|
|
1617
1648
|
async function run() {
|
|
1649
|
+
if (process.argv.includes("--version") || process.argv.includes("-V")) {
|
|
1650
|
+
console.log(getPackageVersion());
|
|
1651
|
+
process.exit(0);
|
|
1652
|
+
}
|
|
1618
1653
|
await initTheme();
|
|
1619
1654
|
program.parse();
|
|
1620
1655
|
const options = program.opts();
|