@backifydev/cli 0.4.8 → 0.4.9
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/dist/index.js +169 -132
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1302,6 +1302,12 @@ function validateWorkload(value, fail) {
|
|
|
1302
1302
|
fail("workload." + key + " must be absent; workload accepts shape, ssr, streaming, batch, accelerator, profile and images");
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
|
+
function lockfileNeedsWorker(lockfile) {
|
|
1306
|
+
return lockfile.jobs.length > 0 || lockfile.schedules.length > 0 || lockfile.events.subscriptions.length > 0;
|
|
1307
|
+
}
|
|
1308
|
+
function lockfileNeedsDatabase(lockfile) {
|
|
1309
|
+
return lockfile.capabilities.includes("database") || lockfile.database != null || lockfileNeedsWorker(lockfile);
|
|
1310
|
+
}
|
|
1305
1311
|
var LOCKFILE_VERSION, LOCKFILE_NAME, LOCKFILE_MAX_BYTES, HTTP_METHODS, WORKLOAD_SHAPES, TARGET_PROFILES, object4, name, nonEmpty, sha256, ROUTE_PATH, CRON;
|
|
1306
1312
|
var init_lockfile = __esm({
|
|
1307
1313
|
"../platform/dist/lockfile.js"() {
|
|
@@ -1733,7 +1739,7 @@ Read the authenticated developer status branding snapshot before building a new
|
|
|
1733
1739
|
|
|
1734
1740
|
## Implementation workflow
|
|
1735
1741
|
|
|
1736
|
-
A new app starts with \`backify new <name> --template web|api|worker\`. Keep \`backify.config.ts\` as the typed intent and connection metadata (\`app.id\`, \`instructionVersion\`); routes, jobs, schedules and event subscriptions live in code. Run \`backify lock\` to generate and commit \`backify.lock.json\`. Run \`backify check\` before delivery; it verifies scripts and lockfile freshness. One image runs as web, worker and migrate roles. See https://docs.backify.dev/architecture/app-runtime-contract.
|
|
1742
|
+
A new app starts with \`backify new <name> --template web|api|worker\`. Keep \`backify.config.ts\` as the typed intent and connection metadata (\`app.id\`, \`instructionVersion\`); routes, jobs, schedules and event subscriptions live in code. Run \`backify lock\` to generate and commit \`backify.lock.json\`. Run \`backify check\` before delivery; it verifies scripts and lockfile freshness. One image runs as web, worker and migrate roles. The templates declare a database and include example data routes and migrations. When the app stores no data and has no jobs, schedules or events, remove \`database\` from \`backify.config.ts\`, the db/ folder and the example data code, so neither the cloud nor \`backify dev\` provisions PostgreSQL. See https://docs.backify.dev/architecture/app-runtime-contract.
|
|
1737
1743
|
|
|
1738
1744
|
Inspect the framework, lockfile, scripts, configuration, and applicable repository instructions before editing. Preserve the existing framework and unrelated work. Implement the requested application rather than stopping at SDK setup; ask what to build if requirements are missing.
|
|
1739
1745
|
From the first setup, make every new application runnable and testable locally without a cloud deployment. Provide a package-manager script that runs it locally (\`backify new\` apps use \`npm run dev\`; apps on the Backify SDK need no start script, because the SDK runner starts them in deployments), document prerequisites and local test identities, start the application, and verify its local URL and a representative user flow. Use \`npm run dev\` (\`backify dev\`) with PostgreSQL 16+ for local platform capabilities, keep local state and credentials out of Git, and clearly disclose emulation limits. Include the actual Local URL, start command, checks, and any blockers in the user handoff; never claim an unstarted application is ready. Follow the matching setup guide for framework-specific local commands.
|
|
@@ -1954,6 +1960,30 @@ var init_project_metadata = __esm({
|
|
|
1954
1960
|
}
|
|
1955
1961
|
});
|
|
1956
1962
|
|
|
1963
|
+
// src/app/workspace.ts
|
|
1964
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
1965
|
+
import { join as join3 } from "node:path";
|
|
1966
|
+
function isSetupManifest(path) {
|
|
1967
|
+
try {
|
|
1968
|
+
const manifest = JSON.parse(readFileSync3(path, "utf8"));
|
|
1969
|
+
const packages = Object.keys({ ...manifest.dependencies, ...manifest.devDependencies });
|
|
1970
|
+
const scripts = Object.keys(manifest.scripts ?? {});
|
|
1971
|
+
return scripts.length === 0 && packages.every((name2) => name2.startsWith("@backifydev/")) && !manifest.workspaces && !manifest.main && !manifest.bin;
|
|
1972
|
+
} catch {
|
|
1973
|
+
return false;
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
function workspaceHasApp(root) {
|
|
1977
|
+
if (existsSync3(join3(root, APP_CONFIG_FILE)) || existsSync3(join3(root, "Dockerfile"))) return true;
|
|
1978
|
+
return existsSync3(join3(root, "package.json")) && !isSetupManifest(join3(root, "package.json"));
|
|
1979
|
+
}
|
|
1980
|
+
var init_workspace = __esm({
|
|
1981
|
+
"src/app/workspace.ts"() {
|
|
1982
|
+
"use strict";
|
|
1983
|
+
init_project_metadata();
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1986
|
+
|
|
1957
1987
|
// ../../node_modules/postgres-array/index.js
|
|
1958
1988
|
var require_postgres_array = __commonJS({
|
|
1959
1989
|
"../../node_modules/postgres-array/index.js"(exports) {
|
|
@@ -7288,27 +7318,27 @@ var init_esm = __esm({
|
|
|
7288
7318
|
// src/app/local-postgres.ts
|
|
7289
7319
|
import { spawn, spawnSync as spawnSync2 } from "node:child_process";
|
|
7290
7320
|
import { randomBytes } from "node:crypto";
|
|
7291
|
-
import { existsSync as
|
|
7321
|
+
import { existsSync as existsSync4, mkdirSync, readdirSync, readFileSync as readFileSync4, rmSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
7292
7322
|
import { createServer } from "node:net";
|
|
7293
|
-
import { join as
|
|
7323
|
+
import { join as join4 } from "node:path";
|
|
7294
7324
|
function findPostgresBin() {
|
|
7295
7325
|
const explicit = process.env.BACKIFY_POSTGRES_BIN;
|
|
7296
|
-
if (explicit &&
|
|
7326
|
+
if (explicit && existsSync4(join4(explicit, exe("pg_ctl")))) return explicit;
|
|
7297
7327
|
const fromPath = spawnSync2(process.platform === "win32" ? "where" : "which", ["pg_ctl"], { encoding: "utf8" }).stdout?.split(/\r?\n/)[0]?.trim();
|
|
7298
|
-
if (fromPath &&
|
|
7328
|
+
if (fromPath && existsSync4(fromPath)) return join4(fromPath, "..");
|
|
7299
7329
|
const roots = process.platform === "win32" ? ["C:\\Program Files\\PostgreSQL"] : ["/usr/lib/postgresql", "/opt/homebrew/opt", "/usr/local/opt"];
|
|
7300
7330
|
for (const root of roots) {
|
|
7301
|
-
if (!
|
|
7331
|
+
if (!existsSync4(root)) continue;
|
|
7302
7332
|
const versions = readdirSync(root).filter((v) => /^(?:postgresql@)?\d+$/.test(v)).sort((a, b) => Number(b.replace(/\D/g, "")) - Number(a.replace(/\D/g, "")));
|
|
7303
7333
|
for (const version2 of versions) {
|
|
7304
|
-
const bin =
|
|
7305
|
-
if (
|
|
7334
|
+
const bin = join4(root, version2, "bin");
|
|
7335
|
+
if (existsSync4(join4(bin, exe("pg_ctl")))) return bin;
|
|
7306
7336
|
}
|
|
7307
7337
|
}
|
|
7308
7338
|
throw new Error("PostgreSQL 16+ was not found. Install it (https://www.postgresql.org/download/) or set BACKIFY_POSTGRES_BIN to its bin directory.");
|
|
7309
7339
|
}
|
|
7310
7340
|
function postgresInstallation(bin = findPostgresBin()) {
|
|
7311
|
-
const output = spawnSync2(
|
|
7341
|
+
const output = spawnSync2(join4(bin, exe("pg_ctl")), ["--version"], { encoding: "utf8", windowsHide: true, timeout: 1e4 }).stdout ?? "";
|
|
7312
7342
|
const version2 = /PostgreSQL\)?\s+(\d+(?:\.\d+)*)/.exec(output)?.[1] ?? "unknown";
|
|
7313
7343
|
return { bin, version: version2, major: Number.parseInt(version2, 10) || 0 };
|
|
7314
7344
|
}
|
|
@@ -7323,7 +7353,7 @@ function freePort(preferred = 0) {
|
|
|
7323
7353
|
});
|
|
7324
7354
|
}
|
|
7325
7355
|
function run(bin, tool, args2) {
|
|
7326
|
-
const result = spawnSync2(
|
|
7356
|
+
const result = spawnSync2(join4(bin, exe(tool)), args2, { encoding: "utf8", windowsHide: true });
|
|
7327
7357
|
if (result.status !== 0) throw new Error(`${tool} failed: ${(result.stderr || result.stdout || "").trim()}`);
|
|
7328
7358
|
}
|
|
7329
7359
|
async function startLocalDatabase(root, extensions = []) {
|
|
@@ -7331,15 +7361,15 @@ async function startLocalDatabase(root, extensions = []) {
|
|
|
7331
7361
|
if (!validDatabaseExtensions(requested)) throw new Error(databaseExtensionsError);
|
|
7332
7362
|
const installation = postgresInstallation(), bin = installation.bin;
|
|
7333
7363
|
if (installation.major && installation.major < 16) throw new Error(`backify dev needs PostgreSQL 16+, but found ${installation.version} at ${bin}. Install a newer version or set BACKIFY_POSTGRES_BIN to its bin directory.`);
|
|
7334
|
-
const home =
|
|
7335
|
-
const data =
|
|
7336
|
-
const statePath =
|
|
7364
|
+
const home = join4(root, ".backify", "dev", "postgres");
|
|
7365
|
+
const data = join4(home, "data");
|
|
7366
|
+
const statePath = join4(home, "state.json");
|
|
7337
7367
|
mkdirSync(home, { recursive: true });
|
|
7338
|
-
let state =
|
|
7339
|
-
if (!state || !
|
|
7368
|
+
let state = existsSync4(statePath) ? JSON.parse(readFileSync4(statePath, "utf8")) : void 0;
|
|
7369
|
+
if (!state || !existsSync4(join4(data, "PG_VERSION"))) {
|
|
7340
7370
|
rmSync(data, { recursive: true, force: true });
|
|
7341
7371
|
state = { password: randomBytes(24).toString("base64url"), port: await freePort(55432) };
|
|
7342
|
-
const pwfile =
|
|
7372
|
+
const pwfile = join4(home, "pw.tmp");
|
|
7343
7373
|
writeFileSync3(pwfile, state.password, { mode: 384 });
|
|
7344
7374
|
try {
|
|
7345
7375
|
run(bin, "initdb", ["-D", data, "-U", "backify_admin", "--auth-host=scram-sha-256", "--auth-local=scram-sha-256", "--pwfile=" + pwfile, "--no-locale", "--encoding=UTF8"]);
|
|
@@ -7348,21 +7378,21 @@ async function startLocalDatabase(root, extensions = []) {
|
|
|
7348
7378
|
}
|
|
7349
7379
|
writeFileSync3(statePath, JSON.stringify(state), { mode: 384 });
|
|
7350
7380
|
}
|
|
7351
|
-
const running = spawnSync2(
|
|
7381
|
+
const running = spawnSync2(join4(bin, exe("pg_ctl")), ["-D", data, "status"], { stdio: "ignore", windowsHide: true }).status === 0;
|
|
7352
7382
|
const port = state.port = running ? state.port : await freePort(state.port);
|
|
7353
7383
|
writeFileSync3(statePath, JSON.stringify(state), { mode: 384 });
|
|
7354
7384
|
if (!running) {
|
|
7355
7385
|
await new Promise((resolve10, reject) => {
|
|
7356
|
-
const child = spawn(
|
|
7386
|
+
const child = spawn(join4(bin, exe("pg_ctl")), ["-D", data, "-l", join4(home, "postgres.log"), "-o", `-h 127.0.0.1 -p ${port}`, "-w", "start"], { stdio: "ignore", windowsHide: true, detached: process.platform !== "win32" });
|
|
7357
7387
|
child.on("error", reject);
|
|
7358
|
-
child.on("exit", (code) => code === 0 ? resolve10() : reject(new Error(`PostgreSQL did not start; see ${
|
|
7388
|
+
child.on("exit", (code) => code === 0 ? resolve10() : reject(new Error(`PostgreSQL did not start; see ${join4(home, "postgres.log")}`)));
|
|
7359
7389
|
});
|
|
7360
7390
|
}
|
|
7361
7391
|
const url2 = (user, password, database) => `postgres://${user}:${encodeURIComponent(password)}@127.0.0.1:${port}/${database}`;
|
|
7362
7392
|
const admin = url2("backify_admin", state.password, "postgres");
|
|
7363
7393
|
const adminApp = url2("backify_admin", state.password, "app");
|
|
7364
7394
|
const stop = async () => {
|
|
7365
|
-
spawnSync2(
|
|
7395
|
+
spawnSync2(join4(bin, exe("pg_ctl")), ["-D", data, "-m", "fast", "-w", "stop"], { stdio: "ignore", windowsHide: true });
|
|
7366
7396
|
};
|
|
7367
7397
|
try {
|
|
7368
7398
|
const client = new esm_default.Client({ connectionString: admin });
|
|
@@ -8013,7 +8043,7 @@ var init_package = __esm({
|
|
|
8013
8043
|
"package.json"() {
|
|
8014
8044
|
package_default = {
|
|
8015
8045
|
name: "@backifydev/cli",
|
|
8016
|
-
version: "0.4.
|
|
8046
|
+
version: "0.4.9",
|
|
8017
8047
|
description: "Command-line setup and diagnostics for Backify applications",
|
|
8018
8048
|
type: "module",
|
|
8019
8049
|
bin: {
|
|
@@ -8085,9 +8115,9 @@ var init_cli_session = __esm({
|
|
|
8085
8115
|
});
|
|
8086
8116
|
|
|
8087
8117
|
// src/compatibility.ts
|
|
8088
|
-
import { readFileSync as
|
|
8118
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
8089
8119
|
import { homedir } from "node:os";
|
|
8090
|
-
import { join as
|
|
8120
|
+
import { join as join6 } from "node:path";
|
|
8091
8121
|
async function checkCompatibility(apiUrl, transport = fetch) {
|
|
8092
8122
|
try {
|
|
8093
8123
|
const response = await transport(apiUrl.replace(/\/$/, "") + "/compatibility", { redirect: "error", signal: AbortSignal.timeout(5e3), headers: cliHeaders });
|
|
@@ -8123,11 +8153,11 @@ var init_compatibility = __esm({
|
|
|
8123
8153
|
"use strict";
|
|
8124
8154
|
init_cli_session();
|
|
8125
8155
|
day = 24 * 60 * 60 * 1e3;
|
|
8126
|
-
noticeFile = () =>
|
|
8156
|
+
noticeFile = () => join6(homedir(), ".backify-client-notice.json");
|
|
8127
8157
|
fileNoticeStore = {
|
|
8128
8158
|
read: () => {
|
|
8129
8159
|
try {
|
|
8130
|
-
const value = JSON.parse(
|
|
8160
|
+
const value = JSON.parse(readFileSync6(noticeFile(), "utf8")).shownAt;
|
|
8131
8161
|
return typeof value === "number" ? value : void 0;
|
|
8132
8162
|
} catch {
|
|
8133
8163
|
return void 0;
|
|
@@ -8144,25 +8174,25 @@ var init_compatibility = __esm({
|
|
|
8144
8174
|
});
|
|
8145
8175
|
|
|
8146
8176
|
// src/delivery.ts
|
|
8147
|
-
import { existsSync as
|
|
8148
|
-
import { dirname, join as
|
|
8177
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
|
|
8178
|
+
import { dirname, join as join7, relative as relativePath } from "node:path";
|
|
8149
8179
|
import { createHash } from "node:crypto";
|
|
8150
8180
|
function validateDeliveryInstructions(root) {
|
|
8151
8181
|
for (const filename of ["BACKIFY.md", "BACKIFY-WORKFLOW.md"]) {
|
|
8152
|
-
const path =
|
|
8153
|
-
if (
|
|
8154
|
-
const existing =
|
|
8182
|
+
const path = join7(root, filename);
|
|
8183
|
+
if (existsSync6(path)) {
|
|
8184
|
+
const existing = readFileSync7(path, "utf8").replace(/\r\n/g, "\n");
|
|
8155
8185
|
if (existing !== deliveryInstructions && !previousGeneratedWorkflowHashes.has(createHash("sha256").update(existing).digest("hex"))) throw new Error(filename + " contains different instructions. Review it before initializing; it will not be overwritten.");
|
|
8156
8186
|
}
|
|
8157
8187
|
}
|
|
8158
8188
|
}
|
|
8159
8189
|
function installDeliveryInstructions(root, instructionFiles2) {
|
|
8160
8190
|
validateDeliveryInstructions(root);
|
|
8161
|
-
writeFileSync6(
|
|
8191
|
+
writeFileSync6(join7(root, "BACKIFY.md"), deliveryInstructions);
|
|
8162
8192
|
for (const relative5 of instructionFiles2) {
|
|
8163
|
-
const instructionPath =
|
|
8164
|
-
const link = relativePath(dirname(instructionPath),
|
|
8165
|
-
const legacyLink = relativePath(dirname(instructionPath),
|
|
8193
|
+
const instructionPath = join7(root, relative5), content = readFileSync7(instructionPath, "utf8");
|
|
8194
|
+
const link = relativePath(dirname(instructionPath), join7(root, "BACKIFY.md")).replaceAll("\\", "/");
|
|
8195
|
+
const legacyLink = relativePath(dirname(instructionPath), join7(root, "BACKIFY-WORKFLOW.md")).replaceAll("\\", "/");
|
|
8166
8196
|
const legacy = "For application delivery and recording each user request, follow [BACKIFY-WORKFLOW.md](" + legacyLink + ").";
|
|
8167
8197
|
const guidance = "For application delivery and recording each user request, follow [BACKIFY.md](" + link + ").";
|
|
8168
8198
|
if (content.includes(legacy)) writeFileSync6(instructionPath, content.replace(legacy, guidance));
|
|
@@ -8180,18 +8210,18 @@ var init_delivery2 = __esm({
|
|
|
8180
8210
|
});
|
|
8181
8211
|
|
|
8182
8212
|
// src/application-support.ts
|
|
8183
|
-
import { existsSync as
|
|
8184
|
-
import { join as
|
|
8213
|
+
import { existsSync as existsSync7, readFileSync as readFileSync8 } from "node:fs";
|
|
8214
|
+
import { join as join8 } from "node:path";
|
|
8185
8215
|
function applicationSupport(root) {
|
|
8186
|
-
const manifestPath =
|
|
8187
|
-
const manifest =
|
|
8216
|
+
const manifestPath = join8(root, "package.json");
|
|
8217
|
+
const manifest = existsSync7(manifestPath) ? JSON.parse(readFileSync8(manifestPath, "utf8")) : {};
|
|
8188
8218
|
const dependencies = { ...manifest.devDependencies, ...manifest.dependencies };
|
|
8189
8219
|
const framework = ["next", "astro", "@sveltejs/kit", "nuxt", "express", "vite", "react"].find((name2) => dependencies[name2]) ?? "unknown";
|
|
8190
|
-
if (!
|
|
8220
|
+
if (!existsSync7(join8(root, "Dockerfile")) && existsSync7(join8(root, "backify.config.ts")) && dependencies["@backifydev/sdk"]) {
|
|
8191
8221
|
return { tier: "recommended", framework, guidance: "This app uses the Backify runtime: Backify's managed build produces one image that runs the web, worker and migrate roles, and Backify keeps its Node.js base image patched. This assessment does not verify deployment or authorization." };
|
|
8192
8222
|
}
|
|
8193
|
-
if (
|
|
8194
|
-
if (
|
|
8223
|
+
if (existsSync7(join8(root, "Dockerfile"))) {
|
|
8224
|
+
if (existsSync7(join8(root, "backify.config.ts")) && dependencies["@backifydev/sdk"] && /@backifydev\/sdk\/dist\/app\/run\.js|\bbackify-run\b/.test(readFileSync8(join8(root, "Dockerfile"), "utf8")))
|
|
8195
8225
|
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." };
|
|
8196
8226
|
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." };
|
|
8197
8227
|
}
|
|
@@ -8199,7 +8229,7 @@ function applicationSupport(root) {
|
|
|
8199
8229
|
return { tier: "recommended", framework, guidance: "React with Vite is the recommended frontend baseline. Prefer TypeScript for new code and use an explicit Backify TypeScript backend for server capabilities. This assessment does not verify deployment or authorization." };
|
|
8200
8230
|
}
|
|
8201
8231
|
return {
|
|
8202
|
-
tier:
|
|
8232
|
+
tier: existsSync7(manifestPath) ? "compatible" : "unassessed",
|
|
8203
8233
|
framework,
|
|
8204
8234
|
guidance: "Backify is TypeScript-first. For new apps, prefer React with Vite and an explicit Backify TypeScript backend. Preserve existing JavaScript/TypeScript frameworks; assess SSR, build, identity and capability integration before claiming support. Browser-only apps do not require Node.js in production."
|
|
8205
8235
|
};
|
|
@@ -8210,32 +8240,8 @@ var init_application_support = __esm({
|
|
|
8210
8240
|
}
|
|
8211
8241
|
});
|
|
8212
8242
|
|
|
8213
|
-
// src/app/workspace.ts
|
|
8214
|
-
import { existsSync as existsSync6, readFileSync as readFileSync8 } from "node:fs";
|
|
8215
|
-
import { join as join8 } from "node:path";
|
|
8216
|
-
function isSetupManifest(path) {
|
|
8217
|
-
try {
|
|
8218
|
-
const manifest = JSON.parse(readFileSync8(path, "utf8"));
|
|
8219
|
-
const packages = Object.keys({ ...manifest.dependencies, ...manifest.devDependencies });
|
|
8220
|
-
const scripts = Object.keys(manifest.scripts ?? {});
|
|
8221
|
-
return scripts.length === 0 && packages.every((name2) => name2.startsWith("@backifydev/")) && !manifest.workspaces && !manifest.main && !manifest.bin;
|
|
8222
|
-
} catch {
|
|
8223
|
-
return false;
|
|
8224
|
-
}
|
|
8225
|
-
}
|
|
8226
|
-
function workspaceHasApp(root) {
|
|
8227
|
-
if (existsSync6(join8(root, APP_CONFIG_FILE)) || existsSync6(join8(root, "Dockerfile"))) return true;
|
|
8228
|
-
return existsSync6(join8(root, "package.json")) && !isSetupManifest(join8(root, "package.json"));
|
|
8229
|
-
}
|
|
8230
|
-
var init_workspace = __esm({
|
|
8231
|
-
"src/app/workspace.ts"() {
|
|
8232
|
-
"use strict";
|
|
8233
|
-
init_project_metadata();
|
|
8234
|
-
}
|
|
8235
|
-
});
|
|
8236
|
-
|
|
8237
8243
|
// src/setup.ts
|
|
8238
|
-
import { existsSync as
|
|
8244
|
+
import { existsSync as existsSync8, readFileSync as readFileSync9, writeFileSync as writeFileSync7, mkdirSync as mkdirSync2, readdirSync as readdirSync2, lstatSync as lstatSync2 } from "node:fs";
|
|
8239
8245
|
import { basename, dirname as dirname2, join as join9, resolve as resolve2, isAbsolute } from "node:path";
|
|
8240
8246
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
8241
8247
|
function instructionSelection(root, agent, instructionFile) {
|
|
@@ -8266,13 +8272,13 @@ function isToolWorkspaceEntry(entry, root = process.cwd()) {
|
|
|
8266
8272
|
return entry.isDirectory() && (entry.name.startsWith(".") || ["work", "outputs"].includes(entry.name) || readdirSync2(join9(root, entry.name)).length === 0) || entry.isFile() && (entry.name.startsWith(".") || /\.(md|mdc)$/i.test(entry.name));
|
|
8267
8273
|
}
|
|
8268
8274
|
function detectPackageManager(root = process.cwd()) {
|
|
8269
|
-
for (const [file, name2] of [["pnpm-lock.yaml", "pnpm"], ["yarn.lock", "yarn"], ["bun.lockb", "bun"], ["bun.lock", "bun"], ["package-lock.json", "npm"]]) if (
|
|
8275
|
+
for (const [file, name2] of [["pnpm-lock.yaml", "pnpm"], ["yarn.lock", "yarn"], ["bun.lockb", "bun"], ["bun.lock", "bun"], ["package-lock.json", "npm"]]) if (existsSync8(join9(root, file))) return name2;
|
|
8270
8276
|
return "npm";
|
|
8271
8277
|
}
|
|
8272
8278
|
function updateInstructions(root = process.cwd(), agent, instructionFile) {
|
|
8273
8279
|
const updates = selectedInstructionFiles(root, agent, instructionFile).map((relative5) => {
|
|
8274
8280
|
const path = join9(root, relative5);
|
|
8275
|
-
return { path, content: updateManagedInstructions(
|
|
8281
|
+
return { path, content: updateManagedInstructions(existsSync8(path) ? readFileSync9(path, "utf8") : "") };
|
|
8276
8282
|
});
|
|
8277
8283
|
for (const { path, content } of updates) {
|
|
8278
8284
|
mkdirSync2(dirname2(path), { recursive: true });
|
|
@@ -8308,7 +8314,7 @@ function installSdk(root = process.cwd()) {
|
|
|
8308
8314
|
}
|
|
8309
8315
|
function ensurePackageManifest(root) {
|
|
8310
8316
|
const path = join9(root, "package.json");
|
|
8311
|
-
if (
|
|
8317
|
+
if (existsSync8(path)) return;
|
|
8312
8318
|
const setupFiles = /* @__PURE__ */ new Set([".git", ".gitignore", ".github", "AGENTS.md", "CLAUDE.md", "GEMINI.md", "BACKIFY.md", "BACKIFY-WORKFLOW.md", "README.md", "LICENSE", "backify.json"]);
|
|
8313
8319
|
if (readdirSync2(root, { withFileTypes: true }).some((entry) => !setupFiles.has(entry.name) && !isToolWorkspaceEntry(entry, root))) throw new Error("package.json is missing. Run backify init from the existing application's JavaScript/TypeScript package directory, or start in an empty folder. See https://agent.backify.dev/");
|
|
8314
8320
|
const name2 = basename(resolve2(root)).toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "backify-app";
|
|
@@ -8320,8 +8326,8 @@ function initialize(appId, root = process.cwd(), install = true, agent, instruct
|
|
|
8320
8326
|
if (existingApp && existingApp !== appId) throw new Error("The project is connected to a different application. Reconcile app.id before initializing.");
|
|
8321
8327
|
const selected = instructionSelection(root, agent, instructionFile), files = selected.files;
|
|
8322
8328
|
validateDeliveryInstructions(root);
|
|
8323
|
-
for (const relative5 of files) if (
|
|
8324
|
-
const customContainer = !
|
|
8329
|
+
for (const relative5 of files) if (existsSync8(join9(root, relative5))) updateManagedInstructions(readFileSync9(join9(root, relative5), "utf8"));
|
|
8330
|
+
const customContainer = !existsSync8(join9(root, "package.json")) && existsSync8(join9(root, "Dockerfile"));
|
|
8325
8331
|
if (!customContainer) {
|
|
8326
8332
|
ensurePackageManifest(root);
|
|
8327
8333
|
if (install) installSdk(root);
|
|
@@ -8332,7 +8338,7 @@ function initialize(appId, root = process.cwd(), install = true, agent, instruct
|
|
|
8332
8338
|
ensureGitignore(root);
|
|
8333
8339
|
}
|
|
8334
8340
|
function ensureGitignore(root = process.cwd()) {
|
|
8335
|
-
const path = join9(root, ".gitignore"), current =
|
|
8341
|
+
const path = join9(root, ".gitignore"), current = existsSync8(path) ? readFileSync9(path, "utf8") : "";
|
|
8336
8342
|
const present2 = new Set(current.split(/\r?\n/).map((line2) => line2.trim().replace(/^\/|\/$/g, "")));
|
|
8337
8343
|
const missing = SETUP_GITIGNORE_RULES.filter((rule) => !present2.has(rule));
|
|
8338
8344
|
if (!missing.length) return false;
|
|
@@ -8350,7 +8356,7 @@ function doctor(root = process.cwd(), agent, instructionFile) {
|
|
|
8350
8356
|
issues.push("package.json is invalid JSON");
|
|
8351
8357
|
}
|
|
8352
8358
|
if (!sdkInstalled(root)) {
|
|
8353
|
-
if (!
|
|
8359
|
+
if (!existsSync8(join9(root, "package.json")) && existsSync8(join9(root, "Dockerfile"))) warnings.push("Custom container: JavaScript SDK capabilities are not validated. Use only supported Backify integrations for this language.");
|
|
8354
8360
|
else issues.push(`${SDK_PACKAGE} is not installed`);
|
|
8355
8361
|
}
|
|
8356
8362
|
let config2;
|
|
@@ -8369,7 +8375,7 @@ function doctor(root = process.cwd(), agent, instructionFile) {
|
|
|
8369
8375
|
}
|
|
8370
8376
|
for (const relative5 of files) {
|
|
8371
8377
|
const path = join9(root, relative5);
|
|
8372
|
-
if (!
|
|
8378
|
+
if (!existsSync8(path)) {
|
|
8373
8379
|
issues.push(`${relative5} is missing`);
|
|
8374
8380
|
continue;
|
|
8375
8381
|
}
|
|
@@ -8407,15 +8413,15 @@ var init_setup = __esm({
|
|
|
8407
8413
|
});
|
|
8408
8414
|
|
|
8409
8415
|
// src/container-build.ts
|
|
8410
|
-
import { existsSync as
|
|
8416
|
+
import { existsSync as existsSync9, readFileSync as readFileSync10 } from "node:fs";
|
|
8411
8417
|
import { join as join10 } from "node:path";
|
|
8412
8418
|
function containerBuildSupport(root) {
|
|
8413
|
-
if (
|
|
8414
|
-
if (!
|
|
8419
|
+
if (existsSync9(join10(root, "Dockerfile"))) return { adapter: "custom-container", issue: null };
|
|
8420
|
+
if (!existsSync9(join10(root, "package.json"))) return { adapter: null, issue: "Provide a repository-root Dockerfile serving HTTP on port 8080 for this language. Local Docker is not required." };
|
|
8415
8421
|
const manifest = JSON.parse(readFileSync10(join10(root, "package.json"), "utf8"));
|
|
8416
|
-
if (!
|
|
8422
|
+
if (!existsSync9(join10(root, "package-lock.json"))) return { adapter: null, issue: "Managed Node builds require package-lock.json. Generate and commit the npm lockfile, or provide a custom Dockerfile." };
|
|
8417
8423
|
const sdk = typeof manifest.dependencies?.["@backifydev/sdk"] === "string";
|
|
8418
|
-
if (!sdk && (typeof manifest.scripts?.start !== "string" || !manifest.scripts.start) || manifest.workspaces || ["pnpm-lock.yaml", "yarn.lock"].some((name2) =>
|
|
8424
|
+
if (!sdk && (typeof manifest.scripts?.start !== "string" || !manifest.scripts.start) || manifest.workspaces || ["pnpm-lock.yaml", "yarn.lock"].some((name2) => existsSync9(join10(root, name2)))) {
|
|
8419
8425
|
return { adapter: null, issue: "Managed Node builds require an npm application at the repository root that depends on @backifydev/sdk or has a start script. Workspaces and other package managers require a custom Dockerfile." };
|
|
8420
8426
|
}
|
|
8421
8427
|
return { adapter: "node-npm", issue: null };
|
|
@@ -8427,7 +8433,7 @@ var init_container_build = __esm({
|
|
|
8427
8433
|
});
|
|
8428
8434
|
|
|
8429
8435
|
// src/development.ts
|
|
8430
|
-
import { existsSync as
|
|
8436
|
+
import { existsSync as existsSync10, readFileSync as readFileSync11, readdirSync as readdirSync3, writeFileSync as writeFileSync8, renameSync, rmSync as rmSync2, mkdtempSync, lstatSync as lstatSync3, cpSync } from "node:fs";
|
|
8431
8437
|
import { dirname as dirname3, join as join11, resolve as resolve3 } from "node:path";
|
|
8432
8438
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
8433
8439
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
@@ -8443,7 +8449,7 @@ function installedSdkVersion(root) {
|
|
|
8443
8449
|
let directory = resolve3(root);
|
|
8444
8450
|
while (true) {
|
|
8445
8451
|
const manifest = join11(directory, "node_modules", "@backifydev", "sdk", "package.json");
|
|
8446
|
-
if (
|
|
8452
|
+
if (existsSync10(manifest)) {
|
|
8447
8453
|
try {
|
|
8448
8454
|
const sdk = JSON.parse(readFileSync11(manifest, "utf8"));
|
|
8449
8455
|
return sdk.name === "@backifydev/sdk" && typeof sdk.version === "string" && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(sdk.version) ? sdk.version : null;
|
|
@@ -8635,9 +8641,9 @@ function attachmentNames(values) {
|
|
|
8635
8641
|
}))];
|
|
8636
8642
|
}
|
|
8637
8643
|
function localReport(runChecks, root = process.cwd()) {
|
|
8638
|
-
const pkg =
|
|
8644
|
+
const pkg = existsSync10(join11(root, "package.json")) ? JSON.parse(readFileSync11(join11(root, "package.json"), "utf8")) : {};
|
|
8639
8645
|
const dependencies = { ...pkg.devDependencies, ...pkg.dependencies };
|
|
8640
|
-
const framework = ["next", "vite", "astro", "@sveltejs/kit", "nuxt", "react", "express"].find((name2) => dependencies[name2]) ?? (
|
|
8646
|
+
const framework = ["next", "vite", "astro", "@sveltejs/kit", "nuxt", "react", "express"].find((name2) => dependencies[name2]) ?? (existsSync10(join11(root, "Dockerfile")) ? "custom-container" : "unknown");
|
|
8641
8647
|
const setup = doctor(root);
|
|
8642
8648
|
const checks = [{ name: "backify doctor", status: setup.valid ? "passed" : "failed" }];
|
|
8643
8649
|
const manager = detectPackageManager(root);
|
|
@@ -8653,8 +8659,8 @@ function localReport(runChecks, root = process.cwd()) {
|
|
|
8653
8659
|
dirty = Boolean(git(["status", "--porcelain"], root));
|
|
8654
8660
|
} catch {
|
|
8655
8661
|
}
|
|
8656
|
-
const outputDirectory = ["dist", "build", "out", "."].find((directory) =>
|
|
8657
|
-
return { framework, sdkVersion: dependencies["@backifydev/sdk"] ?? null, branch, commitSha, dirty, buildCommand: pkg.scripts?.build ? manager + " run build" : null, outputDirectory, hasDockerfile:
|
|
8662
|
+
const outputDirectory = ["dist", "build", "out", "."].find((directory) => existsSync10(join11(root, directory, "index.html"))) ?? null;
|
|
8663
|
+
return { framework, sdkVersion: dependencies["@backifydev/sdk"] ?? null, branch, commitSha, dirty, buildCommand: pkg.scripts?.build ? manager + " run build" : null, outputDirectory, hasDockerfile: existsSync10(join11(root, "Dockerfile")), checks, support: setup.support, warnings: setup.warnings };
|
|
8658
8664
|
}
|
|
8659
8665
|
function matchesSource(release2, commit) {
|
|
8660
8666
|
return release2?.commitSha === commit || release2?.sourceCommitSha === commit;
|
|
@@ -9680,13 +9686,13 @@ __export(new_exports, {
|
|
|
9680
9686
|
templatesDirectory: () => templatesDirectory,
|
|
9681
9687
|
workspaceHasApp: () => workspaceHasApp
|
|
9682
9688
|
});
|
|
9683
|
-
import { cpSync as cpSync2, existsSync as
|
|
9689
|
+
import { cpSync as cpSync2, existsSync as existsSync11, mkdirSync as mkdirSync3, mkdtempSync as mkdtempSync2, readdirSync as readdirSync4, readFileSync as readFileSync13, renameSync as renameSync2, rmSync as rmSync3, statSync, writeFileSync as writeFileSync10 } from "node:fs";
|
|
9684
9690
|
import { tmpdir } from "node:os";
|
|
9685
9691
|
import { dirname as dirname4, join as join12, resolve as resolve4 } from "node:path";
|
|
9686
9692
|
import { fileURLToPath } from "node:url";
|
|
9687
9693
|
function templatesDirectory() {
|
|
9688
9694
|
const here = dirname4(fileURLToPath(import.meta.url));
|
|
9689
|
-
for (const candidate of [join12(here, "..", "templates"), join12(here, "..", "..", "templates")]) if (
|
|
9695
|
+
for (const candidate of [join12(here, "..", "templates"), join12(here, "..", "..", "templates")]) if (existsSync11(join12(candidate, "common"))) return candidate;
|
|
9690
9696
|
throw new Error("Templates are missing from this installation of @backifydev/cli");
|
|
9691
9697
|
}
|
|
9692
9698
|
function bundledCliVersion() {
|
|
@@ -9722,7 +9728,7 @@ function walk(directory) {
|
|
|
9722
9728
|
}
|
|
9723
9729
|
function newAppDirectory(name2, root, dir) {
|
|
9724
9730
|
if (dir) return dir;
|
|
9725
|
-
return
|
|
9731
|
+
return existsSync11(join12(root, "backify.json")) && !workspaceHasApp(root) ? "." : name2;
|
|
9726
9732
|
}
|
|
9727
9733
|
function isSetupEntry(entry, root) {
|
|
9728
9734
|
const name2 = entry.name.toLowerCase();
|
|
@@ -9750,7 +9756,7 @@ function createApp(options) {
|
|
|
9750
9756
|
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");
|
|
9751
9757
|
if (!TEMPLATES.includes(options.template)) throw new Error("Choose a template: " + TEMPLATES.join(", "));
|
|
9752
9758
|
const target = resolve4(options.directory);
|
|
9753
|
-
const existing =
|
|
9759
|
+
const existing = existsSync11(target) ? readdirSync4(target, { withFileTypes: true }) : [];
|
|
9754
9760
|
const blocking = existing.filter((entry) => !isSetupEntry(entry, target)).map((entry) => entry.name);
|
|
9755
9761
|
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).`);
|
|
9756
9762
|
const connected = existing.length ? readProjectMetadata(target) : {};
|
|
@@ -9760,7 +9766,7 @@ function createApp(options) {
|
|
|
9760
9766
|
const templates = templatesDirectory();
|
|
9761
9767
|
cpSync2(join12(templates, "common"), staging, { recursive: true });
|
|
9762
9768
|
cpSync2(join12(templates, options.template), staging, { recursive: true, force: true });
|
|
9763
|
-
for (const hidden of ["_gitignore", "_dockerignore"]) if (
|
|
9769
|
+
for (const hidden of ["_gitignore", "_dockerignore"]) if (existsSync11(join12(staging, hidden))) renameSync2(join12(staging, hidden), join12(staging, "." + hidden.slice(1)));
|
|
9764
9770
|
for (const file of walk(staging)) {
|
|
9765
9771
|
const text2 = readFileSync13(file, "utf8");
|
|
9766
9772
|
const rendered = text2.replaceAll("{{name}}", options.name).replaceAll("{{sdkVersion}}", sdkVersion).replaceAll("{{cliVersion}}", options.cliVersion);
|
|
@@ -9772,7 +9778,7 @@ function createApp(options) {
|
|
|
9772
9778
|
for (const file of walk(staging)) {
|
|
9773
9779
|
const relative5 = file.slice(staging.length + 1);
|
|
9774
9780
|
const destination = join12(target, relative5);
|
|
9775
|
-
if (
|
|
9781
|
+
if (existsSync11(destination) && relative5 !== "package.json") {
|
|
9776
9782
|
if ((relative5 === ".gitignore" || relative5 === ".dockerignore") && mergeIgnoreFile(file, destination)) written.push(relative5);
|
|
9777
9783
|
continue;
|
|
9778
9784
|
}
|
|
@@ -9780,7 +9786,7 @@ function createApp(options) {
|
|
|
9780
9786
|
cpSync2(file, destination);
|
|
9781
9787
|
written.push(relative5);
|
|
9782
9788
|
}
|
|
9783
|
-
if (connected.appId &&
|
|
9789
|
+
if (connected.appId && existsSync11(join12(target, APP_CONFIG_FILE))) {
|
|
9784
9790
|
rmSync3(join12(target, "backify.json"), { force: true });
|
|
9785
9791
|
writeProjectMetadata(target, { appId: connected.appId, instructionVersion: connected.instructionVersion, agent: connected.agent, instructionFile: connected.instructionFile });
|
|
9786
9792
|
}
|
|
@@ -31170,7 +31176,7 @@ __export(coding_tools_exports, {
|
|
|
31170
31176
|
codingTools: () => codingTools,
|
|
31171
31177
|
configureCodingTool: () => configureCodingTool
|
|
31172
31178
|
});
|
|
31173
|
-
import { existsSync as
|
|
31179
|
+
import { existsSync as existsSync12, lstatSync as lstatSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync17, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync11 } from "node:fs";
|
|
31174
31180
|
import { basename as basename3, dirname as dirname5, extname as extname2, join as join14, resolve as resolve5 } from "node:path";
|
|
31175
31181
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
31176
31182
|
function object7(value) {
|
|
@@ -31227,11 +31233,11 @@ function writeAtomically(path, content, previous) {
|
|
|
31227
31233
|
mkdirSync4(dirname5(path), { recursive: true });
|
|
31228
31234
|
const temporary = path + "." + randomUUID5() + ".tmp";
|
|
31229
31235
|
try {
|
|
31230
|
-
writeFileSync11(temporary, content, { flag: "wx", mode:
|
|
31231
|
-
if ((
|
|
31236
|
+
writeFileSync11(temporary, content, { flag: "wx", mode: existsSync12(path) ? lstatSync4(path).mode & 511 : 384 });
|
|
31237
|
+
if ((existsSync12(path) ? readFileSync17(path, "utf8") : void 0) !== previous) throw new Error("MCP configuration changed during setup. Retry after reviewing it.");
|
|
31232
31238
|
renameSync3(temporary, path);
|
|
31233
31239
|
} finally {
|
|
31234
|
-
if (
|
|
31240
|
+
if (existsSync12(temporary)) unlinkSync2(temporary);
|
|
31235
31241
|
}
|
|
31236
31242
|
}
|
|
31237
31243
|
function configureCodingTool(options) {
|
|
@@ -31245,13 +31251,13 @@ function configureCodingTool(options) {
|
|
|
31245
31251
|
if (toml && extname2(path) !== ".toml") throw new Error("Codex reads MCP servers from config.toml; supply a .toml path with --config.");
|
|
31246
31252
|
if (!toml && extname2(path) === ".toml") throw new Error("This tool's MCP configuration is JSON; supply a .json path with --config.");
|
|
31247
31253
|
for (let current = path; ; current = dirname5(current)) {
|
|
31248
|
-
if (
|
|
31254
|
+
if (existsSync12(current) && (lstatSync4(current).isSymbolicLink() || current === path && !lstatSync4(current).isFile())) throw new Error("MCP configuration cannot traverse symlinks or replace a directory.");
|
|
31249
31255
|
if (dirname5(current) === current) break;
|
|
31250
31256
|
}
|
|
31251
31257
|
const entry = codingToolEntry(agent, transport);
|
|
31252
31258
|
const snippet = toml ? { toml: codexToml(entry) } : {};
|
|
31253
31259
|
if (options.dryRun) return { agent, transport, path, entry, ...snippet, changed: void 0 };
|
|
31254
|
-
const previous =
|
|
31260
|
+
const previous = existsSync12(path) ? readFileSync17(path, "utf8") : void 0;
|
|
31255
31261
|
if (toml) {
|
|
31256
31262
|
const state = previous === void 0 ? "absent" : codexState(previous, entry);
|
|
31257
31263
|
if (state === "inline") throw new Error("This config.toml defines mcp_servers as an inline table. It is unchanged; add the --dry-run entry to it manually.");
|
|
@@ -31429,14 +31435,14 @@ __export(project_exports, {
|
|
|
31429
31435
|
sdkRunner: () => sdkRunner
|
|
31430
31436
|
});
|
|
31431
31437
|
import { spawn as spawn2 } from "node:child_process";
|
|
31432
|
-
import { existsSync as
|
|
31438
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync5, readFileSync as readFileSync18 } from "node:fs";
|
|
31433
31439
|
import { createRequire } from "node:module";
|
|
31434
31440
|
import { dirname as dirname6, join as join15, relative as relative2, resolve as resolve6 } from "node:path";
|
|
31435
31441
|
import { pathToFileURL } from "node:url";
|
|
31436
31442
|
import { build } from "esbuild";
|
|
31437
31443
|
async function loadConfig(root) {
|
|
31438
31444
|
const file = join15(root, CONFIG_FILE);
|
|
31439
|
-
if (!
|
|
31445
|
+
if (!existsSync13(file)) throw new ProjectError(`${CONFIG_FILE} was not found in ${root}. Create one with \`backify init\`.`);
|
|
31440
31446
|
const out = join15(root, ".backify", "build", "config.mjs");
|
|
31441
31447
|
mkdirSync5(dirname6(out), { recursive: true });
|
|
31442
31448
|
await build({ entryPoints: [file], bundle: true, platform: "node", format: "esm", outfile: out, packages: "external", logLevel: "silent", absWorkingDir: root });
|
|
@@ -31449,11 +31455,11 @@ async function loadConfig(root) {
|
|
|
31449
31455
|
}
|
|
31450
31456
|
function sdkRunner(root) {
|
|
31451
31457
|
const lookup = createRequire(join15(root, "package.json")).resolve.paths("@backifydev/sdk") ?? [];
|
|
31452
|
-
const manifest = lookup.map((directory) => join15(directory, "@backifydev", "sdk", "package.json")).find((path) =>
|
|
31458
|
+
const manifest = lookup.map((directory) => join15(directory, "@backifydev", "sdk", "package.json")).find((path) => existsSync13(path));
|
|
31453
31459
|
if (!manifest) throw new ProjectError("@backifydev/sdk is not installed. Run npm install.");
|
|
31454
31460
|
const version2 = JSON.parse(readFileSync18(manifest, "utf8")).version;
|
|
31455
31461
|
const runner = join15(dirname6(manifest), "dist", "app", "run.js");
|
|
31456
|
-
if (!
|
|
31462
|
+
if (!existsSync13(runner)) throw new ProjectError(`The installed @backifydev/sdk ${version2} does not include backify-run. Update it with npm install @backifydev/sdk@latest.`);
|
|
31457
31463
|
return { runner, version: version2 };
|
|
31458
31464
|
}
|
|
31459
31465
|
async function bundleServer(root, entry, outName = "server.mjs") {
|
|
@@ -32029,7 +32035,7 @@ __export(lock_exports, {
|
|
|
32029
32035
|
usedCapabilities: () => usedCapabilities
|
|
32030
32036
|
});
|
|
32031
32037
|
import { createHash as createHash4 } from "node:crypto";
|
|
32032
|
-
import { existsSync as
|
|
32038
|
+
import { existsSync as existsSync14, readdirSync as readdirSync5, readFileSync as readFileSync20, writeFileSync as writeFileSync12 } from "node:fs";
|
|
32033
32039
|
import { join as join17 } from "node:path";
|
|
32034
32040
|
function usedCapabilities(root, files) {
|
|
32035
32041
|
const sources = files.filter((file) => /\.[cm]?[jt]sx?$/.test(file)).map((file) => ({ path: file, content: readFileSync20(join17(root, file), "utf8") }));
|
|
@@ -32037,7 +32043,7 @@ function usedCapabilities(root, files) {
|
|
|
32037
32043
|
}
|
|
32038
32044
|
function migrationDigests(root, config2) {
|
|
32039
32045
|
const directory = join17(root, config2.database?.migrations ?? "db/migrations");
|
|
32040
|
-
if (!
|
|
32046
|
+
if (!existsSync14(directory)) return [];
|
|
32041
32047
|
return readdirSync5(directory).filter((f) => f.endsWith(".sql")).sort().map((file) => ({ file, sha256: createHash4("sha256").update(withLfLineEndings(readFileSync20(join17(directory, file)))).digest("hex") }));
|
|
32042
32048
|
}
|
|
32043
32049
|
function withLfLineEndings(content) {
|
|
@@ -32134,7 +32140,7 @@ function lockSession(session) {
|
|
|
32134
32140
|
}
|
|
32135
32141
|
function personalDataWarnings(root, config2, declared) {
|
|
32136
32142
|
const directory = join17(root, config2.database?.migrations ?? "db/migrations");
|
|
32137
|
-
const files =
|
|
32143
|
+
const files = existsSync14(directory) ? readdirSync5(directory).filter((f) => f.endsWith(".sql")).sort().map((file) => ({ file: (config2.database?.migrations ?? "db/migrations") + "/" + file, sql: readFileSync20(join17(directory, file), "utf8") })) : [];
|
|
32138
32144
|
const schema = scanMigrations(files);
|
|
32139
32145
|
const drift = personalDataDrift(declared, new Map([...schema.tables].map(([table, columns]) => [table, columns.map((column) => column.name)])));
|
|
32140
32146
|
const unsure = (name2) => schema.uncertain.has(name2.split(".")[0]) ? " (the migrations change it in ways the scan cannot follow; check it)" : "";
|
|
@@ -32161,7 +32167,7 @@ async function lockCommand(root, options = {}) {
|
|
|
32161
32167
|
return 1;
|
|
32162
32168
|
}
|
|
32163
32169
|
const path = join17(root, LOCKFILE_NAME);
|
|
32164
|
-
const current =
|
|
32170
|
+
const current = existsSync14(path) ? readFileSync20(path, "utf8").replace(/\r\n/g, "\n") : void 0;
|
|
32165
32171
|
if (options.check) {
|
|
32166
32172
|
if (current !== text2) {
|
|
32167
32173
|
console.error(`${LOCKFILE_NAME} is out of date. Run \`backify lock\` and commit the result.`);
|
|
@@ -32195,7 +32201,7 @@ __export(check_exports, {
|
|
|
32195
32201
|
checkCommand: () => checkCommand
|
|
32196
32202
|
});
|
|
32197
32203
|
import { spawn as spawn3 } from "node:child_process";
|
|
32198
|
-
import { existsSync as
|
|
32204
|
+
import { existsSync as existsSync15, readFileSync as readFileSync21 } from "node:fs";
|
|
32199
32205
|
import { join as join18 } from "node:path";
|
|
32200
32206
|
function runScript(root, script) {
|
|
32201
32207
|
return new Promise((resolve10) => {
|
|
@@ -32226,7 +32232,7 @@ backify check failed: npm run ${script} exited with ${code}`);
|
|
|
32226
32232
|
return 1;
|
|
32227
32233
|
}
|
|
32228
32234
|
const path = join18(root, LOCKFILE_NAME);
|
|
32229
|
-
const current =
|
|
32235
|
+
const current = existsSync15(path) ? readFileSync21(path, "utf8").replace(/\r\n/g, "\n") : void 0;
|
|
32230
32236
|
if (current !== text2) {
|
|
32231
32237
|
console.error(`
|
|
32232
32238
|
backify check failed: ${LOCKFILE_NAME} is ${current === void 0 ? "missing" : "out of date"}. Run \`backify lock\` and commit it.`);
|
|
@@ -32254,7 +32260,7 @@ var init_check = __esm({
|
|
|
32254
32260
|
|
|
32255
32261
|
// src/app/local-gateway.ts
|
|
32256
32262
|
import { createHmac, generateKeyPairSync, randomBytes as randomBytes4, sign as rsaSign, timingSafeEqual } from "node:crypto";
|
|
32257
|
-
import { createReadStream, existsSync as
|
|
32263
|
+
import { createReadStream, existsSync as existsSync16, mkdirSync as mkdirSync6, readdirSync as readdirSync6, readFileSync as readFileSync22, rmSync as rmSync4, statSync as statSync2, writeFileSync as writeFileSync13 } from "node:fs";
|
|
32258
32264
|
import { createServer as createServer4, request as httpRequest } from "node:http";
|
|
32259
32265
|
import { connect } from "node:net";
|
|
32260
32266
|
import { dirname as dirname7, join as join19, relative as relative3, resolve as resolve7, sep } from "node:path";
|
|
@@ -32420,8 +32426,8 @@ function startGateway(options) {
|
|
|
32420
32426
|
req.pipe(upstream);
|
|
32421
32427
|
}
|
|
32422
32428
|
function sendFile(res, path, contentType2) {
|
|
32423
|
-
if (!
|
|
32424
|
-
const meta2 =
|
|
32429
|
+
if (!existsSync16(path) || !statSync2(path).isFile()) return json5(res, 404, { error: { code: "not_found", message: "Not found" } });
|
|
32430
|
+
const meta2 = existsSync16(path + ".meta.json") ? JSON.parse(readFileSync22(path + ".meta.json", "utf8")) : {};
|
|
32425
32431
|
res.writeHead(200, { "content-type": contentType2 ?? meta2.contentType ?? "application/octet-stream" });
|
|
32426
32432
|
createReadStream(path).pipe(res);
|
|
32427
32433
|
}
|
|
@@ -32519,7 +32525,7 @@ function startGateway(options) {
|
|
|
32519
32525
|
const prefix = url2.searchParams.get("prefix") ?? "";
|
|
32520
32526
|
const files = [];
|
|
32521
32527
|
const walk2 = (dir) => {
|
|
32522
|
-
if (
|
|
32528
|
+
if (existsSync16(dir)) for (const name2 of readdirSync6(dir)) {
|
|
32523
32529
|
const p = join19(dir, name2);
|
|
32524
32530
|
if (statSync2(p).isDirectory()) walk2(p);
|
|
32525
32531
|
else if (!name2.endsWith(".meta.json")) files.push(relative3(storageDir, p).replace(/\\/g, "/"));
|
|
@@ -32584,11 +32590,12 @@ var init_local_gateway = __esm({
|
|
|
32584
32590
|
var dev_exports = {};
|
|
32585
32591
|
__export(dev_exports, {
|
|
32586
32592
|
devCommand: () => devCommand,
|
|
32593
|
+
localWorkloads: () => localWorkloads,
|
|
32587
32594
|
resolveGatewayPort: () => resolveGatewayPort
|
|
32588
32595
|
});
|
|
32589
32596
|
import { spawn as spawn4 } from "node:child_process";
|
|
32590
32597
|
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
32591
|
-
import { existsSync as
|
|
32598
|
+
import { existsSync as existsSync17, readFileSync as readFileSync23, watch } from "node:fs";
|
|
32592
32599
|
import { join as join20, resolve as resolve8 } from "node:path";
|
|
32593
32600
|
import { context } from "esbuild";
|
|
32594
32601
|
function prefixOutput(child, label, code) {
|
|
@@ -32615,18 +32622,29 @@ function prettyLog(line2) {
|
|
|
32615
32622
|
}
|
|
32616
32623
|
function localSecrets(root) {
|
|
32617
32624
|
const path = join20(root, ".backify", "secrets.local.json");
|
|
32618
|
-
if (!
|
|
32625
|
+
if (!existsSync17(path)) return {};
|
|
32619
32626
|
const values = JSON.parse(readFileSync23(path, "utf8"));
|
|
32620
32627
|
return Object.fromEntries(Object.entries(values).map(([k, v]) => ["BACKIFY_SECRET_" + k, String(v)]));
|
|
32621
32628
|
}
|
|
32629
|
+
async function localWorkloads(root, config2, describe2 = generateLockfile) {
|
|
32630
|
+
if (!config2.server) return { database: false, worker: false };
|
|
32631
|
+
try {
|
|
32632
|
+
const { lockfile } = await describe2(root);
|
|
32633
|
+
return { database: lockfileNeedsDatabase(lockfile), worker: lockfileNeedsWorker(lockfile) };
|
|
32634
|
+
} catch (error2) {
|
|
32635
|
+
return { database: true, worker: true, reason: (error2 instanceof Error ? error2.message : String(error2)).split("\n")[0] };
|
|
32636
|
+
}
|
|
32637
|
+
}
|
|
32622
32638
|
async function devCommand(rootArg, options = {}) {
|
|
32623
32639
|
const root = resolve8(rootArg);
|
|
32624
32640
|
const config2 = await loadConfig(root);
|
|
32625
32641
|
const { runner } = sdkRunner(root);
|
|
32626
32642
|
const capabilities = configuredCapabilities(config2);
|
|
32627
|
-
const needsDatabase = Boolean(config2.server);
|
|
32628
32643
|
say("backify", `Starting ${config2.app.name} (${config2.kind})`, 35);
|
|
32629
|
-
const
|
|
32644
|
+
const needs = await localWorkloads(root, config2);
|
|
32645
|
+
if (needs.reason) say("backify", `Could not describe the server (${needs.reason}); starting PostgreSQL and the worker in case the app needs them.`, 33);
|
|
32646
|
+
else if (config2.server && !needs.database) say("db", "No database: the app declares no database, jobs, schedules or events, so PostgreSQL is not started (as in the cloud). Restart backify dev after adding them.", 34);
|
|
32647
|
+
const database = needs.database ? await startLocalDatabase(root, config2.database?.extensions) : void 0;
|
|
32630
32648
|
if (database) say("db", `PostgreSQL ${database.installation.version} from ${database.installation.bin} on 127.0.0.1:${database.port} (data in .backify/dev/postgres)`, 34);
|
|
32631
32649
|
const gatewayPort = await resolveGatewayPort(options.port);
|
|
32632
32650
|
const identity = createDevIdentity("local", "local");
|
|
@@ -32687,7 +32705,7 @@ async function devCommand(rootArg, options = {}) {
|
|
|
32687
32705
|
web = start("web", [bundle], { ...baseEnv, PORT: String(port), HOST: "127.0.0.1", BACKIFY_PROCESS_ROLE: "web" }, "web", 32);
|
|
32688
32706
|
webPort = port;
|
|
32689
32707
|
}
|
|
32690
|
-
worker = start("worker", [bundle], { ...baseEnv, BACKIFY_PROCESS_ROLE: "worker", BACKIFY_WORKER_IDLE_SECONDS: String(10 ** 9) }, "worker", 35);
|
|
32708
|
+
if (needs.worker) worker = start("worker", [bundle], { ...baseEnv, BACKIFY_PROCESS_ROLE: "worker", BACKIFY_WORKER_IDLE_SECONDS: String(10 ** 9) }, "worker", 35);
|
|
32691
32709
|
});
|
|
32692
32710
|
};
|
|
32693
32711
|
const builder = config2.server ? await context({
|
|
@@ -32714,7 +32732,7 @@ async function devCommand(rootArg, options = {}) {
|
|
|
32714
32732
|
}) : void 0;
|
|
32715
32733
|
await builder?.watch();
|
|
32716
32734
|
const migrationsDir = join20(root, config2.database?.migrations ?? "db/migrations");
|
|
32717
|
-
const migrationWatcher = database &&
|
|
32735
|
+
const migrationWatcher = database && existsSync17(migrationsDir) ? watch(migrationsDir, () => restart()) : void 0;
|
|
32718
32736
|
let frontendPort;
|
|
32719
32737
|
if (config2.kind === "web" && config2.frontend) {
|
|
32720
32738
|
frontendPort = await freePort(5173);
|
|
@@ -32741,6 +32759,7 @@ var init_dev = __esm({
|
|
|
32741
32759
|
"src/app/dev.ts"() {
|
|
32742
32760
|
"use strict";
|
|
32743
32761
|
init_dist();
|
|
32762
|
+
init_lock();
|
|
32744
32763
|
init_local_postgres();
|
|
32745
32764
|
init_local_gateway();
|
|
32746
32765
|
init_project();
|
|
@@ -32845,7 +32864,7 @@ __export(handoff_exports, {
|
|
|
32845
32864
|
validSecretName: () => validSecretName
|
|
32846
32865
|
});
|
|
32847
32866
|
import { createHash as createHash5 } from "node:crypto";
|
|
32848
|
-
import { existsSync as
|
|
32867
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync7, writeFileSync as writeFileSync14 } from "node:fs";
|
|
32849
32868
|
import { dirname as dirname8, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve9, sep as sep2 } from "node:path";
|
|
32850
32869
|
function extractSettings(args2) {
|
|
32851
32870
|
const rest = [], settings = {};
|
|
@@ -32956,7 +32975,7 @@ async function runFoundation(call2, prefix, out) {
|
|
|
32956
32975
|
{ path: resolve9(root, "app.parameters.json"), content: plan.parameters }
|
|
32957
32976
|
];
|
|
32958
32977
|
if (includeOwnerRuntime) files.push({ path: resolve9(root, "owner-runtime.bicep"), content: ownerRuntimeTemplate });
|
|
32959
|
-
const existing = files.find((file) =>
|
|
32978
|
+
const existing = files.find((file) => existsSync18(file.path));
|
|
32960
32979
|
if (existing) throw new CommandError("A foundation file already exists. Choose another directory to preserve it.", "handoff_foundation_file_exists", { path: existing.path });
|
|
32961
32980
|
mkdirSync7(root, { recursive: true });
|
|
32962
32981
|
for (const file of files) writeFileSync14(file.path, file.content, { encoding: "utf8", flag: "wx" });
|
|
@@ -33434,12 +33453,13 @@ function upgradeSdk(root = process.cwd(), suppliedRunner) {
|
|
|
33434
33453
|
|
|
33435
33454
|
// src/environment.ts
|
|
33436
33455
|
init_dist();
|
|
33456
|
+
init_workspace();
|
|
33437
33457
|
init_local_postgres();
|
|
33438
33458
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
33439
33459
|
import { randomUUID } from "node:crypto";
|
|
33440
|
-
import { readFileSync as
|
|
33460
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, unlinkSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
33441
33461
|
import { createServer as createServer2 } from "node:http";
|
|
33442
|
-
import { join as
|
|
33462
|
+
import { join as join5, resolve } from "node:path";
|
|
33443
33463
|
function classifyEnvironmentFailure(error2) {
|
|
33444
33464
|
const value = error2;
|
|
33445
33465
|
const code = value?.code;
|
|
@@ -33495,13 +33515,13 @@ async function probeEndpoint(url2, transport = fetch) {
|
|
|
33495
33515
|
}
|
|
33496
33516
|
function workspaceProbe(root) {
|
|
33497
33517
|
const directory = resolve(root);
|
|
33498
|
-
const filename =
|
|
33518
|
+
const filename = join5(directory, ".backify-environment-" + randomUUID());
|
|
33499
33519
|
const content = randomUUID();
|
|
33500
33520
|
let created = false;
|
|
33501
33521
|
try {
|
|
33502
33522
|
writeFileSync4(filename, content, { flag: "wx" });
|
|
33503
33523
|
created = true;
|
|
33504
|
-
if (
|
|
33524
|
+
if (readFileSync5(filename, "utf8") !== content) throw new Error("Workspace read/write failed.");
|
|
33505
33525
|
} finally {
|
|
33506
33526
|
if (created) unlinkSync(filename);
|
|
33507
33527
|
}
|
|
@@ -33524,10 +33544,21 @@ async function localhostProbe() {
|
|
|
33524
33544
|
if (server.listening) await new Promise((accept) => server.close(() => accept()));
|
|
33525
33545
|
}
|
|
33526
33546
|
}
|
|
33547
|
+
function postgresNeeded(root) {
|
|
33548
|
+
const path = join5(root, LOCKFILE_NAME);
|
|
33549
|
+
if (!workspaceHasApp(root) || !existsSync5(path)) return { needed: true };
|
|
33550
|
+
try {
|
|
33551
|
+
const lockfile = JSON.parse(readFileSync5(path, "utf8"));
|
|
33552
|
+
return lockfileNeedsDatabase(lockfile) ? { needed: true } : { needed: false, detail: `Not needed: ${LOCKFILE_NAME} declares no database, jobs, schedules or events, so backify dev and the cloud run this app without PostgreSQL.` };
|
|
33553
|
+
} catch {
|
|
33554
|
+
return { needed: true };
|
|
33555
|
+
}
|
|
33556
|
+
}
|
|
33527
33557
|
function environmentProbes(root) {
|
|
33528
33558
|
return {
|
|
33529
33559
|
nodeVersion: process.versions.node,
|
|
33530
33560
|
postgres: () => postgresInstallation(),
|
|
33561
|
+
postgresNeeded: () => postgresNeeded(root),
|
|
33531
33562
|
command: (name2) => {
|
|
33532
33563
|
const windowsNpm = name2 === "npm" && process.platform === "win32";
|
|
33533
33564
|
const executable = windowsNpm ? process.env.ComSpec ?? "cmd.exe" : name2;
|
|
@@ -33558,7 +33589,9 @@ async function diagnoseEnvironment(root = process.cwd(), options = {}, probes =
|
|
|
33558
33589
|
await check("git", false, () => probes.command("git"));
|
|
33559
33590
|
await check("workspace", true, probes.workspace);
|
|
33560
33591
|
await check("localhost", true, probes.localhost);
|
|
33561
|
-
|
|
33592
|
+
const need = probes.postgresNeeded?.();
|
|
33593
|
+
if (need && !need.needed) checks.push({ name: "postgresql", required: false, status: "passed", detail: need.detail });
|
|
33594
|
+
else if (probes.postgres) {
|
|
33562
33595
|
const recovery = "Install PostgreSQL 16+ for backify dev (https://www.postgresql.org/download/). Set BACKIFY_POSTGRES_BIN to its bin directory only when it is installed somewhere backify dev does not look.";
|
|
33563
33596
|
try {
|
|
33564
33597
|
const found = probes.postgres();
|
|
@@ -33642,11 +33675,12 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
33642
33675
|
var integrationConnectHelp = `backify integrations connect <provider> [--app <application>] [--definition <UUID>] [--environment <UUID|name>] [--operations <comma-separated-IDs>] [--mode application|user]
|
|
33643
33676
|
backify integrations connect --adoption <UUID> [--app <application>]
|
|
33644
33677
|
Options: --no-browser --no-wait --timeout <seconds, 1-1800> --json
|
|
33645
|
-
Requests read operations by default.
|
|
33678
|
+
Requests read operations by default. The reviewer may approve fewer; the result lists approvedOperations and any declinedOperations.
|
|
33679
|
+
Browser review and consent remain required; provider credentials stay server-side.
|
|
33646
33680
|
Pending setup returns exit code 2. Rerun with --adoption to resume.`;
|
|
33647
33681
|
var uuid2 = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
33648
33682
|
function validateStatus(status) {
|
|
33649
|
-
if (!uuid2.test(status.id) || !["application", "user"].includes(status.mode) || !["review_required", "connection_required", "ready", "reconnect_required", "blocked"].includes(status.state) || status.installationId !== null && !uuid2.test(status.installationId) || status.state === "ready" && !status.installationId) throw new Error("The server returned invalid integration readiness metadata.");
|
|
33683
|
+
if (!uuid2.test(status.id) || !["application", "user"].includes(status.mode) || !["review_required", "connection_required", "ready", "reconnect_required", "blocked"].includes(status.state) || status.installationId !== null && !uuid2.test(status.installationId) || status.state === "ready" && !status.installationId || [status.approvedOperations, status.declinedOperations].some((value) => value != null && (!Array.isArray(value) || value.some((item) => typeof item !== "string" || !/^[A-Za-z0-9_.:-]{1,128}$/.test(item))))) throw new Error("The server returned invalid integration readiness metadata.");
|
|
33650
33684
|
}
|
|
33651
33685
|
function portalOrigin(value) {
|
|
33652
33686
|
const url2 = new URL(value);
|
|
@@ -33700,6 +33734,9 @@ async function connectIntegration(call2, options) {
|
|
|
33700
33734
|
reviewUrl: link,
|
|
33701
33735
|
nextAction: status.nextAction,
|
|
33702
33736
|
...reason ? { reason } : {},
|
|
33737
|
+
...status.approvedOperations ? { approvedOperations: status.approvedOperations } : {},
|
|
33738
|
+
// The reviewer can approve fewer operations than requested; never call a declined one.
|
|
33739
|
+
...status.declinedOperations?.length ? { declinedOperations: status.declinedOperations } : {},
|
|
33703
33740
|
...binding ? { bindings: binding.source } : {},
|
|
33704
33741
|
...approved && status.mode === "user" ? { userConnectionFlowRequired: true } : {}
|
|
33705
33742
|
};
|
|
@@ -34255,13 +34292,13 @@ function reconnectingApiClient(session, reconnect2, transport = fetch) {
|
|
|
34255
34292
|
init_development();
|
|
34256
34293
|
init_setup();
|
|
34257
34294
|
init_dist();
|
|
34258
|
-
import { readFileSync as readFileSync24, existsSync as
|
|
34295
|
+
import { readFileSync as readFileSync24, existsSync as existsSync19, rmSync as rmSync5 } from "node:fs";
|
|
34259
34296
|
import { homedir as homedir3 } from "node:os";
|
|
34260
34297
|
import { join as join21 } from "node:path";
|
|
34261
34298
|
import { spawn as spawn5 } from "node:child_process";
|
|
34262
34299
|
var [command, ...args] = process.argv.slice(2);
|
|
34263
34300
|
var configPath = join21(homedir3(), ".backify.json");
|
|
34264
|
-
var userConfig = command !== "mcp" &&
|
|
34301
|
+
var userConfig = command !== "mcp" && existsSync19(configPath) ? JSON.parse(readFileSync24(configPath, "utf8")) : {};
|
|
34265
34302
|
function callCredential() {
|
|
34266
34303
|
let appId = option("--app");
|
|
34267
34304
|
if (!appId && hasProjectConfig(process.cwd())) appId = projectApplication();
|
|
@@ -34673,7 +34710,7 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
34673
34710
|
}
|
|
34674
34711
|
case "dev": {
|
|
34675
34712
|
const port = portOption("--port");
|
|
34676
|
-
if (!
|
|
34713
|
+
if (!existsSync19(join21(process.cwd(), "backify.config.ts"))) throw new Error("backify dev runs apps with a backify.config.ts. Create one with backify new <name>.");
|
|
34677
34714
|
const { devCommand: devCommand2 } = await Promise.resolve().then(() => (init_dev(), dev_exports));
|
|
34678
34715
|
process.exitCode = await devCommand2(process.cwd(), { port });
|
|
34679
34716
|
break;
|
|
@@ -34747,7 +34784,7 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
|
|
|
34747
34784
|
userConfig.sessions[key] ??= session;
|
|
34748
34785
|
saveUserConfig(configPath, userConfig);
|
|
34749
34786
|
if (args.includes("--clone")) await cloneProject(client, appId);
|
|
34750
|
-
else if (
|
|
34787
|
+
else if (existsSync19(join21(process.cwd(), ".git"))) {
|
|
34751
34788
|
const update = await pullProject(client, appId);
|
|
34752
34789
|
console.log(JSON.stringify(update, null, 2));
|
|
34753
34790
|
if (update.status === "blocked") throw new Error(update.reason);
|