@faable/faable 1.25.0 → 1.26.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.
|
@@ -11,19 +11,15 @@ const gitRunner = (workdir) => command => new Promise(resolve => {
|
|
|
11
11
|
resolve(out || undefined);
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
|
-
// Loose version shape: "starts like semver". Filters out non-version tags
|
|
15
|
-
// (e.g. "nightly", "deploy-2026-07-01") when falling back to git describe;
|
|
16
|
-
// explicit values (--release / FAABLE_RELEASE) are NEVER validated — the
|
|
17
|
-
// platform treats release as free text.
|
|
18
|
-
const looksLikeVersion = (v) => /^\d+\.\d+\.\d+/.test(v);
|
|
19
|
-
const stripV = (tag) => tag.replace(/^v/, "");
|
|
20
14
|
/**
|
|
21
15
|
* Propose the release version for a deploy (Sentry propose-version pattern):
|
|
22
16
|
* explicit `--release` > `FAABLE_RELEASE` env > latest reachable git tag
|
|
23
|
-
* (
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
17
|
+
* (e.g. the tag semantic-release created) > undefined. The release is FREE
|
|
18
|
+
* TEXT and travels VERBATIM — no `v` stripping, no shape validation; only
|
|
19
|
+
* the dashboard footer prepends a display `v`. When undefined the field is
|
|
20
|
+
* omitted from the deployment and the platform injects no FAABLE_RELEASE —
|
|
21
|
+
* the app falls back to its own version source. No SHA fallback: the commit
|
|
22
|
+
* already travels as `github_commit`.
|
|
27
23
|
*/
|
|
28
24
|
const propose_release = async (opts) => {
|
|
29
25
|
const env = opts?.env ?? process.env;
|
|
@@ -32,20 +28,15 @@ const propose_release = async (opts) => {
|
|
|
32
28
|
return { release: opts.explicit, source: "--release" };
|
|
33
29
|
if (env.FAABLE_RELEASE)
|
|
34
30
|
return { release: env.FAABLE_RELEASE, source: "FAABLE_RELEASE env" };
|
|
35
|
-
// Latest tag reachable from HEAD.
|
|
36
|
-
// repo that also tags non-releases still
|
|
37
|
-
// repos whose release tags carry no `v` prefix.
|
|
31
|
+
// Latest tag reachable from HEAD, verbatim. Version-shaped tags are tried
|
|
32
|
+
// first so a repo that also tags non-releases still prefers its releases.
|
|
38
33
|
for (const cmd of [
|
|
39
34
|
`git describe --tags --abbrev=0 --match "v[0-9]*"`,
|
|
40
35
|
`git describe --tags --abbrev=0`,
|
|
41
36
|
]) {
|
|
42
37
|
const tag = await run(cmd);
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
const version = stripV(tag);
|
|
46
|
-
if (looksLikeVersion(version)) {
|
|
47
|
-
return { release: version, source: `git tag ${tag}` };
|
|
48
|
-
}
|
|
38
|
+
if (tag)
|
|
39
|
+
return { release: tag, source: `git tag ${tag}` };
|
|
49
40
|
}
|
|
50
41
|
return undefined;
|
|
51
42
|
};
|
|
@@ -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 };
|