@faable/faable 4.5.3 → 4.5.5
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/dist/api/FaableApi.js
CHANGED
|
@@ -130,12 +130,19 @@ class FaableApi {
|
|
|
130
130
|
async issueAuthAccountToken(account_id) {
|
|
131
131
|
return data(this.client.post(`/auth-accounts/${account_id}/token`));
|
|
132
132
|
}
|
|
133
|
-
// Every app the caller can see, across projects
|
|
134
|
-
//
|
|
135
|
-
// app lives outside the active project must still resolve.
|
|
133
|
+
// Every app the caller can see, across projects (`faable link` offers them
|
|
134
|
+
// to pick from).
|
|
136
135
|
async list() {
|
|
137
136
|
return allPages(next => this.listApps({ pageSize: 200, next }, null));
|
|
138
137
|
}
|
|
138
|
+
// The apps linked to `repository` (the `org/repo` slug), across projects —
|
|
139
|
+
// filtered (and indexed) server side, so a staff session doesn't page
|
|
140
|
+
// through the whole platform to match one repository.
|
|
141
|
+
async appsByRepository(repository) {
|
|
142
|
+
return allPages(next => data(this.client.get(`/app`, {
|
|
143
|
+
params: { repository, ...page_params({ pageSize: 200, next }) }
|
|
144
|
+
})));
|
|
145
|
+
}
|
|
139
146
|
// One page of apps, scoped to `project` (default: the active project).
|
|
140
147
|
// `null` = unscoped. The api filters by the header, so an admin session
|
|
141
148
|
// doesn't page through the whole platform.
|
|
@@ -57,8 +57,7 @@ const find_app_id = async (explicit, ctxAppId, api, workdir = process.cwd()) =>
|
|
|
57
57
|
return app_id;
|
|
58
58
|
const repository = await getGitRemoteUrl(workdir);
|
|
59
59
|
if (repository) {
|
|
60
|
-
const
|
|
61
|
-
const matches = apps.filter(app => app.repository === repository);
|
|
60
|
+
const matches = await api.appsByRepository(repository);
|
|
62
61
|
if (matches.length === 1) {
|
|
63
62
|
const app = matches[0];
|
|
64
63
|
log.info(`🔎 Detected app "${app.name}" (${app.id}) from repository ${repository}`);
|
|
@@ -23,12 +23,12 @@ const upgrade = {
|
|
|
23
23
|
}
|
|
24
24
|
const spinner = ora(`Upgrading ${CLI_PACKAGE} ${version} → ${latest}`).start();
|
|
25
25
|
try {
|
|
26
|
-
await cmd(`npm install -g ${CLI_PACKAGE}@latest`, { timeout: 180_000 });
|
|
26
|
+
await cmd(`npm install -g --prefer-online ${CLI_PACKAGE}@latest`, { timeout: 180_000 });
|
|
27
27
|
spinner.succeed(`Upgraded to ${latest}`);
|
|
28
28
|
}
|
|
29
29
|
catch {
|
|
30
30
|
spinner.fail("Upgrade failed");
|
|
31
|
-
log.error(`❌ Could not upgrade automatically. Try manually: npm install -g ${CLI_PACKAGE}@latest`);
|
|
31
|
+
log.error(`❌ Could not upgrade automatically. Try manually: npm install -g --prefer-online ${CLI_PACKAGE}@latest`);
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
34
|
},
|
|
@@ -6,6 +6,7 @@ import { log } from '../log.js';
|
|
|
6
6
|
|
|
7
7
|
const CLI_PACKAGE = "@faable/faable";
|
|
8
8
|
const REGISTRY_URL = `https://registry.npmjs.org/${CLI_PACKAGE}/latest`;
|
|
9
|
+
const PACKUMENT_URL = `https://registry.npmjs.org/${CLI_PACKAGE.replace("/", "%2f")}`;
|
|
9
10
|
// Hitting the registry at most once a day keeps the background refresh rare.
|
|
10
11
|
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
11
12
|
const UPGRADE_FETCH_TIMEOUT_MS = 10_000;
|
|
@@ -77,16 +78,21 @@ const spawnBackgroundRefresh = () => {
|
|
|
77
78
|
*/
|
|
78
79
|
const getLatestVersion = async () => {
|
|
79
80
|
try {
|
|
80
|
-
|
|
81
|
+
// The same (abbreviated) packument `npm install` resolves against, not
|
|
82
|
+
// `/latest`: for a few minutes after a release the two endpoints
|
|
83
|
+
// disagree, and offering a version npm can't find yet ends in ETARGET.
|
|
84
|
+
const res = await fetch(PACKUMENT_URL, {
|
|
85
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" },
|
|
81
86
|
signal: AbortSignal.timeout(UPGRADE_FETCH_TIMEOUT_MS),
|
|
82
87
|
});
|
|
83
88
|
if (!res.ok)
|
|
84
89
|
return;
|
|
85
90
|
const data = (await res.json());
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
const version = data["dist-tags"]?.latest;
|
|
92
|
+
if (version) {
|
|
93
|
+
await writeCache({ last_check: new Date().toISOString(), latest: version });
|
|
88
94
|
}
|
|
89
|
-
return
|
|
95
|
+
return version;
|
|
90
96
|
}
|
|
91
97
|
catch {
|
|
92
98
|
return;
|