@faable/faable 4.5.2 → 4.5.3
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
|
@@ -293,9 +293,10 @@ class FaableApi {
|
|
|
293
293
|
async listDomains(app_id, team) {
|
|
294
294
|
return firstPage(this.listDomainsPage(app_id, team));
|
|
295
295
|
}
|
|
296
|
+
// Without `app_id`, every domain of the project.
|
|
296
297
|
async listDomainsPage(app_id, team, params = {}) {
|
|
297
298
|
return data(this.client.get(`/domain`, {
|
|
298
|
-
params: { app_id, ...page_params(params) },
|
|
299
|
+
params: { ...(app_id ? { app_id } : {}), ...page_params(params) },
|
|
299
300
|
headers: projectHeader(team)
|
|
300
301
|
}));
|
|
301
302
|
}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { requireApi } from '../../../api/context.js';
|
|
2
2
|
import { fetch_page, print_json, print, more_hint, list_options } from '../../../lib/listing.js';
|
|
3
3
|
import { log } from '../../../log.js';
|
|
4
|
-
import {
|
|
4
|
+
import { requireProject } from '../../../api/project.js';
|
|
5
|
+
import { find_app_id } from '../resolve_app_id.js';
|
|
5
6
|
import { dns_badge, cname_target } from './format.js';
|
|
6
7
|
|
|
7
8
|
const domains_list = {
|
|
8
9
|
command: 'list',
|
|
9
|
-
describe: 'List custom domains of the app',
|
|
10
|
+
describe: 'List custom domains of the app (or of the project, outside a linked repo)',
|
|
10
11
|
builder: yargs => list_options(yargs)
|
|
11
12
|
.option('app', {
|
|
12
13
|
alias: 'a',
|
|
13
14
|
type: 'string',
|
|
14
15
|
description: 'App id, name or slug (defaults to the linked app)'
|
|
15
16
|
})
|
|
16
|
-
.example('$0 deploy domains list', 'Domains of the linked app')
|
|
17
|
+
.example('$0 deploy domains list', 'Domains of the linked app, or of the active project when there is none')
|
|
17
18
|
.showHelpOnFail(false),
|
|
18
19
|
handler: async (args) => {
|
|
19
20
|
const ctx = await requireApi();
|
|
20
|
-
const app_id = await
|
|
21
|
+
const app_id = await find_app_id(args.app, ctx.appId, ctx.api);
|
|
22
|
+
if (!app_id)
|
|
23
|
+
return list_project_domains(ctx.api, args);
|
|
21
24
|
const app = await ctx.api.getApp(app_id);
|
|
22
25
|
const page = await fetch_page(p => ctx.api.listDomainsPage(app_id, app.team, p), args);
|
|
23
26
|
if (args.json)
|
|
@@ -48,5 +51,35 @@ const domains_list = {
|
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
};
|
|
54
|
+
// No app here (an unlinked directory): the domains of the active project,
|
|
55
|
+
// each with the app it routes to.
|
|
56
|
+
const list_project_domains = async (api, args) => {
|
|
57
|
+
const { id: project } = await requireProject(api);
|
|
58
|
+
const page = await fetch_page(p => api.listDomainsPage(undefined, project, p), args);
|
|
59
|
+
if (args.json)
|
|
60
|
+
return print_json(page);
|
|
61
|
+
const domains = page.data;
|
|
62
|
+
if (domains.length === 0) {
|
|
63
|
+
log.info(`🌐 No custom domains in ${project}.`);
|
|
64
|
+
log.info(`Add one with: faable deploy domains add <yourdomain.com> --app <app>.`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const apps = await fetch_page(p => api.listApps(p, project), {
|
|
68
|
+
limit: 200,
|
|
69
|
+
all: true
|
|
70
|
+
});
|
|
71
|
+
const app_name = new Map(apps.data.map(a => [a.id, a.name]));
|
|
72
|
+
const label = (d) => d.app_id ? app_name.get(d.app_id) ?? d.app_id : '(no app)';
|
|
73
|
+
log.info(`🌐 ${domains.length} domain(s) in ${project}:`);
|
|
74
|
+
const width = Math.max(...domains.map(d => d.fqdn.length));
|
|
75
|
+
const app_width = Math.max(...domains.map(d => label(d).length));
|
|
76
|
+
for (const domain of domains) {
|
|
77
|
+
const tls = domain.tls ? 'tls' : 'no-tls';
|
|
78
|
+
print(` ${domain.fqdn.padEnd(width)} ${label(domain).padEnd(app_width)} ${dns_badge(domain)} (${tls})`);
|
|
79
|
+
}
|
|
80
|
+
const hint = more_hint(page);
|
|
81
|
+
if (hint)
|
|
82
|
+
log.info(hint);
|
|
83
|
+
};
|
|
51
84
|
|
|
52
85
|
export { domains_list };
|
|
@@ -23,7 +23,6 @@ class CredentialsStore {
|
|
|
23
23
|
await fs.ensureDir(this.faable_home);
|
|
24
24
|
await fs.writeJSON(this.credentials_path, config, { spaces: 2 });
|
|
25
25
|
await fs.chmod(this.credentials_path, 0o600);
|
|
26
|
-
this.log.info(`Stored credentials`);
|
|
27
26
|
}
|
|
28
27
|
async loadCredentials() {
|
|
29
28
|
const old_path = path__default.join(this.faable_home, 'credentials');
|