@oclif/plugin-update 4.7.52 → 4.7.54

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
@@ -81,7 +81,7 @@ EXAMPLES
81
81
  $ oclif-example update --available
82
82
  ```
83
83
 
84
- _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/4.7.52/src/commands/update.ts)_
84
+ _See code: [src/commands/update.ts](https://github.com/oclif/plugin-update/blob/4.7.54/src/commands/update.ts)_
85
85
  <!-- commandsstop -->
86
86
 
87
87
  # Contributing
package/dist/update.d.ts CHANGED
@@ -18,6 +18,7 @@ export declare class Updater {
18
18
  private fetchVersionManifest;
19
19
  private findLocalVersion;
20
20
  private refreshConfig;
21
+ private resolveActiveDir;
21
22
  private tidy;
22
23
  private touch;
23
24
  private update;
package/dist/update.js CHANGED
@@ -171,6 +171,23 @@ get_script_dir () {
171
171
  async refreshConfig(version) {
172
172
  this.config = await Config.load({ root: join(this.clientRoot, version) });
173
173
  }
174
+ // Resolves the absolute path of the active install directory. Installed
175
+ // directories are named "<version>-<sha>", but `this.config.version` is plain
176
+ // semver, so match by exact name or "<version>-" prefix. Falls back to the
177
+ // bare version path when no match exists.
178
+ async resolveActiveDir() {
179
+ const { version } = this.config;
180
+ try {
181
+ const entries = await readdir(this.clientRoot);
182
+ const match = entries.find((entry) => entry === version || entry.startsWith(`${version}-`));
183
+ if (match)
184
+ return join(this.clientRoot, match);
185
+ }
186
+ catch {
187
+ // fall through to bare version path
188
+ }
189
+ return join(this.clientRoot, version);
190
+ }
174
191
  // removes any unused CLIs
175
192
  async tidy() {
176
193
  debug('tidy');
@@ -179,7 +196,16 @@ get_script_dir () {
179
196
  if (!existsSync(root))
180
197
  return;
181
198
  const files = await ls(root);
182
- const isNotSpecial = (fPath, version) => !['bin', 'current', version].includes(basename(fPath));
199
+ // `version` is plain semver (e.g. "1.2.3") but installed directories are
200
+ // named "<version>-<sha>" (e.g. "1.2.3-abc1234"). Protect both forms so
201
+ // the active CLI never deletes itself. See #1361.
202
+ const isNotSpecial = (fPath, version) => {
203
+ const name = basename(fPath);
204
+ if (name === 'bin' || name === 'current')
205
+ return false;
206
+ // "1.2.3" or "1.2.3-abc1234" both start from `version`
207
+ return !(name === version || name.startsWith(`${version}-`));
208
+ };
183
209
  const isOld = (fStat) => {
184
210
  const { mtime } = fStat;
185
211
  mtime.setHours(mtime.getHours() + 42 * 24);
@@ -196,7 +222,12 @@ get_script_dir () {
196
222
  async touch() {
197
223
  // touch the client so it won't be tidied up right away
198
224
  try {
199
- const p = join(this.clientRoot, this.config.version);
225
+ // `this.config.version` is plain semver, but the installed directory is
226
+ // named "<version>-<sha>", so joining the bare version would point at a
227
+ // non-existent path and silently no-op. Resolve the real directory the
228
+ // same way tidy()'s guard does so the active install's mtime is refreshed
229
+ // and it isn't considered "old". See #1361.
230
+ const p = await this.resolveActiveDir();
200
231
  debug('touching client at', p);
201
232
  if (!existsSync(p))
202
233
  return;
@@ -106,5 +106,5 @@
106
106
  ]
107
107
  }
108
108
  },
109
- "version": "4.7.52"
109
+ "version": "4.7.54"
110
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oclif/plugin-update",
3
- "version": "4.7.52",
3
+ "version": "4.7.54",
4
4
  "author": "Salesforce",
5
5
  "bugs": "https://github.com/oclif/plugin-update/issues",
6
6
  "dependencies": {
@@ -13,7 +13,7 @@
13
13
  "got": "^13",
14
14
  "proxy-agent": "^6.5.0",
15
15
  "semver": "^7.8.5",
16
- "tar-fs": "^2.1.4"
16
+ "tar-fs": "^2.1.5"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@commitlint/config-conventional": "^19",
@@ -31,14 +31,14 @@
31
31
  "chai": "^4.5.0",
32
32
  "commitlint": "^19",
33
33
  "eslint": "^9.39.4",
34
- "eslint-config-oclif": "^6.0.171",
34
+ "eslint-config-oclif": "^6.0.173",
35
35
  "eslint-config-prettier": "^10.1.8",
36
36
  "husky": "^9.1.7",
37
37
  "lint-staged": "^15",
38
38
  "mocha": "^11",
39
39
  "nock": "^13.5.6",
40
40
  "oclif": "^4",
41
- "prettier": "^3.8.4",
41
+ "prettier": "^3.9.1",
42
42
  "shx": "^0.4.0",
43
43
  "sinon": "^18.0.1",
44
44
  "strip-ansi": "^7.2.0",