ssh-config 4.1.1 → 4.1.4

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/index.js CHANGED
@@ -6,7 +6,7 @@ const RE_SPACE = /\s/
6
6
  const RE_LINE_BREAK = /\r|\n/
7
7
  const RE_SECTION_DIRECTIVE = /^(Host|Match)$/i
8
8
  const RE_MULTI_VALUE_DIRECTIVE = /^(GlobalKnownHostsFile|Host|IPQoS|SendEnv|UserKnownHostsFile|ProxyCommand)$/i
9
- const RE_QUOTE_DIRECTIVE = /^(?:CertificateFile|IdentityFile|User)$/i
9
+ const RE_QUOTE_DIRECTIVE = /^(?:CertificateFile|IdentityFile|IdentityAgent|User)$/i
10
10
  const RE_SINGLE_LINE_DIRECTIVE = /^(Include|IdentityFile)$/i
11
11
 
12
12
  const DIRECTIVE = 1
@@ -457,6 +457,10 @@ class SSHConfig extends Array {
457
457
  config.push(node)
458
458
  config = node.config = new SSHConfig()
459
459
  }
460
+ else if (node.type === DIRECTIVE && !node.param) {
461
+ // blank lines at file end
462
+ config[config.length - 1].after += node.before
463
+ }
460
464
  else {
461
465
  config.push(node)
462
466
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ssh-config",
3
3
  "description": "SSH config parser and stringifier",
4
- "version": "4.1.1",
4
+ "version": "4.1.4",
5
5
  "author": "Chen Yangjian (https://www.cyj.me)",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,18 +13,23 @@
13
13
  "types"
14
14
  ],
15
15
  "devDependencies": {
16
+ "@types/mocha": "^9.1.0",
17
+ "@types/node": "^17.0.23",
16
18
  "eslint": "^7.17.0",
17
19
  "heredoc": "^1.3.1",
18
20
  "mocha": "^8.2.1",
19
- "nyc": "^15.1.0"
21
+ "nyc": "^15.1.0",
22
+ "typescript": "^4.6.3"
20
23
  },
21
24
  "scripts": {
22
25
  "lint": "eslint .",
23
- "test": "mocha --exit",
24
- "test:coverage": "nyc mocha --exit && nyc report --reporter=lcov"
26
+ "pretest": "tsc",
27
+ "test": "NODE_OPTIONS=--enable-source-maps mocha --exit --recursive",
28
+ "test:coverage": "nyc mocha --exit --recursive && nyc report --reporter=lcov"
25
29
  },
26
30
  "engine": {
27
31
  "node": ">= 10.0.0"
28
32
  },
33
+ "types": "types/index.d.ts",
29
34
  "license": "MIT"
30
35
  }
package/types/index.d.ts CHANGED
@@ -13,7 +13,7 @@ interface Directive {
13
13
  }
14
14
 
15
15
  interface Section extends Directive {
16
- config: SSHConfig;
16
+ config: SSHConfig<Line>;
17
17
  }
18
18
 
