jsql-neo 6.5.0-beta.5 → 6.5.0-beta.6

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
@@ -3,7 +3,7 @@
3
3
  > **One engine to rule them all** — a Rust-powered embedded database that speaks your language:
4
4
  > MySQL, PostgreSQL, MongoDB, Redis, SQL, TypeScript, **and the browser**.
5
5
 
6
- > **v6.5.0-beta.5** — pre-release build · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
6
+ > **v6.5.0-beta.6** — pre-release build · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
7
7
 
8
8
  ![Engines](https://img.shields.io/badge/engines-Native%20%7C%20WASM%20%7C%20Pure%20JS-7ee787)
9
9
  ![MySQL](https://img.shields.io/badge/protocol-MySQL%20compatible-1f6feb)
package/bin/jsql CHANGED
@@ -8,8 +8,9 @@ const migrate = require('../lib/migrate');
8
8
  const { nag, setStarred, readConfig } = require('../lib/star-nag');
9
9
 
10
10
  // star 提示:任何异常都不该挡住命令本身
11
- // version 只回版本号、star 本身就是干这件事的 —— 这两个不提示,其余全部提示
12
- if (!process.env.JSQL_NO_STAR_NAG && !['version','star'].includes(process.argv[2])) {
11
+ // version / --version 只回版本号、star 本身就是干这件事的 —— 这些不提示,其余全部提示
12
+ const NO_NAG_ARGS = new Set(['version', '--version', '-v', 'star']);
13
+ if (!process.env.JSQL_NO_STAR_NAG && !NO_NAG_ARGS.has(process.argv[2])) {
13
14
  try { nag(); } catch (e) { /* 提示失败与命令无关 */ }
14
15
  }
15
16
 
@@ -190,7 +191,20 @@ const cli = yaggs({ pkg: require('../package.json') })
190
191
  const nonceUrl = sn.startOauthCheck(); // 打开浏览器 + 后台轮询写回 ~/.jsqlmr
191
192
  if (!process.stdout.isTTY) console.log(' ' + nonceUrl);
192
193
  console.log('After you authorize, this config is updated: ' + sn.configPath());
193
- console.log('Run `jsql star` again afterwards to see the result.');
194
+ console.log('Waiting for authorization (up to 3 minutes)…');
195
+ // startOauthCheck 的定时器是 unref 的,命令必须自己前台等,否则接不到结果
196
+ const res = sn.waitForResult(nonceUrl, 180000);
197
+ if (res && res.starred) {
198
+ sn.setStarred(true);
199
+ console.log(`Confirmed: ${res.login} has starred ${res.repo}. Thanks!`);
200
+ return;
201
+ }
202
+ if (res) {
203
+ console.log(`Authorization finished, but ${res.login} has not starred ${res.repo} yet.`);
204
+ console.log(`Star it at https://github.com/${res.repo} then run \`jsql star\` again.`);
205
+ return;
206
+ }
207
+ console.log('Timed out or the link expired. Run `jsql star` again to retry.');
194
208
  })
195
209
  .command('bench', 'Insert + query benchmark against a data directory', (sub) => {
196
210
  sub.option('n', { type: 'number', description: 'Number of rows (default 10000)' });
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * JSQL-NEO v6.5.0-beta.5 — Rust-Powered Embedded Database (WASM + HTTP)
2
+ * JSQL-NEO v6.5.0-beta.6 — Rust-Powered Embedded Database (WASM + HTTP)
3
3
  *
4
4
  * @example
5
5
  * const jsql = require('jsql-neo');
package/lib/star-nag.js CHANGED
@@ -204,4 +204,43 @@ function setStarred(v) {
204
204
  return cfg.starred;
205
205
  }
206
206
 
207
- module.exports = { nag, checkStarred, startOauthCheck, readConfig, setStarred, configPath, REPO, URL };
207
+ /**
208
+ * 同步阻塞轮询授权结果,直到拿到 done / expired 或超时。
209
+ *
210
+ * `jsql star` 用:startOauthCheck 的定时器是 unref 的(不能拖住别的命令),
211
+ * 所以 star 命令必须自己前台等,否则授权完成后 CLI 早已退出,结果没人接。
212
+ *
213
+ * @param {string} startUrl startOauthCheck 返回的 URL(含 nonce)
214
+ * @param {number} [timeoutMs] 最长等待时间,默认 180 秒
215
+ * @returns {object|null} result 对象(含 login/starred/repo),超时或失败返回 null
216
+ */
217
+ function waitForResult(startUrl, timeoutMs = 180000) {
218
+ const { execFileSync } = require('child_process');
219
+ // 注意:本模块顶部有 const URL = 'https://github.com/...' 会遮蔽全局 URL 类,
220
+ // 必须显式从 url 模块取,否则 new URL(...) 抛 TypeError
221
+ const { URL: NodeURL } = require('url');
222
+ let nonce = '';
223
+ try {
224
+ nonce = new NodeURL(startUrl).searchParams.get('nonce') || '';
225
+ } catch (e) {
226
+ return null;
227
+ }
228
+ if (!nonce) return null;
229
+
230
+ const deadline = Date.now() + timeoutMs;
231
+ while (Date.now() < deadline) {
232
+ try {
233
+ const out = execFileSync('curl', ['-sS', '-m', '5', AUTH_RESULT + '?nonce=' + nonce],
234
+ { stdio: ['ignore', 'pipe', 'ignore'], timeout: 8000, encoding: 'utf8' });
235
+ const j = JSON.parse(out);
236
+ if (j && j.state === 'done' && j.result) return j.result;
237
+ if (j && j.state === 'expired') return null;
238
+ } catch (e) {
239
+ // 网络抖动 / 超时 —— 继续等
240
+ }
241
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2000);
242
+ }
243
+ return null;
244
+ }
245
+
246
+ module.exports = { nag, checkStarred, startOauthCheck, waitForResult, readConfig, setStarred, configPath, REPO, URL };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsql-neo",
3
- "version": "6.5.0-beta.5",
3
+ "version": "6.5.0-beta.6",
4
4
  "description": "JSQL-NEO — Rust-powered embedded database with WASM, REST API, B-Tree indexes, WAL, crash recovery",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",