@faable/faable 4.19.0 → 4.20.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.
@@ -290,6 +290,11 @@ class FaableApi {
290
290
  headers: projectHeader(team)
291
291
  }));
292
292
  }
293
+ // Native GitLab (api §393): link a gitlab.com project; the api creates the
294
+ // push webhook with the caller's GitLab token.
295
+ async linkGitlab(app_id, params, team) {
296
+ return data(this.client.post(`/app/${app_id}/link-gitlab`, params, { headers: projectHeader(team) }));
297
+ }
293
298
  // Organizations/accounts where the Faable GitHub App is installed.
294
299
  async listGithubInstallations() {
295
300
  return data(this.client.get(`/github/installations`)).then(res => res.installations);
@@ -28,6 +28,10 @@ const link = {
28
28
  alias: "r",
29
29
  type: "string",
30
30
  description: "GitHub repository, owner/repo or its URL (defaults to the origin remote of --workdir)",
31
+ })
32
+ .option("gitlab", {
33
+ type: "string",
34
+ description: "Link a gitlab.com project instead: its Project ID (the number on its page). Needs --app and GitLab connected in the dashboard",
31
35
  })
32
36
  .option("branch", {
33
37
  alias: "b",
@@ -40,9 +44,12 @@ const link = {
40
44
  description: "Print the link as JSON: app, repository, branch and how it deploys",
41
45
  })
42
46
  .example("$0 deploy link --app web --repo acme/web", "Link acme/web to the app web: from now on a push deploys it")
47
+ .example("$0 deploy link --app web --gitlab 12345678", "Link that gitlab.com project to the app web: pushes deploy it")
43
48
  .showHelpOnFail(false);
44
49
  },
45
50
  handler: async (args) => {
51
+ if (args.gitlab !== undefined)
52
+ return link_gitlab(args);
46
53
  if (args.app || args.json || is_non_interactive()) {
47
54
  return link_to_app(args);
48
55
  }
@@ -147,6 +154,39 @@ const link = {
147
154
  // repository to an existing app at all (arch/deploy/cli-mcp-fallos-2026-10-16-plan.md,
148
155
  // F4; backlog §366). Driven by a program, the repository is spelled out too:
149
156
  // the origin remote of whatever directory the process runs in is a guess.
157
+ const link_gitlab = async (args) => {
158
+ if (!args.app) {
159
+ throw new CliError("app_required", "Say which app to link: --app <id|name>.");
160
+ }
161
+ const project_id = String(args.gitlab ?? "");
162
+ if (!/^[0-9]+$/.test(project_id)) {
163
+ throw new CliError("usage", "--gitlab takes the numeric Project ID shown on the GitLab project page, not its path.");
164
+ }
165
+ const { api } = await requireApi();
166
+ const app = await api.getApp(await resolve_app_ref(api, args.app));
167
+ let linked;
168
+ try {
169
+ linked = await api.linkGitlab(app.id, { project_id, ...(args.branch ? { branch: args.branch } : {}) }, app.team);
170
+ }
171
+ catch (err) {
172
+ const e = err;
173
+ const failed = new CliError("usage", `Could not link GitLab project ${project_id} to ${app.name}: ${e.message}`, { status: e.status, action: e.action, cause: err });
174
+ // gitlab_identity_missing / gitlab_token_invalid / gitlab_project_not_accessible
175
+ if (e.code)
176
+ failed.code = e.code;
177
+ throw failed;
178
+ }
179
+ const result = {
180
+ app_id: app.id,
181
+ app_name: app.name,
182
+ gitlab_project: linked?.gitlab_project_path ?? project_id,
183
+ branch: linked?.gitlab_branch,
184
+ };
185
+ if (args.json)
186
+ return print_json(result);
187
+ log.info(`Linked ${result.gitlab_project} (GitLab) to ${app.name} (${app.id}).`);
188
+ log.info(`Push to deploy is on: the next push to "${result.branch ?? "the default branch"}" deploys.`);
189
+ };
150
190
  const link_to_app = async (args) => {
151
191
  if (!args.app) {
152
192
  throw new CliError("app_required", "Say which app to link: --app <id|name>. Without a terminal there is no list to pick from.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/faable",
3
- "version": "4.19.0",
3
+ "version": "4.20.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Marc Pomar <marc@faable.com>",