dsh-github-hot 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/lib/index.js +15 -1
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -39,6 +39,7 @@
39
39
 
40
40
  import { createHash, randomUUID } from 'node:crypto';
41
41
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
42
+ import { createRequire } from 'node:module';
42
43
  import { homedir } from 'node:os';
43
44
  import { join } from 'node:path';
44
45
  import { pathToFileURL } from 'node:url';
@@ -49,7 +50,20 @@ export const name = 'dsh-github-hot';
49
50
  /** 硬依赖:只要 webServer(提供路由)。 */
50
51
  export const inject = ['webServer'];
51
52
 
52
- const VERSION = '0.1.0';
53
+ /**
54
+ * 版本号:从 package.json 读,**不要在这里写死**。
55
+ *
56
+ * 写死的话每次发版都要记得改两处,漏改就会让 /status 报旧版本
57
+ * (用户排查问题时会被误导)。这里用 createRequire 读同包的 manifest。
58
+ */
59
+ const VERSION = (() => {
60
+ try {
61
+ const require = createRequire(import.meta.url);
62
+ return require('../package.json').version || '0.0.0';
63
+ } catch {
64
+ return '0.0.0';
65
+ }
66
+ })();
53
67
  const ROUTE_PREFIX = '/dsh-github-hot';
54
68
 
55
69
  const BASE = 'https://hysenlabs.com';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-github-hot",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "DSH GitHub 涨星榜插件:日/周/月三榜切换,展示每期涨星 TOP20。卡片流榜单,每个项目带独立中文简介、星数曲线趋势图与多项目走势对比。",
5
5
  "keywords": [
6
6
  "dsh",