xshell 1.3.24 → 1.3.26

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/git.d.ts CHANGED
@@ -37,6 +37,10 @@ export declare class Git {
37
37
  checkout(branch?: 'main'): Promise<void>;
38
38
  checkout(branch?: string): Promise<void>;
39
39
  _checkout(branch: string, create: boolean, remote_branch?: string): Promise<void>;
40
+ /** 基于远程分支创建相同且干净的本地分支 (reset),用于 ci
41
+ 会自动先通过 this.fetch 更新 remote_branch 对应的远程仓库
42
+ - branch: 远程分支名,必须类似 origin/main 这样的格式 */
43
+ checkout_remote(remote_branch: string): Promise<void>;
40
44
  get_version_info(version?: string): Promise<{
41
45
  version: string;
42
46
  branch: string;
@@ -45,6 +49,8 @@ export declare class Git {
45
49
  commiter: string;
46
50
  message: string;
47
51
  }>;
52
+ /** 重置分支到最后提交的状态 */
53
+ reset(remote_branch?: string): Promise<void>;
48
54
  }
49
55
  export interface GitVersionInfo {
50
56
  version: string;
package/git.js CHANGED
@@ -121,6 +121,23 @@ export class Git {
121
121
  ...remote_branch ? [remote_branch] : []
122
122
  ], print_no_command);
123
123
  }
124
+ /** 基于远程分支创建相同且干净的本地分支 (reset),用于 ci
125
+ 会自动先通过 this.fetch 更新 remote_branch 对应的远程仓库
126
+ - branch: 远程分支名,必须类似 origin/main 这样的格式 */
127
+ async checkout_remote(remote_branch) {
128
+ const [remote, name] = remote_branch.split2('/');
129
+ await this.fetch({ remote });
130
+ const branches = await this.get_branches(false);
131
+ if (!branches.includes(`remotes/${remote_branch}`))
132
+ throw new Error(`远程分支 ${remote_branch} 不存在`);
133
+ // 存在对应的本地分支
134
+ if (branches.includes(name)) {
135
+ await this._checkout(name, false);
136
+ await this.reset(remote_branch);
137
+ }
138
+ else
139
+ await this._checkout(name, true, remote_branch);
140
+ }
124
141
  async get_version_info(version) {
125
142
  const branch = await this.get_branch();
126
143
  const { hash, time, commiter, message } = (await this.get_last_commits(1))[0];
@@ -135,6 +152,15 @@ export class Git {
135
152
  message
136
153
  };
137
154
  }
155
+ /** 重置分支到最后提交的状态 */
156
+ async reset(remote_branch) {
157
+ console.log(`重置分支到${remote_branch ? ` ${remote_branch}` : '最后提交的状态'}`);
158
+ await this.call([
159
+ 'reset',
160
+ '--hard',
161
+ ...remote_branch ? [remote_branch] : []
162
+ ], print_no_command);
163
+ }
138
164
  }
139
165
  const print_stdout = { print: { code: false, command: false, stdout: true, stderr: true } };
140
166
  //# sourceMappingURL=git.js.map
