@faable/faable 4.5.0 → 4.5.1

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.
@@ -227,8 +227,12 @@ class FaableApi {
227
227
  async updateApp(app_id, params) {
228
228
  return data(this.client.post(`/app/${app_id}`, params));
229
229
  }
230
- async linkRepository(app_id, params) {
231
- return data(this.client.post(`/app/${app_id}/link-repository`, params));
230
+ // Team pinned via header: the api answers 400 team_required without it
231
+ // (it needs the project to check the plan and the repository guard).
232
+ async linkRepository(app_id, params, team) {
233
+ return data(this.client.post(`/app/${app_id}/link-repository`, params, {
234
+ headers: projectHeader(team)
235
+ }));
232
236
  }
233
237
  // Organizations/accounts where the Faable GitHub App is installed.
234
238
  async listGithubInstallations() {
@@ -259,11 +263,11 @@ class FaableApi {
259
263
  }
260
264
  // Build and deploy the current head of the deploy branch server-side —
261
265
  // the same path a push webhook takes, same-commit dedupe included.
262
- async deployNow(app_id) {
266
+ async deployNow(app_id, team) {
263
267
  return data(
264
268
  // deployment_id: the build this call started (api ≥ the release that
265
269
  // added it; absent from older ones).
266
- this.client.post(`/app/${app_id}/deploy`));
270
+ this.client.post(`/app/${app_id}/deploy`, undefined, { headers: projectHeader(team) }));
267
271
  }
268
272
  // Rebuild a failed deployment from its recorded source (CAS manifest or
269
273
  // git ref). The API enforces the guards: failed phase only, never older
@@ -81,7 +81,7 @@ const apps_create = {
81
81
  linked = await api.linkRepository(app.id, {
82
82
  repository,
83
83
  ...(args.branch ? { github_branch: args.branch } : {})
84
- });
84
+ }, app.team);
85
85
  }
86
86
  catch (err) {
87
87
  await api.deleteApp(app.id, app.team).catch(() => {
@@ -102,7 +102,7 @@ const apps_create = {
102
102
  let first_deploy = null;
103
103
  if (repository && args.deploy && linked.deploy_trigger === 'webhook') {
104
104
  try {
105
- const started = await api.deployNow(app.id);
105
+ const started = await api.deployNow(app.id, app.team);
106
106
  first_deploy = {
107
107
  commit: started.commit,
108
108
  branch: started.branch,
@@ -20,7 +20,7 @@ const trigger = {
20
20
  const app = await ctx.api.getApp(app_id);
21
21
  // Takes the exact same path a git push would (same-commit dedupe
22
22
  // included) — the API answers with an actionable refusal otherwise.
23
- const result = await ctx.api.deployNow(app_id);
23
+ const result = await ctx.api.deployNow(app_id, app.team);
24
24
  if (args.json)
25
25
  return print_json({ app_id, ...result });
26
26
  log.info(`🚀 Building ${result.commit.slice(0, 7)} (${result.branch}) of ${app.name} server-side${result.deployment_id ? ` as ${result.deployment_id}` : ''}.`);
@@ -77,7 +77,7 @@ const link = {
77
77
  // access to the repository before persisting the link.
78
78
  let linked;
79
79
  try {
80
- linked = await api.linkRepository(selectedApp.id, { repository: gitUrl });
80
+ linked = await api.linkRepository(selectedApp.id, { repository: gitUrl }, selectedApp.team);
81
81
  }
82
82
  catch (err) {
83
83
  const code = err?.code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/faable",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Marc Pomar <marc@faable.com>",