@backifydev/cli 0.3.17 → 0.3.18
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 +18 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35846,7 +35846,7 @@ import { hostname, platform, release, arch } from "node:os";
|
|
|
35846
35846
|
// package.json
|
|
35847
35847
|
var package_default = {
|
|
35848
35848
|
name: "@backifydev/cli",
|
|
35849
|
-
version: "0.3.
|
|
35849
|
+
version: "0.3.18",
|
|
35850
35850
|
description: "Command-line setup and diagnostics for Backify applications",
|
|
35851
35851
|
type: "module",
|
|
35852
35852
|
bin: {
|
|
@@ -36693,7 +36693,7 @@ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as re
|
|
|
36693
36693
|
import { dirname as dirname13, isAbsolute as isAbsolute14, join as join16, relative as relative8, resolve as resolve19 } from "node:path";
|
|
36694
36694
|
|
|
36695
36695
|
// src/local-development.ts
|
|
36696
|
-
import { context as context2 } from "esbuild";
|
|
36696
|
+
import { context as context2, formatMessagesSync } from "esbuild";
|
|
36697
36697
|
import { spawn as spawn4 } from "node:child_process";
|
|
36698
36698
|
import { randomBytes as randomBytes6, randomUUID as randomUUID10, createHash as createHash13 } from "node:crypto";
|
|
36699
36699
|
import { existsSync as existsSync13, lstatSync as lstatSync15, mkdirSync as mkdirSync6, readFileSync as readFileSync21, realpathSync as realpathSync5, writeFileSync as writeFileSync11, unlinkSync as unlinkSync5 } from "node:fs";
|
|
@@ -39926,7 +39926,7 @@ async function stopFrontend(child) {
|
|
|
39926
39926
|
else child.kill("SIGTERM");
|
|
39927
39927
|
});
|
|
39928
39928
|
}
|
|
39929
|
-
async function startLocalFrontend(prepared, port, backendUrl) {
|
|
39929
|
+
async function startLocalFrontend(prepared, port, backendUrl, onDiagnostic) {
|
|
39930
39930
|
if (prepared.adapter === "static") return startLocalStaticFrontend(prepared.directory, port, backendUrl);
|
|
39931
39931
|
const assignedPort = await allocateLocalPort(port);
|
|
39932
39932
|
const url2 = "http://127.0.0.1:" + assignedPort;
|
|
@@ -39936,7 +39936,11 @@ async function startLocalFrontend(prepared, port, backendUrl) {
|
|
|
39936
39936
|
const denied = [".env", ".env.*", "*.{crt,pem}", "**/.git/**", "**/.backify", "**/.backify/**", "**/.local-secrets", "**/.local-secrets/**", ...prepared.privateFiles.map((filename2) => filename2.replaceAll("\\", "/"))];
|
|
39937
39937
|
const settings = { moduleUrl: pathToFileURL(prepared.modulePath).href, directory: prepared.directory, port: assignedPort, denied, privateFiles: prepared.privateFiles.map((filename2) => filename2.replaceAll("\\", "/")) };
|
|
39938
39938
|
const launcher = "const settings=" + JSON.stringify(settings) + ";\n" + protectedFrontendSource;
|
|
39939
|
-
const child = spawn3(process.execPath, ["--input-type=module", "--eval", launcher], { cwd: prepared.directory, windowsHide: true, stdio: ["ignore", 2, 2, "ipc"], env: environment });
|
|
39939
|
+
const child = spawn3(process.execPath, ["--input-type=module", "--eval", launcher], { cwd: prepared.directory, windowsHide: true, stdio: ["ignore", onDiagnostic ? "pipe" : 2, onDiagnostic ? "pipe" : 2, "ipc"], env: environment });
|
|
39940
|
+
if (onDiagnostic) {
|
|
39941
|
+
child.stdout?.on("data", (chunk) => onDiagnostic(chunk.toString()));
|
|
39942
|
+
child.stderr?.on("data", (chunk) => onDiagnostic(chunk.toString()));
|
|
39943
|
+
}
|
|
39940
39944
|
let failed = false;
|
|
39941
39945
|
child.on("error", () => {
|
|
39942
39946
|
failed = true;
|
|
@@ -40429,7 +40433,7 @@ async function startLocalDevelopment(options = {}) {
|
|
|
40429
40433
|
let frontend;
|
|
40430
40434
|
try {
|
|
40431
40435
|
if (mode === "full") services = await startLocalServices(root, manifest, { ...options, jobArtifacts, jobIdentityScope: jobWorker?.authTrust?.scope });
|
|
40432
|
-
if (preparedFrontend) frontend = await startLocalFrontend(preparedFrontend, options.frontendPort, backendUrl);
|
|
40436
|
+
if (preparedFrontend) frontend = await startLocalFrontend(preparedFrontend, options.frontendPort, backendUrl, options.onDiagnostic);
|
|
40433
40437
|
} catch (error2) {
|
|
40434
40438
|
try {
|
|
40435
40439
|
await services?.stop();
|
|
@@ -40485,7 +40489,11 @@ async function startLocalDevelopment(options = {}) {
|
|
|
40485
40489
|
await stopChild(child);
|
|
40486
40490
|
if (stopping) return;
|
|
40487
40491
|
const version2 = createHash13("sha256").update(readFileSync21(outfile)).update(services?.configurationFingerprint ?? "lightweight").digest("hex");
|
|
40488
|
-
const worker = spawn4(process.execPath, [outfile], { cwd: root, windowsHide: true, stdio: ["ignore", 2, 2, "ipc"], env: { ...process.env, ...identityEnvironment(), BACKIFY_LOCAL_SECRETS_IPC: "1", HOST: "127.0.0.1", ...backendPort === void 0 ? {} : { PORT: String(backendPort) }, BACKIFY_LOCAL_BACKEND_URL: backendUrl ?? "", BACKIFY_LOCAL_FRONTEND_URL: frontend?.url ?? "", BACKIFY_LOCAL_DATABASE_ENABLED: manifest.capabilities.database && manifest.capabilities.database.enabled !== false ? "1" : "0", BACKIFY_LOCAL_STORAGE_ENABLED: manifest.capabilities.storage && manifest.capabilities.storage.enabled !== false ? "1" : "0", BACKIFY_LOCAL_STORAGE_BUCKETS: JSON.stringify(manifest.capabilities.storage?.buckets?.map((bucket) => bucket.name) ?? (manifest.capabilities.storage ? ["default"] : [])), BACKIFY_LOCAL_TOKEN: token, BACKIFY_LOCAL_PORT: String(dashboardPort), BACKIFY_LOCAL_STATE: join15(directory2, "state.json"), BACKIFY_LOCAL_VERSION: version2, BACKIFY_LOCAL_HCR_URL: services?.runtimeUrl ?? "", BACKIFY_LOCAL_WORKLOAD_TOKEN_PATH: services?.tokenPath ?? "", BACKIFY_LOCAL_DATABASE: services ? services.database ? "postgres" : "disabled" : "document-emulator", BACKIFY_LOCAL_EVENTS: services?.events ? "postgres-events" : services ? "disabled" : "snapshot-emulator", BACKIFY_LOCAL_STORAGE: services ? services.storage ? "filesystem" : "disabled" : "snapshot-emulator" } });
|
|
40492
|
+
const worker = spawn4(process.execPath, [outfile], { cwd: root, windowsHide: true, stdio: ["ignore", options.onDiagnostic ? "pipe" : 2, options.onDiagnostic ? "pipe" : 2, "ipc"], env: { ...process.env, ...identityEnvironment(), BACKIFY_LOCAL_SECRETS_IPC: "1", HOST: "127.0.0.1", ...backendPort === void 0 ? {} : { PORT: String(backendPort) }, BACKIFY_LOCAL_BACKEND_URL: backendUrl ?? "", BACKIFY_LOCAL_FRONTEND_URL: frontend?.url ?? "", BACKIFY_LOCAL_DATABASE_ENABLED: manifest.capabilities.database && manifest.capabilities.database.enabled !== false ? "1" : "0", BACKIFY_LOCAL_STORAGE_ENABLED: manifest.capabilities.storage && manifest.capabilities.storage.enabled !== false ? "1" : "0", BACKIFY_LOCAL_STORAGE_BUCKETS: JSON.stringify(manifest.capabilities.storage?.buckets?.map((bucket) => bucket.name) ?? (manifest.capabilities.storage ? ["default"] : [])), BACKIFY_LOCAL_TOKEN: token, BACKIFY_LOCAL_PORT: String(dashboardPort), BACKIFY_LOCAL_STATE: join15(directory2, "state.json"), BACKIFY_LOCAL_VERSION: version2, BACKIFY_LOCAL_HCR_URL: services?.runtimeUrl ?? "", BACKIFY_LOCAL_WORKLOAD_TOKEN_PATH: services?.tokenPath ?? "", BACKIFY_LOCAL_DATABASE: services ? services.database ? "postgres" : "disabled" : "document-emulator", BACKIFY_LOCAL_EVENTS: services?.events ? "postgres-events" : services ? "disabled" : "snapshot-emulator", BACKIFY_LOCAL_STORAGE: services ? services.storage ? "filesystem" : "disabled" : "snapshot-emulator" } });
|
|
40493
|
+
if (options.onDiagnostic) {
|
|
40494
|
+
worker.stdout?.on("data", (chunk) => options.onDiagnostic(chunk.toString()));
|
|
40495
|
+
worker.stderr?.on("data", (chunk) => options.onDiagnostic(chunk.toString()));
|
|
40496
|
+
}
|
|
40489
40497
|
child = worker;
|
|
40490
40498
|
worker.send({ type: "local-secrets", secrets }, (error2) => {
|
|
40491
40499
|
if (error2) {
|
|
@@ -40519,7 +40527,7 @@ async function startLocalDevelopment(options = {}) {
|
|
|
40519
40527
|
});
|
|
40520
40528
|
};
|
|
40521
40529
|
try {
|
|
40522
|
-
buildContext = await context2({ absWorkingDir: root, stdin: { contents: localWorkerSource(resolve18(root, manifest.runtime.entrypoint)), resolveDir: root, sourcefile: "backify-local-worker.ts", loader: "ts" }, bundle: true, platform: "node", format: "esm", target: "node20", outfile, sourcemap: true, banner: { js: 'import { createRequire as __backifyCreateRequire } from "node:module"; var require = __backifyCreateRequire(import.meta.url);' }, plugins: [{ name: "backify-local-lifecycle", setup(build3) {
|
|
40530
|
+
buildContext = await context2({ logLevel: options.onDiagnostic ? "silent" : void 0, absWorkingDir: root, stdin: { contents: localWorkerSource(resolve18(root, manifest.runtime.entrypoint)), resolveDir: root, sourcefile: "backify-local-worker.ts", loader: "ts" }, bundle: true, platform: "node", format: "esm", target: "node20", outfile, sourcemap: true, banner: { js: 'import { createRequire as __backifyCreateRequire } from "node:module"; var require = __backifyCreateRequire(import.meta.url);' }, plugins: [{ name: "backify-local-lifecycle", setup(build3) {
|
|
40523
40531
|
build3.onLoad({ filter: /./, namespace: "file" }, (input) => {
|
|
40524
40532
|
if (input.path !== resolve18(root, manifest.runtime.entrypoint)) return;
|
|
40525
40533
|
try {
|
|
@@ -40532,6 +40540,9 @@ async function startLocalDevelopment(options = {}) {
|
|
|
40532
40540
|
return { contents: readFileSync21(input.path, "utf8"), loader: input.path.endsWith(".tsx") ? "tsx" : /\.(ts|mts|cts)$/.test(input.path) ? "ts" : input.path.endsWith(".jsx") ? "jsx" : "js", watchFiles: [join15(root, "backify.yaml")] };
|
|
40533
40541
|
});
|
|
40534
40542
|
build3.onEnd((result) => {
|
|
40543
|
+
if (options.onDiagnostic) {
|
|
40544
|
+
for (const kind of ["error", "warning"]) for (const message of formatMessagesSync(kind === "error" ? result.errors : result.warnings, { kind, color: false })) options.onDiagnostic(message);
|
|
40545
|
+
}
|
|
40535
40546
|
if (result.errors.length) rejectStartup(new Error("Local application build failed"));
|
|
40536
40547
|
else if (!stopping) restarting = restarting.then(restart).catch(() => {
|
|
40537
40548
|
rejectStartup(new Error("Local application restart failed"));
|