@procedures/restic 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/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @procedures/restic
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a5f28e5: A host can give secrets only to the restic process, and the package root exports the functions of `restic.run`.
8
+
9
+ - `runRestic(command, options)` starts a restic command and reads its JSON output. Its `env` option gives variables (for example `RESTIC_PASSWORD`, `RESTIC_REPOSITORY` and `B2_ACCOUNT_ID`) only to the restic process. The environment of the host does not change.
10
+ - `createResticModule({ env, run })` gives the module with those settings. The procedure input still has no field for a secret.
11
+ - `findRestic()` finds the program: `RESTIC_EXE`, then on Windows the `restic*.exe` of a WinGet package, then `restic` on the `PATH`.
12
+ - The `run` option replaces the function that starts restic, so a test can give a fake runner.
13
+
14
+ The input, the output and the effects of `restic.run` do not change.
15
+
16
+ ### Patch Changes
17
+
18
+ - ae08311: `runRestic` takes `maxOutputBytes`, and the result has `truncated` when an output stream was longer. `restic ls` of a large snapshot can give more than the default of 64 MiB.
19
+ - Updated dependencies [d919678]
20
+ - Updated dependencies [057d69a]
21
+ - Updated dependencies [b2a1a1e]
22
+ - Updated dependencies [057d69a]
23
+ - Updated dependencies [057d69a]
24
+ - Updated dependencies [057d69a]
25
+ - Updated dependencies [057d69a]
26
+ - Updated dependencies [057d69a]
27
+ - Updated dependencies [afd6a19]
28
+ - Updated dependencies [057d69a]
29
+ - Updated dependencies [4c51727]
30
+ - Updated dependencies [4e751da]
31
+ - @procedures/client@0.4.0
32
+ - @procedures/shell@0.4.0
33
+
3
34
  ## 0.3.0
4
35
 
5
36
  ### Minor Changes
package/README.md CHANGED
@@ -28,3 +28,40 @@ const { json } = await client.exec(["restic", "run"], { path: ["snapshots"] });
28
28
  ## Secrets
29
29
 
30
30
  restic reads the repository and its keys from the environment (`RESTIC_REPOSITORY`, `RESTIC_PASSWORD`, `B2_ACCOUNT_ID`, `AWS_ACCESS_KEY_ID` and the others), so no secret is an input. `restic.run` refuses `--password-command`, because that flag starts a program.
31
+
32
+ A host can give the secrets only to the restic process, with the `env` option of `createResticModule()` or `runRestic()`:
33
+
34
+ - The values go on top of the environment of the host. The value `undefined` removes a variable of the host.
35
+ - The environment of the host does not change, and the output does not contain the values.
36
+ - The procedure input has no field for them. The caller of `restic.run` cannot read or change them.
37
+
38
+ ```ts
39
+ const registry = createRegistry(createResticModule({ env: { RESTIC_REPOSITORY: repository, RESTIC_PASSWORD: password } }));
40
+ ```
41
+
42
+ restic can write the repository address in its error text. Remove it before you show the text to a user.
43
+
44
+ ## Library functions
45
+
46
+ The package root exports the functions that `restic.run` uses:
47
+
48
+ | Function | What it does |
49
+ | --- | --- |
50
+ | `runRestic(command, options)` | Starts a restic command with argv, and reads its JSON output. |
51
+ | `findRestic(options)` | Finds the restic program. |
52
+ | `resticArgv(command)` | Gives the argv of a restic command. |
53
+ | `createResticModule(options)` | Gives the module with the settings of the host: `env` and `run`. |
54
+
55
+ - `command` has `path`, `positional`, `args`, `repository` and `json`. `json` is true when the command does not set it, as in `restic.run`.
56
+ - `options` of `runRestic` has `executable`, `env`, `cwd`, `timeout`, `signal` and `run`.
57
+ - `runRestic` throws when restic does not start. A failed command gives `success: false`, with `exitCode` and `stderr`.
58
+ - `run` replaces the function that starts restic. A test gives a fake runner.
59
+ - `findRestic` gives `RESTIC_EXE` when it is set. On Windows, it then looks for the `restic*.exe` of a WinGet package. Then it gives `restic`, and the `PATH` gives the program.
60
+
61
+ ```ts
62
+ const executable = await findRestic();
63
+ const result = await runRestic(
64
+ { path: ["forget"], args: { "keep-daily": 14, "keep-weekly": 12, prune: true } },
65
+ { executable, env: { RESTIC_REPOSITORY: repository, RESTIC_PASSWORD: password } },
66
+ );
67
+ ```