@twinsearth/w2m-dsh-plugin 0.8.9 → 0.8.11
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 +122 -0
- package/bin/w2m-localside.mjs +325 -325
- package/bin/w2m-rabbit.mjs +0 -0
- package/bin/w2m-stun.mjs +0 -0
- package/package.json +20 -19
- package/src/chatops/account.mjs +430 -399
- package/src/chatops/index.mjs +440 -440
- package/src/plugin/auto-update.mjs +31 -2
- package/src/plugin/tools.mjs +5207 -4878
- package/src/relay/state.mjs +2277 -2277
|
@@ -58,6 +58,19 @@ export const DEFAULT_HISTORY_LIMIT = 50;
|
|
|
58
58
|
/** Default interval between two full checks, in days. */
|
|
59
59
|
export const DEFAULT_INTERVAL_DAYS = 1;
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* A value shaped like a build-time placeholder rather than a version.
|
|
63
|
+
*
|
|
64
|
+
* `__W2M_PLUGIN_VERSION__` is substituted by `scripts/pack.mjs`, but `pnpm publish` packs the source
|
|
65
|
+
* tree directly and never runs that script -- so every npm release has shipped the literal
|
|
66
|
+
* placeholder, in 0.8.8, 0.8.9 and 0.8.10.
|
|
67
|
+
*
|
|
68
|
+
* Recognised by **shape**, not by the one string: matching a single literal would leave the next
|
|
69
|
+
* placeholder name free to reintroduce the same defect. Anything that is not made of version-ish
|
|
70
|
+
* characters is not a version.
|
|
71
|
+
*/
|
|
72
|
+
const VERSION_SHAPE = /^[0-9A-Za-z.\-+]+$/;
|
|
73
|
+
|
|
61
74
|
/**
|
|
62
75
|
* Read the running plugin's version.
|
|
63
76
|
*
|
|
@@ -65,14 +78,30 @@ export const DEFAULT_INTERVAL_DAYS = 1;
|
|
|
65
78
|
* and packagers can pin it. Returns `null` when unknown -- callers must treat
|
|
66
79
|
* that as "cannot decide", never as "old".
|
|
67
80
|
*
|
|
81
|
+
* ## Why a placeholder is "unknown" and not a version
|
|
82
|
+
*
|
|
83
|
+
* The contract above was documented and not implemented: the guard rejected only the empty string,
|
|
84
|
+
* so `__W2M_PLUGIN_VERSION__` passed through as a valid version. The consequence is not cosmetic --
|
|
85
|
+
* the auto-updater's whole job is comparing the installed version against releases, so an
|
|
86
|
+
* npm-installed machine ran an updater whose input was not a version, and `w2m_update` reported
|
|
87
|
+
* `current_version: "__W2M_PLUGIN_VERSION__"`.
|
|
88
|
+
*
|
|
89
|
+
* Treating it as unknown is the **documented** behaviour and it fails safe: the updater declines to
|
|
90
|
+
* decide instead of comparing nonsense. Fixing it here rather than only in the pack step covers
|
|
91
|
+
* every channel, including ones not yet thought of.
|
|
92
|
+
*
|
|
68
93
|
* @param {string} bundledVersion - Version from the caller's own package.json.
|
|
69
94
|
* @param {NodeJS.ProcessEnv} [env]
|
|
70
95
|
* @returns {string|null} The version, or null when unknown.
|
|
71
96
|
*/
|
|
72
97
|
export function resolveCurrentVersion(bundledVersion, env = process.env) {
|
|
73
98
|
const fromEnv = typeof env?.[PKG_VERSION_ENV] === 'string' ? env[PKG_VERSION_ENV].trim() : '';
|
|
74
|
-
if (fromEnv !== '') return fromEnv;
|
|
75
|
-
|
|
99
|
+
if (fromEnv !== '') return VERSION_SHAPE.test(fromEnv) ? fromEnv : null;
|
|
100
|
+
if (typeof bundledVersion !== 'string') return null;
|
|
101
|
+
const trimmed = bundledVersion.trim();
|
|
102
|
+
if (trimmed === '') return null;
|
|
103
|
+
// A placeholder is not a version. Underscores are the tell, and they never appear in a semver.
|
|
104
|
+
return VERSION_SHAPE.test(trimmed) ? trimmed : null;
|
|
76
105
|
}
|
|
77
106
|
|
|
78
107
|
/**
|