@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.cjs
CHANGED
|
@@ -13,7 +13,9 @@ var React7 = require('react');
|
|
|
13
13
|
var ink = require('ink');
|
|
14
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
15
|
var promises = require('fs/promises');
|
|
16
|
+
var url = require('url');
|
|
16
17
|
|
|
18
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
17
19
|
function _interopNamespace(e) {
|
|
18
20
|
if (e && e.__esModule) return e;
|
|
19
21
|
var n = Object.create(null);
|
|
@@ -1628,10 +1630,39 @@ function hasWarnings(result, maxAgeDays) {
|
|
|
1628
1630
|
(s) => s.status === "VALID" && (s.age ?? 0) > maxAgeDays - warningThreshold
|
|
1629
1631
|
);
|
|
1630
1632
|
}
|
|
1631
|
-
|
|
1632
|
-
//
|
|
1633
|
+
function hasVersion(data) {
|
|
1634
|
+
return typeof data === "object" && data !== null && "version" in data && // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1635
|
+
typeof data.version === "string";
|
|
1636
|
+
}
|
|
1637
|
+
var cachedVersion;
|
|
1638
|
+
function getPackageVersion() {
|
|
1639
|
+
if (cachedVersion !== void 0) {
|
|
1640
|
+
return cachedVersion;
|
|
1641
|
+
}
|
|
1642
|
+
const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
1643
|
+
const __dirname = path.dirname(__filename);
|
|
1644
|
+
const possiblePaths = [path.join(__dirname, "../package.json"), path.join(__dirname, "../../package.json")];
|
|
1645
|
+
for (const packageJsonPath of possiblePaths) {
|
|
1646
|
+
try {
|
|
1647
|
+
const content = fs.readFileSync(packageJsonPath, "utf-8");
|
|
1648
|
+
const packageJsonData = JSON.parse(content);
|
|
1649
|
+
if (!hasVersion(packageJsonData)) {
|
|
1650
|
+
throw new Error(`Invalid package.json at ${packageJsonPath}: missing version field`);
|
|
1651
|
+
}
|
|
1652
|
+
cachedVersion = packageJsonData.version;
|
|
1653
|
+
return cachedVersion;
|
|
1654
|
+
} catch (error2) {
|
|
1655
|
+
if (error2 instanceof Error && "code" in error2 && error2.code === "ENOENT") {
|
|
1656
|
+
continue;
|
|
1657
|
+
}
|
|
1658
|
+
throw error2;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
throw new Error("Could not find package.json");
|
|
1662
|
+
}
|
|
1633
1663
|
var program = new commander.Command();
|
|
1634
|
-
program.name("attest-it").description("Human-gated test attestation system").
|
|
1664
|
+
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");
|
|
1665
|
+
program.option("-V, --version", "output the version number");
|
|
1635
1666
|
program.addCommand(initCommand);
|
|
1636
1667
|
program.addCommand(statusCommand);
|
|
1637
1668
|
program.addCommand(runCommand);
|
|
@@ -1639,6 +1670,10 @@ program.addCommand(keygenCommand);
|
|
|
1639
1670
|
program.addCommand(pruneCommand);
|
|
1640
1671
|
program.addCommand(verifyCommand);
|
|
1641
1672
|
async function run() {
|
|
1673
|
+
if (process.argv.includes("--version") || process.argv.includes("-V")) {
|
|
1674
|
+
console.log(getPackageVersion());
|
|
1675
|
+
process.exit(0);
|
|
1676
|
+
}
|
|
1642
1677
|
await initTheme();
|
|
1643
1678
|
program.parse();
|
|
1644
1679
|
const options = program.opts();
|