@aduh95/caritat
Advanced tools
Comparing version 0.4.2 to 0.4.3
#!/usr/bin/env node | ||
import type { VoteMethod } from "./vote.js"; | ||
interface Options { | ||
askForConfirmation?: (ballotContent: string) => boolean | Promise<boolean>; | ||
subject: string; | ||
@@ -5,0 +6,0 @@ headerInstructions?: string; |
#!/usr/bin/env node | ||
import { spawn } from "node:child_process"; | ||
import { once } from "node:events"; | ||
import fs from "node:fs/promises"; | ||
import path from "node:path"; | ||
import os from "node:os"; | ||
import { env, stdin, stdout } from "node:process"; | ||
import { env } from "node:process"; | ||
import * as yaml from "js-yaml"; | ||
@@ -121,21 +120,12 @@ import { generateAndSplitKeyPair } from "@aduh95/caritat-crypto/generateSplitKeyPair"; | ||
const ballotPath = path.join(directory, "ballot.yml"); | ||
let needsConfirmation = true; | ||
let ballotContent; | ||
while (true) { | ||
while (needsConfirmation) { | ||
const vote = loadYmlString(yamlString); | ||
ballotContent = templateBallot(vote); | ||
console.log("Here's how a ballot will look like:\n\n"); | ||
console.log(ballotContent); | ||
stdout.write("\nIs it ready to commit? [Y/n] "); | ||
stdin.resume(); | ||
let chars = await once(stdin, "data"); | ||
stdin.pause(); | ||
if (chars[0][0] === 0x6e || // n | ||
chars[0][0] === 0x4e // N | ||
) { | ||
console.log("Vote template file is ready for edit."); | ||
needsConfirmation = await options.askForConfirmation?.(ballotContent); | ||
if (needsConfirmation) { | ||
await runChildProcessAsync(env?.EDITOR ?? (os.platform() === "win32" ? "notepad" : "vi"), [voteFilePath]); | ||
yamlString = await fs.readFile(voteFilePath, "utf-8"); | ||
} | ||
else | ||
break; | ||
} | ||
@@ -142,0 +132,0 @@ await fs.writeFile(publicKeyPath, ballot.publicKey); |
{ | ||
"name": "@aduh95/caritat", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist/" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2
69141
1653