@faable/faable 1.25.0 → 1.26.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.
|
@@ -3,8 +3,8 @@ import prompts from 'prompts';
|
|
|
3
3
|
import { log } from '../../log.js';
|
|
4
4
|
import { Configuration } from '../../lib/Configuration.js';
|
|
5
5
|
import { getGitRemoteUrl } from '../../lib/git_remote.js';
|
|
6
|
-
import { workflowExists, DEPLOY_WORKFLOW_PATH, writeWorkflow, DEPLOY_DOCS_URL, DEPLOY_WORKFLOW_YAML } from './workflow_template.js';
|
|
7
6
|
|
|
7
|
+
const DEPLOY_DOCS_URL = "https://faable.com/docs/deploy/github-actions";
|
|
8
8
|
const link = {
|
|
9
9
|
command: "link",
|
|
10
10
|
describe: "Link the local repository with a Faable app",
|
|
@@ -70,8 +70,9 @@ const link = {
|
|
|
70
70
|
}
|
|
71
71
|
// The API verifies that the user has a connected GitHub identity AND
|
|
72
72
|
// access to the repository before persisting the link.
|
|
73
|
+
let linked;
|
|
73
74
|
try {
|
|
74
|
-
await api.linkRepository(selectedApp.id, { repository: gitUrl });
|
|
75
|
+
linked = await api.linkRepository(selectedApp.id, { repository: gitUrl });
|
|
75
76
|
}
|
|
76
77
|
catch (err) {
|
|
77
78
|
const code = err?.code;
|
|
@@ -97,10 +98,17 @@ const link = {
|
|
|
97
98
|
// Save locally for CLI convenience (only after the API confirms the link)
|
|
98
99
|
Configuration.instance().saveConfig({ app_slug: selectedApp.name, app_id: selectedApp.id });
|
|
99
100
|
log.info(`Successfully linked local repository to ${selectedApp.name}.`);
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
|
|
101
|
+
// Deploy v4: push-to-deploy is server-side by default — no workflow to
|
|
102
|
+
// scaffold. A repo that brings its own Faable workflow keeps deploying
|
|
103
|
+
// through it (the API leaves the trigger on the Action in that case).
|
|
104
|
+
const branch = linked?.github_branch || "main";
|
|
105
|
+
if (linked?.deploy_trigger === "webhook") {
|
|
106
|
+
log.info(`Push to deploy is on: every push to "${branch}" deploys automatically.`);
|
|
107
|
+
log.info(`Prefer deploying from your own CI? Docs: ${DEPLOY_DOCS_URL}`);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
log.info(`This repository has its own Faable deploy workflow — pushes to "${branch}" keep deploying through it. Docs: ${DEPLOY_DOCS_URL}`);
|
|
111
|
+
}
|
|
104
112
|
},
|
|
105
113
|
};
|
|
106
114
|
// Top-level `faable link` predates the per-product layout (`faable deploy link`).
|
|
@@ -115,32 +123,5 @@ const link_deprecated = {
|
|
|
115
123
|
await link.handler(args);
|
|
116
124
|
}
|
|
117
125
|
};
|
|
118
|
-
const setupDeployWorkflow = async (workdir) => {
|
|
119
|
-
if (workflowExists(workdir)) {
|
|
120
|
-
log.info(`Deploy workflow already present at ${DEPLOY_WORKFLOW_PATH}. Commit & push to "main" to deploy.`);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const { create } = await prompts({
|
|
124
|
-
type: "toggle",
|
|
125
|
-
name: "create",
|
|
126
|
-
message: `Create the GitHub Actions deploy workflow (${DEPLOY_WORKFLOW_PATH})?`,
|
|
127
|
-
initial: true,
|
|
128
|
-
active: "yes",
|
|
129
|
-
inactive: "no",
|
|
130
|
-
});
|
|
131
|
-
if (create) {
|
|
132
|
-
const filePath = await writeWorkflow(workdir);
|
|
133
|
-
log.info(`Created ${filePath}`);
|
|
134
|
-
log.info("Next steps:");
|
|
135
|
-
log.info(" 1. Commit the workflow file");
|
|
136
|
-
log.info(' 2. Push to "main" — that triggers your first deploy');
|
|
137
|
-
log.info(`Docs: ${DEPLOY_DOCS_URL}`);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
log.info(`Skipped. To enable automated deploys, add ${DEPLOY_WORKFLOW_PATH} with:`);
|
|
141
|
-
log.info(`\n${DEPLOY_WORKFLOW_YAML}`);
|
|
142
|
-
log.info(`Then commit & push to "main". Docs: ${DEPLOY_DOCS_URL}`);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
126
|
|
|
146
127
|
export { link, link_deprecated };
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from 'fs/promises';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
3
|
-
import { join, dirname } from 'path';
|
|
4
|
-
|
|
5
|
-
// The canonical GitHub Actions workflow that deploys a Faable app on push.
|
|
6
|
-
// Mirrors the docs at https://faable.com/docs/deploy/github-actions.
|
|
7
|
-
const DEPLOY_WORKFLOW_PATH = ".github/workflows/deploy.yaml";
|
|
8
|
-
const DEPLOY_WORKFLOW_YAML = `name: Deploy to Faable
|
|
9
|
-
on:
|
|
10
|
-
push:
|
|
11
|
-
branches:
|
|
12
|
-
- main
|
|
13
|
-
permissions:
|
|
14
|
-
id-token: write
|
|
15
|
-
contents: write
|
|
16
|
-
pull-requests: write
|
|
17
|
-
issues: write
|
|
18
|
-
jobs:
|
|
19
|
-
deploy:
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
timeout-minutes: 10
|
|
22
|
-
steps:
|
|
23
|
-
- uses: actions/checkout@v6
|
|
24
|
-
- uses: actions/setup-node@v6
|
|
25
|
-
- run: npx @faable/faable@latest deploy
|
|
26
|
-
`;
|
|
27
|
-
const DEPLOY_DOCS_URL = "https://faable.com/docs/deploy/github-actions";
|
|
28
|
-
const workflowExists = (workdir) => existsSync(join(workdir, DEPLOY_WORKFLOW_PATH));
|
|
29
|
-
const writeWorkflow = async (workdir) => {
|
|
30
|
-
const filePath = join(workdir, DEPLOY_WORKFLOW_PATH);
|
|
31
|
-
await mkdir(dirname(filePath), { recursive: true });
|
|
32
|
-
await writeFile(filePath, DEPLOY_WORKFLOW_YAML, "utf8");
|
|
33
|
-
return filePath;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { DEPLOY_DOCS_URL, DEPLOY_WORKFLOW_PATH, DEPLOY_WORKFLOW_YAML, workflowExists, writeWorkflow };
|