package/net.common.d.ts CHANGED
@@ -102,6 +102,7 @@ export interface RemoteOptions {
102
102
  print?: boolean;
103
103
  /** `false` 打印所有交互的 rpc messages */
104
104
  verbose?: boolean;
105
+ proxy?: string;
105
106
  /** 使用者自定义的在 websocket 连接出错时,或者 handlers 出错时的处理
106
107
  用户设置后会覆盖默认的 print 错误功能 */
107
108
  on_error?(error: WebSocketConnectionError | Error, remote: Remote): void;
@@ -141,6 +142,7 @@ export declare class Remote {
141
142
  print: boolean;
142
143
  /** `false` 打印所有交互的 rpc messages */
143
144
  verbose: boolean;
145
+ proxy?: string;
144
146
  /** 防止作为 websocket 连接发起方时并发创建 websocket 连接 */
145
147
  lwebsocket: Lock<WebSocket>;
146
148
  /** map<id, message handler>: 通过 (rpc message).id 找到对应的 handler
@@ -154,7 +156,7 @@ export declare class Remote {
154
156
  error: WebSocketConnectionError | Error;
155
157
  /** 作为 websocket 连接发起方,传入 url
156
158
  作为 websocket 连接接收方,传入 websocket + name */
157
- constructor({ name, url, websocket, funcs, print, verbose, alive, args, on_error, on_reconnect, on_connected }?: RemoteOptions);
159
+ constructor({ name, url, websocket, funcs, print, verbose, alive, args, proxy, on_error, on_reconnect, on_connected }?: RemoteOptions);
158
160
  /** 统一处理首次连接和连接后的 websocket 错误 */
159
161
  _on_error: (error: WebSocketConnectionError | Error) => void;
160
162
  on_reconnect?: (this: Remote) => Promise<void>;
package/net.common.js CHANGED
@@ -213,6 +213,7 @@ export class Remote {
213
213
  print = true;
214
214
  /** `false` 打印所有交互的 rpc messages */
215
215
  verbose = false;
216
+ proxy;
216
217
  // --- states
217
218
  /** 防止作为 websocket 连接发起方时并发创建 websocket 连接 */
218
219
  lwebsocket = new Lock();
@@ -227,7 +228,7 @@ export class Remote {
227
228
  error;
228
229
  /** 作为 websocket 连接发起方,传入 url
229
230
  作为 websocket 连接接收方,传入 websocket + name */
230
- constructor({ name, url, websocket, funcs, print, verbose, alive, args, on_error, on_reconnect, on_connected } = {}) {
231
+ constructor({ name, url, websocket, funcs, print, verbose, alive, args, proxy, on_error, on_reconnect, on_connected } = {}) {
231
232
  if (name)
232
233
  this.name = name;
233
234
  if (alive) {
@@ -280,6 +281,8 @@ export class Remote {
280
281
  this.print = print;
281
282
  if (verbose !== undefined)
282
283
  this.verbose = verbose;
284
+ if (proxy)
285
+ this.proxy = proxy;
283
286
  if (on_error)
284
287
  this.on_error = on_error;
285
288
  }
@@ -368,7 +371,8 @@ export class Remote {
368
371
  on_message: this._on_message,
369
372
  on_error: this._on_error,
370
373
  print: this.print,
371
- keep_alive_duration: this.alive ? 30_000 : undefined
374
+ keep_alive_duration: this.alive ? 30_000 : undefined,
375
+ proxy: this.proxy
372
376
  });
373
377
  this.error = null;
374
378
  if (this.args)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.3.24",
3
+ "version": "1.3.26",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/path.d.ts CHANGED
@@ -54,7 +54,7 @@ export declare function extname(path: string): string;
54
54
  /** `/` */
55
55
  export declare const sep = "/";
56
56
  /** The platform-specific file delimiter. ';' or ':'. */
57
- export declare const delimiter: ";" | ":";
57
+ export declare const delimiter: ":" | ";";
58
58
  /** Returns an object from a path string - the opposite of format().
59
59
  @param path path to evaluate.
60
60
  @throws {TypeError} if `path` is not a string. */
@@ -81,7 +81,7 @@ export declare let path: {
81
81
  basename: typeof basename;
82
82
  extname: typeof extname;
83
83
  sep: string;
84
- delimiter: ";" | ":";
84
+ delimiter: ":" | ";";
85
85
  parse: typeof parse;
86
86
  format: typeof format;
87
87
  toNamespacedPath: typeof toNamespacedPath;
@@ -30733,6 +30733,12 @@ if (false) // removed by dead control flow
30733
30733
  /******/ if (cachedModule !== undefined) {
30734
30734
  /******/ return cachedModule.exports;
30735
30735
  /******/ }
30736
+ /******/ // Check if module exists (development only)
30737
+ /******/ if (__webpack_modules__[moduleId] === undefined) {
30738
+ /******/ var e = new Error("Cannot find module '" + moduleId + "'");
30739
+ /******/ e.code = 'MODULE_NOT_FOUND';
30740
+ /******/ throw e;
30741
+ /******/ }
30736
30742
  /******/ // Create a new module (and put it into the cache)
30737
30743
  /******/ var module = __webpack_module_cache__[moduleId] = {
30738
30744
  /******/ id: moduleId,