@flowscripter/dynamic-cli-framework 3.0.1 → 3.0.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultUpgradeService.d.ts","sourceRoot":"","sources":["../../../../src/service/upgrade/DefaultUpgradeService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EAEZ,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACd,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,EACX,KAAK,cAAc,EACpB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"DefaultUpgradeService.d.ts","sourceRoot":"","sources":["../../../../src/service/upgrade/DefaultUpgradeService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EAEZ,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACd,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,aAAa,EACb,aAAa,EACb,WAAW,EACX,KAAK,cAAc,EACpB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAS1E,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAc5C,MAAM,CAAC,OAAO,OAAO,qBAAsB,YAAW,cAAc;;gBAO/C,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,SAAS;IAKhE,eAAe,CACpB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,YAAY,EAAE,YAAY,GAAG,SAAS,GACrC,IAAI;IAKA,qBAAqB,CAAC,aAAa,UAAQ,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;IA0BrF,QAAQ,IAAI,WAAW,GAAG,SAAS;IAanC,UAAU,IAAI,aAAa,GAAG,SAAS;IAWjC,mBAAmB,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAgBxE,eAAe,CAC1B,UAAU,CAAC,EAAE,WAAW,EACxB,YAAY,CAAC,EAAE,aAAa,EAC5B,qBAAqB,CAAC,EAAE,aAAa,GACpC,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;IAmC7B,OAAO,CAClB,UAAU,CAAC,EAAE,WAAW,EACxB,YAAY,CAAC,EAAE,aAAa,EAC5B,qBAAqB,CAAC,EAAE,aAAa,GACpC,OAAO,CAAC,aAAa,CAAC;CAoQ1B"}
|
|
@@ -7,7 +7,9 @@ import semver from "semver";
|
|
|
7
7
|
import getLogger from "../../util/logger.js";
|
|
8
8
|
const logger = getLogger("DefaultUpgradeService");
|
|
9
9
|
// checkForUpgrade() runs opportunistically on every CLI invocation (via BannerServiceProvider),
|
|
10
|
-
// so
|
|
10
|
+
// so that opportunistic call is raced against this timeout so it never stalls CLI startup.
|
|
11
|
+
// A deliberate caller (waitForResult=true, e.g. the `upgrade` command) awaits checkForUpgrade()
|
|
12
|
+
// directly with no timeout, so its underlying network/spawn calls are never artificially cut off.
|
|
11
13
|
export const VERSION_CHECK_TIMEOUT_MS = 250;
|
|
12
14
|
function describeSpawnFailure(result) {
|
|
13
15
|
return "timedOut" in result
|
|
@@ -36,10 +38,11 @@ export default class DefaultUpgradeService {
|
|
|
36
38
|
getUpgradeCheckResult(waitForResult = false) {
|
|
37
39
|
if (!this.#upgradeCheckPromise) {
|
|
38
40
|
// Only cache a successful result. An `undefined` result can come from a transient
|
|
39
|
-
// failure (e.g. the opportunistic startup check
|
|
40
|
-
//
|
|
41
|
-
// caller (e.g. the `upgrade` command explicitly waiting via
|
|
42
|
-
// chance of a fresh attempt for the rest of this process's
|
|
41
|
+
// failure (e.g. the opportunistic startup check racing past VERSION_CHECK_TIMEOUT_MS
|
|
42
|
+
// before checkForUpgrade() itself resolves) - caching that would permanently deny a
|
|
43
|
+
// later, deliberate caller (e.g. the `upgrade` command explicitly waiting via
|
|
44
|
+
// waitForResult=true) any chance of a fresh attempt for the rest of this process's
|
|
45
|
+
// lifetime.
|
|
43
46
|
this.#upgradeCheckPromise = this.checkForUpgrade().then((result) => {
|
|
44
47
|
if (result === undefined) {
|
|
45
48
|
this.#upgradeCheckPromise = undefined;
|
|
@@ -169,14 +172,14 @@ export default class DefaultUpgradeService {
|
|
|
169
172
|
if (!this.#spawnService || !this.#config.homebrew) {
|
|
170
173
|
return false;
|
|
171
174
|
}
|
|
172
|
-
const result = await this.#spawnService.spawn(["brew", "list", "--versions", this.#config.homebrew.formula], { mode: "ignore", longRunning: false
|
|
175
|
+
const result = await this.#spawnService.spawn(["brew", "list", "--versions", this.#config.homebrew.formula], { mode: "ignore", longRunning: false });
|
|
173
176
|
return result.ok;
|
|
174
177
|
}
|
|
175
178
|
async #isWingetInstalled() {
|
|
176
179
|
if (!this.#spawnService || !this.#config.winget) {
|
|
177
180
|
return false;
|
|
178
181
|
}
|
|
179
|
-
const result = await this.#spawnService.spawn(["winget", "list", "--id", this.#config.winget.packageId], { mode: "ignore", longRunning: false
|
|
182
|
+
const result = await this.#spawnService.spawn(["winget", "list", "--id", this.#config.winget.packageId], { mode: "ignore", longRunning: false });
|
|
180
183
|
return result.ok;
|
|
181
184
|
}
|
|
182
185
|
#isLinuxScriptInstall() {
|
|
@@ -201,7 +204,7 @@ export default class DefaultUpgradeService {
|
|
|
201
204
|
}
|
|
202
205
|
const { owner, repo } = this.#config.githubRelease;
|
|
203
206
|
try {
|
|
204
|
-
const response = await this.#fetchService.fetch(`https://api.github.com/repos/${owner}/${repo}/releases/latest
|
|
207
|
+
const response = await this.#fetchService.fetch(`https://api.github.com/repos/${owner}/${repo}/releases/latest`);
|
|
205
208
|
if (!response.ok) {
|
|
206
209
|
return undefined;
|
|
207
210
|
}
|
|
@@ -223,7 +226,7 @@ export default class DefaultUpgradeService {
|
|
|
223
226
|
return undefined;
|
|
224
227
|
}
|
|
225
228
|
try {
|
|
226
|
-
const response = await this.#fetchService.fetch(`https://raw.githubusercontent.com/${tapOwner}/homebrew-${tapName}/main/${formula}.rb
|
|
229
|
+
const response = await this.#fetchService.fetch(`https://raw.githubusercontent.com/${tapOwner}/homebrew-${tapName}/main/${formula}.rb`);
|
|
227
230
|
if (!response.ok) {
|
|
228
231
|
return undefined;
|
|
229
232
|
}
|
|
@@ -243,7 +246,6 @@ export default class DefaultUpgradeService {
|
|
|
243
246
|
const result = await this.#spawnService.spawn(["winget", "show", "--id", this.#config.winget.packageId], {
|
|
244
247
|
mode: "wrapped",
|
|
245
248
|
longRunning: false,
|
|
246
|
-
timeoutMs: VERSION_CHECK_TIMEOUT_MS,
|
|
247
249
|
onOutput: (line) => lines.push(line),
|
|
248
250
|
});
|
|
249
251
|
if (!result.ok) {
|
package/package.json
CHANGED
|
@@ -23,7 +23,9 @@ import getLogger from "../../util/logger.ts";
|
|
|
23
23
|
const logger = getLogger("DefaultUpgradeService");
|
|
24
24
|
|
|
25
25
|
// checkForUpgrade() runs opportunistically on every CLI invocation (via BannerServiceProvider),
|
|
26
|
-
// so
|
|
26
|
+
// so that opportunistic call is raced against this timeout so it never stalls CLI startup.
|
|
27
|
+
// A deliberate caller (waitForResult=true, e.g. the `upgrade` command) awaits checkForUpgrade()
|
|
28
|
+
// directly with no timeout, so its underlying network/spawn calls are never artificially cut off.
|
|
27
29
|
export const VERSION_CHECK_TIMEOUT_MS = 250;
|
|
28
30
|
|
|
29
31
|
function describeSpawnFailure(result: Extract<SpawnResult, { ok: false }>): string {
|
|
@@ -61,10 +63,11 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
61
63
|
public getUpgradeCheckResult(waitForResult = false): Promise<UpgradeCheckResult | undefined> {
|
|
62
64
|
if (!this.#upgradeCheckPromise) {
|
|
63
65
|
// Only cache a successful result. An `undefined` result can come from a transient
|
|
64
|
-
// failure (e.g. the opportunistic startup check
|
|
65
|
-
//
|
|
66
|
-
// caller (e.g. the `upgrade` command explicitly waiting via
|
|
67
|
-
// chance of a fresh attempt for the rest of this process's
|
|
66
|
+
// failure (e.g. the opportunistic startup check racing past VERSION_CHECK_TIMEOUT_MS
|
|
67
|
+
// before checkForUpgrade() itself resolves) - caching that would permanently deny a
|
|
68
|
+
// later, deliberate caller (e.g. the `upgrade` command explicitly waiting via
|
|
69
|
+
// waitForResult=true) any chance of a fresh attempt for the rest of this process's
|
|
70
|
+
// lifetime.
|
|
68
71
|
this.#upgradeCheckPromise = this.checkForUpgrade().then((result) => {
|
|
69
72
|
if (result === undefined) {
|
|
70
73
|
this.#upgradeCheckPromise = undefined;
|
|
@@ -220,7 +223,7 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
220
223
|
}
|
|
221
224
|
const result = await this.#spawnService.spawn(
|
|
222
225
|
["brew", "list", "--versions", this.#config.homebrew.formula],
|
|
223
|
-
{ mode: "ignore", longRunning: false
|
|
226
|
+
{ mode: "ignore", longRunning: false },
|
|
224
227
|
);
|
|
225
228
|
return result.ok;
|
|
226
229
|
}
|
|
@@ -231,7 +234,7 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
231
234
|
}
|
|
232
235
|
const result = await this.#spawnService.spawn(
|
|
233
236
|
["winget", "list", "--id", this.#config.winget.packageId],
|
|
234
|
-
{ mode: "ignore", longRunning: false
|
|
237
|
+
{ mode: "ignore", longRunning: false },
|
|
235
238
|
);
|
|
236
239
|
return result.ok;
|
|
237
240
|
}
|
|
@@ -262,7 +265,6 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
262
265
|
try {
|
|
263
266
|
const response = await this.#fetchService.fetch(
|
|
264
267
|
`https://api.github.com/repos/${owner}/${repo}/releases/latest`,
|
|
265
|
-
{ timeoutMs: VERSION_CHECK_TIMEOUT_MS },
|
|
266
268
|
);
|
|
267
269
|
if (!response.ok) {
|
|
268
270
|
return undefined;
|
|
@@ -287,7 +289,6 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
287
289
|
try {
|
|
288
290
|
const response = await this.#fetchService.fetch(
|
|
289
291
|
`https://raw.githubusercontent.com/${tapOwner}/homebrew-${tapName}/main/${formula}.rb`,
|
|
290
|
-
{ timeoutMs: VERSION_CHECK_TIMEOUT_MS },
|
|
291
292
|
);
|
|
292
293
|
if (!response.ok) {
|
|
293
294
|
return undefined;
|
|
@@ -310,7 +311,6 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
310
311
|
{
|
|
311
312
|
mode: "wrapped",
|
|
312
313
|
longRunning: false,
|
|
313
|
-
timeoutMs: VERSION_CHECK_TIMEOUT_MS,
|
|
314
314
|
onOutput: (line) => lines.push(line),
|
|
315
315
|
},
|
|
316
316
|
);
|