xshell 1.0.70 → 1.0.72

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
@@ -25,7 +25,10 @@ export declare class Git {
25
25
  hash: string;
26
26
  message: string;
27
27
  }[]>;
28
- fetch(print?: boolean): Promise<void>;
28
+ fetch({ print, remote }?: {
29
+ print?: boolean;
30
+ remote?: string;
31
+ }): Promise<void>;
29
32
  /** - branch?: `'main'` */
30
33
  checkout(branch?: 'main'): Promise<void>;
31
34
  checkout(branch?: string): Promise<void>;
@@ -45,4 +48,6 @@ export declare class Git {
45
48
  update(branch?: 'main'): Promise<void>;
46
49
  update(branch: string): Promise<void>;
47
50
  update(branch: string, remote?: string): Promise<void>;
51
+ /** - message?: stash description */
52
+ stash(message?: string): Promise<import("./process.js").CallResult<string>>;
48
53
  }
package/git.js CHANGED
@@ -76,8 +76,12 @@ export class Git {
76
76
  };
77
77
  });
78
78
  }
79
- async fetch(print = true) {
80
- await this.call(['fetch', '--all', '--prune'], { print: { code: false, command: false, stdout: true, stderr: true } });
79
+ async fetch({ print = true, remote } = {}) {
80
+ await this.call([
81
+ 'fetch',
82
+ remote || '--all',
83
+ '--prune'
84
+ ], { print: { code: false, command: false, stdout: true, stderr: true } });
81
85
  if (print)
82
86
  console.log('更新远程分支成功');
83
87
  }
@@ -152,10 +156,18 @@ export class Git {
152
156
  await this.checkout(target_branch);
153
157
  await this.merge(branch, true);
154
158
  }
155
- async update(branch = 'main', remote = 'origin') {
156
- await this.fetch();
159
+ async update(branch = 'main', remote) {
160
+ await this.fetch({ remote });
157
161
  await this.checkout(branch);
158
- await this.merge(`${remote}/${branch}`);
162
+ await this.merge(`${remote || 'origin'}/${branch}`);
163
+ }
164
+ /** - message?: stash description */
165
+ async stash(message) {
166
+ return this.call([
167
+ 'stash',
168
+ 'push',
169
+ ...message ? ['--message', message] : [],
170
+ ]);
159
171
  }
160
172
  }
161
173
  //# sourceMappingURL=git.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/repl.js CHANGED
@@ -31,6 +31,7 @@ export async function start_repl() {
31
31
  let { Server } = await import('./server.js');
32
32
  server = new Server({
33
33
  name: 'repl',
34
+ http: true,
34
35
  http_port: 8421,
35
36
  funcs: {
36
37
  echo({ data: [data] }) {
package/server.d.ts CHANGED
@@ -35,6 +35,10 @@ export declare class Server {
35
35
  js_exts: Set<string>;
36
36
  app: Koa;
37
37
  handler: ReturnType<Koa['callback']>;
38
+ /** 启用 http server */
39
+ http: boolean;
40
+ /** 启用 http2 server */
41
+ http2: boolean;
38
42
  http_port: number;
39
43
  http2_port: number;
40
44
  /** http2 server 证书文件夹路径,设置后才会启用 http2 server */
@@ -55,8 +59,10 @@ export declare class Server {
55
59
  stdout_write: Function;
56
60
  stderr_write: Function;
57
61
  encoder: TextEncoder;
58
- constructor({ name, http_port, http2_port, fpd_certs, default_hostnames, remote, funcs, stdio_subscribable, }: {
62
+ constructor({ name, http, http2, http_port, http2_port, fpd_certs, default_hostnames, remote, funcs, stdio_subscribable, }: {
59
63
  name: string;
64
+ http?: boolean;
65
+ http2?: boolean;
60
66
  http_port?: number;
61
67
  http2_port?: number;
62
68
  fpd_certs?: string;
package/server.js CHANGED
@@ -26,6 +26,10 @@ export class Server {
26
26
  js_exts = new Set(['.js', '.mjs', '.cjs']);
27
27
  app;
28
28
  handler;
29
+ /** 启用 http server */
30
+ http = false;
31
+ /** 启用 http2 server */
32
+ http2 = false;
29
33
  http_port = 80;
30
34
  http2_port = 443;
31
35
  /** http2 server 证书文件夹路径,设置后才会启用 http2 server */
@@ -44,8 +48,13 @@ export class Server {
44
48
  stdout_write;
45
49
  stderr_write;
46
50
  encoder = new TextEncoder();
47
- constructor({ name, http_port, http2_port, fpd_certs, default_hostnames, remote, funcs, stdio_subscribable, }) {
51
+ constructor({ name, http, http2, http_port, http2_port, fpd_certs, default_hostnames, remote, funcs, stdio_subscribable, }) {
48
52
  this.name = name;
53
+ if (http)
54
+ this.http = http;
55
+ if (http2)
56
+ this.http2 = http2;
57
+ assert(this.http || this.http2, 'http 和 http2 至少启用一个');
49
58
  if (http_port !== undefined)
50
59
  this.http_port = http_port;
51
60
  if (http2_port !== undefined)
@@ -95,8 +104,9 @@ export class Server {
95
104
  this.app = app;
96
105
  this.handler = this.app.callback();
97
106
  this.http_server = http_create_server(this.handler);
98
- const { fpd_certs } = this;
99
- if (fpd_certs) {
107
+ const { http, http2 } = this;
108
+ if (http2) {
109
+ const { fpd_certs } = this;
100
110
  let lazy_secure_ctxs = Object.fromEntries(await Promise.all(
101
111
  // fpd_certs 文件夹下面的每个 .key 对应一个证书及域名
102
112
  (await flist(fpd_certs, { print: false, filter: /\.key$/ }))
@@ -196,16 +206,19 @@ export class Server {
196
206
  }
197
207
  }
198
208
  await Promise.all([
199
- new Promise(resolve => {
209
+ http && new Promise(resolve => {
200
210
  this.http_server.listen(this.http_port, resolve);
201
211
  }),
202
- fpd_certs && new Promise(resolve => {
212
+ http2 && new Promise(resolve => {
203
213
  this.http2_server.listen(this.http2_port, resolve);
204
214
  }),
205
215
  ]);
206
216
  console.log(t('{{name}} 启动成功,正在监听 {{ports}} 端口', {
207
217
  name: this.name,
208
- ports: `${this.http_port}${fpd_certs ? `, ${this.http2_port}` : ''}`
218
+ ports: [
219
+ ...http ? [this.http_port] : [],
220
+ ...http2 ? [this.http2_port] : []
221
+ ].join(', ')
209
222
  }));
210
223
  }
211
224
  stop() {