19
19
  interface Comment {
@@ -21,21 +21,26 @@ interface Comment {
21
21
  content: string;
22
22
  }
23
23
 
24
- type Line = Directive | Comment;
24
+ type Line = Section | Directive | Comment;
25
25
 
26
- export default class SSHConfig extends Array {
27
- static parse(text: string): SSHConfig;
28
- static stringify(config: SSHConfig): string;
26
+ declare class SSHConfig<T> extends Array<T> {
27
+ static parse(text: string): SSHConfig<Line>;
28
+ static stringify(config: SSHConfig<Line>): string;
29
+
30
+ static DIRECTIVE: ELine.DIRECTIVE;
31
+ static COMMENT: ELine.COMMENT;
29
32
 
30
33
  toString(): string;
31
34
 
32
35
  compute(host: string): Record<string, string>;
33
36
 
34
- find(predicate: (value: any, index: number, obj: any[]) => any);
37
+ find<T>(this: SSHConfig<T>, predicate: (line: T, index: number, config: T[]) => boolean): T;
35
38
  find(options: Record<string, string>): Line | Section;
36
39
 
37
40
  remove(options: Record<string, string>): Line | Section;
38
41
 
39
- append(options: Record<string, string>): SSHConfig;
40
- prepend(options: Record<string, string>): SSHConfig;
42
+ append(options: Record<string, string>): SSHConfig<Line>;
43
+ prepend(options: Record<string, string>): SSHConfig<Line>;
41
44
  }
45
+
46
+ export default class extends SSHConfig<Line> {}
package/History.md DELETED
@@ -1,169 +0,0 @@
1
- 4.1.1 / 2021-10-21
2
- ==================
3
-
4
- ## What's Changed
5
- * docs: `.prepend` and type definitions by @cyjake in https://github.com/cyjake/ssh-config/pull/47
6
- * fix: improper parsing of ProxyCommand with quotation marks by @tanhakabir in https://github.com/cyjake/ssh-config/pull/48
7
-
8
-
9
- **Full Changelog**: https://github.com/cyjake/ssh-config/compare/v4.1.0...v4.1.1
10
-
11
- 4.1.0 / 2021-10-20
12
- ==================
13
-
14
- ## What's Changed
15
- * test: switching to github actions by @cyjake in https://github.com/cyjake/ssh-config/pull/44
16
- * feat: add prepend function to prepend options onto config by @tanhakabir in https://github.com/cyjake/ssh-config/pull/45
17
- * build: switch to codecov by @cyjake in https://github.com/cyjake/ssh-config/pull/46
18
-
19
- ## New Contributors
20
- * @tanhakabir made her first contribution in https://github.com/cyjake/ssh-config/pull/45
21
-
22
- **Full Changelog**: https://github.com/cyjake/ssh-config/compare/v4.0.6...v4.1.0
23
-
24
- 4.0.6 / 2021-05-11
25
- ==================
26
-
27
- * fix: IdentityFile parameter value should be quoted if contains space
28
-
29
-
30
- 4.0.5 / 2021-01-08
31
- ==================
32
-
33
- * fix: multiple LocalForward values should be formartted into multiple lines
34
-
35
-
36
- 4.0.4 / 2020-09-01
37
- ==================
38
-
39
- * fix: should not quote directives like LocalForward (#38)
40
-
41
-
42
- 4.0.3 / 2020-08-24
43
- ==================
44
-
45
- * fix: quote values that contain white spaces (36)
46
-
47
-
48
- 4.0.2 / 2020-02-09
49
- ==================
50
-
51
- * fix: 'compute' fails when hosts contain regex chars #34 @roblourens
52
-
53
-
54
- 4.0.1 / 2020-02-01
55
- ==================
56
-
57
- * Fix: parsing `Host` values with trailing spaces
58
-
59
-
60
- 4.0.0 / 2020-01-09
61
- ==================
62
-
63
- * Fix: allow forwarding directives (and `CertificateFile`) to have multiple values (#30)
64
-
65
-
66
- 3.0.1 / 2020-01-07
67
- ==================
68
-
69
- * Fix: append new section to empty config (#27)
70
-
71
-
72
- 3.0.0 / 2019-12-12
73
- ==================
74
-
75
- * Breaking: prefer to separate sections with `\n\n` (#23, #24)
76
- * Breaking: drop `SSHConfig.find()`, please use `SSHConfig.prototype.find()` instead
77
-
78
-
79
- 2.0.0 / 2019-10-08
80
- ==================
81
-
82
- * Breaking: parse `Host` values as an Array to hold multiple patterns
83
- * Breaking: an extra line break will always be added when `.append()`ing config
84
- * Fix: `Host` can contain spaces if quoted with double quotes
85
- * Fix: quoted values can contain double quotes once they are escaped with backslash
86
- * Fix: escape + when converting patterns to regexp
87
- * Fix: parameter/value pairs separated with tab charactor
88
-
89
-
90
- 1.1.6 / 2019-04-02
91
- ==================
92
-
93
- * Fix: appending to empty config
94
-
95
-
96
- 1.1.5 / 2018-12-06
97
- ==================
98
-
99
- * Fix: auto insert newline when `.append()`ing existing config without trailing newlines. #15
100
-
101
-
102
- 1.1.3 / 2017-09-25
103
- ==================
104
-
105
- * Fix: appended config shall comply with existing style, otherwhise default to two spaces. Also an extra linebreak is added after the last line.
106
-
107
-
108
- 1.1.2 / 2017-09-22
109
- ==================
110
-
111
- * Fix: nagate patterns shall be matched first and fail early
112
-
113
-
114
- 1.1.1 / 2017-09-13
115
- ==================
116
-
117
- * Fix: values of `IdentityFile` will now be quoted if contain space.
118
- * Fix: quoted values will have their double quotations stripped while parsed, which is a slightly breaking behavior but I think a patch version will just be fine.
119
-
120
-
121
- 1.1.0 / 2017-09-07
122
- ==================
123
-
124
- * New: `config.append({ Host: '*' })`
125
-
126
- Allow appending sections via `config.append({ ... })` method. Closes #12.
127
-
128
-
129
- 1.0.1 / 2017-02-06
130
- ==================
131
-
132
- * Fix: trim spaces at value beginning and endding
133
- * Fix: make example east more compact
134
-
135
-
136
- 1.0.0 / 2016-05-05
137
- ==================
138
-
139
- * Fix: updated readme to be reflect 1.x changes
140
- * Breaking: parse into a simple ast
141
-
142
- This is a breaking change. The parse result is now a subclass of Array instead of vanila Object.
143
-
144
-
145
- 0.2.1 / 2015-11-17
146
- ==================
147
-
148
- * Fix: code style and one more test case
149
- * Merge pull request #7 from petemill/fix-leading-newline
150
- * Only add a newline between sections if there are previous lines. Fixes https://github.com/dotnil/ssh-config/issues/6
151
-
152
-
153
- 0.2.0 / 2015-07-07
154
- ==================
155
-
156
- * Added converage with istanbul
157
- * Added .append, .find, and .remove; fixes #4
158
- * Added documentations about said methods
159
- * Added badges about npm downloads, version, and build status
160
- * Added .travis.yml
161
- * Implemented .query and support pattern matching (poorly)
162
-
163
-
164
- 0.1.0 / 2015-01-12
165
- ==================
166
-
167
- * Init repo
168
- * Implemented `.parse` and `.stringify`
169
-
@@ -1,10 +0,0 @@
1
- import SSHConfig from './index';
2
-
3
- const config = SSHConfig.parse(`
4
- IdentityFile ~/.ssh/id_rsa
5
-
6
- Host ness
7
- HostName lochness.com
8
- `);
9
-
10
- console.log(config.toString());