@faable/faable 4.32.0 → 4.34.0
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 +35 -9
- package/dist/api/FaableApi.js +25 -0
- package/dist/commands/organization/index.js +193 -0
- package/dist/index.js +2 -0
- package/dist/lib/Configuration.js +4 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,34 +1,46 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://faable.com">
|
|
3
|
-
<img src="https://
|
|
4
|
-
<h3 align="center">Faable</h3>
|
|
2
|
+
<a href="https://faable.com/docs/cli">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/faablecloud/faable/main/.github/assets/cover.png" alt="Faable CLI: deploy and run your apps from the terminal" width="100%">
|
|
5
4
|
</a>
|
|
6
5
|
</p>
|
|
7
6
|
|
|
8
7
|
<p align="center">
|
|
9
|
-
|
|
8
|
+
<a href="https://www.npmjs.com/package/@faable/faable"><img alt="npm version" src="https://img.shields.io/npm/v/@faable/faable.svg?labelColor=121a29&color=7270ee"></a>
|
|
9
|
+
<a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-7270ee?labelColor=121a29"></a>
|
|
10
|
+
<a href="https://faable.com/docs/cli"><img alt="Documentation" src="https://img.shields.io/badge/docs-faable.com-7270ee?labelColor=121a29"></a>
|
|
10
11
|
</p>
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
# Faable CLI
|
|
13
14
|
|
|
14
|
-
`@faable/faable` is the command-line interface for the Faable platform. It
|
|
15
|
-
**Faable Deploy** (ship and operate apps) and **Faable Auth** (manage an identity
|
|
16
|
-
|
|
15
|
+
`@faable/faable` is the command-line interface for the [Faable](https://faable.com) platform. It
|
|
16
|
+
covers **Faable Deploy** (ship and operate apps) and **Faable Auth** (manage an identity tenant:
|
|
17
|
+
users, login-flow actions, OAuth clients and the audit log) from one binary.
|
|
17
18
|
|
|
18
19
|
Full reference: **[faable.com/docs/cli](https://faable.com/docs/cli)**.
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
Requires Node.js 22.8 or later.
|
|
21
24
|
|
|
22
25
|
```bash
|
|
23
26
|
npm i -g @faable/faable
|
|
24
27
|
```
|
|
25
28
|
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
faable login # sign in from your browser
|
|
33
|
+
faable deploy # deploy the current directory
|
|
34
|
+
faable deploy status
|
|
35
|
+
```
|
|
36
|
+
|
|
26
37
|
## Commands
|
|
27
38
|
|
|
28
39
|
| Group | What it does | Docs |
|
|
29
40
|
| --- | --- | --- |
|
|
30
41
|
| `faable login` / `whoami` / `logout` | Session management (device flow; CI uses OIDC, no login needed) | [Authentication](https://faable.com/docs/cli#authentication) |
|
|
31
42
|
| `faable project` | The project commands act on: `list`, `use`, `current`, `clear` (or `--project` on any command) | [Projects](https://faable.com/docs/cli#projects) |
|
|
43
|
+
| `faable organization` | Group projects under a company: `list`, `get`, `create`, `projects add`/`rm`, `admins add`/`rm` (`org` for short) | [Organizations](https://faable.com/docs/cli#organizations) |
|
|
32
44
|
| `faable deploy` | `launch` (the default: a bare `faable deploy` deploys the current directory), then `status`, `logs`, `deployments`, `inspect`, `trigger`, `redeploy`, `cancel`, `traffic`, `usage`, `quota`, `open` | [Deployment](https://faable.com/docs/cli#deployment) |
|
|
33
45
|
| `faable deploy apps` | `list`, `get`, `create` (from a GitHub repository, first deploy included), `set` (branch, root directory, deploy mode) | [Apps](https://faable.com/docs/cli#apps) |
|
|
34
46
|
| `faable deploy secrets` | Environment variables: `list`, `set` (`KEY=VALUE`, `--env-file`, or `-f -` from stdin), `rm` | [Secrets](https://faable.com/docs/cli#secrets) |
|
|
@@ -155,3 +167,17 @@ the public docs, not here.
|
|
|
155
167
|
- [Login flows](https://faable.com/docs/auth/login-flows) and [actions](https://faable.com/docs/auth/extensibility/actions) — the hooks managed by `auth actions`
|
|
156
168
|
- [Logs](https://faable.com/docs/auth/logs) — the audit trail read by `auth logs`
|
|
157
169
|
- [OAuth 2.0 flows](https://faable.com/docs/auth/oauth-flows) · [OpenID Connect](https://faable.com/docs/auth/oidc) · [Validate access tokens](https://faable.com/docs/auth/validate-access-tokens)
|
|
170
|
+
|
|
171
|
+
## Support
|
|
172
|
+
|
|
173
|
+
- **Documentation:** [faable.com/docs](https://faable.com/docs)
|
|
174
|
+
- **Community help, on every plan:** [GitHub Discussions](https://github.com/orgs/faablecloud/discussions)
|
|
175
|
+
- **Help from the Faable team, on the Hobby and Pro plans:** [support@faable.com](mailto:support@faable.com).
|
|
176
|
+
See the [support page](https://faable.com/docs/platform/support)
|
|
177
|
+
- **Bugs and feature requests:** [open an issue](https://github.com/faablecloud/faable/issues)
|
|
178
|
+
- **Security issues:** report them privately to [support@faable.com](mailto:support@faable.com),
|
|
179
|
+
not in a public issue
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
[MIT](LICENSE) © Faable Cloud SLU
|
package/dist/api/FaableApi.js
CHANGED
|
@@ -192,6 +192,31 @@ class FaableApi {
|
|
|
192
192
|
}
|
|
193
193
|
}));
|
|
194
194
|
}
|
|
195
|
+
// ---- organizations (a person's session: api keys are refused) ----
|
|
196
|
+
async listOrganizations() {
|
|
197
|
+
return data(this.client.get(`/organization`));
|
|
198
|
+
}
|
|
199
|
+
async getOrganization(id) {
|
|
200
|
+
return data(this.client.get(`/organization/${id}`));
|
|
201
|
+
}
|
|
202
|
+
async createOrganization(name, project_id) {
|
|
203
|
+
return data(this.client.post(`/organization`, {
|
|
204
|
+
name,
|
|
205
|
+
project_id
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
208
|
+
async addOrganizationProject(id, project_id) {
|
|
209
|
+
return data(this.client.post(`/organization/${id}/project`, { project_id }));
|
|
210
|
+
}
|
|
211
|
+
async removeOrganizationProject(id, project_id) {
|
|
212
|
+
return data(this.client.delete(`/organization/${id}/project/${project_id}`));
|
|
213
|
+
}
|
|
214
|
+
async addOrganizationAdmin(id, user_id) {
|
|
215
|
+
return data(this.client.post(`/organization/${id}/admin`, { user_id }));
|
|
216
|
+
}
|
|
217
|
+
async removeOrganizationAdmin(id, user_id) {
|
|
218
|
+
return data(this.client.delete(`/organization/${id}/admin/${user_id}`));
|
|
219
|
+
}
|
|
195
220
|
async getProject(project_id) {
|
|
196
221
|
return data(this.client.get(`/project/${project_id}`));
|
|
197
222
|
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { requireApi } from '../../api/context.js';
|
|
2
|
+
import { requireProject, resolveProjectRef } from '../../api/project.js';
|
|
3
|
+
import { CliError } from '../../lib/errors.js';
|
|
4
|
+
import { confirm } from '../../lib/interactive.js';
|
|
5
|
+
import { print_json, table_lines, print, json_option } from '../../lib/listing.js';
|
|
6
|
+
import { log } from '../../log.js';
|
|
7
|
+
|
|
8
|
+
// `faable organization` — the companies that group projects. An organization
|
|
9
|
+
// gives nobody access to its projects and is not billed. The api decides who
|
|
10
|
+
// may: its admins and the projects' owners, or staff; a person, never an API
|
|
11
|
+
// key (`Organizations are managed by people`).
|
|
12
|
+
const ID_RE = /^organization_[0-9a-f]{24}$/;
|
|
13
|
+
const resolveOrganization = async (api, ref) => {
|
|
14
|
+
if (ID_RE.test(ref))
|
|
15
|
+
return ref;
|
|
16
|
+
const wanted = ref.toLowerCase();
|
|
17
|
+
const { results } = await api.listOrganizations();
|
|
18
|
+
const matches = results.filter(o => o.name.toLowerCase() === wanted || o.slug.toLowerCase() === wanted);
|
|
19
|
+
if (matches.length === 1)
|
|
20
|
+
return matches[0].id;
|
|
21
|
+
throw new CliError('not_found', matches.length === 0
|
|
22
|
+
? `No organization named "${ref}". See them with: faable organization list`
|
|
23
|
+
: `"${ref}" is more than one organization: use its id.`);
|
|
24
|
+
};
|
|
25
|
+
const project_names = (o) => o.projects.map(p => p.name).join(', ') || '-';
|
|
26
|
+
const organization_list = {
|
|
27
|
+
command: 'list',
|
|
28
|
+
describe: 'List the organizations you administer or have a project in',
|
|
29
|
+
builder: yargs => json_option(yargs).showHelpOnFail(false),
|
|
30
|
+
handler: async (args) => {
|
|
31
|
+
const { api } = await requireApi();
|
|
32
|
+
const { results } = await api.listOrganizations();
|
|
33
|
+
if (args.json)
|
|
34
|
+
return print_json(results);
|
|
35
|
+
if (results.length === 0)
|
|
36
|
+
return log.info('📭 No organizations.');
|
|
37
|
+
for (const line of table_lines(['ID', 'NAME', 'ADMIN', 'PROJECTS'], results.map(o => [
|
|
38
|
+
o.id,
|
|
39
|
+
o.name,
|
|
40
|
+
o.is_admin ? 'yes' : 'no',
|
|
41
|
+
project_names(o)
|
|
42
|
+
]))) {
|
|
43
|
+
print(line);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const organization_get = {
|
|
48
|
+
command: 'get <organization>',
|
|
49
|
+
describe: 'Show an organization: its projects and admins',
|
|
50
|
+
builder: yargs => json_option(yargs)
|
|
51
|
+
.positional('organization', { type: 'string', demandOption: true })
|
|
52
|
+
.showHelpOnFail(false),
|
|
53
|
+
handler: async (args) => {
|
|
54
|
+
const { api } = await requireApi();
|
|
55
|
+
const org = await api.getOrganization(await resolveOrganization(api, args.organization));
|
|
56
|
+
if (args.json)
|
|
57
|
+
return print_json(org);
|
|
58
|
+
print(`${org.name} (${org.id})`);
|
|
59
|
+
print(`Projects: ${project_names(org)}`);
|
|
60
|
+
print(`Admins: ${org.admins?.join(', ') || '-'}`);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const organization_create = {
|
|
64
|
+
command: 'create <name>',
|
|
65
|
+
describe: 'Create an organization from a project (--project or the active one); you become its admin',
|
|
66
|
+
builder: yargs => json_option(yargs)
|
|
67
|
+
.positional('name', { type: 'string', demandOption: true })
|
|
68
|
+
.example('$0 organization create "Acme SL" --project acme-web', '')
|
|
69
|
+
.showHelpOnFail(false),
|
|
70
|
+
handler: async (args) => {
|
|
71
|
+
const { api } = await requireApi();
|
|
72
|
+
const { id } = await requireProject(api);
|
|
73
|
+
const org = await api.createOrganization(args.name, id);
|
|
74
|
+
if (args.json)
|
|
75
|
+
return print_json(org);
|
|
76
|
+
log.info(`✅ Organization ${org.name} (${org.id})`);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const project_positionals = (yargs) => yargs
|
|
80
|
+
.positional('organization', { type: 'string', demandOption: true })
|
|
81
|
+
.positional('project_ref', {
|
|
82
|
+
type: 'string',
|
|
83
|
+
demandOption: true,
|
|
84
|
+
describe: 'Project id, name or slug'
|
|
85
|
+
});
|
|
86
|
+
const projects_add = {
|
|
87
|
+
command: 'add <organization> <project_ref>',
|
|
88
|
+
describe: 'Put a project in the organization (moves it from any other)',
|
|
89
|
+
builder: yargs => project_positionals(yargs).showHelpOnFail(false),
|
|
90
|
+
handler: async (args) => {
|
|
91
|
+
const { api } = await requireApi();
|
|
92
|
+
const id = await resolveOrganization(api, args.organization);
|
|
93
|
+
const project = await resolveProjectRef(api, args.project_ref);
|
|
94
|
+
await api.addOrganizationProject(id, project);
|
|
95
|
+
log.info(`✅ ${args.project_ref} is in ${args.organization}`);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const projects_rm = {
|
|
99
|
+
command: 'rm <organization> <project_ref>',
|
|
100
|
+
describe: 'Take a project out of the organization: it becomes personal',
|
|
101
|
+
builder: yargs => project_positionals(yargs)
|
|
102
|
+
.option('yes', {
|
|
103
|
+
type: 'boolean',
|
|
104
|
+
alias: 'y',
|
|
105
|
+
description: 'Skip the confirmation prompt'
|
|
106
|
+
})
|
|
107
|
+
.showHelpOnFail(false),
|
|
108
|
+
handler: async (args) => {
|
|
109
|
+
const { api } = await requireApi();
|
|
110
|
+
const id = await resolveOrganization(api, args.organization);
|
|
111
|
+
const project = await resolveProjectRef(api, args.project_ref);
|
|
112
|
+
const go = await confirm({
|
|
113
|
+
message: `Take ${args.project_ref} out of ${args.organization}?`,
|
|
114
|
+
yes: args.yes
|
|
115
|
+
});
|
|
116
|
+
if (!go)
|
|
117
|
+
return log.info('Cancelled.');
|
|
118
|
+
await api.removeOrganizationProject(id, project);
|
|
119
|
+
log.info(`✅ ${args.project_ref} is no longer in ${args.organization}`);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const organization_projects = {
|
|
123
|
+
command: 'projects',
|
|
124
|
+
describe: "Add or remove an organization's projects",
|
|
125
|
+
builder: yargs => yargs
|
|
126
|
+
.command(projects_add)
|
|
127
|
+
.command(projects_rm)
|
|
128
|
+
.demandCommand(1)
|
|
129
|
+
.showHelpOnFail(false),
|
|
130
|
+
handler: () => { }
|
|
131
|
+
};
|
|
132
|
+
const admin_positionals = (yargs) => yargs
|
|
133
|
+
.positional('organization', { type: 'string', demandOption: true })
|
|
134
|
+
.positional('user_id', { type: 'string', demandOption: true });
|
|
135
|
+
const admins_add = {
|
|
136
|
+
command: 'add <organization> <user_id>',
|
|
137
|
+
describe: 'Make someone an admin (gives no access to its projects)',
|
|
138
|
+
builder: yargs => admin_positionals(yargs).showHelpOnFail(false),
|
|
139
|
+
handler: async (args) => {
|
|
140
|
+
const { api } = await requireApi();
|
|
141
|
+
const id = await resolveOrganization(api, args.organization);
|
|
142
|
+
await api.addOrganizationAdmin(id, args.user_id);
|
|
143
|
+
log.info(`✅ ${args.user_id} administers ${args.organization}`);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const admins_rm = {
|
|
147
|
+
command: 'rm <organization> <user_id>',
|
|
148
|
+
describe: 'Remove an admin (an organization keeps at least one)',
|
|
149
|
+
builder: yargs => admin_positionals(yargs)
|
|
150
|
+
.option('yes', {
|
|
151
|
+
type: 'boolean',
|
|
152
|
+
alias: 'y',
|
|
153
|
+
description: 'Skip the confirmation prompt'
|
|
154
|
+
})
|
|
155
|
+
.showHelpOnFail(false),
|
|
156
|
+
handler: async (args) => {
|
|
157
|
+
const { api } = await requireApi();
|
|
158
|
+
const id = await resolveOrganization(api, args.organization);
|
|
159
|
+
const go = await confirm({
|
|
160
|
+
message: `Remove ${args.user_id} as admin of ${args.organization}?`,
|
|
161
|
+
yes: args.yes
|
|
162
|
+
});
|
|
163
|
+
if (!go)
|
|
164
|
+
return log.info('Cancelled.');
|
|
165
|
+
await api.removeOrganizationAdmin(id, args.user_id);
|
|
166
|
+
log.info(`✅ ${args.user_id} no longer administers ${args.organization}`);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const organization_admins = {
|
|
170
|
+
command: 'admins',
|
|
171
|
+
describe: "Add or remove an organization's admins",
|
|
172
|
+
builder: yargs => yargs
|
|
173
|
+
.command(admins_add)
|
|
174
|
+
.command(admins_rm)
|
|
175
|
+
.demandCommand(1)
|
|
176
|
+
.showHelpOnFail(false),
|
|
177
|
+
handler: () => { }
|
|
178
|
+
};
|
|
179
|
+
const organization = {
|
|
180
|
+
command: ['organization', 'org'],
|
|
181
|
+
describe: 'Group projects under a company (list, get, create, projects, admins)',
|
|
182
|
+
builder: yargs => yargs
|
|
183
|
+
.command(organization_list)
|
|
184
|
+
.command(organization_get)
|
|
185
|
+
.command(organization_create)
|
|
186
|
+
.command(organization_projects)
|
|
187
|
+
.command(organization_admins)
|
|
188
|
+
.demandCommand(1)
|
|
189
|
+
.showHelpOnFail(false),
|
|
190
|
+
handler: () => { }
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export { organization };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { link_deprecated } from './commands/link/index.js';
|
|
|
6
6
|
import { login } from './commands/login/index.js';
|
|
7
7
|
import { logout } from './commands/logout/index.js';
|
|
8
8
|
import { mcp } from './commands/mcp/index.js';
|
|
9
|
+
import { organization } from './commands/organization/index.js';
|
|
9
10
|
import { project } from './commands/project/index.js';
|
|
10
11
|
import { upgrade } from './commands/upgrade/index.js';
|
|
11
12
|
import { whoami } from './commands/whoami/index.js';
|
|
@@ -94,6 +95,7 @@ yg.scriptName('faable')
|
|
|
94
95
|
.command(deploy)
|
|
95
96
|
.command(auth)
|
|
96
97
|
.command(project)
|
|
98
|
+
.command(organization)
|
|
97
99
|
.command(login)
|
|
98
100
|
.command(logout)
|
|
99
101
|
.command(whoami)
|
|
@@ -36,6 +36,9 @@ class Configuration {
|
|
|
36
36
|
get configuredStartCommand() {
|
|
37
37
|
return this.config.startCommand;
|
|
38
38
|
}
|
|
39
|
+
get installCommand() {
|
|
40
|
+
return this.config.installCommand;
|
|
41
|
+
}
|
|
39
42
|
get buildCommand() {
|
|
40
43
|
return this.config.buildCommand;
|
|
41
44
|
}
|
|
@@ -46,6 +49,7 @@ class Configuration {
|
|
|
46
49
|
deployConfig() {
|
|
47
50
|
return {
|
|
48
51
|
startCommand: this.config.startCommand,
|
|
52
|
+
installCommand: this.config.installCommand,
|
|
49
53
|
buildCommand: this.config.buildCommand,
|
|
50
54
|
buildpack: this.config.buildpack,
|
|
51
55
|
rootDir: this.config.rootDir,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faable/faable",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.34.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Pomar <marc@faable.com>",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
|
-
"homepage": "https://
|
|
23
|
+
"homepage": "https://faable.com/docs/cli",
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
26
|
"bin"
|