@eliware/vyops 1.0.8 → 1.0.10

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/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Release Notes
2
2
 
3
+ ## 1.0.10
4
+
5
+ - Make Git integration optional for deployments using standalone config files.
6
+ - Continue downloading the live VyOS configuration after deployment while
7
+ skipping repository checks and pushback outside a Git repository.
8
+ - Add regression coverage for non-Git and unexpected repository paths.
9
+
10
+ Verification:
11
+
12
+ - `npm test` (100% coverage across statements, branches, functions, and lines)
13
+ - `npm run lint`
14
+ - `npm run audit`
15
+
16
+ ## 1.0.9
17
+
18
+ - Fix `--password-stdin` to read piped passwords correctly on current Node.js
19
+ runtimes.
20
+ - Restore password-authenticated backup workflows for VyOS hosts.
21
+
22
+ Verification:
23
+
24
+ - `npm test` (100% coverage across statements, branches, functions, and lines)
25
+ - `npm run lint`
26
+ - `npm run audit`
27
+
3
28
  ## 1.0.8
4
29
 
5
30
  - Fail immediately with a redacted VyOS error when confirmed commits reject a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliware/vyops",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Deploy native VyOS configuration files over SSH.",
5
5
  "main": "vyops.mjs",
6
6
  "scripts": {
package/src/git.mjs CHANGED
@@ -59,10 +59,19 @@ function configDirectory(config) {
59
59
  return path(config, '..');
60
60
  }
61
61
 
62
+ async function repositoryRoot(config) {
63
+ try {
64
+ const { stdout } = await git(['rev-parse', '--show-toplevel'], configDirectory(config));
65
+ return stdout.trim();
66
+ } catch (error) {
67
+ if (error.stderr?.includes('not a git repository')) return null;
68
+ throw error;
69
+ }
70
+ }
71
+
62
72
  export async function shouldSkip(config) {
63
- const cwd = configDirectory(config);
64
- const { stdout: root } = await git(['rev-parse', '--show-toplevel'], cwd);
65
- const repo = root.trim();
73
+ const repo = await repositoryRoot(config);
74
+ if (!repo) return false;
66
75
  const relative = config.startsWith(`${repo}/`) ? config.slice(repo.length + 1) : config;
67
76
  const { stdout: status } = await git(['status', '--porcelain', '--', relative], repo);
68
77
  if (status.trim()) return false;
@@ -71,8 +80,8 @@ export async function shouldSkip(config) {
71
80
  }
72
81
 
73
82
  export async function pushBack(config, { force = false } = {}) {
74
- const { stdout: root } = await git(['rev-parse', '--show-toplevel'], configDirectory(config));
75
- const repo = root.trim();
83
+ const repo = await repositoryRoot(config);
84
+ if (!repo) return false;
76
85
  return withRepositoryLock(repo, async () => {
77
86
  const relative = config.startsWith(`${repo}/`) ? config.slice(repo.length + 1) : config;
78
87
  const { stdout: diff } = await git(['diff', 'HEAD', '--', relative], repo);
package/src/main.mjs CHANGED
@@ -6,7 +6,12 @@ import { readAndValidateConfig } from './validate.mjs';
6
6
  import { pushBack, shouldSkip } from './git.mjs';
7
7
  import { closeAll } from './ssh.mjs';
8
8
  import { log, registerHandlers, registerSignals } from '@eliware/common';
9
- import { readFile } from 'node:fs/promises';
9
+
10
+ async function readPasswordStdin() {
11
+ const chunks = [];
12
+ for await (const chunk of process.stdin) chunks.push(chunk);
13
+ return Buffer.concat(chunks).toString('utf8').replace(/\r?\n$/, '');
14
+ }
10
15
 
11
16
  const errors = registerHandlers({ log });
12
17
  const signals = registerSignals({ log, shutdownHook: async () => closeAll() });
@@ -23,7 +28,7 @@ try {
23
28
  process.exit(0);
24
29
  }
25
30
  if (args.passwordStdin) {
26
- args.password = (await readFile(0, 'utf8')).replace(/\r?\n$/, '');
31
+ args.password = await readPasswordStdin();
27
32
  if (!args.password) throw new Error('password-stdin received an empty password');
28
33
  }
29
34
  if (args.backup) {