zurik 1.0.1 → 1.0.3

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.
@@ -0,0 +1,31 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*'
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Set up Node
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: 20
20
+ registry-url: 'https://registry.npmjs.org'
21
+
22
+ - name: Install deps
23
+ run: npm ci
24
+
25
+ - name: Build
26
+ run: npm run build --if-present
27
+
28
+ - name: Publish
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
31
+ run: npm publish --access public
package/bin/zurik.js CHANGED
@@ -1,21 +1,74 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import * as readline from "readline";
3
4
  import encryptFiles from "../lib/encrypt.js";
4
5
  import decryptFiles from "../lib/decrypt.js";
5
6
 
6
7
  const args = process.argv.slice(2);
7
8
 
8
- function extractPassword() {
9
+
10
+ function readPassword() {
11
+ return new Promise((resolve) => {
12
+ const rl = readline.createInterface({
13
+ input: process.stdin,
14
+ output: process.stdout,
15
+ terminal: false
16
+ });
17
+
18
+ if (process.stdin.isTTY) {
19
+ process.stdin.setRawMode(true);
20
+ }
21
+
22
+ process.stdout.write("Password: ");
23
+
24
+ let password = "";
25
+
26
+ process.stdin.on("data", (char) => {
27
+ char = char.toString();
28
+
29
+ if (char === "\n" || char === "\r" || char === "\u0004") {
30
+ process.stdin.pause();
31
+ if (process.stdin.isTTY) {
32
+ process.stdin.setRawMode(false);
33
+ }
34
+ rl.close();
35
+ console.log();
36
+ resolve(password);
37
+ } else if (char === "\u007f" || char === "\b") {
38
+ // Backspace
39
+ if (password.length > 0) {
40
+ password = password.slice(0, -1);
41
+ process.stdout.clearLine(0);
42
+ process.stdout.cursorTo(0);
43
+ process.stdout.write("Password: " + "*".repeat(password.length));
44
+ }
45
+ } else if (char === "\u0003") {
46
+ // Ctrl+C
47
+ console.log();
48
+ process.exit(0);
49
+ } else {
50
+ password += char;
51
+ process.stdout.write("*");
52
+ }
53
+ });
54
+ });
55
+ }
56
+
57
+
58
+ async function extractPassword() {
9
59
  const pIndex = args.indexOf("-p");
10
- if (pIndex !== -1 && args[pIndex + 1]) {
11
- return args[pIndex + 1];
60
+ if (pIndex !== -1) {
61
+ if (args[pIndex + 1] && !args[pIndex + 1].startsWith("-")) {
62
+ return args[pIndex + 1];
63
+ }
64
+
65
+ return await readPassword()
12
66
  }
13
67
  return process.env.ZURIK_PASSWORD || null;
14
68
  }
15
69
 
16
-
17
70
  async function run() {
18
- const password = extractPassword();
71
+ const password = await extractPassword();
19
72
  if (!password) {
20
73
  console.error("Missing password. Use -p <password> or set ZURIK_PASSWORD environment variable.");
21
74
  process.exit(1);
package/lib/encrypt.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import fs from "fs";
2
- import path from "path";
3
2
  import { encryptData } from "./crypto.js";
4
3
 
5
4
  export default async function encryptFiles(password) {
@@ -15,6 +14,10 @@ export default async function encryptFiles(password) {
15
14
  .map(x => x.trim())
16
15
  .filter(Boolean);
17
16
 
17
+ if (fileList.length === 0) {
18
+ throw new Error("No files listed in .gitencrypt");
19
+ }
20
+
18
21
  const bundle = { version: 1, files: {} };
19
22
 
20
23
  for (const filePath of fileList) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zurik",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "CLI tool for encrypting and decrypting sensitive project files into a single .zurik bundle.",
5
5
  "type": "module",
6
6
  "bin": {
package/readme.md CHANGED
@@ -22,4 +22,31 @@ npm install -g zurik
22
22
 
23
23
  # also you can pass the password as an argument
24
24
  npx zurik -e -p "your-password"
25
+
26
+ # or you can type the password interactively
27
+ npx zurik -e -p
28
+ ```
29
+
30
+ ## Usage
31
+ ### Encrypt files
32
+ - create *.gitencrypt* file in the root of your project
33
+ - add paths to files you want to encrypt, one per line
34
+ - for example:
35
+ ```txt
36
+ # .gitencrypt
37
+ src/config.json
38
+ src/secret.txt
39
+ ```
40
+ - run the command below
41
+ ```sh
42
+ npx zurik -e -p "your-password"
43
+ ```
44
+ - the encrypted files will be saved in `.zurik` file
45
+ - it will also add the encrypted files to `.gitignore` if they are not already ignored
46
+
47
+ ### Decrypt files
48
+ - run the command below to decrypt the files
49
+ ```sh
50
+ npx zurik -d -p "your-password"
25
51
  ```
52
+ - the decrypted files will be saved in the same directory as the original files