ssh-config 4.1.2 → 4.1.5

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/Readme.md CHANGED
@@ -121,7 +121,7 @@ config.remove({ Host: 'example1' })
121
121
  Since the parsed config is a sub class of Array, you can append new sections with methods like `.push` or `.concat`.
122
122
 
123
123
  ```js
124
- config.push(SSHConfig.parse(`
124
+ config.push(...SSHConfig.parse(`
125
125
  Host ness
126
126
  HostName lochness.com
127
127
  User dinosaur
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.2",
4
+ "version": "4.1.5",
5
5
  "author": "Chen Yangjian (https://www.cyj.me)",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,15 +13,19 @@
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"
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,178 +0,0 @@
1
- 4.1.2 / 2022-01-20
2
- ==================
3
-
4
- ## What's Changed
5
- * docs: types field in package.json by @cyjake in https://github.com/cyjake/ssh-config/pull/50
6
-
7
-
8
- **Full Changelog**: https://github.com/cyjake/ssh-config/compare/v4.1.1...v4.1.2
9
-
10
- 4.1.1 / 2021-10-21
11
- ==================
12
-
13
- ## What's Changed
14
- * docs: `.prepend` and type definitions by @cyjake in https://github.com/cyjake/ssh-config/pull/47
15
- * fix: improper parsing of ProxyCommand with quotation marks by @tanhakabir in https://github.com/cyjake/ssh-config/pull/48
16
-
17
-
18
- **Full Changelog**: https://github.com/cyjake/ssh-config/compare/v4.1.0...v4.1.1
19
-
20
- 4.1.0 / 2021-10-20
21
- ==================
22
-
23
- ## What's Changed
24
- * test: switching to github actions by @cyjake in https://github.com/cyjake/ssh-config/pull/44
25
- * feat: add prepend function to prepend options onto config by @tanhakabir in https://github.com/cyjake/ssh-config/pull/45
26
- * build: switch to codecov by @cyjake in https://github.com/cyjake/ssh-config/pull/46
27
-
28
- ## New Contributors
29
- * @tanhakabir made her first contribution in https://github.com/cyjake/ssh-config/pull/45
30
-
31
- **Full Changelog**: https://github.com/cyjake/ssh-config/compare/v4.0.6...v4.1.0
32
-
33
- 4.0.6 / 2021-05-11
34
- ==================
35
-
36
- * fix: IdentityFile parameter value should be quoted if contains space
37
-
38
-
39
- 4.0.5 / 2021-01-08
40
- ==================
41
-
42
- * fix: multiple LocalForward values should be formartted into multiple lines
43
-
44
-
45
- 4.0.4 / 2020-09-01
46
- ==================
47
-
48
- * fix: should not quote directives like LocalForward (#38)
49
-
50
-
51
- 4.0.3 / 2020-08-24
52
- ==================
53
-
54
- * fix: quote values that contain white spaces (36)
55
-
56
-
57
- 4.0.2 / 2020-02-09
58
- ==================
59
-
60
- * fix: 'compute' fails when hosts contain regex chars #34 @roblourens
61
-
62
-
63
- 4.0.1 / 2020-02-01
64
- ==================
65
-
66
- * Fix: parsing `Host` values with trailing spaces
67
-
68
-
69
- 4.0.0 / 2020-01-09
70
- ==================
71
-
72
- * Fix: allow forwarding directives (and `CertificateFile`) to have multiple values (#30)
73
-
74
-
75
- 3.0.1 / 2020-01-07
76
- ==================
77
-
78
- * Fix: append new section to empty config (#27)
79
-
80
-
81
- 3.0.0 / 2019-12-12
82
- ==================
83
-
84
- * Breaking: prefer to separate sections with `\n\n` (#23, #24)
85
- * Breaking: drop `SSHConfig.find()`, please use `SSHConfig.prototype.find()` instead
86
-
87
-
88
- 2.0.0 / 2019-10-08
89
- ==================
90
-
91
- * Breaking: parse `Host` values as an Array to hold multiple patterns
92
- * Breaking: an extra line break will always be added when `.append()`ing config
93
- * Fix: `Host` can contain spaces if quoted with double quotes
94
- * Fix: quoted values can contain double quotes once they are escaped with backslash
95
- * Fix: escape + when converting patterns to regexp
96
- * Fix: parameter/value pairs separated with tab charactor
97
-
98
-
99
- 1.1.6 / 2019-04-02
100
- ==================
101
-
102
- * Fix: appending to empty config
103
-
104
-
105
- 1.1.5 / 2018-12-06
106
- ==================
107
-
108
- * Fix: auto insert newline when `.append()`ing existing config without trailing newlines. #15
109
-
110
-
111
- 1.1.3 / 2017-09-25
112
- ==================
113
-
114
- * Fix: appended config shall comply with existing style, otherwhise default to two spaces. Also an extra linebreak is added after the last line.
115
-
116
-
117
- 1.1.2 / 2017-09-22
118
- ==================
119
-
120
- * Fix: nagate patterns shall be matched first and fail early
121
-
122
-
123
- 1.1.1 / 2017-09-13
124
- ==================
125
-
126
- * Fix: values of `IdentityFile` will now be quoted if contain space.
127
- * 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.
128
-
129
-
130
- 1.1.0 / 2017-09-07
131
- ==================
132
-
133
- * New: `config.append({ Host: '*' })`
134
-
135
- Allow appending sections via `config.append({ ... })` method. Closes #12.
136
-
137
-
138
- 1.0.1 / 2017-02-06
139
- ==================
140
-
141
- * Fix: trim spaces at value beginning and endding
142
- * Fix: make example east more compact
143
-
144
-
145
- 1.0.0 / 2016-05-05
146
- ==================
147
-
148
- * Fix: updated readme to be reflect 1.x changes
149
- * Breaking: parse into a simple ast
150
-
151
- This is a breaking change. The parse result is now a subclass of Array instead of vanila Object.
152
-
153
-
154
- 0.2.1 / 2015-11-17
155
- ==================
156
-
157
- * Fix: code style and one more test case
158
- * Merge pull request #7 from petemill/fix-leading-newline
159
- * Only add a newline between sections if there are previous lines. Fixes https://github.com/dotnil/ssh-config/issues/6
160
-
161
-
162
- 0.2.0 / 2015-07-07
163
- ==================
164
-
165
- * Added converage with istanbul
166
- * Added .append, .find, and .remove; fixes #4
167
- * Added documentations about said methods
168
- * Added badges about npm downloads, version, and build status
169
- * Added .travis.yml
170
- * Implemented .query and support pattern matching (poorly)
171
-
172
-
173
- 0.1.0 / 2015-01-12
174
- ==================
175
-
176
- * Init repo
177
- * Implemented `.parse` and `.stringify`
178
-
@@ -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());