agent-notify 0.2.0 → 0.2.1

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/package.json +1 -1
  2. package/scripts/install.js +18 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-notify",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Agent notification tool with Feishu integration",
5
5
  "bin": {
6
6
  "agent-notify": "./bin/agent-notify.js"
@@ -29,6 +29,17 @@ function getBinaryDir() {
29
29
 
30
30
  const BINARY_DIR = getBinaryDir();
31
31
 
32
+ function getInstalledVersion(binaryPath) {
33
+ try {
34
+ const version = execSync(`"${binaryPath}" --version`, { encoding: 'utf8', timeout: 5000 }).trim();
35
+ // version output like: agent-notify version 0.1.0
36
+ const match = version.match(/(\d+\.\d+\.\d+)/);
37
+ return match ? match[1] : null;
38
+ } catch (e) {
39
+ return null;
40
+ }
41
+ }
42
+
32
43
  function getRemoteBinaryName(version) {
33
44
  const platform = os.platform();
34
45
  const arch = os.arch();
@@ -126,10 +137,14 @@ async function install() {
126
137
  const localBinaryName = getLocalBinaryName();
127
138
  const binaryPath = path.join(BINARY_DIR, localBinaryName);
128
139
 
129
- // Check if binary already exists
140
+ // Check if binary already exists with correct version
130
141
  if (fs.existsSync(binaryPath)) {
131
- console.log(`Binary already exists at ${binaryPath}`);
132
- return;
142
+ const installedVersion = getInstalledVersion(binaryPath);
143
+ if (installedVersion === PACKAGE_VERSION) {
144
+ console.log(`Binary already exists at ${binaryPath} (v${PACKAGE_VERSION})`);
145
+ return;
146
+ }
147
+ console.log(`Updating binary from v${installedVersion || 'unknown'} to v${PACKAGE_VERSION}...`);
133
148
  }
134
149
 
135
150
  // Create binary directory