@backifydev/cli 0.4.1 → 0.4.3
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 +5 -3
- package/dist/index.js +294 -125
- package/package.json +1 -1
- package/templates/api/backify.config.ts +1 -1
- package/templates/api/package.json +1 -1
- package/templates/web/backify.config.ts +1 -1
- package/templates/web/package.json +2 -2
- package/templates/worker/backify.config.ts +1 -1
- package/templates/worker/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Every page the CLI opens is a standalone page under `/tasks/…` or `/cli/…` (
|
|
|
6
6
|
|
|
7
7
|
## Steps only a person may perform
|
|
8
8
|
|
|
9
|
-
Some steps must be done by a person in the browser under their own Backify permissions. These include signing in with Microsoft or GitHub, approving a plan or someone else's request, paying, granting consent and permanently deleting things. For these, the CLI requests a **human task**, opens its page at `/tasks/<task-id>`,
|
|
9
|
+
Some steps must be done by a person in the browser under their own Backify permissions. These include signing in with Microsoft or GitHub, approving a plan or someone else's request, paying, granting consent and permanently deleting things. For these, the CLI requests a **human task**, opens its page at `/tasks/<task-id>`, and waits for the signed-in person to act. Agents may pre-fill a task but never complete it.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
backify signup # without an account: sign up, choose a plan and approve this CLI's access
|
|
@@ -43,7 +43,7 @@ Use `--no-browser` to open the printed review URL manually, `--no-wait` to retur
|
|
|
43
43
|
backify domains connect app.example.com --environment production
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Requests a Backify task and opens its page at `/tasks/<task-id>`, where an authorized domain manager signs in
|
|
46
|
+
Requests a Backify task and opens its page at `/tasks/<task-id>`, where an authorized domain manager signs in and confirms the hostname and environment; omit either to choose on the page. The command returns as soon as the domain is confirmed (exit code 0, `confirmed: true`) with the expected `https://<hostname>` and what happens next. It does not wait for DNS: after the user adds the records shown on the page, Backify verifies them automatically, issues managed HTTPS and starts routing. Use `--no-browser`, `--no-wait` or `--timeout <seconds>`, and read the current status with `backify domains connect --request TASK_UUID`. Exit code 2 means not yet confirmed or blocked. The CLI never changes DNS or approves the domain itself.
|
|
47
47
|
|
|
48
48
|
## Coding-tool MCP bridge
|
|
49
49
|
|
|
@@ -127,7 +127,7 @@ An app is one repository and one container image that runs as process roles (`we
|
|
|
127
127
|
- a private PostgreSQL cluster in `.backify/dev/postgres` with the platform's `migrate`, `runtime` and `inspect` roles (PostgreSQL 16+ must be installed; set `BACKIFY_POSTGRES_BIN` if it is not found);
|
|
128
128
|
- migrations through the migrate role, then the web and worker roles, rebuilt and restarted when server code or migrations change;
|
|
129
129
|
- the Vite dev server for web apps;
|
|
130
|
-
- a local gateway on one port with development sign-in at `/.backify/auth/login`, verified user tokens forwarded to the backend, `/files/{bucket}` for public buckets, and a local broker for storage (files in `.backify/dev/storage`), mail (saved to `.backify/dev/mail`) and outbound HTTP
|
|
130
|
+
- a local gateway on one port with development sign-in at `/.backify/auth/login`, verified user tokens forwarded to the backend, `/files/{bucket}` for public buckets, and a local broker for storage (files in `.backify/dev/storage`), mail (saved to `.backify/dev/mail`) and outbound HTTP to any HTTPS destination (environment rules are not emulated locally). AI and integrations are available in preview environments only.
|
|
131
131
|
|
|
132
132
|
Local secret values go in `.backify/secrets.local.json` (`{ "NAME": "value" }`); never commit them.
|
|
133
133
|
|
|
@@ -171,6 +171,8 @@ Copy the application's setup prompt from Backify. It contains only the public ap
|
|
|
171
171
|
|
|
172
172
|
`ship` runs configured checks, verifies the repository/branch, and pushes already-committed source using a short-lived repository-scoped GitHub App credential. It never stages, commits, force-pushes, or fabricates preview testing. By default it waits for the exact healthy preview and returns its URL without requesting production publication. Plain requests such as “Now deploy” and approval to merge and retry remain preview-only; production requires an explicit user request to deploy to production. Instruction version 10 (CLI 0.3.12) makes this distinction explicit in installed guidance. Promote the preview in the portal, or explicitly run `ship --production-deploy` to request publication through existing policy and permissions. Required testing/approval returns a pending state and preview URL, not a false successful production deployment. The legacy `--preview-only` flag remains supported but cannot be combined with `--production-deploy`. Use `--timeout <seconds>` to change the default 1200-second wait. Applications must currently be at the repository root. CI checks the committed lockfile, builds and verifies one image, then uploads a release. The web role serves port 8080; web apps also upload a static frontend. Local Docker is not required for backify dev.
|
|
173
173
|
|
|
174
|
+
`workflow refresh` brings the repository's Backify build workflow up to date. A connected repository keeps the workflow it received when it was connected; after a Backify update changes that workflow, or when a build fails in a workflow step your code does not control, run it from the application folder. Backify regenerates the workflow and commits it to the connected branch only when the repository's copy differs. The result's `changed` says whether it committed; when it did, run `pull` before the next push. It needs permission to manage the application's source.
|
|
175
|
+
|
|
174
176
|
`disconnect` revokes that user's application CLI sessions. `logout` removes local credentials only. Prompt histories and local reports remain subject to application permissions. Deploy the matching API and publish CLI 0.3.0 before enabling this flow in production.
|
|
175
177
|
|
|
176
178
|
Connections now report the device hostname, operating system, architecture, and installed CLI version. Browser-based `connect` exchanges a general sign-in token for an application-scoped device session. Application **People & access → CLI access** shows these sessions and lets access managers revoke individual devices; source managers can revoke their own. Existing connections may need reconnecting to record device details. See [CLI access and country lookup configuration](../../docs/cli-access.md) for privacy, permissions and deployment requirements.
|
package/dist/index.js
CHANGED
|
@@ -46,12 +46,12 @@ var init_delivery = __esm({
|
|
|
46
46
|
"use strict";
|
|
47
47
|
deliveryInstructions = `# Backify application delivery and prompt history
|
|
48
48
|
|
|
49
|
-
Instruction version:
|
|
50
|
-
Versioned guide: https://agent.backify.dev/
|
|
49
|
+
Instruction version: 20
|
|
50
|
+
Versioned guide: https://agent.backify.dev/v20/delivery.md
|
|
51
51
|
|
|
52
52
|
## Environment and documentation prerequisites
|
|
53
53
|
|
|
54
|
-
Before installation or connection, read https://agent.backify.dev/
|
|
54
|
+
Before installation or connection, read https://agent.backify.dev/v20 for execution capability checks, required endpoints (including https://docs.backify.dev), native permission requests, verified retries and fallback guidance. Follow the current tool's supported approval mechanism; never bypass restrictions. Read relevant capability documentation before implementation. Local validation must not depend on cloud deployment.
|
|
55
55
|
|
|
56
56
|
Before application implementation, all required setup checks and connected status must be verified OK. If any required check fails or remains unverified after supported recovery, stop setup and implementation; do not build a local website, minimal shell, placeholder, dependency-free fallback, or downloadable application archive. Report the blockers and recommend running the setup prompt in an AI coding tool such as Codex, Claude Code, or VS Code with GitHub Copilot agent mode, with terminal access, a persistent writable workspace, package installation, outbound HTTPS/DNS, and test execution enabled. Tool names alone do not guarantee readiness. Do not ask the application requirements question while setup is blocked. Later preview approval or deployment failures do not invalidate an already verified setup gate.
|
|
57
57
|
|
|
@@ -63,7 +63,7 @@ The minimal setup prompt supplies only this guide reference and a public app ref
|
|
|
63
63
|
|
|
64
64
|
npx @backifydev/cli@latest connect --app <app-id> --reauth --api https://api.backify.dev/api
|
|
65
65
|
|
|
66
|
-
Add --clone according to the workspace rules below. Keep the CLI running while the user signs in at https://auth.backify.dev, selects the app's organization and explicitly approves application-scoped device access. The CLI receives the organization and credential directly; never ask for tokens or organization IDs in chat. Check the completed command result and retrieve app context using CLI status. Browser approval does not authorize production deployment. If authorization is cancelled, denied or times out, report the blocker and use only supported recovery.
|
|
66
|
+
Add --clone according to the workspace rules below. Keep the CLI running while the user signs in at https://auth.backify.dev, selects the app's organization and explicitly approves application-scoped device access. The CLI receives the organization and credential directly; never ask for tokens or organization IDs in chat. Browser approval is a status update, not a question: tell the user what to approve in a progress message and keep waiting for the command. Do not use a question or input-request tool, end the turn, or ask the user to reply in chat; the CLI continues automatically. The same applies to every CLI command that waits for a person in the browser. Check the completed command result and retrieve app context using CLI status. Browser approval does not authorize production deployment. If authorization is cancelled, denied or times out, report the blocker and use only supported recovery.
|
|
67
67
|
|
|
68
68
|
For compatibility, legacy prompts may supply App Id, Organization, and Pair. Substitute those values for <app-id>, <organization-id>, and <pairing-code> below; never invent them. Use npx @backifydev/cli@latest so tool-specific setup and metadata-preserving cloning are available. The public API URL is https://api.backify.dev/api. For a nonproduction environment, replace the --api value with an explicitly trusted endpoint, or omit --api when using a trusted BACKIFY_API_URL override; never send a pairing code to an unverified endpoint.
|
|
69
69
|
|
|
@@ -77,7 +77,7 @@ Initialize using App Id from the copied prompt and the current tool selection:
|
|
|
77
77
|
|
|
78
78
|
npx @backifydev/cli@latest init --app <app-id> --agent <current-tool>
|
|
79
79
|
|
|
80
|
-
For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/
|
|
80
|
+
For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/v20 for rebuilt applications; use the guide matching instructionVersion in backify.config.ts (or the existing older workspace metadata). Do not silently upgrade its managed instruction version or overwrite instructions outside the managed block.
|
|
81
81
|
|
|
82
82
|
Run the following to discover the connected hosting target, repository, branch, reports, releases, and deployment failures:
|
|
83
83
|
|
|
@@ -1688,7 +1688,7 @@ Require explicit confirmation before destructive data operations or removing sta
|
|
|
1688
1688
|
|
|
1689
1689
|
## Application defaults
|
|
1690
1690
|
|
|
1691
|
-
When authentication is required, use email magic links by default and ask the builder which implemented additional providers to enable. Provider-specific setup and secure configuration remain available in the application Authentication page and portal. Preserve existing providers and email defaults; explicitly request method magic-link in newly built embedded email forms.
|
|
1691
|
+
When authentication is required, use email magic links by default and ask the builder which implemented additional providers to enable. Provider-specific setup and secure configuration remain available in the application Authentication page and portal. Preserve existing providers and email defaults; explicitly request method magic-link in newly built embedded email forms. Locally, sign in through the development-only form at /.backify/auth/login with safe test identities and the roles and permissions the flow needs; it sends no mail, so verify real magic-link delivery and provider callbacks in preview. Do not infer roles from email or fabricate provider support.
|
|
1692
1692
|
Read the authenticated developer status branding snapshot before building a new application. Use supplied branding as flexible visual defaults; complete missing design elements as needed and never restrict application functionality because branding is incomplete. Existing applications keep their own branding unless a change is requested.
|
|
1693
1693
|
|
|
1694
1694
|
## Implementation workflow
|
|
@@ -1769,7 +1769,7 @@ var init_dist = __esm({
|
|
|
1769
1769
|
init_protection();
|
|
1770
1770
|
init_auth_setup();
|
|
1771
1771
|
init_operations();
|
|
1772
|
-
INSTRUCTION_VERSION =
|
|
1772
|
+
INSTRUCTION_VERSION = 20;
|
|
1773
1773
|
SDK_PACKAGE = "@backifydev/sdk";
|
|
1774
1774
|
DOCS_URL = "https://docs.backify.dev";
|
|
1775
1775
|
MAIL_LIMITS = Object.freeze({
|
|
@@ -1953,7 +1953,7 @@ Check that the page shows the code ${status.matchCode}.` : ""));
|
|
|
1953
1953
|
}
|
|
1954
1954
|
}
|
|
1955
1955
|
if (options.noWait) return { status, link, reason: "waiting_in_browser" };
|
|
1956
|
-
options.progress?.("Waiting for you in the browser
|
|
1956
|
+
options.progress?.("Waiting for you in the browser; no reply is needed in chat. The CLI continues automatically.\nCoding agents: tell the user this as a status update, not a question or input request, and keep waiting for this command to finish.");
|
|
1957
1957
|
while (true) {
|
|
1958
1958
|
if (status.state !== "pending") {
|
|
1959
1959
|
options.progress?.(status.nextAction);
|
|
@@ -1994,7 +1994,7 @@ var init_package = __esm({
|
|
|
1994
1994
|
"package.json"() {
|
|
1995
1995
|
package_default = {
|
|
1996
1996
|
name: "@backifydev/cli",
|
|
1997
|
-
version: "0.4.
|
|
1997
|
+
version: "0.4.3",
|
|
1998
1998
|
description: "Command-line setup and diagnostics for Backify applications",
|
|
1999
1999
|
type: "module",
|
|
2000
2000
|
bin: {
|
|
@@ -2108,6 +2108,8 @@ function applicationSupport(root) {
|
|
|
2108
2108
|
const dependencies = { ...manifest.devDependencies, ...manifest.dependencies };
|
|
2109
2109
|
const framework = ["next", "astro", "@sveltejs/kit", "nuxt", "express", "vite", "react"].find((name2) => dependencies[name2]) ?? "unknown";
|
|
2110
2110
|
if (existsSync4(join5(root, "Dockerfile"))) {
|
|
2111
|
+
if (existsSync4(join5(root, "backify.config.ts")) && dependencies["@backifydev/sdk"] && /@backifydev\/sdk\/dist\/app\/run\.js|\bbackify-run\b/.test(readFileSync5(join5(root, "Dockerfile"), "utf8")))
|
|
2112
|
+
return { tier: "recommended", framework, guidance: "This app uses the Backify runtime: one image built from its Dockerfile runs the web, worker and migrate roles. This assessment does not verify deployment or authorization." };
|
|
2111
2113
|
return { tier: "advanced", framework, guidance: "Custom-container hosting is an advanced path, not a guarantee of Backify SDK integration or framework support. Preserve the Dockerfile and verify capability integration separately." };
|
|
2112
2114
|
}
|
|
2113
2115
|
if (framework === "vite" && dependencies.react) {
|
|
@@ -2704,6 +2706,121 @@ var init_mcp_grant = __esm({
|
|
|
2704
2706
|
}
|
|
2705
2707
|
});
|
|
2706
2708
|
|
|
2709
|
+
// src/app/new.ts
|
|
2710
|
+
var new_exports = {};
|
|
2711
|
+
__export(new_exports, {
|
|
2712
|
+
TEMPLATES: () => TEMPLATES,
|
|
2713
|
+
bundledCliVersion: () => bundledCliVersion,
|
|
2714
|
+
createApp: () => createApp,
|
|
2715
|
+
templatesDirectory: () => templatesDirectory
|
|
2716
|
+
});
|
|
2717
|
+
import { cpSync as cpSync2, existsSync as existsSync8, mkdirSync as mkdirSync2, mkdtempSync as mkdtempSync2, readdirSync as readdirSync3, readFileSync as readFileSync9, renameSync as renameSync2, rmSync as rmSync2, statSync, writeFileSync as writeFileSync7 } from "node:fs";
|
|
2718
|
+
import { tmpdir } from "node:os";
|
|
2719
|
+
import { dirname as dirname4, join as join9, resolve as resolve4 } from "node:path";
|
|
2720
|
+
import { fileURLToPath } from "node:url";
|
|
2721
|
+
function templatesDirectory() {
|
|
2722
|
+
const here = dirname4(fileURLToPath(import.meta.url));
|
|
2723
|
+
for (const candidate of [join9(here, "..", "templates"), join9(here, "..", "..", "templates")]) if (existsSync8(join9(candidate, "common"))) return candidate;
|
|
2724
|
+
throw new Error("Templates are missing from this installation of @backifydev/cli");
|
|
2725
|
+
}
|
|
2726
|
+
function bundledCliVersion() {
|
|
2727
|
+
try {
|
|
2728
|
+
return JSON.parse(readFileSync9(join9(templatesDirectory(), "..", "package.json"), "utf8")).version;
|
|
2729
|
+
} catch {
|
|
2730
|
+
return void 0;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
function walk(directory) {
|
|
2734
|
+
return readdirSync3(directory).flatMap((name2) => {
|
|
2735
|
+
const path = join9(directory, name2);
|
|
2736
|
+
return statSync(path).isDirectory() ? walk(path) : [path];
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
function isSetupManifest(path) {
|
|
2740
|
+
try {
|
|
2741
|
+
const manifest = JSON.parse(readFileSync9(path, "utf8"));
|
|
2742
|
+
const packages = Object.keys({ ...manifest.dependencies, ...manifest.devDependencies });
|
|
2743
|
+
const scripts = Object.keys(manifest.scripts ?? {});
|
|
2744
|
+
return scripts.length === 0 && packages.every((name2) => name2.startsWith("@backifydev/")) && !manifest.workspaces && !manifest.main && !manifest.bin;
|
|
2745
|
+
} catch {
|
|
2746
|
+
return false;
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
function isSetupEntry(entry, root) {
|
|
2750
|
+
const name2 = entry.name.toLowerCase();
|
|
2751
|
+
if (name2 === ".git") return true;
|
|
2752
|
+
if (entry.isDirectory()) return name2 === "node_modules" || isToolWorkspaceEntry(entry, root);
|
|
2753
|
+
if (name2 === "package.json") return isSetupManifest(join9(root, entry.name));
|
|
2754
|
+
return ["package-lock.json", "backify.json"].includes(name2) || isToolWorkspaceEntry(entry, root);
|
|
2755
|
+
}
|
|
2756
|
+
function installedVersion(root, name2) {
|
|
2757
|
+
try {
|
|
2758
|
+
return JSON.parse(readFileSync9(join9(root, "node_modules", ...name2.split("/"), "package.json"), "utf8")).version;
|
|
2759
|
+
} catch {
|
|
2760
|
+
return void 0;
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
function mergeIgnoreFile(template, destination) {
|
|
2764
|
+
const current = readFileSync9(destination, "utf8");
|
|
2765
|
+
const present2 = new Set(current.split(/\r?\n/).map((line) => line.trim()));
|
|
2766
|
+
const missing = readFileSync9(template, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !present2.has(line));
|
|
2767
|
+
if (!missing.length) return false;
|
|
2768
|
+
writeFileSync7(destination, (current && !current.endsWith("\n") ? current + "\n" : current) + missing.join("\n") + "\n");
|
|
2769
|
+
return true;
|
|
2770
|
+
}
|
|
2771
|
+
function createApp(options) {
|
|
2772
|
+
if (!/^[a-z][a-z0-9-]{0,62}$/.test(options.name)) throw new Error("The app name must be lowercase letters, digits and hyphens, starting with a letter");
|
|
2773
|
+
if (!TEMPLATES.includes(options.template)) throw new Error("Choose a template: " + TEMPLATES.join(", "));
|
|
2774
|
+
const target = resolve4(options.directory);
|
|
2775
|
+
const existing = existsSync8(target) ? readdirSync3(target, { withFileTypes: true }) : [];
|
|
2776
|
+
const blocking = existing.filter((entry) => !isSetupEntry(entry, target)).map((entry) => entry.name);
|
|
2777
|
+
if (blocking.length) throw new Error(`${target} is not empty: ${blocking.slice(0, 5).join(", ")}${blocking.length > 5 ? ", ..." : ""} would be overwritten. backify new writes only into an empty folder or a freshly connected workspace (Git metadata, the Backify workflow, tool instructions and the files backify init created).`);
|
|
2778
|
+
const connected = existing.length ? readProjectMetadata(target) : {};
|
|
2779
|
+
const sdkVersion = installedVersion(target, "@backifydev/sdk") ?? options.sdkVersion;
|
|
2780
|
+
const staging = mkdtempSync2(join9(tmpdir(), "backify-new-"));
|
|
2781
|
+
try {
|
|
2782
|
+
const templates = templatesDirectory();
|
|
2783
|
+
cpSync2(join9(templates, "common"), staging, { recursive: true });
|
|
2784
|
+
cpSync2(join9(templates, options.template), staging, { recursive: true, force: true });
|
|
2785
|
+
for (const hidden of ["_gitignore", "_dockerignore"]) if (existsSync8(join9(staging, hidden))) renameSync2(join9(staging, hidden), join9(staging, "." + hidden.slice(1)));
|
|
2786
|
+
for (const file of walk(staging)) {
|
|
2787
|
+
const text2 = readFileSync9(file, "utf8");
|
|
2788
|
+
const rendered = text2.replaceAll("{{name}}", options.name).replaceAll("{{sdkVersion}}", sdkVersion).replaceAll("{{cliVersion}}", options.cliVersion);
|
|
2789
|
+
if (rendered !== text2) writeFileSync7(file, rendered);
|
|
2790
|
+
}
|
|
2791
|
+
if (connected.instructionFile && connected.instructionFile !== "AGENTS.md") rmSync2(join9(staging, "AGENTS.md"), { force: true });
|
|
2792
|
+
const written = [];
|
|
2793
|
+
mkdirSync2(target, { recursive: true });
|
|
2794
|
+
for (const file of walk(staging)) {
|
|
2795
|
+
const relative4 = file.slice(staging.length + 1);
|
|
2796
|
+
const destination = join9(target, relative4);
|
|
2797
|
+
if (existsSync8(destination) && relative4 !== "package.json") {
|
|
2798
|
+
if ((relative4 === ".gitignore" || relative4 === ".dockerignore") && mergeIgnoreFile(file, destination)) written.push(relative4);
|
|
2799
|
+
continue;
|
|
2800
|
+
}
|
|
2801
|
+
mkdirSync2(dirname4(destination), { recursive: true });
|
|
2802
|
+
cpSync2(file, destination);
|
|
2803
|
+
written.push(relative4);
|
|
2804
|
+
}
|
|
2805
|
+
if (connected.appId && existsSync8(join9(target, APP_CONFIG_FILE))) {
|
|
2806
|
+
rmSync2(join9(target, "backify.json"), { force: true });
|
|
2807
|
+
writeProjectMetadata(target, { appId: connected.appId, instructionVersion: connected.instructionVersion, agent: connected.agent, instructionFile: connected.instructionFile });
|
|
2808
|
+
}
|
|
2809
|
+
return written.map((file) => file.replace(/\\/g, "/")).sort();
|
|
2810
|
+
} finally {
|
|
2811
|
+
rmSync2(staging, { recursive: true, force: true });
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
var TEMPLATES;
|
|
2815
|
+
var init_new = __esm({
|
|
2816
|
+
"src/app/new.ts"() {
|
|
2817
|
+
"use strict";
|
|
2818
|
+
init_project_metadata();
|
|
2819
|
+
init_setup();
|
|
2820
|
+
TEMPLATES = ["web", "api", "worker"];
|
|
2821
|
+
}
|
|
2822
|
+
});
|
|
2823
|
+
|
|
2707
2824
|
// ../../node_modules/zod/v4/core/util.js
|
|
2708
2825
|
var util_exports = {};
|
|
2709
2826
|
__export(util_exports, {
|
|
@@ -3996,7 +4113,7 @@ function datetime(args2) {
|
|
|
3996
4113
|
const timeRegex = args2.local ? `${qualified}|${timeSource({ precision: args2.precision })}` : qualified;
|
|
3997
4114
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
3998
4115
|
}
|
|
3999
|
-
var cuid, cuid2, ulid, xid, ksuid, nanoid, duration,
|
|
4116
|
+
var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid3, uuid7, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base642, base64url, httpProtocol, e164, dateSource, date, anyString, bigint, integer, number, boolean, _null, lowercase, uppercase;
|
|
4000
4117
|
var init_regexes = __esm({
|
|
4001
4118
|
"../../node_modules/zod/v4/core/regexes.js"() {
|
|
4002
4119
|
cuid = /^[cC][0-9a-z]{6,}$/;
|
|
@@ -4006,7 +4123,7 @@ var init_regexes = __esm({
|
|
|
4006
4123
|
ksuid = /^[A-Za-z0-9]{27}$/;
|
|
4007
4124
|
nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
4008
4125
|
duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
4009
|
-
|
|
4126
|
+
guid3 = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
4010
4127
|
uuid7 = (version2) => {
|
|
4011
4128
|
if (!version2)
|
|
4012
4129
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
@@ -5021,7 +5138,7 @@ var init_schemas = __esm({
|
|
|
5021
5138
|
$ZodString.init(inst, def);
|
|
5022
5139
|
});
|
|
5023
5140
|
$ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
5024
|
-
def.pattern ?? (def.pattern =
|
|
5141
|
+
def.pattern ?? (def.pattern = guid3);
|
|
5025
5142
|
$ZodStringFormat.init(inst, def);
|
|
5026
5143
|
});
|
|
5027
5144
|
$ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
@@ -23089,21 +23206,21 @@ __export(mcp_exports, {
|
|
|
23089
23206
|
createCodingMcpServer: () => createCodingMcpServer,
|
|
23090
23207
|
runCodingMcpServer: () => runCodingMcpServer
|
|
23091
23208
|
});
|
|
23092
|
-
import { readFileSync as
|
|
23209
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
23093
23210
|
import { homedir } from "node:os";
|
|
23094
|
-
import { join as
|
|
23211
|
+
import { join as join10 } from "node:path";
|
|
23095
23212
|
import { createHash as createHash3 } from "node:crypto";
|
|
23096
23213
|
function createCodingMcpServer(options = {}) {
|
|
23097
23214
|
const endpoint2 = new URL(options.endpoint ?? process.env.BACKIFY_MCP_URL ?? "https://mcp.backify.dev");
|
|
23098
23215
|
if (endpoint2.username || endpoint2.password || endpoint2.search || endpoint2.hash || endpoint2.protocol !== "https:" && !(endpoint2.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(endpoint2.hostname)))
|
|
23099
23216
|
throw new Error("Backify MCP requires HTTPS (HTTP is allowed only on loopback for development).");
|
|
23100
|
-
const configPath2 = options.configPath ??
|
|
23217
|
+
const configPath2 = options.configPath ?? join10(homedir(), ".backify.json");
|
|
23101
23218
|
let boundOrganizationId = options.organizationId;
|
|
23102
23219
|
let delegated;
|
|
23103
23220
|
const server = new Server({ name: "backify", version: "0.2.0" }, { capabilities: { tools: {} }, instructions: "This is a transport bridge to the single Backify MCP at https://mcp.backify.dev. Organization permissions and all tool policies are enforced there. Sign-in is an explicit terminal action, never an MCP tool." });
|
|
23104
23221
|
const readConfig = () => {
|
|
23105
23222
|
try {
|
|
23106
|
-
return JSON.parse(
|
|
23223
|
+
return JSON.parse(readFileSync10(configPath2, "utf8"));
|
|
23107
23224
|
} catch {
|
|
23108
23225
|
throw new McpError(ErrorCode.InvalidRequest, signIn);
|
|
23109
23226
|
}
|
|
@@ -23196,7 +23313,7 @@ __export(ops_exports, {
|
|
|
23196
23313
|
runOps: () => runOps,
|
|
23197
23314
|
terminalConfirm: () => terminalConfirm
|
|
23198
23315
|
});
|
|
23199
|
-
import { readFileSync as
|
|
23316
|
+
import { readFileSync as readFileSync11, writeFileSync as writeFileSync8 } from "node:fs";
|
|
23200
23317
|
import { basename as basename2, extname } from "node:path";
|
|
23201
23318
|
import { createInterface } from "node:readline/promises";
|
|
23202
23319
|
function opsArguments(args2) {
|
|
@@ -23269,7 +23386,7 @@ function signInRequired(organizationId) {
|
|
|
23269
23386
|
async function signIn2(context2, organizationId) {
|
|
23270
23387
|
const read = () => {
|
|
23271
23388
|
try {
|
|
23272
|
-
return JSON.parse(
|
|
23389
|
+
return JSON.parse(readFileSync11(context2.configPath, "utf8"));
|
|
23273
23390
|
} catch {
|
|
23274
23391
|
throw signInRequired(organizationId);
|
|
23275
23392
|
}
|
|
@@ -23367,9 +23484,9 @@ function requireScopes(operation, session) {
|
|
|
23367
23484
|
if (missing === null || missing.length) throw forbiddenError({ code: "insufficient_scope", requiredScopes: missing === null ? void 0 : missing }, session.organizationId, operation.id);
|
|
23368
23485
|
}
|
|
23369
23486
|
function readInput(path, context2, what) {
|
|
23370
|
-
if (path === "-") return (context2.readStdin ?? (() =>
|
|
23487
|
+
if (path === "-") return (context2.readStdin ?? (() => readFileSync11(0)))();
|
|
23371
23488
|
try {
|
|
23372
|
-
return
|
|
23489
|
+
return readFileSync11(path);
|
|
23373
23490
|
} catch {
|
|
23374
23491
|
throw new OpsError(`Cannot read ${what} ${path}.`, "invalid_input");
|
|
23375
23492
|
}
|
|
@@ -23438,7 +23555,7 @@ function toFetchBody(body) {
|
|
|
23438
23555
|
}
|
|
23439
23556
|
function present(response, output) {
|
|
23440
23557
|
if (output) {
|
|
23441
|
-
|
|
23558
|
+
writeFileSync8(output, response.bytes);
|
|
23442
23559
|
const value2 = { output, bytes: response.bytes.length, contentType: response.contentType || null };
|
|
23443
23560
|
return { value: value2, text: `Saved ${response.bytes.length} bytes to ${output}.` };
|
|
23444
23561
|
}
|
|
@@ -23633,7 +23750,7 @@ __export(tasks_exports, {
|
|
|
23633
23750
|
taskDraft: () => taskDraft,
|
|
23634
23751
|
taskHelp: () => taskHelp
|
|
23635
23752
|
});
|
|
23636
|
-
import { readFileSync as
|
|
23753
|
+
import { readFileSync as readFileSync12 } from "node:fs";
|
|
23637
23754
|
function taskArguments(args2) {
|
|
23638
23755
|
const options = { noBrowser: false, noWait: false, json: false, yes: false };
|
|
23639
23756
|
const positional = [], values = {};
|
|
@@ -23675,7 +23792,7 @@ function taskArguments(args2) {
|
|
|
23675
23792
|
}
|
|
23676
23793
|
return { options, positional, values };
|
|
23677
23794
|
}
|
|
23678
|
-
function taskDraft(values, read = (path) =>
|
|
23795
|
+
function taskDraft(values, read = (path) => readFileSync12(path, "utf8")) {
|
|
23679
23796
|
let draft = {};
|
|
23680
23797
|
for (const source of values.draft ?? []) {
|
|
23681
23798
|
const parsed = JSON.parse(source.startsWith("@") ? read(source.slice(1)) : source);
|
|
@@ -23713,7 +23830,7 @@ async function follow(call2, initial, options, context2) {
|
|
|
23713
23830
|
now: context2.now,
|
|
23714
23831
|
intervalMs: context2.intervalMs
|
|
23715
23832
|
}, purposes[initial.kind] ?? "complete the request");
|
|
23716
|
-
const value = { taskId: status.id, kind: status.kind, state: status.state, url: link,
|
|
23833
|
+
const value = { taskId: status.id, kind: status.kind, state: status.state, url: link, nextAction: status.nextAction, result: status.result, ...reason ? { waiting: reason } : {} };
|
|
23717
23834
|
const exitCode = status.state === "completed" ? 0 : status.state === "pending" ? 2 : 1;
|
|
23718
23835
|
const text2 = status.state === "pending" ? `The task is waiting for a person: ${link}` + (reason === "timed_out" ? "\nStopped waiting. Resume with backify task wait " + status.id : "") : `${status.state}: ${status.nextAction}` + (status.result ? "\n" + JSON.stringify(status.result, null, 2) : "");
|
|
23719
23836
|
return { value, text: text2, exitCode };
|
|
@@ -23936,8 +24053,8 @@ __export(coding_tools_exports, {
|
|
|
23936
24053
|
codingTools: () => codingTools,
|
|
23937
24054
|
configureCodingTool: () => configureCodingTool
|
|
23938
24055
|
});
|
|
23939
|
-
import { existsSync as
|
|
23940
|
-
import { basename as basename3, dirname as
|
|
24056
|
+
import { existsSync as existsSync9, lstatSync as lstatSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync13, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync9 } from "node:fs";
|
|
24057
|
+
import { basename as basename3, dirname as dirname5, join as join11, resolve as resolve5 } from "node:path";
|
|
23941
24058
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
23942
24059
|
function object7(value) {
|
|
23943
24060
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -23955,13 +24072,13 @@ function configureCodingTool(options) {
|
|
|
23955
24072
|
if (transport !== "http" && transport !== "stdio") throw new Error("Select --transport http or stdio.");
|
|
23956
24073
|
const relative4 = options.configPath ?? defaultPaths[agent];
|
|
23957
24074
|
if (!relative4) throw new Error("Open this tool's MCP configuration and supply its exact path with --config. Backify will not guess or modify an editor's global storage.");
|
|
23958
|
-
const path =
|
|
23959
|
-
for (let current = path; ; current =
|
|
23960
|
-
if (
|
|
23961
|
-
if (
|
|
24075
|
+
const path = resolve5(options.root ?? process.cwd(), relative4);
|
|
24076
|
+
for (let current = path; ; current = dirname5(current)) {
|
|
24077
|
+
if (existsSync9(current) && (lstatSync4(current).isSymbolicLink() || current === path && !lstatSync4(current).isFile())) throw new Error("MCP configuration cannot traverse symlinks or replace a directory.");
|
|
24078
|
+
if (dirname5(current) === current) break;
|
|
23962
24079
|
}
|
|
23963
24080
|
if (options.dryRun) return { agent, transport, path, entry: codingToolEntry(agent, transport), changed: void 0 };
|
|
23964
|
-
const previous =
|
|
24081
|
+
const previous = existsSync9(path) ? readFileSync13(path, "utf8") : void 0;
|
|
23965
24082
|
let config2;
|
|
23966
24083
|
try {
|
|
23967
24084
|
config2 = previous === void 0 ? {} : JSON.parse(previous);
|
|
@@ -23977,14 +24094,14 @@ function configureCodingTool(options) {
|
|
|
23977
24094
|
if (servers.backify !== void 0 && changed && !options.dryRun) throw new Error("An existing Backify MCP configuration differs. It is unchanged; inspect --dry-run and update it manually.");
|
|
23978
24095
|
const result = { agent, transport, path, entry, changed };
|
|
23979
24096
|
if (options.dryRun || !changed) return result;
|
|
23980
|
-
|
|
24097
|
+
mkdirSync3(dirname5(path), { recursive: true });
|
|
23981
24098
|
const temporary = path + "." + randomUUID5() + ".tmp";
|
|
23982
24099
|
try {
|
|
23983
|
-
|
|
23984
|
-
if ((
|
|
23985
|
-
|
|
24100
|
+
writeFileSync9(temporary, JSON.stringify({ ...config2, [key]: { ...servers, backify: entry } }, null, 2) + "\n", { flag: "wx", mode: existsSync9(path) ? lstatSync4(path).mode & 511 : 384 });
|
|
24101
|
+
if ((existsSync9(path) ? readFileSync13(path, "utf8") : void 0) !== previous) throw new Error("MCP configuration changed during setup. Retry after reviewing it.");
|
|
24102
|
+
renameSync3(temporary, path);
|
|
23986
24103
|
} finally {
|
|
23987
|
-
if (
|
|
24104
|
+
if (existsSync9(temporary)) unlinkSync2(temporary);
|
|
23988
24105
|
}
|
|
23989
24106
|
return result;
|
|
23990
24107
|
}
|
|
@@ -23995,9 +24112,9 @@ var init_coding_tools = __esm({
|
|
|
23995
24112
|
codingTools = ["copilot", "cursor", "gemini", "cline", "windsurf"];
|
|
23996
24113
|
endpoint = "https://mcp.backify.dev";
|
|
23997
24114
|
defaultPaths = {
|
|
23998
|
-
copilot:
|
|
23999
|
-
cursor:
|
|
24000
|
-
gemini:
|
|
24115
|
+
copilot: join11(".vscode", "mcp.json"),
|
|
24116
|
+
cursor: join11(".cursor", "mcp.json"),
|
|
24117
|
+
gemini: join11(".gemini", "settings.json")
|
|
24001
24118
|
};
|
|
24002
24119
|
}
|
|
24003
24120
|
});
|
|
@@ -24014,16 +24131,16 @@ __export(project_exports, {
|
|
|
24014
24131
|
sdkRunner: () => sdkRunner
|
|
24015
24132
|
});
|
|
24016
24133
|
import { spawn } from "node:child_process";
|
|
24017
|
-
import { existsSync as
|
|
24134
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync4, readFileSync as readFileSync14 } from "node:fs";
|
|
24018
24135
|
import { createRequire } from "node:module";
|
|
24019
|
-
import { dirname as
|
|
24136
|
+
import { dirname as dirname6, join as join12, relative as relative2, resolve as resolve6 } from "node:path";
|
|
24020
24137
|
import { pathToFileURL } from "node:url";
|
|
24021
24138
|
import { build } from "esbuild";
|
|
24022
24139
|
async function loadConfig(root) {
|
|
24023
|
-
const file =
|
|
24024
|
-
if (!
|
|
24025
|
-
const out =
|
|
24026
|
-
|
|
24140
|
+
const file = join12(root, CONFIG_FILE);
|
|
24141
|
+
if (!existsSync10(file)) throw new ProjectError(`${CONFIG_FILE} was not found in ${root}. Create one with \`backify init\`.`);
|
|
24142
|
+
const out = join12(root, ".backify", "build", "config.mjs");
|
|
24143
|
+
mkdirSync4(dirname6(out), { recursive: true });
|
|
24027
24144
|
await build({ entryPoints: [file], bundle: true, platform: "node", format: "esm", outfile: out, packages: "external", logLevel: "silent", absWorkingDir: root });
|
|
24028
24145
|
const module = await import(pathToFileURL(out).href + "?t=" + Date.now());
|
|
24029
24146
|
const value = module.default ?? module.config;
|
|
@@ -24033,18 +24150,18 @@ async function loadConfig(root) {
|
|
|
24033
24150
|
return value;
|
|
24034
24151
|
}
|
|
24035
24152
|
function sdkRunner(root) {
|
|
24036
|
-
const lookup = createRequire(
|
|
24037
|
-
const manifest = lookup.map((directory) =>
|
|
24153
|
+
const lookup = createRequire(join12(root, "package.json")).resolve.paths("@backifydev/sdk") ?? [];
|
|
24154
|
+
const manifest = lookup.map((directory) => join12(directory, "@backifydev", "sdk", "package.json")).find((path) => existsSync10(path));
|
|
24038
24155
|
if (!manifest) throw new ProjectError("@backifydev/sdk is not installed. Run npm install.");
|
|
24039
|
-
const version2 = JSON.parse(
|
|
24040
|
-
const runner =
|
|
24041
|
-
if (!
|
|
24156
|
+
const version2 = JSON.parse(readFileSync14(manifest, "utf8")).version;
|
|
24157
|
+
const runner = join12(dirname6(manifest), "dist", "app", "run.js");
|
|
24158
|
+
if (!existsSync10(runner)) throw new ProjectError(`The installed @backifydev/sdk ${version2} does not include backify-run. Update it with npm install @backifydev/sdk@latest.`);
|
|
24042
24159
|
return { runner, version: version2 };
|
|
24043
24160
|
}
|
|
24044
24161
|
async function bundleServer(root, entry, outName = "server.mjs") {
|
|
24045
|
-
const out =
|
|
24162
|
+
const out = join12(root, ".backify", "build", outName);
|
|
24046
24163
|
const result = await build({
|
|
24047
|
-
entryPoints: [
|
|
24164
|
+
entryPoints: [resolve6(root, entry)],
|
|
24048
24165
|
bundle: true,
|
|
24049
24166
|
platform: "node",
|
|
24050
24167
|
format: "esm",
|
|
@@ -24061,7 +24178,7 @@ async function bundleServer(root, entry, outName = "server.mjs") {
|
|
|
24061
24178
|
return { file: out, inputs: sourceInputs(root, result.metafile) };
|
|
24062
24179
|
}
|
|
24063
24180
|
function sourceInputs(root, metafile) {
|
|
24064
|
-
return Object.keys(metafile.inputs).filter((path) => !path.includes("node_modules")).map((path) => relative2(root,
|
|
24181
|
+
return Object.keys(metafile.inputs).filter((path) => !path.includes("node_modules")).map((path) => relative2(root, resolve6(root, path)).replace(/\\/g, "/")).sort();
|
|
24065
24182
|
}
|
|
24066
24183
|
function isolatedEnv(extra = {}) {
|
|
24067
24184
|
const keep = ["PATH", "Path", "SystemRoot", "TEMP", "TMP", "HOME", "USERPROFILE", "APPDATA", "LOCALAPPDATA"];
|
|
@@ -24115,7 +24232,7 @@ __export(signup_exports, {
|
|
|
24115
24232
|
signupArguments: () => signupArguments,
|
|
24116
24233
|
signupHelp: () => signupHelp
|
|
24117
24234
|
});
|
|
24118
|
-
import { readFileSync as
|
|
24235
|
+
import { readFileSync as readFileSync15 } from "node:fs";
|
|
24119
24236
|
function signupArguments(args2) {
|
|
24120
24237
|
const values = {}, flags = /* @__PURE__ */ new Set();
|
|
24121
24238
|
for (let i = 0; i < args2.length; i++) {
|
|
@@ -24134,7 +24251,7 @@ function signupArguments(args2) {
|
|
|
24134
24251
|
if (values["--plan"] && !["starter", "team", "business"].includes(values["--plan"])) throw new Error("Use --plan starter, team or business.");
|
|
24135
24252
|
if (values["--interval"] && !["month", "year"].includes(values["--interval"])) throw new Error("Use --interval month or year.");
|
|
24136
24253
|
if (values["--currency"] && !["eur", "usd"].includes(values["--currency"])) throw new Error("Use --currency eur or usd.");
|
|
24137
|
-
const company = values["--company"] ? JSON.parse(
|
|
24254
|
+
const company = values["--company"] ? JSON.parse(readFileSync15(values["--company"], "utf8")) : void 0;
|
|
24138
24255
|
if (company !== void 0 && (typeof company !== "object" || company === null || Array.isArray(company))) throw new Error("--company must be a JSON file holding one object of company details.");
|
|
24139
24256
|
const draft = Object.fromEntries(Object.entries({ organizationName: values["--name"], company, plan: values["--plan"], interval: values["--interval"], currency: values["--currency"], scopes: scopes2 ? [.../* @__PURE__ */ new Set(["organization:read", ...scopes2])] : void 0 }).filter(([, value]) => value !== void 0));
|
|
24140
24257
|
return { draft, resume: flags.has("--resume"), noBrowser: flags.has("--no-browser"), noWait: flags.has("--no-wait"), timeoutMs: values["--timeout"] === void 0 ? void 0 : Number(values["--timeout"]) * 1e3 };
|
|
@@ -24205,53 +24322,6 @@ connected; 2 means it is still waiting for you, or you declined. Resume a waitin
|
|
|
24205
24322
|
}
|
|
24206
24323
|
});
|
|
24207
24324
|
|
|
24208
|
-
// src/app/new.ts
|
|
24209
|
-
var new_exports = {};
|
|
24210
|
-
__export(new_exports, {
|
|
24211
|
-
TEMPLATES: () => TEMPLATES,
|
|
24212
|
-
createApp: () => createApp,
|
|
24213
|
-
templatesDirectory: () => templatesDirectory
|
|
24214
|
-
});
|
|
24215
|
-
import { cpSync as cpSync2, existsSync as existsSync10, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync15, renameSync as renameSync3, statSync, writeFileSync as writeFileSync9 } from "node:fs";
|
|
24216
|
-
import { dirname as dirname6, join as join12, resolve as resolve6 } from "node:path";
|
|
24217
|
-
import { fileURLToPath } from "node:url";
|
|
24218
|
-
function templatesDirectory() {
|
|
24219
|
-
const here = dirname6(fileURLToPath(import.meta.url));
|
|
24220
|
-
for (const candidate of [join12(here, "..", "templates"), join12(here, "..", "..", "templates")]) if (existsSync10(join12(candidate, "common"))) return candidate;
|
|
24221
|
-
throw new Error("Templates are missing from this installation of @backifydev/cli");
|
|
24222
|
-
}
|
|
24223
|
-
function walk(directory) {
|
|
24224
|
-
return readdirSync3(directory).flatMap((name2) => {
|
|
24225
|
-
const path = join12(directory, name2);
|
|
24226
|
-
return statSync(path).isDirectory() ? walk(path) : [path];
|
|
24227
|
-
});
|
|
24228
|
-
}
|
|
24229
|
-
function createApp(options) {
|
|
24230
|
-
if (!/^[a-z][a-z0-9-]{0,62}$/.test(options.name)) throw new Error("The app name must be lowercase letters, digits and hyphens, starting with a letter");
|
|
24231
|
-
if (!TEMPLATES.includes(options.template)) throw new Error("Choose a template: " + TEMPLATES.join(", "));
|
|
24232
|
-
const target = resolve6(options.directory);
|
|
24233
|
-
if (existsSync10(target) && readdirSync3(target).length) throw new Error(`${target} is not empty`);
|
|
24234
|
-
mkdirSync4(target, { recursive: true });
|
|
24235
|
-
const templates = templatesDirectory();
|
|
24236
|
-
cpSync2(join12(templates, "common"), target, { recursive: true });
|
|
24237
|
-
cpSync2(join12(templates, options.template), target, { recursive: true, force: true });
|
|
24238
|
-
for (const hidden of ["_gitignore", "_dockerignore"]) if (existsSync10(join12(target, hidden))) renameSync3(join12(target, hidden), join12(target, "." + hidden.slice(1)));
|
|
24239
|
-
const files = walk(target);
|
|
24240
|
-
for (const file of files) {
|
|
24241
|
-
const text2 = readFileSync15(file, "utf8");
|
|
24242
|
-
const rendered = text2.replaceAll("{{name}}", options.name).replaceAll("{{sdkVersion}}", options.sdkVersion).replaceAll("{{cliVersion}}", options.cliVersion);
|
|
24243
|
-
if (rendered !== text2) writeFileSync9(file, rendered);
|
|
24244
|
-
}
|
|
24245
|
-
return files.map((file) => file.slice(target.length + 1).replace(/\\/g, "/")).sort();
|
|
24246
|
-
}
|
|
24247
|
-
var TEMPLATES;
|
|
24248
|
-
var init_new = __esm({
|
|
24249
|
-
"src/app/new.ts"() {
|
|
24250
|
-
"use strict";
|
|
24251
|
-
TEMPLATES = ["web", "api", "worker"];
|
|
24252
|
-
}
|
|
24253
|
-
});
|
|
24254
|
-
|
|
24255
24325
|
// ../analyzer/dist/app-declarations.js
|
|
24256
24326
|
import ts2 from "typescript";
|
|
24257
24327
|
function enclosingBlocker(node2) {
|
|
@@ -30207,7 +30277,7 @@ var init_esm2 = __esm({
|
|
|
30207
30277
|
// src/app/local-postgres.ts
|
|
30208
30278
|
import { spawn as spawn3, spawnSync as spawnSync5 } from "node:child_process";
|
|
30209
30279
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
30210
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync5, readdirSync as readdirSync5, readFileSync as readFileSync18, rmSync as
|
|
30280
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync5, readdirSync as readdirSync5, readFileSync as readFileSync18, rmSync as rmSync3, writeFileSync as writeFileSync11 } from "node:fs";
|
|
30211
30281
|
import { createServer as createServer3 } from "node:net";
|
|
30212
30282
|
import { join as join16 } from "node:path";
|
|
30213
30283
|
function findPostgresBin() {
|
|
@@ -30250,14 +30320,14 @@ async function startLocalDatabase(root, extensions = []) {
|
|
|
30250
30320
|
mkdirSync5(home, { recursive: true });
|
|
30251
30321
|
let state = existsSync13(statePath) ? JSON.parse(readFileSync18(statePath, "utf8")) : void 0;
|
|
30252
30322
|
if (!state || !existsSync13(join16(data, "PG_VERSION"))) {
|
|
30253
|
-
|
|
30323
|
+
rmSync3(data, { recursive: true, force: true });
|
|
30254
30324
|
state = { password: randomBytes3(24).toString("base64url"), port: await freePort(55432) };
|
|
30255
30325
|
const pwfile = join16(home, "pw.tmp");
|
|
30256
30326
|
writeFileSync11(pwfile, state.password, { mode: 384 });
|
|
30257
30327
|
try {
|
|
30258
30328
|
run(bin, "initdb", ["-D", data, "-U", "backify_admin", "--auth-host=scram-sha-256", "--auth-local=scram-sha-256", "--pwfile=" + pwfile, "--no-locale", "--encoding=UTF8"]);
|
|
30259
30329
|
} finally {
|
|
30260
|
-
|
|
30330
|
+
rmSync3(pwfile, { force: true });
|
|
30261
30331
|
}
|
|
30262
30332
|
writeFileSync11(statePath, JSON.stringify(state), { mode: 384 });
|
|
30263
30333
|
}
|
|
@@ -30366,7 +30436,7 @@ var init_local_postgres = __esm({
|
|
|
30366
30436
|
|
|
30367
30437
|
// src/app/local-gateway.ts
|
|
30368
30438
|
import { createHmac, generateKeyPairSync, randomBytes as randomBytes4, sign as rsaSign, timingSafeEqual } from "node:crypto";
|
|
30369
|
-
import { createReadStream, existsSync as existsSync14, mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync19, rmSync as
|
|
30439
|
+
import { createReadStream, existsSync as existsSync14, mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync19, rmSync as rmSync4, statSync as statSync2, writeFileSync as writeFileSync12 } from "node:fs";
|
|
30370
30440
|
import { createServer as createServer4, request as httpRequest } from "node:http";
|
|
30371
30441
|
import { connect } from "node:net";
|
|
30372
30442
|
import { dirname as dirname7, join as join17, relative as relative3, resolve as resolve7, sep } from "node:path";
|
|
@@ -30616,8 +30686,7 @@ function startGateway(options) {
|
|
|
30616
30686
|
}
|
|
30617
30687
|
if (path === "/v1/http/fetch") {
|
|
30618
30688
|
const target = new URL(String(body.url));
|
|
30619
|
-
|
|
30620
|
-
if (!allowed || target.protocol !== "https:") return brokerError(res, 403, "host_not_allowed", `${target.hostname} is not in backify.config.ts http.allow (https only)`);
|
|
30689
|
+
if (target.protocol !== "https:") return brokerError(res, 403, "https_required", `Outbound HTTP to ${target.hostname} must use https`);
|
|
30621
30690
|
const response = await fetch(target, { method: String(body.method ?? "GET"), headers: body.headers, body: body.body, signal: AbortSignal.timeout(Number(body.timeoutSeconds ?? 30) * 1e3) });
|
|
30622
30691
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
30623
30692
|
return json(res, 200, { status: response.status, headers: Object.fromEntries(response.headers), body: bytes.toString("base64"), encoding: "base64" });
|
|
@@ -30651,8 +30720,8 @@ function startGateway(options) {
|
|
|
30651
30720
|
return res.end();
|
|
30652
30721
|
}
|
|
30653
30722
|
if (req.method === "DELETE") {
|
|
30654
|
-
|
|
30655
|
-
|
|
30723
|
+
rmSync4(path, { force: true });
|
|
30724
|
+
rmSync4(path + ".meta.json", { force: true });
|
|
30656
30725
|
res.writeHead(202);
|
|
30657
30726
|
return res.end();
|
|
30658
30727
|
}
|
|
@@ -30696,7 +30765,8 @@ var init_local_gateway = __esm({
|
|
|
30696
30765
|
// src/app/dev.ts
|
|
30697
30766
|
var dev_exports = {};
|
|
30698
30767
|
__export(dev_exports, {
|
|
30699
|
-
devCommand: () => devCommand
|
|
30768
|
+
devCommand: () => devCommand,
|
|
30769
|
+
resolveGatewayPort: () => resolveGatewayPort
|
|
30700
30770
|
});
|
|
30701
30771
|
import { spawn as spawn4 } from "node:child_process";
|
|
30702
30772
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
@@ -30740,7 +30810,7 @@ async function devCommand(rootArg, options = {}) {
|
|
|
30740
30810
|
say("backify", `Starting ${config2.app.name} (${config2.kind})`, 35);
|
|
30741
30811
|
const database = needsDatabase ? await startLocalDatabase(root, config2.database?.extensions) : void 0;
|
|
30742
30812
|
if (database) say("db", `PostgreSQL on 127.0.0.1:${database.port} (data in .backify/dev/postgres)`, 34);
|
|
30743
|
-
const gatewayPort = options.port
|
|
30813
|
+
const gatewayPort = await resolveGatewayPort(options.port);
|
|
30744
30814
|
const identity = createDevIdentity("local", "local");
|
|
30745
30815
|
const workloadToken = "dev-" + randomBytes5(16).toString("hex");
|
|
30746
30816
|
const healthPath = config2.server?.health ?? "/healthz";
|
|
@@ -30848,7 +30918,7 @@ async function devCommand(rootArg, options = {}) {
|
|
|
30848
30918
|
await database?.stop();
|
|
30849
30919
|
return 0;
|
|
30850
30920
|
}
|
|
30851
|
-
var color, say;
|
|
30921
|
+
var color, say, resolveGatewayPort;
|
|
30852
30922
|
var init_dev = __esm({
|
|
30853
30923
|
"src/app/dev.ts"() {
|
|
30854
30924
|
"use strict";
|
|
@@ -30858,6 +30928,7 @@ var init_dev = __esm({
|
|
|
30858
30928
|
init_project();
|
|
30859
30929
|
color = (code, text2) => process.stdout.isTTY ? `\x1B[${code}m${text2}\x1B[0m` : text2;
|
|
30860
30930
|
say = (label, message, code = 36) => console.log(`${color(code, label.padEnd(8))} ${message}`);
|
|
30931
|
+
resolveGatewayPort = (requested) => requested ? Promise.resolve(requested) : freePort(3e3);
|
|
30861
30932
|
}
|
|
30862
30933
|
});
|
|
30863
30934
|
|
|
@@ -31235,7 +31306,7 @@ import { domainToASCII } from "node:url";
|
|
|
31235
31306
|
var domainConnectHelp = `backify domains connect [hostname] [--app <application>] [--environment preview|production]
|
|
31236
31307
|
backify domains connect --request <UUID> [--app <application>]
|
|
31237
31308
|
Options: --hostname <hostname> --no-browser --no-wait --timeout <seconds, 1-3600> --json
|
|
31238
|
-
Requests a Backify task and opens its page, where an authorized user signs in
|
|
31309
|
+
Requests a Backify task and opens its page, where an authorized user signs in
|
|
31239
31310
|
and confirms the hostname and environment. Returns as soon as the domain is confirmed. It does not wait for DNS: Backify verifies the DNS records, issues managed HTTPS and starts
|
|
31240
31311
|
routing automatically once the user adds them. Exit code 0 means confirmed; 2 means not yet confirmed or blocked.
|
|
31241
31312
|
Re-run with --request <task-id> to read the current status without reopening the browser.`;
|
|
@@ -31279,7 +31350,6 @@ async function connectDomain(call2, options) {
|
|
|
31279
31350
|
certificateStatus: status?.certificateStatus ?? null,
|
|
31280
31351
|
bindingStatus: status?.bindingStatus ?? null,
|
|
31281
31352
|
setupUrl: link,
|
|
31282
|
-
matchCode: initial.matchCode ?? null,
|
|
31283
31353
|
nextAction: task.nextAction,
|
|
31284
31354
|
// The address the domain will serve once DNS is verified; `url` is set only when it already does.
|
|
31285
31355
|
expectedUrl: status?.hostname ? "https://" + status.hostname : null,
|
|
@@ -31474,6 +31544,63 @@ function privacyRequestCall(appId, args2) {
|
|
|
31474
31544
|
}
|
|
31475
31545
|
}
|
|
31476
31546
|
|
|
31547
|
+
// src/outbound-http.ts
|
|
31548
|
+
var outboundHttpUsage = [
|
|
31549
|
+
"Use backify outbound <action> --environment <UUID> [--app <application-id>]:",
|
|
31550
|
+
" show default action and rules",
|
|
31551
|
+
" default allow|deny what happens to destinations no rule matches (allow is the default)",
|
|
31552
|
+
" allow|block <pattern> allow or block a host (api.example.com), a wildcard ('*.example.com')",
|
|
31553
|
+
" or an HTTPS URL (https://api.example.com/v1/*); a block always wins",
|
|
31554
|
+
" remove <rule-id>",
|
|
31555
|
+
" destinations [--search <text>] URLs requested in the last 30 days with what the rules decide now",
|
|
31556
|
+
" requests [--search <text>] [--outcome allowed|blocked|not-allowed]",
|
|
31557
|
+
"List environments with backify events environments. Quote wildcards so your shell does not expand them."
|
|
31558
|
+
].join("\n");
|
|
31559
|
+
var guid2 = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
|
|
31560
|
+
function outboundHttpCall(appId, args2) {
|
|
31561
|
+
const option2 = (name2) => {
|
|
31562
|
+
const index = args2.indexOf(name2);
|
|
31563
|
+
return index >= 0 ? args2[index + 1] : void 0;
|
|
31564
|
+
};
|
|
31565
|
+
const [action, value] = args2;
|
|
31566
|
+
const environment = option2("--environment");
|
|
31567
|
+
if (!action || !environment || !guid2.test(environment)) throw new Error(outboundHttpUsage);
|
|
31568
|
+
const base = `/apps/${appId}/outbound-http/environments/${environment}`;
|
|
31569
|
+
const query = (names) => {
|
|
31570
|
+
const params = new URLSearchParams();
|
|
31571
|
+
for (const name2 of names) {
|
|
31572
|
+
const item = option2("--" + name2);
|
|
31573
|
+
if (item) params.set(name2, item);
|
|
31574
|
+
}
|
|
31575
|
+
const text2 = params.toString();
|
|
31576
|
+
return text2 ? "?" + text2 : "";
|
|
31577
|
+
};
|
|
31578
|
+
const positional = value !== void 0 && !value.startsWith("--") ? value : void 0;
|
|
31579
|
+
switch (action) {
|
|
31580
|
+
case "show":
|
|
31581
|
+
return { method: "GET", path: base };
|
|
31582
|
+
case "default":
|
|
31583
|
+
if (positional !== "allow" && positional !== "deny") throw new Error("Use backify outbound default allow|deny --environment <UUID>.");
|
|
31584
|
+
return { method: "PUT", path: base + "/default", body: { action: positional } };
|
|
31585
|
+
case "allow":
|
|
31586
|
+
case "block":
|
|
31587
|
+
if (!positional) throw new Error(`Give a host, wildcard or HTTPS URL: backify outbound ${action} <pattern> --environment <UUID>.`);
|
|
31588
|
+
return { method: "POST", path: base + "/rules", body: { pattern: positional, action } };
|
|
31589
|
+
case "remove":
|
|
31590
|
+
if (!positional || !guid2.test(positional)) throw new Error("Give the rule ID from backify outbound show: backify outbound remove <rule-id> --environment <UUID>.");
|
|
31591
|
+
return { method: "DELETE", path: `${base}/rules/${positional}` };
|
|
31592
|
+
case "destinations":
|
|
31593
|
+
return { method: "GET", path: base + "/destinations" + query(["search"]) };
|
|
31594
|
+
case "requests": {
|
|
31595
|
+
const outcome = option2("--outcome");
|
|
31596
|
+
if (outcome !== void 0 && !["allowed", "blocked", "not-allowed"].includes(outcome)) throw new Error("--outcome must be allowed, blocked or not-allowed.");
|
|
31597
|
+
return { method: "GET", path: base + "/requests" + query(["search", "outcome"]) };
|
|
31598
|
+
}
|
|
31599
|
+
default:
|
|
31600
|
+
throw new Error(outboundHttpUsage);
|
|
31601
|
+
}
|
|
31602
|
+
}
|
|
31603
|
+
|
|
31477
31604
|
// src/pairing.ts
|
|
31478
31605
|
async function pairingCode(args2, input) {
|
|
31479
31606
|
const stdinCount = args2.filter((value) => value === "--pair-stdin").length;
|
|
@@ -31640,7 +31767,7 @@ function reconnectingApiClient(session, reconnect2, transport = fetch) {
|
|
|
31640
31767
|
init_development();
|
|
31641
31768
|
init_setup();
|
|
31642
31769
|
init_dist();
|
|
31643
|
-
import { readFileSync as readFileSync21, existsSync as existsSync16, rmSync as
|
|
31770
|
+
import { readFileSync as readFileSync21, existsSync as existsSync16, rmSync as rmSync5 } from "node:fs";
|
|
31644
31771
|
import { homedir as homedir2 } from "node:os";
|
|
31645
31772
|
import { join as join19 } from "node:path";
|
|
31646
31773
|
import { spawn as spawn5 } from "node:child_process";
|
|
@@ -31674,9 +31801,9 @@ var help = [
|
|
|
31674
31801
|
"Coding: tools configure --agent <tool> [--transport http|stdio] [--config <path>] [--dry-run] | mcp [--organization <organization-id>]",
|
|
31675
31802
|
"Org admin: ops search [<query>] | ops describe <operation-id> | ops get|run <operation-id> [--param <name>=<value>] [--body <file>] [--yes] [--organization <id>] [--json]",
|
|
31676
31803
|
"Org tasks: task start <kind> [--draft <json>] | task get|wait|open <id> | github connect | azure connect|reconnect|update-agent|uninstall|remove | org | billing | members add|invite|list|invitations|join-links|domains (backify task --help)",
|
|
31677
|
-
"Delivery: pull | report [--check] | ship [--production-deploy|--preview-only] [--dry-run] | deploy [<application-id>] [<source-revision>] | request",
|
|
31804
|
+
"Delivery: pull | report [--check] | ship [--production-deploy|--preview-only] [--dry-run] | deploy [<application-id>] [<source-revision>] | request | workflow refresh",
|
|
31678
31805
|
" prompt record --stdin --id <UUID>",
|
|
31679
|
-
"Platform: database extensions|insights --environment <UUID> [--hours <n>] | privacy requests list|show|create|update|close|preview | events environments|inspect|test | auth setup [--providers <list>] | domains connect [hostname] | integrations connect <provider>|discover|prepare|status|list|catalog|search|describe|contract|types",
|
|
31806
|
+
"Platform: database extensions|insights --environment <UUID> [--hours <n>] | privacy requests list|show|create|update|close|preview | events environments|inspect|test | outbound show|default|allow|block|remove|destinations|requests --environment <UUID> | auth setup [--providers <list>] | domains connect [hostname] | integrations connect <provider>|discover|prepare|status|list|catalog|search|describe|contract|types",
|
|
31680
31807
|
"",
|
|
31681
31808
|
"Docs: https://docs.backify.dev/"
|
|
31682
31809
|
].join("\n");
|
|
@@ -31693,7 +31820,7 @@ async function browserLogin(appId, organizationId, apiUrl) {
|
|
|
31693
31820
|
if (args.includes("--no-browser")) throw new CliAuthenticationRequired();
|
|
31694
31821
|
const address = apiAddress(apiUrl ?? process.env.BACKIFY_API_URL ?? userConfig.apiUrl ?? "https://api.backify.dev/api");
|
|
31695
31822
|
return browserAuthenticate({ authUrl, apiUrl: address, applicationId: appId ? applicationGuid(appId) : void 0, organizationId, mcp: appId ? void 0 : { endpoint: process.env.BACKIFY_MCP_URL ?? "https://mcp.backify.dev" }, openBrowser: (url2) => {
|
|
31696
|
-
console.error("
|
|
31823
|
+
console.error("Waiting for browser approval; no reply is needed in chat. Sign in, choose the organization and expiration, and approve Backify CLI access. The CLI continues automatically after approval.\n" + url2 + "\nCoding agents: tell the user this as a status update, not a question or input request, and keep waiting for this command to finish.");
|
|
31697
31824
|
openBrowser(url2);
|
|
31698
31825
|
}, save: (session, mcp) => {
|
|
31699
31826
|
if (appId) {
|
|
@@ -31710,8 +31837,20 @@ async function browserLogin(appId, organizationId, apiUrl) {
|
|
|
31710
31837
|
function applicationClient(session, appId) {
|
|
31711
31838
|
return reconnectingApiClient(session, () => browserLogin(appId, session.organizationId, session.apiUrl));
|
|
31712
31839
|
}
|
|
31840
|
+
var globalHelpCommands = /* @__PURE__ */ new Set(["new", "lock", "check", "dev", "init", "sync", "doctor", "upgrade", "signup", "login", "logout", "connect", "disconnect", "status", "apps", "pull", "report", "ship", "deploy", "request", "prompt", "tools"]);
|
|
31713
31841
|
async function main() {
|
|
31842
|
+
if (command && globalHelpCommands.has(command) && (args.includes("--help") || args.includes("-h"))) {
|
|
31843
|
+
console.log(help);
|
|
31844
|
+
return;
|
|
31845
|
+
}
|
|
31714
31846
|
switch (command) {
|
|
31847
|
+
case "version":
|
|
31848
|
+
case "--version":
|
|
31849
|
+
case "-v": {
|
|
31850
|
+
const { bundledCliVersion: bundledCliVersion2 } = await Promise.resolve().then(() => (init_new(), new_exports));
|
|
31851
|
+
console.log(bundledCliVersion2() ?? "unknown");
|
|
31852
|
+
break;
|
|
31853
|
+
}
|
|
31715
31854
|
case "mcp": {
|
|
31716
31855
|
const { runCodingMcpServer: runCodingMcpServer2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
|
|
31717
31856
|
for (let index = 0; index < args.length; index++) {
|
|
@@ -31913,14 +32052,27 @@ async function main() {
|
|
|
31913
32052
|
break;
|
|
31914
32053
|
}
|
|
31915
32054
|
case "new": {
|
|
31916
|
-
const { createApp: createApp2, TEMPLATES: TEMPLATES2 } = await Promise.resolve().then(() => (init_new(), new_exports));
|
|
32055
|
+
const { bundledCliVersion: bundledCliVersion2, createApp: createApp2, TEMPLATES: TEMPLATES2 } = await Promise.resolve().then(() => (init_new(), new_exports));
|
|
32056
|
+
const { resolve: resolvePath } = await import("node:path");
|
|
31917
32057
|
const name2 = args.find((value) => !value.startsWith("-") && value !== option("--template") && value !== option("--dir"));
|
|
31918
32058
|
if (!name2) throw new Error("Use backify new <name> [--template " + TEMPLATES2.join("|") + "] [--dir <directory>]");
|
|
31919
32059
|
const template = option("--template") ?? "web";
|
|
31920
32060
|
const directory = option("--dir") ?? name2;
|
|
31921
|
-
const files = createApp2({ name: name2, template, directory, sdkVersion: process.env.BACKIFY_TEMPLATE_SDK_VERSION ?? "0.2.
|
|
32061
|
+
const files = createApp2({ name: name2, template, directory, sdkVersion: process.env.BACKIFY_TEMPLATE_SDK_VERSION ?? "0.2.1", cliVersion: process.env.BACKIFY_TEMPLATE_CLI_VERSION ?? bundledCliVersion2() ?? "0.4.2" });
|
|
32062
|
+
const here = resolvePath(directory) === process.cwd();
|
|
31922
32063
|
console.log(`Created ${name2} (${template}) in ${directory} with ${files.length} files.
|
|
31923
|
-
Next: cd ${directory} && npm install && npm run dev`);
|
|
32064
|
+
Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
32065
|
+
break;
|
|
32066
|
+
}
|
|
32067
|
+
case "workflow": {
|
|
32068
|
+
const usage = "Use backify workflow refresh [--app <application-id>]. It regenerates the Backify build workflow and commits it to the connected repository when the repository's copy is out of date.";
|
|
32069
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
32070
|
+
console.log(usage);
|
|
32071
|
+
break;
|
|
32072
|
+
}
|
|
32073
|
+
if (args[0] !== "refresh") throw new Error(usage);
|
|
32074
|
+
const result = await call("/apps/" + applicationGuid(option("--app") ?? projectApplication()) + "/source/github-workflow/refresh", { method: "POST" });
|
|
32075
|
+
console.log(JSON.stringify({ ...result, next: result.changed ? `Backify committed the current workflow to ${result.repository} (${result.branch}); that commit starts a build. Run backify pull before the next push.` : "The repository already has the current workflow." }, null, 2));
|
|
31924
32076
|
break;
|
|
31925
32077
|
}
|
|
31926
32078
|
case "lock": {
|
|
@@ -31931,9 +32083,11 @@ Next: cd ${directory} && npm install && npm run dev`);
|
|
|
31931
32083
|
case "check": {
|
|
31932
32084
|
const { checkCommand: checkCommand2 } = await Promise.resolve().then(() => (init_check(), check_exports));
|
|
31933
32085
|
const appId = readProjectMetadata(process.cwd()).appId;
|
|
32086
|
+
const signedIn = !!appId && (!!userConfig.sessions?.[sessionKey(appId)] || !!userConfig.token);
|
|
32087
|
+
if (appId && !signedIn) console.error("Skipping the organization policy check: this machine has no Backify CLI session for the app. Backify checks policy when the release is uploaded.");
|
|
31934
32088
|
process.exitCode = await checkCommand2(process.cwd(), {
|
|
31935
32089
|
skipScripts: args.includes("--lockfile-only"),
|
|
31936
|
-
policyCheck: appId ? (lockfile) => call(`/apps/${applicationGuid(appId)}/lockfile/check`, { method: "POST", body: JSON.stringify(lockfile) }) : void 0
|
|
32090
|
+
policyCheck: appId && signedIn ? (lockfile) => call(`/apps/${applicationGuid(appId)}/lockfile/check`, { method: "POST", body: JSON.stringify(lockfile) }) : void 0
|
|
31937
32091
|
});
|
|
31938
32092
|
break;
|
|
31939
32093
|
}
|
|
@@ -31978,7 +32132,7 @@ Next: cd ${directory} && npm install && npm run dev`);
|
|
|
31978
32132
|
console.log("Logged in to Backify");
|
|
31979
32133
|
break;
|
|
31980
32134
|
case "logout":
|
|
31981
|
-
|
|
32135
|
+
rmSync5(configPath, { force: true });
|
|
31982
32136
|
console.log("Local CLI credentials removed. Use disconnect before logout to revoke an application session.");
|
|
31983
32137
|
break;
|
|
31984
32138
|
case "connect": {
|
|
@@ -32101,6 +32255,17 @@ Next: cd ${directory} && npm install && npm run dev`);
|
|
|
32101
32255
|
console.log(JSON.stringify(await call(request.path, { method: request.method, body: request.body ? JSON.stringify(request.body) : void 0 }), null, 2));
|
|
32102
32256
|
break;
|
|
32103
32257
|
}
|
|
32258
|
+
case "outbound": {
|
|
32259
|
+
if (!args.length || args.includes("--help")) {
|
|
32260
|
+
console.log(outboundHttpUsage);
|
|
32261
|
+
if (!args.length) process.exitCode = 2;
|
|
32262
|
+
break;
|
|
32263
|
+
}
|
|
32264
|
+
const request = outboundHttpCall(applicationGuid(option("--app") ?? projectApplication()), args);
|
|
32265
|
+
const result = await call(request.path, { method: request.method, body: request.body ? JSON.stringify(request.body) : void 0 });
|
|
32266
|
+
console.log(request.method === "DELETE" ? "Removed the rule." : JSON.stringify(result, null, 2));
|
|
32267
|
+
break;
|
|
32268
|
+
}
|
|
32104
32269
|
case "events": {
|
|
32105
32270
|
const appId = applicationGuid(option("--app") ?? projectApplication());
|
|
32106
32271
|
const prefix = "/apps/" + appId + "/events";
|
|
@@ -32142,7 +32307,11 @@ Next: cd ${directory} && npm install && npm run dev`);
|
|
|
32142
32307
|
}
|
|
32143
32308
|
}
|
|
32144
32309
|
main().catch((error2) => {
|
|
32145
|
-
|
|
32310
|
+
let message = error2 instanceof Error ? error2.message : String(error2);
|
|
32311
|
+
if (error2 instanceof TypeError && message === "fetch failed") {
|
|
32312
|
+
const address = process.env.BACKIFY_API_URL ?? userConfig.apiUrl ?? "https://api.backify.dev/api";
|
|
32313
|
+
message = `Cannot reach the Backify API at ${address}. Check connectivity` + (process.env.BACKIFY_API_URL ? ", or the BACKIFY_API_URL override." : userConfig.apiUrl ? `, or the apiUrl saved in ${configPath} (backify login --api https://api.backify.dev/api resets it).` : ".");
|
|
32314
|
+
}
|
|
32146
32315
|
if (command !== "mcp" && args.includes("--json")) console.log(JSON.stringify({ schemaVersion: 1, status: "failed", exitCode: 1, error: message, ...error2 instanceof CliAuthenticationRequired ? { code: error2.code, reauthenticationCommand: "backify connect --reauth" + (option("--app") ? " --app " + applicationGuid(option("--app")) : "") } : {} }));
|
|
32147
32316
|
else console.error(message);
|
|
32148
32317
|
process.exitCode = 1;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build": "npm run build:server && vite build",
|
|
9
9
|
"build:server": "tsc -p tsconfig.json",
|
|
10
10
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p web/tsconfig.json --noEmit",
|
|
11
|
-
"test": "vitest run"
|
|
11
|
+
"test": "vitest run --root ."
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@backifydev/sdk": "^{{sdkVersion}}"
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"react-dom": "^19.1.1",
|
|
24
24
|
"typescript": "^5.9.2",
|
|
25
25
|
"vite": "^7.1.5",
|
|
26
|
-
"vitest": "^
|
|
26
|
+
"vitest": "^3.2.4"
|
|
27
27
|
}
|
|
28
28
|
}
|