@peng272/dsh-wechat-ilink 0.7.1 → 0.7.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.
- package/CHANGELOG.md +10 -0
- package/lib/index.js +20 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
15
15
|
> documentation this project has: every one of them was an assumed DSH contract
|
|
16
16
|
> that turned out to be wrong.
|
|
17
17
|
|
|
18
|
+
## [0.7.2]
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **The startup banner reported the wrong version.** `PLUGIN_VERSION` was a
|
|
23
|
+
hardcoded literal mirrored from `package.json`, and it drifted on the first
|
|
24
|
+
release that bumped the version: 0.7.1 was loaded while the banner said 0.7.0.
|
|
25
|
+
Since the banner is deliberately the way a loaded build is identified, that
|
|
26
|
+
defeats its purpose. The version is now read from this package's own
|
|
27
|
+
`package.json` at load, so it cannot drift again.
|
|
18
28
|
## [0.7.1]
|
|
19
29
|
|
|
20
30
|
### Fixed
|
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import fs from 'node:fs'
|
|
|
16
16
|
import path from 'node:path'
|
|
17
17
|
import { spawn } from 'node:child_process'
|
|
18
18
|
import { randomUUID } from 'node:crypto'
|
|
19
|
+
import { fileURLToPath } from 'node:url'
|
|
19
20
|
|
|
20
21
|
import { AccountStore, resolveStateDir } from './accounts.js'
|
|
21
22
|
import { ILinkClient, QrLoginManager, DEFAULT_BASE_URL, renderQrPng } from './ilink.js'
|
|
@@ -24,8 +25,25 @@ import { Config } from './schema.js'
|
|
|
24
25
|
|
|
25
26
|
export const name = 'wechat-clawbot'
|
|
26
27
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Plugin version, read from this package's own `package.json`.
|
|
30
|
+
*
|
|
31
|
+
* This used to be a hardcoded literal mirrored from package.json, and it drifted
|
|
32
|
+
* on the very first release that bumped the version — the banner advertised
|
|
33
|
+
* 0.7.0 while 0.7.1 was loaded, which defeats the point of having a banner.
|
|
34
|
+
* Reading the file costs one synchronous read at load and cannot drift.
|
|
35
|
+
*/
|
|
36
|
+
function readOwnVersion() {
|
|
37
|
+
try {
|
|
38
|
+
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
39
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(here, '..', 'package.json'), 'utf-8'))
|
|
40
|
+
return typeof pkg.version === 'string' && pkg.version ? pkg.version : '0.0.0'
|
|
41
|
+
} catch {
|
|
42
|
+
return '0.0.0'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const PLUGIN_VERSION = readOwnVersion()
|
|
29
47
|
|
|
30
48
|
/**
|
|
31
49
|
* Services this plugin requires before it activates.
|
package/package.json
CHANGED